Skip to content

Commit b314701

Browse files
committed
Merge remote-tracking branch 'upstream/master' into navigation
2 parents a36397b + 8e354a0 commit b314701

File tree

8 files changed

+207
-193
lines changed

8 files changed

+207
-193
lines changed

docs/content/content-grids.html

100755100644
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ <h2>Three-column grids</h2>
8080
&lt;div class=&quot;ui-block-a&quot;&gt;Block A&lt;/div&gt;
8181
&lt;div class=&quot;ui-block-b&quot;&gt;Block B&lt;/div&gt;
8282
&lt;div class=&quot;ui-block-c&quot;&gt;Block C&lt;/div&gt;
83-
&lt;/div&gt;&lt;!-- /grid-a --&gt;
83+
&lt;/div&gt;&lt;!-- /grid-b --&gt;
8484
</code></pre>
8585

8686
<p>This will produce a 33/33/33% grid for our content.</p>

docs/pages/docs-pages.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ <h2>Redirects and linking to directories</h2>
192192

193193
<p>However, you can work around this issue by returning your page div with a <code>data-url</code> attribute already specified. When you do this, jQuery Mobile will use that attribute's value for updating the URL, instead of the url used to request that page. This also allows you to return urls that change as the result of a redirect, for example, you might post a form to "/login.html" but return a page from the url "/account" after a successful submission. This tool allows you to take control of the jQuery Mobile history stack in these situations. Here's an example:</p>
194194

195-
<p>The following link points to "docs-links-urltest/index.html": <a href="docs-links-urltest/index.html">Test Link</a> which is a directory with an index page. The return page will update the hash as "docs/pages/docs-links-urltest/" with a trailing slash. This is done via the data-url attribute in that page's source. Keep in mind that the value will replace the entire hash, and it is up to you to replace it with a URL that actually resolves to the correct page when requested via refresh or deep link.</p>
195+
<p>The following link points to "docs-links-urltest/index.html": <a href="docs-links-urltest/index.html">Test Link</a> which is a directory with an index page. The return page will update the hash as "/docs/pages/docs-links-urltest/" with a trailing slash. This is done via the data-url attribute in that page's source. Keep in mind that the value will replace the entire hash, and it is up to you to replace it with a URL that actually resolves to the correct page when requested via refresh or deep link.</p>
196196

197197

198198
<p>Learn more about the technical details of the navigation model and <a href="docs-navmodel.html">Ajax, hashes and history</a> in jQuery mobile.</p>

js/jquery.mobile.init.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,11 @@
7373
initializePage: function(){
7474
//find present pages
7575
var $pages = $( ":jqmData(role='page')" );
76+
77+
//if no pages are found, create one with body's inner html
78+
if( !$pages.length ){
79+
$pages = $( "body" ).wrapInner( "<div data-" + $.mobile.ns + "role='page'></div>" ).children( 0 );
80+
}
7681

7782
//add dialogs, set data-url attrs
7883
$pages.add( ":jqmData(role='dialog')" ).each(function(){

js/jquery.mobile.navigation.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -648,6 +648,9 @@
648648
&& RegExp.$1 ) {
649649
url = fileUrl = path.getFilePath( RegExp.$1 );
650650
}
651+
else{
652+
653+
}
651654

652655
if ( base ) {
653656
base.set( fileUrl );
@@ -656,6 +659,11 @@
656659
//workaround to allow scripts to execute when included in page divs
657660
all.get( 0 ).innerHTML = html;
658661
page = all.find( ":jqmData(role='page'), :jqmData(role='dialog')" ).first();
662+
663+
//if page elem couldn't be found, create one and insert the body element's contents
664+
if( !page.length ){
665+
page = $( "<div data-" + $.mobile.ns + "role='page'>" + html.split( /<\/?body[^>]*>/gmi )[1] + "</div>" );
666+
}
659667

660668
if ( newPageTitle && !page.jqmData( "title" ) ) {
661669
page.jqmData( "title", newPageTitle );

tests/unit/init/init_core.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,19 @@
211211
start();
212212
}, 500);
213213
});
214+
215+
216+
asyncTest( "page element is generated when not present in ajax'd markup", function(){
217+
expect( 1 );
218+
$.mobile.changePage( "nopage.html" );
219+
220+
$( ":jqmData(url$='nopage.html')" ).live( "pagecreate", function(){
221+
ok(true, "page was created from dynamically loaded HTML that contained no page div" );
222+
start();
223+
} );
224+
});
225+
226+
214227

215228
});
216229
})(jQuery);
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/*
2+
* mobile init tests
3+
*/
4+
(function($){
5+
6+
7+
test( "page element is generated when not present in initial markup", function(){
8+
ok( $( ".ui-page" ).length, 1 );
9+
});
10+
11+
12+
})(jQuery);

tests/unit/init/nopage.html

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<title>jQuery Mobile Init Test Suite</title>
6+
<!-- meta viewport left out on purpose for test append -->
7+
<script src="../../../js/jquery.js"></script>
8+
<script src="../jquery.setNameSpace.js"></script>
9+
<script src="../../../js/"></script>
10+
<script src="../../../external/qunit.js"></script>
11+
<script src="../../jquery.testHelper.js"></script>
12+
<script src="init_core_nopage.js"></script>
13+
<link rel="stylesheet" href="../../../themes/default" />
14+
<link rel="stylesheet" href="../../../external/qunit.css"/>
15+
<style>
16+
[data-nstest-role="page"], [data-nstest-role="dialog"] {
17+
position: static !important;
18+
}
19+
</style>
20+
</head>
21+
22+
<h1 id="qunit-header">jQuery Mobile Init Test Suite</h1>
23+
<h2 id="qunit-banner"></h2>
24+
<h2 id="qunit-userAgent"></h2>
25+
<ol id="qunit-tests">
26+
</ol>
27+
28+
</body>
29+
</html>

0 commit comments

Comments
 (0)