diff options
Diffstat (limited to 'lib/rdoc/generator/template/json_index')
-rw-r--r-- | lib/rdoc/generator/template/json_index/js/navigation.js | 44 | ||||
-rw-r--r-- | lib/rdoc/generator/template/json_index/js/searcher.js | 12 |
2 files changed, 10 insertions, 46 deletions
diff --git a/lib/rdoc/generator/template/json_index/js/navigation.js b/lib/rdoc/generator/template/json_index/js/navigation.js index 43c5118abd..dfad74b1ae 100644 --- a/lib/rdoc/generator/template/json_index/js/navigation.js +++ b/lib/rdoc/generator/template/json_index/js/navigation.js @@ -10,10 +10,8 @@ Navigation = new function() { this.initNavigation = function() { var _this = this; - $(document).keydown(function(e) { + document.addEventListener('keydown', function(e) { _this.onkeydown(e); - }).keyup(function(e) { - _this.onkeyup(e); }); this.navigationActive = true; @@ -21,20 +19,6 @@ Navigation = new function() { this.setNavigationActive = function(state) { this.navigationActive = state; - this.clearMoveTimeout(); - } - - this.onkeyup = function(e) { - if (!this.navigationActive) return; - - switch(e.keyCode) { - case 37: //Event.KEY_LEFT: - case 38: //Event.KEY_UP: - case 39: //Event.KEY_RIGHT: - case 40: //Event.KEY_DOWN: - this.clearMoveTimeout(); - break; - } } this.onkeydown = function(e) { @@ -46,7 +30,6 @@ Navigation = new function() { case 38: //Event.KEY_UP: if (e.keyCode == 38 || e.ctrlKey) { if (this.moveUp()) e.preventDefault(); - this.startMoveTimeout(false); } break; case 39: //Event.KEY_RIGHT: @@ -55,33 +38,14 @@ Navigation = new function() { case 40: //Event.KEY_DOWN: if (e.keyCode == 40 || e.ctrlKey) { if (this.moveDown()) e.preventDefault(); - this.startMoveTimeout(true); } break; case 13: //Event.KEY_RETURN: - if (this.$current) e.preventDefault(); - this.select(this.$current); + if (this.current) e.preventDefault(); + this.select(this.current); break; } - if (e.ctrlKey && e.shiftKey) this.select(this.$current); - } - - this.clearMoveTimeout = function() { - clearTimeout(this.moveTimeout); - this.moveTimeout = null; - } - - this.startMoveTimeout = function(isDown) { - if (!$.browser.mozilla && !$.browser.opera) return; - if (this.moveTimeout) this.clearMoveTimeout(); - var _this = this; - - var go = function() { - if (!_this.moveTimeout) return; - _this[isDown ? 'moveDown' : 'moveUp'](); - _this.moveTimeout = setTimeout(go, 100); - } - this.moveTimeout = setTimeout(go, 200); + if (e.ctrlKey && e.shiftKey) this.select(this.current); } this.moveRight = function() { diff --git a/lib/rdoc/generator/template/json_index/js/searcher.js b/lib/rdoc/generator/template/json_index/js/searcher.js index b3b1c58a0f..e200a168b0 100644 --- a/lib/rdoc/generator/template/json_index/js/searcher.js +++ b/lib/rdoc/generator/template/json_index/js/searcher.js @@ -51,20 +51,20 @@ Searcher.prototype = new function() { /* ----- Utilities ------ */ function splitQuery(query) { - return jQuery.grep(query.split(/(\s+|::?|\(\)?)/), function(string) { + return query.split(/(\s+|::?|\(\)?)/).filter(function(string) { return string.match(/\S/); }); } function buildRegexps(queries) { - return jQuery.map(queries, function(query) { + return queries.map(function(query) { return new RegExp(query.replace(/(.)/g, '([$1])([^$1]*?)'), 'i'); }); } function buildHilighters(queries) { - return jQuery.map(queries, function(query) { - return jQuery.map(query.split(''), function(l, i) { + return queries.map(function(query) { + return query.split('').map(function(l, i) { return '\u0001$' + (i*2+1) + '\u0002$' + (i*2+2); }).join(''); }); @@ -221,9 +221,9 @@ Searcher.prototype = new function() { } function triggerResults(results, isLast) { - jQuery.each(this.handlers, function(i, fn) { + this.handlers.forEach(function(fn) { fn.call(this, results, isLast) - }) + }); } } |