From 6ec7c72e5b5152afb676c43ea57a51fb625f9ba2 Mon Sep 17 00:00:00 2001 From: Paul McLanahan Date: Fri, 9 Nov 2012 11:48:21 -0500 Subject: Fix issue with double move event firing in typeahead. Fix test to catch issue. Fix #5806. --- js/bootstrap-typeahead.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/bootstrap-typeahead.js') diff --git a/js/bootstrap-typeahead.js b/js/bootstrap-typeahead.js index 512d91acb..26d845258 100644 --- a/js/bootstrap-typeahead.js +++ b/js/bootstrap-typeahead.js @@ -217,7 +217,7 @@ } , keydown: function (e) { - this.suppressKeyPressRepeat = !~$.inArray(e.keyCode, [40,38,9,13,27]) + this.suppressKeyPressRepeat = ~$.inArray(e.keyCode, [40,38,9,13,27]) this.move(e) } -- cgit v1.2.3 From a7eb9c294a575b5471ddec45ae75e1d09f7ace4c Mon Sep 17 00:00:00 2001 From: fat Date: Fri, 7 Dec 2012 17:06:01 -0500 Subject: add noConflict functionality to all bootstrap plugins --- js/bootstrap-typeahead.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'js/bootstrap-typeahead.js') diff --git a/js/bootstrap-typeahead.js b/js/bootstrap-typeahead.js index 512d91acb..9b123fb3f 100644 --- a/js/bootstrap-typeahead.js +++ b/js/bootstrap-typeahead.js @@ -276,6 +276,8 @@ /* TYPEAHEAD PLUGIN DEFINITION * =========================== */ + var old = $.fn.typeahead + $.fn.typeahead = function (option) { return this.each(function () { var $this = $(this) @@ -297,7 +299,16 @@ $.fn.typeahead.Constructor = Typeahead - /* TYPEAHEAD DATA-API + /* TYPEAHEAD NO CONFLICT + * =================== */ + + $.fn.typeahead.noConflict = function () { + $.fn.typeahead = old + return this + } + + + /* TYPEAHEAD DATA-API * ================== */ $(document).on('focus.typeahead.data-api', '[data-provide="typeahead"]', function (e) { -- cgit v1.2.3 From 1747caf19d59cad7fdc90ae56a00e0e2849f95f4 Mon Sep 17 00:00:00 2001 From: fat Date: Fri, 7 Dec 2012 18:59:13 -0500 Subject: insert menu of typeahead after input which it suggests on #3529 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit note: this will likely break things for people in the same way that doing this to tooltip did… however we think this is a better insertion model for z-index,scrolling,modal,etc. applications --- js/bootstrap-typeahead.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'js/bootstrap-typeahead.js') diff --git a/js/bootstrap-typeahead.js b/js/bootstrap-typeahead.js index 387fd2a6d..3c9153c9b 100644 --- a/js/bootstrap-typeahead.js +++ b/js/bootstrap-typeahead.js @@ -33,7 +33,7 @@ this.sorter = this.options.sorter || this.sorter this.highlighter = this.options.highlighter || this.highlighter this.updater = this.options.updater || this.updater - this.$menu = $(this.options.menu).appendTo('body') + this.$menu = $(this.options.menu).insertAfter(this.$element) this.source = this.options.source this.shown = false this.listen() @@ -56,7 +56,7 @@ } , show: function () { - var pos = $.extend({}, this.$element.offset(), { + var pos = $.extend({}, this.$element.position(), { height: this.$element[0].offsetHeight }) -- cgit v1.2.3 From 820a3b27b6cfd320584be5a8e1652c7dff9771e4 Mon Sep 17 00:00:00 2001 From: fat Date: Fri, 7 Dec 2012 19:16:48 -0500 Subject: get tests passing for typeahead :P --- js/bootstrap-typeahead.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'js/bootstrap-typeahead.js') diff --git a/js/bootstrap-typeahead.js b/js/bootstrap-typeahead.js index 3c9153c9b..088e7ce9b 100644 --- a/js/bootstrap-typeahead.js +++ b/js/bootstrap-typeahead.js @@ -33,8 +33,8 @@ this.sorter = this.options.sorter || this.sorter this.highlighter = this.options.highlighter || this.highlighter this.updater = this.options.updater || this.updater - this.$menu = $(this.options.menu).insertAfter(this.$element) this.source = this.options.source + this.$menu = $(this.options.menu) this.shown = false this.listen() } @@ -60,12 +60,14 @@ height: this.$element[0].offsetHeight }) - this.$menu.css({ - top: pos.top + pos.height - , left: pos.left - }) + this.$menu + .insertAfter(this.$element) + .css({ + top: pos.top + pos.height + , left: pos.left + }) + .show() - this.$menu.show() this.shown = true return this } -- cgit v1.2.3