summaryrefslogtreecommitdiff
path: root/plugins/mail
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2018-12-03 14:21:50 +0300
committerAndrew Dolgov <[email protected]>2018-12-03 14:21:50 +0300
commite76d1fb995e25d78f0131ac56660846b0e9ecb9a (patch)
treeb0815fcc07c7eea917ac5aaddc53c38ee857e848 /plugins/mail
parent71fc6d45bd761a9d2715faa68f2b8c0271ee7169 (diff)
plugins: mail, mailto: remove code from global context
Diffstat (limited to 'plugins/mail')
-rw-r--r--plugins/mail/init.php2
-rw-r--r--plugins/mail/mail.js94
2 files changed, 50 insertions, 46 deletions
diff --git a/plugins/mail/init.php b/plugins/mail/init.php
index d8f92853e..1609a05c3 100644
--- a/plugins/mail/init.php
+++ b/plugins/mail/init.php
@@ -72,7 +72,7 @@ class Mail extends Plugin {
function hook_article_button($line) {
return "<img src=\"plugins/mail/mail.png\"
class='tagsPic' style=\"cursor : pointer\"
- onclick=\"emailArticle(".$line["id"].")\"
+ onclick=\"Plugins.Mail.send(".$line["id"].")\"
alt='Zoom' title='".__('Forward by email')."'>";
}
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&param=" + 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&param=" + 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);
+ }
+};