From 29a28d838ce910baf9427ba6908ff59514e92762 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Mon, 21 Jul 2014 00:00:27 +0200 Subject: [PATCH] Moved to js of BS 3.2.0. --- .../javascripts/app/lib/bootstrap/button.js | 79 +++--- .../javascripts/app/lib/bootstrap/collapse.js | 68 ++--- .../javascripts/app/lib/bootstrap/dropdown.js | 67 +++-- .../javascripts/app/lib/bootstrap/modal.js | 148 +++++++---- .../javascripts/app/lib/bootstrap/popover.js | 46 ++-- .../javascripts/app/lib/bootstrap/tab.js | 45 ++-- .../javascripts/app/lib/bootstrap/tooltip.js | 250 ++++++++++++------ .../app/lib/bootstrap/transition.js | 45 ++-- 8 files changed, 419 insertions(+), 329 deletions(-) diff --git a/app/assets/javascripts/app/lib/bootstrap/button.js b/app/assets/javascripts/app/lib/bootstrap/button.js index c9fdde5e4..b3e944c59 100644 --- a/app/assets/javascripts/app/lib/bootstrap/button.js +++ b/app/assets/javascripts/app/lib/bootstrap/button.js @@ -1,33 +1,26 @@ /* ======================================================================== - * Bootstrap: button.js v3.0.3 + * Bootstrap: button.js v3.2.0 * http://getbootstrap.com/javascript/#buttons * ======================================================================== - * Copyright 2013 Twitter, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright 2011-2014 Twitter, Inc. + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) * ======================================================================== */ -+function ($) { "use strict"; ++function ($) { + 'use strict'; // BUTTON PUBLIC CLASS DEFINITION // ============================== var Button = function (element, options) { - this.$element = $(element) - this.options = $.extend({}, Button.DEFAULTS, options) + this.$element = $(element) + this.options = $.extend({}, Button.DEFAULTS, options) + this.isLoading = false } + Button.VERSION = '3.2.0' + Button.DEFAULTS = { loadingText: 'loading...' } @@ -40,30 +33,31 @@ 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(function () { - state == 'loadingText' ? - $el.addClass(d).attr(d, d) : - $el.removeClass(d).removeAttr(d); - }, 0) + 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 $parent = this.$element.closest('[data-toggle="buttons"]') 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') { - // see if clicking on current one - if ($input.prop('checked') && this.$element.hasClass('active')) - changed = false - else - $parent.find('.active').removeClass('active') + 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') } @@ -75,9 +69,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') @@ -90,6 +82,9 @@ }) } + var old = $.fn.button + + $.fn.button = Plugin $.fn.button.Constructor = Button @@ -105,11 +100,15 @@ // 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') - $btn.button('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 blur.bs.button.data-api', '[data-toggle^="button"]', function (e) { + $(e.target).closest('.btn').toggleClass('focus', e.type == 'focus') + }) }(jQuery); diff --git a/app/assets/javascripts/app/lib/bootstrap/collapse.js b/app/assets/javascripts/app/lib/bootstrap/collapse.js index 1a079938e..5a524241d 100644 --- a/app/assets/javascripts/app/lib/bootstrap/collapse.js +++ b/app/assets/javascripts/app/lib/bootstrap/collapse.js @@ -1,24 +1,14 @@ /* ======================================================================== - * Bootstrap: collapse.js v3.0.3 + * Bootstrap: collapse.js v3.2.0 * http://getbootstrap.com/javascript/#collapse * ======================================================================== - * Copyright 2013 Twitter, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright 2011-2014 Twitter, Inc. + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) * ======================================================================== */ -+function ($) { "use strict"; ++function ($) { + 'use strict'; // COLLAPSE PUBLIC CLASS DEFINITION // ================================ @@ -32,6 +22,8 @@ if (this.options.toggle) this.toggle() } + Collapse.VERSION = '3.2.0' + Collapse.DEFAULTS = { toggle: true } @@ -53,7 +45,7 @@ if (actives && actives.length) { var hasData = actives.data('bs.collapse') if (hasData && hasData.transitioning) return - actives.collapse('hide') + Plugin.call(actives, 'hide') hasData || actives.data('bs.collapse', null) } @@ -61,18 +53,17 @@ this.$element .removeClass('collapse') - .addClass('collapsing') - [dimension](0) + .addClass('collapsing')[dimension](0) this.transitioning = 1 var complete = function () { this.$element .removeClass('collapsing') - .addClass('in') - [dimension]('auto') + .addClass('collapse in')[dimension]('') this.transitioning = 0 - this.$element.trigger('shown.bs.collapse') + this.$element + .trigger('shown.bs.collapse') } if (!$.support.transition) return complete.call(this) @@ -80,9 +71,8 @@ var scrollSize = $.camelCase(['scroll', dimension].join('-')) this.$element - .one($.support.transition.end, $.proxy(complete, this)) - .emulateTransitionEnd(350) - [dimension](this.$element[0][scrollSize]) + .one('bsTransitionEnd', $.proxy(complete, this)) + .emulateTransitionEnd(350)[dimension](this.$element[0][scrollSize]) } Collapse.prototype.hide = function () { @@ -94,14 +84,11 @@ var dimension = this.dimension() - this.$element - [dimension](this.$element[dimension]()) - [0].offsetHeight + this.$element[dimension](this.$element[dimension]())[0].offsetHeight this.$element .addClass('collapsing') - .removeClass('collapse') - .removeClass('in') + .removeClass('collapse in') this.transitioning = 1 @@ -117,7 +104,7 @@ this.$element [dimension](0) - .one($.support.transition.end, $.proxy(complete, this)) + .one('bsTransitionEnd', $.proxy(complete, this)) .emulateTransitionEnd(350) } @@ -129,19 +116,21 @@ // COLLAPSE PLUGIN DEFINITION // ========================== - var old = $.fn.collapse - - $.fn.collapse = function (option) { + function Plugin(option) { return this.each(function () { var $this = $(this) var data = $this.data('bs.collapse') var options = $.extend({}, Collapse.DEFAULTS, $this.data(), typeof option == 'object' && option) + if (!data && options.toggle && option == 'show') option = !option if (!data) $this.data('bs.collapse', (data = new Collapse(this, options))) if (typeof option == 'string') data[option]() }) } + var old = $.fn.collapse + + $.fn.collapse = Plugin $.fn.collapse.Constructor = Collapse @@ -157,11 +146,12 @@ // COLLAPSE DATA-API // ================= - $(document).on('click.bs.collapse.data-api', '[data-toggle=collapse]', function (e) { - var $this = $(this), href + $(document).on('click.bs.collapse.data-api', '[data-toggle="collapse"]', function (e) { + var href + var $this = $(this) var target = $this.attr('data-target') || e.preventDefault() - || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '') //strip for ie7 + || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '') // strip for ie7 var $target = $(target) var data = $target.data('bs.collapse') var option = data ? 'toggle' : $this.data() @@ -169,11 +159,11 @@ var $parent = parent && $(parent) if (!data || !data.transitioning) { - if ($parent) $parent.find('[data-toggle=collapse][data-parent="' + parent + '"]').not($this).addClass('collapsed') - $this[$target.hasClass('in') ? 'addClass' : 'removeClass']('collapsed') + if ($parent) $parent.find('[data-toggle="collapse"][data-parent="' + parent + '"]').not($this).addClass('collapsed') + $this.toggleClass('collapsed', $target.hasClass('in')) } - $target.collapse(option) + Plugin.call($target, option) }) }(jQuery); diff --git a/app/assets/javascripts/app/lib/bootstrap/dropdown.js b/app/assets/javascripts/app/lib/bootstrap/dropdown.js index 13352ef7c..88f118c2d 100644 --- a/app/assets/javascripts/app/lib/bootstrap/dropdown.js +++ b/app/assets/javascripts/app/lib/bootstrap/dropdown.js @@ -1,34 +1,26 @@ /* ======================================================================== - * Bootstrap: dropdown.js v3.0.3 + * Bootstrap: dropdown.js v3.2.0 * http://getbootstrap.com/javascript/#dropdowns * ======================================================================== - * Copyright 2013 Twitter, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright 2011-2014 Twitter, Inc. + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) * ======================================================================== */ -+function ($) { "use strict"; ++function ($) { + 'use strict'; // DROPDOWN CLASS DEFINITION // ========================= var backdrop = '.dropdown-backdrop' - var toggle = '[data-toggle=dropdown]' + var toggle = '[data-toggle="dropdown"]' var Dropdown = function (element) { $(element).on('click.bs.dropdown', this.toggle) } + Dropdown.VERSION = '3.2.0' + Dropdown.prototype.toggle = function (e) { var $this = $(this) @@ -45,15 +37,16 @@ $('