From 642c37ea6117954fc19e2a800f2fce4c1304d89d Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sat, 1 Dec 2018 21:01:53 +0300 Subject: further effocts to wrap JS stuff into objects --- plugins/mail/mail.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins/mail/mail.js') diff --git a/plugins/mail/mail.js b/plugins/mail/mail.js index 929b35243..1dc383b00 100644 --- a/plugins/mail/mail.js +++ b/plugins/mail/mail.js @@ -1,7 +1,7 @@ function emailArticle(id) { try { if (!id) { - var ids = getSelectedArticleIds2(); + var ids = Headlines.getSelectedArticleIds2(); if (ids.length == 0) { alert(__("No articles are selected.")); -- cgit v1.2.3 From 3678315bead3f7264dc2aa9c7feb6e0a0f20ea63 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sun, 2 Dec 2018 08:32:13 +0300 Subject: Article, Headlines: shorten several method names --- plugins/mail/mail.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins/mail/mail.js') diff --git a/plugins/mail/mail.js b/plugins/mail/mail.js index 1dc383b00..538970fc3 100644 --- a/plugins/mail/mail.js +++ b/plugins/mail/mail.js @@ -1,7 +1,7 @@ function emailArticle(id) { try { if (!id) { - var ids = Headlines.getSelectedArticleIds2(); + var ids = Headlines.getSelected(); if (ids.length == 0) { alert(__("No articles are selected.")); -- cgit v1.2.3 From 35ded4bc844d74f120196012c194be9ab5517688 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sun, 2 Dec 2018 16:30:32 +0300 Subject: edit phrasing of some alert()s --- plugins/mail/mail.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins/mail/mail.js') diff --git a/plugins/mail/mail.js b/plugins/mail/mail.js index 538970fc3..d6c28048b 100644 --- a/plugins/mail/mail.js +++ b/plugins/mail/mail.js @@ -4,7 +4,7 @@ function emailArticle(id) { var ids = Headlines.getSelected(); if (ids.length == 0) { - alert(__("No articles are selected.")); + alert(__("No articles selected.")); return; } -- cgit v1.2.3 From d9c5c93cef313127b9b5010fbe279fdbddedadec Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sun, 2 Dec 2018 20:07:57 +0300 Subject: move some more stuff out of common.js rework client-side cookie functions a bit limit dojo cachebust based on server scripts modification time remove param_escape() --- plugins/mail/mail.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins/mail/mail.js') diff --git a/plugins/mail/mail.js b/plugins/mail/mail.js index d6c28048b..af0cf3552 100644 --- a/plugins/mail/mail.js +++ b/plugins/mail/mail.js @@ -14,7 +14,7 @@ function emailArticle(id) { if (dijit.byId("emailArticleDlg")) dijit.byId("emailArticleDlg").destroyRecursive(); - var query = "backend.php?op=pluginhandler&plugin=mail&method=emailArticle¶m=" + param_escape(id); + var query = "backend.php?op=pluginhandler&plugin=mail&method=emailArticle¶m=" + encodeURIComponent(id); dialog = new dijit.Dialog({ id: "emailArticleDlg", -- cgit v1.2.3 From 526389b2d380177490605037fdc3a24ebc688fac Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sun, 2 Dec 2018 20:56:30 +0300 Subject: update notify_* calls to use Notify --- plugins/mail/mail.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins/mail/mail.js') diff --git a/plugins/mail/mail.js b/plugins/mail/mail.js index af0cf3552..b72289c2a 100644 --- a/plugins/mail/mail.js +++ b/plugins/mail/mail.js @@ -29,7 +29,7 @@ function emailArticle(id) { if (error) { alert(__('Error sending email:') + ' ' + error); } else { - notify_info('Your message has been sent.'); + Notify.info('Your message has been sent.'); dialog.hide(); } -- cgit v1.2.3 From 71fc6d45bd761a9d2715faa68f2b8c0271ee7169 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Mon, 3 Dec 2018 13:38:13 +0300 Subject: refactor error reporting to AppBase; keep exception_error() for now as a shim --- plugins/mail/mail.js | 83 ++++++++++++++++++++++++---------------------------- 1 file changed, 39 insertions(+), 44 deletions(-) (limited to 'plugins/mail/mail.js') diff --git a/plugins/mail/mail.js b/plugins/mail/mail.js index b72289c2a..87e354b42 100644 --- a/plugins/mail/mail.js +++ b/plugins/mail/mail.js @@ -1,57 +1,52 @@ function emailArticle(id) { - try { - if (!id) { - var ids = Headlines.getSelected(); + if (!id) { + let ids = Headlines.getSelected(); - if (ids.length == 0) { - alert(__("No articles selected.")); - return; - } - - id = ids.toString(); + if (ids.length == 0) { + alert(__("No articles selected.")); + return; } - if (dijit.byId("emailArticleDlg")) - dijit.byId("emailArticleDlg").destroyRecursive(); - - var query = "backend.php?op=pluginhandler&plugin=mail&method=emailArticle¶m=" + encodeURIComponent(id); - - 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(); - } + id = ids.toString(); + } + 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}); - /* var tmph = dojo.connect(dialog, 'onLoad', function() { - dojo.disconnect(tmph); + } + }); + } + }, + href: query}); - new Ajax.Autocompleter('emailArticleDlg_destination', 'emailArticleDlg_dst_choices', - "backend.php?op=pluginhandler&plugin=mail&method=completeEmails", - { tokens: '', paramName: "search" }); - }); */ + /* var tmph = dojo.connect(dialog, 'onLoad', function() { + dojo.disconnect(tmph); - dialog.show(); + new Ajax.Autocompleter('emailArticleDlg_destination', 'emailArticleDlg_dst_choices', + "backend.php?op=pluginhandler&plugin=mail&method=completeEmails", + { tokens: '', paramName: "search" }); + }); */ - } catch (e) { - exception_error("emailArticle", e); - } + dialog.show(); } -- cgit v1.2.3 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