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 2018/05/01 11:13:39 UTC
[royale-asjs] branch develop updated: Add a bead to force
descendants of a container to inherit a style attribute
This is an automated email from the ASF dual-hosted git repository.
yishayw pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-asjs.git
The following commit(s) were added to refs/heads/develop by this push:
new e1bc712 Add a bead to force descendants of a container to inherit a style attribute
e1bc712 is described below
commit e1bc7129e5de49d1894d53dbc4422d9f7d104b44
Author: DESKTOP-RH4S838\Yishay <yi...@hotmail.com>
AuthorDate: Tue May 1 14:13:31 2018 +0300
Add a bead to force descendants of a container to inherit a style attribute
---
.../Basic/src/main/resources/basic-manifest.xml | 1 +
.../royale/html/beads/StyleInheritanceBead.as | 102 +++++++++++++++++++++
2 files changed, 103 insertions(+)
diff --git a/frameworks/projects/Basic/src/main/resources/basic-manifest.xml b/frameworks/projects/Basic/src/main/resources/basic-manifest.xml
index 6d00cc9..15c8597 100644
--- a/frameworks/projects/Basic/src/main/resources/basic-manifest.xml
+++ b/frameworks/projects/Basic/src/main/resources/basic-manifest.xml
@@ -87,6 +87,7 @@
<component id="ListView" class="org.apache.royale.html.beads.ListView"/>
<component id="AccordionView" class="org.apache.royale.html.beads.AccordionView"/>
<component id="CenterElement" class="org.apache.royale.html.beads.CenterElement"/>
+ <component id="StyleInheritanceBead" class="org.apache.royale.html.beads.StyleInheritanceBead"/>
<component id="CrossBrowserFireListenerOverrideBead" class="org.apache.royale.html.beads.CrossBrowserFireListenerOverrideBead" />
<component id="AccessibilityAltBead" class="org.apache.royale.html.beads.AccessibilityAltBead" />
<component id="DataGridColumnChangePropagator" class="org.apache.royale.html.beads.DataGridColumnChangePropagator" />
diff --git a/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/StyleInheritanceBead.as b/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/StyleInheritanceBead.as
new file mode 100644
index 0000000..28326ed
--- /dev/null
+++ b/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/StyleInheritanceBead.as
@@ -0,0 +1,102 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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.IRenderedObject;
+ import org.apache.royale.core.IStrand;
+ import org.apache.royale.core.IBead;
+ COMPILE::JS {
+ import org.apache.royale.events.IEventDispatcher;
+ import org.apache.royale.core.WrappedHTMLElement;
+ }
+
+ /**
+ * The StyleInheritanceBead class forces descendadants of an IStylableObject to inherit a style
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion Royale 9.3
+ */
+ public class StyleInheritanceBead implements IBead
+ {
+ /**
+ * constructor.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion Royale 9.3
+ */
+ public function StyleInheritanceBead()
+ {
+ }
+
+ public var styleName:String;
+ private var _strand:IStrand;
+
+ /**
+ * @copy org.apache.royale.core.IBead#strand
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion Royale 9.3
+ */
+ public function set strand(value:IStrand):void
+ {
+ _strand = value;
+ COMPILE::JS
+ {
+ (value as IEventDispatcher).addEventListener('initComplete', initCompleteHandler);
+ }
+ }
+
+ /**
+ * @royaleignorecoercion org.apache.royale.core.WrappedHTMLElement
+ */
+ COMPILE::JS
+ private function get hostElement():WrappedHTMLElement
+ {
+ return (_strand as IRenderedObject).element;
+ }
+
+ COMPILE::JS
+ private function initCompleteHandler(e:Event):void
+ {
+ forceInheritanceOnDescendants();
+ }
+
+ /**
+ * @royaleignorecoercion org.apache.royale.core.WrappedHTMLElement
+ */
+ COMPILE::JS
+ private function forceInheritanceOnDescendants():void
+ {
+ var elements:NodeList = hostElement.querySelectorAll("*");
+ for (var i:int = 0; i < elements.length; i++)
+ {
+ var htmlElement:WrappedHTMLElement = elements[i] as WrappedHTMLElement;
+ if (htmlElement)
+ {
+ htmlElement.style[styleName] = "inherit";
+ }
+ }
+ }
+ }
+}
--
To stop receiving notification emails like this one, please contact
yishayw@apache.org.