diff options
author | Andrew Dolgov <[email protected]> | 2018-12-03 15:46:54 +0300 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2018-12-03 15:46:54 +0300 |
commit | 4cb3a601a0fbeb0bf98c932bd5af8a3cffa8ab64 (patch) | |
tree | ed3dae8894591be12287b3cce3ff5b4cc6d1ce0e /plugins/share | |
parent | cd0a39ea4cb7137aef5b225bdc4472d207a48e62 (diff) | |
parent | 98986ce066764158c045c3e23b69e98183b94236 (diff) |
Merge branch 'js-objects' into weblate-integration
Diffstat (limited to 'plugins/share')
-rw-r--r-- | plugins/share/init.php | 4 | ||||
-rw-r--r-- | plugins/share/share.js | 33 | ||||
-rw-r--r-- | plugins/share/share_prefs.js | 25 |
3 files changed, 30 insertions, 32 deletions
diff --git a/plugins/share/init.php b/plugins/share/init.php index 94571bb1b..6ac08b751 100644 --- a/plugins/share/init.php +++ b/plugins/share/init.php @@ -40,7 +40,7 @@ class Share extends Plugin { print "<p>" . __("You can disable all articles shared by unique URLs here.") . "</p>"; - print "<button class=\"btn-danger\" dojoType=\"dijit.form.Button\" onclick=\"return clearArticleAccessKeys()\">". + print "<button class=\"btn-danger\" dojoType=\"dijit.form.Button\" onclick=\"return Plugins.Share.clearKeys()\">". __('Unshare all articles')."</button> "; print "</p>"; @@ -74,7 +74,7 @@ class Share extends Plugin { return "<img id='SHARE-IMG-".$line['int_id']."' src=\"plugins/share/$img\" class='tagsPic' style=\"cursor : pointer\" - onclick=\"shareArticle(".$line['int_id'].")\" + onclick=\"Plugins.Share.shareArticle(".$line['int_id'].")\" title='".__('Share by URL')."'>"; } diff --git a/plugins/share/share.js b/plugins/share/share.js index 11748d8fe..7366c2aff 100644 --- a/plugins/share/share.js +++ b/plugins/share/share.js @@ -1,20 +1,20 @@ -function shareArticle(id) { - try { +Plugins.Share = { + shareArticle: function(id) { if (dijit.byId("shareArticleDlg")) dijit.byId("shareArticleDlg").destroyRecursive(); - var query = "backend.php?op=pluginhandler&plugin=share&method=shareArticle¶m=" + param_escape(id); + const query = "backend.php?op=pluginhandler&plugin=share&method=shareArticle¶m=" + encodeURIComponent(id); - dialog = new dijit.Dialog({ + const dialog = new dijit.Dialog({ id: "shareArticleDlg", title: __("Share article by URL"), style: "width: 600px", - newurl: function() { + newurl: function () { if (confirm(__("Generate new share URL for this article?"))) { - notify_progress("Trying to change URL...", true); + Notify.progress("Trying to change URL...", true); - const query = { op: "pluginhandler", plugin: "share", method: "newkey", id: id }; + const query = {op: "pluginhandler", plugin: "share", method: "newkey", id: id}; xhrJson("backend.php", query, (reply) => { if (reply) { @@ -34,22 +34,22 @@ function shareArticle(id) { const img = $("SHARE-IMG-" + id); if (img) img.src = img.src.replace("notshared.png", "share.png"); - notify(''); + Notify.close(); } else { - notify_error("Could not change URL."); + Notify.error("Could not change URL."); } } }); } }, - unshare: function() { + unshare: function () { if (confirm(__("Remove sharing for this article?"))) { - notify_progress("Trying to unshare...", true); + Notify.progress("Trying to unshare...", true); - const query = { op: "pluginhandler", plugin: "share", method: "unshare", id: id }; + const query = {op: "pluginhandler", plugin: "share", method: "unshare", id: id}; xhrPost("backend.php", query, () => { notify("Article unshared."); @@ -62,16 +62,15 @@ function shareArticle(id) { } }, - href: query}); + href: query + }); dialog.show(); const img = $("SHARE-IMG-" + id); if (img) img.src = img.src.replace("notshared.png", "share.png"); - - } catch (e) { - exception_error("shareArticle", e); } -} +}; + diff --git a/plugins/share/share_prefs.js b/plugins/share/share_prefs.js index 79ca37284..071a6667c 100644 --- a/plugins/share/share_prefs.js +++ b/plugins/share/share_prefs.js @@ -1,16 +1,15 @@ -function clearArticleAccessKeys() { - if (confirm(__("This will invalidate all previously shared article URLs. Continue?"))) { - notify_progress("Clearing URLs..."); - - const query = { op: "pluginhandler", plugin: "share", method: "clearArticleKeys" }; - - xhrPost("backend.php", query, () => { - notify_info("Shared URLs cleared."); - }); - } - - return false; -} +Plugins.Share = { + clearKeys: function() { + if (confirm(__("This will invalidate all previously shared article URLs. Continue?"))) { + Notify.progress("Clearing URLs..."); + const query = {op: "pluginhandler", plugin: "share", method: "clearArticleKeys"}; + xhrPost("backend.php", query, () => { + Notify.info("Shared URLs cleared."); + }); + } + return false; + } +}; |