You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by ah...@apache.org on 2013/10/21 07:06:45 UTC

[1/3] git commit: [flex-asjs] [refs/heads/develop] - add a Button.js so class heirarchy mirrors AS so CSS lookups work.

Updated Branches:
  refs/heads/develop 17947a07f -> 801862b9c


add a Button.js so class heirarchy mirrors AS so CSS lookups work.


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

Branch: refs/heads/develop
Commit: 82197432fb99c4b0eaa14fdf8c62e398d87d6117
Parents: 17947a0
Author: Alex Harui <ah...@apache.org>
Authored: Sun Oct 20 20:40:52 2013 -0700
Committer: Alex Harui <ah...@apache.org>
Committed: Sun Oct 20 20:40:52 2013 -0700

----------------------------------------------------------------------
 .../apache/flex/html/staticControls/Button.js   | 48 ++++++++++++++++++++
 .../flex/html/staticControls/TextButton.js      | 18 +-------
 2 files changed, 50 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/82197432/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/Button.js
----------------------------------------------------------------------
diff --git a/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/Button.js b/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/Button.js
new file mode 100644
index 0000000..43527f5
--- /dev/null
+++ b/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/Button.js
@@ -0,0 +1,48 @@
+/**
+ * Licensed under the Apache License, Version 2.0 (the 'License');
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an 'AS IS' BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+goog.provide('org.apache.flex.html.staticControls.Button');
+
+goog.require('org.apache.flex.core.UIBase');
+
+
+
+/**
+ * @constructor
+ * @extends {org.apache.flex.core.UIBase}
+ */
+org.apache.flex.html.staticControls.Button = function() {
+  goog.base(this);
+};
+goog.inherits(org.apache.flex.html.staticControls.Button,
+    org.apache.flex.core.UIBase);
+
+
+/**
+ * @override
+ * @this {org.apache.flex.html.staticControls.Button}
+ */
+org.apache.flex.html.staticControls.Button.prototype.createElement =
+    function() {
+  this.element = document.createElement('button');
+  this.element.setAttribute('type', 'button');
+
+  this.positioner = this.element;
+  this.element.flexjs_wrapper = this;
+  
+  var impl = org.apache.flex.core.ValuesManager.valuesImpl.
+                getValue(this, "iStatesImpl");
+
+};
+

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/82197432/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/TextButton.js
----------------------------------------------------------------------
diff --git a/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/TextButton.js b/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/TextButton.js
index c54d5f4..54775c6 100644
--- a/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/TextButton.js
+++ b/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/TextButton.js
@@ -14,7 +14,7 @@
 
 goog.provide('org.apache.flex.html.staticControls.TextButton');
 
-goog.require('org.apache.flex.core.UIBase');
+goog.require('org.apache.flex.html.staticControls.Button');
 
 
 
@@ -26,21 +26,7 @@ org.apache.flex.html.staticControls.TextButton = function() {
   goog.base(this);
 };
 goog.inherits(org.apache.flex.html.staticControls.TextButton,
-    org.apache.flex.core.UIBase);
-
-
-/**
- * @override
- * @this {org.apache.flex.html.staticControls.TextButton}
- */
-org.apache.flex.html.staticControls.TextButton.prototype.createElement =
-    function() {
-  this.element = document.createElement('button');
-  this.element.setAttribute('type', 'button');
-
-  this.positioner = this.element;
-  this.element.flexjs_wrapper = this;
-};
+    org.apache.flex.html.staticControls.Button);
 
 
 /**


[3/3] git commit: [flex-asjs] [refs/heads/develop] - JS-side custom CSS

Posted by ah...@apache.org.
JS-side custom CSS


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

Branch: refs/heads/develop
Commit: 801862b9c696770b58c0bc182379445908e84a70
Parents: 824b964
Author: Alex Harui <ah...@apache.org>
Authored: Sun Oct 20 20:48:59 2013 -0700
Committer: Alex Harui <ah...@apache.org>
Committed: Sun Oct 20 20:48:59 2013 -0700

----------------------------------------------------------------------
 frameworks/as/defaults.css                      |   6 +-
 .../org/apache/flex/core/SimpleCSSValuesImpl.as |   2 +-
 .../src/org/apache/flex/core/Application.js     |   4 +
 .../org/apache/flex/core/SimpleCSSValuesImpl.js | 173 +++++++++++++++++++
 .../FlexJS/src/org/apache/flex/core/ViewBase.js |   7 +-
 5 files changed, 185 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/801862b9/frameworks/as/defaults.css
----------------------------------------------------------------------
diff --git a/frameworks/as/defaults.css b/frameworks/as/defaults.css
index 23a9bf5..74f0a38 100644
--- a/frameworks/as/defaults.css
+++ b/frameworks/as/defaults.css
@@ -50,15 +50,15 @@ Button:active
 	padding: 4px;
 }
 
-@media -flex-flash
-{
-
 /* Global style declaration */
 global
 {
     IStatesImpl: ClassReference("org.apache.flex.core.SimpleStatesImpl");
 }
 
+@media -flex-flash
+{
+
 Alert
 {
     IBeadModel: ClassReference("org.apache.flex.html.staticControls.beads.models.AlertModel");

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/801862b9/frameworks/as/src/org/apache/flex/core/SimpleCSSValuesImpl.as
----------------------------------------------------------------------
diff --git a/frameworks/as/src/org/apache/flex/core/SimpleCSSValuesImpl.as b/frameworks/as/src/org/apache/flex/core/SimpleCSSValuesImpl.as
index 0993d55..fdaec8f 100644
--- a/frameworks/as/src/org/apache/flex/core/SimpleCSSValuesImpl.as
+++ b/frameworks/as/src/org/apache/flex/core/SimpleCSSValuesImpl.as
@@ -175,7 +175,7 @@ package org.apache.flex.core
             {
                 valueName = valueName.substr(0, c) +
                     valueName.charAt(c + 1).toUpperCase() +
-                    valueName..substr(c + 2);
+                    valueName.substr(c + 2);
                 c = valueName.indexOf("-");
             }
 

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/801862b9/frameworks/js/FlexJS/src/org/apache/flex/core/Application.js
----------------------------------------------------------------------
diff --git a/frameworks/js/FlexJS/src/org/apache/flex/core/Application.js b/frameworks/js/FlexJS/src/org/apache/flex/core/Application.js
index 7948590..fe5a029 100644
--- a/frameworks/js/FlexJS/src/org/apache/flex/core/Application.js
+++ b/frameworks/js/FlexJS/src/org/apache/flex/core/Application.js
@@ -15,6 +15,7 @@
 goog.provide('org.apache.flex.core.Application');
 
 goog.require('org.apache.flex.core.HTMLElementWrapper');
+goog.require('org.apache.flex.core.ValuesManager');
 goog.require('org.apache.flex.utils.MXMLDataInterpreter');
 
 
@@ -68,6 +69,9 @@ org.apache.flex.core.Application.prototype.start = function() {
   org.apache.flex.utils.MXMLDataInterpreter.generateMXMLProperties(this,
       this.get_MXMLProperties());
 
+  org.apache.flex.core.ValuesManager.valuesImpl = this.valuesImpl;
+  this.valuesImpl.init(this);
+
   this.dispatchEvent('initialize');
 
   this.initialView.applicationModel = this.model;

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/801862b9/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 a54a50f..ed5b2a4 100644
--- a/frameworks/js/FlexJS/src/org/apache/flex/core/SimpleCSSValuesImpl.js
+++ b/frameworks/js/FlexJS/src/org/apache/flex/core/SimpleCSSValuesImpl.js
@@ -21,3 +21,176 @@ goog.provide('org.apache.flex.core.SimpleCSSValuesImpl');
  */
 org.apache.flex.core.SimpleCSSValuesImpl = function() {
 };
+
+/**
+ * @this {org.apache.flex.core.SimpleCSSValuesImpl}
+ * @param {Object} thisObject The object to fetch a value for.
+ * @param {String} valueName The name of the value to fetch.
+ * @param {String} state The psuedo-state if any for.
+ * @param {Object} attrs The object with name value pairs that
+ *                       might make a difference.
+ * @return {Object} The value.
+ */
+org.apache.flex.core.SimpleCSSValuesImpl.prototype.getValue =
+    function(thisObject, valueName, state, attrs) {
+  var c = valueName.indexOf('-');
+  while (c != -1)
+  {
+    valueName = valueName.substr(0, c) +
+    valueName.charAt(c + 1).toUpperCase() +
+    valueName.substr(c + 2);
+    c = valueName.indexOf('-');
+  }
+
+  var values = this.values;
+  var value;
+  var o;
+  var className;
+  var selectorName;
+
+  if (thisObject.hasOwnProperty('className'))
+  {
+    className = thisObject.className;
+    if (state)
+    {
+        selectorName = className + ':' + state;
+        o = values['.' + selectorName];
+        if (o)
+        {
+            value = o[valueName];
+            if (value !== undefined)
+                return value;
+        }
+    }
+
+    o = values['.' + className];
+    if (o)
+    {
+        value = o[valueName];
+        if (value !== undefined)
+            return value;
+    }
+  }
+
+  className = this.getQualifiedClassName(thisObject);
+  while (className != 'Object')
+  {
+    if (state)
+    {
+        selectorName = className + ':' + state;
+        o = values[selectorName];
+        if (o)
+        {
+            value = o[valueName];
+            if (value !== undefined)
+                return value;
+        }
+    }
+
+    o = values[className];
+    if (o)
+    {
+        value = o[valueName];
+        if (value !== undefined)
+            return value;
+    }
+    thisObject = thisObject.__proto__;
+    if (thisObject.__proto__ == null)
+        break;
+    className = this.getQualifiedClassName(thisObject);
+  }
+  o = values['global'];
+  if (o != undefined)
+  {
+    value = o[valueName];
+    if (value !== undefined)
+       return value;
+  }
+  o = values['*'];
+  return o[valueName];
+};
+
+/**
+ * @this {org.apache.flex.core.SimpleCSSValuesImpl}
+ * @param {Object} thisObject The object to get a name for.
+ * @return {string} The CSS selector name or null.
+ */
+org.apache.flex.core.SimpleCSSValuesImpl.prototype.getQualifiedClassName =
+    function(thisObject) {
+    // relies on the values parser to populate the package tree
+    var proto = thisObject.__proto__;
+    if (proto.hasOwnProperty('__css__package_parent'))
+    {
+        var s = proto.__css__name;
+        while (true)
+        {
+            proto = proto.__css__package_parent;
+            if (proto == window || proto == undefined)
+                return s;
+            s = proto.__css__name + '.' + s;
+        }
+    }
+    return null;
+};
+
+/**
+ * @this {org.apache.flex.core.SimpleCSSValuesImpl}
+ * @param {Object} mainclass The main class for the application.
+ */
+org.apache.flex.core.SimpleCSSValuesImpl.prototype.init = function(mainclass) {
+    var cssData = mainclass.cssData;
+    var values = this.values;
+    if (values == null)
+        values = {};
+        
+    var n = cssData.length;
+    var i = 0;
+    while (i < n)
+    {
+        var numMQ = cssData[i++];
+        if (numMQ > 0)
+        {
+            // skip MediaQuery tests for now
+            i += numMQ;
+        }
+        var numSel = cssData[i++];
+        var props = {};
+        for (var j = 0; j < numSel; j++)
+        {
+            var selName = cssData[i++];
+            if (selName.indexOf('.') != 0 &&
+                selName != '*' && selName != 'global')
+            {
+                // should be a type selector
+                var parts = selName.split('.');
+                var numParts = parts.length;
+                var part = window;
+                for (var k = 0; k < numParts; k++)
+                {
+                    var partName = parts[k];
+                    var subpart = part[partName];
+                    if (subpart == undefined)
+                        break;
+                    // assume last part is ctor func
+                    if (k == numParts - 1)
+                        subpart = subpart.prototype;
+                    subpart.__css__package_parent = part;
+                    subpart.__css__name = partName;
+                    part = subpart;
+                }
+            }
+            if (values[selName])
+                props = values[selName];
+            values[selName] = props;
+        }
+        var numProps = cssData[i++];
+        for (j = 0; j < numProps; j++)
+        {
+            var propName = cssData[i++];
+            var propValue = cssData[i++];
+            props[propName] = propValue;
+        }
+    }
+    this.values = values;
+};
+

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/801862b9/frameworks/js/FlexJS/src/org/apache/flex/core/ViewBase.js
----------------------------------------------------------------------
diff --git a/frameworks/js/FlexJS/src/org/apache/flex/core/ViewBase.js b/frameworks/js/FlexJS/src/org/apache/flex/core/ViewBase.js
index c51c2a9..e65ed8e 100644
--- a/frameworks/js/FlexJS/src/org/apache/flex/core/ViewBase.js
+++ b/frameworks/js/FlexJS/src/org/apache/flex/core/ViewBase.js
@@ -14,9 +14,8 @@
 
 goog.provide('org.apache.flex.core.ViewBase');
 
-// TODO: (aharui) bring this in via CSS
-goog.require('org.apache.flex.core.SimpleStatesImpl');
 goog.require('org.apache.flex.core.UIBase');
+goog.require('org.apache.flex.core.ValuesManager');
 goog.require('org.apache.flex.events.ValueChangeEvent');
 goog.require('org.apache.flex.utils.MXMLDataInterpreter');
 
@@ -113,8 +112,10 @@ org.apache.flex.core.ViewBase.prototype.get_states = function() {
 org.apache.flex.core.ViewBase.prototype.set_states = function(value) {
     this.states_ = value;
 
+    var impl = org.apache.flex.core.ValuesManager.valuesImpl.
+                getValue(this, "iStatesImpl");
     // TODO: (aharui) check if bead already exists
-    this.addBead(new org.apache.flex.core.SimpleStatesImpl());
+    this.addBead(new impl());
 };
 
 /**


[2/3] git commit: [flex-asjs] [refs/heads/develop] - use children array instead of getChildAt

Posted by ah...@apache.org.
use children array instead of getChildAt


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

Branch: refs/heads/develop
Commit: 824b9640f3450f23218b142f15db24894c73da61
Parents: 8219743
Author: Alex Harui <ah...@apache.org>
Authored: Sun Oct 20 20:42:12 2013 -0700
Committer: Alex Harui <ah...@apache.org>
Committed: Sun Oct 20 20:42:12 2013 -0700

----------------------------------------------------------------------
 frameworks/js/FlexJS/src/org/apache/flex/core/UIBase.js | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/824b9640/frameworks/js/FlexJS/src/org/apache/flex/core/UIBase.js
----------------------------------------------------------------------
diff --git a/frameworks/js/FlexJS/src/org/apache/flex/core/UIBase.js b/frameworks/js/FlexJS/src/org/apache/flex/core/UIBase.js
index 657a7b6..c9608f8 100644
--- a/frameworks/js/FlexJS/src/org/apache/flex/core/UIBase.js
+++ b/frameworks/js/FlexJS/src/org/apache/flex/core/UIBase.js
@@ -84,7 +84,7 @@ org.apache.flex.core.UIBase.prototype.addElementAt = function(c, index) {
   else
   {
     this.element.insertBefore(c.element,
-            this.getChildAt(index));
+            children[index]);
     c.addedToParent();
   }
 };