fix fatal error in previous because of event not being passed via Headlines.move()

scrollbypages, etc: make event optional anyway
This commit is contained in:
Andrew Dolgov 2019-12-09 23:23:54 +03:00
parent e7dd634183
commit 44ef447c0f
3 changed files with 24 additions and 18 deletions

View File

@ -338,7 +338,7 @@ define(["dojo/_base/declare"], function (declare) {
elem = $("headlines-frame");
}
if (event.repeat) {
if (event && event.repeat) {
elem.addClassName("forbid-smooth-scroll");
window.clearTimeout(this._scroll_reset_timeout);

View File

@ -806,7 +806,13 @@ define(["dojo/_base/declare"], function (declare) {
if (row)
row.toggleClassName("published");
},
move: function (mode, noscroll, noexpand) {
move: function (mode, params) {
params = params || {};
const noscroll = params.noscroll || false;
const noexpand = params.noexpand || false;
const event = params.event;
const rows = Headlines.getLoaded();
let prev_id = false;
@ -849,7 +855,7 @@ define(["dojo/_base/declare"], function (declare) {
if (!noscroll && article && article.offsetTop + article.offsetHeight >
ctr.scrollTop + ctr.offsetHeight) {
Article.scroll(ctr.offsetHeight / 4);
Article.scroll(ctr.offsetHeight / 4, event);
} else if (next_id) {
Article.setActive(next_id);
@ -872,10 +878,10 @@ define(["dojo/_base/declare"], function (declare) {
const ctr = $("headlines-frame");
if (!noscroll && article && article.offsetTop < ctr.scrollTop) {
Article.scroll(-ctr.offsetHeight / 3);
Article.scroll(-ctr.offsetHeight / 3, event);
} else if (!noscroll && prev_article &&
prev_article.offsetTop < ctr.scrollTop) {
Article.scroll(-ctr.offsetHeight / 4);
Article.scroll(-ctr.offsetHeight / 4, event);
} else if (prev_id) {
Article.setActive(prev_id);
Article.cdmScrollToId(prev_id, noscroll);
@ -1387,7 +1393,7 @@ define(["dojo/_base/declare"], function (declare) {
scrollByPages: function (offset, event) {
const elem = $("headlines-frame");
if (event.repeat) {
if (event && event.repeat) {
elem.addClassName("forbid-smooth-scroll");
window.clearTimeout(this._scroll_reset_timeout);

View File

@ -277,23 +277,23 @@ require(["dojo/_base/kernel",
if (rv) Feeds.open({feed: rv[0], is_cat: rv[1], delayed: true})
};
this.hotkey_actions["next_article"] = function () {
Headlines.move('next');
this.hotkey_actions["next_article"] = function (event) {
Headlines.move('next', {event: event});
};
this.hotkey_actions["prev_article"] = function () {
Headlines.move('prev');
this.hotkey_actions["prev_article"] = function (event) {
Headlines.move('prev', {event: event});
};
this.hotkey_actions["next_article_noscroll"] = function () {
Headlines.move('next', true);
this.hotkey_actions["next_article_noscroll"] = function (event) {
Headlines.move('next', {noscroll: true, event: event});
};
this.hotkey_actions["prev_article_noscroll"] = function () {
Headlines.move('prev', true);
this.hotkey_actions["prev_article_noscroll"] = function (event) {
Headlines.move('prev', {noscroll: true, event: event});
};
this.hotkey_actions["next_article_noexpand"] = function () {
Headlines.move('next', true, true);
this.hotkey_actions["next_article_noexpand"] = function (event) {
Headlines.move('next', {noscroll: true, noexpand: true, event: event});
};
this.hotkey_actions["prev_article_noexpand"] = function () {
Headlines.move('prev', true, true);
this.hotkey_actions["prev_article_noexpand"] = function (event) {
Headlines.move('prev', {noscroll: true, noexpand: true, event: event});
};
this.hotkey_actions["search_dialog"] = function () {
Feeds.search();