js/bootstrap-collapse.js
changeset 0 ba8ab09f730e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/bootstrap-collapse.js	Fri Jul 04 16:42:41 2014 +0400
     1.3 @@ -0,0 +1,167 @@
     1.4 +/* =============================================================
     1.5 + * bootstrap-collapse.js v2.3.1
     1.6 + * http://twitter.github.com/bootstrap/javascript.html#collapse
     1.7 + * =============================================================
     1.8 + * Copyright 2012 Twitter, Inc.
     1.9 + *
    1.10 + * Licensed under the Apache License, Version 2.0 (the "License");
    1.11 + * you may not use this file except in compliance with the License.
    1.12 + * You may obtain a copy of the License at
    1.13 + *
    1.14 + * http://www.apache.org/licenses/LICENSE-2.0
    1.15 + *
    1.16 + * Unless required by applicable law or agreed to in writing, software
    1.17 + * distributed under the License is distributed on an "AS IS" BASIS,
    1.18 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    1.19 + * See the License for the specific language governing permissions and
    1.20 + * limitations under the License.
    1.21 + * ============================================================ */
    1.22 +
    1.23 +
    1.24 +!function ($) {
    1.25 +
    1.26 +  "use strict"; // jshint ;_;
    1.27 +
    1.28 +
    1.29 + /* COLLAPSE PUBLIC CLASS DEFINITION
    1.30 +  * ================================ */
    1.31 +
    1.32 +  var Collapse = function (element, options) {
    1.33 +    this.$element = $(element)
    1.34 +    this.options = $.extend({}, $.fn.collapse.defaults, options)
    1.35 +
    1.36 +    if (this.options.parent) {
    1.37 +      this.$parent = $(this.options.parent)
    1.38 +    }
    1.39 +
    1.40 +    this.options.toggle && this.toggle()
    1.41 +  }
    1.42 +
    1.43 +  Collapse.prototype = {
    1.44 +
    1.45 +    constructor: Collapse
    1.46 +
    1.47 +  , dimension: function () {
    1.48 +      var hasWidth = this.$element.hasClass('width')
    1.49 +      return hasWidth ? 'width' : 'height'
    1.50 +    }
    1.51 +
    1.52 +  , show: function () {
    1.53 +      var dimension
    1.54 +        , scroll
    1.55 +        , actives
    1.56 +        , hasData
    1.57 +
    1.58 +      if (this.transitioning || this.$element.hasClass('in')) return
    1.59 +
    1.60 +      dimension = this.dimension()
    1.61 +      scroll = $.camelCase(['scroll', dimension].join('-'))
    1.62 +      actives = this.$parent && this.$parent.find('> .accordion-group > .in')
    1.63 +
    1.64 +      if (actives && actives.length) {
    1.65 +        hasData = actives.data('collapse')
    1.66 +        if (hasData && hasData.transitioning) return
    1.67 +        actives.collapse('hide')
    1.68 +        hasData || actives.data('collapse', null)
    1.69 +      }
    1.70 +
    1.71 +      this.$element[dimension](0)
    1.72 +      this.transition('addClass', $.Event('show'), 'shown')
    1.73 +      $.support.transition && this.$element[dimension](this.$element[0][scroll])
    1.74 +    }
    1.75 +
    1.76 +  , hide: function () {
    1.77 +      var dimension
    1.78 +      if (this.transitioning || !this.$element.hasClass('in')) return
    1.79 +      dimension = this.dimension()
    1.80 +      this.reset(this.$element[dimension]())
    1.81 +      this.transition('removeClass', $.Event('hide'), 'hidden')
    1.82 +      this.$element[dimension](0)
    1.83 +    }
    1.84 +
    1.85 +  , reset: function (size) {
    1.86 +      var dimension = this.dimension()
    1.87 +
    1.88 +      this.$element
    1.89 +        .removeClass('collapse')
    1.90 +        [dimension](size || 'auto')
    1.91 +        [0].offsetWidth
    1.92 +
    1.93 +      this.$element[size !== null ? 'addClass' : 'removeClass']('collapse')
    1.94 +
    1.95 +      return this
    1.96 +    }
    1.97 +
    1.98 +  , transition: function (method, startEvent, completeEvent) {
    1.99 +      var that = this
   1.100 +        , complete = function () {
   1.101 +            if (startEvent.type == 'show') that.reset()
   1.102 +            that.transitioning = 0
   1.103 +            that.$element.trigger(completeEvent)
   1.104 +          }
   1.105 +
   1.106 +      this.$element.trigger(startEvent)
   1.107 +
   1.108 +      if (startEvent.isDefaultPrevented()) return
   1.109 +
   1.110 +      this.transitioning = 1
   1.111 +
   1.112 +      this.$element[method]('in')
   1.113 +
   1.114 +      $.support.transition && this.$element.hasClass('collapse') ?
   1.115 +        this.$element.one($.support.transition.end, complete) :
   1.116 +        complete()
   1.117 +    }
   1.118 +
   1.119 +  , toggle: function () {
   1.120 +      this[this.$element.hasClass('in') ? 'hide' : 'show']()
   1.121 +    }
   1.122 +
   1.123 +  }
   1.124 +
   1.125 +
   1.126 + /* COLLAPSE PLUGIN DEFINITION
   1.127 +  * ========================== */
   1.128 +
   1.129 +  var old = $.fn.collapse
   1.130 +
   1.131 +  $.fn.collapse = function (option) {
   1.132 +    return this.each(function () {
   1.133 +      var $this = $(this)
   1.134 +        , data = $this.data('collapse')
   1.135 +        , options = $.extend({}, $.fn.collapse.defaults, $this.data(), typeof option == 'object' && option)
   1.136 +      if (!data) $this.data('collapse', (data = new Collapse(this, options)))
   1.137 +      if (typeof option == 'string') data[option]()
   1.138 +    })
   1.139 +  }
   1.140 +
   1.141 +  $.fn.collapse.defaults = {
   1.142 +    toggle: true
   1.143 +  }
   1.144 +
   1.145 +  $.fn.collapse.Constructor = Collapse
   1.146 +
   1.147 +
   1.148 + /* COLLAPSE NO CONFLICT
   1.149 +  * ==================== */
   1.150 +
   1.151 +  $.fn.collapse.noConflict = function () {
   1.152 +    $.fn.collapse = old
   1.153 +    return this
   1.154 +  }
   1.155 +
   1.156 +
   1.157 + /* COLLAPSE DATA-API
   1.158 +  * ================= */
   1.159 +
   1.160 +  $(document).on('click.collapse.data-api', '[data-toggle=collapse]', function (e) {
   1.161 +    var $this = $(this), href
   1.162 +      , target = $this.attr('data-target')
   1.163 +        || e.preventDefault()
   1.164 +        || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '') //strip for ie7
   1.165 +      , option = $(target).data('collapse') ? 'toggle' : $this.data()
   1.166 +    $this[$(target).hasClass('in') ? 'addClass' : 'removeClass']('collapsed')
   1.167 +    $(target).collapse(option)
   1.168 +  })
   1.169 +
   1.170 +}(window.jQuery);
   1.171 \ No newline at end of file