[embed] added share buttons config

This commit is contained in:
Maxim Kadushkin 2022-03-26 01:11:32 +03:00
parent ad26e55ef1
commit 3c5fc2e301
3 changed files with 31 additions and 4 deletions

View file

@ -57,6 +57,13 @@
$dlgShare.find('#btn-copyshort').on('click', copytext.bind(this, $dlgShare.find('#id-short-url')));
$dlgShare.find('.share-buttons > span').on('click', function(e){
const key = $(e.target).attr('data-name');
if ( config.btnsShare[key] && config.btnsShare[key].getUrl ) {
window.open(config.btnsShare[key].getUrl(appConfig.shareUrl, encodeURI(appConfig.docTitle)), '',
'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=300,width=600');
return;
}
var _url;
switch ($(e.target).attr('data-name')) {
case 'facebook':

View file

@ -53,9 +53,6 @@ common.view.modals = new(function() {
'<input id="id-short-url" class="form-control" type="text" readonly/>' +
'</div>' +
'<div class="share-buttons">' +
'<span class="svg big-facebook" data-name="facebook"></span>' +
'<span class="svg big-twitter" data-name="twitter"></span>' +
'<span class="svg big-email" data-name="email"></span>' +
'<div class="autotest" id="email" style="display: none"></div>' +
'</div>';
@ -73,9 +70,16 @@ common.view.modals = new(function() {
var _$dlg;
if (name == 'share') {
let _btns = '';
for (const key of Object.keys(config.btnsShare))
_btns += `<span class="svg big-${key}" data-name="${key}"></span>`;
let $sharebox = $(_tplbody_share);
$sharebox.eq(1).prepend(_btns);
_$dlg = $(tplDialog
.replace(/\{title}/, this.txtShare)
.replace(/\{body}/, _tplbody_share)
.replace(/\{body}/, $("<div>").append($sharebox).html())
.replace(/\{footer}/, '<button id="btn-copyshort" type="button" class="btn">' + this.txtCopy + '</button>'))
.appendTo(parent)
.attr('id', 'dlg-share');

View file

@ -246,6 +246,22 @@
});
</script>
<script>
window.config = {
btnsShare: {
'facebook': {
getUrl: (shareurl, title) => `https://www.facebook.com/sharer/sharer.php?u=${shareurl}&t=${encodeURI(title)}`
},
'twitter': {
url: ""
},
'email': {
url: ""
}
}
};
</script>
<!--application-->
<script type="text/javascript" src="../../common/locale.js"></script>
<script type="text/javascript" src="../../common/Gateway.js"></script>