diff options
author | Andrew Dolgov <[email protected]> | 2021-03-08 10:43:49 +0300 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2021-03-08 10:43:49 +0300 |
commit | 1fb7125f90b3d11aecf83da58ef513ff8902a84a (patch) | |
tree | 362b394cd7b95bcd153ef3ba38017662027aa1d8 /js | |
parent | 5db6939dc9628886391bcaa18965de94727c96d9 (diff) |
minor cleanup related to toolbar-main (use dijit methods, etc)
Diffstat (limited to 'js')
-rw-r--r-- | js/App.js | 18 | ||||
-rw-r--r-- | js/Feeds.js | 15 | ||||
-rwxr-xr-x | js/Headlines.js | 18 |
3 files changed, 20 insertions, 31 deletions
@@ -777,13 +777,10 @@ const App = { } }); - const toolbar = document.forms["toolbar-main"]; - - dijit.getEnclosingWidget(toolbar.view_mode).attr('value', - this.getInitParam("default_view_mode")); - - dijit.getEnclosingWidget(toolbar.order_by).attr('value', - this.getInitParam("default_view_order_by")); + dijit.byId('toolbar-main').setValues({ + view_mode: this.getInitParam("default_view_mode"), + order_by: this.getInitParam("default_view_order_by") + }); this.setLoadingProgress(50); @@ -850,13 +847,6 @@ const App = { document.title = tmp; }, - onViewModeChanged: function() { - const view_mode = document.forms["toolbar-main"].view_mode.value; - - App.findAll("body")[0].setAttribute("view-mode", view_mode); - - return Feeds.reloadCurrent(''); - }, hotkeyHandler: function(event) { if (event.target.nodeName == "INPUT" || event.target.nodeName == "TEXTAREA") return; diff --git a/js/Feeds.js b/js/Feeds.js index ad2edf8d5..2d475bcb6 100644 --- a/js/Feeds.js +++ b/js/Feeds.js @@ -117,15 +117,21 @@ const Feeds = { }, reloadCurrent: function(method) { if (this.getActive() != undefined) { - console.log("reloadCurrent: " + method); + console.log("reloadCurrent", this.getActive(), this.activeIsCat(), method); this.open({feed: this.getActive(), is_cat: this.activeIsCat(), method: method}); } - return false; // block unneeded form submits }, openDefaultFeed: function() { this.open({feed: this._default_feed_id}); }, + onViewModeChanged: function() { + // TODO: is this still needed? + App.find("body").setAttribute("view-mode", + dijit.byId("toolbar-main").getValues().view_mode); + + return Feeds.reloadCurrent(''); + }, openNextUnread: function() { const is_cat = this.activeIsCat(); const nuf = this.getNextUnread(this.getActive(), is_cat); @@ -369,10 +375,7 @@ const Feeds = { }, 10 * 1000); } - //Form.enable("toolbar-main"); - - let query = Object.assign({op: "feeds", method: "view", feed: feed}, - dojo.formToObject("toolbar-main")); + let query = {...{op: "feeds", method: "view", feed: feed}, ...dojo.formToObject("toolbar-main")}; if (method) query.m = method; diff --git a/js/Headlines.js b/js/Headlines.js index fd9bc6661..28e43be1f 100755 --- a/js/Headlines.js +++ b/js/Headlines.js @@ -278,7 +278,7 @@ const Headlines = { } }, loadMore: function () { - const view_mode = document.forms["toolbar-main"].view_mode.value; + const view_mode = dijit.byId("toolbar-main").getValues().view_mode; const unread_in_buffer = App.findAll("#headlines-frame > div[id*=RROW][class*=Unread]").length; const num_all = App.findAll("#headlines-frame > div[id*=RROW]").length; const num_unread = Feeds.getUnread(Feeds.getActive(), Feeds.activeIsCat()); @@ -819,19 +819,15 @@ const Headlines = { Notify.close(); }, reverse: function () { - const toolbar = document.forms["toolbar-main"]; - const order_by = dijit.getEnclosingWidget(toolbar.order_by); + const toolbar = dijit.byId("toolbar-main"); + let order_by = toolbar.getValues().order_by; - let value = order_by.attr('value'); - - if (value != "date_reverse") - value = "date_reverse"; + if (order_by != "date_reverse") + order_by = "date_reverse"; else - value = "default"; - - order_by.attr('value', value); + order_by = App.getInitParam("default_view_order_by"); - Feeds.reloadCurrent(); + toolbar.setValues({order_by: order_by}); }, selectionToggleUnread: function (params = {}) { const cmode = params.cmode != undefined ? params.cmode : 2; |