You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by pi...@apache.org on 2021/09/17 09:50:00 UTC

[royale-asjs] 03/03: Jewel Validator: Add "noErrorTip" property which prevents from displaying error tooltip near required field

This is an automated email from the ASF dual-hosted git repository.

piotrz pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-asjs.git

commit 9f6f459610c7de831f2a02eb5925bbd7ed3f4a01
Author: Piotr Zarzycki <pi...@gmail.com>
AuthorDate: Fri Sep 17 11:49:44 2021 +0200

    Jewel Validator: Add "noErrorTip" property which prevents from displaying error tooltip near required field
---
 .../royale/jewel/beads/validators/Validator.as     | 54 ++++++++++++++++------
 1 file changed, 39 insertions(+), 15 deletions(-)

diff --git a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/validators/Validator.as b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/validators/Validator.as
index 3e2fb64..adcf9eb 100644
--- a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/validators/Validator.as
+++ b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/validators/Validator.as
@@ -300,6 +300,25 @@ package org.apache.royale.jewel.beads.validators
             _requiredFieldError = value;
 		}
 
+		private var _noErrorTip:Boolean;
+		/**
+		 *  If true removes displaying error tip
+		 *  Default false
+		 *
+		 *  @langversion 3.0
+		 *  @playerversion Flash 10.2
+		 *  @playerversion AIR 2.6
+		 *  @productversion Royale 0.9.9
+		 */
+		public function get noErrorTip():Boolean
+		{
+			return _noErrorTip;
+		}
+		public function set noErrorTip(value:Boolean):void
+		{
+			_noErrorTip = value;
+		}
+
 		/**
 		 *  Performs validation and return the result.
 		 *  When result is false(invalid), errorTip appears on the control.
@@ -367,26 +386,31 @@ package org.apache.royale.jewel.beads.validators
 			if (!errorText)
 				return;
 
-			if (_errorTip == null) {
-				_errorTip = new ErrorTipLabel();
+			if (!noErrorTip) {
+				if (_errorTip == null) {
+					_errorTip = new ErrorTipLabel();
 
-				_host = UIUtils.findPopUpHost(hostComponent);
-				_host.popUpParent.addElement(_errorTip, false);
-				IEventDispatcher(_host.popUpParent).addEventListener("cleanValidationErrors", cleanValidationErrorsHandler);
-			}
-			COMPILE::JS
-			{
-				hostComponent.element.addEventListener("blur",removeTip);
-			}
+					_host = UIUtils.findPopUpHost(hostComponent);
+					_host.popUpParent.addElement(_errorTip, false);
+					IEventDispatcher(_host.popUpParent).addEventListener("cleanValidationErrors", cleanValidationErrorsHandler);
+				}
+				COMPILE::JS
+				{
+					hostComponent.element.addEventListener("blur", removeTip);
+				}
 
-            _errorTip.text = errorText;
+				_errorTip.text = errorText;
+
+				COMPILE::JS
+				{
+					window.addEventListener('resize', repositionHandler, false);
+					window.addEventListener('scroll', repositionHandler, true);
+					repositionHandler();
+				}
+			}
 
 			COMPILE::JS
 			{
-				window.addEventListener('resize', repositionHandler, false);
-				window.addEventListener('scroll', repositionHandler, true);
-				repositionHandler();
-
 				createErrorBorder();
 			}
 		}