From 3c5fc2e3014569997214afd02b1c6b78ec316df7 Mon Sep 17 00:00:00 2001 From: Maxim Kadushkin Date: Sat, 26 Mar 2022 01:11:32 +0300 Subject: [PATCH] [embed] added share buttons config --- apps/common/embed/lib/controller/modals.js | 7 +++++++ apps/common/embed/lib/view/modals.js | 12 ++++++++---- apps/documenteditor/embed/index.html | 16 ++++++++++++++++ 3 files changed, 31 insertions(+), 4 deletions(-) diff --git a/apps/common/embed/lib/controller/modals.js b/apps/common/embed/lib/controller/modals.js index d8802955a..72d0bf361 100644 --- a/apps/common/embed/lib/controller/modals.js +++ b/apps/common/embed/lib/controller/modals.js @@ -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': diff --git a/apps/common/embed/lib/view/modals.js b/apps/common/embed/lib/view/modals.js index 8f9c9760d..1964fb1a8 100644 --- a/apps/common/embed/lib/view/modals.js +++ b/apps/common/embed/lib/view/modals.js @@ -53,9 +53,6 @@ common.view.modals = new(function() { '' + '' + '
' + - '' + - '' + - '' + '' + '
'; @@ -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 += ``; + + let $sharebox = $(_tplbody_share); + $sharebox.eq(1).prepend(_btns); + _$dlg = $(tplDialog .replace(/\{title}/, this.txtShare) - .replace(/\{body}/, _tplbody_share) + .replace(/\{body}/, $("
").append($sharebox).html()) .replace(/\{footer}/, '')) .appendTo(parent) .attr('id', 'dlg-share'); diff --git a/apps/documenteditor/embed/index.html b/apps/documenteditor/embed/index.html index b4ba894b1..cafdd2d2b 100644 --- a/apps/documenteditor/embed/index.html +++ b/apps/documenteditor/embed/index.html @@ -246,6 +246,22 @@ }); + +