1 | /* ========================================================================
|
---|
2 | * Bootstrap: alert.js v3.4.1
|
---|
3 | * https://getbootstrap.com/docs/3.4/javascript/#alerts
|
---|
4 | * ========================================================================
|
---|
5 | * Copyright 2011-2019 Twitter, Inc.
|
---|
6 | * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
|
---|
7 | * ======================================================================== */
|
---|
8 |
|
---|
9 |
|
---|
10 | +function ($) {
|
---|
11 | 'use strict';
|
---|
12 |
|
---|
13 | // ALERT CLASS DEFINITION
|
---|
14 | // ======================
|
---|
15 |
|
---|
16 | var dismiss = '[data-dismiss="alert"]'
|
---|
17 | var Alert = function (el) {
|
---|
18 | $(el).on('click', dismiss, this.close)
|
---|
19 | }
|
---|
20 |
|
---|
21 | Alert.VERSION = '3.4.1'
|
---|
22 |
|
---|
23 | Alert.TRANSITION_DURATION = 150
|
---|
24 |
|
---|
25 | Alert.prototype.close = function (e) {
|
---|
26 | var $this = $(this)
|
---|
27 | var selector = $this.attr('data-target')
|
---|
28 |
|
---|
29 | if (!selector) {
|
---|
30 | selector = $this.attr('href')
|
---|
31 | selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') // strip for ie7
|
---|
32 | }
|
---|
33 |
|
---|
34 | selector = selector === '#' ? [] : selector
|
---|
35 | var $parent = $(document).find(selector)
|
---|
36 |
|
---|
37 | if (e) e.preventDefault()
|
---|
38 |
|
---|
39 | if (!$parent.length) {
|
---|
40 | $parent = $this.closest('.alert')
|
---|
41 | }
|
---|
42 |
|
---|
43 | $parent.trigger(e = $.Event('close.bs.alert'))
|
---|
44 |
|
---|
45 | if (e.isDefaultPrevented()) return
|
---|
46 |
|
---|
47 | $parent.removeClass('in')
|
---|
48 |
|
---|
49 | function removeElement() {
|
---|
50 | // detach from parent, fire event then clean up data
|
---|
51 | $parent.detach().trigger('closed.bs.alert').remove()
|
---|
52 | }
|
---|
53 |
|
---|
54 | $.support.transition && $parent.hasClass('fade') ?
|
---|
55 | $parent
|
---|
56 | .one('bsTransitionEnd', removeElement)
|
---|
57 | .emulateTransitionEnd(Alert.TRANSITION_DURATION) :
|
---|
58 | removeElement()
|
---|
59 | }
|
---|
60 |
|
---|
61 |
|
---|
62 | // ALERT PLUGIN DEFINITION
|
---|
63 | // =======================
|
---|
64 |
|
---|
65 | function Plugin(option) {
|
---|
66 | return this.each(function () {
|
---|
67 | var $this = $(this)
|
---|
68 | var data = $this.data('bs.alert')
|
---|
69 |
|
---|
70 | if (!data) $this.data('bs.alert', (data = new Alert(this)))
|
---|
71 | if (typeof option == 'string') data[option].call($this)
|
---|
72 | })
|
---|
73 | }
|
---|
74 |
|
---|
75 | var old = $.fn.alert
|
---|
76 |
|
---|
77 | $.fn.alert = Plugin
|
---|
78 | $.fn.alert.Constructor = Alert
|
---|
79 |
|
---|
80 |
|
---|
81 | // ALERT NO CONFLICT
|
---|
82 | // =================
|
---|
83 |
|
---|
84 | $.fn.alert.noConflict = function () {
|
---|
85 | $.fn.alert = old
|
---|
86 | return this
|
---|
87 | }
|
---|
88 |
|
---|
89 |
|
---|
90 | // ALERT DATA-API
|
---|
91 | // ==============
|
---|
92 |
|
---|
93 | $(document).on('click.bs.alert.data-api', dismiss, Alert.prototype.close)
|
---|
94 |
|
---|
95 | }(jQuery);
|
---|