]>
git.r.bdr.sh - rbdr/dotfiles/blob - atom/packages/ex-mode/node_modules/space-pen/node_modules/jquery/src/attributes/classes.js
101138415f874ad1b82f018680976f39e91a1762
5 "../data/var/data_priv",
7 ], function( jQuery
, rnotwhite
, strundefined
, data_priv
) {
9 var rclass
= /[\t\r\n\f]/g;
12 addClass: function( value
) {
13 var classes
, elem
, cur
, clazz
, j
, finalValue
,
14 proceed
= typeof value
=== "string" && value
,
18 if ( jQuery
.isFunction( value
) ) {
19 return this.each(function( j
) {
20 jQuery( this ).addClass( value
.call( this, j
, this.className
) );
25 // The disjunction here is for better compressibility (see removeClass)
26 classes
= ( value
|| "" ).match( rnotwhite
) || [];
28 for ( ; i
< len
; i
++ ) {
30 cur
= elem
.nodeType
=== 1 && ( elem
.className
?
31 ( " " + elem
.className
+ " " ).replace( rclass
, " " ) :
37 while ( (clazz
= classes
[j
++]) ) {
38 if ( cur
.indexOf( " " + clazz
+ " " ) < 0 ) {
43 // only assign if different to avoid unneeded rendering.
44 finalValue
= jQuery
.trim( cur
);
45 if ( elem
.className
!== finalValue
) {
46 elem
.className
= finalValue
;
55 removeClass: function( value
) {
56 var classes
, elem
, cur
, clazz
, j
, finalValue
,
57 proceed
= arguments
.length
=== 0 || typeof value
=== "string" && value
,
61 if ( jQuery
.isFunction( value
) ) {
62 return this.each(function( j
) {
63 jQuery( this ).removeClass( value
.call( this, j
, this.className
) );
67 classes
= ( value
|| "" ).match( rnotwhite
) || [];
69 for ( ; i
< len
; i
++ ) {
71 // This expression is here for better compressibility (see addClass)
72 cur
= elem
.nodeType
=== 1 && ( elem
.className
?
73 ( " " + elem
.className
+ " " ).replace( rclass
, " " ) :
79 while ( (clazz
= classes
[j
++]) ) {
80 // Remove *all* instances
81 while ( cur
.indexOf( " " + clazz
+ " " ) >= 0 ) {
82 cur
= cur
.replace( " " + clazz
+ " ", " " );
86 // Only assign if different to avoid unneeded rendering.
87 finalValue
= value
? jQuery
.trim( cur
) : "";
88 if ( elem
.className
!== finalValue
) {
89 elem
.className
= finalValue
;
98 toggleClass: function( value
, stateVal
) {
99 var type
= typeof value
;
101 if ( typeof stateVal
=== "boolean" && type
=== "string" ) {
102 return stateVal
? this.addClass( value
) : this.removeClass( value
);
105 if ( jQuery
.isFunction( value
) ) {
106 return this.each(function( i
) {
107 jQuery( this ).toggleClass( value
.call(this, i
, this.className
, stateVal
), stateVal
);
111 return this.each(function() {
112 if ( type
=== "string" ) {
113 // Toggle individual class names
116 self
= jQuery( this ),
117 classNames
= value
.match( rnotwhite
) || [];
119 while ( (className
= classNames
[ i
++ ]) ) {
120 // Check each className given, space separated list
121 if ( self
.hasClass( className
) ) {
122 self
.removeClass( className
);
124 self
.addClass( className
);
128 // Toggle whole class name
129 } else if ( type
=== strundefined
|| type
=== "boolean" ) {
130 if ( this.className
) {
131 // store className if set
132 data_priv
.set( this, "__className__", this.className
);
135 // If the element has a class name or if we're passed `false`,
136 // then remove the whole classname (if there was one, the above saved it).
137 // Otherwise bring back whatever was previously saved (if anything),
138 // falling back to the empty string if nothing was stored.
139 this.className
= this.className
|| value
=== false ? "" : data_priv
.get( this, "__className__" ) || "";
144 hasClass: function( selector
) {
145 var className
= " " + selector
+ " ",
148 for ( ; i
< l
; i
++ ) {
149 if ( this[i
].nodeType
=== 1 && (" " + this[i
].className
+ " ").replace(rclass
, " ").indexOf( className
) >= 0 ) {