1
0
Fork 0

Added jquery clone styles plugin

master
Matthieu Lalonde 12 years ago
parent d1e6308912
commit 3093c9ccd9

@ -0,0 +1,38 @@
/*
* getStyleObject Plugin for jQuery JavaScript Library
* From: http://upshots.org/?p=112
*
* Copyright: Unknown, see source link
* Plugin version by Dakota Schneider (http://hackthetruth.org)
*
* Source: http://stackoverflow.com/a/6416477
*/
(function($){
$.fn.getStyleObject = function(){
var dom = this.get(0);
var style;
var returns = {};
if(window.getComputedStyle){
var camelize = function(a,b){
return b.toUpperCase();
};
style = window.getComputedStyle(dom, null);
for(var i=0;i<style.length;i++){
var prop = style[i];
var camel = prop.replace(/\-([a-z])/g, camelize);
var val = style.getPropertyValue(prop);
returns[camel] = val;
}
return returns;
}
if(dom.currentStyle){
style = dom.currentStyle;
for(var propp in style){
returns[propp] = style[propp];
}
return returns;
}
return this.css();
};
})(jQuery);
Loading…
Cancel
Save