autodividers-linkbar.js 2.1 KB

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