summaryrefslogtreecommitdiff
path: root/js/AppBase.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/AppBase.js')
-rw-r--r--js/AppBase.js63
1 files changed, 54 insertions, 9 deletions
diff --git a/js/AppBase.js b/js/AppBase.js
index 86cc44e8a..b037a52a2 100644
--- a/js/AppBase.js
+++ b/js/AppBase.js
@@ -7,6 +7,39 @@ define(["dojo/_base/declare"], function (declare) {
hotkey_prefix: 0,
hotkey_prefix_pressed: false,
hotkey_prefix_timeout: 0,
+ Scrollable: {
+ scrollByPages: function (elem, page_offset) {
+ if (!elem) return;
+
+ /* keep a line or so from the previous page */
+ const offset = (elem.offsetHeight - (page_offset > 0 ? 50 : -50)) * page_offset;
+
+ this.scroll(elem, offset);
+ },
+ scroll: function(elem, offset) {
+ if (!elem) return;
+
+ elem.scrollTop += offset;
+ },
+ isChildVisible: function(elem, ctr) {
+ if (!elem) return;
+
+ const ctop = ctr.scrollTop;
+ const cbottom = ctop + ctr.offsetHeight;
+
+ const etop = elem.offsetTop;
+ const ebottom = etop + elem.offsetHeight;
+
+ return etop >= ctop && ebottom <= cbottom ||
+ etop < ctop && ebottom > ctop || ebottom > cbottom && etop < cbottom;
+ },
+ fitsInContainer: function (elem, ctr) {
+ if (!elem) return;
+
+ return elem.offsetTop + elem.offsetHeight <= ctr.scrollTop + ctr.offsetHeight &&
+ elem.offsetTop >= ctr.scrollTop;
+ }
+ },
constructor: function() {
window.onerror = this.Error.onWindowError;
},
@@ -101,6 +134,20 @@ define(["dojo/_base/declare"], function (declare) {
}
},
+ isCombinedMode: function() {
+ return this.getInitParam("combined_display_mode");
+ },
+ getActionByHotkeySequence: function (sequence) {
+ const hotkeys_map = App.getInitParam("hotkeys");
+
+ for (const seq in hotkeys_map[1]) {
+ if (hotkeys_map[1].hasOwnProperty(seq)) {
+ if (seq == sequence) {
+ return hotkeys_map[1][seq];
+ }
+ }
+ }
+ },
keyeventToAction: function(event) {
const hotkeys_map = App.getInitParam("hotkeys");
@@ -144,18 +191,16 @@ define(["dojo/_base/declare"], function (declare) {
hotkey_name = keychar ? keychar : "(" + keycode + ")";
}
- const hotkey_full = this.hotkey_prefix ? this.hotkey_prefix + " " + hotkey_name : hotkey_name;
+ let hotkey_full = this.hotkey_prefix ? this.hotkey_prefix + " " + hotkey_name : hotkey_name;
this.hotkey_prefix = false;
- let action_name = false;
+ let action_name = this.getActionByHotkeySequence(hotkey_full);
- for (const sequence in hotkeys_map[1]) {
- if (hotkeys_map[1].hasOwnProperty(sequence)) {
- if (sequence == hotkey_full) {
- action_name = hotkeys_map[1][sequence];
- break;
- }
- }
+ // check for mode-specific hotkey
+ if (!action_name) {
+ hotkey_full = (App.isCombinedMode() ? "{C}" : "{3}") + hotkey_full;
+
+ action_name = this.getActionByHotkeySequence(hotkey_full);
}
console.log('keyeventToAction', hotkey_full, '=>', action_name);