You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by ca...@apache.org on 2016/11/03 19:16:42 UTC

[22/29] git commit: [flex-asjs] [refs/heads/feature/mdl] - Changes in TextInput

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/a593dd99
Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/a593dd99
Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/a593dd99

Branch: refs/heads/feature/mdl
Commit: a593dd999ab71010192f6f1a4ab0d3e93febfc3e
Parents: e9dd895
Author: Carlos Rovira <ca...@apache.org>
Authored: Tue Oct 25 19:02:37 2016 +0200
Committer: Carlos Rovira <ca...@apache.org>
Committed: Thu Nov 3 20:15:48 2016 +0100

----------------------------------------------------------------------
 .../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/a593dd99/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/a593dd99/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'));
-            }
-		}
 	}
 }