flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aha...@apache.org
Subject [5/5] git commit: [flex-asjs] [refs/heads/develop] - changes needed to support states in JS
Date Fri, 14 Jun 2013 16:52:59 GMT
changes needed to support states in JS


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

Branch: refs/heads/develop
Commit: 7a18c74adf3df6401a04ce165396554bf3324657
Parents: 6cb30a9
Author: Alex Harui <aharui@apache.org>
Authored: Thu Jun 13 23:21:36 2013 -0700
Committer: Alex Harui <aharui@apache.org>
Committed: Thu Jun 13 23:23:32 2013 -0700

----------------------------------------------------------------------
 frameworks/as/src/FlexJSUIClasses.as            |  1 +
 .../org/apache/flex/core/SimpleStatesImpl.js    | 24 +++++---
 .../FlexJS/src/org/apache/flex/core/UIBase.js   | 19 ++++--
 .../FlexJS/src/org/apache/flex/core/ViewBase.js |  8 +--
 .../org/apache/flex/events/ValueChangeEvent.js  | 65 ++++++++++++++++++++
 .../apache/flex/html/staticControls/Label.js    |  4 +-
 .../apache/flex/html/staticControls/TextArea.js |  6 +-
 7 files changed, 106 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/7a18c74a/frameworks/as/src/FlexJSUIClasses.as
----------------------------------------------------------------------
diff --git a/frameworks/as/src/FlexJSUIClasses.as b/frameworks/as/src/FlexJSUIClasses.as
index 42b2c55..f91ab96 100644
--- a/frameworks/as/src/FlexJSUIClasses.as
+++ b/frameworks/as/src/FlexJSUIClasses.as
@@ -56,6 +56,7 @@ internal class FlexJSUIClasses
 	import org.apache.flex.events.CustomEvent; CustomEvent;
 	import org.apache.flex.events.Event; Event;
 	import org.apache.flex.utils.Timer; Timer;
+    import org.apache.flex.core.SimpleStatesImpl; SimpleStatesImpl;
 }
 
 }

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/7a18c74a/frameworks/js/FlexJS/src/org/apache/flex/core/SimpleStatesImpl.js
----------------------------------------------------------------------
diff --git a/frameworks/js/FlexJS/src/org/apache/flex/core/SimpleStatesImpl.js b/frameworks/js/FlexJS/src/org/apache/flex/core/SimpleStatesImpl.js
index 6fbbd2f..4392257 100644
--- a/frameworks/js/FlexJS/src/org/apache/flex/core/SimpleStatesImpl.js
+++ b/frameworks/js/FlexJS/src/org/apache/flex/core/SimpleStatesImpl.js
@@ -49,12 +49,13 @@ org.apache.flex.core.SimpleStatesImpl.prototype.set_strand =
 /**
  * @protected
  * @this {org.apache.flex.core.SimpleStatesImpl}
+ * @param {Object} event The event.
  */
 org.apache.flex.core.SimpleStatesImpl.prototype.stateChangeHandler =
-    function() {
+    function(event) {
   var s, p;
   var doc = event.target;
-  var arr = doc.states;
+  var arr = doc.get_states();
   for (p in arr)
   {
     s = arr[p];
@@ -83,7 +84,7 @@ org.apache.flex.core.SimpleStatesImpl.prototype.stateChangeHandler =
 org.apache.flex.core.SimpleStatesImpl.prototype.revert = function(s) {
   var p, o;
   var arr = s.overrides;
-  for (var p in arr)
+  for (p in arr)
   {
     o = arr[p];
     if (o.type == 'AddItems')
@@ -93,7 +94,8 @@ org.apache.flex.core.SimpleStatesImpl.prototype.revert = function(s) {
         var item = o.items[q];
         var parent = o.document[o.destination];
         item.removeFromParent(parent);
-        parent.dispatchEvent(new Event('childrenAdded'));
+        parent.dispatchEvent(
+            new org.apache.flex.events.Event('childrenAdded'));
       }
     }
     else if (o.type == 'SetProperty')
@@ -109,17 +111,20 @@ org.apache.flex.core.SimpleStatesImpl.prototype.revert = function(s)
{
  * @param {Object} s The State to apply.
  */
 org.apache.flex.core.SimpleStatesImpl.prototype.apply = function(s) {
+  var o, p;
   var arr = s.overrides;
-  for (var p in arr)
+  for (p in arr)
   {
     o = arr[p];
     if (o.type == 'AddItems')
     {
       if (o.items == null)
       {
-        var di = org.apache.flex.utils.MXMLDataInterpreter;
-        o.items = di.generateMXMLArray(o.document,
-                                        null, o.itemsDescriptor, true);
+        //TODO (aharui).  This array should be deferred
+        //var di = org.apache.flex.utils.MXMLDataInterpreter;
+        //o.items = di.generateMXMLArray(o.document,
+        //                                null, o.itemsDescriptor, true);
+        o.items = o.itemsDescriptor;
       }
       for (var q in o.items)
       {
@@ -137,7 +142,8 @@ org.apache.flex.core.SimpleStatesImpl.prototype.apply = function(s) {
         {
             item.addToParent(parent);
         }
-        parent.dispatchEvent(new Event('childrenAdded'));
+        parent.dispatchEvent(
+            new org.apache.flex.events.Event('childrenAdded'));
       }
     }
     else if (o.type == 'SetProperty')

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/7a18c74a/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 ca2a6eb..a88f1fe 100644
--- a/frameworks/js/FlexJS/src/org/apache/flex/core/UIBase.js
+++ b/frameworks/js/FlexJS/src/org/apache/flex/core/UIBase.js
@@ -56,7 +56,7 @@ org.apache.flex.core.UIBase.prototype.internalAddChild = function(child)
{
  */
 org.apache.flex.core.UIBase.prototype.internalAddChildAt =
     function(child, index) {
-  this.element.insertBefore(child, internalGetChildAt(index));
+  this.element.insertBefore(child, this.internalGetChildAt(index));
 };
 
 /**
@@ -75,7 +75,7 @@ org.apache.flex.core.UIBase.prototype.internalRemoveChild =
  */
 org.apache.flex.core.UIBase.prototype.internalGetChildAt =
     function(index) {
-  return this.element.childNodex[index];
+  return this.element.childNodes[index];
 };
 
 /**
@@ -98,7 +98,11 @@ org.apache.flex.core.UIBase.prototype.addToParentAt = function(p, index)
{
   if (this.element == null)
     this.element = document.createElement('div');
 
-  p.internalAddChildAt(this.element);
+  var children = p.internalChildren();
+  if (index >= children.length)
+    p.internalAddChild(this.element);
+  else
+    p.internalAddChildAt(this.element, index);
 };
 
 /**
@@ -107,7 +111,14 @@ org.apache.flex.core.UIBase.prototype.addToParentAt = function(p, index)
{
  * @return {number} The index in parent.
  */
 org.apache.flex.core.UIBase.prototype.getIndexInParent = function(p) {
-  return p.internalGetChildIndex(this.element);
+  var children = p.internalChildren();
+  var n = children.length;
+  for (i = 0; i < n; i++)
+  {
+     if (children[i] == this.element)
+        return i;
+  }
+  return -1;
 };
 
 /**

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/7a18c74a/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 9c22630..29af15c 100644
--- a/frameworks/js/FlexJS/src/org/apache/flex/core/ViewBase.js
+++ b/frameworks/js/FlexJS/src/org/apache/flex/core/ViewBase.js
@@ -16,8 +16,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.events.ValueChangeEvent');
 goog.require('org.apache.flex.utils.MXMLDataInterpreter');
 
 
@@ -141,7 +141,7 @@ org.apache.flex.core.ViewBase.prototype.hasState = function(state) {
  * @return {string} The name of the current state.
  */
 org.apache.flex.core.ViewBase.prototype.get_currentState = function() {
-    return this.states_;
+    return this.currentState_;
 };
 
 /**
@@ -151,8 +151,8 @@ org.apache.flex.core.ViewBase.prototype.get_currentState = function()
{
  */
 org.apache.flex.core.ViewBase.prototype.set_currentState = function(value) {
     var event = new org.apache.flex.events.ValueChangeEvent(
-            'currentStateChanged', false, false, this._currentState, value);
-    this._currentState = value;
+            'currentStateChanged', this.currentState_, value);
+    this.currentState_ = value;
     this.dispatchEvent(event);
 };
 

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/7a18c74a/frameworks/js/FlexJS/src/org/apache/flex/events/ValueChangeEvent.js
----------------------------------------------------------------------
diff --git a/frameworks/js/FlexJS/src/org/apache/flex/events/ValueChangeEvent.js b/frameworks/js/FlexJS/src/org/apache/flex/events/ValueChangeEvent.js
new file mode 100644
index 0000000..45240b6
--- /dev/null
+++ b/frameworks/js/FlexJS/src/org/apache/flex/events/ValueChangeEvent.js
@@ -0,0 +1,65 @@
+/**
+ * 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.events.ValueChangeEvent');
+
+goog.require('goog.events.Event');
+
+
+
+/**
+ * @constructor
+ * @extends {goog.events.Event}
+ * @param {string} type The event type.
+ * @param {string} ov The old value.
+ * @param {string} nv The new value.
+ */
+org.apache.flex.events.ValueChangeEvent = function(type, ov, nv) {
+  goog.base(this);
+
+  this.type = type;
+  this.oldValue = ov;
+  this.newValue = nv;
+};
+goog.inherits(org.apache.flex.events.ValueChangeEvent,
+    goog.events.Event);
+
+
+/**
+ * @expose
+ * @this {org.apache.flex.events.ValueChangeEvent}
+ * @param {string} type The event type.
+ */
+org.apache.flex.events.ValueChangeEvent.prototype.init = function(type) {
+  this.type = type;
+};
+
+
+/**
+ * @expose
+ * @type {string} type The event type.
+ */
+org.apache.flex.events.ValueChangeEvent.prototype.type = null;
+
+/**
+ * @expose
+ * @type {Object} oldValue The old value.
+ */
+org.apache.flex.events.ValueChangeEvent.prototype.oldValue = null;
+
+/**
+ * @expose
+ * @type {string} newValue The new value.
+ */
+org.apache.flex.events.ValueChangeEvent.prototype.newValue = null;

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/7a18c74a/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/Label.js
----------------------------------------------------------------------
diff --git a/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/Label.js b/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/Label.js
index c9fb63f..404f92a 100644
--- a/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/Label.js
+++ b/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/Label.js
@@ -24,8 +24,9 @@ goog.require('org.apache.flex.core.UIBase');
  */
 org.apache.flex.html.staticControls.Label = function() {
   goog.base(this);
-  
+
   this.element = document.createElement('div');
+  this.positioner = this.element;
 };
 goog.inherits(org.apache.flex.html.staticControls.Label,
     org.apache.flex.core.UIBase);
@@ -39,7 +40,6 @@ goog.inherits(org.apache.flex.html.staticControls.Label,
 org.apache.flex.html.staticControls.Label.prototype.addToParent = function(p) {
   goog.base(this, 'addToParent', p);
 
-  this.positioner = this.element;
 };
 
 /**

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/7a18c74a/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/TextArea.js
----------------------------------------------------------------------
diff --git a/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/TextArea.js b/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/TextArea.js
index 1ec8cb5..8b733b4 100644
--- a/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/TextArea.js
+++ b/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/TextArea.js
@@ -24,6 +24,10 @@ goog.require('org.apache.flex.core.UIBase');
  */
 org.apache.flex.html.staticControls.TextArea = function() {
   goog.base(this);
+
+  this.element = document.createElement('textarea');
+  this.positioner = this.element;
+
 };
 goog.inherits(org.apache.flex.html.staticControls.TextArea,
     org.apache.flex.core.UIBase);
@@ -36,11 +40,9 @@ goog.inherits(org.apache.flex.html.staticControls.TextArea,
  */
 org.apache.flex.html.staticControls.TextArea.prototype.addToParent =
     function(p) {
-  this.element = document.createElement('textarea');
 
   p.internalAddChild(this.element);
 
-  this.positioner = this.element;
   this.element.flexjs_wrapper = this;
 };
 


Mime
View raw message