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

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

commit bd31916070745db3add66ce1bc34a7e93fdc86ca
Author: Alex Harui <aha...@apache.org>
AuthorDate: Fri Feb 2 12:24:31 2018 -0800

    use hash anchor links
---
 .../ASDoc/src/main/royale/ASDocMainView.mxml       | 17 +++-
 ...gBackgroundColorHashAnchorStringItemRenderer.as | 96 ++++++++++++++++++++++
 .../main/royale/HashAnchorStringItemRenderer.as    | 66 +++++++++++++++
 .../ASDoc/src/main/royale/models/ASDocModel.as     |  4 +-
 4 files changed, 178 insertions(+), 5 deletions(-)

diff --git a/examples/royale/ASDoc/src/main/royale/ASDocMainView.mxml 
b/examples/royale/ASDoc/src/main/royale/ASDocMainView.mxml
index 19f92dc..e7340aa 100644
--- a/examples/royale/ASDoc/src/main/royale/ASDocMainView.mxml
+++ b/examples/royale/ASDoc/src/main/royale/ASDocMainView.mxml
@@ -20,6 +20,7 @@ limitations under the License.
 <rs:DocPage xmlns:fx="http://ns.adobe.com/mxml/2009";
                                xmlns:js="library://ns.apache.org/royale/basic"
                                xmlns:rs="library://ns.apache.org/royale/site"
+                               xmlns:local="*"
                            width="100%" height="100%"
                            >
     <fx:Script>
@@ -64,6 +65,8 @@ limitations under the License.
                ]]>
     </fx:Script>
        <fx:Style>
+           @namespace "*";
+           
         .sectionLabel{
             font-size: 16px;
             font-weight: bold;
@@ -89,10 +92,14 @@ limitations under the License.
                border-style: solid;
         }
         
+        .HashAnchorAnchor {
+            text-decoration: none;
+        }
+        
        </fx:Style>
        <fx:Declarations>
                <fx:Component className="AltBGRenderer">
-                   <js:AlternatingBackgroundColorStringItemRenderer 
backgroundColor0="#ffffff" backgroundColor1="#ffeeee" />
+                   
<local:AlternatingBackgroundColorHashAnchorStringItemRenderer 
backgroundColor0="#ffffff" backgroundColor1="#ffeeee" />
                </fx:Component>
        </fx:Declarations>
        <js:states>
@@ -122,8 +129,12 @@ limitations under the License.
             <js:beads>
                 <js:VerticalLayout />
             </js:beads>
-            <js:List id="packageList" 
dataProvider="{ASDocModel(applicationModel).packageList}" 
change="packageChangedHandler()" width="100%" height="50%"/>
-            <js:List id="classList" 
dataProvider="{ASDocModel(applicationModel).classList}" 
change="classChangedHandler()"  width="100%" height="50%"/>
+            <js:List id="packageList" 
dataProvider="{ASDocModel(applicationModel).packageList}" 
change="packageChangedHandler()" 
+               width="100%" height="50%"
+               itemRenderer="HashAnchorStringItemRenderer"/>
+            <js:List id="classList" 
dataProvider="{ASDocModel(applicationModel).classList}" 
change="classChangedHandler()"  
+               width="100%" height="50%"
+               itemRenderer="HashAnchorStringItemRenderer" labelField="label" 
/>
         </js:Group>
         <js:Container className="rightSide" id="rightSide" height="100%">
             <js:beads>
diff --git 
a/examples/royale/ASDoc/src/main/royale/AlternatingBackgroundColorHashAnchorStringItemRenderer.as
 
b/examples/royale/ASDoc/src/main/royale/AlternatingBackgroundColorHashAnchorStringItemRenderer.as
new file mode 100644
index 0000000..6033830
--- /dev/null
+++ 
b/examples/royale/ASDoc/src/main/royale/AlternatingBackgroundColorHashAnchorStringItemRenderer.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
+{
+
+       /**
+        *  The AlternatingBackgroundColorHashAnchorItemRenderer class displays 
data in string form using the data's toString()
+        *  function and alternates between two background colors.  This is the 
most simple implementation for immutable lists
+        *  and will not handle adding/removing renderers.
+        *
+        *  @langversion 3.0
+        *  @playerversion Flash 10.2
+        *  @playerversion AIR 2.6
+        *  @productversion Royale 0.0
+        */
+       public class AlternatingBackgroundColorHashAnchorStringItemRenderer 
extends HashAnchorStringItemRenderer
+       {
+               /**
+                *  constructor.
+                *
+                *  @langversion 3.0
+                *  @playerversion Flash 10.2
+                *  @playerversion AIR 2.6
+                *  @productversion Royale 0.0
+                */
+               public function 
AlternatingBackgroundColorHashAnchorStringItemRenderer()
+               {
+               }
+
+               private var _color0:String;
+               
+               public function get backgroundColor0():String
+               {
+                       return _color0;
+               }
+               public function set backgroundColor0(value:String):void
+               {
+                       _color0 = value;
+               }
+               
+               private var _color1:String;
+               
+               public function get backgroundColor1():String
+               {
+                       return _color1;
+               }
+               public function set backgroundColor1(value:String):void
+               {
+                       _color1 = value;
+               }
+               
+               private var oddIndex:Boolean;
+               
+               override public function addedToParent():void
+               {
+                       super.addedToParent();
+
+                       var index:int = parent.getElementIndex(this);
+                       oddIndex = ((index % 2) == 1)
+                       COMPILE::JS
+                       {
+                               element.style.backgroundColor = oddIndex ? 
_color1 : _color0;
+                       }
+               }
+
+               /**
+                * @private
+                */
+               override public function updateRenderer():void
+               {
+                       super.updateRenderer();
+                       COMPILE::JS
+                       {
+                               if (element.style.backgroundColor == null || 
element.style.backgroundColor == "")
+                                       element.style.backgroundColor = 
oddIndex ? _color1 : _color0;
+                       }
+               }
+
+       }
+}
diff --git 
a/examples/royale/ASDoc/src/main/royale/HashAnchorStringItemRenderer.as 
b/examples/royale/ASDoc/src/main/royale/HashAnchorStringItemRenderer.as
new file mode 100644
index 0000000..274c215
--- /dev/null
+++ b/examples/royale/ASDoc/src/main/royale/HashAnchorStringItemRenderer.as
@@ -0,0 +1,66 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+{
+import  org.apache.royale.html.supportClasses.StringItemRenderer;
+
+       /**
+        *  The HashAnchorStringItemRenderer class displays data in string form 
using the data's toString()
+        *  function.  It assumes the data is an encoding of class, package or 
function name and
+        *  sets up the renderer so the controller logic will open the right 
document.  On JS, by
+        *  using anchor tags, it should allow the browser to dictate 
permalinks and allow
+        *  search engines to crawl the app.
+        *
+        *  @langversion 3.0
+        *  @playerversion Flash 10.2
+        *  @playerversion AIR 2.6
+        *  @productversion Royale 0.0
+        */
+       public class HashAnchorStringItemRenderer extends StringItemRenderer
+       {
+               /**
+                *  constructor.
+                *
+                *  @langversion 3.0
+                *  @playerversion Flash 10.2
+                *  @playerversion AIR 2.6
+                *  @productversion Royale 0.0
+                */
+               public function HashAnchorStringItemRenderer()
+               {
+                       typeNames += " HashAnchorStringItemRenderer"
+               }
+
+               override public function set text(value:String):void
+               {
+            COMPILE::SWF
+            {
+                textField.text = value;
+            }
+            COMPILE::JS
+            {
+               var href:String = data.href;
+               if (!href) // assume package name
+                       href = value;
+                this.element.innerHTML = "<a href='#" + href + "' 
class='HashAnchorAnchor'>" + value + "</a>";
+            }
+               }
+
+       }
+}
diff --git a/examples/royale/ASDoc/src/main/royale/models/ASDocModel.as 
b/examples/royale/ASDoc/src/main/royale/models/ASDocModel.as
index 02ba5e4..cf13d92 100644
--- a/examples/royale/ASDoc/src/main/royale/models/ASDocModel.as
+++ b/examples/royale/ASDoc/src/main/royale/models/ASDocModel.as
@@ -148,9 +148,9 @@ package models
                 for (var p:String in packageData)
                 {
                     if (filter == null)
-                        arr.push(p);
+                        arr.push({ label: p, href: value + "/" + p});
                     else if (filter(packageData[p]))
-                        arr.push(p);
+                        arr.push({ label: p, href: value + "/" + p});
                 }
                 arr.sort();
                 _classList = arr;

-- 
To stop receiving notification emails like this one, please contact
aha...@apache.org.

Reply via email to