From be7bb7d5eeab801fd1039db9de81594c1267477c Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sat, 30 Mar 2013 13:42:33 +0400 Subject: [PATCH] headline menu: add ability to toggle unread/published/starred --- js/viewfeed.js | 54 ++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 46 insertions(+), 8 deletions(-) diff --git a/js/viewfeed.js b/js/viewfeed.js index 7abfef09..b7eaef36 100644 --- a/js/viewfeed.js +++ b/js/viewfeed.js @@ -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) { -- 2.39.5