flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aha...@apache.org
Subject [5/6] git commit: [flex-asjs] [refs/heads/develop] - fix style handling
Date Wed, 17 Dec 2014 00:08:07 GMT
fix style handling


Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/6df49095
Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/6df49095
Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/6df49095

Branch: refs/heads/develop
Commit: 6df490955f5db4e911d56f893c0d6af9a02a347d
Parents: 2523dd9
Author: Alex Harui <aharui@apache.org>
Authored: Tue Dec 16 15:46:51 2014 -0800
Committer: Alex Harui <aharui@apache.org>
Committed: Tue Dec 16 16:07:56 2014 -0800

----------------------------------------------------------------------
 .../org/apache/flex/core/SimpleCSSValuesImpl.js | 56 +++++++++++---------
 1 file changed, 32 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/6df49095/frameworks/js/FlexJS/src/org/apache/flex/core/SimpleCSSValuesImpl.js
----------------------------------------------------------------------
diff --git a/frameworks/js/FlexJS/src/org/apache/flex/core/SimpleCSSValuesImpl.js b/frameworks/js/FlexJS/src/org/apache/flex/core/SimpleCSSValuesImpl.js
index 8fa8079..e8ea5c8 100644
--- a/frameworks/js/FlexJS/src/org/apache/flex/core/SimpleCSSValuesImpl.js
+++ b/frameworks/js/FlexJS/src/org/apache/flex/core/SimpleCSSValuesImpl.js
@@ -253,8 +253,11 @@ org.apache.flex.core.SimpleCSSValuesImpl.prototype.parseStyles = function(styles
       obj[pieces[0]] = false;
     else {
       var n = Number(value);
-      if (isNaN(n))
+      if (isNaN(n)) {
+        if (value.indexOf("'") == 0)
+          value = value.substring(1, value.length - 1);
         obj[pieces[0]] = value;
+	  }
       else
         obj[pieces[0]] = n;
     }
@@ -266,14 +269,23 @@ org.apache.flex.core.SimpleCSSValuesImpl.prototype.parseStyles = function(styles
 /**
  * The styles that apply to each UI widget
  */
-org.apache.flex.core.SimpleCSSValuesImpl.perInstanceStyles =
-  ['backgroundColor',
-   'backgroundImage',
-   'color',
-   'fontFamily',
-   'fontWeight',
-   'fontSize',
-   'fontStyle'];
+org.apache.flex.core.SimpleCSSValuesImpl.perInstanceStyles = {
+   backgroundColor : 1,
+   backgroundImage : 1,
+   color : 1,
+   fontFamily : 1,
+   fontWeight : 1,
+   fontSize : 1,
+   fontStyle : 1
+};
+
+/**
+ * The styles that use color format #RRGGBB
+ */
+org.apache.flex.core.SimpleCSSValuesImpl.colorStyles = {
+   backgroundColor : 1,
+   color : 1
+};
 
 
 /**
@@ -283,20 +295,16 @@ org.apache.flex.core.SimpleCSSValuesImpl.perInstanceStyles =
 org.apache.flex.core.SimpleCSSValuesImpl.prototype.applyStyles =
     function(thisObject, styles) {
   var styleList = org.apache.flex.core.SimpleCSSValuesImpl.perInstanceStyles;
-  var n = styleList.length;
-  for (var i = 0; i < n; i++) {
-    this.applyStyle(thisObject, styleList[i]);
+  var colorStyles = org.apache.flex.core.SimpleCSSValuesImpl.colorStyles;
+  for (var p in styles) {
+    //if (styleList[p])
+    var value = styles[p];
+    if (typeof(value) == "number") {
+      if (colorStyles[p])
+        value = "#" + value.toString(16);
+      else
+        value = value.toString() + "px";
+	}
+    thisObject.element.style[p] = value;
   }
 };
-
-
-/**
- * @param {Object} thisObject The object to apply styles to;
- * @param {string} style The style name.
- */
-org.apache.flex.core.SimpleCSSValuesImpl.prototype.applyStyle =
-    function(thisObject, style) {
-  var value = this.getValue(thisObject, style);
-  if (value !== undefined)
-    thisObject.element.style[style] = value;
-};
\ No newline at end of file


Mime
View raw message