hotkey support for prefs

This commit is contained in:
Andrew Dolgov 2008-05-16 07:05:12 +01:00
parent 85ef21180b
commit 746dcf4299
6 changed files with 137 additions and 18 deletions

37
help/4.php Normal file
View File

@ -0,0 +1,37 @@
<h1><?php echo __("Keyboard Shortcuts") ?></h1>
<table width='100%'><tr><td width='50%' valign='top'>
<h2><?php echo __("Navigation") ?></h2>
<table>
<tr><td class='n'>1</td><td><?php echo __("Preferences") ?></td></tr>
<tr><td class='n'>2</td><td><?php echo __("My Feeds") ?></td></tr>
<tr><td class='n'>3</td><td><?php echo __("Other Feeds") ?></td></tr>
<tr><td class='n'>4</td><td><?php echo __("Content Filtering") ?></td></tr>
<tr><td class='n'>5</td><td><?php echo __("Label Editor") ?></td></tr>
<tr><td class='n'>6</td><td><?php echo __("User Manager") ?></td></tr>
</table>
</td><td valign='top'>
<h2><?php echo __("Panel actions") ?></h2>
<table>
<tr><td class='n'>c s</td><td><?php echo __("Subscribe to feed") ?></td></tr>
<tr><td class='n'>c f</td><td><?php echo __("Create filter") ?></td></tr>
<tr><td class='n'>c l</td><td><?php echo __("Create label") ?></td></tr>
<tr><td class='n'>c u</td><td><?php echo __("Create user") ?></td></tr>
</table>
<h2><?php echo __("Other actions") ?></h2>
<table>
<tr><td class='n'>g x</td><td><?php echo __("Exit preferences") ?></td></tr>
</table>
</td></tr></table>
<p class='insensitive'><span class='small'>Note: not all actions may be available, depending on Tiny Tiny RSS configuration and your access level.</span></p>
<p class="small"><?php echo __("Press any key to close this window.") ?></p>

View File

@ -6,7 +6,7 @@
function module_pref_labels($link) { function module_pref_labels($link) {
if (!GLOBAL_ENABLE_LABELS) { if (!GLOBAL_ENABLE_LABELS) {
print "<p>Sorry, labels have been administratively disabled for this installation. Please contact instance owner or edit configuration file to enable this functionality.</p>"; print __("Sorry, labels have been administratively disabled for this installation. Please contact instance owner or edit configuration file to enable this functionality.");
return; return;
} }

View File

@ -10,8 +10,8 @@ var xmlhttp = Ajax.getTransport();
var init_params = new Array(); var init_params = new Array();
var caller_subop = false; var caller_subop = false;
var sanity_check_done = false; var sanity_check_done = false;
var hotkey_prefix = false;
function infobox_callback() { function infobox_callback() {
if (xmlhttp.readyState == 4) { if (xmlhttp.readyState == 4) {
@ -1654,8 +1654,13 @@ function pref_hotkey_handler(e) {
try { try {
var keycode; var keycode;
var shift_key = false;
if (!hotkeys_enabled) return; try {
shift_key = e.shiftKey;
} catch (e) {
}
if (window.event) { if (window.event) {
keycode = window.event.keyCode; keycode = window.event.keyCode;
@ -1663,12 +1668,81 @@ function pref_hotkey_handler(e) {
keycode = e.which; 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) { if (keycode == 13 || keycode == 27) {
seq = ""; seq = "";
} else { } else {
seq = seq + "" + keycode; seq = seq + "" + keycode;
} }
/* Global hotkeys */
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';
}
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 (document.getElementById("piggie")) {
@ -1680,6 +1754,12 @@ function pref_hotkey_handler(e) {
} }
} }
if (hotkey_prefix) {
debug("KP: PREFIX=" + hotkey_prefix + " CODE=" + keycode);
} else {
debug("KP: CODE=" + keycode);
}
} catch (e) { } catch (e) {
exception_error("pref_hotkey_handler", e); exception_error("pref_hotkey_handler", e);
} }

View File

@ -69,12 +69,14 @@
<body> <body>
<img id="piggie" src="images/piggie.png" style="display : none" alt="piggie">
<div id="hotkey_help_overlay" style="display : none" onclick="Element.hide(this)"> <div id="hotkey_help_overlay" style="display : none" onclick="Element.hide(this)">
<?php rounded_table_start("hho"); ?>
<?php include "help/4.php" ?> <?php include "help/4.php" ?>
<?php rounded_table_end(); ?>
</div> </div>
<img id="piggie" src="images/piggie.png" style="display : none" alt="piggie">
<script type="text/javascript"> <script type="text/javascript">
if (document.addEventListener) { if (document.addEventListener) {
document.addEventListener("DOMContentLoaded", init, null); document.addEventListener("DOMContentLoaded", init, null);

View File

@ -674,7 +674,7 @@ span.feed_error {
color : red; color : red;
} }
span.insensitive, div.insensitive, li.insensitive, label.insensitive, td.insensitive { .insensitive {
color : gray; color : gray;
} }

View File

@ -1302,7 +1302,7 @@ function hotkey_handler(e) {
if (Element.visible("hotkey_help_overlay")) { if (Element.visible("hotkey_help_overlay")) {
Element.hide("hotkey_help_overlay"); Element.hide("hotkey_help_overlay");
} }
} */ }
if (typeof localHotkeyHandler != 'undefined') { if (typeof localHotkeyHandler != 'undefined') {
try { try {
@ -1310,7 +1310,7 @@ function hotkey_handler(e) {
} catch (e) { } catch (e) {
exception_error("hotkey_handler, local:", e); exception_error("hotkey_handler, local:", e);
} }
} } */
if (hotkey_prefix) { if (hotkey_prefix) {
debug("KP: PREFIX=" + hotkey_prefix + " CODE=" + keycode); debug("KP: PREFIX=" + hotkey_prefix + " CODE=" + keycode);