From: Andrew Dolgov Date: Thu, 15 May 2008 15:57:14 +0000 (+0100) Subject: rework hotkeys (incomplete) X-Git-Tag: 1.2.23-final~136 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=4298481d698393bbc2950330416af549599b595f;p=tt-rss.git rework hotkeys (incomplete) --- diff --git a/functions.js b/functions.js index 4c574eaf..ed9a08e5 100644 --- a/functions.js +++ b/functions.js @@ -1,7 +1,7 @@ var hotkeys_enabled = true; var debug_mode_enabled = false; var xmlhttp_rpc = Ajax.getTransport(); - +var hotkey_prefix = false; var hotkey_zone = 0; /* add method to remove element from array */ @@ -79,7 +79,9 @@ function open_article_callback(transport) { if (link) { debug("link url: " + link.firstChild.nodeValue); - window.open(link.firstChild.nodeValue, "_blank"); + var w = window.open(link.firstChild.nodeValue, "_blank"); + + if (!w) { notify_error("Failed to load article in new window"); } if (id) { id = id.firstChild.nodeValue; @@ -214,23 +216,202 @@ function hotkey_handler(e) { var keycode; var shift_key = false; + var feedlist = document.getElementById('feedList'); + 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 ((keycode == 70 || keycode == 67) && !hotkey_prefix) { + hotkey_prefix = keycode; + debug("KP: PREFIX=" + keycode); + return; + } + + if (Element.visible("hotkey_help_overlay")) { + Element.hide("hotkey_help_overlay"); + } + + /* 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'; + } - if (window.event) { - keycode = window.event.keyCode; - } else if (e) { - keycode = e.which; + 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 == 191) { // / + return displayDlg("search", getActiveFeedId()); + } + + if (keycode == 74) { // j + var feed = getActiveFeedId(); + var new_feed = getRelativeFeedId(feedlist, feed, 'prev'); + if (new_feed) viewfeed(new_feed, ''); + return; + } + + if (keycode == 75) { // k + var feed = getActiveFeedId(); + var new_feed = getRelativeFeedId(feedlist, feed, 'next'); + if (new_feed) viewfeed(new_feed, ''); + return; + } + + if (keycode == 78 || keycode == 40) { // n, down + if (typeof moveToPost != 'undefined') { + return moveToPost('next'); + } + } + + if (keycode == 80 || keycode == 38) { // p, up + if (typeof moveToPost != 'undefined') { + return moveToPost('prev'); + } + } + + if (keycode == 83 && shift_key) { // S + var id = getActiveArticleId(); + if (id) { + togglePub(id); + } + return; + } + + if (keycode == 83) { // s + var id = getActiveArticleId(); + if (id) { + toggleMark(id); + } + return; + } + + + if (keycode == 85) { // u + var id = getActiveArticleId(); + if (id) { + toggleUnread(id); + } + return; + } + + if (keycode == 84) { // t + /* FIXME: edit tags */ + return notify_error("Function not implemented"); + } + + if (keycode == 84) { // t + /* FIXME: edit tags */ + return notify_error("Function not implemented"); + } + + if (keycode == 79) { // o + if (getActiveArticleId()) { + openArticleInNewWindow(getActiveArticleId()); + } + } + } + /* Prefix f */ + + if (hotkey_prefix == 70) { // f + + hotkey_prefix = false; + + if (keycode == 65) { // a + return toggleDispRead(); + } + + if (keycode == 85 && shift_key) { // r + return scheduleFeedUpdate(true); + } + + if (keycode == 85) { // u + if (getActiveFeedId()) { + return viewfeed(getActiveFeedId(), "ForceUpdate"); + } + } + + if (keycode == 69) { // e + return editFeedDlg(getActiveFeedId()); + } + + if (keycode == 83) { // s + return displayDlg("quickAddFeed"); + } + + if (keycode == 67 && shift_key) { // C + if (typeof catchupAllFeeds != 'undefined') { + return catchupAllFeeds(); + } + } + + if (keycode == 67) { // c + if (getActiveFeedId()) { + return catchupCurrentFeed(); + } + } + + } + + /* Prefix c */ + + if (hotkey_prefix == 67) { // c + hotkey_prefix = false; + + if (keycode == 70) { // f + return displayDlg("quickAddFilter", getActiveFeedId()); + } + + if (keycode == 83) { // s + if (typeof collapse_feedlist != 'undefined') { + return collapse_feedlist(); + } + } + + } +/* if (keycode == 48) { // 0 return setHotkeyZone(0); } @@ -310,16 +491,12 @@ function hotkey_handler(e) { debug_mode_enabled = !debug_mode_enabled; } - if (keycode == 190 && shift_key) { // > - viewFeedGoPage(1); - } - - if (keycode == 188 && shift_key) { // < - viewFeedGoPage(-1); - } - if (keycode == 191 && shift_key) { // ? - viewFeedGoPage(0); + if (!Element.visible("hotkey_help_overlay")) { + Element.show("hotkey_help_overlay"); + } else { + Element.hide("hotkey_help_overlay"); + } } if (keycode == 69 && shift_key) { // e @@ -392,6 +569,12 @@ function hotkey_handler(e) { } } + if (keycode == 27) { // escape + if (Element.visible("hotkey_help_overlay")) { + Element.hide("hotkey_help_overlay"); + } + } */ + if (typeof localHotkeyHandler != 'undefined') { try { return localHotkeyHandler(e); @@ -400,7 +583,14 @@ function hotkey_handler(e) { } } - debug("KP=" + keycode); + if (hotkey_prefix) { + debug("KP: PREFIX=" + hotkey_prefix + " CODE=" + keycode); + + } else { + debug("KP: CODE=" + keycode); + } + + } catch (e) { exception_error("hotkey_handler", e); } diff --git a/help/3.php b/help/3.php new file mode 100644 index 00000000..28c38e00 --- /dev/null +++ b/help/3.php @@ -0,0 +1,47 @@ +

Keyboard Shortcuts

+ +
+ +

Navigation

+ + + + + +
j/kMove between feeds
n/pMove between articles
/Show search dialog
+ +

Active article actions

+ + + + + + + +
sToggle starred
shift-SToggle published
uToggle unread
tEdit tags
+ +
+ +

Feed actions

+ + + + + + + + + +
f a(Un)hide read feeds
f sSubscribe to feed
f uUpdate feed
f UUpdate all feeds
f eEdit feed
f cMark feed as read
f CMark all feeds as read
+ +

Other actions

+ + + + + +
c fCreate filter
c sCollapse sidebar
?Display this help dialog
+ +
+ +

Press any key to close this window.

diff --git a/images/shadow_dark.png b/images/shadow_dark.png new file mode 100644 index 00000000..3a26b2a5 Binary files /dev/null and b/images/shadow_dark.png differ diff --git a/tt-rss.css b/tt-rss.css index 47cce5eb..14256b61 100644 --- a/tt-rss.css +++ b/tt-rss.css @@ -239,7 +239,7 @@ input.editbox { display : none; float : right; font-size : 9pt; - z-index : 999; + z-index : 998; -moz-border-radius : 2px; padding : 5px 5px 5px 5px; } @@ -1790,3 +1790,55 @@ img.hlScorePic { height : 16px; } +div#hotkey_help_overlay { + position : absolute; + left : 15%; + right : 15%; + top : 15%; + z-index : 999; +/* background-color : #f8fcf5; + border-width : 1px 1px 1px 1px; + border-style : solid; + border-color : #99d67a; */ + padding : 1em; + background : url("images/shadow_dark.png"); + color : white; + border : 1px solid black; +} + +div#hotkey_help_overlay h1 { + text-align : center; +} + +div#hotkey_help_overlay ul { + list-style-type : none; + margin : 0px; +} + +div#hotkey_help_overlay li { + margin : 0px; +} + +div#hotkey_help_overlay p { + text-align : center; +} + +div#hotkey_help_overlay td.n { + text-align : right; + font-weight : bold; + width : 6em; + color : #a0ffa0; + padding-right : 5px; +} + +div#hotkey_help_overlay h1 { + margin : 0px 0px 0.5em 0px; +} + +div#hotkey_help_overlay h2 { + font-size : 13pt; + border-width : 0px; + margin : 0.7em 0px 0.5em 0px; + text-align : center; + color : #88b0f0; +} diff --git a/tt-rss.php b/tt-rss.php index 37728aa7..1bb490b3 100644 --- a/tt-rss.php +++ b/tt-rss.php @@ -82,6 +82,10 @@ +
+ +
+