PageSourceSearch

https://www.bnf.fr/themes/custom/bnfsi/bootstrap/js/collapse.js?tm77ui

js bnf.fr collected 2026-10-01 07:39:24 UTC 6,208 bytes, 219 lines download raw bytes

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