Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 28C8D200BC6 for ; Sun, 6 Nov 2016 02:30:22 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 27942160B13; Sun, 6 Nov 2016 01:30:22 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 55F25160B10 for ; Sun, 6 Nov 2016 02:30:21 +0100 (CET) Received: (qmail 13390 invoked by uid 500); 6 Nov 2016 01:30:18 -0000 Mailing-List: contact commits-help@flex.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@flex.apache.org Delivered-To: mailing list commits@flex.apache.org Received: (qmail 12831 invoked by uid 99); 6 Nov 2016 01:30:17 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 06 Nov 2016 01:30:17 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id C79C0E1772; Sun, 6 Nov 2016 01:30:17 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: carlosrovira@apache.org To: commits@flex.apache.org Date: Sun, 06 Nov 2016 01:30:50 -0000 Message-Id: <91d0539e2c754d36af3023e316e65300@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [34/41] git commit: [flex-asjs] [refs/heads/feature/mdl] - Fixed radio button archived-at: Sun, 06 Nov 2016 01:30:22 -0000 Fixed radio button Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/48b4e0ad Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/48b4e0ad Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/48b4e0ad Branch: refs/heads/feature/mdl Commit: 48b4e0ada6a223aebb325df846d07b5e4b9bdc0a Parents: e35219b Author: Carlos Rovira Authored: Tue Oct 25 00:06:03 2016 +0200 Committer: Carlos Rovira Committed: Sun Nov 6 02:28:52 2016 +0100 ---------------------------------------------------------------------- .../flex/org/apache/flex/mdl/RadioButton.as | 84 ++++++++------------ 1 file changed, 33 insertions(+), 51 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/48b4e0ad/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/RadioButton.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/RadioButton.as b/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/RadioButton.as index d19ce78..ee79872 100644 --- a/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/RadioButton.as +++ b/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/RadioButton.as @@ -26,6 +26,7 @@ package org.apache.flex.mdl { import org.apache.flex.core.UIBase; import org.apache.flex.core.WrappedHTMLElement; + import org.apache.flex.html.supportClasses.RadioButtonIcon; } /** @@ -74,8 +75,8 @@ package org.apache.flex.mdl */ public static var radioCounter:int = 0; - private var input:HTMLInputElement; private var radio:HTMLSpanElement; + private var icon:RadioButtonIcon; private var label:HTMLLabelElement; private var textNode:Text; @@ -88,22 +89,19 @@ package org.apache.flex.mdl */ override protected function createElement():WrappedHTMLElement { - // hide this eleement - input = document.createElement('input') as HTMLInputElement; - input.type = 'radio'; - input.className = 'mdl-radio__button'; - input.id = '_radio_' + radioCounter++; - input.addEventListener('change', selectionChangeHandler, false); + icon = new RadioButtonIcon(); + icon.className = 'mdl-radio__button'; + icon.id = '_radio_' + RadioButton.radioCounter++; + + textNode = document.createTextNode('') as Text; radio = document.createElement('span') as HTMLSpanElement; radio.className = 'mdl-radio__label'; radio.addEventListener('mouseover', mouseOverHandler, false); radio.addEventListener('mouseout', mouseOutHandler, false); - textNode = document.createTextNode('') as Text; - label = document.createElement('label') as HTMLLabelElement; - label.appendChild(input); + label.appendChild(icon.element); label.appendChild(radio); radio.appendChild(textNode); label.style.position = 'relative'; @@ -112,10 +110,10 @@ package org.apache.flex.mdl positioner = element; positioner.style.position = 'relative'; - (input as WrappedHTMLElement).flexjs_wrapper = this; - (radio as WrappedHTMLElement).flexjs_wrapper = this; - element.flexjs_wrapper = this; + (element as WrappedHTMLElement).flexjs_wrapper = this; (textNode as WrappedHTMLElement).flexjs_wrapper = this; + (icon.element as WrappedHTMLElement).flexjs_wrapper = this; + (radio as WrappedHTMLElement).flexjs_wrapper = this; className = typeNames = 'mdl-radio mdl-js-radio'; @@ -158,20 +156,16 @@ package org.apache.flex.mdl { super.id = value; label.id = value; - input.id = value; + icon.element.id = value; } - /** - * @flexjsignorecoercion String - */ public function get groupName():String { - return input.name as String; + return (icon.element as HTMLInputElement).name as String; } - public function set groupName(value:String):void { - input.name = value; + (icon.element as HTMLInputElement).name = value; } public function get text():String @@ -184,74 +178,62 @@ package org.apache.flex.mdl textNode.nodeValue = value; } + /** @export */ public function get selected():Boolean { - return input.checked; + return (icon.element as HTMLInputElement).checked; } - public function set selected(value:Boolean):void { - input.checked = value; - /*if (input.checked) - radio.className = 'radio-icon-checked'; - else - radio.className = 'radio-icon';*/ + (icon.element as HTMLInputElement).checked = value; } - public function get value():String + public function get value():Object { - return input.value; + return (icon.element as HTMLInputElement).value; } - - public function set value(value:String):void + public function set value(v:Object):void { - input.value = value; + (icon.element as HTMLInputElement).value = v as String; } - /** - * @flexjsignorecoercion Array - * @flexjsignorecoercion String - */ public function get selectedValue():Object { - var buttons:Array; + var buttons:NodeList; var groupName:String; var i:int; var n:int; - - groupName = input.name as String; - buttons = document.getElementsByName(groupName) as Array; + + groupName = (icon.element as HTMLInputElement).name as String; + buttons = document.getElementsByName(groupName); n = buttons.length; - + for (i = 0; i < n; i++) { if (buttons[i].checked) { return buttons[i].value; } } - return null; + return null; } - + /** * @flexjsignorecoercion Array - * @flexjsignorecoercion String */ public function set selectedValue(value:Object):void { - var buttons:Array; + var buttons:NodeList; var groupName:String; var i:int; var n:int; - - groupName = input.name as String; - buttons = document.getElementsByName(groupName) as Array; + + groupName = (icon.element as HTMLInputElement).name as String; + buttons = document.getElementsByName(groupName); n = buttons.length; for (i = 0; i < n; i++) { if (buttons[i].value === value) { buttons[i].checked = true; - buttons[i].flexjs_wrapper.selected = true; + break; } - else - buttons[i].flexjs_wrapper.selected = false; } }