flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From carlosrov...@apache.org
Subject flex-asjs git commit: Solve a bug in change text field that was not removing prompt. But must be revisited since this should be handled through model and not directly from component, but model is missing when queried…
Date Sun, 01 Jan 2017 19:39:09 GMT
Repository: flex-asjs
Updated Branches:
  refs/heads/develop 81bf74d4c -> fadd9f0a2


Solve a bug in change text field that was not removing prompt. But must be revisited since
this should be handled through model and not directly from component, but model is missing
when queried…


Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/fadd9f0a
Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/fadd9f0a
Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/fadd9f0a

Branch: refs/heads/develop
Commit: fadd9f0a2d3d039383f1d21f55c7c39e392ca51a
Parents: 81bf74d
Author: Carlos Rovira <carlosrovira@apache.org>
Authored: Sun Jan 1 20:39:06 2017 +0100
Committer: Carlos Rovira <carlosrovira@apache.org>
Committed: Sun Jan 1 20:39:06 2017 +0100

----------------------------------------------------------------------
 .../org/apache/flex/mdl/beads/TextPrompt.as     | 71 ++++++++++++++------
 .../src/main/resources/defaults.css             | 14 ++++
 2 files changed, 63 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fadd9f0a/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/beads/TextPrompt.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/beads/TextPrompt.as
b/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/beads/TextPrompt.as
index 413892a..31178b6 100644
--- a/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/beads/TextPrompt.as
+++ b/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/beads/TextPrompt.as
@@ -32,6 +32,7 @@ package org.apache.flex.mdl.beads
 	import org.apache.flex.events.IEventDispatcher;
 
     import org.apache.flex.mdl.supportClasses.ITextField;
+	import org.apache.flex.mdl.supportClasses.TextFieldBase;
 	
 	/**
 	 *  The TextPrompt class is a specialty bead that can be used with
@@ -92,15 +93,15 @@ package org.apache.flex.mdl.beads
 		{
 			_strand = value;
 			
+			//var model:Object = UIBase(_strand).model;
+			// listen for changes in text to hide or show the prompt
+			//if (!model.hasOwnProperty("text")) {
+			//	throw new Error("Model requires a text property when used with TextPromptBead");
+			//}
+			IEventDispatcher(UIBase(_strand)).addEventListener("textChange", handleTextChange);
+
 			COMPILE::SWF
 			{
-				// listen for changes in text to hide or show the prompt
-				var model:Object = UIBase(_strand).model;
-				if (!model.hasOwnProperty("text")) {
-					throw new Error("Model requires a text property when used with TextPromptBead");
-				}
-				IEventDispatcher(model).addEventListener("textChange", handleTextChange);
-				
 				// create a TextField that displays the prompt - it shows
 				// and hides based on the model's content
 				promptField = new CSSTextField();
@@ -114,37 +115,63 @@ package org.apache.flex.mdl.beads
 				// trigger the event handler to display if needed
 				handleTextChange(null);					
 			}
+
 			COMPILE::JS
 			{
-				var mdlTi:ITextField = value as ITextField;
+				mdlTi = value as ITextField;
                 mdlTi.textNode.nodeValue = prompt;
+				
 				//var e:HTMLInputElement = host.element as HTMLInputElement;
 				//e.placeholder = prompt;
 			}
 		}
 		
+		private var promptAdded:Boolean;
+		
+		COMPILE::JS
+		private var mdlTi:ITextField;
+
 		COMPILE::SWF
 		private var promptField:CSSTextField;
-		private var promptAdded:Boolean;
+		
 		
 		/**
 		 * @private
 		 */
-		COMPILE::SWF
 		private function handleTextChange( event:Event ):void
-		{	
-			// see what the model currently has to determine if the prompt should be
-			// displayed or not.
-			var model:Object = UIBase(_strand).model;
-			
-			if (model.text != null && model.text.length > 0 ) {
-				if (promptAdded) UIBase(_strand).$displayObjectContainer.removeChild(promptField);
-				promptAdded = false;
+		{
+			COMPILE::SWF
+			{
+				// see what the model currently has to determine if the prompt should be
+				// displayed or not.
+				var model:Object = UIBase(_strand).model;
+				
+				if (model.text != null && model.text.length > 0 ) {
+					if (promptAdded) UIBase(_strand).$displayObjectContainer.removeChild(promptField);
+					promptAdded = false;
+				}
+				else {
+					if (!promptAdded) UIBase(_strand).$displayObjectContainer.addChild(promptField);
+					promptField.text = prompt;
+					promptAdded = true;
+				}
 			}
-			else {
-				if (!promptAdded) UIBase(_strand).$displayObjectContainer.addChild(promptField);
-				promptField.text = prompt;
-				promptAdded = true;
+
+			COMPILE::JS
+			{
+				// see what the model currently has to determine if the prompt should be
+				// displayed or not.
+				var model:Object = UIBase(_strand).model;
+				
+				if (TextFieldBase(mdlTi).text != null && TextFieldBase(mdlTi).text.length >
0 )
+				{
+					mdlTi.textNode.nodeValue = "";
+				} 
+				else 
+				{
+					mdlTi.textNode.nodeValue = prompt;
+				}
+				
 			}
 		}
 	}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fadd9f0a/frameworks/projects/MaterialDesignLite/src/main/resources/defaults.css
----------------------------------------------------------------------
diff --git a/frameworks/projects/MaterialDesignLite/src/main/resources/defaults.css b/frameworks/projects/MaterialDesignLite/src/main/resources/defaults.css
index 1ebf7dc..681d838 100644
--- a/frameworks/projects/MaterialDesignLite/src/main/resources/defaults.css
+++ b/frameworks/projects/MaterialDesignLite/src/main/resources/defaults.css
@@ -20,6 +20,20 @@
 
 @namespace "library://ns.apache.org/flexjs/mdl";
 
+TextField
+{
+    IBeadModel: ClassReference("org.apache.flex.html.beads.models.TextModel");
+    /*IBeadView: ClassReference("org.apache.flex.html.beads.TextInputWithBorderView");
+    IBeadController: ClassReference("org.apache.flex.html.beads.controllers.EditableTextKeyboardController");*/
+}
+
+TextArea
+{
+    IBeadModel: ClassReference("org.apache.flex.html.beads.models.TextModel");
+    /*IBeadView: ClassReference("org.apache.flex.html.beads.TextInputWithBorderView");
+    IBeadController: ClassReference("org.apache.flex.html.beads.controllers.EditableTextKeyboardController");*/
+}
+
 CheckBox
 {
     IBeadModel: ClassReference("org.apache.flex.html.beads.models.ToggleButtonModel");		



Mime
View raw message