From a0690e507d0aa0065f3d96e15cc65da30a1933b9 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Sun, 4 Aug 2013 23:53:46 +0200 Subject: [PATCH] Upgrade BS3 js files. --- .../app/lib/bootstrap/bootstrap-button.js | 80 +-- .../app/lib/bootstrap/bootstrap-collapse.js | 214 +++--- .../app/lib/bootstrap/bootstrap-dropdown.js | 169 +++-- .../app/lib/bootstrap/bootstrap-modal.js | 398 ++++++----- .../app/lib/bootstrap/bootstrap-popover.js | 157 ++--- .../app/lib/bootstrap/bootstrap-tab.js | 157 ++--- .../app/lib/bootstrap/bootstrap-tooltip.js | 643 +++++++++--------- .../app/lib/bootstrap/bootstrap-transition.js | 74 +- 8 files changed, 939 insertions(+), 953 deletions(-) diff --git a/app/assets/javascripts/app/lib/bootstrap/bootstrap-button.js b/app/assets/javascripts/app/lib/bootstrap/bootstrap-button.js index ce4599164..539e9fead 100644 --- a/app/assets/javascripts/app/lib/bootstrap/bootstrap-button.js +++ b/app/assets/javascripts/app/lib/bootstrap/bootstrap-button.js @@ -1,8 +1,8 @@ -/* ============================================================ - * bootstrap-button.js v2.3.2 - * http://twitter.github.com/bootstrap/javascript.html#buttons - * ============================================================ - * Copyright 2012 Twitter, Inc. +/* ======================================================================== + * Bootstrap: button.js v3.0.0 + * http://twbs.github.com/bootstrap/javascript.html#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. @@ -15,30 +15,32 @@ * 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. - * ============================================================ */ + * ======================================================================== */ -!function ($) { ++function ($) { "use strict"; - "use strict"; // jshint ;_; - - - /* BUTTON PUBLIC CLASS DEFINITION - * ============================== */ + // BUTTON PUBLIC CLASS DEFINITION + // ============================== var Button = function (element, options) { this.$element = $(element) - this.options = $.extend({}, $.fn.button.defaults, options) + this.options = $.extend({}, Button.DEFAULTS, options) + } + + Button.DEFAULTS = { + loadingText: 'loading...' } Button.prototype.setState = function (state) { - var d = 'disabled' - , $el = this.$element - , data = $el.data() - , val = $el.is('input') ? 'val' : 'html' + var d = 'disabled' + var $el = this.$element + var val = $el.is('input') ? 'val' : 'html' + var data = $el.data() state = state + 'Text' - data.resetText || $el.data('resetText', $el[val]()) + + if (!data.resetText) $el.data('resetText', $el[val]()) $el[val](data[state] || this.options[state]) @@ -46,46 +48,45 @@ setTimeout(function () { state == 'loadingText' ? $el.addClass(d).attr(d, d) : - $el.removeClass(d).removeAttr(d) + $el.removeClass(d).removeAttr(d); }, 0) } Button.prototype.toggle = function () { - var $parent = this.$element.closest('[data-toggle="buttons-radio"]') + var $parent = this.$element.closest('[data-toggle="buttons"]') - $parent && $parent - .find('.active') - .removeClass('active') + if ($parent.length) { + var $input = this.$element.find('input').prop('checked', !this.$element.hasClass('active')) + if ($input.prop('type') === 'radio') $parent.find('.active').removeClass('active') + } this.$element.toggleClass('active') } - /* BUTTON PLUGIN DEFINITION - * ======================== */ + // BUTTON PLUGIN DEFINITION + // ======================== var old = $.fn.button $.fn.button = function (option) { return this.each(function () { - var $this = $(this) - , data = $this.data('button') - , options = typeof option == 'object' && option - if (!data) $this.data('button', (data = new Button(this, options))) + var $this = $(this) + var data = $this.data('button') + var options = typeof option == 'object' && option + + if (!data) $this.data('bs.button', (data = new Button(this, options))) + if (option == 'toggle') data.toggle() else if (option) data.setState(option) }) } - $.fn.button.defaults = { - loadingText: 'loading...' - } - $.fn.button.Constructor = Button - /* BUTTON NO CONFLICT - * ================== */ + // BUTTON NO CONFLICT + // ================== $.fn.button.noConflict = function () { $.fn.button = old @@ -93,13 +94,14 @@ } - /* BUTTON DATA-API - * =============== */ + // BUTTON DATA-API + // =============== - $(document).on('click.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') + e.preventDefault() }) -}(window.jQuery); \ No newline at end of file +}(window.jQuery); diff --git a/app/assets/javascripts/app/lib/bootstrap/bootstrap-collapse.js b/app/assets/javascripts/app/lib/bootstrap/bootstrap-collapse.js index 74a73a890..34ac3c7fa 100644 --- a/app/assets/javascripts/app/lib/bootstrap/bootstrap-collapse.js +++ b/app/assets/javascripts/app/lib/bootstrap/bootstrap-collapse.js @@ -1,7 +1,7 @@ -/* ============================================================= - * bootstrap-collapse.js v2.3.2 - * http://twitter.github.com/bootstrap/javascript.html#collapse - * ============================================================= +/* ======================================================================== + * Bootstrap: collapse.js v3.0.0 + * http://twbs.github.com/bootstrap/javascript.html#collapse + * ======================================================================== * Copyright 2012 Twitter, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -15,135 +15,138 @@ * 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. - * ============================================================ */ + * ======================================================================== */ -!function ($) { ++function ($) { "use strict"; - "use strict"; // jshint ;_; - - - /* COLLAPSE PUBLIC CLASS DEFINITION - * ================================ */ + // COLLAPSE PUBLIC CLASS DEFINITION + // ================================ var Collapse = function (element, options) { - this.$element = $(element) - this.options = $.extend({}, $.fn.collapse.defaults, options) + this.$element = $(element) + this.options = $.extend({}, Collapse.DEFAULTS, options) + this.transitioning = null - if (this.options.parent) { - this.$parent = $(this.options.parent) - } - - this.options.toggle && this.toggle() + if (this.options.parent) this.$parent = $(this.options.parent) + if (this.options.toggle) this.toggle() } - Collapse.prototype = { + Collapse.DEFAULTS = { + toggle: true + } - constructor: Collapse + Collapse.prototype.dimension = function () { + var hasWidth = this.$element.hasClass('width') + return hasWidth ? 'width' : 'height' + } - , dimension: function () { - var hasWidth = this.$element.hasClass('width') - return hasWidth ? 'width' : 'height' + Collapse.prototype.show = function () { + if (this.transitioning || this.$element.hasClass('in')) return + + var startEvent = $.Event('show.bs.collapse') + this.$element.trigger(startEvent) + if (startEvent.isDefaultPrevented()) return + + var actives = this.$parent && this.$parent.find('> .accordion-group > .in') + + if (actives && actives.length) { + var hasData = actives.data('bs.collapse') + if (hasData && hasData.transitioning) return + actives.collapse('hide') + hasData || actives.data('bs.collapse', null) } - , show: function () { - var dimension - , scroll - , actives - , hasData + var dimension = this.dimension() - if (this.transitioning || this.$element.hasClass('in')) return + this.$element + .removeClass('collapse') + .addClass('collapsing') + [dimension](0) - dimension = this.dimension() - scroll = $.camelCase(['scroll', dimension].join('-')) - actives = this.$parent && this.$parent.find('> .accordion-group > .in') - - if (actives && actives.length) { - hasData = actives.data('collapse') - if (hasData && hasData.transitioning) return - actives.collapse('hide') - hasData || actives.data('collapse', null) - } - - this.$element[dimension](0) - this.transition('addClass', $.Event('show'), 'shown') - $.support.transition && this.$element[dimension](this.$element[0][scroll]) - } - - , hide: function () { - var dimension - if (this.transitioning || !this.$element.hasClass('in')) return - dimension = this.dimension() - this.reset(this.$element[dimension]()) - this.transition('removeClass', $.Event('hide'), 'hidden') - this.$element[dimension](0) - } - - , reset: function (size) { - var dimension = this.dimension() + this.transitioning = 1 + var complete = function () { this.$element - .removeClass('collapse') - [dimension](size || 'auto') - [0].offsetWidth - - this.$element[size !== null ? 'addClass' : 'removeClass']('collapse') - - return this + .removeClass('collapsing') + .addClass('in') + [dimension]('auto') + this.transitioning = 0 + this.$element.trigger('shown.bs.collapse') } - , transition: function (method, startEvent, completeEvent) { - var that = this - , complete = function () { - if (startEvent.type == 'show') that.reset() - that.transitioning = 0 - that.$element.trigger(completeEvent) - } + if (!$.support.transition) return complete.call(this) - this.$element.trigger(startEvent) + var scrollSize = $.camelCase(['scroll', dimension].join('-')) - if (startEvent.isDefaultPrevented()) return + this.$element + .one($.support.transition.end, $.proxy(complete, this)) + .emulateTransitionEnd(350) + [dimension](this.$element[0][scrollSize]) + } - this.transitioning = 1 + Collapse.prototype.hide = function () { + if (this.transitioning || !this.$element.hasClass('in')) return - this.$element[method]('in') + var startEvent = $.Event('hide.bs.collapse') + this.$element.trigger(startEvent) + if (startEvent.isDefaultPrevented()) return - $.support.transition && this.$element.hasClass('collapse') ? - this.$element.one($.support.transition.end, complete) : - complete() + var dimension = this.dimension() + + this.$element + [dimension](this.$element[dimension]()) + [0].offsetHeight + + this.$element + .addClass('collapsing') + .removeClass('collapse') + .removeClass('in') + + this.transitioning = 1 + + var complete = function () { + this.transitioning = 0 + this.$element + .trigger('hidden.bs.collapse') + .removeClass('collapsing') + .addClass('collapse') } - , toggle: function () { - this[this.$element.hasClass('in') ? 'hide' : 'show']() - } + if (!$.support.transition) return complete.call(this) + this.$element + [dimension](0) + .one($.support.transition.end, $.proxy(complete, this)) + .emulateTransitionEnd(350) + } + + Collapse.prototype.toggle = function () { + this[this.$element.hasClass('in') ? 'hide' : 'show']() } - /* COLLAPSE PLUGIN DEFINITION - * ========================== */ + // COLLAPSE PLUGIN DEFINITION + // ========================== var old = $.fn.collapse $.fn.collapse = function (option) { return this.each(function () { - var $this = $(this) - , data = $this.data('collapse') - , options = $.extend({}, $.fn.collapse.defaults, $this.data(), typeof option == 'object' && option) - if (!data) $this.data('collapse', (data = new Collapse(this, options))) + var $this = $(this) + var data = $this.data('bs.collapse') + var options = $.extend({}, Collapse.DEFAULTS, $this.data(), typeof option == 'object' && option) + + if (!data) $this.data('bs.collapse', (data = new Collapse(this, options))) if (typeof option == 'string') data[option]() }) } - $.fn.collapse.defaults = { - toggle: true - } - $.fn.collapse.Constructor = Collapse - /* COLLAPSE NO CONFLICT - * ==================== */ + // COLLAPSE NO CONFLICT + // ==================== $.fn.collapse.noConflict = function () { $.fn.collapse = old @@ -151,17 +154,26 @@ } - /* COLLAPSE DATA-API - * ================= */ + // COLLAPSE DATA-API + // ================= - $(document).on('click.collapse.data-api', '[data-toggle=collapse]', function (e) { - var $this = $(this), href - , target = $this.attr('data-target') + $(document).on('click.bs.collapse.data-api', '[data-toggle=collapse]', function (e) { + var $this = $(this), href + var target = $this.attr('data-target') || e.preventDefault() || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '') //strip for ie7 - , option = $(target).data('collapse') ? 'toggle' : $this.data() - $this[$(target).hasClass('in') ? 'addClass' : 'removeClass']('collapsed') - $(target).collapse(option) + var $target = $(target) + var data = $target.data('bs.collapse') + var option = data ? 'toggle' : $this.data() + var parent = $this.attr('data-parent') + 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') + } + + $target.collapse(option) }) -}(window.jQuery); \ No newline at end of file +}(window.jQuery); diff --git a/app/assets/javascripts/app/lib/bootstrap/bootstrap-dropdown.js b/app/assets/javascripts/app/lib/bootstrap/bootstrap-dropdown.js index 6cc122113..69bbd802c 100644 --- a/app/assets/javascripts/app/lib/bootstrap/bootstrap-dropdown.js +++ b/app/assets/javascripts/app/lib/bootstrap/bootstrap-dropdown.js @@ -1,7 +1,7 @@ -/* ============================================================ - * bootstrap-dropdown.js v2.3.2 - * http://twitter.github.com/bootstrap/javascript.html#dropdowns - * ============================================================ +/* ======================================================================== + * Bootstrap: dropdown.js v3.0.0 + * http://twbs.github.com/bootstrap/javascript.html#dropdowns + * ======================================================================== * Copyright 2012 Twitter, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -15,131 +15,116 @@ * 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. - * ============================================================ */ + * ======================================================================== */ -!function ($) { ++function ($) { "use strict"; - "use strict"; // jshint ;_; + // DROPDOWN CLASS DEFINITION + // ========================= + var backdrop = '.dropdown-backdrop' + var toggle = '[data-toggle=dropdown]' + var Dropdown = function (element) { + var $el = $(element).on('click.bs.dropdown', this.toggle) + } - /* DROPDOWN CLASS DEFINITION - * ========================= */ + Dropdown.prototype.toggle = function (e) { + var $this = $(this) - var toggle = '[data-toggle=dropdown]' - , Dropdown = function (element) { - var $el = $(element).on('click.dropdown.data-api', this.toggle) - $('html').on('click.dropdown.data-api', function () { - $el.parent().removeClass('open') - }) + if ($this.is('.disabled, :disabled')) return + + var $parent = getParent($this) + var isActive = $parent.hasClass('open') + + clearMenus() + + if (!isActive) { + if ('ontouchstart' in document.documentElement) { + // if mobile we we use a backdrop because click events don't delegate + $('