nitdoc: makes quick-search field aware of paste from mouse.
authorAlexandre Terrasa <alexandre@moz-code.org>
Tue, 9 Dec 2014 20:27:35 +0000 (15:27 -0500)
committerAlexandre Terrasa <alexandre@moz-code.org>
Tue, 9 Dec 2014 20:27:35 +0000 (15:27 -0500)
Fixes #666

Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

share/nitdoc/js/plugins/quicksearch.js

index 13f500c..df006f9 100644 (file)
@@ -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 = $("<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) {