You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by pe...@apache.org on 2013/05/09 22:33:16 UTC
git commit: [flex-asjs] [refs/heads/develop] - RadioButtons for
jQuery. RadioButtons cannot be programmatically added due to a known jQuery
bug (documented in the RadioButton.js file).
Updated Branches:
refs/heads/develop 0991467eb -> 114aeec95
RadioButtons for jQuery. RadioButtons cannot be programmatically added due to a known jQuery bug (documented in the RadioButton.js file).
Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/114aeec9
Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/114aeec9
Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/114aeec9
Branch: refs/heads/develop
Commit: 114aeec95635a765abc6e527517de984cd2dfadd
Parents: 0991467
Author: Peter Ent <pe...@apache.org>
Authored: Thu May 9 16:33:01 2013 -0400
Committer: Peter Ent <pe...@apache.org>
Committed: Thu May 9 16:33:01 2013 -0400
----------------------------------------------------------------------
frameworks/as/jquery-manifest.xml | 1 -
.../apache/flex/html/staticControls/RadioButton.as | 6 +
.../as/src/org/apache/flex/jquery/Application.as | 43 ----
.../flex/jquery/staticControls/RadioButton.as | 4 +
.../org/apache/flex/html/staticControls/Label.js | 14 ++
.../apache/flex/html/staticControls/RadioButton.js | 16 ++
.../src/org/apache/flex/jquery/Application.js | 114 -----------
.../flex/jquery/staticControls/RadioButton.js | 158 ++++++++++++---
8 files changed, 169 insertions(+), 187 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/114aeec9/frameworks/as/jquery-manifest.xml
----------------------------------------------------------------------
diff --git a/frameworks/as/jquery-manifest.xml b/frameworks/as/jquery-manifest.xml
index cdb9dd5..d760aff 100644
--- a/frameworks/as/jquery-manifest.xml
+++ b/frameworks/as/jquery-manifest.xml
@@ -21,7 +21,6 @@
<componentPackage>
- <component id="Application" class="org.apache.flex.jquery.Application"/>
<component id="TextButton" class="org.apache.flex.jquery.staticControls.TextButton"/>
<component id="CheckBox" class="org.apache.flex.jquery.staticControls.CheckBox"/>
<component id="RadioButton" class="org.apache.flex.jquery.staticControls.RadioButton"/>
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/114aeec9/frameworks/as/src/org/apache/flex/html/staticControls/RadioButton.as
----------------------------------------------------------------------
diff --git a/frameworks/as/src/org/apache/flex/html/staticControls/RadioButton.as b/frameworks/as/src/org/apache/flex/html/staticControls/RadioButton.as
index 0aee02b..a6caf5b 100644
--- a/frameworks/as/src/org/apache/flex/html/staticControls/RadioButton.as
+++ b/frameworks/as/src/org/apache/flex/html/staticControls/RadioButton.as
@@ -19,6 +19,7 @@
package org.apache.flex.html.staticControls
{
import flash.display.DisplayObject;
+ import flash.display.DisplayObjectContainer;
import flash.display.SimpleButton;
import flash.events.MouseEvent;
import flash.utils.Dictionary;
@@ -111,6 +112,11 @@ package org.apache.flex.html.staticControls
IValueToggleButtonModel(model).selectedValue = newValue;
}
+ public function addToParent(p:DisplayObjectContainer):void
+ {
+ p.addChild(this);
+ }
+
public function initModel():void
{
if (getBeadByType(IValueToggleButtonModel) == null)
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/114aeec9/frameworks/as/src/org/apache/flex/jquery/Application.as
----------------------------------------------------------------------
diff --git a/frameworks/as/src/org/apache/flex/jquery/Application.as b/frameworks/as/src/org/apache/flex/jquery/Application.as
deleted file mode 100644
index 5801d07..0000000
--- a/frameworks/as/src/org/apache/flex/jquery/Application.as
+++ /dev/null
@@ -1,43 +0,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.
-//
-////////////////////////////////////////////////////////////////////////////////
-package org.apache.flex.jquery
-{
- import flash.display.Sprite;
- import flash.display.StageAlign;
- import flash.display.StageScaleMode;
- import flash.events.IOErrorEvent;
-
- import org.apache.flex.core.Application;
- import org.apache.flex.core.IFlexInfo;
- import org.apache.flex.events.Event;
- import org.apache.flex.utils.MXMLDataInterpreter;
-
- //--------------------------------------
- // Events
- //--------------------------------------
-
- /**
- * Dispatched at startup.
- */
- [Event(name="initialize", type="org.apache.flex.events.Event")]
-
- public class Application extends org.apache.flex.core.Application implements IFlexInfo
- {
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/114aeec9/frameworks/as/src/org/apache/flex/jquery/staticControls/RadioButton.as
----------------------------------------------------------------------
diff --git a/frameworks/as/src/org/apache/flex/jquery/staticControls/RadioButton.as b/frameworks/as/src/org/apache/flex/jquery/staticControls/RadioButton.as
index a94739a..aac1ad5 100644
--- a/frameworks/as/src/org/apache/flex/jquery/staticControls/RadioButton.as
+++ b/frameworks/as/src/org/apache/flex/jquery/staticControls/RadioButton.as
@@ -22,5 +22,9 @@ package org.apache.flex.jquery.staticControls
public class RadioButton extends org.apache.flex.html.staticControls.RadioButton
{
+ override public function initModel():void
+ {
+ super.initModel();
+ }
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/114aeec9/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 875607a..55d1361 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
@@ -40,6 +40,20 @@ org.apache.flex.html.staticControls.Label.prototype.addToParent = function(p) {
this.positioner = this.element;
};
+/**
+ * @expose
+ * @this {org.apache.flex.html.staticControls.Label}
+ */
+org.apache.flex.html.staticControls.Label.prototype.initModel = function() {
+};
+/**
+ * @expose
+ * @this {org.apache.flex.html.staticControls.Label}
+ */
+org.apache.flex.html.staticControls.Label.prototype.initSkin = function() {
+
+};
+
/**
* @expose
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/114aeec9/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/RadioButton.js
----------------------------------------------------------------------
diff --git a/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/RadioButton.js b/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/RadioButton.js
index fb657b2..e8f67d6 100644
--- a/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/RadioButton.js
+++ b/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/RadioButton.js
@@ -51,6 +51,22 @@ org.apache.flex.html.staticControls.RadioButton.prototype.addToParent =
rb.flexjs_wrapper = this;
};
+/**
+ * @expose
+ * @this {org.apache.flex.html.staticControls.RadioButton}
+ */
+org.apache.flex.html.staticControls.RadioButton.prototype.initModel =
+function() {
+};
+
+/**
+ * @expose
+ * @this {org.apache.flex.html.staticControls.RadioButton}
+ */
+org.apache.flex.html.staticControls.RadioButton.prototype.initSkin =
+function() {
+};
+
/**
* @expose
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/114aeec9/frameworks/js/FlexJS/src/org/apache/flex/jquery/Application.js
----------------------------------------------------------------------
diff --git a/frameworks/js/FlexJS/src/org/apache/flex/jquery/Application.js b/frameworks/js/FlexJS/src/org/apache/flex/jquery/Application.js
deleted file mode 100644
index e6eb0f8..0000000
--- a/frameworks/js/FlexJS/src/org/apache/flex/jquery/Application.js
+++ /dev/null
@@ -1,114 +0,0 @@
-/**
- * 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.
- */
-
-// ------------------------------------------------------------------
-// jQuery
-// ------------------------------------------------------------------
-
-// (erikdebruin) do these have to be in the global namespace?
-var head, link, mainjs, uijs;
-
-// Bring in the jQuery sources. You can use the minified versions for
-// better performance.
-mainjs = document.createElement('script');
-/** @type {Object} */ mainjs.src = 'http://code.jquery.com/jquery-1.9.1.js';
-document.head.appendChild(mainjs);
-
-uijs = document.createElement('script');
-/** @type {Object} */ uijs.src =
- 'http://code.jquery.com/ui/1.10.2/jquery-ui.js';
-document.head.appendChild(uijs);
-
-// create a stylesheet link to the corresponding jquery theme file.
-head = document.getElementsByTagName('head')[0];
-link = document.createElement('link');
-/** @type {Object} */ link.id = 'jquerycss';
-/** @type {Object} */ link.rel = 'stylesheet';
-/** @type {Object} */ link.type = 'text/css';
-/** @type {Object} */ link.href =
- 'http://code.jquery.com/ui/1.10.2/themes/smoothness/jquery-ui.css';
-/** @type {Object} */ link.media = 'all';
-head.appendChild(link);
-
-// ------------------------------------------------------------------
-// end jQuery
-// ------------------------------------------------------------------
-
-goog.provide('org.apache.flex.jquery.Application');
-
-goog.require('org.apache.flex.core.HTMLElementWrapper');
-goog.require('org.apache.flex.utils.MXMLDataInterpreter');
-
-
-
-/**
- * @constructor
- * @extends {org.apache.flex.core.HTMLElementWrapper}
- */
-org.apache.flex.jquery.Application = function() {
- goog.base(this);
-
-};
-goog.inherits(org.apache.flex.jquery.Application,
- org.apache.flex.core.HTMLElementWrapper);
-
-
-/**
- * @expose
- * @type {Object}
- */
-org.apache.flex.jquery.Application.prototype.controller = null;
-
-
-/**
- * @expose
- * @type {org.apache.flex.core.ViewBase}
- */
-org.apache.flex.jquery.Application.prototype.initialView = null;
-
-
-/**
- * @expose
- * @type {org.apache.flex.events.EventDispatcher}
- */
-org.apache.flex.jquery.Application.prototype.model = null;
-
-
-/**
- * @expose
- * @type {org.apache.flex.core.SimpleValuesImpl}
- */
-org.apache.flex.jquery.Application.prototype.valuesImpl = null;
-
-
-/**
- * @expose
- * @this {org.apache.flex.jquery.Application}
- */
-org.apache.flex.jquery.Application.prototype.start = function() {
- var evt, i, n, q;
-
- this.element = document.getElementsByTagName('body')[0];
-
- org.apache.flex.utils.MXMLDataInterpreter.generateMXMLProperties(this,
- this.get_MXMLProperties());
-
- this.dispatchEvent('initialize');
-
- this.initialView.addToParent(this.element);
- this.initialView.initUI(this.model);
-
- this.dispatchEvent('viewChanged');
-};
-
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/114aeec9/frameworks/js/FlexJS/src/org/apache/flex/jquery/staticControls/RadioButton.js
----------------------------------------------------------------------
diff --git a/frameworks/js/FlexJS/src/org/apache/flex/jquery/staticControls/RadioButton.js b/frameworks/js/FlexJS/src/org/apache/flex/jquery/staticControls/RadioButton.js
index 35d2371..db85bf9 100644
--- a/frameworks/js/FlexJS/src/org/apache/flex/jquery/staticControls/RadioButton.js
+++ b/frameworks/js/FlexJS/src/org/apache/flex/jquery/staticControls/RadioButton.js
@@ -16,39 +16,114 @@ goog.provide('org.apache.flex.jquery.staticControls.RadioButton');
goog.require('org.apache.flex.core.UIBase');
-
-
/**
* @constructor
* @extends {org.apache.flex.core.UIBase}
*/
org.apache.flex.jquery.staticControls.RadioButton = function() {
+
goog.base(this);
+
+ org.apache.flex.core.UIBase.call(this);
+ org.apache.flex.jquery.staticControls.RadioButton.radioCounter++;
};
goog.inherits(org.apache.flex.jquery.staticControls.RadioButton,
org.apache.flex.core.UIBase);
/**
+ * @expose
+ * @this {org.apache.flex.jquery.staticControls.RadioButton}
+ * The name of the radioGroup.
+ */
+org.apache.flex.jquery.staticControls.RadioButton.prototype.radioGroupName;
+
+/**
+ * @expose
+ * @this {org.apache.flex.jquery.staticControls.RadioButton}
+ * Used to provide ids to the radio buttons.
+ */
+org.apache.flex.jquery.staticControls.RadioButton.radioCounter = 0;
+
+/**
+ * @expose
+ * @this {org.apache.flex.jquery.staticControls.RadioButton}
+ * Used to manage groups on the radio buttons.
+ */
+org.apache.flex.jquery.staticControls.RadioButton.groups = { };
+
+/**
+ * @this {org.apache.flex.jquery.staticControls.RadioButton}
+ * Flag to make sure the event handler is set only once.
+ */
+org.apache.flex.jquery.staticControls.RadioButton.groupHandlerSet = false;
+
+/**
* @override
* @this {org.apache.flex.jquery.staticControls.RadioButton}
* @param {Object} p The parent element.
*/
org.apache.flex.jquery.staticControls.RadioButton.prototype.addToParent =
function(p) {
- var rb;
- this.element = document.createElement('label');
+ var input = document.createElement('input');
+ input.type = 'radio';
+ input.name = 'radio';
+ input.id = 'radio'+org.apache.flex.jquery.staticControls.RadioButton.radioCounter;
+
+ var label = document.createElement('label');
+ label.htmlFor = input.id;
+
+ p.appendChild(input);
+ p.appendChild(label);
+
+ this.element = input;
+ this.labelFor = label;
- rb = document.createElement('input');
- rb.type = 'radio';
- $(rb).button();
- this.element.appendChild(rb);
- this.element.appendChild(document.createTextNode('radio button'));
+ this.positioner = this.element;
+};
- p.appendChild(this.element);
+/**
+ * @override
+ * @this {org.apache.flex.jquery.staticControls.RadioButton}
+ * @param {Object} doc the document for this item
+ */
+org.apache.flex.jquery.staticControls.RadioButton.prototype.setDocument =
+function(doc, id) {
+ if( ! org.apache.flex.jquery.staticControls.RadioButton.groupHandlerSet ) {
+ org.apache.flex.jquery.staticControls.RadioButton.groupHandlerSet = true;
+ doc.addEventListener("initComplete",goog.bind(this.initCompleteHandler, this));
+ }
+}
- this.positioner = this.element;
+/**
+ * @this {org.apache.flex.jquery.staticControls.RadioButton}
+ * @param {Event} event The event.
+ */
+org.apache.flex.jquery.staticControls.RadioButton.prototype.initCompleteHandler =
+function(event) {
+ var divtags = org.apache.flex.jquery.staticControls.RadioButton.groups;
+ for(var name in divtags)
+ {
+ var div = divtags[name];
+ $(div).buttonset();
+ }
+}
+
+/**
+ * @expose
+ * @this {org.apache.flex.jquery.staticControls.RadioButton}
+ */
+org.apache.flex.jquery.staticControls.RadioButton.prototype.initModel =
+function() {
+};
+
+/**
+ * @expose
+ * @this {org.apache.flex.jquery.staticControls.RadioButton}
+ */
+org.apache.flex.jquery.staticControls.RadioButton.prototype.initSkin =
+function() {
};
@@ -57,9 +132,8 @@ org.apache.flex.jquery.staticControls.RadioButton.prototype.addToParent =
* @this {org.apache.flex.jquery.staticControls.RadioButton}
* @return {string} The groupName getter.
*/
-org.apache.flex.jquery.staticControls.RadioButton.prototype.get_groupName =
- function() {
- return this.element.childNodes.item(0).name;
+org.apache.flex.jquery.staticControls.RadioButton.prototype.get_groupName = function() {
+ return this.radioGroupName;
};
@@ -68,9 +142,39 @@ org.apache.flex.jquery.staticControls.RadioButton.prototype.get_groupName =
* @this {org.apache.flex.jquery.staticControls.RadioButton}
* @param {string} value The groupName setter.
*/
-org.apache.flex.jquery.staticControls.RadioButton.prototype.set_groupName =
- function(value) {
- this.element.childNodes.item(0).name = value;
+org.apache.flex.jquery.staticControls.RadioButton.prototype.set_groupName = function(value) {
+
+/*
+ * NOTE: Ideally when a RadioButton was created it would be added to an existing set of RadioButtons.
+ * This is especially true for RadioButtons added dynamically. However, due to a bug in jQuery
+ * (see http://bugs.jqueryui.com/ticket/8975), it is currently not possible to add or remove RadioButtons
+ * programmatically. For this version the groups are maintained here in RadioButton and once the
+ * application has finished initializing, the groups are given their buttonset().
+ */
+
+ this.radioGroupName = value;
+
+ this.element.name = value;
+
+ var div;
+
+ if( org.apache.flex.jquery.staticControls.RadioButton.groups[value] ) {
+ div = org.apache.flex.jquery.staticControls.RadioButton.groups[value];
+ div.appendChild(this.element);
+ div.appendChild(this.labelFor);
+ }
+ else {
+ var p = this.element.parentElement;
+ div = document.createElement('div');
+ div.id = value;
+ div.appendChild(this.element);
+ div.appendChild(this.labelFor);
+ p.appendChild(div);
+
+ org.apache.flex.jquery.staticControls.RadioButton.groups[String(value)] = div;
+ }
+
+ this.positioner = div;
};
@@ -79,9 +183,8 @@ org.apache.flex.jquery.staticControls.RadioButton.prototype.set_groupName =
* @this {org.apache.flex.jquery.staticControls.RadioButton}
* @return {string} The text getter.
*/
-org.apache.flex.jquery.staticControls.RadioButton.prototype.get_text =
- function() {
- return this.element.childNodes.item(1).nodeValue;
+org.apache.flex.jquery.staticControls.RadioButton.prototype.get_text = function() {
+ return this.labelFor.innerHTML;
};
@@ -90,9 +193,8 @@ org.apache.flex.jquery.staticControls.RadioButton.prototype.get_text =
* @this {org.apache.flex.jquery.staticControls.RadioButton}
* @param {string} value The text setter.
*/
-org.apache.flex.jquery.staticControls.RadioButton.prototype.set_text =
- function(value) {
- this.element.childNodes.item(1).nodeValue = value;
+org.apache.flex.jquery.staticControls.RadioButton.prototype.set_text = function(value) {
+ this.labelFor.innerHTML = value;
};
@@ -101,9 +203,8 @@ org.apache.flex.jquery.staticControls.RadioButton.prototype.set_text =
* @this {org.apache.flex.jquery.staticControls.RadioButton}
* @return {bool} The selected getter.
*/
-org.apache.flex.jquery.staticControls.RadioButton.prototype.get_selected =
- function() {
- return this.element.childNodes.item(0).checked;
+org.apache.flex.jquery.staticControls.RadioButton.prototype.get_selected = function() {
+ return this.element.checked;
};
@@ -112,7 +213,6 @@ org.apache.flex.jquery.staticControls.RadioButton.prototype.get_selected =
* @this {org.apache.flex.jquery.staticControls.RadioButton}
* @param {bool} value The selected setter.
*/
-org.apache.flex.jquery.staticControls.RadioButton.prototype.set_selected =
- function(value) {
- this.element.childNodes.item(0).checked = value;
+org.apache.flex.jquery.staticControls.RadioButton.prototype.set_selected = function(value) {
+ this.element.checked = value;
};
Re: git commit: [flex-asjs] [refs/heads/develop] - RadioButtons for
jQuery. RadioButtons cannot be programmatically added due to a known jQuery
bug (documented in the RadioButton.js file).
Posted by Peter Ent <pe...@adobe.com>.
The jQuery JS files do not get injected - you have to do it manually. I
will check in my sample today and the instructions are in the main
app.mxml file.
--peter
On 5/9/13 5:04 PM, "Alex Harui" <ah...@adobe.com> wrote:
>Excellent.
>
>One question though: if you took out jquery.Application, how do the Jquery
>JS files get injected?
>
>-Alex
>
>
>On 5/9/13 1:33 PM, "pent@apache.org" <pe...@apache.org> wrote:
>
>> Updated Branches:
>> refs/heads/develop 0991467eb -> 114aeec95
>>
>>
>> RadioButtons for jQuery. RadioButtons cannot be programmatically added
>>due to
>> a known jQuery bug (documented in the RadioButton.js file).
>>
>>
>> Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo
>> Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/114aeec9
>> Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/114aeec9
>> Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/114aeec9
>>
>> Branch: refs/heads/develop
>> Commit: 114aeec95635a765abc6e527517de984cd2dfadd
>> Parents: 0991467
>> Author: Peter Ent <pe...@apache.org>
>> Authored: Thu May 9 16:33:01 2013 -0400
>> Committer: Peter Ent <pe...@apache.org>
>> Committed: Thu May 9 16:33:01 2013 -0400
>>
>> ----------------------------------------------------------------------
>> frameworks/as/jquery-manifest.xml | 1 -
>> .../apache/flex/html/staticControls/RadioButton.as | 6 +
>> .../as/src/org/apache/flex/jquery/Application.as | 43 ----
>> .../flex/jquery/staticControls/RadioButton.as | 4 +
>> .../org/apache/flex/html/staticControls/Label.js | 14 ++
>> .../apache/flex/html/staticControls/RadioButton.js | 16 ++
>> .../src/org/apache/flex/jquery/Application.js | 114 -----------
>> .../flex/jquery/staticControls/RadioButton.js | 158
>>++++++++++++---
>> 8 files changed, 169 insertions(+), 187 deletions(-)
>> ----------------------------------------------------------------------
>>
>>
>>
>>http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/114aeec9/frameworks
>>/as/j
>> query-manifest.xml
>> ----------------------------------------------------------------------
>> diff --git a/frameworks/as/jquery-manifest.xml
>> b/frameworks/as/jquery-manifest.xml
>> index cdb9dd5..d760aff 100644
>> --- a/frameworks/as/jquery-manifest.xml
>> +++ b/frameworks/as/jquery-manifest.xml
>> @@ -21,7 +21,6 @@
>>
>> <componentPackage>
>>
>> - <component id="Application"
>>class="org.apache.flex.jquery.Application"/>
>> <component id="TextButton"
>> class="org.apache.flex.jquery.staticControls.TextButton"/>
>> <component id="CheckBox"
>> class="org.apache.flex.jquery.staticControls.CheckBox"/>
>> <component id="RadioButton"
>> class="org.apache.flex.jquery.staticControls.RadioButton"/>
>>
>>
>>http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/114aeec9/frameworks
>>/as/s
>> rc/org/apache/flex/html/staticControls/RadioButton.as
>> ----------------------------------------------------------------------
>> diff --git
>> a/frameworks/as/src/org/apache/flex/html/staticControls/RadioButton.as
>> b/frameworks/as/src/org/apache/flex/html/staticControls/RadioButton.as
>> index 0aee02b..a6caf5b 100644
>> ---
>>a/frameworks/as/src/org/apache/flex/html/staticControls/RadioButton.as
>> +++
>>b/frameworks/as/src/org/apache/flex/html/staticControls/RadioButton.as
>> @@ -19,6 +19,7 @@
>> package org.apache.flex.html.staticControls
>> {
>> import flash.display.DisplayObject;
>> + import flash.display.DisplayObjectContainer;
>> import flash.display.SimpleButton;
>> import flash.events.MouseEvent;
>> import flash.utils.Dictionary;
>> @@ -111,6 +112,11 @@ package org.apache.flex.html.staticControls
>> IValueToggleButtonModel(model).selectedValue =
>> newValue;
>> }
>>
>> + public function
>>addToParent(p:DisplayObjectContainer):void
>> + {
>> + p.addChild(this);
>> + }
>> +
>> public function initModel():void
>> {
>> if (getBeadByType(IValueToggleButtonModel) ==
>>null)
>>
>>
>>http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/114aeec9/frameworks
>>/as/s
>> rc/org/apache/flex/jquery/Application.as
>> ----------------------------------------------------------------------
>> diff --git a/frameworks/as/src/org/apache/flex/jquery/Application.as
>> b/frameworks/as/src/org/apache/flex/jquery/Application.as
>> deleted file mode 100644
>> index 5801d07..0000000
>> --- a/frameworks/as/src/org/apache/flex/jquery/Application.as
>> +++ /dev/null
>> @@ -1,43 +0,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.
>> -//
>>
>>-////////////////////////////////////////////////////////////////////////
>>/////
>> ///
>> -package org.apache.flex.jquery
>> -{
>> - import flash.display.Sprite;
>> - import flash.display.StageAlign;
>> - import flash.display.StageScaleMode;
>> - import flash.events.IOErrorEvent;
>> -
>> - import org.apache.flex.core.Application;
>> - import org.apache.flex.core.IFlexInfo;
>> - import org.apache.flex.events.Event;
>> - import org.apache.flex.utils.MXMLDataInterpreter;
>> -
>> - //--------------------------------------
>> - // Events
>> - //--------------------------------------
>> -
>> - /**
>> - * Dispatched at startup.
>> - */
>> - [Event(name="initialize", type="org.apache.flex.events.Event")]
>> -
>> - public class Application extends org.apache.flex.core.Application
>> implements IFlexInfo
>> - {
>> - }
>> -}
>> \ No newline at end of file
>>
>>
>>http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/114aeec9/frameworks
>>/as/s
>> rc/org/apache/flex/jquery/staticControls/RadioButton.as
>> ----------------------------------------------------------------------
>> diff --git
>> a/frameworks/as/src/org/apache/flex/jquery/staticControls/RadioButton.as
>> b/frameworks/as/src/org/apache/flex/jquery/staticControls/RadioButton.as
>> index a94739a..aac1ad5 100644
>> ---
>>a/frameworks/as/src/org/apache/flex/jquery/staticControls/RadioButton.as
>> +++
>>b/frameworks/as/src/org/apache/flex/jquery/staticControls/RadioButton.as
>> @@ -22,5 +22,9 @@ package org.apache.flex.jquery.staticControls
>>
>> public class RadioButton extends
>> org.apache.flex.html.staticControls.RadioButton
>> {
>> + override public function initModel():void
>> + {
>> + super.initModel();
>> + }
>> }
>> }
>> \ No newline at end of file
>>
>>
>>http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/114aeec9/frameworks
>>/js/F
>> lexJS/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 875607a..55d1361 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
>> @@ -40,6 +40,20 @@
>> org.apache.flex.html.staticControls.Label.prototype.addToParent =
>>function(p)
>> {
>> this.positioner = this.element;
>> };
>>
>> +/**
>> + * @expose
>> + * @this {org.apache.flex.html.staticControls.Label}
>> + */
>> +org.apache.flex.html.staticControls.Label.prototype.initModel =
>>function() {
>> +};
>> +/**
>> + * @expose
>> + * @this {org.apache.flex.html.staticControls.Label}
>> + */
>> +org.apache.flex.html.staticControls.Label.prototype.initSkin =
>>function() {
>> +
>> +};
>> +
>>
>> /**
>> * @expose
>>
>>
>>http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/114aeec9/frameworks
>>/js/F
>> lexJS/src/org/apache/flex/html/staticControls/RadioButton.js
>> ----------------------------------------------------------------------
>> diff --git
>>
>>a/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/RadioButto
>>n.js
>>
>>b/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/RadioButto
>>n.js
>> index fb657b2..e8f67d6 100644
>> ---
>>
>>a/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/RadioButto
>>n.js
>> +++
>>
>>b/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/RadioButto
>>n.js
>> @@ -51,6 +51,22 @@
>> org.apache.flex.html.staticControls.RadioButton.prototype.addToParent =
>> rb.flexjs_wrapper = this;
>> };
>>
>> +/**
>> + * @expose
>> + * @this {org.apache.flex.html.staticControls.RadioButton}
>> + */
>> +org.apache.flex.html.staticControls.RadioButton.prototype.initModel =
>> +function() {
>> +};
>> +
>> +/**
>> + * @expose
>> + * @this {org.apache.flex.html.staticControls.RadioButton}
>> + */
>> +org.apache.flex.html.staticControls.RadioButton.prototype.initSkin =
>> +function() {
>> +};
>> +
>>
>> /**
>> * @expose
>>
>>
>>http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/114aeec9/frameworks
>>/js/F
>> lexJS/src/org/apache/flex/jquery/Application.js
>> ----------------------------------------------------------------------
>> diff --git
>>a/frameworks/js/FlexJS/src/org/apache/flex/jquery/Application.js
>> b/frameworks/js/FlexJS/src/org/apache/flex/jquery/Application.js
>> deleted file mode 100644
>> index e6eb0f8..0000000
>> --- a/frameworks/js/FlexJS/src/org/apache/flex/jquery/Application.js
>> +++ /dev/null
>> @@ -1,114 +0,0 @@
>> -/**
>> - * 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.
>> - */
>> -
>> -// ------------------------------------------------------------------
>> -// jQuery
>> -// ------------------------------------------------------------------
>> -
>> -// (erikdebruin) do these have to be in the global namespace?
>> -var head, link, mainjs, uijs;
>> -
>> -// Bring in the jQuery sources. You can use the minified versions for
>> -// better performance.
>> -mainjs = document.createElement('script');
>> -/** @type {Object} */ mainjs.src =
>>'http://code.jquery.com/jquery-1.9.1.js';
>> -document.head.appendChild(mainjs);
>> -
>> -uijs = document.createElement('script');
>> -/** @type {Object} */ uijs.src =
>> - 'http://code.jquery.com/ui/1.10.2/jquery-ui.js';
>> -document.head.appendChild(uijs);
>> -
>> -// create a stylesheet link to the corresponding jquery theme file.
>> -head = document.getElementsByTagName('head')[0];
>> -link = document.createElement('link');
>> -/** @type {Object} */ link.id = 'jquerycss';
>> -/** @type {Object} */ link.rel = 'stylesheet';
>> -/** @type {Object} */ link.type = 'text/css';
>> -/** @type {Object} */ link.href =
>> - 'http://code.jquery.com/ui/1.10.2/themes/smoothness/jquery-ui.css';
>> -/** @type {Object} */ link.media = 'all';
>> -head.appendChild(link);
>> -
>> -// ------------------------------------------------------------------
>> -// end jQuery
>> -// ------------------------------------------------------------------
>> -
>> -goog.provide('org.apache.flex.jquery.Application');
>> -
>> -goog.require('org.apache.flex.core.HTMLElementWrapper');
>> -goog.require('org.apache.flex.utils.MXMLDataInterpreter');
>> -
>> -
>> -
>> -/**
>> - * @constructor
>> - * @extends {org.apache.flex.core.HTMLElementWrapper}
>> - */
>> -org.apache.flex.jquery.Application = function() {
>> - goog.base(this);
>> -
>> -};
>> -goog.inherits(org.apache.flex.jquery.Application,
>> - org.apache.flex.core.HTMLElementWrapper);
>> -
>> -
>> -/**
>> - * @expose
>> - * @type {Object}
>> - */
>> -org.apache.flex.jquery.Application.prototype.controller = null;
>> -
>> -
>> -/**
>> - * @expose
>> - * @type {org.apache.flex.core.ViewBase}
>> - */
>> -org.apache.flex.jquery.Application.prototype.initialView = null;
>> -
>> -
>> -/**
>> - * @expose
>> - * @type {org.apache.flex.events.EventDispatcher}
>> - */
>> -org.apache.flex.jquery.Application.prototype.model = null;
>> -
>> -
>> -/**
>> - * @expose
>> - * @type {org.apache.flex.core.SimpleValuesImpl}
>> - */
>> -org.apache.flex.jquery.Application.prototype.valuesImpl = null;
>> -
>> -
>> -/**
>> - * @expose
>> - * @this {org.apache.flex.jquery.Application}
>> - */
>> -org.apache.flex.jquery.Application.prototype.start = function() {
>> - var evt, i, n, q;
>> -
>> - this.element = document.getElementsByTagName('body')[0];
>> -
>> -
>>org.apache.flex.utils.MXMLDataInterpreter.generateMXMLProperties(this,
>> - this.get_MXMLProperties());
>> -
>> - this.dispatchEvent('initialize');
>> -
>> - this.initialView.addToParent(this.element);
>> - this.initialView.initUI(this.model);
>> -
>> - this.dispatchEvent('viewChanged');
>> -};
>> -
>>
>>
>>http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/114aeec9/frameworks
>>/js/F
>> lexJS/src/org/apache/flex/jquery/staticControls/RadioButton.js
>> ----------------------------------------------------------------------
>> diff --git
>>
>>a/frameworks/js/FlexJS/src/org/apache/flex/jquery/staticControls/RadioBut
>>ton.j
>> s
>>
>b/frameworks/js/FlexJS/src/org/apache/flex/jquery/staticControls/RadioButt
>on.j>
>s
>> index 35d2371..db85bf9 100644
>> ---
>>
>a/frameworks/js/FlexJS/src/org/apache/flex/jquery/staticControls/RadioButt
>on.j>
>s
>> +++
>>
>b/frameworks/js/FlexJS/src/org/apache/flex/jquery/staticControls/RadioButt
>on.j>
>s
>> @@ -16,39 +16,114 @@
>> goog.provide('org.apache.flex.jquery.staticControls.RadioButton');
>>
>> goog.require('org.apache.flex.core.UIBase');
>>
>> -
>> -
>> /**
>> * @constructor
>> * @extends {org.apache.flex.core.UIBase}
>> */
>> org.apache.flex.jquery.staticControls.RadioButton = function() {
>> +
>> goog.base(this);
>> +
>> + org.apache.flex.core.UIBase.call(this);
>> + org.apache.flex.jquery.staticControls.RadioButton.radioCounter++;
>> };
>> goog.inherits(org.apache.flex.jquery.staticControls.RadioButton,
>> org.apache.flex.core.UIBase);
>>
>>
>> /**
>> + * @expose
>> + * @this {org.apache.flex.jquery.staticControls.RadioButton}
>> + * The name of the radioGroup.
>> + */
>>
>>+org.apache.flex.jquery.staticControls.RadioButton.prototype.radioGroupNa
>>me;
>> +
>> +/**
>> + * @expose
>> + * @this {org.apache.flex.jquery.staticControls.RadioButton}
>> + * Used to provide ids to the radio buttons.
>> + */
>> +org.apache.flex.jquery.staticControls.RadioButton.radioCounter = 0;
>> +
>> +/**
>> + * @expose
>> + * @this {org.apache.flex.jquery.staticControls.RadioButton}
>> + * Used to manage groups on the radio buttons.
>> + */
>> +org.apache.flex.jquery.staticControls.RadioButton.groups = { };
>> +
>> +/**
>> + * @this {org.apache.flex.jquery.staticControls.RadioButton}
>> + * Flag to make sure the event handler is set only once.
>> + */
>> +org.apache.flex.jquery.staticControls.RadioButton.groupHandlerSet =
>>false;
>> +
>> +/**
>> * @override
>> * @this {org.apache.flex.jquery.staticControls.RadioButton}
>> * @param {Object} p The parent element.
>> */
>>
>>org.apache.flex.jquery.staticControls.RadioButton.prototype.addToParent =
>> function(p) {
>> - var rb;
>>
>> - this.element = document.createElement('label');
>> + var input = document.createElement('input');
>> + input.type = 'radio';
>> + input.name = 'radio';
>> + input.id =
>> 'radio'+org.apache.flex.jquery.staticControls.RadioButton.radioCounter;
>> +
>> + var label = document.createElement('label');
>> + label.htmlFor = input.id;
>> +
>> + p.appendChild(input);
>> + p.appendChild(label);
>> +
>> + this.element = input;
>> + this.labelFor = label;
>>
>> - rb = document.createElement('input');
>> - rb.type = 'radio';
>> - $(rb).button();
>> - this.element.appendChild(rb);
>> - this.element.appendChild(document.createTextNode('radio button'));
>> + this.positioner = this.element;
>> +};
>>
>> - p.appendChild(this.element);
>> +/**
>> + * @override
>> + * @this {org.apache.flex.jquery.staticControls.RadioButton}
>> + * @param {Object} doc the document for this item
>> + */
>>
>>+org.apache.flex.jquery.staticControls.RadioButton.prototype.setDocument
>>=
>> +function(doc, id) {
>> + if( !
>> org.apache.flex.jquery.staticControls.RadioButton.groupHandlerSet ) {
>> +
>> org.apache.flex.jquery.staticControls.RadioButton.groupHandlerSet =
>>true;
>> +
>> doc.addEventListener("initComplete",goog.bind(this.initCompleteHandler,
>> this));
>> + }
>> +}
>>
>> - this.positioner = this.element;
>> +/**
>> + * @this {org.apache.flex.jquery.staticControls.RadioButton}
>> + * @param {Event} event The event.
>> + */
>>
>>+org.apache.flex.jquery.staticControls.RadioButton.prototype.initComplete
>>Handl
>> er =
>> +function(event) {
>> + var divtags =
>> org.apache.flex.jquery.staticControls.RadioButton.groups;
>> + for(var name in divtags)
>> + {
>> + var div = divtags[name];
>> + $(div).buttonset();
>> + }
>> +}
>> +
>> +/**
>> + * @expose
>> + * @this {org.apache.flex.jquery.staticControls.RadioButton}
>> + */
>> +org.apache.flex.jquery.staticControls.RadioButton.prototype.initModel =
>> +function() {
>> +};
>> +
>> +/**
>> + * @expose
>> + * @this {org.apache.flex.jquery.staticControls.RadioButton}
>> + */
>> +org.apache.flex.jquery.staticControls.RadioButton.prototype.initSkin =
>> +function() {
>> };
>>
>>
>> @@ -57,9 +132,8 @@
>> org.apache.flex.jquery.staticControls.RadioButton.prototype.addToParent
>>=
>> * @this {org.apache.flex.jquery.staticControls.RadioButton}
>> * @return {string} The groupName getter.
>> */
>>
>>-org.apache.flex.jquery.staticControls.RadioButton.prototype.get_groupNam
>>e =
>> - function() {
>> - return this.element.childNodes.item(0).name;
>>
>>+org.apache.flex.jquery.staticControls.RadioButton.prototype.get_groupNam
>>e =
>> function() {
>> + return this.radioGroupName;
>> };
>>
>>
>> @@ -68,9 +142,39 @@
>>
>>org.apache.flex.jquery.staticControls.RadioButton.prototype.get_groupName
>> =
>> * @this {org.apache.flex.jquery.staticControls.RadioButton}
>> * @param {string} value The groupName setter.
>> */
>>
>>-org.apache.flex.jquery.staticControls.RadioButton.prototype.set_groupNam
>>e =
>> - function(value) {
>> - this.element.childNodes.item(0).name = value;
>>
>>+org.apache.flex.jquery.staticControls.RadioButton.prototype.set_groupNam
>>e =
>> function(value) {
>> +
>> +/*
>> + * NOTE: Ideally when a RadioButton was created it would be added to an
>> existing set of RadioButtons.
>> + * This is especially true for RadioButtons added dynamically.
>>However, due
>> to a bug in jQuery
>> + * (see http://bugs.jqueryui.com/ticket/8975), it is currently not
>>possible
>> to add or remove RadioButtons
>> + * programmatically. For this version the groups are maintained here in
>> RadioButton and once the
>> + * application has finished initializing, the groups are given their
>> buttonset().
>> + */
>> +
>> + this.radioGroupName = value;
>> +
>> + this.element.name = value;
>> +
>> + var div;
>> +
>> + if(
>>org.apache.flex.jquery.staticControls.RadioButton.groups[value] )
>> {
>> + div =
>> org.apache.flex.jquery.staticControls.RadioButton.groups[value];
>> + div.appendChild(this.element);
>> + div.appendChild(this.labelFor);
>> + }
>> + else {
>> + var p = this.element.parentElement;
>> + div = document.createElement('div');
>> + div.id = value;
>> + div.appendChild(this.element);
>> + div.appendChild(this.labelFor);
>> + p.appendChild(div);
>> +
>> +
>> org.apache.flex.jquery.staticControls.RadioButton.groups[String(value)]
>>= div;
>> + }
>> +
>> + this.positioner = div;
>> };
>>
>>
>> @@ -79,9 +183,8 @@
>>
>>org.apache.flex.jquery.staticControls.RadioButton.prototype.set_groupName
>> =
>> * @this {org.apache.flex.jquery.staticControls.RadioButton}
>> * @return {string} The text getter.
>> */
>> -org.apache.flex.jquery.staticControls.RadioButton.prototype.get_text =
>> - function() {
>> - return this.element.childNodes.item(1).nodeValue;
>> +org.apache.flex.jquery.staticControls.RadioButton.prototype.get_text =
>> function() {
>> + return this.labelFor.innerHTML;
>> };
>>
>>
>> @@ -90,9 +193,8 @@
>> org.apache.flex.jquery.staticControls.RadioButton.prototype.get_text =
>> * @this {org.apache.flex.jquery.staticControls.RadioButton}
>> * @param {string} value The text setter.
>> */
>> -org.apache.flex.jquery.staticControls.RadioButton.prototype.set_text =
>> - function(value) {
>> - this.element.childNodes.item(1).nodeValue = value;
>> +org.apache.flex.jquery.staticControls.RadioButton.prototype.set_text =
>> function(value) {
>> + this.labelFor.innerHTML = value;
>> };
>>
>>
>> @@ -101,9 +203,8 @@
>> org.apache.flex.jquery.staticControls.RadioButton.prototype.set_text =
>> * @this {org.apache.flex.jquery.staticControls.RadioButton}
>> * @return {bool} The selected getter.
>> */
>>
>>-org.apache.flex.jquery.staticControls.RadioButton.prototype.get_selected
>> =
>> - function() {
>> - return this.element.childNodes.item(0).checked;
>>
>>+org.apache.flex.jquery.staticControls.RadioButton.prototype.get_selected
>> =
>> function() {
>> + return this.element.checked;
>> };
>>
>>
>> @@ -112,7 +213,6 @@
>>
>>org.apache.flex.jquery.staticControls.RadioButton.prototype.get_selected
>>=
>> * @this {org.apache.flex.jquery.staticControls.RadioButton}
>> * @param {bool} value The selected setter.
>> */
>>
>>-org.apache.flex.jquery.staticControls.RadioButton.prototype.set_selected
>> =
>> - function(value) {
>> - this.element.childNodes.item(0).checked = value;
>>
>>+org.apache.flex.jquery.staticControls.RadioButton.prototype.set_selected
>> =
>> function(value) {
>> + this.element.checked = value;
>> };
>>
>
>--
>Alex Harui
>Flex SDK Team
>Adobe Systems, Inc.
>http://blogs.adobe.com/aharui
>
Re: git commit: [flex-asjs] [refs/heads/develop] - RadioButtons for
jQuery. RadioButtons cannot be programmatically added due to a known jQuery
bug (documented in the RadioButton.js file).
Posted by Peter Ent <pe...@adobe.com>.
The jQuery JS files do not get injected - you have to do it manually. I
will check in my sample today and the instructions are in the main
app.mxml file.
--peter
On 5/9/13 5:04 PM, "Alex Harui" <ah...@adobe.com> wrote:
>Excellent.
>
>One question though: if you took out jquery.Application, how do the Jquery
>JS files get injected?
>
>-Alex
>
>
>On 5/9/13 1:33 PM, "pent@apache.org" <pe...@apache.org> wrote:
>
>> Updated Branches:
>> refs/heads/develop 0991467eb -> 114aeec95
>>
>>
>> RadioButtons for jQuery. RadioButtons cannot be programmatically added
>>due to
>> a known jQuery bug (documented in the RadioButton.js file).
>>
>>
>> Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo
>> Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/114aeec9
>> Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/114aeec9
>> Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/114aeec9
>>
>> Branch: refs/heads/develop
>> Commit: 114aeec95635a765abc6e527517de984cd2dfadd
>> Parents: 0991467
>> Author: Peter Ent <pe...@apache.org>
>> Authored: Thu May 9 16:33:01 2013 -0400
>> Committer: Peter Ent <pe...@apache.org>
>> Committed: Thu May 9 16:33:01 2013 -0400
>>
>> ----------------------------------------------------------------------
>> frameworks/as/jquery-manifest.xml | 1 -
>> .../apache/flex/html/staticControls/RadioButton.as | 6 +
>> .../as/src/org/apache/flex/jquery/Application.as | 43 ----
>> .../flex/jquery/staticControls/RadioButton.as | 4 +
>> .../org/apache/flex/html/staticControls/Label.js | 14 ++
>> .../apache/flex/html/staticControls/RadioButton.js | 16 ++
>> .../src/org/apache/flex/jquery/Application.js | 114 -----------
>> .../flex/jquery/staticControls/RadioButton.js | 158
>>++++++++++++---
>> 8 files changed, 169 insertions(+), 187 deletions(-)
>> ----------------------------------------------------------------------
>>
>>
>>
>>http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/114aeec9/frameworks
>>/as/j
>> query-manifest.xml
>> ----------------------------------------------------------------------
>> diff --git a/frameworks/as/jquery-manifest.xml
>> b/frameworks/as/jquery-manifest.xml
>> index cdb9dd5..d760aff 100644
>> --- a/frameworks/as/jquery-manifest.xml
>> +++ b/frameworks/as/jquery-manifest.xml
>> @@ -21,7 +21,6 @@
>>
>> <componentPackage>
>>
>> - <component id="Application"
>>class="org.apache.flex.jquery.Application"/>
>> <component id="TextButton"
>> class="org.apache.flex.jquery.staticControls.TextButton"/>
>> <component id="CheckBox"
>> class="org.apache.flex.jquery.staticControls.CheckBox"/>
>> <component id="RadioButton"
>> class="org.apache.flex.jquery.staticControls.RadioButton"/>
>>
>>
>>http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/114aeec9/frameworks
>>/as/s
>> rc/org/apache/flex/html/staticControls/RadioButton.as
>> ----------------------------------------------------------------------
>> diff --git
>> a/frameworks/as/src/org/apache/flex/html/staticControls/RadioButton.as
>> b/frameworks/as/src/org/apache/flex/html/staticControls/RadioButton.as
>> index 0aee02b..a6caf5b 100644
>> ---
>>a/frameworks/as/src/org/apache/flex/html/staticControls/RadioButton.as
>> +++
>>b/frameworks/as/src/org/apache/flex/html/staticControls/RadioButton.as
>> @@ -19,6 +19,7 @@
>> package org.apache.flex.html.staticControls
>> {
>> import flash.display.DisplayObject;
>> + import flash.display.DisplayObjectContainer;
>> import flash.display.SimpleButton;
>> import flash.events.MouseEvent;
>> import flash.utils.Dictionary;
>> @@ -111,6 +112,11 @@ package org.apache.flex.html.staticControls
>> IValueToggleButtonModel(model).selectedValue =
>> newValue;
>> }
>>
>> + public function
>>addToParent(p:DisplayObjectContainer):void
>> + {
>> + p.addChild(this);
>> + }
>> +
>> public function initModel():void
>> {
>> if (getBeadByType(IValueToggleButtonModel) ==
>>null)
>>
>>
>>http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/114aeec9/frameworks
>>/as/s
>> rc/org/apache/flex/jquery/Application.as
>> ----------------------------------------------------------------------
>> diff --git a/frameworks/as/src/org/apache/flex/jquery/Application.as
>> b/frameworks/as/src/org/apache/flex/jquery/Application.as
>> deleted file mode 100644
>> index 5801d07..0000000
>> --- a/frameworks/as/src/org/apache/flex/jquery/Application.as
>> +++ /dev/null
>> @@ -1,43 +0,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.
>> -//
>>
>>-////////////////////////////////////////////////////////////////////////
>>/////
>> ///
>> -package org.apache.flex.jquery
>> -{
>> - import flash.display.Sprite;
>> - import flash.display.StageAlign;
>> - import flash.display.StageScaleMode;
>> - import flash.events.IOErrorEvent;
>> -
>> - import org.apache.flex.core.Application;
>> - import org.apache.flex.core.IFlexInfo;
>> - import org.apache.flex.events.Event;
>> - import org.apache.flex.utils.MXMLDataInterpreter;
>> -
>> - //--------------------------------------
>> - // Events
>> - //--------------------------------------
>> -
>> - /**
>> - * Dispatched at startup.
>> - */
>> - [Event(name="initialize", type="org.apache.flex.events.Event")]
>> -
>> - public class Application extends org.apache.flex.core.Application
>> implements IFlexInfo
>> - {
>> - }
>> -}
>> \ No newline at end of file
>>
>>
>>http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/114aeec9/frameworks
>>/as/s
>> rc/org/apache/flex/jquery/staticControls/RadioButton.as
>> ----------------------------------------------------------------------
>> diff --git
>> a/frameworks/as/src/org/apache/flex/jquery/staticControls/RadioButton.as
>> b/frameworks/as/src/org/apache/flex/jquery/staticControls/RadioButton.as
>> index a94739a..aac1ad5 100644
>> ---
>>a/frameworks/as/src/org/apache/flex/jquery/staticControls/RadioButton.as
>> +++
>>b/frameworks/as/src/org/apache/flex/jquery/staticControls/RadioButton.as
>> @@ -22,5 +22,9 @@ package org.apache.flex.jquery.staticControls
>>
>> public class RadioButton extends
>> org.apache.flex.html.staticControls.RadioButton
>> {
>> + override public function initModel():void
>> + {
>> + super.initModel();
>> + }
>> }
>> }
>> \ No newline at end of file
>>
>>
>>http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/114aeec9/frameworks
>>/js/F
>> lexJS/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 875607a..55d1361 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
>> @@ -40,6 +40,20 @@
>> org.apache.flex.html.staticControls.Label.prototype.addToParent =
>>function(p)
>> {
>> this.positioner = this.element;
>> };
>>
>> +/**
>> + * @expose
>> + * @this {org.apache.flex.html.staticControls.Label}
>> + */
>> +org.apache.flex.html.staticControls.Label.prototype.initModel =
>>function() {
>> +};
>> +/**
>> + * @expose
>> + * @this {org.apache.flex.html.staticControls.Label}
>> + */
>> +org.apache.flex.html.staticControls.Label.prototype.initSkin =
>>function() {
>> +
>> +};
>> +
>>
>> /**
>> * @expose
>>
>>
>>http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/114aeec9/frameworks
>>/js/F
>> lexJS/src/org/apache/flex/html/staticControls/RadioButton.js
>> ----------------------------------------------------------------------
>> diff --git
>>
>>a/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/RadioButto
>>n.js
>>
>>b/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/RadioButto
>>n.js
>> index fb657b2..e8f67d6 100644
>> ---
>>
>>a/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/RadioButto
>>n.js
>> +++
>>
>>b/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/RadioButto
>>n.js
>> @@ -51,6 +51,22 @@
>> org.apache.flex.html.staticControls.RadioButton.prototype.addToParent =
>> rb.flexjs_wrapper = this;
>> };
>>
>> +/**
>> + * @expose
>> + * @this {org.apache.flex.html.staticControls.RadioButton}
>> + */
>> +org.apache.flex.html.staticControls.RadioButton.prototype.initModel =
>> +function() {
>> +};
>> +
>> +/**
>> + * @expose
>> + * @this {org.apache.flex.html.staticControls.RadioButton}
>> + */
>> +org.apache.flex.html.staticControls.RadioButton.prototype.initSkin =
>> +function() {
>> +};
>> +
>>
>> /**
>> * @expose
>>
>>
>>http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/114aeec9/frameworks
>>/js/F
>> lexJS/src/org/apache/flex/jquery/Application.js
>> ----------------------------------------------------------------------
>> diff --git
>>a/frameworks/js/FlexJS/src/org/apache/flex/jquery/Application.js
>> b/frameworks/js/FlexJS/src/org/apache/flex/jquery/Application.js
>> deleted file mode 100644
>> index e6eb0f8..0000000
>> --- a/frameworks/js/FlexJS/src/org/apache/flex/jquery/Application.js
>> +++ /dev/null
>> @@ -1,114 +0,0 @@
>> -/**
>> - * 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.
>> - */
>> -
>> -// ------------------------------------------------------------------
>> -// jQuery
>> -// ------------------------------------------------------------------
>> -
>> -// (erikdebruin) do these have to be in the global namespace?
>> -var head, link, mainjs, uijs;
>> -
>> -// Bring in the jQuery sources. You can use the minified versions for
>> -// better performance.
>> -mainjs = document.createElement('script');
>> -/** @type {Object} */ mainjs.src =
>>'http://code.jquery.com/jquery-1.9.1.js';
>> -document.head.appendChild(mainjs);
>> -
>> -uijs = document.createElement('script');
>> -/** @type {Object} */ uijs.src =
>> - 'http://code.jquery.com/ui/1.10.2/jquery-ui.js';
>> -document.head.appendChild(uijs);
>> -
>> -// create a stylesheet link to the corresponding jquery theme file.
>> -head = document.getElementsByTagName('head')[0];
>> -link = document.createElement('link');
>> -/** @type {Object} */ link.id = 'jquerycss';
>> -/** @type {Object} */ link.rel = 'stylesheet';
>> -/** @type {Object} */ link.type = 'text/css';
>> -/** @type {Object} */ link.href =
>> - 'http://code.jquery.com/ui/1.10.2/themes/smoothness/jquery-ui.css';
>> -/** @type {Object} */ link.media = 'all';
>> -head.appendChild(link);
>> -
>> -// ------------------------------------------------------------------
>> -// end jQuery
>> -// ------------------------------------------------------------------
>> -
>> -goog.provide('org.apache.flex.jquery.Application');
>> -
>> -goog.require('org.apache.flex.core.HTMLElementWrapper');
>> -goog.require('org.apache.flex.utils.MXMLDataInterpreter');
>> -
>> -
>> -
>> -/**
>> - * @constructor
>> - * @extends {org.apache.flex.core.HTMLElementWrapper}
>> - */
>> -org.apache.flex.jquery.Application = function() {
>> - goog.base(this);
>> -
>> -};
>> -goog.inherits(org.apache.flex.jquery.Application,
>> - org.apache.flex.core.HTMLElementWrapper);
>> -
>> -
>> -/**
>> - * @expose
>> - * @type {Object}
>> - */
>> -org.apache.flex.jquery.Application.prototype.controller = null;
>> -
>> -
>> -/**
>> - * @expose
>> - * @type {org.apache.flex.core.ViewBase}
>> - */
>> -org.apache.flex.jquery.Application.prototype.initialView = null;
>> -
>> -
>> -/**
>> - * @expose
>> - * @type {org.apache.flex.events.EventDispatcher}
>> - */
>> -org.apache.flex.jquery.Application.prototype.model = null;
>> -
>> -
>> -/**
>> - * @expose
>> - * @type {org.apache.flex.core.SimpleValuesImpl}
>> - */
>> -org.apache.flex.jquery.Application.prototype.valuesImpl = null;
>> -
>> -
>> -/**
>> - * @expose
>> - * @this {org.apache.flex.jquery.Application}
>> - */
>> -org.apache.flex.jquery.Application.prototype.start = function() {
>> - var evt, i, n, q;
>> -
>> - this.element = document.getElementsByTagName('body')[0];
>> -
>> -
>>org.apache.flex.utils.MXMLDataInterpreter.generateMXMLProperties(this,
>> - this.get_MXMLProperties());
>> -
>> - this.dispatchEvent('initialize');
>> -
>> - this.initialView.addToParent(this.element);
>> - this.initialView.initUI(this.model);
>> -
>> - this.dispatchEvent('viewChanged');
>> -};
>> -
>>
>>
>>http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/114aeec9/frameworks
>>/js/F
>> lexJS/src/org/apache/flex/jquery/staticControls/RadioButton.js
>> ----------------------------------------------------------------------
>> diff --git
>>
>>a/frameworks/js/FlexJS/src/org/apache/flex/jquery/staticControls/RadioBut
>>ton.j
>> s
>>
>b/frameworks/js/FlexJS/src/org/apache/flex/jquery/staticControls/RadioButt
>on.j>
>s
>> index 35d2371..db85bf9 100644
>> ---
>>
>a/frameworks/js/FlexJS/src/org/apache/flex/jquery/staticControls/RadioButt
>on.j>
>s
>> +++
>>
>b/frameworks/js/FlexJS/src/org/apache/flex/jquery/staticControls/RadioButt
>on.j>
>s
>> @@ -16,39 +16,114 @@
>> goog.provide('org.apache.flex.jquery.staticControls.RadioButton');
>>
>> goog.require('org.apache.flex.core.UIBase');
>>
>> -
>> -
>> /**
>> * @constructor
>> * @extends {org.apache.flex.core.UIBase}
>> */
>> org.apache.flex.jquery.staticControls.RadioButton = function() {
>> +
>> goog.base(this);
>> +
>> + org.apache.flex.core.UIBase.call(this);
>> + org.apache.flex.jquery.staticControls.RadioButton.radioCounter++;
>> };
>> goog.inherits(org.apache.flex.jquery.staticControls.RadioButton,
>> org.apache.flex.core.UIBase);
>>
>>
>> /**
>> + * @expose
>> + * @this {org.apache.flex.jquery.staticControls.RadioButton}
>> + * The name of the radioGroup.
>> + */
>>
>>+org.apache.flex.jquery.staticControls.RadioButton.prototype.radioGroupNa
>>me;
>> +
>> +/**
>> + * @expose
>> + * @this {org.apache.flex.jquery.staticControls.RadioButton}
>> + * Used to provide ids to the radio buttons.
>> + */
>> +org.apache.flex.jquery.staticControls.RadioButton.radioCounter = 0;
>> +
>> +/**
>> + * @expose
>> + * @this {org.apache.flex.jquery.staticControls.RadioButton}
>> + * Used to manage groups on the radio buttons.
>> + */
>> +org.apache.flex.jquery.staticControls.RadioButton.groups = { };
>> +
>> +/**
>> + * @this {org.apache.flex.jquery.staticControls.RadioButton}
>> + * Flag to make sure the event handler is set only once.
>> + */
>> +org.apache.flex.jquery.staticControls.RadioButton.groupHandlerSet =
>>false;
>> +
>> +/**
>> * @override
>> * @this {org.apache.flex.jquery.staticControls.RadioButton}
>> * @param {Object} p The parent element.
>> */
>>
>>org.apache.flex.jquery.staticControls.RadioButton.prototype.addToParent =
>> function(p) {
>> - var rb;
>>
>> - this.element = document.createElement('label');
>> + var input = document.createElement('input');
>> + input.type = 'radio';
>> + input.name = 'radio';
>> + input.id =
>> 'radio'+org.apache.flex.jquery.staticControls.RadioButton.radioCounter;
>> +
>> + var label = document.createElement('label');
>> + label.htmlFor = input.id;
>> +
>> + p.appendChild(input);
>> + p.appendChild(label);
>> +
>> + this.element = input;
>> + this.labelFor = label;
>>
>> - rb = document.createElement('input');
>> - rb.type = 'radio';
>> - $(rb).button();
>> - this.element.appendChild(rb);
>> - this.element.appendChild(document.createTextNode('radio button'));
>> + this.positioner = this.element;
>> +};
>>
>> - p.appendChild(this.element);
>> +/**
>> + * @override
>> + * @this {org.apache.flex.jquery.staticControls.RadioButton}
>> + * @param {Object} doc the document for this item
>> + */
>>
>>+org.apache.flex.jquery.staticControls.RadioButton.prototype.setDocument
>>=
>> +function(doc, id) {
>> + if( !
>> org.apache.flex.jquery.staticControls.RadioButton.groupHandlerSet ) {
>> +
>> org.apache.flex.jquery.staticControls.RadioButton.groupHandlerSet =
>>true;
>> +
>> doc.addEventListener("initComplete",goog.bind(this.initCompleteHandler,
>> this));
>> + }
>> +}
>>
>> - this.positioner = this.element;
>> +/**
>> + * @this {org.apache.flex.jquery.staticControls.RadioButton}
>> + * @param {Event} event The event.
>> + */
>>
>>+org.apache.flex.jquery.staticControls.RadioButton.prototype.initComplete
>>Handl
>> er =
>> +function(event) {
>> + var divtags =
>> org.apache.flex.jquery.staticControls.RadioButton.groups;
>> + for(var name in divtags)
>> + {
>> + var div = divtags[name];
>> + $(div).buttonset();
>> + }
>> +}
>> +
>> +/**
>> + * @expose
>> + * @this {org.apache.flex.jquery.staticControls.RadioButton}
>> + */
>> +org.apache.flex.jquery.staticControls.RadioButton.prototype.initModel =
>> +function() {
>> +};
>> +
>> +/**
>> + * @expose
>> + * @this {org.apache.flex.jquery.staticControls.RadioButton}
>> + */
>> +org.apache.flex.jquery.staticControls.RadioButton.prototype.initSkin =
>> +function() {
>> };
>>
>>
>> @@ -57,9 +132,8 @@
>> org.apache.flex.jquery.staticControls.RadioButton.prototype.addToParent
>>=
>> * @this {org.apache.flex.jquery.staticControls.RadioButton}
>> * @return {string} The groupName getter.
>> */
>>
>>-org.apache.flex.jquery.staticControls.RadioButton.prototype.get_groupNam
>>e =
>> - function() {
>> - return this.element.childNodes.item(0).name;
>>
>>+org.apache.flex.jquery.staticControls.RadioButton.prototype.get_groupNam
>>e =
>> function() {
>> + return this.radioGroupName;
>> };
>>
>>
>> @@ -68,9 +142,39 @@
>>
>>org.apache.flex.jquery.staticControls.RadioButton.prototype.get_groupName
>> =
>> * @this {org.apache.flex.jquery.staticControls.RadioButton}
>> * @param {string} value The groupName setter.
>> */
>>
>>-org.apache.flex.jquery.staticControls.RadioButton.prototype.set_groupNam
>>e =
>> - function(value) {
>> - this.element.childNodes.item(0).name = value;
>>
>>+org.apache.flex.jquery.staticControls.RadioButton.prototype.set_groupNam
>>e =
>> function(value) {
>> +
>> +/*
>> + * NOTE: Ideally when a RadioButton was created it would be added to an
>> existing set of RadioButtons.
>> + * This is especially true for RadioButtons added dynamically.
>>However, due
>> to a bug in jQuery
>> + * (see http://bugs.jqueryui.com/ticket/8975), it is currently not
>>possible
>> to add or remove RadioButtons
>> + * programmatically. For this version the groups are maintained here in
>> RadioButton and once the
>> + * application has finished initializing, the groups are given their
>> buttonset().
>> + */
>> +
>> + this.radioGroupName = value;
>> +
>> + this.element.name = value;
>> +
>> + var div;
>> +
>> + if(
>>org.apache.flex.jquery.staticControls.RadioButton.groups[value] )
>> {
>> + div =
>> org.apache.flex.jquery.staticControls.RadioButton.groups[value];
>> + div.appendChild(this.element);
>> + div.appendChild(this.labelFor);
>> + }
>> + else {
>> + var p = this.element.parentElement;
>> + div = document.createElement('div');
>> + div.id = value;
>> + div.appendChild(this.element);
>> + div.appendChild(this.labelFor);
>> + p.appendChild(div);
>> +
>> +
>> org.apache.flex.jquery.staticControls.RadioButton.groups[String(value)]
>>= div;
>> + }
>> +
>> + this.positioner = div;
>> };
>>
>>
>> @@ -79,9 +183,8 @@
>>
>>org.apache.flex.jquery.staticControls.RadioButton.prototype.set_groupName
>> =
>> * @this {org.apache.flex.jquery.staticControls.RadioButton}
>> * @return {string} The text getter.
>> */
>> -org.apache.flex.jquery.staticControls.RadioButton.prototype.get_text =
>> - function() {
>> - return this.element.childNodes.item(1).nodeValue;
>> +org.apache.flex.jquery.staticControls.RadioButton.prototype.get_text =
>> function() {
>> + return this.labelFor.innerHTML;
>> };
>>
>>
>> @@ -90,9 +193,8 @@
>> org.apache.flex.jquery.staticControls.RadioButton.prototype.get_text =
>> * @this {org.apache.flex.jquery.staticControls.RadioButton}
>> * @param {string} value The text setter.
>> */
>> -org.apache.flex.jquery.staticControls.RadioButton.prototype.set_text =
>> - function(value) {
>> - this.element.childNodes.item(1).nodeValue = value;
>> +org.apache.flex.jquery.staticControls.RadioButton.prototype.set_text =
>> function(value) {
>> + this.labelFor.innerHTML = value;
>> };
>>
>>
>> @@ -101,9 +203,8 @@
>> org.apache.flex.jquery.staticControls.RadioButton.prototype.set_text =
>> * @this {org.apache.flex.jquery.staticControls.RadioButton}
>> * @return {bool} The selected getter.
>> */
>>
>>-org.apache.flex.jquery.staticControls.RadioButton.prototype.get_selected
>> =
>> - function() {
>> - return this.element.childNodes.item(0).checked;
>>
>>+org.apache.flex.jquery.staticControls.RadioButton.prototype.get_selected
>> =
>> function() {
>> + return this.element.checked;
>> };
>>
>>
>> @@ -112,7 +213,6 @@
>>
>>org.apache.flex.jquery.staticControls.RadioButton.prototype.get_selected
>>=
>> * @this {org.apache.flex.jquery.staticControls.RadioButton}
>> * @param {bool} value The selected setter.
>> */
>>
>>-org.apache.flex.jquery.staticControls.RadioButton.prototype.set_selected
>> =
>> - function(value) {
>> - this.element.childNodes.item(0).checked = value;
>>
>>+org.apache.flex.jquery.staticControls.RadioButton.prototype.set_selected
>> =
>> function(value) {
>> + this.element.checked = value;
>> };
>>
>
>--
>Alex Harui
>Flex SDK Team
>Adobe Systems, Inc.
>http://blogs.adobe.com/aharui
>
Re: git commit: [flex-asjs] [refs/heads/develop] - RadioButtons for
jQuery. RadioButtons cannot be programmatically added due to a known jQuery
bug (documented in the RadioButton.js file).
Posted by Alex Harui <ah...@adobe.com>.
Excellent.
One question though: if you took out jquery.Application, how do the Jquery
JS files get injected?
-Alex
On 5/9/13 1:33 PM, "pent@apache.org" <pe...@apache.org> wrote:
> Updated Branches:
> refs/heads/develop 0991467eb -> 114aeec95
>
>
> RadioButtons for jQuery. RadioButtons cannot be programmatically added due to
> a known jQuery bug (documented in the RadioButton.js file).
>
>
> Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo
> Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/114aeec9
> Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/114aeec9
> Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/114aeec9
>
> Branch: refs/heads/develop
> Commit: 114aeec95635a765abc6e527517de984cd2dfadd
> Parents: 0991467
> Author: Peter Ent <pe...@apache.org>
> Authored: Thu May 9 16:33:01 2013 -0400
> Committer: Peter Ent <pe...@apache.org>
> Committed: Thu May 9 16:33:01 2013 -0400
>
> ----------------------------------------------------------------------
> frameworks/as/jquery-manifest.xml | 1 -
> .../apache/flex/html/staticControls/RadioButton.as | 6 +
> .../as/src/org/apache/flex/jquery/Application.as | 43 ----
> .../flex/jquery/staticControls/RadioButton.as | 4 +
> .../org/apache/flex/html/staticControls/Label.js | 14 ++
> .../apache/flex/html/staticControls/RadioButton.js | 16 ++
> .../src/org/apache/flex/jquery/Application.js | 114 -----------
> .../flex/jquery/staticControls/RadioButton.js | 158 ++++++++++++---
> 8 files changed, 169 insertions(+), 187 deletions(-)
> ----------------------------------------------------------------------
>
>
> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/114aeec9/frameworks/as/j
> query-manifest.xml
> ----------------------------------------------------------------------
> diff --git a/frameworks/as/jquery-manifest.xml
> b/frameworks/as/jquery-manifest.xml
> index cdb9dd5..d760aff 100644
> --- a/frameworks/as/jquery-manifest.xml
> +++ b/frameworks/as/jquery-manifest.xml
> @@ -21,7 +21,6 @@
>
> <componentPackage>
>
> - <component id="Application" class="org.apache.flex.jquery.Application"/>
> <component id="TextButton"
> class="org.apache.flex.jquery.staticControls.TextButton"/>
> <component id="CheckBox"
> class="org.apache.flex.jquery.staticControls.CheckBox"/>
> <component id="RadioButton"
> class="org.apache.flex.jquery.staticControls.RadioButton"/>
>
> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/114aeec9/frameworks/as/s
> rc/org/apache/flex/html/staticControls/RadioButton.as
> ----------------------------------------------------------------------
> diff --git
> a/frameworks/as/src/org/apache/flex/html/staticControls/RadioButton.as
> b/frameworks/as/src/org/apache/flex/html/staticControls/RadioButton.as
> index 0aee02b..a6caf5b 100644
> --- a/frameworks/as/src/org/apache/flex/html/staticControls/RadioButton.as
> +++ b/frameworks/as/src/org/apache/flex/html/staticControls/RadioButton.as
> @@ -19,6 +19,7 @@
> package org.apache.flex.html.staticControls
> {
> import flash.display.DisplayObject;
> + import flash.display.DisplayObjectContainer;
> import flash.display.SimpleButton;
> import flash.events.MouseEvent;
> import flash.utils.Dictionary;
> @@ -111,6 +112,11 @@ package org.apache.flex.html.staticControls
> IValueToggleButtonModel(model).selectedValue =
> newValue;
> }
>
> + public function addToParent(p:DisplayObjectContainer):void
> + {
> + p.addChild(this);
> + }
> +
> public function initModel():void
> {
> if (getBeadByType(IValueToggleButtonModel) == null)
>
> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/114aeec9/frameworks/as/s
> rc/org/apache/flex/jquery/Application.as
> ----------------------------------------------------------------------
> diff --git a/frameworks/as/src/org/apache/flex/jquery/Application.as
> b/frameworks/as/src/org/apache/flex/jquery/Application.as
> deleted file mode 100644
> index 5801d07..0000000
> --- a/frameworks/as/src/org/apache/flex/jquery/Application.as
> +++ /dev/null
> @@ -1,43 +0,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.
> -//
> -/////////////////////////////////////////////////////////////////////////////
> ///
> -package org.apache.flex.jquery
> -{
> - import flash.display.Sprite;
> - import flash.display.StageAlign;
> - import flash.display.StageScaleMode;
> - import flash.events.IOErrorEvent;
> -
> - import org.apache.flex.core.Application;
> - import org.apache.flex.core.IFlexInfo;
> - import org.apache.flex.events.Event;
> - import org.apache.flex.utils.MXMLDataInterpreter;
> -
> - //--------------------------------------
> - // Events
> - //--------------------------------------
> -
> - /**
> - * Dispatched at startup.
> - */
> - [Event(name="initialize", type="org.apache.flex.events.Event")]
> -
> - public class Application extends org.apache.flex.core.Application
> implements IFlexInfo
> - {
> - }
> -}
> \ No newline at end of file
>
> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/114aeec9/frameworks/as/s
> rc/org/apache/flex/jquery/staticControls/RadioButton.as
> ----------------------------------------------------------------------
> diff --git
> a/frameworks/as/src/org/apache/flex/jquery/staticControls/RadioButton.as
> b/frameworks/as/src/org/apache/flex/jquery/staticControls/RadioButton.as
> index a94739a..aac1ad5 100644
> --- a/frameworks/as/src/org/apache/flex/jquery/staticControls/RadioButton.as
> +++ b/frameworks/as/src/org/apache/flex/jquery/staticControls/RadioButton.as
> @@ -22,5 +22,9 @@ package org.apache.flex.jquery.staticControls
>
> public class RadioButton extends
> org.apache.flex.html.staticControls.RadioButton
> {
> + override public function initModel():void
> + {
> + super.initModel();
> + }
> }
> }
> \ No newline at end of file
>
> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/114aeec9/frameworks/js/F
> lexJS/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 875607a..55d1361 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
> @@ -40,6 +40,20 @@
> org.apache.flex.html.staticControls.Label.prototype.addToParent = function(p)
> {
> this.positioner = this.element;
> };
>
> +/**
> + * @expose
> + * @this {org.apache.flex.html.staticControls.Label}
> + */
> +org.apache.flex.html.staticControls.Label.prototype.initModel = function() {
> +};
> +/**
> + * @expose
> + * @this {org.apache.flex.html.staticControls.Label}
> + */
> +org.apache.flex.html.staticControls.Label.prototype.initSkin = function() {
> +
> +};
> +
>
> /**
> * @expose
>
> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/114aeec9/frameworks/js/F
> lexJS/src/org/apache/flex/html/staticControls/RadioButton.js
> ----------------------------------------------------------------------
> diff --git
> a/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/RadioButton.js
> b/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/RadioButton.js
> index fb657b2..e8f67d6 100644
> ---
> a/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/RadioButton.js
> +++
> b/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/RadioButton.js
> @@ -51,6 +51,22 @@
> org.apache.flex.html.staticControls.RadioButton.prototype.addToParent =
> rb.flexjs_wrapper = this;
> };
>
> +/**
> + * @expose
> + * @this {org.apache.flex.html.staticControls.RadioButton}
> + */
> +org.apache.flex.html.staticControls.RadioButton.prototype.initModel =
> +function() {
> +};
> +
> +/**
> + * @expose
> + * @this {org.apache.flex.html.staticControls.RadioButton}
> + */
> +org.apache.flex.html.staticControls.RadioButton.prototype.initSkin =
> +function() {
> +};
> +
>
> /**
> * @expose
>
> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/114aeec9/frameworks/js/F
> lexJS/src/org/apache/flex/jquery/Application.js
> ----------------------------------------------------------------------
> diff --git a/frameworks/js/FlexJS/src/org/apache/flex/jquery/Application.js
> b/frameworks/js/FlexJS/src/org/apache/flex/jquery/Application.js
> deleted file mode 100644
> index e6eb0f8..0000000
> --- a/frameworks/js/FlexJS/src/org/apache/flex/jquery/Application.js
> +++ /dev/null
> @@ -1,114 +0,0 @@
> -/**
> - * 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.
> - */
> -
> -// ------------------------------------------------------------------
> -// jQuery
> -// ------------------------------------------------------------------
> -
> -// (erikdebruin) do these have to be in the global namespace?
> -var head, link, mainjs, uijs;
> -
> -// Bring in the jQuery sources. You can use the minified versions for
> -// better performance.
> -mainjs = document.createElement('script');
> -/** @type {Object} */ mainjs.src = 'http://code.jquery.com/jquery-1.9.1.js';
> -document.head.appendChild(mainjs);
> -
> -uijs = document.createElement('script');
> -/** @type {Object} */ uijs.src =
> - 'http://code.jquery.com/ui/1.10.2/jquery-ui.js';
> -document.head.appendChild(uijs);
> -
> -// create a stylesheet link to the corresponding jquery theme file.
> -head = document.getElementsByTagName('head')[0];
> -link = document.createElement('link');
> -/** @type {Object} */ link.id = 'jquerycss';
> -/** @type {Object} */ link.rel = 'stylesheet';
> -/** @type {Object} */ link.type = 'text/css';
> -/** @type {Object} */ link.href =
> - 'http://code.jquery.com/ui/1.10.2/themes/smoothness/jquery-ui.css';
> -/** @type {Object} */ link.media = 'all';
> -head.appendChild(link);
> -
> -// ------------------------------------------------------------------
> -// end jQuery
> -// ------------------------------------------------------------------
> -
> -goog.provide('org.apache.flex.jquery.Application');
> -
> -goog.require('org.apache.flex.core.HTMLElementWrapper');
> -goog.require('org.apache.flex.utils.MXMLDataInterpreter');
> -
> -
> -
> -/**
> - * @constructor
> - * @extends {org.apache.flex.core.HTMLElementWrapper}
> - */
> -org.apache.flex.jquery.Application = function() {
> - goog.base(this);
> -
> -};
> -goog.inherits(org.apache.flex.jquery.Application,
> - org.apache.flex.core.HTMLElementWrapper);
> -
> -
> -/**
> - * @expose
> - * @type {Object}
> - */
> -org.apache.flex.jquery.Application.prototype.controller = null;
> -
> -
> -/**
> - * @expose
> - * @type {org.apache.flex.core.ViewBase}
> - */
> -org.apache.flex.jquery.Application.prototype.initialView = null;
> -
> -
> -/**
> - * @expose
> - * @type {org.apache.flex.events.EventDispatcher}
> - */
> -org.apache.flex.jquery.Application.prototype.model = null;
> -
> -
> -/**
> - * @expose
> - * @type {org.apache.flex.core.SimpleValuesImpl}
> - */
> -org.apache.flex.jquery.Application.prototype.valuesImpl = null;
> -
> -
> -/**
> - * @expose
> - * @this {org.apache.flex.jquery.Application}
> - */
> -org.apache.flex.jquery.Application.prototype.start = function() {
> - var evt, i, n, q;
> -
> - this.element = document.getElementsByTagName('body')[0];
> -
> - org.apache.flex.utils.MXMLDataInterpreter.generateMXMLProperties(this,
> - this.get_MXMLProperties());
> -
> - this.dispatchEvent('initialize');
> -
> - this.initialView.addToParent(this.element);
> - this.initialView.initUI(this.model);
> -
> - this.dispatchEvent('viewChanged');
> -};
> -
>
> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/114aeec9/frameworks/js/F
> lexJS/src/org/apache/flex/jquery/staticControls/RadioButton.js
> ----------------------------------------------------------------------
> diff --git
> a/frameworks/js/FlexJS/src/org/apache/flex/jquery/staticControls/RadioButton.j
> s
>
b/frameworks/js/FlexJS/src/org/apache/flex/jquery/staticControls/RadioButton.j>
s
> index 35d2371..db85bf9 100644
> ---
>
a/frameworks/js/FlexJS/src/org/apache/flex/jquery/staticControls/RadioButton.j>
s
> +++
>
b/frameworks/js/FlexJS/src/org/apache/flex/jquery/staticControls/RadioButton.j>
s
> @@ -16,39 +16,114 @@
> goog.provide('org.apache.flex.jquery.staticControls.RadioButton');
>
> goog.require('org.apache.flex.core.UIBase');
>
> -
> -
> /**
> * @constructor
> * @extends {org.apache.flex.core.UIBase}
> */
> org.apache.flex.jquery.staticControls.RadioButton = function() {
> +
> goog.base(this);
> +
> + org.apache.flex.core.UIBase.call(this);
> + org.apache.flex.jquery.staticControls.RadioButton.radioCounter++;
> };
> goog.inherits(org.apache.flex.jquery.staticControls.RadioButton,
> org.apache.flex.core.UIBase);
>
>
> /**
> + * @expose
> + * @this {org.apache.flex.jquery.staticControls.RadioButton}
> + * The name of the radioGroup.
> + */
> +org.apache.flex.jquery.staticControls.RadioButton.prototype.radioGroupName;
> +
> +/**
> + * @expose
> + * @this {org.apache.flex.jquery.staticControls.RadioButton}
> + * Used to provide ids to the radio buttons.
> + */
> +org.apache.flex.jquery.staticControls.RadioButton.radioCounter = 0;
> +
> +/**
> + * @expose
> + * @this {org.apache.flex.jquery.staticControls.RadioButton}
> + * Used to manage groups on the radio buttons.
> + */
> +org.apache.flex.jquery.staticControls.RadioButton.groups = { };
> +
> +/**
> + * @this {org.apache.flex.jquery.staticControls.RadioButton}
> + * Flag to make sure the event handler is set only once.
> + */
> +org.apache.flex.jquery.staticControls.RadioButton.groupHandlerSet = false;
> +
> +/**
> * @override
> * @this {org.apache.flex.jquery.staticControls.RadioButton}
> * @param {Object} p The parent element.
> */
> org.apache.flex.jquery.staticControls.RadioButton.prototype.addToParent =
> function(p) {
> - var rb;
>
> - this.element = document.createElement('label');
> + var input = document.createElement('input');
> + input.type = 'radio';
> + input.name = 'radio';
> + input.id =
> 'radio'+org.apache.flex.jquery.staticControls.RadioButton.radioCounter;
> +
> + var label = document.createElement('label');
> + label.htmlFor = input.id;
> +
> + p.appendChild(input);
> + p.appendChild(label);
> +
> + this.element = input;
> + this.labelFor = label;
>
> - rb = document.createElement('input');
> - rb.type = 'radio';
> - $(rb).button();
> - this.element.appendChild(rb);
> - this.element.appendChild(document.createTextNode('radio button'));
> + this.positioner = this.element;
> +};
>
> - p.appendChild(this.element);
> +/**
> + * @override
> + * @this {org.apache.flex.jquery.staticControls.RadioButton}
> + * @param {Object} doc the document for this item
> + */
> +org.apache.flex.jquery.staticControls.RadioButton.prototype.setDocument =
> +function(doc, id) {
> + if( !
> org.apache.flex.jquery.staticControls.RadioButton.groupHandlerSet ) {
> +
> org.apache.flex.jquery.staticControls.RadioButton.groupHandlerSet = true;
> +
> doc.addEventListener("initComplete",goog.bind(this.initCompleteHandler,
> this));
> + }
> +}
>
> - this.positioner = this.element;
> +/**
> + * @this {org.apache.flex.jquery.staticControls.RadioButton}
> + * @param {Event} event The event.
> + */
> +org.apache.flex.jquery.staticControls.RadioButton.prototype.initCompleteHandl
> er =
> +function(event) {
> + var divtags =
> org.apache.flex.jquery.staticControls.RadioButton.groups;
> + for(var name in divtags)
> + {
> + var div = divtags[name];
> + $(div).buttonset();
> + }
> +}
> +
> +/**
> + * @expose
> + * @this {org.apache.flex.jquery.staticControls.RadioButton}
> + */
> +org.apache.flex.jquery.staticControls.RadioButton.prototype.initModel =
> +function() {
> +};
> +
> +/**
> + * @expose
> + * @this {org.apache.flex.jquery.staticControls.RadioButton}
> + */
> +org.apache.flex.jquery.staticControls.RadioButton.prototype.initSkin =
> +function() {
> };
>
>
> @@ -57,9 +132,8 @@
> org.apache.flex.jquery.staticControls.RadioButton.prototype.addToParent =
> * @this {org.apache.flex.jquery.staticControls.RadioButton}
> * @return {string} The groupName getter.
> */
> -org.apache.flex.jquery.staticControls.RadioButton.prototype.get_groupName =
> - function() {
> - return this.element.childNodes.item(0).name;
> +org.apache.flex.jquery.staticControls.RadioButton.prototype.get_groupName =
> function() {
> + return this.radioGroupName;
> };
>
>
> @@ -68,9 +142,39 @@
> org.apache.flex.jquery.staticControls.RadioButton.prototype.get_groupName =
> * @this {org.apache.flex.jquery.staticControls.RadioButton}
> * @param {string} value The groupName setter.
> */
> -org.apache.flex.jquery.staticControls.RadioButton.prototype.set_groupName =
> - function(value) {
> - this.element.childNodes.item(0).name = value;
> +org.apache.flex.jquery.staticControls.RadioButton.prototype.set_groupName =
> function(value) {
> +
> +/*
> + * NOTE: Ideally when a RadioButton was created it would be added to an
> existing set of RadioButtons.
> + * This is especially true for RadioButtons added dynamically. However, due
> to a bug in jQuery
> + * (see http://bugs.jqueryui.com/ticket/8975), it is currently not possible
> to add or remove RadioButtons
> + * programmatically. For this version the groups are maintained here in
> RadioButton and once the
> + * application has finished initializing, the groups are given their
> buttonset().
> + */
> +
> + this.radioGroupName = value;
> +
> + this.element.name = value;
> +
> + var div;
> +
> + if( org.apache.flex.jquery.staticControls.RadioButton.groups[value] )
> {
> + div =
> org.apache.flex.jquery.staticControls.RadioButton.groups[value];
> + div.appendChild(this.element);
> + div.appendChild(this.labelFor);
> + }
> + else {
> + var p = this.element.parentElement;
> + div = document.createElement('div');
> + div.id = value;
> + div.appendChild(this.element);
> + div.appendChild(this.labelFor);
> + p.appendChild(div);
> +
> +
> org.apache.flex.jquery.staticControls.RadioButton.groups[String(value)] = div;
> + }
> +
> + this.positioner = div;
> };
>
>
> @@ -79,9 +183,8 @@
> org.apache.flex.jquery.staticControls.RadioButton.prototype.set_groupName =
> * @this {org.apache.flex.jquery.staticControls.RadioButton}
> * @return {string} The text getter.
> */
> -org.apache.flex.jquery.staticControls.RadioButton.prototype.get_text =
> - function() {
> - return this.element.childNodes.item(1).nodeValue;
> +org.apache.flex.jquery.staticControls.RadioButton.prototype.get_text =
> function() {
> + return this.labelFor.innerHTML;
> };
>
>
> @@ -90,9 +193,8 @@
> org.apache.flex.jquery.staticControls.RadioButton.prototype.get_text =
> * @this {org.apache.flex.jquery.staticControls.RadioButton}
> * @param {string} value The text setter.
> */
> -org.apache.flex.jquery.staticControls.RadioButton.prototype.set_text =
> - function(value) {
> - this.element.childNodes.item(1).nodeValue = value;
> +org.apache.flex.jquery.staticControls.RadioButton.prototype.set_text =
> function(value) {
> + this.labelFor.innerHTML = value;
> };
>
>
> @@ -101,9 +203,8 @@
> org.apache.flex.jquery.staticControls.RadioButton.prototype.set_text =
> * @this {org.apache.flex.jquery.staticControls.RadioButton}
> * @return {bool} The selected getter.
> */
> -org.apache.flex.jquery.staticControls.RadioButton.prototype.get_selected =
> - function() {
> - return this.element.childNodes.item(0).checked;
> +org.apache.flex.jquery.staticControls.RadioButton.prototype.get_selected =
> function() {
> + return this.element.checked;
> };
>
>
> @@ -112,7 +213,6 @@
> org.apache.flex.jquery.staticControls.RadioButton.prototype.get_selected =
> * @this {org.apache.flex.jquery.staticControls.RadioButton}
> * @param {bool} value The selected setter.
> */
> -org.apache.flex.jquery.staticControls.RadioButton.prototype.set_selected =
> - function(value) {
> - this.element.childNodes.item(0).checked = value;
> +org.apache.flex.jquery.staticControls.RadioButton.prototype.set_selected =
> function(value) {
> + this.element.checked = value;
> };
>
--
Alex Harui
Flex SDK Team
Adobe Systems, Inc.
http://blogs.adobe.com/aharui
Re: git commit: [flex-asjs] [refs/heads/develop] - RadioButtons for
jQuery. RadioButtons cannot be programmatically added due to a known jQuery
bug (documented in the RadioButton.js file).
Posted by Alex Harui <ah...@adobe.com>.
Excellent.
One question though: if you took out jquery.Application, how do the Jquery
JS files get injected?
-Alex
On 5/9/13 1:33 PM, "pent@apache.org" <pe...@apache.org> wrote:
> Updated Branches:
> refs/heads/develop 0991467eb -> 114aeec95
>
>
> RadioButtons for jQuery. RadioButtons cannot be programmatically added due to
> a known jQuery bug (documented in the RadioButton.js file).
>
>
> Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo
> Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/114aeec9
> Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/114aeec9
> Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/114aeec9
>
> Branch: refs/heads/develop
> Commit: 114aeec95635a765abc6e527517de984cd2dfadd
> Parents: 0991467
> Author: Peter Ent <pe...@apache.org>
> Authored: Thu May 9 16:33:01 2013 -0400
> Committer: Peter Ent <pe...@apache.org>
> Committed: Thu May 9 16:33:01 2013 -0400
>
> ----------------------------------------------------------------------
> frameworks/as/jquery-manifest.xml | 1 -
> .../apache/flex/html/staticControls/RadioButton.as | 6 +
> .../as/src/org/apache/flex/jquery/Application.as | 43 ----
> .../flex/jquery/staticControls/RadioButton.as | 4 +
> .../org/apache/flex/html/staticControls/Label.js | 14 ++
> .../apache/flex/html/staticControls/RadioButton.js | 16 ++
> .../src/org/apache/flex/jquery/Application.js | 114 -----------
> .../flex/jquery/staticControls/RadioButton.js | 158 ++++++++++++---
> 8 files changed, 169 insertions(+), 187 deletions(-)
> ----------------------------------------------------------------------
>
>
> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/114aeec9/frameworks/as/j
> query-manifest.xml
> ----------------------------------------------------------------------
> diff --git a/frameworks/as/jquery-manifest.xml
> b/frameworks/as/jquery-manifest.xml
> index cdb9dd5..d760aff 100644
> --- a/frameworks/as/jquery-manifest.xml
> +++ b/frameworks/as/jquery-manifest.xml
> @@ -21,7 +21,6 @@
>
> <componentPackage>
>
> - <component id="Application" class="org.apache.flex.jquery.Application"/>
> <component id="TextButton"
> class="org.apache.flex.jquery.staticControls.TextButton"/>
> <component id="CheckBox"
> class="org.apache.flex.jquery.staticControls.CheckBox"/>
> <component id="RadioButton"
> class="org.apache.flex.jquery.staticControls.RadioButton"/>
>
> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/114aeec9/frameworks/as/s
> rc/org/apache/flex/html/staticControls/RadioButton.as
> ----------------------------------------------------------------------
> diff --git
> a/frameworks/as/src/org/apache/flex/html/staticControls/RadioButton.as
> b/frameworks/as/src/org/apache/flex/html/staticControls/RadioButton.as
> index 0aee02b..a6caf5b 100644
> --- a/frameworks/as/src/org/apache/flex/html/staticControls/RadioButton.as
> +++ b/frameworks/as/src/org/apache/flex/html/staticControls/RadioButton.as
> @@ -19,6 +19,7 @@
> package org.apache.flex.html.staticControls
> {
> import flash.display.DisplayObject;
> + import flash.display.DisplayObjectContainer;
> import flash.display.SimpleButton;
> import flash.events.MouseEvent;
> import flash.utils.Dictionary;
> @@ -111,6 +112,11 @@ package org.apache.flex.html.staticControls
> IValueToggleButtonModel(model).selectedValue =
> newValue;
> }
>
> + public function addToParent(p:DisplayObjectContainer):void
> + {
> + p.addChild(this);
> + }
> +
> public function initModel():void
> {
> if (getBeadByType(IValueToggleButtonModel) == null)
>
> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/114aeec9/frameworks/as/s
> rc/org/apache/flex/jquery/Application.as
> ----------------------------------------------------------------------
> diff --git a/frameworks/as/src/org/apache/flex/jquery/Application.as
> b/frameworks/as/src/org/apache/flex/jquery/Application.as
> deleted file mode 100644
> index 5801d07..0000000
> --- a/frameworks/as/src/org/apache/flex/jquery/Application.as
> +++ /dev/null
> @@ -1,43 +0,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.
> -//
> -/////////////////////////////////////////////////////////////////////////////
> ///
> -package org.apache.flex.jquery
> -{
> - import flash.display.Sprite;
> - import flash.display.StageAlign;
> - import flash.display.StageScaleMode;
> - import flash.events.IOErrorEvent;
> -
> - import org.apache.flex.core.Application;
> - import org.apache.flex.core.IFlexInfo;
> - import org.apache.flex.events.Event;
> - import org.apache.flex.utils.MXMLDataInterpreter;
> -
> - //--------------------------------------
> - // Events
> - //--------------------------------------
> -
> - /**
> - * Dispatched at startup.
> - */
> - [Event(name="initialize", type="org.apache.flex.events.Event")]
> -
> - public class Application extends org.apache.flex.core.Application
> implements IFlexInfo
> - {
> - }
> -}
> \ No newline at end of file
>
> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/114aeec9/frameworks/as/s
> rc/org/apache/flex/jquery/staticControls/RadioButton.as
> ----------------------------------------------------------------------
> diff --git
> a/frameworks/as/src/org/apache/flex/jquery/staticControls/RadioButton.as
> b/frameworks/as/src/org/apache/flex/jquery/staticControls/RadioButton.as
> index a94739a..aac1ad5 100644
> --- a/frameworks/as/src/org/apache/flex/jquery/staticControls/RadioButton.as
> +++ b/frameworks/as/src/org/apache/flex/jquery/staticControls/RadioButton.as
> @@ -22,5 +22,9 @@ package org.apache.flex.jquery.staticControls
>
> public class RadioButton extends
> org.apache.flex.html.staticControls.RadioButton
> {
> + override public function initModel():void
> + {
> + super.initModel();
> + }
> }
> }
> \ No newline at end of file
>
> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/114aeec9/frameworks/js/F
> lexJS/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 875607a..55d1361 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
> @@ -40,6 +40,20 @@
> org.apache.flex.html.staticControls.Label.prototype.addToParent = function(p)
> {
> this.positioner = this.element;
> };
>
> +/**
> + * @expose
> + * @this {org.apache.flex.html.staticControls.Label}
> + */
> +org.apache.flex.html.staticControls.Label.prototype.initModel = function() {
> +};
> +/**
> + * @expose
> + * @this {org.apache.flex.html.staticControls.Label}
> + */
> +org.apache.flex.html.staticControls.Label.prototype.initSkin = function() {
> +
> +};
> +
>
> /**
> * @expose
>
> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/114aeec9/frameworks/js/F
> lexJS/src/org/apache/flex/html/staticControls/RadioButton.js
> ----------------------------------------------------------------------
> diff --git
> a/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/RadioButton.js
> b/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/RadioButton.js
> index fb657b2..e8f67d6 100644
> ---
> a/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/RadioButton.js
> +++
> b/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/RadioButton.js
> @@ -51,6 +51,22 @@
> org.apache.flex.html.staticControls.RadioButton.prototype.addToParent =
> rb.flexjs_wrapper = this;
> };
>
> +/**
> + * @expose
> + * @this {org.apache.flex.html.staticControls.RadioButton}
> + */
> +org.apache.flex.html.staticControls.RadioButton.prototype.initModel =
> +function() {
> +};
> +
> +/**
> + * @expose
> + * @this {org.apache.flex.html.staticControls.RadioButton}
> + */
> +org.apache.flex.html.staticControls.RadioButton.prototype.initSkin =
> +function() {
> +};
> +
>
> /**
> * @expose
>
> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/114aeec9/frameworks/js/F
> lexJS/src/org/apache/flex/jquery/Application.js
> ----------------------------------------------------------------------
> diff --git a/frameworks/js/FlexJS/src/org/apache/flex/jquery/Application.js
> b/frameworks/js/FlexJS/src/org/apache/flex/jquery/Application.js
> deleted file mode 100644
> index e6eb0f8..0000000
> --- a/frameworks/js/FlexJS/src/org/apache/flex/jquery/Application.js
> +++ /dev/null
> @@ -1,114 +0,0 @@
> -/**
> - * 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.
> - */
> -
> -// ------------------------------------------------------------------
> -// jQuery
> -// ------------------------------------------------------------------
> -
> -// (erikdebruin) do these have to be in the global namespace?
> -var head, link, mainjs, uijs;
> -
> -// Bring in the jQuery sources. You can use the minified versions for
> -// better performance.
> -mainjs = document.createElement('script');
> -/** @type {Object} */ mainjs.src = 'http://code.jquery.com/jquery-1.9.1.js';
> -document.head.appendChild(mainjs);
> -
> -uijs = document.createElement('script');
> -/** @type {Object} */ uijs.src =
> - 'http://code.jquery.com/ui/1.10.2/jquery-ui.js';
> -document.head.appendChild(uijs);
> -
> -// create a stylesheet link to the corresponding jquery theme file.
> -head = document.getElementsByTagName('head')[0];
> -link = document.createElement('link');
> -/** @type {Object} */ link.id = 'jquerycss';
> -/** @type {Object} */ link.rel = 'stylesheet';
> -/** @type {Object} */ link.type = 'text/css';
> -/** @type {Object} */ link.href =
> - 'http://code.jquery.com/ui/1.10.2/themes/smoothness/jquery-ui.css';
> -/** @type {Object} */ link.media = 'all';
> -head.appendChild(link);
> -
> -// ------------------------------------------------------------------
> -// end jQuery
> -// ------------------------------------------------------------------
> -
> -goog.provide('org.apache.flex.jquery.Application');
> -
> -goog.require('org.apache.flex.core.HTMLElementWrapper');
> -goog.require('org.apache.flex.utils.MXMLDataInterpreter');
> -
> -
> -
> -/**
> - * @constructor
> - * @extends {org.apache.flex.core.HTMLElementWrapper}
> - */
> -org.apache.flex.jquery.Application = function() {
> - goog.base(this);
> -
> -};
> -goog.inherits(org.apache.flex.jquery.Application,
> - org.apache.flex.core.HTMLElementWrapper);
> -
> -
> -/**
> - * @expose
> - * @type {Object}
> - */
> -org.apache.flex.jquery.Application.prototype.controller = null;
> -
> -
> -/**
> - * @expose
> - * @type {org.apache.flex.core.ViewBase}
> - */
> -org.apache.flex.jquery.Application.prototype.initialView = null;
> -
> -
> -/**
> - * @expose
> - * @type {org.apache.flex.events.EventDispatcher}
> - */
> -org.apache.flex.jquery.Application.prototype.model = null;
> -
> -
> -/**
> - * @expose
> - * @type {org.apache.flex.core.SimpleValuesImpl}
> - */
> -org.apache.flex.jquery.Application.prototype.valuesImpl = null;
> -
> -
> -/**
> - * @expose
> - * @this {org.apache.flex.jquery.Application}
> - */
> -org.apache.flex.jquery.Application.prototype.start = function() {
> - var evt, i, n, q;
> -
> - this.element = document.getElementsByTagName('body')[0];
> -
> - org.apache.flex.utils.MXMLDataInterpreter.generateMXMLProperties(this,
> - this.get_MXMLProperties());
> -
> - this.dispatchEvent('initialize');
> -
> - this.initialView.addToParent(this.element);
> - this.initialView.initUI(this.model);
> -
> - this.dispatchEvent('viewChanged');
> -};
> -
>
> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/114aeec9/frameworks/js/F
> lexJS/src/org/apache/flex/jquery/staticControls/RadioButton.js
> ----------------------------------------------------------------------
> diff --git
> a/frameworks/js/FlexJS/src/org/apache/flex/jquery/staticControls/RadioButton.j
> s
>
b/frameworks/js/FlexJS/src/org/apache/flex/jquery/staticControls/RadioButton.j>
s
> index 35d2371..db85bf9 100644
> ---
>
a/frameworks/js/FlexJS/src/org/apache/flex/jquery/staticControls/RadioButton.j>
s
> +++
>
b/frameworks/js/FlexJS/src/org/apache/flex/jquery/staticControls/RadioButton.j>
s
> @@ -16,39 +16,114 @@
> goog.provide('org.apache.flex.jquery.staticControls.RadioButton');
>
> goog.require('org.apache.flex.core.UIBase');
>
> -
> -
> /**
> * @constructor
> * @extends {org.apache.flex.core.UIBase}
> */
> org.apache.flex.jquery.staticControls.RadioButton = function() {
> +
> goog.base(this);
> +
> + org.apache.flex.core.UIBase.call(this);
> + org.apache.flex.jquery.staticControls.RadioButton.radioCounter++;
> };
> goog.inherits(org.apache.flex.jquery.staticControls.RadioButton,
> org.apache.flex.core.UIBase);
>
>
> /**
> + * @expose
> + * @this {org.apache.flex.jquery.staticControls.RadioButton}
> + * The name of the radioGroup.
> + */
> +org.apache.flex.jquery.staticControls.RadioButton.prototype.radioGroupName;
> +
> +/**
> + * @expose
> + * @this {org.apache.flex.jquery.staticControls.RadioButton}
> + * Used to provide ids to the radio buttons.
> + */
> +org.apache.flex.jquery.staticControls.RadioButton.radioCounter = 0;
> +
> +/**
> + * @expose
> + * @this {org.apache.flex.jquery.staticControls.RadioButton}
> + * Used to manage groups on the radio buttons.
> + */
> +org.apache.flex.jquery.staticControls.RadioButton.groups = { };
> +
> +/**
> + * @this {org.apache.flex.jquery.staticControls.RadioButton}
> + * Flag to make sure the event handler is set only once.
> + */
> +org.apache.flex.jquery.staticControls.RadioButton.groupHandlerSet = false;
> +
> +/**
> * @override
> * @this {org.apache.flex.jquery.staticControls.RadioButton}
> * @param {Object} p The parent element.
> */
> org.apache.flex.jquery.staticControls.RadioButton.prototype.addToParent =
> function(p) {
> - var rb;
>
> - this.element = document.createElement('label');
> + var input = document.createElement('input');
> + input.type = 'radio';
> + input.name = 'radio';
> + input.id =
> 'radio'+org.apache.flex.jquery.staticControls.RadioButton.radioCounter;
> +
> + var label = document.createElement('label');
> + label.htmlFor = input.id;
> +
> + p.appendChild(input);
> + p.appendChild(label);
> +
> + this.element = input;
> + this.labelFor = label;
>
> - rb = document.createElement('input');
> - rb.type = 'radio';
> - $(rb).button();
> - this.element.appendChild(rb);
> - this.element.appendChild(document.createTextNode('radio button'));
> + this.positioner = this.element;
> +};
>
> - p.appendChild(this.element);
> +/**
> + * @override
> + * @this {org.apache.flex.jquery.staticControls.RadioButton}
> + * @param {Object} doc the document for this item
> + */
> +org.apache.flex.jquery.staticControls.RadioButton.prototype.setDocument =
> +function(doc, id) {
> + if( !
> org.apache.flex.jquery.staticControls.RadioButton.groupHandlerSet ) {
> +
> org.apache.flex.jquery.staticControls.RadioButton.groupHandlerSet = true;
> +
> doc.addEventListener("initComplete",goog.bind(this.initCompleteHandler,
> this));
> + }
> +}
>
> - this.positioner = this.element;
> +/**
> + * @this {org.apache.flex.jquery.staticControls.RadioButton}
> + * @param {Event} event The event.
> + */
> +org.apache.flex.jquery.staticControls.RadioButton.prototype.initCompleteHandl
> er =
> +function(event) {
> + var divtags =
> org.apache.flex.jquery.staticControls.RadioButton.groups;
> + for(var name in divtags)
> + {
> + var div = divtags[name];
> + $(div).buttonset();
> + }
> +}
> +
> +/**
> + * @expose
> + * @this {org.apache.flex.jquery.staticControls.RadioButton}
> + */
> +org.apache.flex.jquery.staticControls.RadioButton.prototype.initModel =
> +function() {
> +};
> +
> +/**
> + * @expose
> + * @this {org.apache.flex.jquery.staticControls.RadioButton}
> + */
> +org.apache.flex.jquery.staticControls.RadioButton.prototype.initSkin =
> +function() {
> };
>
>
> @@ -57,9 +132,8 @@
> org.apache.flex.jquery.staticControls.RadioButton.prototype.addToParent =
> * @this {org.apache.flex.jquery.staticControls.RadioButton}
> * @return {string} The groupName getter.
> */
> -org.apache.flex.jquery.staticControls.RadioButton.prototype.get_groupName =
> - function() {
> - return this.element.childNodes.item(0).name;
> +org.apache.flex.jquery.staticControls.RadioButton.prototype.get_groupName =
> function() {
> + return this.radioGroupName;
> };
>
>
> @@ -68,9 +142,39 @@
> org.apache.flex.jquery.staticControls.RadioButton.prototype.get_groupName =
> * @this {org.apache.flex.jquery.staticControls.RadioButton}
> * @param {string} value The groupName setter.
> */
> -org.apache.flex.jquery.staticControls.RadioButton.prototype.set_groupName =
> - function(value) {
> - this.element.childNodes.item(0).name = value;
> +org.apache.flex.jquery.staticControls.RadioButton.prototype.set_groupName =
> function(value) {
> +
> +/*
> + * NOTE: Ideally when a RadioButton was created it would be added to an
> existing set of RadioButtons.
> + * This is especially true for RadioButtons added dynamically. However, due
> to a bug in jQuery
> + * (see http://bugs.jqueryui.com/ticket/8975), it is currently not possible
> to add or remove RadioButtons
> + * programmatically. For this version the groups are maintained here in
> RadioButton and once the
> + * application has finished initializing, the groups are given their
> buttonset().
> + */
> +
> + this.radioGroupName = value;
> +
> + this.element.name = value;
> +
> + var div;
> +
> + if( org.apache.flex.jquery.staticControls.RadioButton.groups[value] )
> {
> + div =
> org.apache.flex.jquery.staticControls.RadioButton.groups[value];
> + div.appendChild(this.element);
> + div.appendChild(this.labelFor);
> + }
> + else {
> + var p = this.element.parentElement;
> + div = document.createElement('div');
> + div.id = value;
> + div.appendChild(this.element);
> + div.appendChild(this.labelFor);
> + p.appendChild(div);
> +
> +
> org.apache.flex.jquery.staticControls.RadioButton.groups[String(value)] = div;
> + }
> +
> + this.positioner = div;
> };
>
>
> @@ -79,9 +183,8 @@
> org.apache.flex.jquery.staticControls.RadioButton.prototype.set_groupName =
> * @this {org.apache.flex.jquery.staticControls.RadioButton}
> * @return {string} The text getter.
> */
> -org.apache.flex.jquery.staticControls.RadioButton.prototype.get_text =
> - function() {
> - return this.element.childNodes.item(1).nodeValue;
> +org.apache.flex.jquery.staticControls.RadioButton.prototype.get_text =
> function() {
> + return this.labelFor.innerHTML;
> };
>
>
> @@ -90,9 +193,8 @@
> org.apache.flex.jquery.staticControls.RadioButton.prototype.get_text =
> * @this {org.apache.flex.jquery.staticControls.RadioButton}
> * @param {string} value The text setter.
> */
> -org.apache.flex.jquery.staticControls.RadioButton.prototype.set_text =
> - function(value) {
> - this.element.childNodes.item(1).nodeValue = value;
> +org.apache.flex.jquery.staticControls.RadioButton.prototype.set_text =
> function(value) {
> + this.labelFor.innerHTML = value;
> };
>
>
> @@ -101,9 +203,8 @@
> org.apache.flex.jquery.staticControls.RadioButton.prototype.set_text =
> * @this {org.apache.flex.jquery.staticControls.RadioButton}
> * @return {bool} The selected getter.
> */
> -org.apache.flex.jquery.staticControls.RadioButton.prototype.get_selected =
> - function() {
> - return this.element.childNodes.item(0).checked;
> +org.apache.flex.jquery.staticControls.RadioButton.prototype.get_selected =
> function() {
> + return this.element.checked;
> };
>
>
> @@ -112,7 +213,6 @@
> org.apache.flex.jquery.staticControls.RadioButton.prototype.get_selected =
> * @this {org.apache.flex.jquery.staticControls.RadioButton}
> * @param {bool} value The selected setter.
> */
> -org.apache.flex.jquery.staticControls.RadioButton.prototype.set_selected =
> - function(value) {
> - this.element.childNodes.item(0).checked = value;
> +org.apache.flex.jquery.staticControls.RadioButton.prototype.set_selected =
> function(value) {
> + this.element.checked = value;
> };
>
--
Alex Harui
Flex SDK Team
Adobe Systems, Inc.
http://blogs.adobe.com/aharui