app/assets/javascripts/bootstrap/collapse.js in bootstrap-on-rails-0.0.2 vs app/assets/javascripts/bootstrap/collapse.js in bootstrap-on-rails-3.2.0

- old
+ new

@@ -1,26 +1,16 @@ /* ======================================================================== - * Bootstrap: collapse.js v3.0.2 + * 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 // ================================ var Collapse = function (element, options) { @@ -30,10 +20,12 @@ if (this.options.parent) this.$parent = $(this.options.parent) if (this.options.toggle) this.toggle() } + Collapse.VERSION = '3.2.0' + Collapse.DEFAULTS = { toggle: true } Collapse.prototype.dimension = function () { @@ -51,40 +43,38 @@ var actives = this.$parent && this.$parent.find('> .panel > .in') 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) } var dimension = this.dimension() 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) 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 () { if (this.transitioning || !this.$element.hasClass('in')) return @@ -92,13 +82,11 @@ this.$element.trigger(startEvent) if (startEvent.isDefaultPrevented()) return 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') @@ -115,11 +103,11 @@ if (!$.support.transition) return complete.call(this) this.$element [dimension](0) - .one($.support.transition.end, $.proxy(complete, this)) + .one('bsTransitionEnd', $.proxy(complete, this)) .emulateTransitionEnd(350) } Collapse.prototype.toggle = function () { this[this.$element.hasClass('in') ? 'hide' : 'show']() @@ -127,23 +115,25 @@ // 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 // COLLAPSE NO CONFLICT // ==================== @@ -155,25 +145,26 @@ // 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() 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') + if ($parent) $parent.find('[data-toggle="collapse"][data-parent="' + parent + '"]').not($this).addClass('collapsed') $this[$target.hasClass('in') ? 'addClass' : 'removeClass']('collapsed') } - $target.collapse(option) + Plugin.call($target, option) }) }(jQuery);