diff options
Diffstat (limited to 'theme/javascript/core')
-rwxr-xr-x | theme/javascript/core/keyboard.js | 39 | ||||
-rwxr-xr-x | theme/javascript/core/navigation.js | 6 |
2 files changed, 22 insertions, 23 deletions
diff --git a/theme/javascript/core/keyboard.js b/theme/javascript/core/keyboard.js index 22fe953..27a9247 100755 --- a/theme/javascript/core/keyboard.js +++ b/theme/javascript/core/keyboard.js @@ -1,38 +1,39 @@ define([ - "jQuery", - "Mousetrap", - "core/navigation", - "core/sidebar", - "core/search" -], function($, Mousetrap, navigation, sidebar, search){ + 'jQuery', + 'Mousetrap', + 'core/navigation', + 'core/sidebar' +], function($, Mousetrap, navigation, sidebar){ + + // Bind a keyboard shortcuts + function bindShortcut(keys, fn) { + Mousetrap.bind(keys, function(e) { + fn(); + return false; + }); + } + + // Bind keyboard shortcuts var init = function() { // Next - Mousetrap.bind(['right'], function(e) { + bindShortcut(['right'], function(e) { navigation.goNext(); - return false; }); // Prev - Mousetrap.bind(['left'], function(e) { + bindShortcut(['left'], function(e) { navigation.goPrev(); - return false; }); // Toggle Summary - Mousetrap.bind(['s'], function(e) { + bindShortcut(['s'], function(e) { sidebar.toggle(); - return false; - }); - - // Toggle Search - Mousetrap.bind(['f'], function(e) { - search.toggle(); - return false; }); }; return { - init: init + init: init, + bind: bindShortcut }; });
\ No newline at end of file diff --git a/theme/javascript/core/navigation.js b/theme/javascript/core/navigation.js index c1766ab..060eb7a 100755 --- a/theme/javascript/core/navigation.js +++ b/theme/javascript/core/navigation.js @@ -4,9 +4,8 @@ define([ "core/events", "core/state", "core/progress", - "core/loading", - "core/search" -], function($, URL, events, state, progress, loading, search) { + "core/loading" +], function($, URL, events, state, progress, loading) { var prev, next; var usePushState = (typeof history.pushState !== "undefined"); @@ -67,7 +66,6 @@ define([ // Update state state.update($("html")); // recover search keyword - search.recover(); preparePage(); }) .fail(function (e) { |