From 0b93d8d0137c46ce153ca65fae3e22304cc80009 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Wed, 10 Mar 2021 10:01:22 +0300 Subject: add hotkey to toggle grid view --- js/App.js | 6 ++++++ js/Feeds.js | 1 - js/Headlines.js | 9 ++++++--- 3 files changed, 12 insertions(+), 4 deletions(-) (limited to 'js') diff --git a/js/App.js b/js/App.js index 20498e692..82c84ce3c 100644 --- a/js/App.js +++ b/js/App.js @@ -1102,6 +1102,12 @@ const App = { this.hotkey_actions["feed_reverse"] = () => { Headlines.reverse(); }; + this.hotkey_actions["feed_toggle_grid"] = () => { + xhr.json("backend.php", {op: "rpc", method: "togglepref", key: "CDM_ENABLE_GRID"}, (reply) => { + App.setInitParam("cdm_enable_grid", reply.value); + Headlines.renderAgain(); + }) + }; this.hotkey_actions["feed_toggle_vgroup"] = () => { xhr.post("backend.php", {op: "rpc", method: "togglepref", key: "VFEED_GROUP_BY_FEED"}, () => { Feeds.reloadCurrent(); diff --git a/js/Feeds.js b/js/Feeds.js index 9e65a06fd..46d978cb4 100644 --- a/js/Feeds.js +++ b/js/Feeds.js @@ -330,7 +330,6 @@ const Feeds = { container.setAttribute("data-feed-id", id); container.setAttribute("data-is-cat", is_cat ? "true" : "false"); - container.setAttribute("data-enable-grid", App.getInitParam("cdm_enable_grid") ? "true" : "false"); this.select(id, is_cat); diff --git a/js/Headlines.js b/js/Headlines.js index 8f104c951..fce371904 100755 --- a/js/Headlines.js +++ b/js/Headlines.js @@ -383,10 +383,13 @@ const Headlines = { return this.headlines[id]; }, setCommonClasses: function () { - App.byId("headlines-frame").removeClassName("cdm"); - App.byId("headlines-frame").removeClassName("normal"); + const container = App.byId("headlines-frame"); + + container.removeClassName("cdm"); + container.removeClassName("normal"); - App.byId("headlines-frame").addClassName(App.isCombinedMode() ? "cdm" : "normal"); + container.addClassName(App.isCombinedMode() ? "cdm" : "normal"); + container.setAttribute("data-enable-grid", App.getInitParam("cdm_enable_grid") ? "true" : "false"); // for floating title because it's placed outside of headlines-frame App.byId("main").removeClassName("expandable"); -- cgit v1.2.3