|
12 | 12 | $head = $( "head" ), |
13 | 13 | $window = $( window ); |
14 | 14 |
|
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 |
16 | 16 | $( window.document ).trigger( "mobileinit" ); |
17 | 17 |
|
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 |
21 | 21 | if ( !$.mobile.gradeA() ) { |
22 | 22 | return; |
23 | 23 | } |
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 |
26 | 26 | // or generally work better browsing in regular http for full page refreshes (BB5, Opera Mini) |
27 | | - if( $.mobile.ajaxBlacklist ){ |
| 27 | + if ( $.mobile.ajaxBlacklist ) { |
28 | 28 | $.mobile.ajaxEnabled = false; |
29 | 29 | } |
30 | 30 |
|
31 | | - //add mobile, initial load "rendering" classes to docEl |
| 31 | + // add mobile, initial load "rendering" classes to docEl |
32 | 32 | $html.addClass( "ui-mobile ui-mobile-rendering" ); |
33 | 33 |
|
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 |
36 | 36 | var $loader = $( "<div class='ui-loader ui-body-a ui-corner-all'><span class='ui-icon ui-icon-loading spin'></span><h1></h1></div>" ); |
37 | 37 |
|
38 | 38 | $.extend($.mobile, { |
39 | 39 | // turn on/off page loading message. |
40 | 40 | showPageLoadingMsg: function() { |
41 | | - if( $.mobile.loadingMessage ){ |
| 41 | + if ( $.mobile.loadingMessage ) { |
42 | 42 | var activeBtn = $( "." + $.mobile.activeBtnClass ).first(); |
43 | | - |
| 43 | + |
44 | 44 | $loader |
45 | 45 | .find( "h1" ) |
46 | 46 | .text( $.mobile.loadingMessage ) |
47 | 47 | .end() |
48 | 48 | .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 || |
52 | 52 | activeBtn.length && activeBtn.offset().top || 100 |
53 | | - } ); |
| 53 | + }); |
54 | 54 | } |
55 | | - |
| 55 | + |
56 | 56 | $html.addClass( "ui-loading" ); |
57 | 57 | }, |
58 | 58 |
|
|
70 | 70 | }, |
71 | 71 |
|
72 | 72 | // 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 |
75 | 75 | 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 ) { |
79 | 79 | $pages = $( "body" ).wrapInner( "<div data-" + $.mobile.ns + "role='page'></div>" ).children( 0 ); |
80 | 80 | } |
81 | 81 |
|
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() { |
84 | 84 | var $this = $(this); |
85 | 85 |
|
86 | 86 | // unless the data url is already set set it to the id |
87 | | - if( !$this.jqmData('url') ){ |
| 87 | + if ( !$this.jqmData("url") ) { |
88 | 88 | $this.attr( "data-" + $.mobile.ns + "url", $this.attr( "id" ) ); |
89 | 89 | } |
90 | 90 | }); |
91 | 91 |
|
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) |
93 | 93 | $.mobile.firstPage = $pages.first(); |
94 | 94 |
|
95 | | - //define page container |
| 95 | + // define page container |
96 | 96 | $.mobile.pageContainer = $pages.first().parent().addClass( "ui-mobile-viewport" ); |
97 | 97 |
|
98 | | - //cue page loading message |
| 98 | + // cue page loading message |
99 | 99 | $.mobile.showPageLoadingMsg(); |
100 | 100 |
|
101 | 101 | // 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 ) ) { |
103 | 103 | $.mobile.changePage( $.mobile.firstPage, { transition: "none", reverse: true, changeHash: false, fromHashChange: true } ); |
104 | 104 | } |
105 | 105 | // otherwise, trigger a hashchange to load a deeplink |
|
108 | 108 | } |
109 | 109 | } |
110 | 110 | }); |
111 | | - |
112 | | - //initialize events now, after mobileinit has occurred |
| 111 | + |
| 112 | + // initialize events now, after mobileinit has occurred |
113 | 113 | $.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() { |
119 | 119 | window.scrollTo( 0, 1 ); |
120 | 120 |
|
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 |
124 | 124 | $.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 ) { |
128 | 128 | $( $.mobile.initializePage ); |
129 | 129 | } |
130 | | - |
131 | | - //window load event |
132 | | - //hide iOS browser chrome on load |
| 130 | + |
| 131 | + // window load event |
| 132 | + // hide iOS browser chrome on load |
133 | 133 | $window.load( $.mobile.silentScroll ); |
134 | 134 | }); |
135 | 135 | })( jQuery, this ); |
0 commit comments