From 746dcf42995b4dea9da7036386a0649b38c4e095 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Fri, 16 May 2008 07:05:12 +0100 Subject: [PATCH] hotkey support for prefs --- help/4.php | 37 ++++++++++++++ modules/pref-labels.php | 2 +- prefs.js | 104 +++++++++++++++++++++++++++++++++++----- prefs.php | 6 ++- tt-rss.css | 2 +- tt-rss.js | 4 +- 6 files changed, 137 insertions(+), 18 deletions(-) create mode 100644 help/4.php diff --git a/help/4.php b/help/4.php new file mode 100644 index 000000000..78eed93f3 --- /dev/null +++ b/help/4.php @@ -0,0 +1,37 @@ +

+ +
+ +

+ + + + + + + + +
1
2
3
4
5
6
+ +
+ +

+ + + + + + +
c s
c f
c l
c u
+ +

+ + + +
g x
+ +
+ +

Note: not all actions may be available, depending on Tiny Tiny RSS configuration and your access level.

+ +

diff --git a/modules/pref-labels.php b/modules/pref-labels.php index 65948ce43..e9e6ee860 100644 --- a/modules/pref-labels.php +++ b/modules/pref-labels.php @@ -6,7 +6,7 @@ function module_pref_labels($link) { if (!GLOBAL_ENABLE_LABELS) { - print "

Sorry, labels have been administratively disabled for this installation. Please contact instance owner or edit configuration file to enable this functionality.

"; + print __("Sorry, labels have been administratively disabled for this installation. Please contact instance owner or edit configuration file to enable this functionality."); return; } diff --git a/prefs.js b/prefs.js index e3449a238..308c7b7aa 100644 --- a/prefs.js +++ b/prefs.js @@ -10,8 +10,8 @@ var xmlhttp = Ajax.getTransport(); var init_params = new Array(); var caller_subop = false; - var sanity_check_done = false; +var hotkey_prefix = false; function infobox_callback() { if (xmlhttp.readyState == 4) { @@ -1654,31 +1654,111 @@ function pref_hotkey_handler(e) { try { var keycode; - - if (!hotkeys_enabled) return; - + var shift_key = false; + + try { + shift_key = e.shiftKey; + } catch (e) { + + } + if (window.event) { keycode = window.event.keyCode; } else if (e) { keycode = e.which; } - + + if (keycode == 27) { // escape + if (Element.visible("hotkey_help_overlay")) { + Element.hide("hotkey_help_overlay"); + } + hotkey_prefix = false; + closeInfoBox(); + } + + if (!hotkeys_enabled) { + debug("hotkeys disabled"); + return; + } + + if (keycode == 16) return; // ignore lone shift + + if (Element.visible("hotkey_help_overlay")) { + Element.hide("hotkey_help_overlay"); + } + if (keycode == 13 || keycode == 27) { seq = ""; } else { seq = seq + "" + keycode; } + /* Global hotkeys */ - if (document.getElementById("piggie")) { + if (!hotkey_prefix) { + + if (keycode == 68 && shift_key) { // d + if (!debug_mode_enabled) { + document.getElementById('debug_output').style.display = 'block'; + debug('debug mode activated'); + } else { + document.getElementById('debug_output').style.display = 'none'; + } - if (seq.match("807371717369")) { - seq = ""; - localPiggieFunction(true); - } else { - localPiggieFunction(false); + debug_mode_enabled = !debug_mode_enabled; + return; + } + + if (keycode == 191 && shift_key) { // ? + if (!Element.visible("hotkey_help_overlay")) { + Element.show("hotkey_help_overlay"); + } else { + Element.hide("hotkey_help_overlay"); + } + return; + } + + if (keycode == 49) { // 1 + selectTab("genConfig"); + } + + if (keycode == 50 && document.getElementById("feedConfigTab")) { // 2 + return selectTab("feedConfig"); + } + + if (keycode == 51 && document.getElementById("feedBrowserTab")) { // 3 + return selectTab("feedBrowser"); + } + + if (keycode == 52 && document.getElementById("filterConfigTab")) { // 4 + return selectTab("filterConfig"); + } + + if (keycode == 53 && document.getElementById("labelConfigTab")) { // 5 + return selectTab("labelConfig"); + } + + if (keycode == 54 && document.getElementById("userConfigTab")) { // 6 + return selectTab("userConfig"); + } + + } + + if (document.getElementById("piggie")) { + + if (seq.match("807371717369")) { + seq = ""; + localPiggieFunction(true); + } else { + localPiggieFunction(false); + } + } + + if (hotkey_prefix) { + debug("KP: PREFIX=" + hotkey_prefix + " CODE=" + keycode); + } else { + debug("KP: CODE=" + keycode); } - } } catch (e) { exception_error("pref_hotkey_handler", e); diff --git a/prefs.php b/prefs.php index bf58aa3bd..908f66f2c 100644 --- a/prefs.php +++ b/prefs.php @@ -69,12 +69,14 @@ - - + +