1
+ /* ==========================================================
2
+ * bootstrap-alerts.js v1.4.0
3
+ * http://twitter.github.com/bootstrap/javascript.html#alerts
4
+ * ==========================================================
5
+ * Copyright 2011 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 ( $ ) {
22
+
23
+ "use strict"
24
+
25
+ /* CSS TRANSITION SUPPORT (https://gist.github.com/373874)
26
+ * ======================================================= */
27
+
28
+ var transitionEnd
29
+
30
+ $ ( document ) . ready ( function ( ) {
31
+
32
+ $ . support . transition = ( function ( ) {
33
+ var thisBody = document . body || document . documentElement
34
+ , thisStyle = thisBody . style
35
+ , support = thisStyle . transition !== undefined || thisStyle . WebkitTransition !== undefined || thisStyle . MozTransition !== undefined || thisStyle . MsTransition !== undefined || thisStyle . OTransition !== undefined
36
+ return support
37
+ } ) ( )
38
+
39
+ // set CSS transition event type
40
+ if ( $ . support . transition ) {
41
+ transitionEnd = "TransitionEnd"
42
+ if ( $ . browser . webkit ) {
43
+ transitionEnd = "webkitTransitionEnd"
44
+ } else if ( $ . browser . mozilla ) {
45
+ transitionEnd = "transitionend"
46
+ } else if ( $ . browser . opera ) {
47
+ transitionEnd = "oTransitionEnd"
48
+ }
49
+ }
50
+
51
+ } )
52
+
53
+ /* ALERT CLASS DEFINITION
54
+ * ====================== */
55
+
56
+ var Alert = function ( content , options ) {
57
+ this . settings = $ . extend ( { } , $ . fn . alert . defaults , options )
58
+ this . $element = $ ( content )
59
+ . delegate ( this . settings . selector , 'click' , this . close )
60
+ }
61
+
62
+ Alert . prototype = {
63
+
64
+ close : function ( e ) {
65
+ var $element = $ ( this ) . parent ( '.alert-message' )
66
+
67
+ e && e . preventDefault ( )
68
+ $element . removeClass ( 'in' )
69
+
70
+ function removeElement ( ) {
71
+ $element . remove ( )
72
+ }
73
+
74
+ $ . support . transition && $element . hasClass ( 'fade' ) ?
75
+ $element . bind ( transitionEnd , removeElement ) :
76
+ removeElement ( )
77
+ }
78
+
79
+ }
80
+
81
+
82
+ /* ALERT PLUGIN DEFINITION
83
+ * ======================= */
84
+
85
+ $ . fn . alert = function ( options ) {
86
+
87
+ if ( options === true ) {
88
+ return this . data ( 'alert' )
89
+ }
90
+
91
+ return this . each ( function ( ) {
92
+ var $this = $ ( this )
93
+
94
+ if ( typeof options == 'string' ) {
95
+ return $this . data ( 'alert' ) [ options ] ( )
96
+ }
97
+
98
+ $ ( this ) . data ( 'alert' , new Alert ( this , options ) )
99
+
100
+ } )
101
+ }
102
+
103
+ $ . fn . alert . defaults = {
104
+ selector : '.close'
105
+ }
106
+
107
+ $ ( document ) . ready ( function ( ) {
108
+ new Alert ( $ ( 'body' ) , {
109
+ selector : '.alert-message[data-alert] .close'
110
+ } )
111
+ } )
112
+
113
+ } ( window . jQuery || window . ender ) ;
0 commit comments