flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From carlosrov...@apache.org
Subject git commit: [flex-asjs] [refs/heads/develop] - Numeric TextField bead
Date Tue, 29 Nov 2016 22:05:31 GMT
Repository: flex-asjs
Updated Branches:
  refs/heads/develop 059b1f5a1 -> 9f867260d


Numeric TextField bead


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

Branch: refs/heads/develop
Commit: 9f867260d238c0251607db061712f3362a431276
Parents: 059b1f5
Author: Carlos Rovira <carlosrovira@apache.org>
Authored: Tue Nov 29 23:05:24 2016 +0100
Committer: Carlos Rovira <carlosrovira@apache.org>
Committed: Tue Nov 29 23:05:24 2016 +0100

----------------------------------------------------------------------
 .../MDLExample/src/main/flex/TextFields.mxml    |  16 ++-
 .../flex/org/apache/flex/mdl/beads/Numeric.as   | 129 +++++++++++++++++++
 .../src/main/resources/mdl-manifest.xml         |   1 +
 3 files changed, 145 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/9f867260/examples/flexjs/MDLExample/src/main/flex/TextFields.mxml
----------------------------------------------------------------------
diff --git a/examples/flexjs/MDLExample/src/main/flex/TextFields.mxml b/examples/flexjs/MDLExample/src/main/flex/TextFields.mxml
index 6ddceed..e5fadf6 100644
--- a/examples/flexjs/MDLExample/src/main/flex/TextFields.mxml
+++ b/examples/flexjs/MDLExample/src/main/flex/TextFields.mxml
@@ -26,7 +26,7 @@ limitations under the License.
     
         <!-- Text Fields :: https://getmdl.io/components/index.html#textfields-section
-->
         <js:Form action="#">
-            <mdl:TextField id="mdlti" change="mdlfloatingti.text = mdlti.text" className="mdlti_example">
+            <mdl:TextField id="mdlti" change="mdlfloatingti.text = mdlti.text">
                 <js:beads>
                     <mdl:TextPrompt prompt="Normal Text Field..."/>
                 </js:beads>
@@ -38,6 +38,20 @@ limitations under the License.
                 <mdl:TextPrompt prompt="Floating Label"/>
             </js:beads>
         </mdl:TextField>
+
+        <mdl:TextField>
+            <js:beads>
+                <mdl:TextPrompt prompt="Number..."/>
+                <mdl:Numeric text="This is not a number."/>
+            </js:beads>
+        </mdl:TextField>
+
+        <mdl:TextField floatingLabel="true">
+            <js:beads>
+                <mdl:TextPrompt prompt="Number..."/>
+                <mdl:Numeric/>
+            </js:beads>
+        </mdl:TextField>
     
     </mdl:Grid>
 

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/9f867260/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/beads/Numeric.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/beads/Numeric.as
b/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/beads/Numeric.as
new file mode 100644
index 0000000..6f28433
--- /dev/null
+++ b/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/beads/Numeric.as
@@ -0,0 +1,129 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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.mdl.beads
+{
+	COMPILE::SWF
+	{
+		import flash.text.TextFieldType;			
+		
+		import org.apache.flex.core.CSSTextField;
+	}
+	
+	import org.apache.flex.core.IBead;
+	import org.apache.flex.core.IStrand;
+	import org.apache.flex.core.UIBase;
+	import org.apache.flex.events.Event;
+	import org.apache.flex.events.IEventDispatcher;
+
+    import org.apache.flex.mdl.TextField;
+	
+	/**
+	 *  The TextPrompt class is a specialty bead that can be used with
+	 *  any TextField control. The bead places a string into the input field
+	 *  when there is no value associated with the text property.
+	 *  
+	 *  @langversion 3.0
+	 *  @playerversion Flash 10.2
+	 *  @playerversion AIR 2.6
+	 *  @productversion FlexJS 0.0
+	 */
+	public class Numeric implements IBead
+	{
+		/**
+		 *  constructor.
+		 *
+		 *  @langversion 3.0
+		 *  @playerversion Flash 10.2
+		 *  @playerversion AIR 2.6
+		 *  @productversion FlexJS 0.0
+		 */
+		public function Numeric()
+		{
+		}
+		
+		private var _pattern:String = "-?[0-9]*(\.[0-9]+)?";
+		
+		/**
+		 *  The string to use as numeric pattern.
+		 *
+		 *  @langversion 3.0
+		 *  @playerversion Flash 10.2
+		 *  @playerversion AIR 2.6
+		 *  @productversion FlexJS 0.0
+		 */
+		public function get pattern():String
+		{
+			return _pattern;
+		}
+		public function set pattern(value:String):void
+		{
+			_pattern = value;
+		}
+		
+        private var _text:String = "Input is not a number!";
+
+        /**
+		 *  The string to use as error text in the associated span.
+		 *
+		 *  @langversion 3.0
+		 *  @playerversion Flash 10.2
+		 *  @playerversion AIR 2.6
+		 *  @productversion FlexJS 0.0
+		 */
+        public function get text():String
+        {
+            return _text;
+        }
+        public function set text(value:String):void
+        {
+            _text = value;
+        }
+
+		private var _strand:IStrand;
+		
+		/**
+		 *  @copy org.apache.flex.core.IBead#strand
+		 *  
+		 *  @langversion 3.0
+		 *  @playerversion Flash 10.2
+		 *  @playerversion AIR 2.6
+		 *  @productversion FlexJS 0.0
+		 *  @flexjsignorecoercion HTMLInputElement
+		 *  @flexjsignorecoercion org.apache.flex.core.UIBase;
+		 */
+		public function set strand(value:IStrand):void
+		{
+			_strand = value;
+			
+			COMPILE::JS
+			{
+				var mdlTi:TextField = value as TextField;
+                mdlTi.input.setAttribute('pattern', pattern);
+
+                var span:HTMLSpanElement = document.createElement('span') as HTMLSpanElement;
+                span.className = "mdl-textfield__error";
+
+                var spanTextNode:Text = document.createTextNode(text) as Text;
+                span.appendChild(spanTextNode);
+
+                mdlTi.positioner.appendChild(span);
+			}
+		}
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/9f867260/frameworks/projects/MaterialDesignLite/src/main/resources/mdl-manifest.xml
----------------------------------------------------------------------
diff --git a/frameworks/projects/MaterialDesignLite/src/main/resources/mdl-manifest.xml b/frameworks/projects/MaterialDesignLite/src/main/resources/mdl-manifest.xml
index de38b0d..f552067 100644
--- a/frameworks/projects/MaterialDesignLite/src/main/resources/mdl-manifest.xml
+++ b/frameworks/projects/MaterialDesignLite/src/main/resources/mdl-manifest.xml
@@ -27,6 +27,7 @@
     <component id="RadioButton" class="org.apache.flex.mdl.RadioButton"/>
     <component id="Switch" class="org.apache.flex.mdl.Switch"/>
     <component id="TextPrompt" class="org.apache.flex.mdl.beads.TextPrompt"/>
+    <component id="Numeric" class="org.apache.flex.mdl.beads.Numeric"/>
     <component id="Disabled" class="org.apache.flex.mdl.beads.Disabled"/>
     <component id="Slider" class="org.apache.flex.mdl.Slider"/>
     <component id="Badge" class="org.apache.flex.mdl.beads.Badge"/>


Mime
View raw message