root / trunk / web / dojo / dojox / html / styles.js @ 12
History | View | Annotate | Download (3.14 KB)
1 |
/*
|
---|---|
2 |
Copyright (c) 2004-2010, The Dojo Foundation All Rights Reserved.
|
3 |
Available via Academic Free License >= 2.1 OR the modified BSD license.
|
4 |
see: http://dojotoolkit.org/license for details
|
5 |
*/
|
6 |
|
7 |
|
8 |
if(!dojo._hasResource["dojox.html.styles"]){ |
9 |
dojo._hasResource["dojox.html.styles"]=true; |
10 |
dojo.provide("dojox.html.styles");
|
11 |
(function(){
|
12 |
var _1={};
|
13 |
var _2={};
|
14 |
var _3=[];
|
15 |
var _4=[];
|
16 |
dojox.html.insertCssRule=function(_5,_6,_7){ |
17 |
var ss=dojox.html.getDynamicStyleSheet(_7);
|
18 |
var _8=_5+" {"+_6+"}"; |
19 |
if(dojo.isIE){
|
20 |
ss.cssText+=_8; |
21 |
}else{
|
22 |
if(ss.sheet){
|
23 |
ss.sheet.insertRule(_8,ss._indicies.length); |
24 |
}else{
|
25 |
ss.appendChild(dojo.doc.createTextNode(_8)); |
26 |
} |
27 |
} |
28 |
ss._indicies.push(_5+" "+_6);
|
29 |
return _5;
|
30 |
}; |
31 |
dojox.html.removeCssRule=function(_9,_a,_b){ |
32 |
var ss;
|
33 |
var _c=-1; |
34 |
for(var nm in _1){ |
35 |
if(_b&&_b!=nm){
|
36 |
continue;
|
37 |
} |
38 |
ss=_1[nm]; |
39 |
for(var i=0;i<ss._indicies.length;i++){ |
40 |
if(_9+" "+_a==ss._indicies[i]){ |
41 |
_c=i; |
42 |
break;
|
43 |
} |
44 |
} |
45 |
if(_c>-1){ |
46 |
break;
|
47 |
} |
48 |
} |
49 |
if(!ss){
|
50 |
return false; |
51 |
} |
52 |
if(_c==-1){ |
53 |
return false; |
54 |
} |
55 |
ss._indicies.splice(_c,1);
|
56 |
if(dojo.isIE){
|
57 |
ss.removeRule(_c); |
58 |
}else{
|
59 |
if(ss.sheet){
|
60 |
ss.sheet.deleteRule(_c); |
61 |
}else{
|
62 |
if(document.styleSheets[0]){ |
63 |
} |
64 |
} |
65 |
} |
66 |
return true; |
67 |
}; |
68 |
dojox.html.getStyleSheet=function(_d){ |
69 |
if(_1[_d||"default"]){ |
70 |
return _1[_d||"default"]; |
71 |
} |
72 |
if(!_d){
|
73 |
return false; |
74 |
} |
75 |
var _e=dojox.html.getStyleSheets();
|
76 |
if(_e[_d]){
|
77 |
return dojox.html.getStyleSheets()[_d];
|
78 |
} |
79 |
for(var nm in _e){ |
80 |
if(_e[nm].href&&_e[nm].href.indexOf(_d)>-1){ |
81 |
return _e[nm];
|
82 |
} |
83 |
} |
84 |
return false; |
85 |
}; |
86 |
dojox.html.getDynamicStyleSheet=function(_f){ |
87 |
if(!_f){
|
88 |
_f="default";
|
89 |
} |
90 |
if(!_1[_f]){
|
91 |
if(dojo.doc.createStyleSheet){
|
92 |
_1[_f]=dojo.doc.createStyleSheet(); |
93 |
_1[_f].title=_f; |
94 |
}else{
|
95 |
_1[_f]=dojo.doc.createElement("style");
|
96 |
_1[_f].setAttribute("type","text/css"); |
97 |
dojo.doc.getElementsByTagName("head")[0].appendChild(_1[_f]); |
98 |
} |
99 |
_1[_f]._indicies=[]; |
100 |
} |
101 |
return _1[_f];
|
102 |
}; |
103 |
dojox.html.enableStyleSheet=function(_10){ |
104 |
var ss=dojox.html.getStyleSheet(_10);
|
105 |
if(ss){
|
106 |
if(ss.sheet){
|
107 |
ss.sheet.disabled=false;
|
108 |
}else{
|
109 |
ss.disabled=false;
|
110 |
} |
111 |
} |
112 |
}; |
113 |
dojox.html.disableStyleSheet=function(_11){ |
114 |
var ss=dojox.html.getStyleSheet(_11);
|
115 |
if(ss){
|
116 |
if(ss.sheet){
|
117 |
ss.sheet.disabled=true;
|
118 |
}else{
|
119 |
ss.disabled=true;
|
120 |
} |
121 |
} |
122 |
}; |
123 |
dojox.html.activeStyleSheet=function(_12){ |
124 |
var _13=dojox.html.getToggledStyleSheets();
|
125 |
if(arguments.length==1){ |
126 |
dojo.forEach(_13,function(s){
|
127 |
s.disabled=(s.title==_12)?false:true; |
128 |
}); |
129 |
}else{
|
130 |
for(var i=0;i<_13.length;i++){ |
131 |
if(_13[i].disabled==false){ |
132 |
return _13[i];
|
133 |
} |
134 |
} |
135 |
} |
136 |
return true; |
137 |
}; |
138 |
dojox.html.getPreferredStyleSheet=function(){ |
139 |
}; |
140 |
dojox.html.getToggledStyleSheets=function(){ |
141 |
if(!_3.length){
|
142 |
var _14=dojox.html.getStyleSheets();
|
143 |
for(var nm in _14){ |
144 |
if(_14[nm].title){
|
145 |
_3.push(_14[nm]); |
146 |
} |
147 |
} |
148 |
} |
149 |
return _3;
|
150 |
}; |
151 |
dojox.html.getStyleSheets=function(){ |
152 |
if(_2.collected){
|
153 |
return _2;
|
154 |
} |
155 |
var _15=dojo.doc.styleSheets;
|
156 |
dojo.forEach(_15,function(n){
|
157 |
var s=(n.sheet)?n.sheet:n;
|
158 |
var _16=s.title||s.href;
|
159 |
if(dojo.isIE){
|
160 |
if(s.cssText.indexOf("#default#VML")==-1){ |
161 |
if(s.href){
|
162 |
_2[_16]=s; |
163 |
}else{
|
164 |
if(s.imports.length){
|
165 |
dojo.forEach(s.imports,function(si){
|
166 |
_2[si.title||si.href]=si; |
167 |
}); |
168 |
}else{
|
169 |
_2[_16]=s; |
170 |
} |
171 |
} |
172 |
} |
173 |
}else{
|
174 |
_2[_16]=s; |
175 |
_2[_16].id=s.ownerNode.id; |
176 |
dojo.forEach(s.cssRules,function(r){
|
177 |
if(r.href){
|
178 |
_2[r.href]=r.styleSheet; |
179 |
_2[r.href].id=s.ownerNode.id; |
180 |
} |
181 |
}); |
182 |
} |
183 |
}); |
184 |
_2.collected=true;
|
185 |
return _2;
|
186 |
}; |
187 |
})(); |
188 |
} |