FEATURE: Make share button support custom javascript (#8090)
* FEATURE: Make share button support custom javascript * clean code * formatting * formatting
This commit is contained in:
parent
67a98946b8
commit
7129637279
|
@ -19,6 +19,11 @@
|
|||
return "http://twitter.com/intent/tweet?url=" + encodeURIComponent(link) + "&text=" + encodeURIComponent(title);
|
||||
},
|
||||
|
||||
// If provided, handle by custom javascript rather than default url open
|
||||
clickHandler: function(link, title){
|
||||
alert("Hello!")
|
||||
}
|
||||
|
||||
// If true, opens in a popup of `popupHeight` size. If false it's opened in a new tab
|
||||
shouldOpenInPopup: true,
|
||||
popupHeight: 265
|
||||
|
@ -48,23 +53,27 @@ export default {
|
|||
},
|
||||
|
||||
shareSource(source, data) {
|
||||
const url = source.generateUrl(data.url, data.title);
|
||||
const options = {
|
||||
menubar: "no",
|
||||
toolbar: "no",
|
||||
resizable: "yes",
|
||||
scrollbars: "yes",
|
||||
width: 600,
|
||||
height: source.popupHeight || 315
|
||||
};
|
||||
const stringOptions = Object.keys(options)
|
||||
.map(k => `${k}=${options[k]}`)
|
||||
.join(",");
|
||||
|
||||
if (source.shouldOpenInPopup) {
|
||||
window.open(url, "", stringOptions);
|
||||
if (source.clickHandler) {
|
||||
source.clickHandler(data.url, data.title);
|
||||
} else {
|
||||
window.open(url, "_blank");
|
||||
const url = source.generateUrl(data.url, data.title);
|
||||
const options = {
|
||||
menubar: "no",
|
||||
toolbar: "no",
|
||||
resizable: "yes",
|
||||
scrollbars: "yes",
|
||||
width: 600,
|
||||
height: source.popupHeight || 315
|
||||
};
|
||||
const stringOptions = Object.keys(options)
|
||||
.map(k => `${k}=${options[k]}`)
|
||||
.join(",");
|
||||
|
||||
if (source.shouldOpenInPopup) {
|
||||
window.open(url, "", stringOptions);
|
||||
} else {
|
||||
window.open(url, "_blank");
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
|
Loading…
Reference in New Issue