From 806b46d0c41836c7ed23486194c5d29b013639c0 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Thu, 24 Feb 2022 21:07:53 +0300 Subject: [PATCH] * add actions dropdown to toggle combined mode * hide 'toggle widescreen' menu item when in combined mode * unify some mode toggling code in App --- index.php | 11 ++++++++- js/App.js | 69 ++++++++++++++++++++++++++++--------------------------- 2 files changed, 45 insertions(+), 35 deletions(-) diff --git a/index.php b/index.php index 2dbc078cd..37a3253b9 100644 --- a/index.php +++ b/index.php @@ -238,6 +238,13 @@
menu
+ +
@@ -248,7 +255,9 @@
-
+
+
+
{ + this.setInitParam("combined_display_mode", + !this.getInitParam("combined_display_mode")); + + Article.close(); + Headlines.renderAgain(); + }) }, getActionByHotkeySequence: function(sequence) { const hotkeys_map = this.getInitParam("hotkeys"); @@ -797,7 +808,7 @@ const App = { this.setLoadingProgress(50); this._widescreen_mode = this.getInitParam("widescreen"); - this.setWidescreen(this._widescreen_mode); + this.setWideScreenMode(this.isWideScreenMode(), true); Headlines.initScrollHandler(); @@ -882,7 +893,22 @@ const App = { } } }, - setWidescreen: function(wide) { + isWideScreenMode: function() { + return !!this._widescreen_mode; + }, + setWideScreenMode: function(wide, quiet = false) { + + if (this.isCombinedMode() && !quiet) { + alert(__("Widescreen is not available in combined mode.")); + return; + } + + // reset stored sizes because geometry changed + Cookie.set("ttrss_ci_width", 0); + Cookie.set("ttrss_ci_height", 0); + + this._widescreen_mode = wide; + const article_id = Article.getActive(); const headlines_frame = App.byId("headlines-frame"); const content_insert = dijit.byId("content-insert"); @@ -1201,31 +1227,13 @@ const App = { } }; this.hotkey_actions["toggle_widescreen"] = () => { - if (!this.isCombinedMode()) { - this._widescreen_mode = !this._widescreen_mode; - - // reset stored sizes because geometry changed - Cookie.set("ttrss_ci_width", 0); - Cookie.set("ttrss_ci_height", 0); - - this.setWidescreen(this._widescreen_mode); - } else { - alert(__("Widescreen is not available in combined mode.")); - } + this.setWideScreenMode(!this.isWideScreenMode()); }; this.hotkey_actions["help_dialog"] = () => { this.hotkeyHelp(); }; this.hotkey_actions["toggle_combined_mode"] = () => { - const value = this.isCombinedMode() ? "false" : "true"; - - xhr.post("backend.php", {op: "rpc", method: "setpref", key: "COMBINED_DISPLAY_MODE", value: value}, () => { - this.setInitParam("combined_display_mode", - !this.getInitParam("combined_display_mode")); - - Article.close(); - Headlines.renderAgain(); - }) + App.setCombinedMode(!App.isCombinedMode()); }; this.hotkey_actions["toggle_cdm_expanded"] = () => { const value = this.getInitParam("cdm_expanded") ? "false" : "true"; @@ -1294,18 +1302,11 @@ const App = { Feeds.toggleUnread(); break; case "qmcToggleWidescreen": - if (!this.isCombinedMode()) { - this._widescreen_mode = !this._widescreen_mode; - - // reset stored sizes because geometry changed - Cookie.set("ttrss_ci_width", 0); - Cookie.set("ttrss_ci_height", 0); - - this.setWidescreen(this._widescreen_mode); - } else { - alert(__("Widescreen is not available in combined mode.")); - } + App.setWideScreenMode(!App.isWideScreenMode()); break; + case "qmcToggleCombined": + App.setCombinedMode(!App.isCombinedMode()); + break; case "qmcHKhelp": this.hotkeyHelp() break;