|
1 |
| -$.mobile.document.on( "pageshow", "#demo-page", function() { |
2 |
| - var head = $( ".ui-page-active [data-role='header']" ), |
3 |
| - foot = $( ".ui-page-active [data-role='footer']" ), |
4 |
| - headerheight = head.outerHeight(); |
5 |
| - |
6 |
| - $.mobile.window.on( "throttledresize", function() { |
7 |
| - $( "#sorter" ).height( $.mobile.window.height() - headerheight - 20 ).css( "top", headerheight + 18 ); |
8 |
| - }); |
| 1 | +$.mobile.document.on( "pagecreate", "#demo-page", function(){ |
| 2 | + var head = $( ".ui-page-active [data-role='header']" ); |
9 | 3 |
|
10 |
| - $( "#sorter" ).height( $.mobile.window.height() - headerheight - 20 ).css( "top", headerheight + 18 ); |
| 4 | + $.mobile.document.on( "click", "#sorter li", function() { |
| 5 | + var top, |
| 6 | + letter = $( this ).text(), |
| 7 | + divider = $( "#sortedList" ).find( "li.ui-li-divider:contains(" + letter + ")" ); |
11 | 8 |
|
12 |
| - $.mobile.window.scroll( function( e ) { |
13 |
| - var headTop = $(window).scrollTop(); |
| 9 | + if ( divider.length > 0 ) { |
| 10 | + top = divider.offset().top; |
| 11 | + $.mobile.silentScroll( top ); |
| 12 | + } else { |
| 13 | + return false; |
| 14 | + } |
| 15 | + }); |
| 16 | + $( "#sorter li" ).hover(function() { |
| 17 | + $( this ).addClass( "ui-btn" ).removeClass( "ui-li-static" ); |
| 18 | + }, function() { |
| 19 | + $( this ).removeClass( "ui-btn" ).addClass( "ui-li-static" ); |
| 20 | + }); |
| 21 | +}); |
| 22 | +$( function(){ |
| 23 | + $.mobile.window.on( "scroll", function( e ) { |
| 24 | + var headTop = $(window).scrollTop(), |
| 25 | + foot = $( ".ui-page-active [data-role='footer']" ), |
| 26 | + head = $( ".ui-page-active [data-role='header']" ), |
| 27 | + headerheight = head.outerHeight(); |
14 | 28 |
|
15 | 29 | if( headTop < headerheight && headTop > 0 ) {
|
16 | 30 | $( "#sorter" ).css({
|
17 | 31 | "top": headerheight + 15 - headTop,
|
18 |
| - "height": $.mobile.window.height() - headerheight - 20 |
| 32 | + "height": window.innerHeight - head[ 0 ].offsetHeight + window.pageYOffset - 10 |
19 | 33 | });
|
20 |
| - } else if ( headTop >= headerheight && headTop > 0 && parseInt( headTop + $.mobile.window.height( )) < parseInt( foot.offset().top ) ) { |
| 34 | + $("#sorter li").height( "3.7%" ); |
| 35 | + } else if ( headTop >= headerheight && headTop > 0 && parseInt( headTop + |
| 36 | + $.mobile.window.height( )) < parseInt( foot.offset().top ) ) { |
| 37 | + |
21 | 38 | $( "#sorter" ).css({
|
22 | 39 | "top": "15px",
|
23 |
| - "height": $.mobile.window.height() |
| 40 | + "height": window.innerHeight - 8 |
24 | 41 | });
|
25 | 42 | $("#sorter li").height( "3.7%" );
|
26 |
| - } else if ( parseInt( headTop + $.mobile.window.height() ) >= parseInt( foot.offset().top ) && parseInt( headTop + $.mobile.window.height() ) <= parseInt( foot.offset().top ) + foot.height() ) { |
| 43 | + } else if ( parseInt( headTop + window.innerHeight ) >= parseInt( foot.offset().top ) && |
| 44 | + parseInt( headTop + window.innerHeight ) <= parseInt( foot.offset().top ) + |
| 45 | + foot.height() ) { |
| 46 | + |
27 | 47 | $( "#sorter" ).css({
|
28 | 48 | "top": "15px",
|
29 |
| - "height": $.mobile.window.height() - ( parseInt( headTop + $.mobile.window.height() ) - parseInt( foot.offset().top ) + 8 ) |
| 49 | + "height": window.innerHeight - ( parseInt( headTop + window.innerHeight ) - |
| 50 | + parseInt( foot.offset().top ) + 8 ) |
30 | 51 | });
|
31 |
| - } else if( parseInt( headTop + $.mobile.window.height() ) >= parseInt( foot.offset().top ) ) { |
| 52 | + } else if( parseInt( headTop + window.innerHeight ) >= parseInt( foot.offset().top ) ) { |
32 | 53 | $( "#sorter" ).css({
|
33 | 54 | "top": "15px"
|
34 | 55 | });
|
35 | 56 | } else {
|
36 | 57 | $( "#sorter" ).css( "top", headerheight + 15 );
|
37 | 58 | }
|
38 | 59 | });
|
| 60 | +}); |
| 61 | +$.mobile.window.on( "throttledresize", function() { |
| 62 | + $( "#sorter" ).height( window.innerHeight - headerheight - 20 ).css( "top", headerheight + 18 ); |
| 63 | +}); |
| 64 | +$.mobile.document.on( "pageshow", "#demo-page", function() { |
| 65 | + var headerheight = $( ".ui-page-active [data-role='header']" ).outerHeight(); |
39 | 66 |
|
40 |
| - $( "#sorter li" ).click( function() { |
41 |
| - var top, |
42 |
| - letter = $( this ).text(), |
43 |
| - divider = $( "#sortedList" ).find( "li.ui-li-divider:contains(" + letter + ")" ); |
44 |
| - |
45 |
| - if ( divider.length > 0 ) { |
46 |
| - top = divider.offset().top; |
47 |
| - $.mobile.silentScroll( top ); |
48 |
| - } else { |
49 |
| - return false; |
50 |
| - } |
51 |
| - }); |
52 |
| - |
53 |
| - $( "#sorter li" ).hover(function() { |
54 |
| - $( this ).addClass( "ui-btn-up-b" ).removeClass( "ui-btn-up-c" ); |
55 |
| - }, function() { |
56 |
| - $( this ).removeClass( "ui-btn-up-b" ).addClass( "ui-btn-up-c" ); |
57 |
| - }); |
| 67 | + $( "#sorter" ).height( window.innerHeight - headerheight - 20 ).css( "top", headerheight + 18 ); |
58 | 68 | });
|
0 commit comments