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

carlosrovira 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 92919d9  jewel-alternaterowcolor-beads: beads for List and Table to 
get alternate row colors. This could be temporal while we get compiler working 
with nth-child css styles
92919d9 is described below

commit 92919d9b88d8386677f6576032ea553f926a7721
Author: Carlos Rovira <[email protected]>
AuthorDate: Fri Jul 17 20:31:49 2020 +0200

    jewel-alternaterowcolor-beads: beads for List and Table to get alternate 
row colors. This could be temporal while we get compiler working with nth-child 
css styles
---
 .../Jewel/src/main/resources/jewel-manifest.xml    |   3 +
 .../beads/controls/list/ListAlternateRowColor.as   | 133 +++++++++++++++++++++
 .../beads/controls/table/TableAlternateRowColor.as | 102 ++++++++++++++++
 3 files changed, 238 insertions(+)

diff --git a/frameworks/projects/Jewel/src/main/resources/jewel-manifest.xml 
b/frameworks/projects/Jewel/src/main/resources/jewel-manifest.xml
index 866850f..ea516ef 100644
--- a/frameworks/projects/Jewel/src/main/resources/jewel-manifest.xml
+++ b/frameworks/projects/Jewel/src/main/resources/jewel-manifest.xml
@@ -110,6 +110,9 @@
 
     <component id="AssignTabContent" 
class="org.apache.royale.jewel.beads.controls.tabbar.AssignTabContent"/>
     
+    <component id="ListAlternateRowColor" 
class="org.apache.royale.jewel.beads.controls.list.ListAlternateRowColor"/>
+    <component id="TableAlternateRowColor" 
class="org.apache.royale.jewel.beads.controls.table.TableAlternateRowColor"/>
+
     <component id="HorizontalListScroll" 
class="org.apache.royale.jewel.beads.controls.list.HorizontalListScroll"/>
     <component id="VirtualListView" 
class="org.apache.royale.jewel.beads.views.VirtualListView"/>
 
diff --git 
a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/controls/list/ListAlternateRowColor.as
 
b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/controls/list/ListAlternateRowColor.as
new file mode 100644
index 0000000..40c7489
--- /dev/null
+++ 
b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/controls/list/ListAlternateRowColor.as
@@ -0,0 +1,133 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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.list
+{
+       COMPILE::JS
+       {
+       import org.apache.royale.utils.html.getClassStyle;
+       }
+       import org.apache.royale.core.IBead;
+       import org.apache.royale.core.IStrand;
+       import org.apache.royale.core.IStyledUIBase;
+       import org.apache.royale.core.UIBase;
+       import org.apache.royale.utils.IClassSelectorListSupport;
+       import org.apache.royale.utils.css.addDynamicSelector;
+       
+       /**
+        *  The ListAlternateRowColor bead is a specialty bead that can be used 
with
+        *  Jewel List control to alternate the background color of every row 
with two colors
+        * 
+        *  Note: This bead is temporal due to a bug in the css compiler that 
prevent add 'nth-child' rules
+        *  
+        *  @langversion 3.0
+        *  @playerversion Flash 10.2
+        *  @playerversion AIR 2.6
+        *  @productversion Royale 0.10.0
+        */
+       public class ListAlternateRowColor implements IBead
+       {
+               /**
+                *  constructor.
+                *
+                *  @langversion 3.0
+                *  @playerversion Flash 10.2
+                *  @playerversion AIR 2.6
+                *  @productversion Royale 0.10.0
+                */
+               public function ListAlternateRowColor()
+               {
+               }
+
+               private var _oddColor:String = "#ffffff";
+               /*
+                * The odd color value to use
+                */
+               public function get oddColor():String {
+                       return _oddColor;
+               }
+               public function set oddColor(value:String):void {
+                       _oddColor = value;
+               }
+               
+               private var _evenColor:String = "#fafafa";
+               /*
+                * The even color value to use
+                */
+               public function get evenColor():String {
+                       return _evenColor;
+               }
+               public function set evenColor(value:String):void {
+                       _evenColor = value;
+               }
+
+               protected var ruleName:String;
+               protected var _strand:IStyledUIBase;
+               
+               /**
+                *  @copy org.apache.royale.core.IBead#strand
+                *  
+                *  @langversion 3.0
+                *  @playerversion Flash 10.2
+                *  @playerversion AIR 2.6
+                *  @productversion Royale 0.10.0
+                */
+               public function set strand(value:IStrand):void
+               {
+                       _strand = value as IStyledUIBase;
+
+                       ruleName = "alternateRowColor-" + ((new 
Date()).getTime() + "-" + Math.floor(Math.random()*1000));
+
+                       createAlternateRowColorRule();
+
+                       var l:IClassSelectorListSupport = value as 
IClassSelectorListSupport;
+                       l.addClass(ruleName);
+               }
+
+               /**
+                * create the dynamic class selector
+                */
+               protected function createAlternateRowColorRule():void
+               {
+                       var emphasis:String =  _strand.emphasis ? "." + 
_strand.emphasis : ".primary";
+                       var bgColor:String;
+
+                       var style:String = "." + ruleName + " 
.jewel.item:nth-child(even)";
+                       addDynamicSelector(style, "background: " + evenColor + 
";");
+                       
+                       style = "." + ruleName + " .jewel.item:nth-child(odd)";
+                       addDynamicSelector(style, "background: " + oddColor + 
";");
+
+                       style = "." + ruleName + " .jewel.item" + emphasis + 
".hovered";
+                       COMPILE::JS
+                       {
+                       var styles:Object = getClassStyle(".jewel.item" + 
emphasis + ".hovered");
+                       bgColor = styles.background;
+                       }
+                       addDynamicSelector(style, "background: " + bgColor + 
";");
+                       
+                       style = "." + ruleName + " .jewel.item" + emphasis + 
".selected";
+                       COMPILE::JS
+                       {
+                       styles = getClassStyle(".jewel.item" + emphasis + 
".selected");
+                       bgColor = styles.background;
+                       }
+                       addDynamicSelector(style, "background: " + bgColor + 
";");
+               }
+       }
+}
diff --git 
a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/controls/table/TableAlternateRowColor.as
 
b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/controls/table/TableAlternateRowColor.as
new file mode 100644
index 0000000..7afe163
--- /dev/null
+++ 
b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/controls/table/TableAlternateRowColor.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.jewel.beads.controls.table
+{
+       import org.apache.royale.core.IBead;
+       import org.apache.royale.core.IStrand;
+       import org.apache.royale.utils.IClassSelectorListSupport;
+       import org.apache.royale.utils.css.addDynamicSelector;
+       
+       /**
+        *  The TableAlternateRowColor bead is a specialty bead that can be 
used with
+        *  Jewel Table control to alternate the background color of every row 
with two colors
+        *  
+        *  Note: This bead is temporal due to a bug in the css compiler that 
prevent add 'nth-child' rules
+        *  
+        *  @langversion 3.0
+        *  @playerversion Flash 10.2
+        *  @playerversion AIR 2.6
+        *  @productversion Royale 0.10.0
+        */
+       public class TableAlternateRowColor implements IBead
+       {
+               /**
+                *  constructor.
+                *
+                *  @langversion 3.0
+                *  @playerversion Flash 10.2
+                *  @playerversion AIR 2.6
+                *  @productversion Royale 0.10.0
+                */
+               public function TableAlternateRowColor()
+               {
+               }
+
+               private var _oddColor:String = "#ffffff";
+               /*
+                * The odd color value to use
+                */
+               public function get oddColor():String {
+                       return _oddColor;
+               }
+               public function set oddColor(value:String):void {
+                       _oddColor = value;
+               }
+               
+               private var _evenColor:String = "#fafafa";
+               /*
+                * The even color value to use
+                */
+               public function get evenColor():String {
+                       return _evenColor;
+               }
+               public function set evenColor(value:String):void {
+                       _evenColor = value;
+               }
+
+               protected var ruleName:String;
+
+               /**
+                *  @copy org.apache.royale.core.IBead#strand
+                *  
+                *  @langversion 3.0
+                *  @playerversion Flash 10.2
+                *  @playerversion AIR 2.6
+                *  @productversion Royale 0.10.0
+                */
+               public function set strand(value:IStrand):void
+               {
+                       ruleName = "alternateRowColor-" + ((new 
Date()).getTime() + "-" + Math.floor(Math.random()*1000));
+
+                       createAlternateRowColorRule();
+
+                       var l:IClassSelectorListSupport = value as 
IClassSelectorListSupport;
+                       l.addClass(ruleName);
+               }
+               
+               /**
+                * create the dynamic class selector
+                */
+               protected function createAlternateRowColorRule():void
+               {
+                       addDynamicSelector(".jewel.table." + ruleName + " 
.jewel.tablerow:nth-child(even)", "background: " + evenColor + ";");
+                       addDynamicSelector(".jewel.table." + ruleName + " 
.jewel.tablerow:nth-child(odd)", "background: " + oddColor + ";");
+               }
+       }
+}

Reply via email to