Skip to content
This repository has been archived by the owner on Oct 8, 2021. It is now read-only.

Commit

Permalink
Merge f3ab667 into 09832f3
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabriel "_|Nix|_" Schulhof committed Jan 22, 2014
2 parents 09832f3 + f3ab667 commit 41453e8
Show file tree
Hide file tree
Showing 2 changed files with 103 additions and 0 deletions.
1 change: 1 addition & 0 deletions demos/jqm-contents.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
<li data-filtertext="ajax navigation navigate widget history event method"><a href="../navigation/" data-ajax="false">Navigation</a></li>
<li data-filtertext="linking pages page links navigation ajax prefetch cache"><a href="../navigation-linking-pages/" data-ajax="false">Linking pages</a></li>
<li data-filtertext="php redirect server redirection server-side navigation"><a href="../navigation-php-redirect/" data-ajax="false">PHP redirect demo</a></li>
<li data-filtertext="navigation redirection hash query"><a href="../navigation-hash-processing/" data-ajax="false">Hash processing demo</a></li>
</ul>
</li>
<li data-role="collapsible" data-collapsed-icon="carat-d" data-expanded-icon="carat-u" data-iconpos="right" data-inset="false">
Expand Down
102 changes: 102 additions & 0 deletions demos/navigation-hash-processing/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Hash Processing - Navigation - jQuery Mobile Demos</title>
<link rel="stylesheet" href="../../css/themes/default/jquery.mobile.css" />
<link rel="stylesheet" href="../_assets/css/jqm-demos.css" />
<link rel="shortcut icon" href="../favicon.ico">
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Open+Sans:300,400,700">
<script src="../../external/jquery/jquery.js"></script>
<script src="../_assets/js/"></script>
<script src="../../js/"></script>
<script id="demo-script">
$.mobile.document
.on( "pagecontainerbeforetransition", function( event, data ) {
var hashQuery, cleanHash, url, hash, absNoHash, queryParameters;

// Split the URL of the destination page into its components, retrieve the
// hash, create an object from the query string, and replace all URLs in
// data with a version that does not include the hash query string
url = $.mobile.path.parseUrl( data.absUrl );
hash = url.hash;
absNoHash = url.hrefNoHash;
queryParameters = {};
hashQuery = hash.split( "?" );
cleanHash = hashQuery[ 0 ] || "";

// We're only interested in the case where we're navigating to the
// secondary page
if ( cleanHash === "#secondary-page" ) {

// Assemble query parameters object from the query string
hashQuery = hashQuery.length > 1 ? hashQuery[ 1 ] : "";
$.each( hashQuery.split( "&" ), function( index, value ) {
var pair = value.split( "=" );

if ( pair.length > 0 && pair[ 0 ] ) {
queryParameters[ pair[ 0 ] ] =
( pair.length > 1 ? pair[ 1 ] : true );
}
});

$( "#section" ).text( queryParameters.section );
$( "#secondary-page" ).jqmData( "url", hash );
}
});
</script>
</head>
<body>
<div id="main-page" data-role="page" class="jqm-demos" data-quicklinks="true">

<div data-role="header" class="jqm-header">
<h2><a href="../" title="jQuery Mobile Demos home"><img src="../_assets/img/jquery-logo.png" alt="jQuery Mobile"></a></h2>
<p><span class="jqm-version"></span> Demos</p>
<a href="#" class="jqm-navmenu-link ui-btn ui-btn-icon-notext ui-corner-all ui-icon-bars ui-nodisc-icon ui-alt-icon ui-btn-left">Menu</a>
<a href="#" class="jqm-search-link ui-btn ui-btn-icon-notext ui-corner-all ui-icon-search ui-nodisc-icon ui-alt-icon ui-btn-right">Search</a>
</div><!-- /header -->

<div role="main" class="ui-content jqm-content">
<h1>Hash Processing</h1>
<p>If you wish to perform processing on the hash values as a user clicks the links to the various internal pages in your application, you can do so by handling the <code>pagecontainerbeforetransition</code> event.</p>
<div data-demo-html="#demo-page,#secondary-page" data-demo-js="#demo-script">
<a href="#demo-page" class="ui-btn ui-corner-all ui-shadow ui-btn-inline">Open Demo</a>
</div>
</div><!-- /content -->

<?php include( '../jqm-navmenu.php' ); ?>

<div data-role="footer" data-position="fixed" data-tap-toggle="false" class="jqm-footer">
<p>jQuery Mobile Demos version <span class="jqm-version"></span></p>
<p>Copyright 2014 The jQuery Foundation</p>
</div><!-- /footer -->

<?php include( '../jqm-search.php' ); ?>

</div><!-- /page -->

<div id="demo-page" data-role="page">
<div data-role="header">
<a href="#main-page" class="ui-btn ui-icon-back ui-btn-icon-left">Back To Demos</a>
<h1>Demo Main Page</h1>
</div>
<div role="main" class="ui-content">
<p>The following three buttons all take you to the same page. However, when you get there, you will notice that the title of the page is different depending on which button you have clicked.</p>
<a href="#secondary-page?section=My Area" class="ui-btn ui-corner-all ui-shadow ui-btn-inline">My Area</a>
<a href="#secondary-page?section=My Friends" class="ui-btn ui-corner-all ui-shadow ui-btn-inline">My Friends</a>
<a href="#secondary-page?section=My Items" class="ui-btn ui-corner-all ui-shadow ui-btn-inline">My Items</a>
</div>
</div>

<div id="secondary-page" data-role="page">
<div data-role="header">
<a href="#demo-page" class="ui-btn ui-icon-back ui-btn-icon-left">Back To Main Page</a>
<a href="#main-page" class="ui-btn ui-icon-arrow-u ui-btn-icon-left">Back To Demos</a>
<h1 id="section"></h1>
</div>
<div role="main" class="ui-content">
<p>This is the second page in the demo. Notice that, as you navigate to this page from the main page, the title of this page changes depending on which button on the main page you clicked.</p>
</div>
</body>
</html>

0 comments on commit 41453e8

Please sign in to comment.