Changes in TextInput
Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/016e3e82 Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/016e3e82 Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/016e3e82 Branch: refs/heads/feature/mdl Commit: 016e3e82c86727d88595fd4d8e03b10321867223 Parents: 5436aac Author: Carlos Rovira <carlosrov...@apache.org> Authored: Tue Oct 25 19:02:37 2016 +0200 Committer: Carlos Rovira <carlosrov...@apache.org> Committed: Wed Oct 26 10:59:07 2016 +0200 ---------------------------------------------------------------------- .../flexjs/MDLExample/src/main/flex/App.mxml | 13 +++-- .../main/flex/org/apache/flex/mdl/TextInput.as | 55 ++++++-------------- 2 files changed, 21 insertions(+), 47 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/016e3e82/examples/flexjs/MDLExample/src/main/flex/App.mxml ---------------------------------------------------------------------- diff --git a/examples/flexjs/MDLExample/src/main/flex/App.mxml b/examples/flexjs/MDLExample/src/main/flex/App.mxml index a50dbeb..3924dba 100644 --- a/examples/flexjs/MDLExample/src/main/flex/App.mxml +++ b/examples/flexjs/MDLExample/src/main/flex/App.mxml @@ -55,16 +55,15 @@ limitations under the License. </js:HContainer> <!-- Text Fields :: https://getmdl.io/components/index.html#textfields-section --> - <mdl:TextInput id="mdlti" change="mdlchk.text = mdlti.text" text="Text..."/> - - <mdl:TextInput mdlEffect="mdl-textfield--floating-label" text="Floating Label"/> + <mdl:TextInput id="mdlti" text="Normal Text Field..." change="mdlchk.text = mdlti.text"/> + <mdl:TextInput text="Floating Label" mdlEffect="mdl-textfield--floating-label" /> <!-- Toggles :: https://getmdl.io/components/index.html#toggles-section --> - <mdl:CheckBox id="mdlchk" text="This Checks" selected="true" mdlEffect="mdl-js-ripple-effect"/> - <mdl:CheckBox id="mdlchk1" text="This is disabled at start" /> + <mdl:CheckBox id="mdlchk" text="Disabled at start" /> + <mdl:CheckBox id="mdlchk1" text="Selected and with Ripple" selected="true" mdlEffect="mdl-js-ripple-effect"/> - <mdl:RadioButton groupName="g1" text="Black" mdlEffect="mdl-js-ripple-effect"/> - <mdl:RadioButton groupName="g1" text="White"/> + <mdl:RadioButton groupName="g1" text="Black"/> + <mdl:RadioButton groupName="g1" text="Ripple" mdlEffect="mdl-js-ripple-effect"/> <mdl:RadioButton groupName="g1" text="Red"/> </js:Form> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/016e3e82/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/TextInput.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/TextInput.as b/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/TextInput.as index b387b81..87f9c5a 100644 --- a/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/TextInput.as +++ b/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/TextInput.as @@ -64,41 +64,34 @@ package org.apache.flex.mdl COMPILE::JS override protected function createElement():WrappedHTMLElement { - var div:HTMLDivElement; - var input:HTMLInputElement; - var label:HTMLLabelElement; - var textNode:Text; - - div = document.createElement('div') as HTMLDivElement; + var div:HTMLDivElement = document.createElement('div') as HTMLDivElement; + div.className = "mdl-textfield mdl-js-textfield"; - input = document.createElement('input') as HTMLInputElement; + var input:HTMLInputElement = document.createElement('input') as HTMLInputElement; input.setAttribute('type', 'text'); input.className = 'mdl-textfield__input'; - - label = document.createElement('label') as HTMLLabelElement; - label.className = "mdl-textfield__label"; - _textNode = textNode = document.createTextNode('') as Text; + //attach input handler to dispatch flexjs change event when user write in textinput + //goog.events.listen(element, 'change', killChangeHandler); + goog.events.listen(input, 'input', textChangeHandler); + + var label:HTMLLabelElement = document.createElement('label') as HTMLLabelElement; + label.className = "mdl-textfield__label"; + + var textNode:Text = document.createTextNode('') as Text; label.appendChild(textNode); div.appendChild(input); div.appendChild(label); - element = div as WrappedHTMLElement; - - //attach input handler to dispatch flexjs change event when user write in textinput - //goog.events.listen(element, 'change', killChangeHandler); - goog.events.listen(input, 'input', textChangeHandler); - - positioner = element; + element = input as WrappedHTMLElement; + + positioner = div as WrappedHTMLElement; positioner.style.position = 'relative'; - (div as WrappedHTMLElement).flexjs_wrapper = this; (input as WrappedHTMLElement).flexjs_wrapper = this; (label as WrappedHTMLElement).flexjs_wrapper = this; element.flexjs_wrapper = this; - className = typeNames = "mdl-textfield mdl-js-textfield"; - return element; } @@ -114,26 +107,8 @@ package org.apache.flex.mdl _mdlEffect = value; COMPILE::JS { - className = _mdlEffect; + positioner.className = positioner.className + " " + _mdlEffect; } } - - /** - * @private - */ - override public function set text(value:String):void - { - //COMPILE::SWF - //{ - //inSetter = true; - //ITextModel(model).text = value; - //inSetter = false; - //} - COMPILE::JS - { - _textNode.nodeValue = value; - dispatchEvent(new Event('textChange')); - } - } } }