* use es5 (?) default parameter values for some functions
* when moving to next article, try to show hsp if its next
This commit is contained in:
parent
bed36cbf9f
commit
2e4b403787
17
js/App.js
17
js/App.js
|
@ -98,6 +98,15 @@ const App = {
|
||||||
|
|
||||||
return elem.offsetTop + elem.offsetHeight <= ctr.scrollTop + ctr.offsetHeight &&
|
return elem.offsetTop + elem.offsetHeight <= ctr.scrollTop + ctr.offsetHeight &&
|
||||||
elem.offsetTop >= ctr.scrollTop;
|
elem.offsetTop >= ctr.scrollTop;
|
||||||
|
},
|
||||||
|
scrollTo: function (elem, ctr, params = {}) {
|
||||||
|
const force_to_top = params.force_to_top || false;
|
||||||
|
|
||||||
|
if (!elem || !ctr) return;
|
||||||
|
|
||||||
|
if (force_to_top || !App.Scrollable.fitsInContainer(elem, ctr)) {
|
||||||
|
ctr.scrollTop = elem.offsetTop;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
dialogOf: function (elem) {
|
dialogOf: function (elem) {
|
||||||
|
@ -541,9 +550,7 @@ const App = {
|
||||||
this.initSecondStage();
|
this.initSecondStage();
|
||||||
},
|
},
|
||||||
Error: {
|
Error: {
|
||||||
fatal: function (error, params) {
|
fatal: function (error, params = {}) {
|
||||||
params = params || {};
|
|
||||||
|
|
||||||
if (params.code) {
|
if (params.code) {
|
||||||
if (params.code == 6) {
|
if (params.code == 6) {
|
||||||
window.location.href = "index.php";
|
window.location.href = "index.php";
|
||||||
|
@ -557,9 +564,7 @@ const App = {
|
||||||
return this.report(error,
|
return this.report(error,
|
||||||
Object.extend({title: __("Fatal error")}, params));
|
Object.extend({title: __("Fatal error")}, params));
|
||||||
},
|
},
|
||||||
report: function(error, params) {
|
report: function(error, params = {}) {
|
||||||
params = params || {};
|
|
||||||
|
|
||||||
if (!error) return;
|
if (!error) return;
|
||||||
|
|
||||||
console.error("[Error.report]", error, params);
|
console.error("[Error.report]", error, params);
|
||||||
|
|
|
@ -383,9 +383,7 @@ const Article = {
|
||||||
dialog.show();
|
dialog.show();
|
||||||
|
|
||||||
},
|
},
|
||||||
cdmMoveToId: function (id, params) {
|
cdmMoveToId: function (id, params = {}) {
|
||||||
params = params || {};
|
|
||||||
|
|
||||||
const force_to_top = params.force_to_top || false;
|
const force_to_top = params.force_to_top || false;
|
||||||
|
|
||||||
const ctr = $("headlines-frame");
|
const ctr = $("headlines-frame");
|
||||||
|
|
|
@ -814,9 +814,7 @@ const Headlines = {
|
||||||
|
|
||||||
Feeds.reloadCurrent();
|
Feeds.reloadCurrent();
|
||||||
},
|
},
|
||||||
selectionToggleUnread: function (params) {
|
selectionToggleUnread: function (params = {}) {
|
||||||
params = params || {};
|
|
||||||
|
|
||||||
const cmode = params.cmode != undefined ? params.cmode : 2;
|
const cmode = params.cmode != undefined ? params.cmode : 2;
|
||||||
const no_error = params.no_error || false;
|
const no_error = params.no_error || false;
|
||||||
const ids = params.ids || Headlines.getSelected();
|
const ids = params.ids || Headlines.getSelected();
|
||||||
|
@ -882,9 +880,7 @@ const Headlines = {
|
||||||
if (row)
|
if (row)
|
||||||
row.toggleClassName("published");
|
row.toggleClassName("published");
|
||||||
},
|
},
|
||||||
move: function (mode, params) {
|
move: function (mode, params = {}) {
|
||||||
params = params || {};
|
|
||||||
|
|
||||||
const no_expand = params.no_expand || false;
|
const no_expand = params.no_expand || false;
|
||||||
const force_previous = params.force_previous || this.default_force_previous;
|
const force_previous = params.force_previous || this.default_force_previous;
|
||||||
const force_to_top = params.force_to_top || this.default_force_to_top;
|
const force_to_top = params.force_to_top || this.default_force_to_top;
|
||||||
|
@ -930,6 +926,17 @@ const Headlines = {
|
||||||
} else {
|
} else {
|
||||||
Article.view(next_id, no_expand);
|
Article.view(next_id, no_expand);
|
||||||
}
|
}
|
||||||
|
} else if (App.isCombinedMode()) {
|
||||||
|
// try to show hsp if no next article exists, in case there's useful information like first_id_changed etc
|
||||||
|
const row = $("RROW-" + current_id);
|
||||||
|
|
||||||
|
if (row) {
|
||||||
|
const sibling = row.nextSibling;
|
||||||
|
|
||||||
|
if (sibling && Element.visible(sibling) && sibling.id == "headlines-spacer") {
|
||||||
|
App.Scrollable.scrollTo(sibling, $("headlines-frame"));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if (mode === "prev") {
|
} else if (mode === "prev") {
|
||||||
if (prev_id || current_id) {
|
if (prev_id || current_id) {
|
||||||
|
|
Loading…
Reference in New Issue