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

Commit

Permalink
Page: Add option enhance
Browse files Browse the repository at this point in the history
Enhances the page only if the option is on, which, by
default, it is.

Fixes gh-7416
Closes gh-7897
  • Loading branch information
Gabriel Schulhof committed Apr 6, 2015
1 parent f911c53 commit b347f0d
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 2 deletions.
5 changes: 4 additions & 1 deletion js/widgets/page.js
Expand Up @@ -46,6 +46,7 @@ $.widget( "mobile.page", {

// Deprecated in 1.4 remove in 1.5
contentTheme: null,
enhance: true,
enhanced: false
},

Expand All @@ -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();
Expand Down
11 changes: 11 additions & 0 deletions tests/integration/page/enhance.html
@@ -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>
5 changes: 4 additions & 1 deletion tests/integration/page/index.html
Expand Up @@ -20,7 +20,8 @@

],
[ "init" ],
[ "page_title_entity.js" ]
[ "page_title_entity.js" ],
[ "page_enhance_within.js" ]
]);
</script>

Expand All @@ -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">
Expand Down
11 changes: 11 additions & 0 deletions tests/integration/page/no-enhance.html
@@ -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>
21 changes: 21 additions & 0 deletions tests/integration/page/page_enhance_within.js
@@ -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
]);
});
1 change: 1 addition & 0 deletions tests/integration/page/page_title_entity.js
Expand Up @@ -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
Expand Down

0 comments on commit b347f0d

Please sign in to comment.