]> git.wh0rd.org - tt-rss.git/blobdiff - viewfeed.js
rework email article dialog
[tt-rss.git] / viewfeed.js
index dadbe94852fd021e8234a4b18abdb93a5bba8953..d14d9818049a8b040077858c63bc727169682c4e 100644 (file)
@@ -669,10 +669,10 @@ function toggleUnread(id, cmode, effect) {
        }
 }
 
-function selectionRemoveLabel(id) {
+function selectionRemoveLabel(id, ids) {
        try {
 
-               var ids = getSelectedArticleIds2();
+               if (!ids) var ids = getSelectedArticleIds2();
 
                if (ids.length == 0) {
                        alert(__("No articles are selected."));
@@ -707,10 +707,10 @@ function selectionRemoveLabel(id) {
        }
 }
 
-function selectionAssignLabel(id) {
+function selectionAssignLabel(id, ids) {
        try {
 
-               var ids = getSelectedArticleIds2();
+               if (!ids) ids = getSelectedArticleIds2();
 
                if (ids.length == 0) {
                        alert(__("No articles are selected."));
@@ -1869,61 +1869,58 @@ function emailArticle(id) {
                        id = ids.toString();
                }
 
-               displayDlg('emailArticle', id, 
-                  function () {                                
-                               document.forms['article_email_form'].destination.focus();
-
-                          new Ajax.Autocompleter('destination', 'destination_choices',
-                                  "backend.php?op=rpc&subop=completeEmails",
-                                  { tokens: '', paramName: "search" });
-
-                       });
+               if (dijit.byId("emailArticleDlg"))
+                       dijit.byId("emailArticleDlg").destroyRecursive();
 
-       } catch (e) {
-               exception_error("emailArticle", e);
-       }
-}
+               var query = "backend.php?op=dlg&id=emailArticle&param=" + param_escape(id);
 
-function emailArticleDo() {
-       try {
-               var f = document.forms['article_email_form'];
-
-               if (f.destination.value == "") {
-                       alert("Please fill in the destination email.");
-                       return;
-               }
+               dialog = new dijit.Dialog({
+                       id: "emailArticleDlg",
+                       title: __("Forward article by email"),
+                       style: "width: 600px",
+                       execute: function() {
+                               if (this.validate()) {
 
-               if (f.subject.value == "") {
-                       alert("Please fill in the subject.");
-                       return;
-               }
-
-               var query = Form.serialize("article_email_form");
+                                       new Ajax.Request("backend.php", {
+                                               parameters: dojo.objectToQuery(this.attr('value')),
+                                               onComplete: function(transport) { 
+               
+                                                       var error = transport.responseXML.getElementsByTagName('error')[0];
+                       
+                                                       if (error) {
+                                                               alert(__('Error sending email:') + ' ' + error.firstChild.nodeValue);
+                                                       } else {
+                                                               notify_info('Your message has been sent.');
+                                                               dialog.hide();
+                                                       }
+                       
+                                       } });
+                               }
+                       },
+                       href: query});
 
-//             console.log(query);
+               var tmph = dojo.connect(dialog, 'onLoad', function() {
+               dojo.disconnect(tmph);
 
-               new Ajax.Request("backend.php", {
-                       parameters: query,
-                       onComplete: function(transport) { 
-                               try {
+                  new Ajax.Autocompleter('emailArticleDlg_destination', 'emailArticleDlg_dst_choices',
+                          "backend.php?op=rpc&subop=completeEmails",
+                          { tokens: '', paramName: "search" });
+               });
 
-                                       var error = transport.responseXML.getElementsByTagName('error')[0];
+               dialog.show();
 
-                                       if (error) {
-                                               alert(__('Error sending email:') + ' ' + error.firstChild.nodeValue);
-                                       } else {
-                                               notify_info('Your message has been sent.');
-                                               closeInfoBox();
-                                       }
+               /* displayDlg('emailArticle', id, 
+                  function () {                                
+                               document.forms['article_email_form'].destination.focus();
 
-                               } catch (e) {
-                                       exception_error("sendEmailDo", e);
-                               }
+                          new Ajax.Autocompleter('destination', 'destination_choices',
+                                  "backend.php?op=rpc&subop=completeEmails",
+                                  { tokens: '', paramName: "search" });
 
-                       } });
+                       }); */
 
        } catch (e) {
-               exception_error("emailArticleDo", e);
+               exception_error("emailArticle", e);
        }
 }
 
@@ -2231,7 +2228,12 @@ function initHeadlinesMenu() {
                        dijit.byId("headlinesMenu").destroyRecursive();
 
                var ids = [];
-               var nodes = $$("#headlines-frame > div[id*=RROW]");
+
+               if (!isCdmMode()) {
+                       nodes = $$("#headlines-frame > div[id*=RROW]");
+               } else {
+                       nodes = $$("#headlines-frame span[id*=RTITLE]");
+               }
 
                nodes.each(function(node) {
                        ids.push(node.id);
@@ -2255,17 +2257,20 @@ function initHeadlinesMenu() {
 
                });
 
-               menu.addChild(new dijit.MenuItem({
-                       label: __("View article"),
-                       onClick: function(event) {
-                               view(this.getParent().callerRowId);
-                       }}));
+               if (!isCdmMode())
+                       menu.addChild(new dijit.MenuItem({
+                               label: __("View article"),
+                               onClick: function(event) {
+                                       view(this.getParent().callerRowId);
+                               }}));
 
                menu.addChild(new dijit.MenuItem({
                        label: __("View in a new tab"),
                        onClick: function(event) {
                                hlOpenInNewTab(event, this.getParent().callerRowId);
-                       }}));
+                               }}));
+
+               menu.addChild(new dijit.MenuSeparator());
 
                menu.addChild(new dijit.MenuItem({
                        label: __("Open original article"),
@@ -2273,6 +2278,38 @@ function initHeadlinesMenu() {
                                openArticleInNewWindow(this.getParent().callerRowId);
                        }}));
 
+               var labels = dijit.byId("feedTree").model.getItemsInCategory(-2);
+
+               if (labels) {
+
+                       menu.addChild(new dijit.MenuSeparator());
+
+                       var labelsMenu = new dijit.Menu({ownerMenu: menu});
+
+                       labels.each(function(label) {
+                               var id = label.id[0];
+                               var bare_id = id.substr(id.indexOf(":")+1);
+                               var name = label.name[0];
+
+                               bare_id = -11-bare_id;
+
+                               labelsMenu.addChild(new dijit.MenuItem({
+                                       label: name,
+                                       labelId: bare_id,
+                                       onClick: function(event) {
+                                               //console.log(this.labelId);
+                                               //console.log(this.getParent().ownerMenu.callerRowId);
+                                               selectionAssignLabel(this.labelId, 
+                                                       [this.getParent().ownerMenu.callerRowId]);
+                               }}));
+                       });
+
+                       menu.addChild(new dijit.PopupMenuItem({
+                               label: __("Labels"),
+                               popup: labelsMenu,
+                       }));
+               }
+
                menu.startup();
 
        } catch (e) {