5ba2c0d9b5ed6cfa7966769b7049989da8e35e17
[framework/web/web-ui-fw.git] / libs / js / jquery-mobile-1.0.1pre / js / jquery.mobile.fixHeaderFooter.native.js
1 /*
2 * "fixHeaderFooter" native plugin - Behavior for "fixed" headers,footers, and scrolling inner content
3 */
4
5 (function( $, undefined ) {
6
7 // Enable touch overflow scrolling when it's natively supported
8 $.mobile.touchOverflowEnabled = false;
9
10 // Enabled zoom when touch overflow is enabled. Can cause usability issues, unfortunately
11 $.mobile.touchOverflowZoomEnabled = false;
12
13 $( document ).bind( "pagecreate", function( event ) {
14         if( $.support.touchOverflow && $.mobile.touchOverflowEnabled ){
15                 
16                 var $target = $( event.target ),
17                         scrollStartY = 0;
18                         
19                 if( $target.is( ":jqmData(role='page')" ) ){
20                         
21                         $target.each(function() {
22                                 var $page = $( this ),
23                                         $fixies = $page.find( ":jqmData(role='header'), :jqmData(role='footer')" ).filter( ":jqmData(position='fixed')" ),
24                                         fullScreen = $page.jqmData( "fullscreen" ),
25                                         $scrollElem = $fixies.length ? $page.find( ".ui-content" ) : $page;
26                                 
27                                 $page.addClass( "ui-mobile-touch-overflow" );
28                                 
29                                 $scrollElem.bind( "scrollstop", function(){
30                                         if( $scrollElem.scrollTop() > 0 ){
31                                                 window.scrollTo( 0, $.mobile.defaultHomeScroll );
32                                         }
33                                 });     
34                                 
35                                 if( $fixies.length ){
36                                         
37                                         $page.addClass( "ui-native-fixed" );
38                                         
39                                         if( fullScreen ){
40
41                                                 $page.addClass( "ui-native-fullscreen" );
42
43                                                 $fixies.addClass( "fade in" );
44
45                                                 $( document ).bind( "vclick", function(){
46                                                         $fixies
47                                                                 .removeClass( "ui-native-bars-hidden" )
48                                                                 .toggleClass( "in out" )
49                                                                 .animationComplete(function(){
50                                                                         $(this).not( ".in" ).addClass( "ui-native-bars-hidden" );
51                                                                 });
52                                                 });
53                                         }
54                                 }
55                         });
56                 }
57         }
58 });
59
60 })( jQuery );