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

master
Andrew Dolgov 2 years ago
parent 5db6939dc9
commit 1fb7125f90
  1. 7
      index.php
  2. 18
      js/App.js
  3. 15
      js/Feeds.js
  4. 18
      js/Headlines.js

@ -168,10 +168,10 @@
</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') ?>"
onchange="App.onViewModeChanged()"
onchange="Feeds.onViewModeChanged()"
dojoType="fox.form.Select">
<option selected="selected" value="adaptive"><?= __('Adaptive') ?></option>
<option value="all_articles"><?= __('All Articles') ?></option>
@ -179,11 +179,10 @@
<option value="published"><?= __('Published') ?></option>
<option value="unread"><?= __('Unread') ?></option>
<option value="has_note"><?= __('With Note') ?></option>
<!-- <option value="noscores"><?= __('Ignore Scoring') ?></option> -->
</select>
<select title="<?= __('Sort articles') ?>"
onchange="App.onViewModeChanged()"
onchange="Feeds.onViewModeChanged()"
dojoType="fox.form.Select" name="order_by">
<option selected="selected" value="default"><?= __('Default') ?></option>

@ -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;

@ -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;

@ -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;

Loading…
Cancel
Save