Mercurial > wikked
comparison static/bootstrap/js/alert.js @ 149:d29e2f337b00
Updated to Bootstrap 3.0.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Thu, 12 Dec 2013 21:54:04 -0800 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
148:f02e049d6546 | 149:d29e2f337b00 |
---|---|
1 /* ======================================================================== | |
2 * Bootstrap: alert.js v3.0.3 | |
3 * http://getbootstrap.com/javascript/#alerts | |
4 * ======================================================================== | |
5 * Copyright 2013 Twitter, Inc. | |
6 * | |
7 * Licensed under the Apache License, Version 2.0 (the "License"); | |
8 * you may not use this file except in compliance with the License. | |
9 * You may obtain a copy of the License at | |
10 * | |
11 * http://www.apache.org/licenses/LICENSE-2.0 | |
12 * | |
13 * Unless required by applicable law or agreed to in writing, software | |
14 * distributed under the License is distributed on an "AS IS" BASIS, | |
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
16 * See the License for the specific language governing permissions and | |
17 * limitations under the License. | |
18 * ======================================================================== */ | |
19 | |
20 | |
21 +function ($) { "use strict"; | |
22 | |
23 // ALERT CLASS DEFINITION | |
24 // ====================== | |
25 | |
26 var dismiss = '[data-dismiss="alert"]' | |
27 var Alert = function (el) { | |
28 $(el).on('click', dismiss, this.close) | |
29 } | |
30 | |
31 Alert.prototype.close = function (e) { | |
32 var $this = $(this) | |
33 var selector = $this.attr('data-target') | |
34 | |
35 if (!selector) { | |
36 selector = $this.attr('href') | |
37 selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') // strip for ie7 | |
38 } | |
39 | |
40 var $parent = $(selector) | |
41 | |
42 if (e) e.preventDefault() | |
43 | |
44 if (!$parent.length) { | |
45 $parent = $this.hasClass('alert') ? $this : $this.parent() | |
46 } | |
47 | |
48 $parent.trigger(e = $.Event('close.bs.alert')) | |
49 | |
50 if (e.isDefaultPrevented()) return | |
51 | |
52 $parent.removeClass('in') | |
53 | |
54 function removeElement() { | |
55 $parent.trigger('closed.bs.alert').remove() | |
56 } | |
57 | |
58 $.support.transition && $parent.hasClass('fade') ? | |
59 $parent | |
60 .one($.support.transition.end, removeElement) | |
61 .emulateTransitionEnd(150) : | |
62 removeElement() | |
63 } | |
64 | |
65 | |
66 // ALERT PLUGIN DEFINITION | |
67 // ======================= | |
68 | |
69 var old = $.fn.alert | |
70 | |
71 $.fn.alert = function (option) { | |
72 return this.each(function () { | |
73 var $this = $(this) | |
74 var data = $this.data('bs.alert') | |
75 | |
76 if (!data) $this.data('bs.alert', (data = new Alert(this))) | |
77 if (typeof option == 'string') data[option].call($this) | |
78 }) | |
79 } | |
80 | |
81 $.fn.alert.Constructor = Alert | |
82 | |
83 | |
84 // ALERT NO CONFLICT | |
85 // ================= | |
86 | |
87 $.fn.alert.noConflict = function () { | |
88 $.fn.alert = old | |
89 return this | |
90 } | |
91 | |
92 | |
93 // ALERT DATA-API | |
94 // ============== | |
95 | |
96 $(document).on('click.bs.alert.data-api', dismiss, Alert.prototype.close) | |
97 | |
98 }(jQuery); |