]> git.wh0rd.org - tt-rss.git/blob - plugins/mail/mail.js
6166f01c11f4266d0ef58c3a56d56a4a3d5bb8b0
[tt-rss.git] / plugins / mail / mail.js
1 function emailArticle(id) {
2 try {
3 if (!id) {
4 var ids = getSelectedArticleIds2();
5
6 if (ids.length == 0) {
7 alert(__("No articles are selected."));
8 return;
9 }
10
11 id = ids.toString();
12 }
13
14 if (dijit.byId("emailArticleDlg"))
15 dijit.byId("emailArticleDlg").destroyRecursive();
16
17 var query = "backend.php?op=pluginhandler&plugin=mail&method=emailArticle&param=" + param_escape(id);
18
19 dialog = new dijit.Dialog({
20 id: "emailArticleDlg",
21 title: __("Forward article by email"),
22 style: "width: 600px",
23 execute: function() {
24 if (this.validate()) {
25
26 new Ajax.Request("backend.php", {
27 parameters: dojo.objectToQuery(this.attr('value')),
28 onComplete: function(transport) {
29 console.log(transport.responseText);
30
31 var reply = JSON.parse(transport.responseText);
32
33 var error = reply['error'];
34
35 if (error) {
36 alert(__('Error sending email:') + ' ' + error);
37 } else {
38 notify_info('Your message has been sent.');
39 dialog.hide();
40 }
41
42 } });
43 }
44 },
45 href: query});
46
47 var tmph = dojo.connect(dialog, 'onLoad', function() {
48 dojo.disconnect(tmph);
49
50 new Ajax.Autocompleter('emailArticleDlg_destination', 'emailArticleDlg_dst_choices',
51 "backend.php?op=pluginhandler&plugin=mail&method=completeEmails",
52 { tokens: '', paramName: "search" });
53 });
54
55 dialog.show();
56
57 } catch (e) {
58 exception_error("emailArticle", e);
59 }
60 }
61
62