PageSourceSearch

https://www.ijcas.org/asset/js/bootstrap.modal.js

js ijcas.org collected 2026-10-04 16:51:20 UTC 13,019 bytes, 436 lines download raw bytes

vendor: 13,019 bytes, lines 1-436
1/*!
2 * Bootstrap v3.4.1 (https://getbootstrap.com/)
3 * Copyright 2011-2019 Twitter, Inc.
4 * Licensed under the MIT license
5 */
6
7if (typeof jQuery === 'undefined') {
8  throw new Error('Bootstrap\'s JavaScript requires jQuery')
9}
10
11+function ($) {
12  'use strict';
13  var version = $.fn.jquery.split(' ')[0].split('.')
14  if ((version[0] < 2 && version[1] < 9) || (version[0] == 1 && version[1] == 9 && version[2] < 1) || (version[0] > 3)) {
15    throw new Error('Bootstrap\'s JavaScript requires jQuery version 1.9.1 or higher, but lower than version 4')
16  }
17}(jQuery);
18
19/* ========================================================================
20 * Bootstrap: transition.js v3.4.1
21 * https://getbootstrap.com/docs/3.4/javascript/#transitions
22 * ========================================================================
23 * Copyright 2011-2019 Twitter, Inc.
24 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
25 * ======================================================================== */
26
27
28+function ($) {
29  'use strict';
30
31  // CSS TRANSITION SUPPORT (Shoutout: https://modernizr.com/)
32  // ============================================================
33
34  function transitionEnd() {
35    var el = document.createElement('bootstrap')
36
37    var transEndEventNames = {
38      WebkitTransition : 'webkitTransitionEnd',
39      MozTransition    : 'transitionend',
40      OTransition      : 'oTransitionEnd otransitionend',
41      transition       : 'transitionend'
42    }
43
44    for (var name in transEndEventNames) {
45      if (el.style[name] !== undefined) {
46        return { end: transEndEventNames[name] }
47      }
48    }
49
50    return false // explicit for ie8 (  ._.)
51  }
52
53  // https://blog.alexmaccaw.com/css-transitions
54  $.fn.emulateTransitionEnd = function (duration) {
55    var called = false
56    var $el = this
57    $(this).one('bsTransitionEnd', function () { called = true })
58    var callback = function () { if (!called) $($el).trigger($.support.transition.end) }
59    setTimeout(callback, duration)
60    return this
61  }
62
63  $(function () {
64    $.support.transition = transitionEnd()
65
66    if (!$.support.transition) return
67
68    $.event.special.bsTransitionEnd = {
69      bindType: $.support.transition.end,
70      delegateType: $.support.transition.end,
71      handle: function (e) {
72        if ($(e.target).is(this)) return e.handleObj.handler.apply(this, arguments)
73      }
74    }
75  })
76
77}(jQuery);
78
79/* ========================================================================
80 * Bootstrap: modal.js v3.4.1
81 * https://getbootstrap.com/docs/3.4/javascript/#modals
82 * ========================================================================
83 * Copyright 2011-2019 Twitter, Inc.
84 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
85 * ======================================================================== */
86
87
88+function ($) {
89  'use strict';
90
91  // MODAL CLASS DEFINITION
92  // ======================
93
94  var Modal = function (element, options) {
95    this.options = options
96    this.$body = $(document.body)
97    this.$element = $(element)
98    this.$dialog = this.$element.find('.modal-dialog')
99    this.$backdrop = null
100    this.isShown = null
101    this.originalBodyPad = null
102    this.scrollbarWidth = 0
103    this.ignoreBackdropClick = false
104    this.fixedContent = '.navbar-fixed-top, .navbar-fixed-bottom'
105
106    if (this.options.remote) {
107      this.$element
108        .find('.modal-content')
109        .load(this.options.remote, $.proxy(function () {
110          this.$element.trigger('loaded.bs.modal')
111        }, this))
112    }
113  }
114
115  Modal.VERSION = '3.4.1'
116
117  Modal.TRANSITION_DURATION = 300
118  Modal.BACKDROP_TRANSITION_DURATION = 150
119
120  Modal.DEFAULTS = {
121    backdrop: true,
122    keyboard: true,
123    show: true
124  }
125
126  Modal.prototype.toggle = function (_relatedTarget) {
127    return this.isShown ? this.hide() : this.show(_relatedTarget)
128  }
129
130  Modal.prototype.show = function (_relatedTarget) {
131    var that = this
132    var e = $.Event('show.bs.modal', { relatedTarget: _relatedTarget })
133
134    this.$element.trigger(e)
135
136    if (this.isShown || e.isDefaultPrevented()) return
137
138    this.isShown = true
139
140    this.checkScrollbar()
141    this.setScrollbar()
142    this.$body.addClass('modal-open')
143
144    this.escape()
145    this.resize()
146
147    this.$element.on('click.dismiss.bs.modal', '[data-dismiss="modal"]', $.proxy(this.hide, this))
148
149    this.$dialog.on('mousedown.dismiss.bs.modal', function () {
150      that.$element.one('mouseup.dismiss.bs.modal', function (e) {
151        if ($(e.target).is(that.$element)) that.ignoreBackdropClick = true
152      })
153    })
154
155    this.backdrop(function () {
156      var transition = $.support.transition && that.$element.hasClass('fade')
157
158      if (!that.$element.parent().length) {
159        that.$element.appendTo(that.$body) // don't move modals dom position
160      }
161
162      that.$element
163        .show()
164        .scrollTop(0)
165
166      that.adjustDialog()
167
168      if (transition) {
169        that.$element[0].offsetWidth // force reflow
170      }
171
172      that.$element.addClass('in')
173
174      that.enforceFocus()
175
176      var e = $.Event('shown.bs.modal', { relatedTarget: _relatedTarget })
177
178      transition ?
179        that.$dialog // wait for modal to slide in
180          .one('bsTransitionEnd', function () {
181            that.$element.trigger('focus').trigger(e)
182          })
183          .emulateTransitionEnd(Modal.TRANSITION_DURATION) :
184        that.$element.trigger('focus').trigger(e)
185    })
186  }
187
188  Modal.prototype.hide = function (e) {
189    if (e) e.preventDefault()
190
191    e = $.Event('hide.bs.modal')
192
193    this.$element.trigger(e)
194
195    if (!this.isShown || e.isDefaultPrevented()) return
196
197    this.isShown = false
198
199    this.escape()
200    this.resize()
201
202    $(document).off('focusin.bs.modal')
203
204    this.$element
205      .removeClass('in')
206      .off('click.dismiss.bs.modal')
207      .off('mouseup.dismiss.bs.modal')
208
209    this.$dialog.off('mousedown.dismiss.bs.modal')
210
211    $.support.transition && this.$element.hasClass('fade') ?
212      this.$element
213        .one('bsTransitionEnd', $.proxy(this.hideModal, this))
214        .emulateTransitionEnd(Modal.TRANSITION_DURATION) :
215      this.hideModal()
216  }
217
218  Modal.prototype.enforceFocus = function () {
219    $(document)
220      .off('focusin.bs.modal') // guard against infinite focus loop
221      .on('focusin.bs.modal', $.proxy(function (e) {
222        if (document !== e.target &&
223          this.$element[0] !== e.target &&
224          !this.$element.has(e.target).length) {
225          this.$element.trigger('focus')
226        }
227      }, this))
228  }
229
230  Modal.prototype.escape = function () {
231    if (this.isShown && this.options.keyboard) {
232      this.$element.on('keydown.dismiss.bs.modal', $.proxy(function (e) {
233        e.which == 27 && this.hide()
234      }, this))
235    } else if (!this.isShown) {
236      this.$element.off('keydown.dismiss.bs.modal')
237    }
238  }
239
240  Modal.prototype.resize = function () {
241    if (this.isShown) {
242      $(window).on('resize.bs.modal', $.proxy(this.handleUpdate, this))
243    } else {
244      $(window).off('resize.bs.modal')
245    }
246  }
247
248  Modal.prototype.hideModal = function () {
249    var that = this
250    this.$element.hide()
251    this.backdrop(function () {
252      that.$body.removeClass('modal-open')
253      that.resetAdjustments()
254      that.resetScrollbar()
255      that.$element.trigger('hidden.bs.modal')
256    })
257  }
258
259  Modal.prototype.removeBackdrop = function () {
260    this.$backdrop && this.$backdrop.remove()
261    this.$backdrop = null
262  }
263
264  Modal.prototype.backdrop = function (callback) {
265    var that = this
266    var animate = this.$element.hasClass('fade') ? 'fade' : ''
267
268    if (this.isShown && this.options.backdrop) {
269      var doAnimate = $.support.transition && animate
270
271      this.$backdrop = $(document.createElement('div'))
272        .addClass('modal-backdrop ' + animate)
273        .appendTo(this.$body)
274
275      this.$element.on('click.dismiss.bs.modal', $.proxy(function (e) {
276        if (this.ignoreBackdropClick) {
277          this.ignoreBackdropClick = false
278          return
279        }
280        if (e.target !== e.currentTarget) return
281        this.options.backdrop == 'static'
282          ? this.$element[0].focus()
283          : this.hide()
284      }, this))
285
286      if (doAnimate) this.$backdrop[0].offsetWidth // force reflow
287
288      this.$backdrop.addClass('in')
289
290      if (!callback) return
291
292      doAnimate ?
293        this.$backdrop
294          .one('bsTransitionEnd', callback)
295          .emulateTransitionEnd(Modal.BACKDROP_TRANSITION_DURATION) :
296        callback()
297
298    } else if (!this.isShown && this.$backdrop) {
299      this.$backdrop.removeClass('in')
300
301      var callbackRemove = function () {
302        that.removeBackdrop()
303        callback && callback()
304      }
305      $.support.transition && this.$element.hasClass('fade') ?
306        this.$backdrop
307          .one('bsTransitionEnd', callbackRemove)
308          .emulateTransitionEnd(Modal.BACKDROP_TRANSITION_DURATION) :
309        callbackRemove()
310
311    } else if (callback) {
312      callback()
313    }
314  }
315
316  // these following methods are used to handle overflowing modals
317
318  Modal.prototype.handleUpdate = function () {
319    this.adjustDialog()
320  }
321
322  Modal.prototype.adjustDialog = function () {
323    var modalIsOverflowing = this.$element[0].scrollHeight > document.documentElement.clientHeight
324
325    this.$element.css({
326      paddingLeft: !this.bodyIsOverflowing && modalIsOverflowing ? this.scrollbarWidth : '',
327      paddingRight: this.bodyIsOverflowing && !modalIsOverflowing ? this.scrollbarWidth : ''
328    })
329  }
330
331  Modal.prototype.resetAdjustments = function () {
332    this.$element.css({
333      paddingLeft: '',
334      paddingRight: ''
335    })
336  }
337
338  Modal.prototype.checkScrollbar = function () {
339    var fullWindowWidth = window.innerWidth
340    if (!fullWindowWidth) { // workaround for missing window.innerWidth in IE8
341      var documentElementRect = document.documentElement.getBoundingClientRect()
342      fullWindowWidth = documentElementRect.right - Math.abs(documentElementRect.left)
343    }
344    this.bodyIsOverflowing = document.body.clientWidth < fullWindowWidth
345    this.scrollbarWidth = this.measureScrollbar()
346  }
347
348  Modal.prototype.setScrollbar = function () {
349    var bodyPad = parseInt((this.$body.css('padding-right') || 0), 10)
350    this.originalBodyPad = document.body.style.paddingRight || ''
351    var scrollbarWidth = this.scrollbarWidth
352    if (this.bodyIsOverflowing) {
353      this.$body.css('padding-right', bodyPad + scrollbarWidth)
354      $(this.fixedContent).each(function (index, element) {
355        var actualPadding = element.style.paddingRight
356        var calculatedPadding = $(element).css('padding-right')
357        $(element)
358          .data('padding-right', actualPadding)
359          .css('padding-right', parseFloat(calculatedPadding) + scrollbarWidth + 'px')
360      })
361    }
362  }
363
364  Modal.prototype.resetScrollbar = function () {
365    this.$body.css('padding-right', this.originalBodyPad)
366    $(this.fixedContent).each(function (index, element) {
367      var padding = $(element).data('padding-right')
368      $(element).removeData('padding-right')
369      element.style.paddingRight = padding ? padding : ''
370    })
371  }
372
373  Modal.prototype.measureScrollbar = function () { // thx walsh
374    var scrollDiv = document.createElement('div')
375    scrollDiv.className = 'modal-scrollbar-measure'
376    this.$body.append(scrollDiv)
377    var scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth
378    this.$body[0].removeChild(scrollDiv)
379    return scrollbarWidth
380  }
381
382
383  // MODAL PLUGIN DEFINITION
384  // =======================
385
386  function Plugin(option, _relatedTarget) {
387    return this.each(function () {
388      var $this = $(this)
389      var data = $this.data('bs.modal')
390      var options = $.extend({}, Modal.DEFAULTS, $this.data(), typeof option == 'object' && option)
391
392      if (!data) $this.data('bs.modal', (data = new Modal(this, options)))
393      if (typeof option == 'string') data[option](_relatedTarget)
394      else if (options.show) data.show(_relatedTarget)
395    })
396  }
397
398  var old = $.fn.modal
399
400  $.fn.modal = Plugin
401  $.fn.modal.Constructor = Modal
402
403
404  // MODAL NO CONFLICT
405  // =================
406
407  $.fn.modal.noConflict = function () {
408    $.fn.modal = old
409    return this
410  }
411
412
413  // MODAL DATA-API
414  // ==============
415
416  $(document).on('click.bs.modal.data-api', '[data-toggle="modal"]', function (e) {
417    var $this = $(this)
418    var href = $this.attr('href')
419    var target = $this.attr('data-target') ||
420      (href && href.replace(/.*(?=#[^\s]+$)/, '')) // strip for ie7
421
422    var $target = $(document).find(target)
423    var option = $target.data('bs.modal') ? 'toggle' : $.extend({ remote: !/#/.test(href) && href }, $target.data(), $this.data())
424
425    if ($this.is('a')) e.preventDefault()
426
427    $target.one('show.bs.modal', function (showEvent) {
428      if (showEvent.isDefaultPrevented()) return // only register focus restorer if modal will actually get shown
429      $target.one('hidden.bs.modal', function () {
430        $this.is(':visible') && $this.trigger('focus')
431      })
432    })
433    Plugin.call($target, option, this)
434  })
435
436}(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.