indvd00m@0: /* ============================================================= indvd00m@0: * bootstrap-collapse.js v2.3.1 indvd00m@0: * http://twitter.github.com/bootstrap/javascript.html#collapse indvd00m@0: * ============================================================= indvd00m@0: * Copyright 2012 Twitter, Inc. indvd00m@0: * indvd00m@0: * Licensed under the Apache License, Version 2.0 (the "License"); indvd00m@0: * you may not use this file except in compliance with the License. indvd00m@0: * You may obtain a copy of the License at indvd00m@0: * indvd00m@0: * http://www.apache.org/licenses/LICENSE-2.0 indvd00m@0: * indvd00m@0: * Unless required by applicable law or agreed to in writing, software indvd00m@0: * distributed under the License is distributed on an "AS IS" BASIS, indvd00m@0: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. indvd00m@0: * See the License for the specific language governing permissions and indvd00m@0: * limitations under the License. indvd00m@0: * ============================================================ */ indvd00m@0: indvd00m@0: indvd00m@0: !function ($) { indvd00m@0: indvd00m@0: "use strict"; // jshint ;_; indvd00m@0: indvd00m@0: indvd00m@0: /* COLLAPSE PUBLIC CLASS DEFINITION indvd00m@0: * ================================ */ indvd00m@0: indvd00m@0: var Collapse = function (element, options) { indvd00m@0: this.$element = $(element) indvd00m@0: this.options = $.extend({}, $.fn.collapse.defaults, options) indvd00m@0: indvd00m@0: if (this.options.parent) { indvd00m@0: this.$parent = $(this.options.parent) indvd00m@0: } indvd00m@0: indvd00m@0: this.options.toggle && this.toggle() indvd00m@0: } indvd00m@0: indvd00m@0: Collapse.prototype = { indvd00m@0: indvd00m@0: constructor: Collapse indvd00m@0: indvd00m@0: , dimension: function () { indvd00m@0: var hasWidth = this.$element.hasClass('width') indvd00m@0: return hasWidth ? 'width' : 'height' indvd00m@0: } indvd00m@0: indvd00m@0: , show: function () { indvd00m@0: var dimension indvd00m@0: , scroll indvd00m@0: , actives indvd00m@0: , hasData indvd00m@0: indvd00m@0: if (this.transitioning || this.$element.hasClass('in')) return indvd00m@0: indvd00m@0: dimension = this.dimension() indvd00m@0: scroll = $.camelCase(['scroll', dimension].join('-')) indvd00m@0: actives = this.$parent && this.$parent.find('> .accordion-group > .in') indvd00m@0: indvd00m@0: if (actives && actives.length) { indvd00m@0: hasData = actives.data('collapse') indvd00m@0: if (hasData && hasData.transitioning) return indvd00m@0: actives.collapse('hide') indvd00m@0: hasData || actives.data('collapse', null) indvd00m@0: } indvd00m@0: indvd00m@0: this.$element[dimension](0) indvd00m@0: this.transition('addClass', $.Event('show'), 'shown') indvd00m@0: $.support.transition && this.$element[dimension](this.$element[0][scroll]) indvd00m@0: } indvd00m@0: indvd00m@0: , hide: function () { indvd00m@0: var dimension indvd00m@0: if (this.transitioning || !this.$element.hasClass('in')) return indvd00m@0: dimension = this.dimension() indvd00m@0: this.reset(this.$element[dimension]()) indvd00m@0: this.transition('removeClass', $.Event('hide'), 'hidden') indvd00m@0: this.$element[dimension](0) indvd00m@0: } indvd00m@0: indvd00m@0: , reset: function (size) { indvd00m@0: var dimension = this.dimension() indvd00m@0: indvd00m@0: this.$element indvd00m@0: .removeClass('collapse') indvd00m@0: [dimension](size || 'auto') indvd00m@0: [0].offsetWidth indvd00m@0: indvd00m@0: this.$element[size !== null ? 'addClass' : 'removeClass']('collapse') indvd00m@0: indvd00m@0: return this indvd00m@0: } indvd00m@0: indvd00m@0: , transition: function (method, startEvent, completeEvent) { indvd00m@0: var that = this indvd00m@0: , complete = function () { indvd00m@0: if (startEvent.type == 'show') that.reset() indvd00m@0: that.transitioning = 0 indvd00m@0: that.$element.trigger(completeEvent) indvd00m@0: } indvd00m@0: indvd00m@0: this.$element.trigger(startEvent) indvd00m@0: indvd00m@0: if (startEvent.isDefaultPrevented()) return indvd00m@0: indvd00m@0: this.transitioning = 1 indvd00m@0: indvd00m@0: this.$element[method]('in') indvd00m@0: indvd00m@0: $.support.transition && this.$element.hasClass('collapse') ? indvd00m@0: this.$element.one($.support.transition.end, complete) : indvd00m@0: complete() indvd00m@0: } indvd00m@0: indvd00m@0: , toggle: function () { indvd00m@0: this[this.$element.hasClass('in') ? 'hide' : 'show']() indvd00m@0: } indvd00m@0: indvd00m@0: } indvd00m@0: indvd00m@0: indvd00m@0: /* COLLAPSE PLUGIN DEFINITION indvd00m@0: * ========================== */ indvd00m@0: indvd00m@0: var old = $.fn.collapse indvd00m@0: indvd00m@0: $.fn.collapse = function (option) { indvd00m@0: return this.each(function () { indvd00m@0: var $this = $(this) indvd00m@0: , data = $this.data('collapse') indvd00m@0: , options = $.extend({}, $.fn.collapse.defaults, $this.data(), typeof option == 'object' && option) indvd00m@0: if (!data) $this.data('collapse', (data = new Collapse(this, options))) indvd00m@0: if (typeof option == 'string') data[option]() indvd00m@0: }) indvd00m@0: } indvd00m@0: indvd00m@0: $.fn.collapse.defaults = { indvd00m@0: toggle: true indvd00m@0: } indvd00m@0: indvd00m@0: $.fn.collapse.Constructor = Collapse indvd00m@0: indvd00m@0: indvd00m@0: /* COLLAPSE NO CONFLICT indvd00m@0: * ==================== */ indvd00m@0: indvd00m@0: $.fn.collapse.noConflict = function () { indvd00m@0: $.fn.collapse = old indvd00m@0: return this indvd00m@0: } indvd00m@0: indvd00m@0: indvd00m@0: /* COLLAPSE DATA-API indvd00m@0: * ================= */ indvd00m@0: indvd00m@0: $(document).on('click.collapse.data-api', '[data-toggle=collapse]', function (e) { indvd00m@0: var $this = $(this), href indvd00m@0: , target = $this.attr('data-target') indvd00m@0: || e.preventDefault() indvd00m@0: || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '') //strip for ie7 indvd00m@0: , option = $(target).data('collapse') ? 'toggle' : $this.data() indvd00m@0: $this[$(target).hasClass('in') ? 'addClass' : 'removeClass']('collapsed') indvd00m@0: $(target).collapse(option) indvd00m@0: }) indvd00m@0: indvd00m@0: }(window.jQuery);