summaryrefslogtreecommitdiff
path: root/js/Headlines.js
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2020-04-17 07:58:34 +0300
committerAndrew Dolgov <[email protected]>2020-04-17 07:58:34 +0300
commite17c7e2fb432f572bcfd2a3ae173f36dd08e1cac (patch)
tree0fbe4df650ed563a9ef26b451e46d6a1c0a6f3fc /js/Headlines.js
parentb3e4f0188e68ee7f61121b247d7202fb68d9c28e (diff)
Headlines.renderAgain: scroll instantly to active article when going back to combined mode on the fly
Diffstat (limited to 'js/Headlines.js')
-rwxr-xr-xjs/Headlines.js32
1 files changed, 17 insertions, 15 deletions
diff --git a/js/Headlines.js b/js/Headlines.js
index 540c400d3..79eecd79f 100755
--- a/js/Headlines.js
+++ b/js/Headlines.js
@@ -385,8 +385,22 @@ define(["dojo/_base/declare"], function (declare) {
objectById: function (id){
return this.headlines[id];
},
+ setCommonClasses: function() {
+ $("headlines-frame").removeClassName("cdm");
+ $("headlines-frame").removeClassName("normal");
+
+ $("headlines-frame").addClassName(App.isCombinedMode() ? "cdm" : "normal");
+
+ // for floating title because it's placed outside of headlines-frame
+ $("main").removeClassName("expandable");
+ $("main").removeClassName("expanded");
+
+ if (App.isCombinedMode())
+ $("main").addClassName(App.getInitParam("cdm_expanded") ? " expanded" : " expandable");
+ },
renderAgain: function() {
// TODO: wrap headline elements into a knockoutjs model to prevent all this stuff
+ Headlines.setCommonClasses();
$$("#headlines-frame > div[id*=RROW]").each((row) => {
const id = row.getAttribute("data-article-id");
@@ -401,7 +415,7 @@ define(["dojo/_base/declare"], function (declare) {
new_row.addClassName("active");
if (App.isCombinedMode())
- Article.cdmScrollToId(id);
+ Article.cdmScrollToId(id, true, null, true);
else
Article.view(id);
}
@@ -598,24 +612,12 @@ define(["dojo/_base/declare"], function (declare) {
Feeds.infscroll_disabled = parseInt(headlines_count) != 30;
console.log('infscroll_disabled=', Feeds.infscroll_disabled);
- // TODO: the below needs to be applied again when switching expanded/expandable on the fly
- // via hotkeys, not just on feed load
-
- $("headlines-frame").removeClassName("cdm");
- $("headlines-frame").removeClassName("normal");
-
- $("headlines-frame").addClassName(App.isCombinedMode() ? "cdm" : "normal");
+ // also called in renderAgain() after view mode switch
+ Headlines.setCommonClasses();
$("headlines-frame").setAttribute("is-vfeed",
reply['headlines']['is_vfeed'] ? 1 : 0);
- // for floating title because it's placed outside of headlines-frame
- $("main").removeClassName("expandable");
- $("main").removeClassName("expanded");
-
- if (App.isCombinedMode())
- $("main").addClassName(App.getInitParam("cdm_expanded") ? " expanded" : " expandable");
-
Article.setActive(0);
try {