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:47 UTC
[3/3] git commit: [flex-asjs] [refs/heads/develop] - JS-side custom
CSS
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());
};
/**