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 71484c4afee6be0a250eb771839a88aa1c590459
Author: Alex Harui <aha...@apache.org>
AuthorDate: Fri Feb 2 14:08:30 2018 -0800

    simple routing for JS
---
 .../Basic/src/main/resources/basic-manifest.xml    |  2 +
 .../royale/routing/HashChangeNotifierBead.as       | 99 ++++++++++++++++++++++
 2 files changed, 101 insertions(+)

diff --git a/frameworks/projects/Basic/src/main/resources/basic-manifest.xml 
b/frameworks/projects/Basic/src/main/resources/basic-manifest.xml
index 4da5734..620cd3c 100644
--- a/frameworks/projects/Basic/src/main/resources/basic-manifest.xml
+++ b/frameworks/projects/Basic/src/main/resources/basic-manifest.xml
@@ -196,4 +196,6 @@
     <component id="TreeGrid" class="org.apache.royale.html.TreeGrid" />
     <component id="TreeGridColumn" 
class="org.apache.royale.html.supportClasses.TreeGridColumn" />
 
+    <component id="HashChangeNotifierBead" 
class="org.apache.royale.routing.HashChangeNotifierBead" />
+
 </componentPackage>
diff --git 
a/frameworks/projects/Basic/src/main/royale/org/apache/royale/routing/HashChangeNotifierBead.as
 
b/frameworks/projects/Basic/src/main/royale/org/apache/royale/routing/HashChangeNotifierBead.as
new file mode 100644
index 0000000..0102403
--- /dev/null
+++ 
b/frameworks/projects/Basic/src/main/royale/org/apache/royale/routing/HashChangeNotifierBead.as
@@ -0,0 +1,99 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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.routing
+{
+       
+       import org.apache.royale.core.IBead;
+       import org.apache.royale.core.IStrand;
+       import org.apache.royale.events.Event;
+       import org.apache.royale.events.IEventDispatcher;
+       import org.apache.royale.events.EventDispatcher;
+
+       /**
+     *  Dispatched when the hash portion of the URL has changed
+     *
+     *  @langversion 3.0
+     *  @playerversion Flash 10.2
+     *  @playerversion AIR 2.6
+     *  @productversion Royale 0.9
+     */
+    [Event(name="hashChange", type="org.apache.royale.events.Event")]
+    
+       /**
+        *  The HashChangeNotifierBead class allows you to respond to the hash 
changing on the url.
+        *  
+        *  @langversion 3.0
+        *  @playerversion Flash 10.2
+        *  @playerversion AIR 2.6
+        *  @productversion Royale 0.9
+        */
+
+       public class HashChangeNotifierBead extends EventDispatcher implements 
IBead
+       {
+               /**
+                *  constructor.
+                *
+                *  @langversion 3.0
+                *  @playerversion Flash 10.2
+                *  @playerversion AIR 2.6
+                *  @productversion Royale 0.9
+                */
+               public function HashChangeNotifierBead()
+               {
+               }
+               
+               private var _strand:IStrand;
+               
+               /**
+                *  @copy org.apache.royale.core.IBead#strand
+                *  
+                *  @langversion 3.0
+                *  @playerversion Flash 10.2
+                *  @playerversion AIR 2.6
+                *  @productversion Royale 0.9
+                */
+               public function set strand(value:IStrand):void
+               {       
+                       _strand = value;
+                       COMPILE::JS
+                       {
+                               window.addEventListener("hashchange", 
hashChangeHandler);
+                       }
+               }
+               
+               public function get hash():String
+               {
+                       COMPILE::JS
+                       {
+                               return location.hash;
+                       }
+                       COMPILE::SWF
+                       {
+                               return null; //TODO (aharui) SWF impl
+                       }
+               }
+               
+               private function hashChangeHandler():void
+               {
+                       dispatchEvent(new Event("hashChange"));
+               }
+
+               
+       }
+}

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

Reply via email to