PageSourceSearch

https://www.archives.gov/sites/all/themes/nara/assets/javascripts/bootstrap/collapse.js?tluiwm

js archives.gov collected 2026-09-25 06:07:18 UTC 4,872 bytes, 170 lines download raw bytes

1/* ========================================================================
2 * Bootstrap: collapse.js v3.2.0
3 * http://getbootstrap.com/javascript/#collapse
4 * ========================================================================
5 * Copyright 2011-2014 Twitter, Inc.
6 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
7 * ======================================================================== */
8
9
10+function ($) {
11  'use strict';
12
13  // COLLAPSE PUBLIC CLASS DEFINITION
14  // ================================
15
16  var Collapse = function (element, options) {
17    this.$element      = $(element)
18    this.options       = $.extend({}, Collapse.DEFAULTS, options)
19    this.transitioning = null
20
21    if (this.options.parent) this.$parent = $(this.options.parent)
22    if (this.options.toggle) this.toggle()
23  }
24
25  Collapse.VERSION  = '3.2.0'
26
27  Collapse.DEFAULTS = {
28    toggle: true
29  }
30
31  Collapse.prototype.dimension = function () {
32    var hasWidth = this.$element.hasClass('width')
33    return hasWidth ? 'width' : 'height'
34  }
35
36  Collapse.prototype.show = function () {
37    if (this.transitioning || this.$element.hasClass('in')) return
38
39    var startEvent = $.Event('show.bs.collapse')
40    this.$element.trigger(startEvent)
41    if (startEvent.isDefaultPrevented()) return
42
43    var actives = this.$parent && this.$parent.find('> .panel > .in')
44
45    if (actives && actives.length) {
46      var hasData = actives.data('bs.collapse')
47      if (hasData && hasData.transitioning) return
48      Plugin.call(actives, 'hide')
49      hasData || actives.data('bs.collapse', null)
50    }
51
52    var dimension = this.dimension()
53
54    this.$element
55      .removeClass('collapse')
56      .addClass('collapsing')[dimension](0)
57
58    this.transitioning = 1
59
60    var complete = function () {
61      this.$element
62        .removeClass('collapsing')
63        .addClass('collapse in')[dimension]('')
64      this.transitioning = 0
65      this.$element
66        .trigger('shown.bs.collapse')
67    }
68
69    if (!$.support.transition) return complete.call(this)
70
71    var scrollSize = $.camelCase(['scroll', dimension].join('-'))
72
73    this.$element
74      .one('bsTransitionEnd', $.proxy(complete, this))
75      .emulateTransitionEnd(350)[dimension](this.$element[0][scrollSize])
76  }
77
78  Collapse.prototype.hide = function () {
79    if (this.transitioning || !this.$element.hasClass('in')) return
80
81    var startEvent = $.Event('hide.bs.collapse')
82    this.$element.trigger(startEvent)
83    if (startEvent.isDefaultPrevented()) return
84
85    var dimension = this.dimension()
86
87    this.$element[dimension](this.$element[dimension]())[0].offsetHeight
88
89    this.$element
90      .addClass('collapsing')
91      .removeClass('collapse')
92      .removeClass('in')
93
94    this.transitioning = 1
95
96    var complete = function () {
97      this.transitioning = 0
98      this.$element
99        .trigger('hidden.bs.collapse')
100        .removeClass('collapsing')
101        .addClass('collapse')
102    }
103
104    if (!$.support.transition) return complete.call(this)
105
106    this.$element
107      [dimension](0)
108      .one('bsTransitionEnd', $.proxy(complete, this))
109      .emulateTransitionEnd(350)
110  }
111
112  Collapse.prototype.toggle = function () {
113    this[this.$element.hasClass('in') ? 'hide' : 'show']()
114  }
115
116
117  // COLLAPSE PLUGIN DEFINITION
118  // ==========================
119
120  function Plugin(option) {
121    return this.each(function () {
122      var $this   = $(this)
123      var data    = $this.data('bs.collapse')
124      var options = $.extend({}, Collapse.DEFAULTS, $this.data(), typeof option == 'object' && option)
125
126      if (!data && options.toggle && option == 'show') option = !option
127      if (!data) $this.data('bs.collapse', (data = new Collapse(this, options)))
128      if (typeof option == 'string') data[option]()
129    })
130  }
131
132  var old = $.fn.collapse
133
134  $.fn.collapse             = Plugin
135  $.fn.collapse.Constructor = Collapse
136
137
138  // COLLAPSE NO CONFLICT
139  // ====================
140
141  $.fn.collapse.noConflict = function () {
142    $.fn.collapse = old
143    return this
144  }
145
146
147  // COLLAPSE DATA-API
148  // =================
149
150  $(document).on('click.bs.collapse.data-api', '[data-toggle="collapse"]', function (e) {
151    var href
152    var $this   = $(this)
153    var target  = $this.attr('data-target')
154        || e.preventDefault()
155        || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '') // strip for ie7
156    var $target = $(target)
157    var data    = $target.data('bs.collapse')
158    var option  = data ? 'toggle' : $this.data()
159    var parent  = $this.attr('data-parent')
160    var $parent = parent && $(parent)
161
162    if (!data || !data.transitioning) {
163      if ($parent) $parent.find('[data-toggle="collapse"][data-parent="' + parent + '"]').not($this).addClass('collapsed')
164      $this[$target.hasClass('in') ? 'addClass' : 'removeClass']('collapsed')
165    }
166
167    Plugin.call($target, option)
168  })
169
170}(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.