From e76d1fb995e25d78f0131ac56660846b0e9ecb9a Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Mon, 3 Dec 2018 14:21:50 +0300 Subject: plugins: mail, mailto: remove code from global context --- plugins/mail/mail.js | 94 +++++++++++++++++++++++++++------------------------- 1 file changed, 49 insertions(+), 45 deletions(-) (limited to 'plugins/mail/mail.js') diff --git a/plugins/mail/mail.js b/plugins/mail/mail.js index 87e354b42..eb7b7e6b6 100644 --- a/plugins/mail/mail.js +++ b/plugins/mail/mail.js @@ -1,52 +1,56 @@ -function emailArticle(id) { - if (!id) { - let ids = Headlines.getSelected(); +Plugins.Mail = { + send: function(id) { + if (!id) { + let ids = Headlines.getSelected(); + + if (ids.length == 0) { + alert(__("No articles selected.")); + return; + } - if (ids.length == 0) { - alert(__("No articles selected.")); - return; + id = ids.toString(); } - id = ids.toString(); - } + if (dijit.byId("emailArticleDlg")) + dijit.byId("emailArticleDlg").destroyRecursive(); - if (dijit.byId("emailArticleDlg")) - dijit.byId("emailArticleDlg").destroyRecursive(); - - const query = "backend.php?op=pluginhandler&plugin=mail&method=emailArticle¶m=" + encodeURIComponent(id); - - const dialog = new dijit.Dialog({ - id: "emailArticleDlg", - title: __("Forward article by email"), - style: "width: 600px", - execute: function() { - if (this.validate()) { - xhrJson("backend.php", this.attr('value'), (reply) => { - if (reply) { - const error = reply['error']; - - if (error) { - alert(__('Error sending email:') + ' ' + error); - } else { - Notify.info('Your message has been sent.'); - dialog.hide(); - } - - } - }); - } - }, - href: query}); + const query = "backend.php?op=pluginhandler&plugin=mail&method=emailArticle¶m=" + encodeURIComponent(id); - /* var tmph = dojo.connect(dialog, 'onLoad', function() { - dojo.disconnect(tmph); - - new Ajax.Autocompleter('emailArticleDlg_destination', 'emailArticleDlg_dst_choices', - "backend.php?op=pluginhandler&plugin=mail&method=completeEmails", - { tokens: '', paramName: "search" }); - }); */ - - dialog.show(); -} + const dialog = new dijit.Dialog({ + id: "emailArticleDlg", + title: __("Forward article by email"), + style: "width: 600px", + execute: function () { + if (this.validate()) { + xhrJson("backend.php", this.attr('value'), (reply) => { + if (reply) { + const error = reply['error']; + if (error) { + alert(__('Error sending email:') + ' ' + error); + } else { + Notify.info('Your message has been sent.'); + dialog.hide(); + } + } + }); + } + }, + href: query + }); + + /* var tmph = dojo.connect(dialog, 'onLoad', function() { + dojo.disconnect(tmph); + + new Ajax.Autocompleter('emailArticleDlg_destination', 'emailArticleDlg_dst_choices', + "backend.php?op=pluginhandler&plugin=mail&method=completeEmails", + { tokens: '', paramName: "search" }); + }); */ + + dialog.show(); + }, + onHotkey: function(id) { + Plugins.Mail.send(id); + } +}; -- cgit v1.2.3