minor cleanup related to toolbar-main (use dijit methods, etc)

This commit is contained in:
Andrew Dolgov 2021-03-08 10:43:49 +03:00
parent 5db6939dc9
commit 1fb7125f90
4 changed files with 23 additions and 35 deletions

View File

@ -168,10 +168,10 @@
</div> </div>
<form id="toolbar-main" action="" style="order : 20" onsubmit='return false'> <form id="toolbar-main" dojoType="dijit.form.Form" action="" style="order : 20" onsubmit="return false">
<select name="view_mode" title="<?= __('Show articles') ?>" <select name="view_mode" title="<?= __('Show articles') ?>"
onchange="App.onViewModeChanged()" onchange="Feeds.onViewModeChanged()"
dojoType="fox.form.Select"> dojoType="fox.form.Select">
<option selected="selected" value="adaptive"><?= __('Adaptive') ?></option> <option selected="selected" value="adaptive"><?= __('Adaptive') ?></option>
<option value="all_articles"><?= __('All Articles') ?></option> <option value="all_articles"><?= __('All Articles') ?></option>
@ -179,11 +179,10 @@
<option value="published"><?= __('Published') ?></option> <option value="published"><?= __('Published') ?></option>
<option value="unread"><?= __('Unread') ?></option> <option value="unread"><?= __('Unread') ?></option>
<option value="has_note"><?= __('With Note') ?></option> <option value="has_note"><?= __('With Note') ?></option>
<!-- <option value="noscores"><?= __('Ignore Scoring') ?></option> -->
</select> </select>
<select title="<?= __('Sort articles') ?>" <select title="<?= __('Sort articles') ?>"
onchange="App.onViewModeChanged()" onchange="Feeds.onViewModeChanged()"
dojoType="fox.form.Select" name="order_by"> dojoType="fox.form.Select" name="order_by">
<option selected="selected" value="default"><?= __('Default') ?></option> <option selected="selected" value="default"><?= __('Default') ?></option>

View File

@ -777,13 +777,10 @@ const App = {
} }
}); });
const toolbar = document.forms["toolbar-main"]; dijit.byId('toolbar-main').setValues({
view_mode: this.getInitParam("default_view_mode"),
dijit.getEnclosingWidget(toolbar.view_mode).attr('value', order_by: this.getInitParam("default_view_order_by")
this.getInitParam("default_view_mode")); });
dijit.getEnclosingWidget(toolbar.order_by).attr('value',
this.getInitParam("default_view_order_by"));
this.setLoadingProgress(50); this.setLoadingProgress(50);
@ -850,13 +847,6 @@ const App = {
document.title = tmp; 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) { hotkeyHandler: function(event) {
if (event.target.nodeName == "INPUT" || event.target.nodeName == "TEXTAREA") return; if (event.target.nodeName == "INPUT" || event.target.nodeName == "TEXTAREA") return;

View File

@ -117,15 +117,21 @@ const Feeds = {
}, },
reloadCurrent: function(method) { reloadCurrent: function(method) {
if (this.getActive() != undefined) { 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}); this.open({feed: this.getActive(), is_cat: this.activeIsCat(), method: method});
} }
return false; // block unneeded form submits
}, },
openDefaultFeed: function() { openDefaultFeed: function() {
this.open({feed: this._default_feed_id}); 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() { openNextUnread: function() {
const is_cat = this.activeIsCat(); const is_cat = this.activeIsCat();
const nuf = this.getNextUnread(this.getActive(), is_cat); const nuf = this.getNextUnread(this.getActive(), is_cat);
@ -369,10 +375,7 @@ const Feeds = {
}, 10 * 1000); }, 10 * 1000);
} }
//Form.enable("toolbar-main"); let query = {...{op: "feeds", method: "view", feed: feed}, ...dojo.formToObject("toolbar-main")};
let query = Object.assign({op: "feeds", method: "view", feed: feed},
dojo.formToObject("toolbar-main"));
if (method) query.m = method; if (method) query.m = method;

View File

@ -278,7 +278,7 @@ const Headlines = {
} }
}, },
loadMore: function () { 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 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_all = App.findAll("#headlines-frame > div[id*=RROW]").length;
const num_unread = Feeds.getUnread(Feeds.getActive(), Feeds.activeIsCat()); const num_unread = Feeds.getUnread(Feeds.getActive(), Feeds.activeIsCat());
@ -819,19 +819,15 @@ const Headlines = {
Notify.close(); Notify.close();
}, },
reverse: function () { reverse: function () {
const toolbar = document.forms["toolbar-main"]; const toolbar = dijit.byId("toolbar-main");
const order_by = dijit.getEnclosingWidget(toolbar.order_by); let order_by = toolbar.getValues().order_by;
let value = order_by.attr('value'); if (order_by != "date_reverse")
order_by = "date_reverse";
if (value != "date_reverse")
value = "date_reverse";
else else
value = "default"; order_by = App.getInitParam("default_view_order_by");
order_by.attr('value', value); toolbar.setValues({order_by: order_by});
Feeds.reloadCurrent();
}, },
selectionToggleUnread: function (params = {}) { selectionToggleUnread: function (params = {}) {
const cmode = params.cmode != undefined ? params.cmode : 2; const cmode = params.cmode != undefined ? params.cmode : 2;