Skip to content

Commit 7c449fc

Browse files
committed
style cleanups
1 parent 4932521 commit 7c449fc

File tree

1 file changed

+33
-38
lines changed

1 file changed

+33
-38
lines changed

js/jquery.mobile.page.sections.js

Lines changed: 33 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,23 @@
77

88
(function( $, undefined ) {
99

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;
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;
1616

1717
$( ":jqmData(role='page'), :jqmData(role='dialog')" ).live( "pagecreate", function( e ) {
1818

19-
var $page = $( this ),
20-
o = $page.data( "page" ).options,
21-
pageTheme = o.theme;
19+
var $page = $( this ),
20+
o = $page.data( "page" ).options,
21+
pageTheme = o.theme;
2222

2323
$( ":jqmData(role='header'), :jqmData(role='footer'), :jqmData(role='content')", this ).each(function() {
24-
var $this = $( this ),
25-
role = $this.jqmData( "role" ),
26-
theme = $this.jqmData( "theme" ),
24+
var $this = $( this ),
25+
role = $this.jqmData( "role" ),
26+
theme = $this.jqmData( "theme" ),
2727
$headeranchors,
2828
leftbtn,
2929
rightbtn,
@@ -36,35 +36,32 @@ $( ":jqmData(role='page'), :jqmData(role='dialog')" ).live( "pagecreate", functi
3636

3737
var thisTheme = theme || ( role === "header" ? o.headerTheme : o.footerTheme ) || pageTheme;
3838

39-
//add theme class
40-
$this.addClass( "ui-bar-" + thisTheme );
41-
42-
// Add ARIA role
43-
$this.attr( "role", role === "header" ? "banner" : "contentinfo" );
39+
$this
40+
//add theme class
41+
.addClass( "ui-bar-" + thisTheme )
42+
// Add ARIA role
43+
.attr( "role", role === "header" ? "banner" : "contentinfo" );
4444

4545
// Right,left buttons
4646
$headeranchors = $this.children( "a" );
47-
leftbtn = $headeranchors.hasClass( "ui-btn-left" );
48-
rightbtn = $headeranchors.hasClass( "ui-btn-right" );
49-
50-
if ( !leftbtn ) {
51-
leftbtn = $headeranchors.eq( 0 ).not( ".ui-btn-right" ).addClass( "ui-btn-left" ).length;
52-
}
53-
54-
if ( !rightbtn ) {
55-
rightbtn = $headeranchors.eq( 1 ).addClass( "ui-btn-right" ).length;
56-
}
47+
leftbtn = $headeranchors.hasClass( "ui-btn-left" );
48+
rightbtn = $headeranchors.hasClass( "ui-btn-right" );
5749

50+
leftbtn = leftbtn || $headeranchors.eq( 0 ).not( ".ui-btn-right" ).addClass( "ui-btn-left" ).length;
51+
52+
rightbtn = rightbtn || $headeranchors.eq( 1 ).addClass( "ui-btn-right" ).length;
53+
5854
// Auto-add back btn on pages beyond first view
59-
if ( o.addBackBtn && role === "header" &&
60-
$( ".ui-page" ).length > 1 &&
61-
$this.jqmData( "url" ) !== $.mobile.path.stripHash( location.hash ) &&
62-
!leftbtn ) {
63-
64-
backBtn = $( "<a href='#' class='ui-btn-left' data-"+ $.mobile.ns +"rel='back' data-"+ $.mobile.ns +"icon='arrow-l'>"+ o.backBtnText +"</a>" ).prependTo( $this );
65-
66-
// If theme is provided, override default inheritance
67-
backBtn.attr( "data-"+ $.mobile.ns +"theme", o.backBtnTheme || thisTheme );
55+
if ( o.addBackBtn &&
56+
role === "header" &&
57+
$( ".ui-page" ).length > 1 &&
58+
$this.jqmData( "url" ) !== $.mobile.path.stripHash( location.hash ) &&
59+
!leftbtn ) {
60+
61+
backBtn = $( "<a href='#' class='ui-btn-left' data-"+ $.mobile.ns +"rel='back' data-"+ $.mobile.ns +"icon='arrow-l'>"+ o.backBtnText +"</a>" )
62+
// If theme is provided, override default inheritance
63+
.attr( "data-"+ $.mobile.ns +"theme", o.backBtnTheme || thisTheme )
64+
.prependTo( $this );
6865
}
6966

7067
// Page title
@@ -78,14 +75,12 @@ $( ":jqmData(role='page'), :jqmData(role='dialog')" ).live( "pagecreate", functi
7875
});
7976

8077
} else if ( role === "content" ) {
81-
8278
if (theme || o.contentTheme) {
8379
$this.addClass( "ui-body-" + ( theme || o.contentTheme ) );
8480
}
8581

8682
// Add ARIA role
8783
$this.attr( "role", "main" );
88-
8984
}
9085
});
9186
});

0 commit comments

Comments
 (0)