-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcssob.js
34 lines (32 loc) · 1.18 KB
/
cssob.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
(function(){
window.cssob = {};
cssob.methods = [];
cssob.methods[0] = {name: 'listProps', func: function(){
var Result = []
for(var key in this){
if(this[key] != ""){
Result.push(key);
}}
return Result;
}};
cssob.composeMethods = function composeMethods(elm){
var meths = cssob.methods;
for(var i = 0; i<meths.length; i++){
elm[meths[i].name] = meths[i].func;
}}
function CSSStyleDeclarationCompensation(){this.n = false}
window.CSSStyleDeclaration = window.CSSStyleDeclaration || new CSSStyleDeclarationCompensation();
window.CSSRuleStyleDeclaration = window.CSSRuleStyleDeclaration || undefined;
var elm = (CSSRuleStyleDeclaration || CSSStyleDeclaration).prototype;
if(CSSStyleDeclaration.n === false){elm = CSSStyleDeclaration;}
cssob.composeMethods(elm);//Method Assignment
crules = document.styleSheets;
for(var qi = 0; qi<crules.length; qi++){
ruleSet = crules[qi].cssRules || crules[qi].rules;
for(var rsi = 0;rsi<ruleSet.length; rsi++){
var rule = ruleSet[rsi];
if(CSSStyleDeclaration.n === false){cssob.composeMethods(rule.style);} //IE7 method Assignment
cssob[rule.selectorText.toLowerCase()] = rule.style;
}
}
})();