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/06/14 18:52:55 UTC
[1/5] git commit: [flex-asjs] [refs/heads/develop] - handle null to
prevent RTE
Updated Branches:
refs/heads/develop c557d7ab9 -> 7a18c74ad
handle null to prevent RTE
Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/ca805a0b
Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/ca805a0b
Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/ca805a0b
Branch: refs/heads/develop
Commit: ca805a0b6c6223368926e7b332ad971cf936a2b7
Parents: fe9a9ac
Author: Alex Harui <ah...@apache.org>
Authored: Tue Jun 11 14:33:42 2013 -0700
Committer: Alex Harui <ah...@apache.org>
Committed: Thu Jun 13 23:23:21 2013 -0700
----------------------------------------------------------------------
.../org/apache/flex/html/staticControls/beads/TextFieldBeadBase.as | 2 ++
1 file changed, 2 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/ca805a0b/frameworks/as/src/org/apache/flex/html/staticControls/beads/TextFieldBeadBase.as
----------------------------------------------------------------------
diff --git a/frameworks/as/src/org/apache/flex/html/staticControls/beads/TextFieldBeadBase.as b/frameworks/as/src/org/apache/flex/html/staticControls/beads/TextFieldBeadBase.as
index b9a2ebf..a746745 100644
--- a/frameworks/as/src/org/apache/flex/html/staticControls/beads/TextFieldBeadBase.as
+++ b/frameworks/as/src/org/apache/flex/html/staticControls/beads/TextFieldBeadBase.as
@@ -78,6 +78,8 @@ package org.apache.flex.html.staticControls.beads
}
public function set text(value:String):void
{
+ if (value == null)
+ value == "";
_textField.text = value;
}
[3/5] git commit: [flex-asjs] [refs/heads/develop] - initial JS
version of MXML view states
Posted by ah...@apache.org.
initial JS version of MXML view states
Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/ff99ba71
Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/ff99ba71
Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/ff99ba71
Branch: refs/heads/develop
Commit: ff99ba71878fe710a6a0cf151457e88e2bfa5c11
Parents: ca805a0
Author: Alex Harui <ah...@apache.org>
Authored: Tue Jun 11 14:34:38 2013 -0700
Committer: Alex Harui <ah...@apache.org>
Committed: Thu Jun 13 23:23:26 2013 -0700
----------------------------------------------------------------------
frameworks/js/FlexJS/src/mx/states/AddItems.js | 78 ++++++++++
.../js/FlexJS/src/mx/states/SetProperty.js | 66 ++++++++
frameworks/js/FlexJS/src/mx/states/State.js | 34 +++++
.../org/apache/flex/core/SimpleStatesImpl.js | 149 +++++++++++++++++++
.../FlexJS/src/org/apache/flex/core/UIBase.js | 61 +++++++-
.../FlexJS/src/org/apache/flex/core/ViewBase.js | 101 ++++++++++++-
.../apache/flex/utils/MXMLDataInterpreter.js | 2 +-
7 files changed, 488 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/ff99ba71/frameworks/js/FlexJS/src/mx/states/AddItems.js
----------------------------------------------------------------------
diff --git a/frameworks/js/FlexJS/src/mx/states/AddItems.js b/frameworks/js/FlexJS/src/mx/states/AddItems.js
new file mode 100644
index 0000000..6dc5a6d
--- /dev/null
+++ b/frameworks/js/FlexJS/src/mx/states/AddItems.js
@@ -0,0 +1,78 @@
+/**
+ * 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('mx.states.AddItems');
+
+
+/**
+ * @constructor
+ */
+mx.states.AddItems = function() {
+};
+
+/**
+ * @this {mx.states.AddItems}
+ * @param {Object} document The MXML object.
+ */
+mx.states.AddItems.prototype.setDocument = function(document) {
+ this.document = document;
+};
+
+/**
+ * @type {string} document The type of override.
+ */
+mx.states.AddItems.prototype.type = 'AddItems';
+
+/**
+ * @expose
+ * @type {Object} document The MXML object.
+ */
+mx.states.AddItems.prototype.document = null;
+
+/**
+ * @expose
+ * @type {Array} items The array of items to add.
+ */
+mx.states.AddItems.prototype.items = null;
+
+/**
+ * @expose
+ * @type {Array} itemsDescriptor The descriptors for items.
+ */
+mx.states.AddItems.prototype.itemsDescriptor = null;
+
+/**
+ * @expose
+ * @type {string} destination The id of the parent.
+ */
+mx.states.AddItems.prototype.destination = null;
+
+/**
+ * @expose
+ * @type {string} propertyName The child property name (e.g. mxmlContent).
+ */
+mx.states.AddItems.prototype.propertyName = null;
+
+/**
+ * @expose
+ * @type {string} position Where the item goes relative to relativeTo.
+ */
+mx.states.AddItems.prototype.position = null;
+
+/**
+ * @expose
+ * @type {string} relativeTo The id of the child where the item goes.
+ */
+mx.states.AddItems.prototype.relativeTo = null;
+
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/ff99ba71/frameworks/js/FlexJS/src/mx/states/SetProperty.js
----------------------------------------------------------------------
diff --git a/frameworks/js/FlexJS/src/mx/states/SetProperty.js b/frameworks/js/FlexJS/src/mx/states/SetProperty.js
new file mode 100644
index 0000000..a6e5e56
--- /dev/null
+++ b/frameworks/js/FlexJS/src/mx/states/SetProperty.js
@@ -0,0 +1,66 @@
+/**
+ * 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('mx.states.SetProperty');
+
+
+/**
+ * @constructor
+ */
+mx.states.SetProperty = function() {
+};
+
+/**
+ * @this {mx.states.SetProperty}
+ * @param {Object} document The MXML object.
+ */
+mx.states.SetProperty.prototype.setDocument = function(document) {
+ this.document = document;
+};
+
+/**
+ * @type {string} document The type of override.
+ */
+mx.states.SetProperty.prototype.type = 'SetProperty';
+
+/**
+ * @expose
+ * @type {Object} document The MXML object.
+ */
+mx.states.SetProperty.prototype.document = null;
+
+/**
+ * @expose
+ * @type {string} name The target property name.
+ */
+mx.states.SetProperty.prototype.name = null;
+
+/**
+ * @expose
+ * @type {string} target The id of the object.
+ */
+mx.states.SetProperty.prototype.target = null;
+
+/**
+ * @expose
+ * @type {Object} previousValue The value to revert to.
+ */
+mx.states.SetProperty.prototype.previousValue = null;
+
+/**
+ * @expose
+ * @type {Object} value The value to set.
+ */
+mx.states.SetProperty.prototype.value = null;
+
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/ff99ba71/frameworks/js/FlexJS/src/mx/states/State.js
----------------------------------------------------------------------
diff --git a/frameworks/js/FlexJS/src/mx/states/State.js b/frameworks/js/FlexJS/src/mx/states/State.js
new file mode 100644
index 0000000..c78be6a
--- /dev/null
+++ b/frameworks/js/FlexJS/src/mx/states/State.js
@@ -0,0 +1,34 @@
+/**
+ * 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('mx.states.State');
+
+
+/**
+ * @constructor
+ */
+mx.states.State = function() {
+};
+
+/**
+ * @expose
+ * @type {string} name The state name.
+ */
+mx.states.State.prototype.name = null;
+
+/**
+ * @expose
+ * @type {Array} overrides The state data.
+ */
+mx.states.State.prototype.overrides = null;
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/ff99ba71/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
new file mode 100644
index 0000000..6fbbd2f
--- /dev/null
+++ b/frameworks/js/FlexJS/src/org/apache/flex/core/SimpleStatesImpl.js
@@ -0,0 +1,149 @@
+/**
+ * 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.core.SimpleStatesImpl');
+
+goog.require('org.apache.flex.events.EventDispatcher');
+
+
+/**
+ * @constructor
+ */
+org.apache.flex.core.SimpleStatesImpl = function() {
+ goog.base(this);
+
+ /**
+ * @private
+ * @type {Object}
+ */
+ this.strand_ = null;
+};
+goog.inherits(org.apache.flex.core.SimpleStatesImpl,
+ org.apache.flex.events.EventDispatcher);
+
+/**
+ * @expose
+ * @this {org.apache.flex.net.dataConverters.LazyCollection}
+ * @param {Object} value The new host.
+ */
+org.apache.flex.core.SimpleStatesImpl.prototype.set_strand =
+ function(value) {
+ if (this.strand_ !== value) {
+ this.strand_ = value;
+ this.strand_.addEventListener('currentStateChanged',
+ goog.bind(this.stateChangeHandler, this));
+ }
+};
+
+/**
+ * @protected
+ * @this {org.apache.flex.core.SimpleStatesImpl}
+ */
+org.apache.flex.core.SimpleStatesImpl.prototype.stateChangeHandler =
+ function() {
+ var s, p;
+ var doc = event.target;
+ var arr = doc.states;
+ for (p in arr)
+ {
+ s = arr[p];
+ if (s.name == event.oldValue)
+ {
+ this.revert(s);
+ break;
+ }
+ }
+ for (p in arr)
+ {
+ s = arr[p];
+ if (s.name == event.newValue)
+ {
+ this.apply(s);
+ break;
+ }
+ }
+};
+
+/**
+ * @protected
+ * @this {org.apache.flex.core.SimpleStatesImpl}
+ * @param {Object} s The State to revert.
+ */
+org.apache.flex.core.SimpleStatesImpl.prototype.revert = function(s) {
+ var p, o;
+ var arr = s.overrides;
+ for (var p in arr)
+ {
+ o = arr[p];
+ if (o.type == 'AddItems')
+ {
+ for (var q in o.items)
+ {
+ var item = o.items[q];
+ var parent = o.document[o.destination];
+ item.removeFromParent(parent);
+ parent.dispatchEvent(new Event('childrenAdded'));
+ }
+ }
+ else if (o.type == 'SetProperty')
+ {
+ o.document[o.target][o.name] = o.previousValue;
+ }
+ }
+};
+
+/**
+ * @protected
+ * @this {org.apache.flex.core.SimpleStatesImpl}
+ * @param {Object} s The State to apply.
+ */
+org.apache.flex.core.SimpleStatesImpl.prototype.apply = function(s) {
+ var arr = s.overrides;
+ for (var 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);
+ }
+ for (var q in o.items)
+ {
+ var item = o.items[q];
+ var parent = o.document[o.destination];
+ if (o.relativeTo != null)
+ {
+ var child = o.document[o.relativeTo];
+ var index = child.getIndexInParent(parent);
+ if (o.position == 'after')
+ index++;
+ item.addToParentAt(parent, index);
+ }
+ else
+ {
+ item.addToParent(parent);
+ }
+ parent.dispatchEvent(new Event('childrenAdded'));
+ }
+ }
+ else if (o.type == 'SetProperty')
+ {
+ o.previousValue = o.document[o.target][o.name];
+ o.document[o.target][o.name] = o.value;
+ }
+ }
+};
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/ff99ba71/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 c52c222..ca2a6eb 100644
--- a/frameworks/js/FlexJS/src/org/apache/flex/core/UIBase.js
+++ b/frameworks/js/FlexJS/src/org/apache/flex/core/UIBase.js
@@ -51,14 +51,73 @@ org.apache.flex.core.UIBase.prototype.internalAddChild = function(child) {
/**
* @this {org.apache.flex.core.UIBase}
+ * @param {Object} child The element to be added.
+ * @param {number} index The index for the element to be added.
+ */
+org.apache.flex.core.UIBase.prototype.internalAddChildAt =
+ function(child, index) {
+ this.element.insertBefore(child, internalGetChildAt(index));
+};
+
+/**
+ * @this {org.apache.flex.core.UIBase}
+ * @param {Object} child The element to be removed.
+ */
+org.apache.flex.core.UIBase.prototype.internalRemoveChild =
+ function(child) {
+ this.element.removeChild(child);
+};
+
+/**
+ * @this {org.apache.flex.core.UIBase}
+ * @param {number} index The index.
+ * @return {Object} The child.
+ */
+org.apache.flex.core.UIBase.prototype.internalGetChildAt =
+ function(index) {
+ return this.element.childNodex[index];
+};
+
+/**
+ * @this {org.apache.flex.core.UIBase}
* @param {Object} p The parent component.
*/
org.apache.flex.core.UIBase.prototype.addToParent = function(p) {
- this.element = document.createElement('div');
+ if (this.element == null)
+ this.element = document.createElement('div');
p.internalAddChild(this.element);
};
+/**
+ * @this {org.apache.flex.core.UIBase}
+ * @param {Object} p The parent component.
+ * @param {number} index The index.
+ */
+org.apache.flex.core.UIBase.prototype.addToParentAt = function(p, index) {
+ if (this.element == null)
+ this.element = document.createElement('div');
+
+ p.internalAddChildAt(this.element);
+};
+
+/**
+ * @this {org.apache.flex.core.UIBase}
+ * @param {Object} p The parent component.
+ * @return {number} The index in parent.
+ */
+org.apache.flex.core.UIBase.prototype.getIndexInParent = function(p) {
+ return p.internalGetChildIndex(this.element);
+};
+
+/**
+ * @this {org.apache.flex.core.UIBase}
+ * @param {Object} p The parent component.
+ */
+org.apache.flex.core.UIBase.prototype.removeFromParent = function(p) {
+ p.internalRemoveChild(this.element);
+};
+
/**
* @expose
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/ff99ba71/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 82e3137..9c22630 100644
--- a/frameworks/js/FlexJS/src/org/apache/flex/core/ViewBase.js
+++ b/frameworks/js/FlexJS/src/org/apache/flex/core/ViewBase.js
@@ -14,17 +14,40 @@
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.utils.MXMLDataInterpreter');
+
/**
* @constructor
* @extends {org.apache.flex.core.UIBase}
*/
org.apache.flex.core.ViewBase = function() {
goog.base(this);
+
+ /**
+ * @private
+ * @type {Array}
+ */
+ this.states_ = null;
+
+ /**
+ * @private
+ * @type {Array}
+ */
+ this.transitions_ = null;
+
+ /**
+ * @private
+ * @type {string}
+ */
+ this.currentState_ = null;
+
};
goog.inherits(org.apache.flex.core.ViewBase, org.apache.flex.core.UIBase);
@@ -71,7 +94,83 @@ org.apache.flex.core.ViewBase.prototype.initUI = function(model) {
* @this {org.apache.flex.core.ViewBase}
* @return {Object} The application model.
*/
-org.apache.flex.core.UIBase.prototype.get_applicationModel = function() {
+org.apache.flex.core.ViewBase.prototype.get_applicationModel = function() {
return this.applicationModel;
};
+/**
+ * @expose
+ * @this {org.apache.flex.core.ViewBase}
+ * @return {Array} The array of State objects.
+ */
+org.apache.flex.core.ViewBase.prototype.get_states = function() {
+ return this.states_;
+};
+
+/**
+ * @expose
+ * @this {org.apache.flex.core.ViewBase}
+ * @param {Array} value The array of State objects.
+ */
+org.apache.flex.core.ViewBase.prototype.set_states = function(value) {
+ this.states_ = value;
+
+ // TODO: (aharui) check if bead already exists
+ this.addBead(new org.apache.flex.core.SimpleStatesImpl());
+};
+
+/**
+ * @expose
+ * @this {org.apache.flex.core.ViewBase}
+ * @param {string} state The name of the state.
+ * @return {boolean} True if state in states array.
+ */
+org.apache.flex.core.ViewBase.prototype.hasState = function(state) {
+ for (var p in this.states_)
+ {
+ var s = states_[p];
+ if (s.name == state)
+ return true;
+ }
+ return false;
+};
+
+/**
+ * @expose
+ * @this {org.apache.flex.core.ViewBase}
+ * @return {string} The name of the current state.
+ */
+org.apache.flex.core.ViewBase.prototype.get_currentState = function() {
+ return this.states_;
+};
+
+/**
+ * @expose
+ * @this {org.apache.flex.core.ViewBase}
+ * @param {string} value The name of the current state.
+ */
+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;
+ this.dispatchEvent(event);
+};
+
+/**
+ * @expose
+ * @this {org.apache.flex.core.ViewBase}
+ * @return {Array} The array of transitions.
+ */
+org.apache.flex.core.ViewBase.prototype.get_transitions = function() {
+ return this.transitions_;
+};
+
+/**
+ * @expose
+ * @this {org.apache.flex.core.ViewBase}
+ * @param {Array} value The array of transitions.
+ */
+org.apache.flex.core.ViewBase.prototype.set_transitions = function(value) {
+ this.transitions_ = value;
+};
+
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/ff99ba71/frameworks/js/FlexJS/src/org/apache/flex/utils/MXMLDataInterpreter.js
----------------------------------------------------------------------
diff --git a/frameworks/js/FlexJS/src/org/apache/flex/utils/MXMLDataInterpreter.js b/frameworks/js/FlexJS/src/org/apache/flex/utils/MXMLDataInterpreter.js
index 949a202..75924a9 100644
--- a/frameworks/js/FlexJS/src/org/apache/flex/utils/MXMLDataInterpreter.js
+++ b/frameworks/js/FlexJS/src/org/apache/flex/utils/MXMLDataInterpreter.js
@@ -257,7 +257,7 @@ org.apache.flex.utils.MXMLDataInterpreter.generateMXMLArray =
self = org.apache.flex.utils.MXMLDataInterpreter;
self.generateMXMLInstances(
document, comp, children, opt_recursive);
- if (typeof comp.childrenAdded === 'function')
+ if (typeof comp.childrenAdded === 'function')
comp.childrenAdded();
} else {
comp.setMXMLDescriptor(children);
[2/5] git commit: [flex-asjs] [refs/heads/develop] - Support states
in FlexJS. Must use mx:States because of MXMLC hard-coded expectations,
but includeIn and property.state syntax now works
Posted by ah...@apache.org.
Support states in FlexJS. Must use mx:States because of MXMLC hard-coded expectations, but includeIn and property.state syntax now works
Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/fe9a9ac1
Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/fe9a9ac1
Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/fe9a9ac1
Branch: refs/heads/develop
Commit: fe9a9ac13212c4ad2d8cfed91383c4d5367a4439
Parents: c557d7a
Author: Alex Harui <ah...@apache.org>
Authored: Thu May 30 22:29:09 2013 -0700
Committer: Alex Harui <ah...@apache.org>
Committed: Thu Jun 13 23:23:21 2013 -0700
----------------------------------------------------------------------
frameworks/as/compile-config.xml | 5 +
frameworks/as/defaults.css | 2 +-
frameworks/as/mx-manifest.xml | 26 ++++
frameworks/as/src/mx/states/AddItems.as | 65 +++++++++
frameworks/as/src/mx/states/SetProperty.as | 60 ++++++++
frameworks/as/src/mx/states/State.as | 34 +++++
.../as/src/org/apache/flex/core/IStatesImpl.as | 26 ++++
.../org/apache/flex/core/SimpleStatesImpl.as | 137 +++++++++++++++++++
.../as/src/org/apache/flex/core/UIBase.as | 39 ++++++
.../as/src/org/apache/flex/core/ViewBase.as | 56 +++++++-
.../flex/html/staticControls/Container.as | 17 ++-
11 files changed, 463 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fe9a9ac1/frameworks/as/compile-config.xml
----------------------------------------------------------------------
diff --git a/frameworks/as/compile-config.xml b/frameworks/as/compile-config.xml
index f96ddcf..aa41d8e 100644
--- a/frameworks/as/compile-config.xml
+++ b/frameworks/as/compile-config.xml
@@ -35,6 +35,10 @@
<manifest>basic-manifest.xml</manifest>
</namespace>
<namespace>
+ <uri>library://ns.adobe.com/flex/mx</uri>
+ <manifest>mx-manifest.xml</manifest>
+ </namespace>
+ <namespace>
<uri>library://ns.apache.org/flexjs/html5</uri>
<manifest>html5-manifest.xml</manifest>
</namespace>
@@ -66,6 +70,7 @@
<include-namespaces>
<uri>library://ns.apache.org/flexjs/basic</uri>
+ <uri>library://ns.adobe.com/flex/mx</uri>
<uri>library://ns.apache.org/flexjs/html5</uri>
<uri>library://ns.apache.org/flexjs/jquery</uri>
<uri>library://ns.apache.org/flexjs/createjs</uri>
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fe9a9ac1/frameworks/as/defaults.css
----------------------------------------------------------------------
diff --git a/frameworks/as/defaults.css b/frameworks/as/defaults.css
index a68bb5f..04c0492 100644
--- a/frameworks/as/defaults.css
+++ b/frameworks/as/defaults.css
@@ -58,7 +58,7 @@ global
{
ITextBead: ClassReference("org.apache.flex.html.staticControls.beads.TextFieldBead");
ITextModel: ClassReference("org.apache.flex.html.staticControls.beads.models.TextModel");
-
+ IStatesImpl: ClassReference("org.apache.flex.core.SimpleStatesImpl");
}
CheckBox
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fe9a9ac1/frameworks/as/mx-manifest.xml
----------------------------------------------------------------------
diff --git a/frameworks/as/mx-manifest.xml b/frameworks/as/mx-manifest.xml
new file mode 100644
index 0000000..6654ace
--- /dev/null
+++ b/frameworks/as/mx-manifest.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You 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.
+
+-->
+
+
+<componentPackage>
+
+ <component id="State" class="mx.states.State"/>
+
+</componentPackage>
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fe9a9ac1/frameworks/as/src/mx/states/AddItems.as
----------------------------------------------------------------------
diff --git a/frameworks/as/src/mx/states/AddItems.as b/frameworks/as/src/mx/states/AddItems.as
new file mode 100644
index 0000000..dc0049a
--- /dev/null
+++ b/frameworks/as/src/mx/states/AddItems.as
@@ -0,0 +1,65 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You 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.
+//
+////////////////////////////////////////////////////////////////////////////////
+
+// shim the mx classes for states
+package mx.states
+{
+ import org.apache.flex.core.IDocument;
+
+ public class AddItems implements IDocument
+ {
+ public function AddItems()
+ {
+ super();
+ }
+
+ public var items:Array;
+
+ public var itemsDescriptor:Array;
+
+ public var destination:String;
+
+ public var propertyName:String;
+
+ public var position:String;
+
+ public var relativeTo:String;
+
+ public var document:Object;
+
+ public function setDocument(document:Object, id:String = null):void
+ {
+ this.document = document;
+ }
+
+ /**
+ * @private
+ * Initialize this object from a descriptor.
+ */
+ public function initializeFromObject(properties:Object):Object
+ {
+ for (var p:String in properties)
+ {
+ this[p] = properties[p];
+ }
+
+ return Object(this);
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fe9a9ac1/frameworks/as/src/mx/states/SetProperty.as
----------------------------------------------------------------------
diff --git a/frameworks/as/src/mx/states/SetProperty.as b/frameworks/as/src/mx/states/SetProperty.as
new file mode 100644
index 0000000..78e0a73
--- /dev/null
+++ b/frameworks/as/src/mx/states/SetProperty.as
@@ -0,0 +1,60 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You 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.
+//
+////////////////////////////////////////////////////////////////////////////////
+// shim the mx classes for states
+package mx.states
+{
+ import org.apache.flex.core.IDocument;
+
+ public class SetProperty implements IDocument
+ {
+ public function SetProperty()
+ {
+ super();
+ }
+
+ public var target:String;
+
+ public var name:String;
+
+ public var value:*;
+
+ public var previousValue:*;
+
+ public var document:Object;
+
+ public function setDocument(document:Object, id:String = null):void
+ {
+ this.document = document;
+ }
+
+ /**
+ * @private
+ * Initialize this object from a descriptor.
+ */
+ public function initializeFromObject(properties:Object):Object
+ {
+ for (var p:String in properties)
+ {
+ this[p] = properties[p];
+ }
+
+ return Object(this);
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fe9a9ac1/frameworks/as/src/mx/states/State.as
----------------------------------------------------------------------
diff --git a/frameworks/as/src/mx/states/State.as b/frameworks/as/src/mx/states/State.as
new file mode 100644
index 0000000..3a38d54
--- /dev/null
+++ b/frameworks/as/src/mx/states/State.as
@@ -0,0 +1,34 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You 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.
+//
+////////////////////////////////////////////////////////////////////////////////
+
+// shim the mx classes for states
+package mx.states
+{
+ public class State
+ {
+ public function State(properties:Object = null)
+ {
+ super();
+ }
+
+ public var name:String;
+
+ public var overrides:Array;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fe9a9ac1/frameworks/as/src/org/apache/flex/core/IStatesImpl.as
----------------------------------------------------------------------
diff --git a/frameworks/as/src/org/apache/flex/core/IStatesImpl.as b/frameworks/as/src/org/apache/flex/core/IStatesImpl.as
new file mode 100644
index 0000000..152fe8f
--- /dev/null
+++ b/frameworks/as/src/org/apache/flex/core/IStatesImpl.as
@@ -0,0 +1,26 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You 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.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.core
+{
+ import org.apache.flex.events.IEventDispatcher;
+
+ public interface IStatesImpl extends IEventDispatcher, IBead
+ {
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fe9a9ac1/frameworks/as/src/org/apache/flex/core/SimpleStatesImpl.as
----------------------------------------------------------------------
diff --git a/frameworks/as/src/org/apache/flex/core/SimpleStatesImpl.as b/frameworks/as/src/org/apache/flex/core/SimpleStatesImpl.as
new file mode 100644
index 0000000..a5f6a14
--- /dev/null
+++ b/frameworks/as/src/org/apache/flex/core/SimpleStatesImpl.as
@@ -0,0 +1,137 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You 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.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.core
+{
+ import flash.display.DisplayObject;
+ import flash.events.IEventDispatcher;
+
+ import mx.states.AddItems;
+ import mx.states.SetProperty;
+ import mx.states.State;
+
+ import org.apache.flex.events.Event;
+ import org.apache.flex.events.EventDispatcher;
+ import org.apache.flex.events.ValueChangeEvent;
+ import org.apache.flex.utils.MXMLDataInterpreter;
+
+ public class SimpleStatesImpl extends EventDispatcher implements IStatesImpl, IBead
+ {
+ public function SimpleStatesImpl()
+ {
+ super();
+ }
+
+ private var _strand:IStrand;
+
+ public function set strand(value:IStrand):void
+ {
+ _strand = value;
+ IEventDispatcher(_strand).addEventListener("currentStateChanged", stateChangeHandler);
+ }
+
+ private function stateChangeHandler(event:ValueChangeEvent):void
+ {
+ var doc:Object = event.target;
+ var arr:Array = doc.states;
+ for each (var s:State in arr)
+ {
+ if (s.name == event.oldValue)
+ {
+ revert(s);
+ break;
+ }
+ }
+ for each (s in arr)
+ {
+ if (s.name == event.newValue)
+ {
+ apply(s);
+ break;
+ }
+ }
+
+ }
+
+ private function revert(s:State):void
+ {
+ var arr:Array = s.overrides;
+ for each (var o:Object in arr)
+ {
+ if (o is AddItems)
+ {
+ var ai:AddItems = AddItems(o);
+ for each (var item:DisplayObject in ai.items)
+ {
+ var parent:Object = ai.document[ai.destination];
+ if (item is UIBase)
+ UIBase(item).removeFromParent(parent);
+ parent.dispatchEvent(new Event("childrenAdded"));
+ }
+ }
+ else if (o is SetProperty)
+ {
+ var sp:SetProperty = SetProperty(o);
+ sp.document[sp.target][sp.name] = sp.previousValue;
+ }
+ }
+ }
+
+ private function apply(s:State):void
+ {
+ var arr:Array = s.overrides;
+ for each (var o:Object in arr)
+ {
+ if (o is AddItems)
+ {
+ var ai:AddItems = AddItems(o);
+ if (ai.items == null)
+ {
+ ai.items = MXMLDataInterpreter.generateMXMLArray(ai.document,
+ null, ai.itemsDescriptor, true);
+ }
+ for each (var item:DisplayObject in ai.items)
+ {
+ var parent:Object = ai.document[ai.destination];
+ if (ai.relativeTo != null)
+ {
+ var child:Object = ai.document[ai.relativeTo];
+ var index:int = UIBase(child).getIndexInParent(parent);
+ if (ai.position == "after")
+ index++;
+ if (item is UIBase)
+ UIBase(item).addToParentAt(parent, index);
+ }
+ else
+ {
+ if (item is UIBase)
+ UIBase(item).addToParent(parent);
+ }
+ parent.dispatchEvent(new Event("childrenAdded"));
+ }
+ }
+ else if (o is SetProperty)
+ {
+ var sp:SetProperty = SetProperty(o);
+ sp.previousValue = sp.document[sp.target][sp.name];
+ sp.document[sp.target][sp.name] = sp.value;
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fe9a9ac1/frameworks/as/src/org/apache/flex/core/UIBase.as
----------------------------------------------------------------------
diff --git a/frameworks/as/src/org/apache/flex/core/UIBase.as b/frameworks/as/src/org/apache/flex/core/UIBase.as
index 34187ee..fc073fa 100644
--- a/frameworks/as/src/org/apache/flex/core/UIBase.as
+++ b/frameworks/as/src/org/apache/flex/core/UIBase.as
@@ -175,6 +175,30 @@ package org.apache.flex.core
else
p.addChild(this);
}
+
+ public function addToParentAt(p:Object, index:int):void
+ {
+ if (p is UIBase)
+ UIBase(p).internalAddChildAt(this, index);
+ else
+ p.addChild(this, index);
+ }
+
+ public function getIndexInParent(p:Object):int
+ {
+ if (p is UIBase)
+ return UIBase(p).internalGetChildIndex(this);
+ else
+ return p.getChildIndex(this);
+ }
+
+ public function removeFromParent(p:Object):void
+ {
+ if (p is UIBase)
+ UIBase(p).internalRemoveChild(this);
+ else
+ p.removeChild(this);
+ }
/**
* Used internally by addToParent() implementations
@@ -190,6 +214,21 @@ package org.apache.flex.core
addChild(child as DisplayObject);
}
+ public function internalAddChildAt(child:Object, index:int):void
+ {
+ addChildAt(child as DisplayObject, index);
+ }
+
+ public function internalGetChildIndex(child:Object):int
+ {
+ return getChildIndex(child as DisplayObject);
+ }
+
+ public function internalRemoveChild(child:Object):void
+ {
+ removeChild(child as DisplayObject);
+ }
+
/*
public function addToParent(p:Object):void
{
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fe9a9ac1/frameworks/as/src/org/apache/flex/core/ViewBase.as
----------------------------------------------------------------------
diff --git a/frameworks/as/src/org/apache/flex/core/ViewBase.as b/frameworks/as/src/org/apache/flex/core/ViewBase.as
index f9b96f1..177a366 100644
--- a/frameworks/as/src/org/apache/flex/core/ViewBase.as
+++ b/frameworks/as/src/org/apache/flex/core/ViewBase.as
@@ -18,8 +18,11 @@
////////////////////////////////////////////////////////////////////////////////
package org.apache.flex.core
{
+ import mx.states.State;
+
import org.apache.flex.core.ValuesManager;
- import org.apache.flex.events.Event;
+ import org.apache.flex.events.Event;
+ import org.apache.flex.events.ValueChangeEvent;
import org.apache.flex.utils.MXMLDataInterpreter;
[Event(name="initComplete", type="org.apache.flex.events.Event")]
@@ -64,5 +67,54 @@ package org.apache.flex.core
{
return _applicationModel;
}
- }
+
+ private var _states:Array;
+
+ public function get states():Array
+ {
+ return _states;
+ }
+ public function set states(value:Array):void
+ {
+ _states = value;
+ if (getBeadByType(IStatesImpl) == null)
+ addBead(new (ValuesManager.valuesImpl.getValue(this, "iStatesImpl")) as IBead);
+
+ }
+
+ public function hasState(state:String):Boolean
+ {
+ for each (var s:State in _states)
+ {
+ if (s.name == state)
+ return true;
+ }
+ return false;
+ }
+
+ private var _currentState:String;
+
+ public function get currentState():String
+ {
+ return _currentState;
+ }
+ public function set currentState(value:String):void
+ {
+ var event:ValueChangeEvent = new ValueChangeEvent("currentStateChanged", false, false, _currentState, value)
+ _currentState = value;
+ dispatchEvent(event);
+ }
+
+ private var _transitions:Array;
+
+ public function get transitions():Array
+ {
+ return _transitions;
+ }
+ public function set transitions(value:Array):void
+ {
+ _transitions = value;
+ }
+
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fe9a9ac1/frameworks/as/src/org/apache/flex/html/staticControls/Container.as
----------------------------------------------------------------------
diff --git a/frameworks/as/src/org/apache/flex/html/staticControls/Container.as b/frameworks/as/src/org/apache/flex/html/staticControls/Container.as
index 35b2d19..6e31c7f 100644
--- a/frameworks/as/src/org/apache/flex/html/staticControls/Container.as
+++ b/frameworks/as/src/org/apache/flex/html/staticControls/Container.as
@@ -60,7 +60,22 @@ package org.apache.flex.html.staticControls
actualParent.addChild(child as DisplayObject);
}
- public function getChildren():Array
+ override public function internalAddChildAt(child:Object, index:int):void
+ {
+ actualParent.addChildAt(child as DisplayObject, index);
+ }
+
+ override public function internalGetChildIndex(child:Object):int
+ {
+ return actualParent.getChildIndex(child as DisplayObject);
+ }
+
+ override public function internalRemoveChild(child:Object):void
+ {
+ actualParent.removeChild(child as DisplayObject);
+ }
+
+ public function getChildren():Array
{
var children:Array = [];
var n:int = actualParent.numChildren;
[4/5] git commit: [flex-asjs] [refs/heads/develop] - handle null
which could happen when restoring states
Posted by ah...@apache.org.
handle null which could happen when restoring states
Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/6cb30a9a
Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/6cb30a9a
Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/6cb30a9a
Branch: refs/heads/develop
Commit: 6cb30a9a1588c0b62ea948d15c2dd489cd07922a
Parents: ff99ba7
Author: Alex Harui <ah...@apache.org>
Authored: Tue Jun 11 14:52:15 2013 -0700
Committer: Alex Harui <ah...@apache.org>
Committed: Thu Jun 13 23:23:28 2013 -0700
----------------------------------------------------------------------
.../org/apache/flex/html/staticControls/beads/TextFieldBeadBase.as | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/6cb30a9a/frameworks/as/src/org/apache/flex/html/staticControls/beads/TextFieldBeadBase.as
----------------------------------------------------------------------
diff --git a/frameworks/as/src/org/apache/flex/html/staticControls/beads/TextFieldBeadBase.as b/frameworks/as/src/org/apache/flex/html/staticControls/beads/TextFieldBeadBase.as
index a746745..6b19447 100644
--- a/frameworks/as/src/org/apache/flex/html/staticControls/beads/TextFieldBeadBase.as
+++ b/frameworks/as/src/org/apache/flex/html/staticControls/beads/TextFieldBeadBase.as
@@ -79,7 +79,7 @@ package org.apache.flex.html.staticControls.beads
public function set text(value:String):void
{
if (value == null)
- value == "";
+ value = "";
_textField.text = value;
}
[5/5] git commit: [flex-asjs] [refs/heads/develop] - changes needed
to support states in JS
Posted by ah...@apache.org.
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 <ah...@apache.org>
Authored: Thu Jun 13 23:21:36 2013 -0700
Committer: Alex Harui <ah...@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;
};