summaryrefslogtreecommitdiff
path: root/js/Article.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/Article.js')
-rw-r--r--js/Article.js57
1 files changed, 41 insertions, 16 deletions
diff --git a/js/Article.js b/js/Article.js
index b933ed716..08b565695 100644
--- a/js/Article.js
+++ b/js/Article.js
@@ -2,6 +2,7 @@
/* global __, ngettext */
define(["dojo/_base/declare"], function (declare) {
Article = {
+ _scroll_reset_timeout: false,
getScoreClass: function (score) {
if (score > 500) {
return "score-high";
@@ -32,7 +33,7 @@ define(["dojo/_base/declare"], function (declare) {
if (ids.length > 0) {
const score = prompt(__("Please enter new score for selected articles:"));
- if (parseInt(score) != undefined) {
+ if (!isNaN(parseInt(score))) {
ids.each((id) => {
const row = $("RROW-" + id);
@@ -66,7 +67,7 @@ define(["dojo/_base/declare"], function (declare) {
const score_old = row.getAttribute("data-score");
const score = prompt(__("Please enter new score for this article:"), score_old);
- if (parseInt(score) != undefined) {
+ if (!isNaN(parseInt(score))) {
row.setAttribute("data-score", score);
const pic = row.select(".icon-score")[0];
@@ -274,15 +275,28 @@ define(["dojo/_base/declare"], function (declare) {
dialog.show();
},
- cdmScrollToId: function (id, force) {
+ cdmScrollToId: function (id, force, event) {
const ctr = $("headlines-frame");
const e = $("RROW-" + id);
+ const is_expanded = App.getInitParam("cdm_expanded");
if (!e || !ctr) return;
- if (force || e.offsetTop + e.offsetHeight > (ctr.scrollTop + ctr.offsetHeight) ||
+ if (force || is_expanded || e.offsetTop + e.offsetHeight > (ctr.scrollTop + ctr.offsetHeight) ||
e.offsetTop < ctr.scrollTop) {
+ if (event && event.repeat || !is_expanded) {
+ ctr.addClassName("forbid-smooth-scroll");
+ window.clearTimeout(this._scroll_reset_timeout);
+
+ this._scroll_reset_timeout = window.setTimeout(() => {
+ if (ctr) ctr.removeClassName("forbid-smooth-scroll");
+ }, 250)
+
+ } else {
+ ctr.removeClassName("forbid-smooth-scroll");
+ }
+
ctr.scrollTop = e.offsetTop;
Element.hide("floatingTitle");
@@ -314,19 +328,30 @@ define(["dojo/_base/declare"], function (declare) {
else
return 0;
},
- scroll: function (offset) {
- if (!App.isCombinedMode()) {
- const ci = $("content-insert");
- if (ci) {
- ci.scrollTop += offset;
- }
- } else {
- const hi = $("headlines-frame");
- if (hi) {
- hi.scrollTop += offset;
- }
+ scrollByPages: function (page_offset, event) {
+ const elem = App.isCombinedMode() ? $("headlines-frame") : $("content-insert");
+
+ const offset = elem.offsetHeight * page_offset * 0.99;
+ this.scroll(offset, event);
+ },
+ scroll: function (offset, event) {
+
+ const elem = App.isCombinedMode() ? $("headlines-frame") : $("content-insert");
+
+ if (event && event.repeat) {
+ elem.addClassName("forbid-smooth-scroll");
+ window.clearTimeout(this._scroll_reset_timeout);
+
+ this._scroll_reset_timeout = window.setTimeout(() => {
+ if (elem) elem.removeClassName("forbid-smooth-scroll");
+ }, 250)
+
+ } else {
+ elem.removeClassName("forbid-smooth-scroll");
}
+
+ elem.scrollTop += offset;
},
mouseIn: function (id) {
this.post_under_pointer = id;
@@ -340,4 +365,4 @@ define(["dojo/_base/declare"], function (declare) {
}
return Article;
-}); \ No newline at end of file
+});