Skip to content

Commit 8ec38ba

Browse files
committed
Merge pull request jquery-archive#2249 from rwldrn/jquery.mobile.init.js
Core Style Conformance: jquery.mobile.init.js
2 parents 0253e67 + 45ab6a9 commit 8ec38ba

File tree

1 file changed

+45
-45
lines changed

1 file changed

+45
-45
lines changed

js/jquery.mobile.init.js

Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -12,47 +12,47 @@
1212
$head = $( "head" ),
1313
$window = $( window );
1414

15-
//trigger mobileinit event - useful hook for configuring $.mobile settings before they're used
15+
// trigger mobileinit event - useful hook for configuring $.mobile settings before they're used
1616
$( window.document ).trigger( "mobileinit" );
1717

18-
//support conditions
19-
//if device support condition(s) aren't met, leave things as they are -> a basic, usable experience,
20-
//otherwise, proceed with the enhancements
18+
// support conditions
19+
// if device support condition(s) aren't met, leave things as they are -> a basic, usable experience,
20+
// otherwise, proceed with the enhancements
2121
if ( !$.mobile.gradeA() ) {
2222
return;
2323
}
24-
25-
// override ajaxEnabled on platforms that have known conflicts with hash history updates
24+
25+
// override ajaxEnabled on platforms that have known conflicts with hash history updates
2626
// or generally work better browsing in regular http for full page refreshes (BB5, Opera Mini)
27-
if( $.mobile.ajaxBlacklist ){
27+
if ( $.mobile.ajaxBlacklist ) {
2828
$.mobile.ajaxEnabled = false;
2929
}
3030

31-
//add mobile, initial load "rendering" classes to docEl
31+
// add mobile, initial load "rendering" classes to docEl
3232
$html.addClass( "ui-mobile ui-mobile-rendering" );
3333

34-
//loading div which appears during Ajax requests
35-
//will not appear if $.mobile.loadingMessage is false
34+
// loading div which appears during Ajax requests
35+
// will not appear if $.mobile.loadingMessage is false
3636
var $loader = $( "<div class='ui-loader ui-body-a ui-corner-all'><span class='ui-icon ui-icon-loading spin'></span><h1></h1></div>" );
3737

3838
$.extend($.mobile, {
3939
// turn on/off page loading message.
4040
showPageLoadingMsg: function() {
41-
if( $.mobile.loadingMessage ){
41+
if ( $.mobile.loadingMessage ) {
4242
var activeBtn = $( "." + $.mobile.activeBtnClass ).first();
43-
43+
4444
$loader
4545
.find( "h1" )
4646
.text( $.mobile.loadingMessage )
4747
.end()
4848
.appendTo( $.mobile.pageContainer )
49-
//position at y center (if scrollTop supported), above the activeBtn (if defined), or just 100px from top
50-
.css( {
51-
top: $.support.scrollTop && $(window).scrollTop() + $(window).height() / 2 ||
49+
// position at y center (if scrollTop supported), above the activeBtn (if defined), or just 100px from top
50+
.css({
51+
top: $.support.scrollTop && $window.scrollTop() + $window.height() / 2 ||
5252
activeBtn.length && activeBtn.offset().top || 100
53-
} );
53+
});
5454
}
55-
55+
5656
$html.addClass( "ui-loading" );
5757
},
5858

@@ -70,36 +70,36 @@
7070
},
7171

7272
// find and enhance the pages in the dom and transition to the first page.
73-
initializePage: function(){
74-
//find present pages
73+
initializePage: function() {
74+
// find present pages
7575
var $pages = $( ":jqmData(role='page')" );
76-
77-
//if no pages are found, create one with body's inner html
78-
if( !$pages.length ){
76+
77+
// if no pages are found, create one with body's inner html
78+
if ( !$pages.length ) {
7979
$pages = $( "body" ).wrapInner( "<div data-" + $.mobile.ns + "role='page'></div>" ).children( 0 );
8080
}
8181

82-
//add dialogs, set data-url attrs
83-
$pages.add( ":jqmData(role='dialog')" ).each(function(){
82+
// add dialogs, set data-url attrs
83+
$pages.add( ":jqmData(role='dialog')" ).each(function() {
8484
var $this = $(this);
8585

8686
// unless the data url is already set set it to the id
87-
if( !$this.jqmData('url') ){
87+
if ( !$this.jqmData("url") ) {
8888
$this.attr( "data-" + $.mobile.ns + "url", $this.attr( "id" ) );
8989
}
9090
});
9191

92-
//define first page in dom case one backs out to the directory root (not always the first page visited, but defined as fallback)
92+
// define first page in dom case one backs out to the directory root (not always the first page visited, but defined as fallback)
9393
$.mobile.firstPage = $pages.first();
9494

95-
//define page container
95+
// define page container
9696
$.mobile.pageContainer = $pages.first().parent().addClass( "ui-mobile-viewport" );
9797

98-
//cue page loading message
98+
// cue page loading message
9999
$.mobile.showPageLoadingMsg();
100100

101101
// if hashchange listening is disabled or there's no hash deeplink, change to the first page in the DOM
102-
if( !$.mobile.hashListeningEnabled || !$.mobile.path.stripHash( location.hash ) ){
102+
if ( !$.mobile.hashListeningEnabled || !$.mobile.path.stripHash( location.hash ) ) {
103103
$.mobile.changePage( $.mobile.firstPage, { transition: "none", reverse: true, changeHash: false, fromHashChange: true } );
104104
}
105105
// otherwise, trigger a hashchange to load a deeplink
@@ -108,28 +108,28 @@
108108
}
109109
}
110110
});
111-
112-
//initialize events now, after mobileinit has occurred
111+
112+
// initialize events now, after mobileinit has occurred
113113
$.mobile._registerInternalEvents();
114-
115-
//check which scrollTop value should be used by scrolling to 1 immediately at domready
116-
//then check what the scroll top is. Android will report 0... others 1
117-
//note that this initial scroll won't hide the address bar. It's just for the check.
118-
$(function(){
114+
115+
// check which scrollTop value should be used by scrolling to 1 immediately at domready
116+
// then check what the scroll top is. Android will report 0... others 1
117+
// note that this initial scroll won't hide the address bar. It's just for the check.
118+
$(function() {
119119
window.scrollTo( 0, 1 );
120120

121-
//if defaultHomeScroll hasn't been set yet, see if scrollTop is 1
122-
//it should be 1 in most browsers, but android treats 1 as 0 (for hiding addr bar)
123-
//so if it's 1, use 0 from now on
121+
// if defaultHomeScroll hasn't been set yet, see if scrollTop is 1
122+
// it should be 1 in most browsers, but android treats 1 as 0 (for hiding addr bar)
123+
// so if it's 1, use 0 from now on
124124
$.mobile.defaultHomeScroll = ( !$.support.scrollTop || $(window).scrollTop() === 1 ) ? 0 : 1;
125-
126-
//dom-ready inits
127-
if( $.mobile.autoInitializePage ){
125+
126+
// dom-ready inits
127+
if ( $.mobile.autoInitializePage ) {
128128
$( $.mobile.initializePage );
129129
}
130-
131-
//window load event
132-
//hide iOS browser chrome on load
130+
131+
// window load event
132+
// hide iOS browser chrome on load
133133
$window.load( $.mobile.silentScroll );
134134
});
135135
})( jQuery, this );

0 commit comments

Comments
 (0)