From 9863d337024df7510788667c2dbde84dcdb74b4f Mon Sep 17 00:00:00 2001 From: Alexandre Terrasa Date: Tue, 9 Dec 2014 15:27:35 -0500 Subject: [PATCH] nitdoc: makes quick-search field aware of paste from mouse. Fixes #666 Signed-off-by: Alexandre Terrasa --- share/nitdoc/js/plugins/quicksearch.js | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/share/nitdoc/js/plugins/quicksearch.js b/share/nitdoc/js/plugins/quicksearch.js index 13f500c..df006f9 100644 --- a/share/nitdoc/js/plugins/quicksearch.js +++ b/share/nitdoc/js/plugins/quicksearch.js @@ -52,17 +52,21 @@ define([ }, _create: function() { - this.element - .attr(this.options.fieldAttrs) - .keydown($.proxy(this._doKeyDown, this)) - .keyup($.proxy(this._doKeyUp, this)) - + // set widget options + this.element.attr(this.options.fieldAttrs); + // event dispatch + this._on(this.element, { + "keydown": this._doKeyDown, + "keyup": this._doKeyUp, + "input": this._doInput + }); + // add result table element once this._table = $("") .attr("id", this.options.tableID) .css(this.options.tableCSS) .css("min-width", this.element.outerWidth()); $("body").append(this._table); - + // make table disappear when a click occurs outside $(document).click($.proxy(this.closeTable, this)); }, @@ -94,11 +98,14 @@ define([ this.closeTable(); return true; default: // Other keys - utils.delayEvent($.proxy(this.search, this)); return true; } }, + _doInput: function(event) { + utils.delayEvent($.proxy(this.search, this)); + }, + /* Result lookup */ _getResults: function(query) { -- 1.7.9.5