autodividers-linkbar.js 2.1 KB

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