Permalink
Browse files

RF-14302: fix location handling in mobile showcase

  • Loading branch information...
1 parent c70b963 commit 6da5d06a8b5f22a77285fab601d9ba8efd5fac97 @michpetrov michpetrov committed Jun 16, 2016
Showing with 16 additions and 3 deletions.
  1. +16 −3 examples/showcase/src/main/webapp/mobile/templates/main.xhtml
@@ -55,7 +55,7 @@
<a4j:status onstart="#{rich:element('ajaxLoader')}.style.visibility='visible'" onstop="#{rich:element('ajaxLoader')}.style.visibility='hidden'" />
</div>
</header>
- <h:form style="width:100%;height:100%;">
+ <h:form style="width:100%;height:100%;" id="fn">
<script>
var updateQueue = function(options) {
RichFaces.queue.setQueueOptions({"org.richfaces.queue.global":options});
@@ -76,17 +76,30 @@
};
var handleHashChange = function(demo,sample) {
+ console.log([demo,sample]);
+ isAjaxRequest = window.isAjaxRequest || false;
+ if (!isAjaxRequest) {
+ hashChange(demo,sample);
+ isAjaxRequest = false;
+ return;
+ }
slidfast.core.slideTo('component-page');
setUpQueue(sample);
+ isAjaxRequest = false;
};
$(window).on('load', function() {
var sample = '#{demoNavigator.currentSample.id}';
if (sample == 'queue') { // slide back after page refresh
+ isAjaxRequest = true;
location.hash = '#{demoNavigator.currentDemo.id}' + ":" + sample;
}
});
</script>
+ <a4j:jsFunction name="hashChange" render="componentPanel form menu" oncomplete="isAjaxRequest=true; handleHashChange('#{demoNavigator.currentDemo.id}','#{demoNavigator.currentSample.id}')">
+ <f:param name="demo" value="param1"/>
+ <f:param name="sample" value="param2"/>
+ </a4j:jsFunction>
<a4j:push id="pushTopics" address="pushTopics" ondataavailable="jQuery(#{rich:element('serverDate')}).text(event.rf.data)" rendered="#{(userAgent.phone || userAgent.tablet) and demoNavigator.currentDemo.id == 'push'}" />
</h:form>
@@ -95,14 +108,14 @@
<div id="home-page" class="page stage-left">
<nav>
<div class="nav-list">
- <h:form>
+ <h:form id="menu">
<rich:panelMenu activeItem="#{demoNavigator.currentDemo.id}">
<c:forEach items="#{demoNavigator.groups}" var="gr">
<rich:panelMenuGroup label="#{gr.name}" rightExpandedIcon="#{gr.newItems ? '/images/icons/new-ic.gif' : null}"
rightCollapsedIcon="#{gr.newItems ? '/images/icons/new-ic.gif' : null}">
<c:forEach items="#{gr.demos}" var="d">
- <rich:panelMenuItem label="#{d.name}" oncomplete="location.hash='#{d.id}:#{demoNavigator.currentSample.id}'" render="componentPanel form"
+ <rich:panelMenuItem label="#{d.name}" oncomplete="isAjaxRequest=true;location.hash='#{d.id}:#{demoNavigator.currentSample.id}'" render="componentPanel form"
rightIcon="#{(d.newItems || gr.newItem) ? '/images/icons/new-small-ic.gif' : null}">
<f:param name="demo" value="#{d.id}"/>
<f:param name="sample" value="#{demoNavigator.currentSample.id}"/>

0 comments on commit 6da5d06

Please sign in to comment.