Updated Branches: refs/heads/develop 8a5460a90 -> d8ceac774
Adding initial versions List and RadioButton components for JavaScript. Still need to work on events. Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/d8ceac77 Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/d8ceac77 Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/d8ceac77 Branch: refs/heads/develop Commit: d8ceac774c2f91cbc3aa89cf2fa2af8303bd8db7 Parents: 8a5460a Author: Peter Ent <[email protected]> Authored: Tue Apr 2 10:28:24 2013 -0400 Committer: Peter Ent <[email protected]> Committed: Tue Apr 2 10:28:24 2013 -0400 ---------------------------------------------------------------------- frameworks/as/defaults.css | 11 + frameworks/as/html5-manifest.xml | 2 + .../org/apache/flex/html5/staticControls/List.js | 146 +++++++++++++++ .../flex/html5/staticControls/RadioButton.js | 103 ++++++++++ 4 files changed, 262 insertions(+), 0 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d8ceac77/frameworks/as/defaults.css ---------------------------------------------------------------------- diff --git a/frameworks/as/defaults.css b/frameworks/as/defaults.css index e592eed..38aae49 100644 --- a/frameworks/as/defaults.css +++ b/frameworks/as/defaults.css @@ -90,3 +90,14 @@ h5|CheckBox IToggleButtonModel: ClassReference("org.apache.flex.html.staticControls.beads.models.ToggleButtonModel"); ICheckBoxBead: ClassReference("org.apache.flex.html.staticControls.beads.CheckBoxBead"); } + +h5|RadioButton +{ + IToggleButtonModel: ClassReference("org.apache.flex.html.staticControls.beads.models.ValueToggleButtonModel"); + IRadioButtonBead: ClassReference("org.apache.flex.html.staticControls.beads.RadioButtonBead"); +} + +h5|List +{ + ISelectionModel: ClassReference("org.apache.flex.html.staticControls.beads.models.ArraySelectionModel"); +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d8ceac77/frameworks/as/html5-manifest.xml ---------------------------------------------------------------------- diff --git a/frameworks/as/html5-manifest.xml b/frameworks/as/html5-manifest.xml index f15b632..6b43be9 100644 --- a/frameworks/as/html5-manifest.xml +++ b/frameworks/as/html5-manifest.xml @@ -27,5 +27,7 @@ <component id="TextInput" class="org.apache.flex.html5.staticControls.TextInput"/> <component id="TextArea" class="org.apache.flex.html5.staticControls.TextArea"/> <component id="CheckBox" class="org.apache.flex.html5.staticControls.CheckBox"/> + <component id="RadioButton" class="org.apache.flex.html5.staticControls.RadioButton"/> + <component id="List" class="org.apache.flex.html5.staticControls.List"/> </componentPackage> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d8ceac77/frameworks/js/FlexJS/src/org/apache/flex/html5/staticControls/List.js ---------------------------------------------------------------------- diff --git a/frameworks/js/FlexJS/src/org/apache/flex/html5/staticControls/List.js b/frameworks/js/FlexJS/src/org/apache/flex/html5/staticControls/List.js new file mode 100644 index 0000000..5675115 --- /dev/null +++ b/frameworks/js/FlexJS/src/org/apache/flex/html5/staticControls/List.js @@ -0,0 +1,146 @@ +/** + * 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.html5.staticControls.List'); + +goog.require('org.apache.flex.core.UIBase'); + +/** + * @constructor + * @extends {org.apache.flex.core.UIBase} + */ +org.apache.flex.html5.staticControls.List = function() { + org.apache.flex.core.UIBase.call(this); + + /** + * @private + * @type {Array.<Object>} + */ + this._dataProvider; + +}; +goog.inherits( + org.apache.flex.html5.staticControls.List, org.apache.flex.core.UIBase +); + +/** + * @override + * @this {org.apache.flex.html5.staticControls.List} + * @param {Object} p The parent element. + */ +org.apache.flex.html5.staticControls.List.prototype.addToParent = function(p) { + this.element = document.createElement('select'); + this.element.onChange = org.apache.flex.FlexGlobal.createProxy( + this, this.changeHandler); + this.element.size = 5; + + p.appendChild(this.element); + + this.positioner = this.element; +}; + +/** + * @expose + * @this {org.apache.flex.html5.staticControls.List} + * @return {Array.<Object>} The collection of data. + */ +org.apache.flex.html5.staticControls.List.prototype.get_dataProvider = +function() { + return this._dataProvider; +}; + +/** + * @expose + * @this {org.apache.flex.html5.staticControls.List} + * @param {Array.<Object>} value The text setter. + */ +org.apache.flex.html5.staticControls.List.prototype.set_dataProvider = +function(value) { + this._dataProvider = value; + + var dp = this.element.options; + var n = dp.length; + for (var i = 0; i < n; i++) + dp.remove(0); + + n = value.length; + for (i = 0; i < n; i++) + { + var opt = document.createElement('option'); + opt.text = value[i]; + dp.add(opt); + } +}; + +/** + * @expose + * @this {org.apache.flex.html5.staticControls.List} + * @return {int} The selected index. + */ +org.apache.flex.html5.staticControls.List.prototype.get_selectedIndex = +function() { + return this.element.selectedIndex; +}; + +/** + * @expose + * @this {org.apache.flex.html5.staticControls.List} + * @param {int} value The selected index. + */ +org.apache.flex.html5.staticControls.List.prototype.set_selectedIndex = +function(value) { + this.element.selectedIndex = value; +}; + +/** + * @expose + * @this {org.apache.flex.html5.staticControls.List} + * @return {Object} The selected item. + */ +org.apache.flex.html5.staticControls.List.prototype.get_selectedItem = +function() { + return this._dataProvider[this.element.selectedIndex]; +}; + +/** + * @expose + * @this {org.apache.flex.html5.staticControls.List} + * @param {Object} value The selected item. + */ +org.apache.flex.html5.staticControls.List.prototype.set_selectedItem = +function(value) { + + var dp = this._dataProvider; + var n = dp.length; + for (var i = 0; i < n; i++) + { + if (dp[i] == value) + break; + } + if (i < n) + this.element.selectedIndex = i; +}; + +/** + * @protected + * @this {org.apache.flex.html5.staticControls.List} + * @return {Object} The selected item. + */ +org.apache.flex.html5.staticControls.List.prototype.changeHandler = +function() { + evt = document.createEvent('Event'); + evt.initEvent('change', false, false); + this.element.dispatchEvent(evt); +}; + http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d8ceac77/frameworks/js/FlexJS/src/org/apache/flex/html5/staticControls/RadioButton.js ---------------------------------------------------------------------- diff --git a/frameworks/js/FlexJS/src/org/apache/flex/html5/staticControls/RadioButton.js b/frameworks/js/FlexJS/src/org/apache/flex/html5/staticControls/RadioButton.js new file mode 100644 index 0000000..971ac86 --- /dev/null +++ b/frameworks/js/FlexJS/src/org/apache/flex/html5/staticControls/RadioButton.js @@ -0,0 +1,103 @@ +/** + * 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.html5.staticControls.RadioButton'); + +goog.require('org.apache.flex.core.UIBase'); + +var rbCount = 0; + +/** + * @constructor + * @extends {org.apache.flex.core.UIBase} + */ +org.apache.flex.html5.staticControls.RadioButton = function() { + org.apache.flex.core.UIBase.call(this); +}; +goog.inherits( + org.apache.flex.html5.staticControls.RadioButton, org.apache.flex.core.UIBase +); + +/** + * @override + * @this {org.apache.flex.html5.staticControls.RadioButton} + * @param {Object} p The parent element. + */ +org.apache.flex.html5.staticControls.RadioButton.prototype.addToParent = + function(p) { + this.element = document.createElement('label'); + + var rb = document.createElement('input'); + rb.type = 'radio'; + this.element.appendChild(rb); + this.element.appendChild(document.createTextNode("radio button")); + + p.appendChild(this.element); + + this.positioner = this.element; +}; + +/** + * @expose + * @this {org.apache.flex.html5.staticControls.RadioButton} + * @return {string} The groupName getter. + */ +org.apache.flex.html5.staticControls.RadioButton.prototype.get_groupName = function() { + return this.element.childNodes.item(0).name; +}; + +/** + * @expose + * @this {org.apache.flex.html5.staticControls.RadioButton} + * @param {string} value The groupName setter. + */ +org.apache.flex.html5.staticControls.RadioButton.prototype.set_groupName = function(value) { + this.element.childNodes.item(0).name = value; +}; + +/** + * @expose + * @this {org.apache.flex.html5.staticControls.RadioButton} + * @return {string} The text getter. + */ +org.apache.flex.html5.staticControls.RadioButton.prototype.get_text = function() { + return this.element.childNodes.item(1).nodeValue; +}; + +/** + * @expose + * @this {org.apache.flex.html5.staticControls.RadioButton} + * @param {string} value The text setter. + */ +org.apache.flex.html5.staticControls.RadioButton.prototype.set_text = function(value) { + this.element.childNodes.item(1).nodeValue = value; +}; + +/** + * @expose + * @this {org.apache.flex.html5.staticControls.RadioButton} + * @return {bool} The selected getter. + */ +org.apache.flex.html5.staticControls.RadioButton.prototype.get_selected = function() { + return this.element.childNodes.item(0).checked; +}; + +/** + * @expose + * @this {org.apache.flex.html5.staticControls.RadioButton} + * @param {bool} value The selected setter. + */ +org.apache.flex.html5.staticControls.RadioButton.prototype.set_selected = function(value) { + this.element.childNodes.item(0).checked = value; +};
