add Headlines.renderAgain() to switch between combined/expanded modes faster
This commit is contained in:
parent
7915706946
commit
54f02a3b31
|
@ -160,6 +160,16 @@ define(["dojo/_base/declare"], function (declare) {
|
||||||
${__('Originally from:')} <a target="_blank" rel="noopener noreferrer" href="${hl.orig_feed[1]}">${hl.orig_feed[0]}</a>
|
${__('Originally from:')} <a target="_blank" rel="noopener noreferrer" href="${hl.orig_feed[1]}">${hl.orig_feed[0]}</a>
|
||||||
</span>` : "";
|
</span>` : "";
|
||||||
},
|
},
|
||||||
|
unpack: function(row) {
|
||||||
|
if (row.hasAttribute("data-content")) {
|
||||||
|
console.log("unpacking: " + row.id);
|
||||||
|
|
||||||
|
row.select(".content-inner")[0].innerHTML = row.getAttribute("data-content");
|
||||||
|
row.removeAttribute("data-content");
|
||||||
|
|
||||||
|
PluginHost.run(PluginHost.HOOK_ARTICLE_RENDERED_CDM, row);
|
||||||
|
}
|
||||||
|
},
|
||||||
view: function (id, noexpand) {
|
view: function (id, noexpand) {
|
||||||
this.setActive(id);
|
this.setActive(id);
|
||||||
|
|
||||||
|
@ -283,14 +293,7 @@ define(["dojo/_base/declare"], function (declare) {
|
||||||
const row = $("RROW-" + id);
|
const row = $("RROW-" + id);
|
||||||
|
|
||||||
if (row) {
|
if (row) {
|
||||||
if (row.hasAttribute("data-content")) {
|
Article.unpack(row);
|
||||||
console.log("unpacking: " + row.id);
|
|
||||||
|
|
||||||
row.select(".content-inner")[0].innerHTML = row.getAttribute("data-content");
|
|
||||||
row.removeAttribute("data-content");
|
|
||||||
|
|
||||||
PluginHost.run(PluginHost.HOOK_ARTICLE_RENDERED_CDM, row);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (row.hasClassName("Unread")) {
|
if (row.hasClassName("Unread")) {
|
||||||
|
|
||||||
|
|
|
@ -228,12 +228,7 @@ define(["dojo/_base/declare"], function (declare) {
|
||||||
const row = rows[i];
|
const row = rows[i];
|
||||||
|
|
||||||
if (row.offsetTop <= threshold) {
|
if (row.offsetTop <= threshold) {
|
||||||
console.log("unpacking: " + row.id);
|
Article.unpack(row);
|
||||||
|
|
||||||
row.select(".content-inner")[0].innerHTML = row.getAttribute("data-content");
|
|
||||||
row.removeAttribute("data-content");
|
|
||||||
|
|
||||||
PluginHost.run(PluginHost.HOOK_ARTICLE_RENDERED_CDM, row);
|
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -242,7 +237,34 @@ define(["dojo/_base/declare"], function (declare) {
|
||||||
objectById: function (id){
|
objectById: function (id){
|
||||||
return this.headlines[id];
|
return this.headlines[id];
|
||||||
},
|
},
|
||||||
renderHeadline: function (headlines, hl) {
|
renderAgain: function() {
|
||||||
|
$$("#headlines-frame > div[id*=RROW]").each((row) => {
|
||||||
|
const id = row.getAttribute("data-article-id");
|
||||||
|
const selected = row.hasClassName("Selected");
|
||||||
|
const active = row.hasClassName("active");
|
||||||
|
|
||||||
|
if (this.headlines[id]) {
|
||||||
|
const new_row = this.render({}, this.headlines[id]);
|
||||||
|
|
||||||
|
row.parentNode.replaceChild(new_row, row);
|
||||||
|
|
||||||
|
if (active) {
|
||||||
|
new_row.addClassName("active");
|
||||||
|
|
||||||
|
if (App.isCombinedMode())
|
||||||
|
Article.cdmScrollToId(id);
|
||||||
|
else
|
||||||
|
Article.view(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (selected) this.select("all", id);
|
||||||
|
|
||||||
|
Article.unpack(new_row);
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
render: function (headlines, hl) {
|
||||||
let row = null;
|
let row = null;
|
||||||
|
|
||||||
let row_class = "";
|
let row_class = "";
|
||||||
|
@ -372,7 +394,7 @@ define(["dojo/_base/declare"], function (declare) {
|
||||||
|
|
||||||
PluginHost.run(PluginHost.HOOK_HEADLINE_RENDERED, tmp.firstChild);
|
PluginHost.run(PluginHost.HOOK_HEADLINE_RENDERED, tmp.firstChild);
|
||||||
|
|
||||||
$("headlines-frame").appendChild(tmp.firstChild);
|
return tmp.firstChild;
|
||||||
},
|
},
|
||||||
onLoaded: function (transport, offset) {
|
onLoaded: function (transport, offset) {
|
||||||
const reply = App.handleRpcJson(transport);
|
const reply = App.handleRpcJson(transport);
|
||||||
|
@ -434,7 +456,9 @@ define(["dojo/_base/declare"], function (declare) {
|
||||||
for (let i = 0; i < reply['headlines']['content'].length; i++) {
|
for (let i = 0; i < reply['headlines']['content'].length; i++) {
|
||||||
const hl = reply['headlines']['content'][i];
|
const hl = reply['headlines']['content'][i];
|
||||||
|
|
||||||
this.renderHeadline(reply['headlines'], hl);
|
$("headlines-frame").appendChild(
|
||||||
|
this.render(reply['headlines'], hl));
|
||||||
|
|
||||||
this.headlines[parseInt(hl.id)] = hl;
|
this.headlines[parseInt(hl.id)] = hl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -503,7 +527,9 @@ define(["dojo/_base/declare"], function (declare) {
|
||||||
for (let i = 0; i < reply['headlines']['content'].length; i++) {
|
for (let i = 0; i < reply['headlines']['content'].length; i++) {
|
||||||
const hl = reply['headlines']['content'][i];
|
const hl = reply['headlines']['content'][i];
|
||||||
|
|
||||||
this.renderHeadline(reply['headlines'], hl);
|
$("headlines-frame").appendChild(
|
||||||
|
this.render(reply['headlines'], hl));
|
||||||
|
|
||||||
this.headlines[parseInt(hl.id)] = hl;
|
this.headlines[parseInt(hl.id)] = hl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -930,10 +956,12 @@ define(["dojo/_base/declare"], function (declare) {
|
||||||
|
|
||||||
this.updateSelectedPrompt();
|
this.updateSelectedPrompt();
|
||||||
},
|
},
|
||||||
select: function (mode) {
|
select: function (mode, articleId) {
|
||||||
// mode = all,none,unread,invert,marked,published
|
// mode = all,none,unread,invert,marked,published
|
||||||
let query = "#headlines-frame > div[id*=RROW]";
|
let query = "#headlines-frame > div[id*=RROW]";
|
||||||
|
|
||||||
|
if (articleId) query += "[data-article-id=" + articleId + "]";
|
||||||
|
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case "none":
|
case "none":
|
||||||
case "all":
|
case "all":
|
||||||
|
|
|
@ -444,8 +444,6 @@ require(["dojo/_base/kernel",
|
||||||
App.helpDialog("main");
|
App.helpDialog("main");
|
||||||
};
|
};
|
||||||
this.hotkey_actions["toggle_combined_mode"] = function () {
|
this.hotkey_actions["toggle_combined_mode"] = function () {
|
||||||
Notify.progress("Loading, please wait...");
|
|
||||||
|
|
||||||
const value = App.isCombinedMode() ? "false" : "true";
|
const value = App.isCombinedMode() ? "false" : "true";
|
||||||
|
|
||||||
xhrPost("backend.php", {op: "rpc", method: "setpref", key: "COMBINED_DISPLAY_MODE", value: value}, () => {
|
xhrPost("backend.php", {op: "rpc", method: "setpref", key: "COMBINED_DISPLAY_MODE", value: value}, () => {
|
||||||
|
@ -453,17 +451,15 @@ require(["dojo/_base/kernel",
|
||||||
!App.getInitParam("combined_display_mode"));
|
!App.getInitParam("combined_display_mode"));
|
||||||
|
|
||||||
Article.close();
|
Article.close();
|
||||||
Feeds.reloadCurrent();
|
Headlines.renderAgain();
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
this.hotkey_actions["toggle_cdm_expanded"] = function () {
|
this.hotkey_actions["toggle_cdm_expanded"] = function () {
|
||||||
Notify.progress("Loading, please wait...");
|
|
||||||
|
|
||||||
const value = App.getInitParam("cdm_expanded") ? "false" : "true";
|
const value = App.getInitParam("cdm_expanded") ? "false" : "true";
|
||||||
|
|
||||||
xhrPost("backend.php", {op: "rpc", method: "setpref", key: "CDM_EXPANDED", value: value}, () => {
|
xhrPost("backend.php", {op: "rpc", method: "setpref", key: "CDM_EXPANDED", value: value}, () => {
|
||||||
App.setInitParam("cdm_expanded", !App.getInitParam("cdm_expanded"));
|
App.setInitParam("cdm_expanded", !App.getInitParam("cdm_expanded"));
|
||||||
Feeds.reloadCurrent();
|
Headlines.renderAgain();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
this.hotkey_actions["toggle_night_mode"] = function () {
|
this.hotkey_actions["toggle_night_mode"] = function () {
|
||||||
|
|
Loading…
Reference in New Issue