123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- /*
- * Ext JS Library 2.0 Copyright(c) 2006-2007, Ext JS, LLC. licensing@extjs.com
- *
- * http://extjs.com/license
- */
- Ext.util.CSS = function() {
- var D = null;
- var C = document;
- var B = /(-[a-z])/gi;
- var A = function(E, F) {
- return F.charAt(1).toUpperCase()
- };
- return {
- createStyleSheet : function(G, J) {
- var F;
- var E = C.getElementsByTagName("head")[0];
- var I = C.createElement("style");
- I.setAttribute("type", "text/css");
- if (J) {
- I.setAttribute("id", J)
- }
- if (Ext.isIE) {
- E.appendChild(I);
- F = I.styleSheet;
- F.cssText = G
- } else {
- try {
- I.appendChild(C.createTextNode(G))
- } catch (H) {
- I.cssText = G
- }
- E.appendChild(I);
- F = I.styleSheet
- ? I.styleSheet
- : (I.sheet || C.styleSheets[C.styleSheets.length - 1])
- }
- this.cacheStyleSheet(F);
- return F
- },
- removeStyleSheet : function(F) {
- var E = C.getElementById(F);
- if (E) {
- E.parentNode.removeChild(E)
- }
- },
- swapStyleSheet : function(G, E) {
- this.removeStyleSheet(G);
- var F = C.createElement("link");
- F.setAttribute("rel", "stylesheet");
- F.setAttribute("type", "text/css");
- F.setAttribute("id", G);
- F.setAttribute("href", E);
- C.getElementsByTagName("head")[0].appendChild(F)
- },
- refreshCache : function() {
- return this.getRules(true)
- },
- cacheStyleSheet : function(F) {
- if (!D) {
- D = {}
- }
- try {
- var H = F.cssRules || F.rules;
- for (var E = H.length - 1; E >= 0; --E) {
- D[H[E].selectorText] = H[E]
- }
- } catch (G) {
- }
- },
- getRules : function(F) {
- if (D == null || F) {
- D = {};
- var H = C.styleSheets;
- for (var G = 0, E = H.length; G < E; G++) {
- try {
- this.cacheStyleSheet(H[G])
- } catch (I) {
- }
- }
- }
- return D
- },
- getRule : function(E, G) {
- var F = this.getRules(G);
- if (!(E instanceof Array)) {
- return F[E]
- }
- for (var H = 0; H < E.length; H++) {
- if (F[E[H]]) {
- return F[E[H]]
- }
- }
- return null
- },
- updateRule : function(E, H, G) {
- if (!(E instanceof Array)) {
- var I = this.getRule(E);
- if (I) {
- I.style[H.replace(B, A)] = G;
- return true
- }
- } else {
- for (var F = 0; F < E.length; F++) {
- if (this.updateRule(E[F], H, G)) {
- return true
- }
- }
- }
- return false
- }
- }
- }();
|