Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'libs/bower_components/jquery/src/attributes/classes.js')
-rw-r--r--libs/bower_components/jquery/src/attributes/classes.js153
1 files changed, 85 insertions, 68 deletions
diff --git a/libs/bower_components/jquery/src/attributes/classes.js b/libs/bower_components/jquery/src/attributes/classes.js
index 64bc747c52..a58f5491c4 100644
--- a/libs/bower_components/jquery/src/attributes/classes.js
+++ b/libs/bower_components/jquery/src/attributes/classes.js
@@ -1,39 +1,37 @@
-define([
+define( [
"../core",
"../var/rnotwhite",
- "../var/strundefined",
"../core/init"
-], function( jQuery, rnotwhite, strundefined ) {
+], function( jQuery, rnotwhite ) {
var rclass = /[\t\r\n\f]/g;
-jQuery.fn.extend({
+function getClass( elem ) {
+ return jQuery.attr( elem, "class" ) || "";
+}
+
+jQuery.fn.extend( {
addClass: function( value ) {
- var classes, elem, cur, clazz, j, finalValue,
- i = 0,
- len = this.length,
- proceed = typeof value === "string" && value;
+ var classes, elem, cur, curValue, clazz, j, finalValue,
+ i = 0;
if ( jQuery.isFunction( value ) ) {
- return this.each(function( j ) {
- jQuery( this ).addClass( value.call( this, j, this.className ) );
- });
+ return this.each( function( j ) {
+ jQuery( this ).addClass( value.call( this, j, getClass( this ) ) );
+ } );
}
- if ( proceed ) {
- // The disjunction here is for better compressibility (see removeClass)
- classes = ( value || "" ).match( rnotwhite ) || [];
+ if ( typeof value === "string" && value ) {
+ classes = value.match( rnotwhite ) || [];
- for ( ; i < len; i++ ) {
- elem = this[ i ];
- cur = elem.nodeType === 1 && ( elem.className ?
- ( " " + elem.className + " " ).replace( rclass, " " ) :
- " "
- );
+ while ( ( elem = this[ i++ ] ) ) {
+ curValue = getClass( elem );
+ cur = elem.nodeType === 1 &&
+ ( " " + curValue + " " ).replace( rclass, " " );
if ( cur ) {
j = 0;
- while ( (clazz = classes[j++]) ) {
+ while ( ( clazz = classes[ j++ ] ) ) {
if ( cur.indexOf( " " + clazz + " " ) < 0 ) {
cur += clazz + " ";
}
@@ -41,8 +39,8 @@ jQuery.fn.extend({
// only assign if different to avoid unneeded rendering.
finalValue = jQuery.trim( cur );
- if ( elem.className !== finalValue ) {
- elem.className = finalValue;
+ if ( curValue !== finalValue ) {
+ jQuery.attr( elem, "class", finalValue );
}
}
}
@@ -52,40 +50,43 @@ jQuery.fn.extend({
},
removeClass: function( value ) {
- var classes, elem, cur, clazz, j, finalValue,
- i = 0,
- len = this.length,
- proceed = arguments.length === 0 || typeof value === "string" && value;
+ var classes, elem, cur, curValue, clazz, j, finalValue,
+ i = 0;
if ( jQuery.isFunction( value ) ) {
- return this.each(function( j ) {
- jQuery( this ).removeClass( value.call( this, j, this.className ) );
- });
+ return this.each( function( j ) {
+ jQuery( this ).removeClass( value.call( this, j, getClass( this ) ) );
+ } );
}
- if ( proceed ) {
- classes = ( value || "" ).match( rnotwhite ) || [];
- for ( ; i < len; i++ ) {
- elem = this[ i ];
+ if ( !arguments.length ) {
+ return this.attr( "class", "" );
+ }
+
+ if ( typeof value === "string" && value ) {
+ classes = value.match( rnotwhite ) || [];
+
+ while ( ( elem = this[ i++ ] ) ) {
+ curValue = getClass( elem );
+
// This expression is here for better compressibility (see addClass)
- cur = elem.nodeType === 1 && ( elem.className ?
- ( " " + elem.className + " " ).replace( rclass, " " ) :
- ""
- );
+ cur = elem.nodeType === 1 &&
+ ( " " + curValue + " " ).replace( rclass, " " );
if ( cur ) {
j = 0;
- while ( (clazz = classes[j++]) ) {
+ while ( ( clazz = classes[ j++ ] ) ) {
+
// Remove *all* instances
- while ( cur.indexOf( " " + clazz + " " ) >= 0 ) {
+ while ( cur.indexOf( " " + clazz + " " ) > -1 ) {
cur = cur.replace( " " + clazz + " ", " " );
}
}
- // only assign if different to avoid unneeded rendering.
- finalValue = value ? jQuery.trim( cur ) : "";
- if ( elem.className !== finalValue ) {
- elem.className = finalValue;
+ // Only assign if different to avoid unneeded rendering.
+ finalValue = jQuery.trim( cur );
+ if ( curValue !== finalValue ) {
+ jQuery.attr( elem, "class", finalValue );
}
}
}
@@ -102,21 +103,27 @@ jQuery.fn.extend({
}
if ( jQuery.isFunction( value ) ) {
- return this.each(function( i ) {
- jQuery( this ).toggleClass( value.call(this, i, this.className, stateVal), stateVal );
- });
+ return this.each( function( i ) {
+ jQuery( this ).toggleClass(
+ value.call( this, i, getClass( this ), stateVal ),
+ stateVal
+ );
+ } );
}
- return this.each(function() {
+ return this.each( function() {
+ var className, i, self, classNames;
+
if ( type === "string" ) {
- // toggle individual class names
- var className,
- i = 0,
- self = jQuery( this ),
- classNames = value.match( rnotwhite ) || [];
-
- while ( (className = classNames[ i++ ]) ) {
- // check each className given, space separated list
+
+ // Toggle individual class names
+ i = 0;
+ self = jQuery( this );
+ classNames = value.match( rnotwhite ) || [];
+
+ while ( ( className = classNames[ i++ ] ) ) {
+
+ // Check each className given, space separated list
if ( self.hasClass( className ) ) {
self.removeClass( className );
} else {
@@ -125,33 +132,43 @@ jQuery.fn.extend({
}
// Toggle whole class name
- } else if ( type === strundefined || type === "boolean" ) {
- if ( this.className ) {
+ } else if ( value === undefined || type === "boolean" ) {
+ className = getClass( this );
+ if ( className ) {
+
// store className if set
- jQuery._data( this, "__className__", this.className );
+ jQuery._data( this, "__className__", className );
}
// If the element has a class name or if we're passed "false",
// then remove the whole classname (if there was one, the above saved it).
// Otherwise bring back whatever was previously saved (if anything),
// falling back to the empty string if nothing was stored.
- this.className = this.className || value === false ? "" : jQuery._data( this, "__className__" ) || "";
+ jQuery.attr( this, "class",
+ className || value === false ?
+ "" :
+ jQuery._data( this, "__className__" ) || ""
+ );
}
- });
+ } );
},
hasClass: function( selector ) {
- var className = " " + selector + " ",
- i = 0,
- l = this.length;
- for ( ; i < l; i++ ) {
- if ( this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) >= 0 ) {
+ var className, elem,
+ i = 0;
+
+ className = " " + selector + " ";
+ while ( ( elem = this[ i++ ] ) ) {
+ if ( elem.nodeType === 1 &&
+ ( " " + getClass( elem ) + " " ).replace( rclass, " " )
+ .indexOf( className ) > -1
+ ) {
return true;
}
}
return false;
}
-});
+} );
-});
+} );