|
2 | 2 | //>>description: Behavior for "fixed" headers and footers
|
3 | 3 | //>>label: Fixedtoolbar
|
4 | 4 |
|
5 |
| -define( [ "jquery", "jquery.mobile.widget", "jquery.mobile.core", "jquery.mobile.navigation", "jquery.mobile.page", "jquery.mobile.page.sections" ], function( $ ) { |
| 5 | +define( [ "jquery", "jquery.mobile.widget", "jquery.mobile.core", "jquery.mobile.navigation", "jquery.mobile.page", "jquery.mobile.page.sections", "jquery.mobile.zoom" ], function( $ ) { |
6 | 6 | //>>excludeEnd("jqmBuildExclude");
|
7 | 7 | (function( $, undefined ) {
|
8 | 8 |
|
@@ -111,18 +111,20 @@ define( [ "jquery", "jquery.mobile.widget", "jquery.mobile.core", "jquery.mobile
|
111 | 111 | $el = self.element;
|
112 | 112 |
|
113 | 113 | //page event bindings
|
| 114 | + // Fixed toolbars require page zoom to be disabled, otherwise usability issues crop up |
| 115 | + // This method is meant to disable zoom while a fixed-positioned toolbar page is visible |
114 | 116 | $el.closest( ".ui-page" )
|
115 | 117 | .bind( "pagebeforeshow", function(){
|
116 |
| - if( o.togglePageZoom ){ |
117 |
| - self.disablePageZoom(); |
| 118 | + if( o.togglePageZoom && $.mobile.zoom ){ |
| 119 | + $.mobile.zoom.disable(); |
118 | 120 | }
|
119 | 121 | if( o.visibleOnPageShow ){
|
120 | 122 | self.show();
|
121 | 123 | }
|
122 | 124 | } )
|
123 | 125 | .bind( "pagehide", function(){
|
124 |
| - if( o.togglePageZoom ){ |
125 |
| - self.restorePageZoom(); |
| 126 | + if( o.togglePageZoom && $.mobile.zoom ){ |
| 127 | + $.mobile.zoom.enable(); |
126 | 128 | }
|
127 | 129 | });
|
128 | 130 | },
|
@@ -201,61 +203,6 @@ define( [ "jquery", "jquery.mobile.widget", "jquery.mobile.core", "jquery.mobile
|
201 | 203 | destroy: function(){
|
202 | 204 | this.element.removeClass( "ui-header-fixed ui-footer-fixed ui-header-fullscreen ui-footer-fullscreen in out fade slidedown slideup ui-fixed-hidden" )
|
203 | 205 | this.element.closest( ".ui-page" ).removeClass( "ui-page-header-fixed ui-page-footer-fixed ui-page-header-fullscreen ui-page-footer-fullscreen" );
|
204 |
| - }, |
205 |
| - |
206 |
| - // for caching reference to meta viewport elem |
207 |
| - _metaViewport: null, |
208 |
| - |
209 |
| - // on pageshow, does a meta viewport element exist in the head? |
210 |
| - _metaViewportPreexists: false, |
211 |
| - |
212 |
| - // used for storing value of meta viewport content at page show, for restoration on hide |
213 |
| - _metaViewportContent: "", |
214 |
| - |
215 |
| - // Fixed toolbars require page zoom to be disabled, otherwise usability issues crop up |
216 |
| - // This method is meant to disable zoom while a fixed-positioned toolbar page is visible |
217 |
| - disablePageZoom: function(){ |
218 |
| - if( !this.options.togglePageZoom ){ |
219 |
| - return; |
220 |
| - } |
221 |
| - var cont = "user-scalable=no"; |
222 |
| - this._metaViewport = $( "meta[name='viewport']" ); |
223 |
| - this._metaViewportPreexists = this._metaViewport.length; |
224 |
| - |
225 |
| - var currentContent = this._metaViewport.attr( "content" ); |
226 |
| - |
227 |
| - // If scaling's already disabled, or another plugin is handling it on this page already |
228 |
| - if( currentContent.indexOf( cont ) > -1 ){ |
229 |
| - return; |
230 |
| - } |
231 |
| - else { |
232 |
| - this._metaViewportContent = currentContent; |
233 |
| - } |
234 |
| - |
235 |
| - if( !this._metaViewportPreexists ){ |
236 |
| - this._metaViewport = $( "<meta>", { "name": "viewport", "content": cont } ).prependTo( "head" ); |
237 |
| - } |
238 |
| - else{ |
239 |
| - this._metaViewport.attr( "content", this._metaViewportContent + ", " + cont ); |
240 |
| - } |
241 |
| - }, |
242 |
| - |
243 |
| - // restore the meta viewport tag to its original state, or remove it |
244 |
| - restorePageZoom: function(){ |
245 |
| - if( !this.options.togglePageZoom ){ |
246 |
| - return; |
247 |
| - } |
248 |
| - var cont = "user-scalable=no"; |
249 |
| - if( this._metaViewport.attr( "content" ).indexOf( cont ) < 0 ){ |
250 |
| - return; |
251 |
| - } |
252 |
| - |
253 |
| - if( this._metaViewportPreexists ){ |
254 |
| - this._metaViewport.attr( "content", this._metaViewportContent ); |
255 |
| - } |
256 |
| - else { |
257 |
| - this._metaViewport.remove(); |
258 |
| - } |
259 | 206 | }
|
260 | 207 |
|
261 | 208 | });
|
|
0 commit comments