Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/glacials/countvoncount. A Magic: The Gathering JS life counter
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178define( [ "../core", "../var/rnotwhite", "../data/var/dataPriv", "../core/init"], function( jQuery, rnotwhite, dataPriv ) {
var rclass = /[\t\r\n\f]/g;
function getClass( elem ) { return elem.getAttribute && elem.getAttribute( "class" ) || "";}
jQuery.fn.extend( { addClass: function( 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, getClass( this ) ) ); } ); }
if ( typeof value === "string" && value ) { classes = value.match( rnotwhite ) || [];
while ( ( elem = this[ i++ ] ) ) { curValue = getClass( elem ); cur = elem.nodeType === 1 && ( " " + curValue + " " ).replace( rclass, " " );
if ( cur ) { j = 0; while ( ( clazz = classes[ j++ ] ) ) { if ( cur.indexOf( " " + clazz + " " ) < 0 ) { cur += clazz + " "; } }
// Only assign if different to avoid unneeded rendering. finalValue = jQuery.trim( cur ); if ( curValue !== finalValue ) { elem.setAttribute( "class", finalValue ); } } } }
return this; },
removeClass: function( 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, getClass( this ) ) ); } ); }
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 && ( " " + curValue + " " ).replace( rclass, " " );
if ( cur ) { j = 0; while ( ( clazz = classes[ j++ ] ) ) {
// Remove *all* instances while ( cur.indexOf( " " + clazz + " " ) > -1 ) { cur = cur.replace( " " + clazz + " ", " " ); } }
// Only assign if different to avoid unneeded rendering. finalValue = jQuery.trim( cur ); if ( curValue !== finalValue ) { elem.setAttribute( "class", finalValue ); } } } }
return this; },
toggleClass: function( value, stateVal ) { var type = typeof value;
if ( typeof stateVal === "boolean" && type === "string" ) { return stateVal ? this.addClass( value ) : this.removeClass( value ); }
if ( jQuery.isFunction( value ) ) { return this.each( function( i ) { jQuery( this ).toggleClass( value.call( this, i, getClass( this ), stateVal ), stateVal ); } ); }
return this.each( function() { var className, i, self, classNames;
if ( type === "string" ) {
// 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 { self.addClass( className ); } }
// Toggle whole class name } else if ( value === undefined || type === "boolean" ) { className = getClass( this ); if ( className ) {
// Store className if set dataPriv.set( 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. if ( this.setAttribute ) { this.setAttribute( "class", className || value === false ? "" : dataPriv.get( this, "__className__" ) || "" ); } } } ); },
hasClass: function( selector ) { 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; }} );
} );