topical media & game development
lib-jquery-plugin-animate-animate-files-jquery.js / js
/*
* jQuery Animate To Class
* Copyright 2008 Igor Frias Vieira
* http://igorvieira.com/blog/animate-to-class/
*
* Released under the MIT and GPL licenses.
*/
(function(.fn.extend({
animateToClass : function(to, duration, easing, callback)
{
if(!to){ return this; }
styles = selectStyle(to);
if(!styles) return this;
return this.animate(styles, duration, easing, callback);
}
});
function selectStyle(sel)
{
if(sel.substr(0,1) != ".")
{
sel = "." + sel;
}
for(var cont = 0; cont < document.styleSheets.length; cont++)
{
v = document.styleSheets[cont];
attrClass = selectAttr(sel, v);
if(attrClass != false)
{
break;
}
}
if(!attrClass)
{
attrClass = Array();
}
objStyle = {}
if(attrClass == "")
{
return false;
}
if(attrClass.match(";"))
{
attrClass = attrClass.split(";");
}
else
{
attrClass = [attrClass];
}
attrClass.each(function(i,v){
if(v != ""){
v = v.split(":");
v[0] = toCamelCase(v[0]);
objStyle[v[0]] = .browser.msie)
{
if(v.rules.length > 0)
{
$(v.rules).each(function(i2,v2){
if(sel == v2.selectorText)
{
attrClass = v2.style.cssText;
}
});
}
else if(v.imports.length > 0)
{
$(v.imports).each(function(i2,v2){
if(sel == v2.selectorText)
{
attrClass = v2.style.cssText;
}
else if(v2 == "[object]" || v2 == "[Object CSSStyleSheet]" || v2 == "[object CSSImportRule]")
{
return selectAttr(sel, v2);
}
});
}
}
else
{
$(v.cssRules).each(function(i2,v2){
if(sel == v2.selectorText)
{
attrClass = v2.style.cssText;
}
else if(v2 == "[object CSSImportRule]")
{
return selectAttr(sel, v2.styleSheet);
}
});
}
return attrClass;
}
function toCamelCase(str)
{
str =
(C) Æliens
20/2/2008
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.