From 170ba560c242a38293b46ac3871549a262b58e64 Mon Sep 17 00:00:00 2001 From: Chris Rebert Date: Sat, 19 Apr 2014 18:53:23 -0700 Subject: quote attribute value in ^= selector in button.js --- js/button.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/button.js') diff --git a/js/button.js b/js/button.js index f4d8d8b30..be3b769c2 100644 --- a/js/button.js +++ b/js/button.js @@ -97,7 +97,7 @@ // BUTTON DATA-API // =============== - $(document).on('click.bs.button.data-api', '[data-toggle^=button]', function (e) { + $(document).on('click.bs.button.data-api', '[data-toggle^="button"]', function (e) { var $btn = $(e.target) if (!$btn.hasClass('btn')) $btn = $btn.closest('.btn') $btn.button('toggle') -- cgit v1.2.3 From a9f2b6ce0fb2ac059e30da259f7ae25282803c09 Mon Sep 17 00:00:00 2001 From: Collin Donahue-Oponski Date: Mon, 21 Apr 2014 23:03:33 -0600 Subject: #11464 - Fix JS noConflict mode - Refactor all plugins to use an internal reference to the jQuery plugin, because in noConflict mode you can never expect to be defined on the jQuery object --- js/button.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'js/button.js') diff --git a/js/button.js b/js/button.js index be3b769c2..b359a6ec6 100644 --- a/js/button.js +++ b/js/button.js @@ -67,9 +67,7 @@ // BUTTON PLUGIN DEFINITION // ======================== - var old = $.fn.button - - $.fn.button = function (option) { + function Plugin(option) { return this.each(function () { var $this = $(this) var data = $this.data('bs.button') @@ -82,6 +80,9 @@ }) } + var old = $.fn.button + + $.fn.button = Plugin $.fn.button.Constructor = Button @@ -100,7 +101,7 @@ $(document).on('click.bs.button.data-api', '[data-toggle^="button"]', function (e) { var $btn = $(e.target) if (!$btn.hasClass('btn')) $btn = $btn.closest('.btn') - $btn.button('toggle') + Plugin.call($btn, 'toggle') e.preventDefault() }) -- cgit v1.2.3 From d8ee1ba9b61ef4ba5b0494433e3a6eac414ef782 Mon Sep 17 00:00:00 2001 From: Heinrich Fenkart Date: Mon, 5 May 2014 12:11:59 +0200 Subject: Allow for resetText of a button to be a falsey value; fixes #13466 --- js/button.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'js/button.js') diff --git a/js/button.js b/js/button.js index b359a6ec6..bbce6690e 100644 --- a/js/button.js +++ b/js/button.js @@ -31,9 +31,9 @@ state = state + 'Text' - if (!data.resetText) $el.data('resetText', $el[val]()) + if (data.resetText == null) $el.data('resetText', $el[val]()) - $el[val](data[state] || this.options[state]) + $el[val](data[state] == null ? this.options[state] : data[state]) // push to event loop to allow forms to submit setTimeout($.proxy(function () { -- cgit v1.2.3 From f219fee07b14ea1d37e197b1d80f5c7a8e3bc186 Mon Sep 17 00:00:00 2001 From: fat Date: Mon, 12 May 2014 21:15:16 -0700 Subject: versions --- js/button.js | 2 ++ 1 file changed, 2 insertions(+) (limited to 'js/button.js') diff --git a/js/button.js b/js/button.js index bbce6690e..aa7145072 100644 --- a/js/button.js +++ b/js/button.js @@ -19,6 +19,8 @@ this.isLoading = false } + Button.VERSION = '3.1.1' + Button.DEFAULTS = { loadingText: 'loading...' } -- cgit v1.2.3 From 1c6fa9010daf0d0c21de9e20fe6ac4dba1788d90 Mon Sep 17 00:00:00 2001 From: Katie Zhu Date: Mon, 9 Jun 2014 22:18:05 -0700 Subject: MD/CommonJS/Globals #12909 --- js/button.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'js/button.js') diff --git a/js/button.js b/js/button.js index aa7145072..cab7d8c3d 100644 --- a/js/button.js +++ b/js/button.js @@ -7,7 +7,11 @@ * ======================================================================== */ -+function ($) { +(function (o_o) { + typeof define === 'function' && define.amd ? define(['jquery'], o_o) : + typeof exports === 'object' ? o_o(require('jquery')) : o_o(this.jQuery) +})(function ($) { + 'use strict'; // BUTTON PUBLIC CLASS DEFINITION @@ -107,4 +111,4 @@ e.preventDefault() }) -}(jQuery); +}); -- cgit v1.2.3 From e9d6756a1ac76a9db31a41e8e03f663bedc41b70 Mon Sep 17 00:00:00 2001 From: Heinrich Fenkart Date: Thu, 12 Jun 2014 06:00:02 +0200 Subject: Fix regression of #10038 introduced by #13772 --- js/button.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/button.js') diff --git a/js/button.js b/js/button.js index cab7d8c3d..c05c5e3dd 100644 --- a/js/button.js +++ b/js/button.js @@ -9,7 +9,7 @@ (function (o_o) { typeof define === 'function' && define.amd ? define(['jquery'], o_o) : - typeof exports === 'object' ? o_o(require('jquery')) : o_o(this.jQuery) + typeof exports === 'object' ? o_o(require('jquery')) : o_o(jQuery) })(function ($) { 'use strict'; -- cgit v1.2.3 From 2b302f69eea416bc85e7827b7d7a74d49f879662 Mon Sep 17 00:00:00 2001 From: fat Date: Thu, 12 Jun 2014 11:11:04 -0700 Subject: some changes from #13801 - add strict mode back and == --- js/button.js | 156 ++++++++++++++++++++++++++++++----------------------------- 1 file changed, 79 insertions(+), 77 deletions(-) (limited to 'js/button.js') diff --git a/js/button.js b/js/button.js index c05c5e3dd..e96788c05 100644 --- a/js/button.js +++ b/js/button.js @@ -7,108 +7,110 @@ * ======================================================================== */ -(function (o_o) { - typeof define === 'function' && define.amd ? define(['jquery'], o_o) : - typeof exports === 'object' ? o_o(require('jquery')) : o_o(jQuery) -})(function ($) { ++function () { 'use strict'; - 'use strict'; + (function (o_o) { + typeof define == 'function' && define.amd ? define(['jquery'], o_o) : + typeof exports == 'object' ? o_o(require('jquery')) : o_o(jQuery) + })(function ($) { - // BUTTON PUBLIC CLASS DEFINITION - // ============================== + // BUTTON PUBLIC CLASS DEFINITION + // ============================== - var Button = function (element, options) { - this.$element = $(element) - this.options = $.extend({}, Button.DEFAULTS, options) - this.isLoading = false - } + var Button = function (element, options) { + this.$element = $(element) + this.options = $.extend({}, Button.DEFAULTS, options) + this.isLoading = false + } - Button.VERSION = '3.1.1' + Button.VERSION = '3.1.1' - Button.DEFAULTS = { - loadingText: 'loading...' - } + Button.DEFAULTS = { + loadingText: 'loading...' + } - Button.prototype.setState = function (state) { - var d = 'disabled' - var $el = this.$element - var val = $el.is('input') ? 'val' : 'html' - var data = $el.data() + Button.prototype.setState = function (state) { + var d = 'disabled' + var $el = this.$element + var val = $el.is('input') ? 'val' : 'html' + var data = $el.data() - state = state + 'Text' + state = state + 'Text' - if (data.resetText == null) $el.data('resetText', $el[val]()) + if (data.resetText == null) $el.data('resetText', $el[val]()) - $el[val](data[state] == null ? this.options[state] : data[state]) + $el[val](data[state] == null ? this.options[state] : data[state]) - // push to event loop to allow forms to submit - setTimeout($.proxy(function () { - if (state == 'loadingText') { - this.isLoading = true - $el.addClass(d).attr(d, d) - } else if (this.isLoading) { - this.isLoading = false - $el.removeClass(d).removeAttr(d) - } - }, this), 0) - } - - Button.prototype.toggle = function () { - var changed = true - var $parent = this.$element.closest('[data-toggle="buttons"]') - - if ($parent.length) { - var $input = this.$element.find('input') - if ($input.prop('type') == 'radio') { - if ($input.prop('checked') && this.$element.hasClass('active')) changed = false - else $parent.find('.active').removeClass('active') + // push to event loop to allow forms to submit + setTimeout($.proxy(function () { + if (state == 'loadingText') { + this.isLoading = true + $el.addClass(d).attr(d, d) + } else if (this.isLoading) { + this.isLoading = false + $el.removeClass(d).removeAttr(d) + } + }, this), 0) + } + + Button.prototype.toggle = function () { + var changed = true + var $parent = this.$element.closest('[data-toggle="buttons"]') + + if ($parent.length) { + var $input = this.$element.find('input') + if ($input.prop('type') == 'radio') { + if ($input.prop('checked') && this.$element.hasClass('active')) changed = false + else $parent.find('.active').removeClass('active') + } + if (changed) $input.prop('checked', !this.$element.hasClass('active')).trigger('change') } - if (changed) $input.prop('checked', !this.$element.hasClass('active')).trigger('change') + + if (changed) this.$element.toggleClass('active') } - if (changed) this.$element.toggleClass('active') - } + // BUTTON PLUGIN DEFINITION + // ======================== - // BUTTON PLUGIN DEFINITION - // ======================== + function Plugin(option) { + return this.each(function () { + var $this = $(this) + var data = $this.data('bs.button') + var options = typeof option == 'object' && option - function Plugin(option) { - return this.each(function () { - var $this = $(this) - var data = $this.data('bs.button') - var options = typeof option == 'object' && option + if (!data) $this.data('bs.button', (data = new Button(this, options))) - if (!data) $this.data('bs.button', (data = new Button(this, options))) + if (option == 'toggle') data.toggle() + else if (option) data.setState(option) + }) + } - if (option == 'toggle') data.toggle() - else if (option) data.setState(option) - }) - } + var old = $.fn.button - var old = $.fn.button + $.fn.button = Plugin + $.fn.button.Constructor = Button - $.fn.button = Plugin - $.fn.button.Constructor = Button + // BUTTON NO CONFLICT + // ================== - // BUTTON NO CONFLICT - // ================== + $.fn.button.noConflict = function () { + $.fn.button = old + return this + } - $.fn.button.noConflict = function () { - $.fn.button = old - return this - } + // BUTTON DATA-API + // =============== - // BUTTON DATA-API - // =============== + $(document).on('click.bs.button.data-api', '[data-toggle^="button"]', function (e) { + var $btn = $(e.target) + if (!$btn.hasClass('btn')) $btn = $btn.closest('.btn') + Plugin.call($btn, 'toggle') + e.preventDefault() + }) - $(document).on('click.bs.button.data-api', '[data-toggle^="button"]', function (e) { - var $btn = $(e.target) - if (!$btn.hasClass('btn')) $btn = $btn.closest('.btn') - Plugin.call($btn, 'toggle') - e.preventDefault() }) -}); +}(); -- cgit v1.2.3 From c2c19a4d2d45d8ccb5c84d293dea35a94148c9a4 Mon Sep 17 00:00:00 2001 From: Chris Rebert Date: Mon, 23 Jun 2014 11:07:18 -0700 Subject: Revert UMD (#13772 & friends) for now, due to #13812. Will hopefully revert this reversion and land a fully-working version of UMD in v3.3.0. Revert "some changes from #13801 - add strict mode back and ==" This reverts commit 2b302f69eea416bc85e7827b7d7a74d49f879662. Revert "Fix regression of #10038 introduced by #13772" This reverts commit e9d6756a1ac76a9db31a41e8e03f663bedc41b70. Revert "MD/CommonJS/Globals #12909" This reverts commit 1c6fa9010daf0d0c21de9e20fe6ac4dba1788d90. Revert "address #13811" This reverts commit f347d7d955bbb17234b8e12c68efae7d516ce62c. Conflicts: js/carousel.js js/collapse.js js/dropdown.js js/modal.js js/tab.js js/tooltip.js --- js/button.js | 154 ++++++++++++++++++++++++++++------------------------------- 1 file changed, 74 insertions(+), 80 deletions(-) (limited to 'js/button.js') diff --git a/js/button.js b/js/button.js index e96788c05..aa7145072 100644 --- a/js/button.js +++ b/js/button.js @@ -7,110 +7,104 @@ * ======================================================================== */ -+function () { 'use strict'; ++function ($) { + 'use strict'; - (function (o_o) { - typeof define == 'function' && define.amd ? define(['jquery'], o_o) : - typeof exports == 'object' ? o_o(require('jquery')) : o_o(jQuery) - })(function ($) { + // BUTTON PUBLIC CLASS DEFINITION + // ============================== - // BUTTON PUBLIC CLASS DEFINITION - // ============================== + var Button = function (element, options) { + this.$element = $(element) + this.options = $.extend({}, Button.DEFAULTS, options) + this.isLoading = false + } - var Button = function (element, options) { - this.$element = $(element) - this.options = $.extend({}, Button.DEFAULTS, options) - this.isLoading = false - } - - Button.VERSION = '3.1.1' - - Button.DEFAULTS = { - loadingText: 'loading...' - } + Button.VERSION = '3.1.1' - Button.prototype.setState = function (state) { - var d = 'disabled' - var $el = this.$element - var val = $el.is('input') ? 'val' : 'html' - var data = $el.data() + Button.DEFAULTS = { + loadingText: 'loading...' + } - state = state + 'Text' + Button.prototype.setState = function (state) { + var d = 'disabled' + var $el = this.$element + var val = $el.is('input') ? 'val' : 'html' + var data = $el.data() - if (data.resetText == null) $el.data('resetText', $el[val]()) + state = state + 'Text' - $el[val](data[state] == null ? this.options[state] : data[state]) + if (data.resetText == null) $el.data('resetText', $el[val]()) - // push to event loop to allow forms to submit - setTimeout($.proxy(function () { - if (state == 'loadingText') { - this.isLoading = true - $el.addClass(d).attr(d, d) - } else if (this.isLoading) { - this.isLoading = false - $el.removeClass(d).removeAttr(d) - } - }, this), 0) - } + $el[val](data[state] == null ? this.options[state] : data[state]) - Button.prototype.toggle = function () { - var changed = true - var $parent = this.$element.closest('[data-toggle="buttons"]') - - if ($parent.length) { - var $input = this.$element.find('input') - if ($input.prop('type') == 'radio') { - if ($input.prop('checked') && this.$element.hasClass('active')) changed = false - else $parent.find('.active').removeClass('active') - } - if (changed) $input.prop('checked', !this.$element.hasClass('active')).trigger('change') + // push to event loop to allow forms to submit + setTimeout($.proxy(function () { + if (state == 'loadingText') { + this.isLoading = true + $el.addClass(d).attr(d, d) + } else if (this.isLoading) { + this.isLoading = false + $el.removeClass(d).removeAttr(d) } - - if (changed) this.$element.toggleClass('active') + }, this), 0) + } + + Button.prototype.toggle = function () { + var changed = true + var $parent = this.$element.closest('[data-toggle="buttons"]') + + if ($parent.length) { + var $input = this.$element.find('input') + if ($input.prop('type') == 'radio') { + if ($input.prop('checked') && this.$element.hasClass('active')) changed = false + else $parent.find('.active').removeClass('active') + } + if (changed) $input.prop('checked', !this.$element.hasClass('active')).trigger('change') } + if (changed) this.$element.toggleClass('active') + } - // BUTTON PLUGIN DEFINITION - // ======================== - function Plugin(option) { - return this.each(function () { - var $this = $(this) - var data = $this.data('bs.button') - var options = typeof option == 'object' && option + // BUTTON PLUGIN DEFINITION + // ======================== - if (!data) $this.data('bs.button', (data = new Button(this, options))) + function Plugin(option) { + return this.each(function () { + var $this = $(this) + var data = $this.data('bs.button') + var options = typeof option == 'object' && option - if (option == 'toggle') data.toggle() - else if (option) data.setState(option) - }) - } + if (!data) $this.data('bs.button', (data = new Button(this, options))) - var old = $.fn.button + if (option == 'toggle') data.toggle() + else if (option) data.setState(option) + }) + } - $.fn.button = Plugin - $.fn.button.Constructor = Button + var old = $.fn.button + $.fn.button = Plugin + $.fn.button.Constructor = Button - // BUTTON NO CONFLICT - // ================== - $.fn.button.noConflict = function () { - $.fn.button = old - return this - } + // BUTTON NO CONFLICT + // ================== + $.fn.button.noConflict = function () { + $.fn.button = old + return this + } - // BUTTON DATA-API - // =============== - $(document).on('click.bs.button.data-api', '[data-toggle^="button"]', function (e) { - var $btn = $(e.target) - if (!$btn.hasClass('btn')) $btn = $btn.closest('.btn') - Plugin.call($btn, 'toggle') - e.preventDefault() - }) + // BUTTON DATA-API + // =============== + $(document).on('click.bs.button.data-api', '[data-toggle^="button"]', function (e) { + var $btn = $(e.target) + if (!$btn.hasClass('btn')) $btn = $btn.closest('.btn') + Plugin.call($btn, 'toggle') + e.preventDefault() }) -}(); +}(jQuery); -- cgit v1.2.3 From 6b6476fcd93d8ab368afa9149361fac43d15019e Mon Sep 17 00:00:00 2001 From: fat Date: Mon, 23 Jun 2014 23:32:52 -0700 Subject: add "focus" to focused btns with button plugin --- js/button.js | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) (limited to 'js/button.js') diff --git a/js/button.js b/js/button.js index aa7145072..1d524154e 100644 --- a/js/button.js +++ b/js/button.js @@ -97,14 +97,30 @@ } + // FOCUS SHIM (FOR BUTTON GROUPS) + // ============================== + + function getBtnTarget(target) { + var $target = $(target) + return $target.hasClass('btn') ? $target : $target.parent('.btn') + } + + // BUTTON DATA-API // =============== - $(document).on('click.bs.button.data-api', '[data-toggle^="button"]', function (e) { - var $btn = $(e.target) - if (!$btn.hasClass('btn')) $btn = $btn.closest('.btn') - Plugin.call($btn, 'toggle') - e.preventDefault() - }) + $(document) + .on('click.bs.button.data-api', '[data-toggle^="button"]', function (e) { + var $btn = $(e.target) + if (!$btn.hasClass('btn')) $btn = $btn.closest('.btn') + Plugin.call($btn, 'toggle') + e.preventDefault() + }) + .on('focus.bs.button.data-api', '[data-toggle^="button"]', function (e) { + getBtnTarget(e.target).addClass('focus') + }) + .on('blur.bs.button.data-api', '[data-toggle^="button"]', function (e) { + getBtnTarget(e.target).removeClass('focus') + }) }(jQuery); -- cgit v1.2.3 From ff6b279b3cd37e7e4e6bd93535afd016f6957afc Mon Sep 17 00:00:00 2001 From: Mark Otto Date: Thu, 26 Jun 2014 09:13:24 -0700 Subject: bump to v3.2.0 --- js/button.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'js/button.js') diff --git a/js/button.js b/js/button.js index aa7145072..dc3164f86 100644 --- a/js/button.js +++ b/js/button.js @@ -1,5 +1,5 @@ /* ======================================================================== - * Bootstrap: button.js v3.1.1 + * Bootstrap: button.js v3.2.0 * http://getbootstrap.com/javascript/#buttons * ======================================================================== * Copyright 2011-2014 Twitter, Inc. @@ -19,7 +19,7 @@ this.isLoading = false } - Button.VERSION = '3.1.1' + Button.VERSION = '3.2.0' Button.DEFAULTS = { loadingText: 'loading...' -- cgit v1.2.3