You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by yi...@apache.org on 2019/02/28 17:27:42 UTC

[royale-asjs] 01/01: First implementation

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

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

commit 416b16d582b9a91b44660c2957a8b4b6851bfdf4
Author: DESKTOP-RH4S838\Yishay <yi...@hotmail.com>
AuthorDate: Thu Feb 28 19:27:07 2019 +0200

    First implementation
---
 .../Basic/src/main/resources/basic-manifest.xml    |   1 +
 .../royale/org/apache/royale/html/LoadIndicator.as |  59 +++++++++
 .../apache/royale/html/beads/DisableLoaderBead.as  | 138 +++++++++++++++++++++
 3 files changed, 198 insertions(+)

diff --git a/frameworks/projects/Basic/src/main/resources/basic-manifest.xml b/frameworks/projects/Basic/src/main/resources/basic-manifest.xml
index 65e8a13..82d2990 100644
--- a/frameworks/projects/Basic/src/main/resources/basic-manifest.xml
+++ b/frameworks/projects/Basic/src/main/resources/basic-manifest.xml
@@ -148,6 +148,7 @@
     <component id="UnselectableElementBead" class="org.apache.royale.html.beads.UnselectableElementBead"/>
     <component id="DisableBead" class="org.apache.royale.html.beads.DisableBead" />
     <component id="DisabledAlphaBead" class="org.apache.royale.html.beads.DisabledAlphaBead" />
+    <component id="DisableLoaderBead" class="org.apache.royale.html.beads.DisableLoaderBead" />
     <component id="DisableChildrenBead" class="org.apache.royale.html.beads.DisableChildrenBead" />
     <component id="NumericOnlyTextInputBead" class="org.apache.royale.html.accessories.NumericOnlyTextInputBead" />
     <component id="PasswordInputBead" class="org.apache.royale.html.accessories.PasswordInputBead" />
diff --git a/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/LoadIndicator.as b/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/LoadIndicator.as
new file mode 100644
index 0000000..d60c098
--- /dev/null
+++ b/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/LoadIndicator.as
@@ -0,0 +1,59 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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.royale.html
+{
+	
+	import org.apache.royale.core.UIBase;
+	COMPILE::JS
+	{
+		import org.apache.royale.core.WrappedHTMLElement;
+	}
+	
+    /**
+     *  The loader class provides an animated indicator
+     *
+     *  @toplevel
+     *  @langversion 3.0
+     *  @playerversion Flash 10.2
+     *  @playerversion AIR 2.6
+     *  @productversion Royale 0.9.6
+     */
+	public class LoadIndicator extends UIBase
+	{
+		public function LoadIndicator()
+		{
+		}
+		
+		COMPILE::JS
+		/**
+		 *  @royaleignorecoercion org.apache.royale.core.WrappedHTMLElement
+		 */
+		override protected function createElement():WrappedHTMLElement
+		{
+			element = document.createElementNS('http://www.w3.org/2000/svg', 'svg') as WrappedHTMLElement;
+			
+			// initially undefined could be set to null
+			if (positioner == null)
+				positioner = element;
+			element.setAttribute("viewBox","0 0 50 50");
+			element.innerHTML = '<path fill="#FF6700" d="M25.251,6.461c-10.318,0-18.683,8.365-18.683,18.683h4.068c0-8.071,6.543-14.615,14.615-14.615V6.461z"><animateTransform attributeType="xml" attributeName="transform" type="rotate" from="0 25 25" to="360 25 25" dur="0.6s" repeatCount="indefinite"/></path>';
+			return positioner;
+		}
+	}
+}
diff --git a/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/DisableLoaderBead.as b/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/DisableLoaderBead.as
new file mode 100644
index 0000000..deb6d59
--- /dev/null
+++ b/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/DisableLoaderBead.as
@@ -0,0 +1,138 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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.royale.html.beads
+{
+	import org.apache.royale.core.IBead;
+	import org.apache.royale.core.IParent;
+	import org.apache.royale.core.IStrand;
+	import org.apache.royale.core.IUIBase;
+	import org.apache.royale.events.ValueEvent;
+	import org.apache.royale.geom.Point;
+	import org.apache.royale.html.LoadIndicator;
+	import org.apache.royale.utils.PointUtils;
+
+	COMPILE::JS
+    {
+		import org.apache.royale.core.WrappedHTMLElement;
+	}
+	/**
+	 *  The DisableLoaderBead class is a specialty bead that can be used with
+	 *  any UIBase control which has a DisableBead attached.
+	 *  
+	 *  @langversion 3.0
+	 *  @playerversion Flash 10.2
+	 *  @playerversion AIR 2.6
+	 *  @productversion Royale 0.9.6
+	 */
+	public class DisableLoaderBead implements IBead
+	{
+		/**
+		 *  constructor.
+		 *
+		 *  @langversion 3.0
+		 *  @playerversion Flash 10.2
+		 *  @playerversion AIR 2.6
+		 *  @productversion Royale 0.9.6
+		 */
+		public function DisableLoaderBead()
+		{
+		}
+		
+		private var _strand:IStrand;
+		private var _loader:IUIBase;
+
+		/**
+		 *  @copy org.apache.royale.core.IBead#strand
+		 *  
+		 *  @langversion 3.0
+		 *  @playerversion Flash 10.2
+		 *  @playerversion AIR 2.6
+		 *  @productversion Royale 0.9.6
+		 */
+		public function set strand(value:IStrand):void
+		{	
+			COMPILE::JS
+			{
+				_strand = value;
+				host.addEventListener("disabledChange", disabledChangeHandler);
+				updateHost(null);
+			}
+		}
+
+		private function disabledChangeHandler(e:ValueEvent):void
+		{
+			updateHost(e.value);
+		}
+		
+        /**
+         * @royaleignorecoercion org.apache.royale.core.IUIBase
+         */
+		private function get host():IUIBase
+		{
+			return _strand as IUIBase;
+		}
+
+		private function updateHost(value:Object):void
+		{
+			COMPILE::JS
+			{
+				if(!_strand)//bail out
+					return;
+				
+				var disabled:Boolean;
+				if(value == null)
+				{
+					var disableBead:DisableBead = _strand.getBeadByType(DisableBead) as DisableBead;
+					if(!disableBead)// The DisableBead was not added yet. We'll set this when the event is dispatched.
+						return;
+					disabled = disableBead.disabled;
+				} else {
+					disabled = value;
+				}
+				if (disabled)
+				{
+					addLoadIndicator();
+				} else
+				{
+					removeLoadIndicator();
+				}
+			}
+		}
+		
+		protected function addLoadIndicator():void
+		{
+			var point:Point = PointUtils.localToGlobal(new Point(host.x, host.y), host);
+			_loader = new LoadIndicator();
+			_loader.x = point.x;
+			_loader.y = point.y;
+			_loader.width = host.width;
+			_loader.height = host.height;
+			COMPILE::JS
+			{
+				_loader.element.style.position = "absolute";
+			}
+			(host.topMostEventDispatcher as IParent).addElement(_loader);
+		}
+		
+		protected function removeLoadIndicator():void
+		{
+			_loader.parent.removeElement(_loader);
+		}
+	}
+}