summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2021-02-18 15:13:41 +0300
committerAndrew Dolgov <[email protected]>2021-02-18 15:13:41 +0300
commit2e4b4037870ae0d69bc7a945bc86424d4cc9c1d2 (patch)
treeee5e5178cc283ce52653d8626f61f134e6f49486
parentbed36cbf9fde4a9016029fb8c21e6e68d540dee2 (diff)
* use es5 (?) default parameter values for some functions
* when moving to next article, try to show hsp if its next
-rw-r--r--js/App.js19
-rw-r--r--js/Article.js4
-rwxr-xr-xjs/Headlines.js19
3 files changed, 26 insertions, 16 deletions
diff --git a/js/App.js b/js/App.js
index 8776aab81..55844873c 100644
--- a/js/App.js
+++ b/js/App.js
@@ -98,7 +98,16 @@ const App = {
return elem.offsetTop + elem.offsetHeight <= ctr.scrollTop + ctr.offsetHeight &&
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) {
@@ -541,9 +550,7 @@ const App = {
this.initSecondStage();
},
Error: {
- fatal: function (error, params) {
- params = params || {};
-
+ fatal: function (error, params = {}) {
if (params.code) {
if (params.code == 6) {
window.location.href = "index.php";
@@ -557,9 +564,7 @@ const App = {
return this.report(error,
Object.extend({title: __("Fatal error")}, params));
},
- report: function(error, params) {
- params = params || {};
-
+ report: function(error, params = {}) {
if (!error) return;
console.error("[Error.report]", error, params);
diff --git a/js/Article.js b/js/Article.js
index a42d3af67..81917fd47 100644
--- a/js/Article.js
+++ b/js/Article.js
@@ -383,9 +383,7 @@ const Article = {
dialog.show();
},
- cdmMoveToId: function (id, params) {
- params = params || {};
-
+ cdmMoveToId: function (id, params = {}) {
const force_to_top = params.force_to_top || false;
const ctr = $("headlines-frame");
diff --git a/js/Headlines.js b/js/Headlines.js
index dadf79c1a..16026f593 100755
--- a/js/Headlines.js
+++ b/js/Headlines.js
@@ -814,9 +814,7 @@ const Headlines = {
Feeds.reloadCurrent();
},
- selectionToggleUnread: function (params) {
- params = params || {};
-
+ selectionToggleUnread: function (params = {}) {
const cmode = params.cmode != undefined ? params.cmode : 2;
const no_error = params.no_error || false;
const ids = params.ids || Headlines.getSelected();
@@ -882,9 +880,7 @@ const Headlines = {
if (row)
row.toggleClassName("published");
},
- move: function (mode, params) {
- params = params || {};
-
+ move: function (mode, params = {}) {
const no_expand = params.no_expand || false;
const force_previous = params.force_previous || this.default_force_previous;
const force_to_top = params.force_to_top || this.default_force_to_top;
@@ -930,6 +926,17 @@ const Headlines = {
} else {
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") {
if (prev_id || current_id) {