1 //>>excludeStart("jqmBuildExclude", pragmas.jqmBuildExclude);
2 //>>description: Theming and layout of headers, footers, and content areas
3 //>>label: Page Sections
6 define( [ "jquery", "./jquery.mobile.page", "./jquery.mobile.core", "./jquery.mobile.buttonMarkup" ], function( $ ) {
7 //>>excludeEnd("jqmBuildExclude");
8 (function( $, undefined ) {
10 $.mobile.page.prototype.options.backBtnText = "Back";
11 $.mobile.page.prototype.options.addBackBtn = false;
12 $.mobile.page.prototype.options.backBtnTheme = null;
13 $.mobile.page.prototype.options.headerTheme = "a";
14 $.mobile.page.prototype.options.footerTheme = "a";
15 $.mobile.page.prototype.options.contentTheme = null;
17 $( document ).delegate( ":jqmData(role='page'), :jqmData(role='dialog')", "pagecreate", function( e ) {
19 var $page = $( this ),
20 o = $page.data( "page" ).options,
21 pageRole = $page.jqmData( "role" ),
24 $( ":jqmData(role='header'), :jqmData(role='footer'), :jqmData(role='content')", this )
28 var $this = $( this ),
29 role = $this.jqmData( "role" ),
30 theme = $this.jqmData( "theme" ),
31 contentTheme = theme || o.contentTheme || ( pageRole === "dialog" && pageTheme ),
37 $this.addClass( "ui-" + role );
39 //apply theming and markup modifications to page,header,content,footer
40 if ( role === "header" || role === "footer" ) {
42 var thisTheme = theme || ( role === "header" ? o.headerTheme : o.footerTheme ) || pageTheme;
46 .addClass( "ui-bar-" + thisTheme )
48 .attr( "role", role === "header" ? "banner" : "contentinfo" );
50 if( role === "header") {
52 $headeranchors = $this.children( "a" );
53 leftbtn = $headeranchors.hasClass( "ui-btn-left" );
54 rightbtn = $headeranchors.hasClass( "ui-btn-right" );
56 leftbtn = leftbtn || $headeranchors.eq( 0 ).not( ".ui-btn-right" ).addClass( "ui-btn-left" ).length;
58 rightbtn = rightbtn || $headeranchors.eq( 1 ).addClass( "ui-btn-right" ).length;
61 // Auto-add back btn on pages beyond first view
64 $( ".ui-page" ).length > 1 &&
65 $page.jqmData( "url" ) !== $.mobile.path.stripHash( location.hash ) &&
68 backBtn = $( "<a href='#' class='ui-btn-left' data-"+ $.mobile.ns +"rel='back' data-"+ $.mobile.ns +"icon='arrow-l'>"+ o.backBtnText +"</a>" )
69 // If theme is provided, override default inheritance
70 .attr( "data-"+ $.mobile.ns +"theme", o.backBtnTheme || thisTheme )
75 $this.children( "h1, h2, h3, h4, h5, h6" )
76 .addClass( "ui-title" )
77 // Regardless of h element number in src, it becomes h1 for the enhanced page
83 } else if ( role === "content" ) {
85 $this.addClass( "ui-body-" + ( contentTheme ) );
89 $this.attr( "role", "main" );
95 //>>excludeStart("jqmBuildExclude", pragmas.jqmBuildExclude);
97 //>>excludeEnd("jqmBuildExclude");