2 * This plugin handles theming and layout of headers, footers, and content areas
5 (function( $, undefined ) {
7 $.mobile.page.prototype.options.backBtnText = "Back";
8 $.mobile.page.prototype.options.addBackBtn = false;
9 $.mobile.page.prototype.options.backBtnTheme = null;
10 $.mobile.page.prototype.options.headerTheme = "a";
11 $.mobile.page.prototype.options.footerTheme = "a";
12 $.mobile.page.prototype.options.contentTheme = null;
14 $( ":jqmData(role='page'), :jqmData(role='dialog')" ).live( "pagecreate", function( e ) {
16 var $page = $( this ),
17 o = $page.data( "page" ).options,
18 pageRole = $page.jqmData( "role" ),
21 $( ":jqmData(role='header'), :jqmData(role='footer'), :jqmData(role='content')", this ).each(function() {
22 var $this = $( this ),
23 role = $this.jqmData( "role" ),
24 theme = $this.jqmData( "theme" ),
25 contentTheme = theme || o.contentTheme || ( pageRole === "dialog" && pageTheme ),
31 $this.addClass( "ui-" + role );
33 //apply theming and markup modifications to page,header,content,footer
34 if ( role === "header" || role === "footer" ) {
36 var thisTheme = theme || ( role === "header" ? o.headerTheme : o.footerTheme ) || pageTheme;
40 .addClass( "ui-bar-" + thisTheme )
42 .attr( "role", role === "header" ? "banner" : "contentinfo" );
45 $headeranchors = $this.children( "a" );
46 leftbtn = $headeranchors.hasClass( "ui-btn-left" );
47 rightbtn = $headeranchors.hasClass( "ui-btn-right" );
49 leftbtn = leftbtn || $headeranchors.eq( 0 ).not( ".ui-btn-right" ).addClass( "ui-btn-left" ).length;
51 rightbtn = rightbtn || $headeranchors.eq( 1 ).addClass( "ui-btn-right" ).length;
53 // Auto-add back btn on pages beyond first view
56 $( ".ui-page" ).length > 1 &&
57 $this.jqmData( "url" ) !== $.mobile.path.stripHash( location.hash ) &&
60 backBtn = $( "<a href='#' class='ui-btn-left' data-"+ $.mobile.ns +"rel='back' data-"+ $.mobile.ns +"icon='arrow-l'>"+ o.backBtnText +"</a>" )
61 // If theme is provided, override default inheritance
62 .attr( "data-"+ $.mobile.ns +"theme", o.backBtnTheme || thisTheme )
67 $this.children( "h1, h2, h3, h4, h5, h6" )
68 .addClass( "ui-title" )
69 // Regardless of h element number in src, it becomes h1 for the enhanced page
76 } else if ( role === "content" ) {
78 $this.addClass( "ui-body-" + ( contentTheme ) );
82 $this.attr( "role", "main" );