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 f36cdb5efd26f6425a4e1f06eaa209dec4c3d97b Author: Alex Harui <aha...@apache.org> AuthorDate: Fri Feb 2 14:08:47 2018 -0800 implement routing in ASDoc --- .../ASDoc/src/main/royale/ASDocMainView.mxml | 42 +++++++++++++++++++--- 1 file changed, 38 insertions(+), 4 deletions(-) diff --git a/examples/royale/ASDoc/src/main/royale/ASDocMainView.mxml b/examples/royale/ASDoc/src/main/royale/ASDocMainView.mxml index e7340aa..0b7f84d 100644 --- a/examples/royale/ASDoc/src/main/royale/ASDocMainView.mxml +++ b/examples/royale/ASDoc/src/main/royale/ASDocMainView.mxml @@ -22,6 +22,7 @@ limitations under the License. xmlns:rs="library://ns.apache.org/royale/site" xmlns:local="*" width="100%" height="100%" + initComplete="applicationModel.addEventListener('packageListChanged', packagesReadyHandler)" > <fx:Script> <![CDATA[ @@ -29,6 +30,12 @@ limitations under the License. import org.apache.royale.events.Event; import org.apache.royale.events.DetailEvent; + private function packagesReadyHandler(event:Event):void + { + // wait until package data is ready before updating initial view to any anchor hash + updateView(); + } + public var currentPackage:String; private function packageChangedHandler():void @@ -62,6 +69,32 @@ limitations under the License. dispatchEvent(new DetailEvent(viewBeads.selected ? "addTag" : "removeTag", false, false, "viewbead")); } + private function updateView():void + { + var hash:String = router.hash; + if (hash.charAt(0) == "#") + hash = hash.substring(1); + if (!hash) + currentState = "packages"; + else + { + var c:int = hash.indexOf("/"); + if (c != -1) + { + var pkg:String = hash.substr(0, c); + packageList.selectedItem = pkg; + packageChangedHandler(); + var cls:String = hash.substr(c + 1); + classList.selectedItem = cls; + classChangedHandler(); + } + else + { + packageList.selectedItem = hash; + packageChangedHandler(); + } + } + } ]]> </fx:Script> <fx:Style> @@ -108,7 +141,8 @@ limitations under the License. </js:states> <js:beads> <js:ViewDataBinding /> - <js:OneFlexibleChildVerticalLayoutForOverflow flexibleChild="topContainer" /> + <js:OneFlexibleChildVerticalLayoutForOverflow flexibleChild="topContainer" /> + <js:HashChangeNotifierBead id="router" hashChange="updateView()" /> </js:beads> <rs:DocTopBar /> <rs:DocTagline /> @@ -129,10 +163,10 @@ limitations under the License. <js:beads> <js:VerticalLayout /> </js:beads> - <js:List id="packageList" dataProvider="{ASDocModel(applicationModel).packageList}" change="packageChangedHandler()" + <js:List id="packageList" dataProvider="{ASDocModel(applicationModel).packageList}" width="100%" height="50%" itemRenderer="HashAnchorStringItemRenderer"/> - <js:List id="classList" dataProvider="{ASDocModel(applicationModel).classList}" change="classChangedHandler()" + <js:List id="classList" dataProvider="{ASDocModel(applicationModel).classList}" width="100%" height="50%" itemRenderer="HashAnchorStringItemRenderer" labelField="label" /> </js:Group> @@ -147,7 +181,7 @@ limitations under the License. </js:beads> <js:Label className="paneTitle" text="All Packages" width="100%"/> <js:List className="paneList" id="packagePaneList" dataProvider="{ASDocModel(applicationModel).packageList}" - itemRenderer="AltBGRenderer" change="packageListChangedHandler()"/> + itemRenderer="AltBGRenderer"/> </js:Group> <js:Group id="detailsPane" width="100%" includeIn="classDetail"> <js:beads> -- To stop receiving notification emails like this one, please contact aha...@apache.org.