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

hugoferreira 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 b2cf5e914f New Jewel SectionContentVisibility bead
b2cf5e914f is described below

commit b2cf5e914f96d555d885a578f59c7075cac52c40
Author: Hugo Ferreira <[email protected]>
AuthorDate: Mon Oct 10 23:39:12 2022 +0100

    New Jewel SectionContentVisibility bead
---
 .../Jewel/src/main/resources/jewel-manifest.xml    |  1 +
 .../controls/tabbar/SectionContentVisibility.as    | 96 ++++++++++++++++++++++
 2 files changed, 97 insertions(+)

diff --git a/frameworks/projects/Jewel/src/main/resources/jewel-manifest.xml 
b/frameworks/projects/Jewel/src/main/resources/jewel-manifest.xml
index 219e42b33c..12fb65f392 100644
--- a/frameworks/projects/Jewel/src/main/resources/jewel-manifest.xml
+++ b/frameworks/projects/Jewel/src/main/resources/jewel-manifest.xml
@@ -101,6 +101,7 @@
     <component id="DateField" class="org.apache.royale.jewel.DateField"/>
     <component id="DataContainer" 
class="org.apache.royale.jewel.DataContainer" />
     <component id="ToolTipLabel" 
class="org.apache.royale.jewel.supportClasses.tooltip.ToolTipLabel" />
+    <component id="SectionContentVisibility" 
class="org.apache.royale.jewel.beads.controls.tabbar.SectionContentVisibility"/>
 
     <component id="Form" class="org.apache.royale.jewel.Form"/>
     <component id="FormItem" class="org.apache.royale.jewel.FormItem"/>
diff --git 
a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/controls/tabbar/SectionContentVisibility.as
 
b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/controls/tabbar/SectionContentVisibility.as
new file mode 100644
index 0000000000..a03a08cdc4
--- /dev/null
+++ 
b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/controls/tabbar/SectionContentVisibility.as
@@ -0,0 +1,96 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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.jewel.beads.controls.tabbar
+{
+       import org.apache.royale.events.Event;
+    import org.apache.royale.core.IStrand;
+    import org.apache.royale.jewel.SectionContent;
+    import org.apache.royale.jewel.TabBarContent;
+    import org.apache.royale.jewel.TabBar;
+    import org.apache.royale.core.IBead;
+
+       /**
+        *  The SectionContentVisibility class is a specialty bead that can be 
used with
+        *  SectionContent contained in TabBarContent. The bead add visible 
function to the TabBar section
+        *  
+        *  @langversion 3.0
+        *  @playerversion Flash 10.2
+        *  @playerversion AIR 2.6
+        *  @productversion Royale 0.9.9
+        */
+    public class SectionContentVisibility implements IBead
+    {
+        private var sectionContent:SectionContent;
+        private var _visible:Boolean = true;
+
+               public function SectionContentVisibility()
+               {
+                       super();
+               }
+
+        public function get visible():Boolean
+        {
+            return _visible;
+        }
+
+        public function set visible(value:Boolean):void
+        {
+            _visible = value;
+
+            if (sectionContent != null)
+                setTabVisibility();
+        }
+
+               /**                             
+                *  @copy org.apache.royale.core.IBead#strand
+                *
+                *  @langversion 3.0
+                *  @playerversion Flash 10.2
+                *  @playerversion AIR 2.6
+                *  @productversion Royale 0.9.9
+                */
+        public function set strand(value:IStrand):void
+               {
+            sectionContent = value as SectionContent;
+
+            (value as SectionContent).addEventListener("beadsAdded", 
childrenAddedHandler);
+               }
+
+        private function childrenAddedHandler(event:Event):void
+        {
+            sectionContent.removeEventListener("beadsAdded", 
childrenAddedHandler);
+
+            setTabVisibility();
+        }
+
+        private function setTabVisibility():void
+        {
+            var tabBar:TabBarContent = sectionContent.parent as TabBarContent;
+
+            COMPILE::JS
+               {
+                var styleDeclaration:CSSStyleDeclaration = 
(tabBar.parent.getElementAt(0) as 
TabBar).getElementAt(tabBar.getElementIndex(sectionContent)).element.style;
+                if (visible)
+                    styleDeclaration.removeProperty("display");
+                else
+                    styleDeclaration.display = "none";
+            }
+        }        
+    }
+}
\ No newline at end of file

Reply via email to