vendor: 5,701 bytes, lines 1-196
1/* ======================================================================== 2 * Bootstrap: collapse.js v3.3.5 3 * http://getbootstrap.com/javascript/#collapse 4 * ======================================================================== 5 * Copyright 2011-2015 Twitter, Inc. 6 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) 7 * ======================================================================== */ 8 9 10+function ($) { 11 'use strict'; 12 13 var Collapse = function (element, options) { 14 this.$element = $(element) 15 this.options = $.extend({}, Collapse.DEFAULTS, options) 16 this.$trigger = $('[data-toggle="collapse"][href="#' + element.id + '"],' + 17 '[data-toggle="collapse"][data-target="#' + element.id + '"]') 18 this.transitioning = null 19 20 if (this.options.parent) { 21 this.$parent = this.getParent() 22 } else { 23 this.addAriaAndCollapsedClass(this.$element, this.$trigger) 24 } 25 26 if (this.options.toggle) this.toggle() 27 } 28 29 Collapse.VERSION = '3.3.5' 30 31 Collapse.TRANSITION_DURATION = 350 32 33 Collapse.DEFAULTS = { 34 toggle: true 35 } 36 37 Collapse.prototype.dimension = function () { 38 var hasWidth = this.$element.hasClass('width') 39 return hasWidth ? 'width' : 'height' 40 } 41 42 Collapse.prototype.show = function () { 43 if (this.transitioning || this.$element.hasClass('in')) return 44 45 var activesData 46 var actives = this.$parent && this.$parent.children('.panel').children('.in, .collapsing') 47 48 if (actives && actives.length) { 49 activesData = actives.data('bs.collapse') 50 if (activesData && activesData.transitioning) return 51 } 52 53 var startEvent = $.Event('show.bs.collapse') 54 this.$element.trigger(startEvent) 55 if (startEvent.isDefaultPrevented()) return 56 57 if (actives && actives.length) { 58 Plugin.call(actives, 'hide') 59 activesData || actives.data('bs.collapse', null) 60 } 61 62 var dimension = this.dimension() 63 64 this.$element 65 .removeClass('collapse') 66 .addClass('collapsing')[dimension](0) 67 .attr('aria-expanded', true) 68 69 this.$trigger 70 .removeClass('collapsed') 71 .attr('aria-expanded', true) 72 73 this.transitioning = 1 74 75 var complete = function () { 76 this.$element 77 .removeClass('collapsing') 78 .addClass('collapse in')[dimension]('') 79 this.transitioning = 0 80 this.$element 81 .trigger('shown.bs.collapse') 82 } 83 84 if (!$.support.transition) return complete.call(this) 85 86 var scrollSize = $.camelCase(['scroll', dimension].join('-')) 87 88 this.$element 89 .one('bsTransitionEnd', $.proxy(complete, this)) 90 .emulateTransitionEnd(Collapse.TRANSITION_DURATION)[dimension](this.$element[0][scrollSize]) 91 } 92 93 Collapse.prototype.hide = function () { 94 if (this.transitioning || !this.$element.hasClass('in')) return 95 96 var startEvent = $.Event('hide.bs.collapse') 97 this.$element.trigger(startEvent) 98 if (startEvent.isDefaultPrevented()) return 99 100 var dimension = this.dimension() 101 102 this.$element[dimension](this.$element[dimension]())[0].offsetHeight 103 104 this.$element 105 .addClass('collapsing') 106 .removeClass('collapse in') 107 .attr('aria-expanded', false) 108 109 this.$trigger 110 .addClass('collapsed') 111 .attr('aria-expanded', false) 112 113 this.transitioning = 1 114 115 var complete = function () { 116 this.transitioning = 0 117 this.$element 118 .removeClass('collapsing') 119 .addClass('collapse') 120 .trigger('hidden.bs.collapse') 121 } 122 123 if (!$.support.transition) return complete.call(this) 124 125 this.$element 126 [dimension](0) 127 .one('bsTransitionEnd', $.proxy(complete, this)) 128 .emulateTransitionEnd(Collapse.TRANSITION_DURATION) 129 } 130 131 Collapse.prototype.toggle = function () { 132 this[this.$element.hasClass('in') ? 'hide' : 'show']() 133 } 134 135 Collapse.prototype.getParent = function () { 136 return $(this.options.parent) 137 .find('[data-toggle="collapse"][data-parent="' + this.options.parent + '"]') 138 .each($.proxy(function (i, element) { 139 var $element = $(element) 140 this.addAriaAndCollapsedClass(getTargetFromTrigger($element), $element) 141 }, this)) 142 .end() 143 } 144 145 Collapse.prototype.addAriaAndCollapsedClass = function ($element, $trigger) { 146 var isOpen = $element.hasClass('in') 147 148 $element.attr('aria-expanded', isOpen) 149 $trigger 150 .toggleClass('collapsed', !isOpen) 151 .attr('aria-expanded', isOpen) 152 } 153 154 function getTargetFromTrigger($trigger) { 155 var href 156 var target = $trigger.attr('data-target') 157 || (href = $trigger.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '') 158 159 return $(target) 160 } 161 162 function Plugin(option) { 163 return this.each(function () { 164 var $this = $(this) 165 var data = $this.data('bs.collapse') 166 var options = $.extend({}, Collapse.DEFAULTS, $this.data(), typeof option == 'object' && option) 167 168 if (!data && options.toggle && /show|hide/.test(option)) options.toggle = false 169 if (!data) $this.data('bs.collapse', (data = new Collapse(this, options))) 170 if (typeof option == 'string') data[option]() 171 }) 172 } 173 174 var old = $.fn.collapse 175 176 $.fn.collapse = Plugin 177 $.fn.collapse.Constructor = Collapse 178 179 $.fn.collapse.noConflict = function () { 180 $.fn.collapse = old 181 return this 182 } 183 184 $(document).on('click.bs.collapse.data-api', '[data-toggle="collapse"]', function (e) { 185 var $this = $(this) 186 187 if (!$this.attr('data-target')) e.preventDefault() 188 189 var $target = getTargetFromTrigger($this) 190 var data = $target.data('bs.collapse') 191 var option = data ? 'toggle' : $this.data() 192 193 Plugin.call($target, option) 194 }) 195 196}(jQuery);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.