]> git.wh0rd.org Git - tt-rss.git/commitdiff
headline menu: add ability to toggle unread/published/starred
authorAndrew Dolgov <fox@madoka.volgo-balt.ru>
Sat, 30 Mar 2013 09:42:33 +0000 (13:42 +0400)
committerAndrew Dolgov <fox@madoka.volgo-balt.ru>
Sat, 30 Mar 2013 09:42:33 +0000 (13:42 +0400)
js/viewfeed.js

index 7abfef095c1989f7d71059edb41ee2bbe072cba2..b7eaef3627808dd7e9257130c066f823ea9c227f 100644 (file)
@@ -726,9 +726,9 @@ function selectionAssignLabel(id, ids) {
        }
 }
 
-function selectionToggleUnread(set_state, callback, no_error) {
+function selectionToggleUnread(set_state, callback, no_error, ids) {
        try {
-               var rows = getSelectedArticleIds2();
+               var rows = ids ? ids : getSelectedArticleIds2();
 
                if (rows.length == 0 && !no_error) {
                        alert(__("No articles are selected."));
@@ -787,12 +787,13 @@ function selectionToggleUnread(set_state, callback, no_error) {
        }
 }
 
-function selectionToggleMarked() {
+// sel_state ignored
+function selectionToggleMarked(sel_state, callback, no_error, ids) {
        try {
 
-               var rows = getSelectedArticleIds2();
+               var rows = ids ? ids : getSelectedArticleIds2();
 
-               if (rows.length == 0) {
+               if (rows.length == 0 && !no_error) {
                        alert(__("No articles are selected."));
                        return;
                }
@@ -810,6 +811,7 @@ function selectionToggleMarked() {
                                parameters: query,
                                onComplete: function(transport) {
                                        handle_rpc_json(transport);
+                                       if (callback) callback(transport);
                                } });
 
                }
@@ -819,12 +821,13 @@ function selectionToggleMarked() {
        }
 }
 
-function selectionTogglePublished() {
+// sel_state ignored
+function selectionTogglePublished(sel_state, callback, no_error, ids) {
        try {
 
-               var rows = getSelectedArticleIds2();
+               var rows = ids ? ids : getSelectedArticleIds2();
 
-               if (rows.length == 0) {
+               if (rows.length == 0 && !no_error) {
                        alert(__("No articles are selected."));
                        return;
                }
@@ -1888,6 +1891,41 @@ function initHeadlinesMenu() {
 
                menu.addChild(new dijit.MenuSeparator());
 
+               menu.addChild(new dijit.MenuItem({
+                       label: __("Toggle unread"),
+                       onClick: function(event) {
+                               var ids = getSelectedArticleIds2();
+                               // cast to string
+                               var id = this.getParent().callerRowId + "";
+                               ids = ids.size() != 0 && ids.indexOf(id) != -1 ? ids : [id];
+
+                               selectionToggleUnread(undefined, false, true, ids);
+                               }}));
+
+               menu.addChild(new dijit.MenuItem({
+                       label: __("Toggle marked"),
+                       onClick: function(event) {
+                               var ids = getSelectedArticleIds2();
+                               // cast to string
+                               var id = this.getParent().callerRowId + "";
+                               ids = ids.size() != 0 && ids.indexOf(id) != -1 ? ids : [id];
+
+                               selectionToggleMarked(undefined, false, true, ids);
+                               }}));
+
+               menu.addChild(new dijit.MenuItem({
+                       label: __("Toggle published"),
+                       onClick: function(event) {
+                               var ids = getSelectedArticleIds2();
+                               // cast to string
+                               var id = this.getParent().callerRowId + "";
+                               ids = ids.size() != 0 && ids.indexOf(id) != -1 ? ids : [id];
+
+                               selectionTogglePublished(undefined, false, true, ids);
+                               }}));
+
+               menu.addChild(new dijit.MenuSeparator());
+
                menu.addChild(new dijit.MenuItem({
                        label: __("Mark above as read"),
                        onClick: function(event) {