incubator-xap-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmarga...@apache.org
Subject svn commit: r533188 - /incubator/xap/trunk/codebase/src/xap/util/CssUtils.js
Date Fri, 27 Apr 2007 18:35:10 GMT
Author: jmargaris
Date: Fri Apr 27 11:35:09 2007
New Revision: 533188

URL: http://svn.apache.org/viewvc?view=rev&rev=533188
Log:
For Michael Mikhaylov: http://issues.apache.org/jira/browse/XAP-396

Modified:
    incubator/xap/trunk/codebase/src/xap/util/CssUtils.js

Modified: incubator/xap/trunk/codebase/src/xap/util/CssUtils.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/xap/util/CssUtils.js?view=diff&rev=533188&r1=533187&r2=533188
==============================================================================
--- incubator/xap/trunk/codebase/src/xap/util/CssUtils.js (original)
+++ incubator/xap/trunk/codebase/src/xap/util/CssUtils.js Fri Apr 27 11:35:09 2007
@@ -32,13 +32,23 @@
  * @return CSS Rule object or null
  *
  */
-xap.util.CssUtils.getCSSRule = function (ruleName) {
+xap.util.CssUtils.getCSSRule = function (selector) {
+	sel = selector.toLowerCase();
 	if (document.styleSheets) {
 	 	 for (var i = 0; i < document.styleSheets.length; i++) {
-	 	 	var currentStyleSheet=document.styleSheets[i];
+	 	 	var currentStyleSheet = document.styleSheets[i];
 	 	 	if( ! currentStyleSheet) { continue; }
-			var rule = xap.util.CssUtils.getCSSRuleFromStyleSheet(ruleName, currentStyleSheet);
-			if(rule && rule.selectorText == ruleName) { return rule; }
+			var rule = xap.util.CssUtils.getCSSRuleFromStyleSheet(sel, currentStyleSheet);
+			if(rule !== null) { return rule; }
+			// check imports (IE only)
+			if(currentStyleSheet.imports && currentStyleSheet.imports.length > 0) {
+		 	  for (var j = 0; j < currentStyleSheet.imports.length; j++) {
+		 	 	var importedStyleSheet = currentStyleSheet.imports[j];
+	 	 		if( ! importedStyleSheet) { continue; }
+				rule = xap.util.CssUtils.getCSSRuleFromStyleSheet(sel, importedStyleSheet);
+				if(rule !== null) { return rule; }
+			  }
+			}
 		}
 	}
 	return null;
@@ -51,16 +61,18 @@
  * @return CSS Rule object or null
  *
  */
-xap.util.CssUtils.getCSSRuleFromStyleSheet = function (ruleName, styleSheet) {
+xap.util.CssUtils.getCSSRuleFromStyleSheet = function (selector, styleSheet) {
 	if(styleSheet) {
- 	 	var styleSheetRules = styleSheet.cssRules ? styleSheet.cssRules : styleSheet.rules;
+ 	 	var styleSheetRules = styleSheet.cssRules ? styleSheet.cssRules : styleSheet.rules ;
  	 	if(!styleSheetRules) { return null; }
 		for(var j = 0; j < styleSheetRules.length; j++) {
 			var rule = styleSheetRules[j];
-			if(rule.type == 3) { rule = xap.util.CssUtils.getCSSRuleFromStyleSheet(ruleName, rule.styleSheet);
}
-			if(rule && rule.selectorText == ruleName) {
+			// check imports (FF & W3C DOM)
+			if(rule.type == 3) { rule = xap.util.CssUtils.getCSSRuleFromStyleSheet(selector, rule.styleSheet);
}
+			if(rule && rule.selectorText.toLowerCase() == selector) {
 				return rule;
 			}
 		}
-	} 	return null;
+	} 	
+	return null;
 };



Mime
View raw message