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 --- docs/assets/js/bootstrap.js | 142 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 136 insertions(+), 6 deletions(-) (limited to 'docs/assets/js/bootstrap.js') diff --git a/docs/assets/js/bootstrap.js b/docs/assets/js/bootstrap.js index 7431e9777..ff524ce00 100644 --- a/docs/assets/js/bootstrap.js +++ b/docs/assets/js/bootstrap.js @@ -127,6 +127,8 @@ /* ALERT PLUGIN DEFINITION * ======================= */ + var old = $.fn.alert + $.fn.alert = function (option) { return this.each(function () { var $this = $(this) @@ -139,6 +141,15 @@ $.fn.alert.Constructor = Alert + /* ALERT NO CONFLICT + * ================= */ + + $.fn.alert.noConflict = function () { + $.fn.alert = old + return this + } + + /* ALERT DATA-API * ============== */ @@ -210,6 +221,8 @@ /* BUTTON PLUGIN DEFINITION * ======================== */ + var old = $.fn.button + $.fn.button = function (option) { return this.each(function () { var $this = $(this) @@ -228,6 +241,15 @@ $.fn.button.Constructor = Button + /* BUTTON NO CONFLICT + * ================== */ + + $.fn.button.noConflict = function () { + $.fn.button = old + return this + } + + /* BUTTON DATA-API * =============== */ @@ -380,6 +402,8 @@ /* CAROUSEL PLUGIN DEFINITION * ========================== */ + var old = $.fn.carousel + $.fn.carousel = function (option) { return this.each(function () { var $this = $(this) @@ -401,6 +425,14 @@ $.fn.carousel.Constructor = Carousel + /* CAROUSEL NO CONFLICT + * ==================== */ + + $.fn.carousel.noConflict = function () { + $.fn.carousel = old + return this + } + /* CAROUSEL DATA-API * ================= */ @@ -534,8 +566,10 @@ } - /* COLLAPSIBLE PLUGIN DEFINITION - * ============================== */ + /* COLLAPSE PLUGIN DEFINITION + * ========================== */ + + var old = $.fn.collapse $.fn.collapse = function (option) { return this.each(function () { @@ -554,9 +588,18 @@ $.fn.collapse.Constructor = Collapse - /* COLLAPSIBLE DATA-API + /* COLLAPSE NO CONFLICT * ==================== */ + $.fn.collapse.noConflict = function () { + $.fn.collapse = old + return this + } + + + /* COLLAPSE DATA-API + * ================= */ + $(document).on('click.collapse.data-api', '[data-toggle=collapse]', function (e) { var $this = $(this), href , target = $this.attr('data-target') @@ -693,6 +736,8 @@ /* DROPDOWN PLUGIN DEFINITION * ========================== */ + var old = $.fn.dropdown + $.fn.dropdown = function (option) { return this.each(function () { var $this = $(this) @@ -705,6 +750,15 @@ $.fn.dropdown.Constructor = Dropdown + /* DROPDOWN NO CONFLICT + * ==================== */ + + $.fn.dropdown.noConflict = function () { + $.fn.dropdown = old + return this + } + + /* APPLY TO STANDARD DROPDOWN ELEMENTS * =================================== */ @@ -910,6 +964,8 @@ /* MODAL PLUGIN DEFINITION * ======================= */ + var old = $.fn.modal + $.fn.modal = function (option) { return this.each(function () { var $this = $(this) @@ -930,6 +986,15 @@ $.fn.modal.Constructor = Modal + /* MODAL NO CONFLICT + * ================= */ + + $.fn.modal.noConflict = function () { + $.fn.modal = old + return this + } + + /* MODAL DATA-API * ============== */ @@ -1201,6 +1266,8 @@ /* TOOLTIP PLUGIN DEFINITION * ========================= */ + var old = $.fn.tooltip + $.fn.tooltip = function ( option ) { return this.each(function () { var $this = $(this) @@ -1224,6 +1291,15 @@ , html: false } + + /* TOOLTIP NO CONFLICT + * =================== */ + + $.fn.tooltip.noConflict = function () { + $.fn.tooltip = old + return this + } + }(window.jQuery);/* =========================================================== * bootstrap-popover.js v2.2.2 * http://twitter.github.com/bootstrap/javascript.html#popovers @@ -1307,6 +1383,8 @@ /* POPOVER PLUGIN DEFINITION * ======================= */ + var old = $.fn.popover + $.fn.popover = function (option) { return this.each(function () { var $this = $(this) @@ -1326,8 +1404,16 @@ , template: '

' }) -}(window.jQuery); -/* ============================================================= + + /* POPOVER NO CONFLICT + * =================== */ + + $.fn.popover.noConflict = function () { + $.fn.popover = old + return this + } + +}(window.jQuery);/* ============================================================= * bootstrap-scrollspy.js v2.2.2 * http://twitter.github.com/bootstrap/javascript.html#scrollspy * ============================================================= @@ -1450,6 +1536,8 @@ /* SCROLLSPY PLUGIN DEFINITION * =========================== */ + var old = $.fn.scrollspy + $.fn.scrollspy = function (option) { return this.each(function () { var $this = $(this) @@ -1467,6 +1555,15 @@ } + /* SCROLLSPY NO CONFLICT + * ===================== */ + + $.fn.scrollspy.noConflict = function () { + $.fn.scrollspy = old + return this + } + + /* SCROLLSPY DATA-API * ================== */ @@ -1589,6 +1686,8 @@ /* TAB PLUGIN DEFINITION * ===================== */ + var old = $.fn.tab + $.fn.tab = function ( option ) { return this.each(function () { var $this = $(this) @@ -1601,6 +1700,15 @@ $.fn.tab.Constructor = Tab + /* TAB NO CONFLICT + * =============== */ + + $.fn.tab.noConflict = function () { + $.fn.tab = old + return this + } + + /* TAB DATA-API * ============ */ @@ -1887,6 +1995,8 @@ /* TYPEAHEAD PLUGIN DEFINITION * =========================== */ + var old = $.fn.typeahead + $.fn.typeahead = function (option) { return this.each(function () { var $this = $(this) @@ -1908,7 +2018,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) { @@ -1989,6 +2108,8 @@ /* AFFIX PLUGIN DEFINITION * ======================= */ + var old = $.fn.affix + $.fn.affix = function (option) { return this.each(function () { var $this = $(this) @@ -2006,6 +2127,15 @@ } + /* AFFIX NO CONFLICT + * ================= */ + + $.fn.affix.noConflict = function () { + $.fn.affix = old + return this + } + + /* AFFIX DATA-API * ============== */ -- cgit v1.2.3 From 66b70016d0f083098c32ad051173e6f52a6b2084 Mon Sep 17 00:00:00 2001 From: fat Date: Fri, 7 Dec 2012 17:14:49 -0500 Subject: rebuild and only select visible dropdown items --- docs/assets/js/bootstrap.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'docs/assets/js/bootstrap.js') diff --git a/docs/assets/js/bootstrap.js b/docs/assets/js/bootstrap.js index ff524ce00..e6bcfb62a 100644 --- a/docs/assets/js/bootstrap.js +++ b/docs/assets/js/bootstrap.js @@ -694,7 +694,7 @@ if (!isActive || (isActive && e.keyCode == 27)) return $this.click() - $items = $('[role=menu] li:not(.divider) a', $parent) + $items = $('[role=menu] li:not(.divider):visible a', $parent) if (!$items.length) return @@ -1474,7 +1474,7 @@ , $href = /^#\w/.test(href) && $(href) return ( $href && $href.length - && [[ $href.position().top, href ]] ) || null + && [[ $href.position().top + self.$scrollElement.scrollTop(), href ]] ) || null }) .sort(function (a, b) { return a[0] - b[0] }) .each(function () { -- cgit v1.2.3 From 91fbadad5b058f160eb3b5eb8e88432e0088efee Mon Sep 17 00:00:00 2001 From: fat Date: Fri, 7 Dec 2012 17:49:05 -0500 Subject: remove slide from carousel constructor #5579 --- docs/assets/js/bootstrap.js | 1 - 1 file changed, 1 deletion(-) (limited to 'docs/assets/js/bootstrap.js') diff --git a/docs/assets/js/bootstrap.js b/docs/assets/js/bootstrap.js index e6bcfb62a..422699ce1 100644 --- a/docs/assets/js/bootstrap.js +++ b/docs/assets/js/bootstrap.js @@ -290,7 +290,6 @@ var Carousel = function (element, options) { this.$element = $(element) this.options = options - this.options.slide && this.slide(this.options.slide) this.options.pause == 'hover' && this.$element .on('mouseenter', $.proxy(this.pause, this)) .on('mouseleave', $.proxy(this.cycle, this)) -- cgit v1.2.3 From 437654030aa283b92a260245b54fa17a417c20d8 Mon Sep 17 00:00:00 2001 From: fat Date: Fri, 7 Dec 2012 18:37:32 -0500 Subject: focus on escape in typeahead --- docs/assets/js/bootstrap.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'docs/assets/js/bootstrap.js') diff --git a/docs/assets/js/bootstrap.js b/docs/assets/js/bootstrap.js index 422699ce1..ce634fee3 100644 --- a/docs/assets/js/bootstrap.js +++ b/docs/assets/js/bootstrap.js @@ -664,9 +664,10 @@ if (!isActive) { $parent.toggleClass('open') - $this.focus() } + $this.focus() + return false } @@ -1935,7 +1936,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 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 --- docs/assets/js/bootstrap.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'docs/assets/js/bootstrap.js') diff --git a/docs/assets/js/bootstrap.js b/docs/assets/js/bootstrap.js index ce634fee3..d791b88de 100644 --- a/docs/assets/js/bootstrap.js +++ b/docs/assets/js/bootstrap.js @@ -1752,7 +1752,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() @@ -1775,7 +1775,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 --- docs/assets/js/bootstrap.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'docs/assets/js/bootstrap.js') diff --git a/docs/assets/js/bootstrap.js b/docs/assets/js/bootstrap.js index d791b88de..6c15a5832 100644 --- a/docs/assets/js/bootstrap.js +++ b/docs/assets/js/bootstrap.js @@ -1752,8 +1752,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() } @@ -1779,12 +1779,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