define(["../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 && _AN_Call_getattribute("getAttribute", elem, "class") || ""; } jQuery.fn.extend({ addClass: function (value){ var classes, elem, cur, curValue, clazz, j, finalValue, proceed = typeof value === "string" && value, i = 0, len = _AN_Read_length("length", this); if (jQuery.isFunction(value)) { return this.each(function (j){ jQuery(this).addClass(value.call(this, j, getClass(this))); } ); } if (proceed) { classes = (value || "").match(rnotwhite) || [] ; for (; i < len; i++ ){ elem = this[i]; curValue = getClass(elem); cur = elem.nodeType === 1 && _AN_Call_replace("replace", (" " + curValue + " "), rclass, " "); if (cur) { j = 0; while ((clazz = classes[j++ ])){ if (cur.indexOf(" " + clazz + " ") < 0) { cur += clazz + " "; } } finalValue = jQuery.trim(cur); if (curValue !== finalValue) { _AN_Call_setattribute("setAttribute", elem, "class", finalValue); } } } } return this; } , removeClass: function (value){ var classes, elem, cur, curValue, clazz, j, finalValue, proceed = _AN_Read_length("length", arguments) === 0 || typeof value === "string" && value, i = 0, len = _AN_Read_length("length", this); if (jQuery.isFunction(value)) { 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]; curValue = getClass(elem); cur = elem.nodeType === 1 && _AN_Call_replace("replace", (" " + curValue + " "), rclass, " "); if (cur) { j = 0; while ((clazz = classes[j++ ])){ while (cur.indexOf(" " + clazz + " ") > -1){ cur = _AN_Call_replace("replace", cur, " " + clazz + " ", " "); } } finalValue = value? jQuery.trim(cur): ""; if (curValue !== finalValue) { _AN_Call_setattribute("setAttribute", elem, "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") { i = 0; self = jQuery(this); classNames = value.match(rnotwhite) || [] ; while ((className = classNames[i++ ])){ if (self.hasClass(className)) { self.removeClass(className); } else { self.addClass(className); } } } else if (value === undefined || type === "boolean") { className = getClass(this); if (className) { dataPriv.set(this, "__className__", className); } if (this.setAttribute) { _AN_Call_setattribute("setAttribute", this, "class", className || value === false ? "": dataPriv.get(this, "__className__") || ""); } } } ); } , hasClass: function (selector){ var className = " " + selector + " ", i = 0, l = _AN_Read_length("length", this); for (; i < l; i++ ){ if (this[i].nodeType === 1 && _AN_Call_replace("replace", (" " + getClass(this[i]) + " "), rclass, " ").indexOf(className) > -1) { return true ; } } return false ; } } ); } );