Skip to content

Commit

Permalink
Libdoc: Search shortcut (s to open, esc to close) #1872
Browse files Browse the repository at this point in the history
  • Loading branch information
pekkaklarck committed Dec 16, 2014
1 parent b206dd2 commit e1d8c74
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/robot/htmldata/libdoc/libdoc.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ <h1>Opening library documentation failed</h1>
renderTemplate('keywords', libdoc);
scrollToHash();
}
$(document).bind('keydown', handleKeydown);
});

function parseTemplates() {
Expand All @@ -67,6 +68,15 @@ <h1>Opening library documentation failed</h1>
$.tmpl(name + '-template', argument).appendTo(container);
}

function handleKeydown(event) {
event = event || window.event;
var keyCode = event.keyCode || event.which;
if (keyCode === 27) // esc
setTimeout(closeSearch, 0);
if (keyCode === 83 && $('#search').is(':hidden')) // s
setTimeout(openSearch, 0);
}

function scrollToHash() {
if (window.location.hash) {
var hash = window.location.hash.substring(1).replace('+', ' ');
Expand Down Expand Up @@ -183,12 +193,13 @@ <h2 id="Introduction">Introduction</h2>
<input type="checkbox" id="include-doc" onclick="doSearch()" checked>
<label for="include-doc">Documentation</label>
</fieldset>
<input type="button" value="Reset" onclick="resetSearch()">
<input type="button" value="Close" onclick="closeSearch()">
<input type="button" value="Reset" onclick="resetSearch()"
title="Reset search">
<input type="button" value="Close" onclick="closeSearch()"
title="Close search (shortcut: <Esc>)">
</fieldset>
</form>
<!-- TODO: Placefolder until we get real icon -->
<div id="open-search" onclick="openSearch()"></div>
<div id="open-search" onclick="openSearch()" title="Search keywords (shortcut: s)"></div>
</script>

<script type="text/x-jquery-tmpl" id="importing-template">
Expand Down

0 comments on commit e1d8c74

Please sign in to comment.