Permalink
Browse files

Page: Add option enhance

Enhances the page only if the option is on, which, by
default, it is.

Fixes gh-7416
Closes gh-7897
  • Loading branch information...
gabrielschulhof committed Jan 5, 2015
1 parent f911c53 commit b347f0d20e965211d508dc9d60bdaf1350b0ceb5
View
@@ -46,6 +46,7 @@ $.widget( "mobile.page", {
// Deprecated in 1.4 remove in 1.5
contentTheme: null,
enhance: true,
enhanced: false
},
@@ -71,7 +72,9 @@ $.widget( "mobile.page", {
pagebeforeshow: "_handlePageBeforeShow"
});
this.element.enhanceWithin();
if ( this.options.enhance ) {
this.element.enhanceWithin();
}
// Dialog widget is deprecated in 1.4 remove this in 1.5
if ( $.mobile.getAttribute( this.element[0], "role" ) === "dialog" && $.mobile.dialog ) {
this.element.dialog();
@@ -0,0 +1,11 @@
<html>
<head>
<title>Enhance Page</title>
<body>
<div data-nstest-role="page" id="enhance">
<div data-nstest-role="header" id="enhance-header">
<h2>Page Header</h2>
</div>
</div>
</body>
</html>
@@ -20,7 +20,8 @@
],
[ "init" ],
[ "page_title_entity.js" ]
[ "page_title_entity.js" ],
[ "page_enhance_within.js" ]
]);
</script>
@@ -36,6 +37,8 @@
<div data-nstest-role="page">
<a id="openTestPage" href="#title-test">Go</a>
<a href="enhance.html" id="open-enhance">Enhance Within</a>
<a href="no-enhance.html" id="open-no-enhance">No Enhance Within</a>
</div>
<div data-nstest-role="page" id="title-test">
@@ -0,0 +1,11 @@
<html>
<head>
<title>Do Not Enhance Page</title>
<body>
<div data-nstest-role="page" id="no-enhance" data-nstest-enhance="false">
<div data-nstest-role="header" id="no-enhance-header">
<h2>Page Header</h2>
</div>
</div>
</body>
</html>
@@ -0,0 +1,21 @@
asyncTest( "Option enhance", function() {
$.testHelper.pageSequence([
function() {
$( "#open-enhance" ).click();
},
function() {
deepEqual( !!$( "#enhance-header" ).toolbar( "instance" ), true,
"Page with option enhance contains a toolbar widget" );
$.mobile.back();
},
function() {
$( "#open-no-enhance" ).click();
},
function() {
deepEqual( !!$( "#no-enhance-header" ).toolbar( "instance" ), false,
"Page with option enhance turned off contains no toolbar widget" );
$.mobile.back();
},
start
]);
});
@@ -11,6 +11,7 @@
deepEqual( $.mobile.activePage.attr( "id" ), "title-test", "Title test page is active" );
deepEqual( document.title.length > 0, true, "Document title is not empty" );
deepEqual( !!document.title.match(/&([a-zA-Z]+|#([0-9]+|[xX][0-9a-fA-F]+));/), false, "Document title contains no character references" );
$.mobile.back();
},
start

0 comments on commit b347f0d

Please sign in to comment.