mirror of
https://github.com/Hopiu/jquery-mobile.git
synced 2026-04-05 15:10:59 +00:00
style cleanups
This commit is contained in:
parent
49325216ed
commit
7c449fc791
1 changed files with 32 additions and 37 deletions
|
|
@ -7,23 +7,23 @@
|
|||
|
||||
(function( $, undefined ) {
|
||||
|
||||
$.mobile.page.prototype.options.backBtnText = "Back";
|
||||
$.mobile.page.prototype.options.addBackBtn = false;
|
||||
$.mobile.page.prototype.options.backBtnTheme = null;
|
||||
$.mobile.page.prototype.options.headerTheme = "a";
|
||||
$.mobile.page.prototype.options.footerTheme = "a";
|
||||
$.mobile.page.prototype.options.contentTheme = null;
|
||||
$.mobile.page.prototype.options.backBtnText = "Back";
|
||||
$.mobile.page.prototype.options.addBackBtn = false;
|
||||
$.mobile.page.prototype.options.backBtnTheme = null;
|
||||
$.mobile.page.prototype.options.headerTheme = "a";
|
||||
$.mobile.page.prototype.options.footerTheme = "a";
|
||||
$.mobile.page.prototype.options.contentTheme = null;
|
||||
|
||||
$( ":jqmData(role='page'), :jqmData(role='dialog')" ).live( "pagecreate", function( e ) {
|
||||
|
||||
var $page = $( this ),
|
||||
o = $page.data( "page" ).options,
|
||||
pageTheme = o.theme;
|
||||
var $page = $( this ),
|
||||
o = $page.data( "page" ).options,
|
||||
pageTheme = o.theme;
|
||||
|
||||
$( ":jqmData(role='header'), :jqmData(role='footer'), :jqmData(role='content')", this ).each(function() {
|
||||
var $this = $( this ),
|
||||
role = $this.jqmData( "role" ),
|
||||
theme = $this.jqmData( "theme" ),
|
||||
var $this = $( this ),
|
||||
role = $this.jqmData( "role" ),
|
||||
theme = $this.jqmData( "theme" ),
|
||||
$headeranchors,
|
||||
leftbtn,
|
||||
rightbtn,
|
||||
|
|
@ -36,35 +36,32 @@ $( ":jqmData(role='page'), :jqmData(role='dialog')" ).live( "pagecreate", functi
|
|||
|
||||
var thisTheme = theme || ( role === "header" ? o.headerTheme : o.footerTheme ) || pageTheme;
|
||||
|
||||
//add theme class
|
||||
$this.addClass( "ui-bar-" + thisTheme );
|
||||
|
||||
// Add ARIA role
|
||||
$this.attr( "role", role === "header" ? "banner" : "contentinfo" );
|
||||
$this
|
||||
//add theme class
|
||||
.addClass( "ui-bar-" + thisTheme )
|
||||
// Add ARIA role
|
||||
.attr( "role", role === "header" ? "banner" : "contentinfo" );
|
||||
|
||||
// Right,left buttons
|
||||
$headeranchors = $this.children( "a" );
|
||||
leftbtn = $headeranchors.hasClass( "ui-btn-left" );
|
||||
rightbtn = $headeranchors.hasClass( "ui-btn-right" );
|
||||
|
||||
if ( !leftbtn ) {
|
||||
leftbtn = $headeranchors.eq( 0 ).not( ".ui-btn-right" ).addClass( "ui-btn-left" ).length;
|
||||
}
|
||||
|
||||
if ( !rightbtn ) {
|
||||
rightbtn = $headeranchors.eq( 1 ).addClass( "ui-btn-right" ).length;
|
||||
}
|
||||
leftbtn = $headeranchors.hasClass( "ui-btn-left" );
|
||||
rightbtn = $headeranchors.hasClass( "ui-btn-right" );
|
||||
|
||||
leftbtn = leftbtn || $headeranchors.eq( 0 ).not( ".ui-btn-right" ).addClass( "ui-btn-left" ).length;
|
||||
|
||||
rightbtn = rightbtn || $headeranchors.eq( 1 ).addClass( "ui-btn-right" ).length;
|
||||
|
||||
// Auto-add back btn on pages beyond first view
|
||||
if ( o.addBackBtn && role === "header" &&
|
||||
$( ".ui-page" ).length > 1 &&
|
||||
$this.jqmData( "url" ) !== $.mobile.path.stripHash( location.hash ) &&
|
||||
!leftbtn ) {
|
||||
if ( o.addBackBtn &&
|
||||
role === "header" &&
|
||||
$( ".ui-page" ).length > 1 &&
|
||||
$this.jqmData( "url" ) !== $.mobile.path.stripHash( location.hash ) &&
|
||||
!leftbtn ) {
|
||||
|
||||
backBtn = $( "<a href='#' class='ui-btn-left' data-"+ $.mobile.ns +"rel='back' data-"+ $.mobile.ns +"icon='arrow-l'>"+ o.backBtnText +"</a>" ).prependTo( $this );
|
||||
|
||||
// If theme is provided, override default inheritance
|
||||
backBtn.attr( "data-"+ $.mobile.ns +"theme", o.backBtnTheme || thisTheme );
|
||||
backBtn = $( "<a href='#' class='ui-btn-left' data-"+ $.mobile.ns +"rel='back' data-"+ $.mobile.ns +"icon='arrow-l'>"+ o.backBtnText +"</a>" )
|
||||
// If theme is provided, override default inheritance
|
||||
.attr( "data-"+ $.mobile.ns +"theme", o.backBtnTheme || thisTheme )
|
||||
.prependTo( $this );
|
||||
}
|
||||
|
||||
// Page title
|
||||
|
|
@ -78,14 +75,12 @@ $( ":jqmData(role='page'), :jqmData(role='dialog')" ).live( "pagecreate", functi
|
|||
});
|
||||
|
||||
} else if ( role === "content" ) {
|
||||
|
||||
if (theme || o.contentTheme) {
|
||||
$this.addClass( "ui-body-" + ( theme || o.contentTheme ) );
|
||||
}
|
||||
|
||||
// Add ARIA role
|
||||
$this.attr( "role", "main" );
|
||||
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue