Path: blob/main/website/GAUSS/js/bootstrap-collapse.js
2941 views
/* =============================================================1* bootstrap-collapse.js v2.0.32* http://twitter.github.com/bootstrap/javascript.html#collapse3* =============================================================4* Copyright 2012 Twitter, Inc.5*6* Licensed under the Apache License, Version 2.0 (the "License");7* you may not use this file except in compliance with the License.8* You may obtain a copy of the License at9*10* http://www.apache.org/licenses/LICENSE-2.011*12* Unless required by applicable law or agreed to in writing, software13* distributed under the License is distributed on an "AS IS" BASIS,14* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.15* See the License for the specific language governing permissions and16* limitations under the License.17* ============================================================ */181920!function ($) {2122"use strict"; // jshint ;_;232425/* COLLAPSE PUBLIC CLASS DEFINITION26* ================================ */2728var Collapse = function (element, options) {29this.$element = $(element)30this.options = $.extend({}, $.fn.collapse.defaults, options)3132if (this.options.parent) {33this.$parent = $(this.options.parent)34}3536this.options.toggle && this.toggle()37}3839Collapse.prototype = {4041constructor: Collapse4243, dimension: function () {44var hasWidth = this.$element.hasClass('width')45return hasWidth ? 'width' : 'height'46}4748, show: function () {49var dimension50, scroll51, actives52, hasData5354if (this.transitioning) return5556dimension = this.dimension()57scroll = $.camelCase(['scroll', dimension].join('-'))58actives = this.$parent && this.$parent.find('> .accordion-group > .in')5960if (actives && actives.length) {61hasData = actives.data('collapse')62if (hasData && hasData.transitioning) return63actives.collapse('hide')64hasData || actives.data('collapse', null)65}6667this.$element[dimension](0)68this.transition('addClass', $.Event('show'), 'shown')69this.$element[dimension](this.$element[0][scroll])70}7172, hide: function () {73var dimension74if (this.transitioning) return75dimension = this.dimension()76this.reset(this.$element[dimension]())77this.transition('removeClass', $.Event('hide'), 'hidden')78this.$element[dimension](0)79}8081, reset: function (size) {82var dimension = this.dimension()8384this.$element85.removeClass('collapse')86[dimension](size || 'auto')87[0].offsetWidth8889this.$element[size !== null ? 'addClass' : 'removeClass']('collapse')9091return this92}9394, transition: function (method, startEvent, completeEvent) {95var that = this96, complete = function () {97if (startEvent.type == 'show') that.reset()98that.transitioning = 099that.$element.trigger(completeEvent)100}101102this.$element.trigger(startEvent)103104if (startEvent.isDefaultPrevented()) return105106this.transitioning = 1107108this.$element[method]('in')109110$.support.transition && this.$element.hasClass('collapse') ?111this.$element.one($.support.transition.end, complete) :112complete()113}114115, toggle: function () {116this[this.$element.hasClass('in') ? 'hide' : 'show']()117}118119}120121122/* COLLAPSIBLE PLUGIN DEFINITION123* ============================== */124125$.fn.collapse = function (option) {126return this.each(function () {127var $this = $(this)128, data = $this.data('collapse')129, options = typeof option == 'object' && option130if (!data) $this.data('collapse', (data = new Collapse(this, options)))131if (typeof option == 'string') data[option]()132})133}134135$.fn.collapse.defaults = {136toggle: true137}138139$.fn.collapse.Constructor = Collapse140141142/* COLLAPSIBLE DATA-API143* ==================== */144145$(function () {146$('body').on('click.collapse.data-api', '[data-toggle=collapse]', function ( e ) {147var $this = $(this), href148, target = $this.attr('data-target')149|| e.preventDefault()150|| (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '') //strip for ie7151, option = $(target).data('collapse') ? 'toggle' : $this.data()152$(target).collapse(option)153})154})155156}(window.jQuery);157158