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/11 23:59:24 UTC
[2/2] git commit: [flex-asjs] [refs/heads/develop] - repair
DataBindingTest
repair DataBindingTest
Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/17947a07
Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/17947a07
Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/17947a07
Branch: refs/heads/develop
Commit: 17947a07f782c8c5fbbb8cb63451b099e8e90301
Parents: be258c2
Author: Alex Harui <ah...@apache.org>
Authored: Fri Oct 11 14:59:05 2013 -0700
Committer: Alex Harui <ah...@apache.org>
Committed: Fri Oct 11 14:59:05 2013 -0700
----------------------------------------------------------------------
.../flex/html/staticControls/DropDownList.js | 74 ++++++++++++++++++++
.../beads/layouts/NonVirtualHorizontalLayout.js | 6 +-
.../beads/models/ArraySelectionModel.js | 12 +++-
3 files changed, 85 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/17947a07/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/DropDownList.js
----------------------------------------------------------------------
diff --git a/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/DropDownList.js b/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/DropDownList.js
index e5c9a31..341b3c2 100644
--- a/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/DropDownList.js
+++ b/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/DropDownList.js
@@ -24,6 +24,80 @@ goog.require('org.apache.flex.core.ListBase');
*/
org.apache.flex.html.staticControls.DropDownList = function() {
goog.base(this);
+ this.model =
+ new org.apache.flex.html.staticControls.beads.models.ArraySelectionModel();
+
};
goog.inherits(org.apache.flex.html.staticControls.DropDownList,
org.apache.flex.core.ListBase);
+
+/**
+ * @override
+ * @this {org.apache.flex.html.staticControls.DropDownList}
+ */
+org.apache.flex.html.staticControls.DropDownList.prototype.
+createElement = function() {
+ this.element = document.createElement('select');
+ this.element.size = 1;
+ goog.events.listen(this.element, 'change',
+ goog.bind(this.changeHandler, this));
+ this.positioner = this.element;
+};
+
+/**
+ * @expose
+ * @this {org.apache.flex.html.staticControls.DropDownList}
+ * @param {Object} value The new dataProvider.
+ */
+org.apache.flex.html.staticControls.DropDownList.prototype.
+set_dataProvider = function(value) {
+ var dp, i, n, opt;
+
+ this.model.set_dataProvider(value);
+
+ dp = this.element.options;
+ n = dp.length;
+ for (i = 0; i < n; i++) {
+ dp.remove(0);
+ }
+
+ n = value.length;
+ for (i = 0; i < n; i++) {
+ opt = document.createElement('option');
+ opt.text = value[i];
+ dp.add(opt);
+ }
+
+};
+
+/**
+ * @protected
+ * @this {org.apache.flex.html.staticControls.DropDownList}
+ */
+org.apache.flex.html.staticControls.DropDownList.prototype.changeHandler =
+ function() {
+ this.model.set_selectedIndex(this.element.selectedIndex);
+ this.dispatchEvent('change');
+};
+
+/**
+ * @expose
+ * @this {org.apache.flex.html.staticControls.DropDownList}
+ * @param {Number} value The new selected index.
+ */
+org.apache.flex.html.staticControls.DropDownList.prototype.
+set_selectedIndex = function(value) {
+ this.model.set_selectedIndex(value);
+ this.element.selectedIndex = value;
+};
+
+/**
+ * @expose
+ * @this {org.apache.flex.html.staticControls.DropDownList}
+ * @param {Object} value The new selected item.
+ */
+org.apache.flex.html.staticControls.DropDownList.prototype.
+set_selectedItem = function(value) {
+ this.model.set_selectedItem(value);
+ this.element.selectedIndex = this.get_selectedIndex();
+};
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/17947a07/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/beads/layouts/NonVirtualHorizontalLayout.js
----------------------------------------------------------------------
diff --git a/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/beads/layouts/NonVirtualHorizontalLayout.js b/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/beads/layouts/NonVirtualHorizontalLayout.js
index a9f29a0..535e2af 100644
--- a/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/beads/layouts/NonVirtualHorizontalLayout.js
+++ b/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/beads/layouts/NonVirtualHorizontalLayout.js
@@ -58,11 +58,7 @@ org.apache.flex.html.staticControls.beads.layouts.NonVirtualHorizontalLayout.
prototype.changeHandler = function(event) {
var children, i, n;
- var layoutParent = this.strand_.getBeadByType(
- org.apache.flex.html.staticControls.beads.ListView);
- var contentView = layoutParent.get_dataGroup();
-
- children = contentView.internalChildren();
+ children = this.strand_.internalChildren();
n = children.length;
for (i = 0; i < n; i++)
{
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/17947a07/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/beads/models/ArraySelectionModel.js
----------------------------------------------------------------------
diff --git a/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/beads/models/ArraySelectionModel.js b/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/beads/models/ArraySelectionModel.js
index 12944a1..099aefe 100644
--- a/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/beads/models/ArraySelectionModel.js
+++ b/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/beads/models/ArraySelectionModel.js
@@ -93,7 +93,16 @@ set_selectedIndex = function(value) {
*/
org.apache.flex.html.staticControls.beads.models.ArraySelectionModel.prototype.
get_selectedItem = function() {
- return this.selectedItem_;
+ var si;
+
+ si = this.selectedIndex_;
+
+ if (!this.dataProvider_ || si < 0 ||
+ si >= this.dataProvider_.length) {
+ return null;
+ }
+
+ return this.dataProvider_[si];
};
@@ -104,7 +113,6 @@ get_selectedItem = function() {
*/
org.apache.flex.html.staticControls.beads.models.ArraySelectionModel.prototype.
set_selectedItem = function(value) {
- this.selectedItem_ = value;
// find item in dataProvider and set selectedIndex or -1 if not exists
this.selectedIndex_ = -1;