Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,20 @@ import Sharee from 'sharee';

window.fcShareeConnector = {

create: function (container, optionsJson) {
this._updateXButtonLabel();
this._updateCopyDriverOnClick();
let parsedOptions = JSON.parse(optionsJson);
const sharee = new Sharee(container, parsedOptions);
},
create: function(container, optionsJson) {
this._configureDrivers();
let parsedOptions = JSON.parse(optionsJson);
const sharee = new Sharee(container, parsedOptions);
},

createWithCustomDrivers: function (container, optionsJson) {
this._updateXButtonLabel();
this._updateCopyDriverOnClick();
let parsedOptions = JSON.parse(optionsJson);
// add the custom drivers to the list of drivers
let drivers = parsedOptions.drivers.concat(container.customDrivers);
parsedOptions.drivers = drivers;
const sharee = new Sharee(container, parsedOptions);
},
createWithCustomDrivers: function(container, optionsJson) {
this._configureDrivers();
let parsedOptions = JSON.parse(optionsJson);
// add the custom drivers to the list of drivers
let drivers = parsedOptions.drivers.concat(container.customDrivers);
parsedOptions.drivers = drivers;
const sharee = new Sharee(container, parsedOptions);
},

addCustomDriver(container, customDriverJson) {
if (container.customDrivers == null) {
Expand Down Expand Up @@ -88,6 +86,34 @@ window.fcShareeConnector = {

Sharee.addDriver(name, f);
},

/**
* Configures Sharee drivers by applying required overrides and fixes.
*
* Includes workarounds for missing features and/or known issues in the base library.
* To be revisited if upstream issues are resolved.
*/
_configureDrivers() {
this._updateXButtonLabel();
this._updateSocialShareLinks();
this._updateCopyDriverOnClick();
},

/*
* Workaround because of issue https://github.com/parsagholipour/sharee/issues/8
* (to be removed when issue is fixed)
*/
_updateSocialShareLinks() {
Sharee.drivers['facebook'].prototype.getLink = function() {
return `https://facebook.com/sharer/sharer.php?u=${encodeURIComponent(this.options?.shareLink)}&t=${encodeURIComponent(this.options?.shareText)}`
}
Sharee.drivers['whatsapp'].prototype.getLink = function() {
return `https://wa.me?text=${encodeURIComponent(this.options?.shareText)} \n ${encodeURIComponent(this.options?.shareLink)}`
}
Sharee.drivers['linkedin'].prototype.getLink = function() {
return `https://www.linkedin.com/shareArticle?url=${encodeURIComponent(this.options?.shareLink)}`
}
},

/**
* Replaces onClick function on CopyDriver to take in consideration shareLink option
Expand Down