* add actions dropdown to toggle combined mode
* hide 'toggle widescreen' menu item when in combined mode * unify some mode toggling code in App
This commit is contained in:
parent
bd0af3ae9e
commit
806b46d0c4
11
index.php
11
index.php
|
@ -238,6 +238,13 @@
|
|||
<div dojoType="fox.form.DropDownButton" class="action-button" title="<?= __('Actions...') ?>">
|
||||
<span><i class="material-icons">menu</i></span>
|
||||
<div dojoType="dijit.Menu" style="display: none">
|
||||
<script type='dojo/method' event='onOpen' args='evt,a,b,c'>
|
||||
const ws = this.getChildren().find((m) => m.id == 'qmcToggleWidescreen');
|
||||
|
||||
if (ws)
|
||||
ws.attr('hidden', !!App.isCombinedMode());
|
||||
</script>
|
||||
|
||||
<div dojoType="dijit.MenuItem" onclick="App.onActionSelected('qmcPrefs')"><?= __('Preferences...') ?></div>
|
||||
<div dojoType="dijit.MenuItem" onclick="App.onActionSelected('qmcSearch')"><?= __('Search...') ?></div>
|
||||
<div dojoType="dijit.MenuItem" disabled="1"><?= __('Feed actions:') ?></div>
|
||||
|
@ -248,7 +255,9 @@
|
|||
<div dojoType="dijit.MenuItem" onclick="App.onActionSelected('qmcCatchupAll')"><?= __('Mark as read') ?></div>
|
||||
<div dojoType="dijit.MenuItem" onclick="App.onActionSelected('qmcShowOnlyUnread')"><?= __('(Un)hide read feeds') ?></div>
|
||||
<div dojoType="dijit.MenuItem" disabled="1"><?= __('Other actions:') ?></div>
|
||||
<div dojoType="dijit.MenuItem" onclick="App.onActionSelected('qmcToggleWidescreen')"><?= __('Toggle widescreen mode') ?></div>
|
||||
<div dojoType="dijit.MenuItem" id="qmcToggleWidescreen" onclick="App.onActionSelected('qmcToggleWidescreen')">
|
||||
<?= __('Toggle widescreen mode') ?></div>
|
||||
<div dojoType="dijit.MenuItem" onclick="App.onActionSelected('qmcToggleCombined')"><?= __('Toggle combined mode') ?></div>
|
||||
<div dojoType="dijit.MenuItem" onclick="App.onActionSelected('qmcHKhelp')"><?= __('Keyboard shortcuts help') ?></div>
|
||||
|
||||
<?php
|
||||
|
|
69
js/App.js
69
js/App.js
|
@ -286,7 +286,18 @@ const App = {
|
|||
|
||||
},
|
||||
isCombinedMode: function() {
|
||||
return this.getInitParam("combined_display_mode");
|
||||
return !!this.getInitParam("combined_display_mode");
|
||||
},
|
||||
setCombinedMode: function(combined) {
|
||||
const value = combined ? "true" : "false";
|
||||
|
||||
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();
|
||||
})
|
||||
},
|
||||
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;
|
||||
|
|
Loading…
Reference in New Issue