(function($){function isDOMAttrModifiedSupported(){var p=document.createElement("p");
var flag=false;
if(p.addEventListener){p.addEventListener("DOMAttrModified",function(){flag=true;
},false);
}else{if(p.attachEvent){p.attachEvent("onDOMAttrModified",function(){flag=true;
});
}else{return false;
}}p.setAttribute("id","target");
return flag;
}function checkAttributes(chkAttr,e){if(chkAttr){var attributes=this.data("attr-old-value");
if(e.attributeName.indexOf("style")>=0){if(!attributes.style){attributes.style={};
}var keys=e.attributeName.split(".");
e.attributeName=keys[0];
e.oldValue=attributes.style[keys[1]];
e.newValue=keys[1]+":"+this.prop("style")[$.camelCase(keys[1])];
attributes.style[keys[1]]=e.newValue;
}else{e.oldValue=attributes[e.attributeName];
e.newValue=this.attr(e.attributeName);
attributes[e.attributeName]=e.newValue;
}this.data("attr-old-value",attributes);
}}var MutationObserver=window.MutationObserver||window.WebKitMutationObserver;
$.fn.attrchange=function(a,b){if(typeof a=="object"){var cfg={trackValues:false,callback:$.noop};
if(typeof a==="function"){cfg.callback=a;
}else{$.extend(cfg,a);
}if(cfg.trackValues){this.each(function(i,el){var attributes={};
for(var attr,i=0,attrs=el.attributes,l=attrs.length;
i<l;
i++){attr=attrs.item(i);
attributes[attr.nodeName]=attr.value;
}$(this).data("attr-old-value",attributes);
});
}if(MutationObserver){var mOptions={subtree:false,attributes:true,attributeOldValue:cfg.trackValues};
var observer=new MutationObserver(function(mutations){mutations.forEach(function(e){var _this=e.target;
if(cfg.trackValues){e.newValue=$(_this).attr(e.attributeName);
}if($(_this).data("attrchange-status")==="connected"){cfg.callback.call(_this,e);
}});
});
return this.data("attrchange-method","Mutation Observer").data("attrchange-status","connected").data("attrchange-obs",observer).each(function(){observer.observe(this,mOptions);
});
}else{if(isDOMAttrModifiedSupported()){return this.data("attrchange-method","DOMAttrModified").data("attrchange-status","connected").on("DOMAttrModified",function(event){if(event.originalEvent){event=event.originalEvent;
}event.attributeName=event.attrName;
event.oldValue=event.prevValue;
if($(this).data("attrchange-status")==="connected"){cfg.callback.call(this,event);
}});
}else{if("onpropertychange" in document.body){return this.data("attrchange-method","propertychange").data("attrchange-status","connected").on("propertychange",function(e){e.attributeName=window.event.propertyName;
checkAttributes.call($(this),cfg.trackValues,e);
if($(this).data("attrchange-status")==="connected"){cfg.callback.call(this,e);
}});
}}}return this;
}else{if(typeof a=="string"&&$.fn.attrchange.hasOwnProperty("extensions")&&$.fn.attrchange.extensions.hasOwnProperty(a)){return $.fn.attrchange.extensions[a].call(this,b);
}}};
})(jQuery);
