0
0
mirror of https://github.com/Doodle3D/doodle3d-connect.git synced 2024-11-05 15:13:23 +01:00
doodle3d-connect/js/libs/.jquery.mobile/demos/listview-autodividers-linkbar/autodividers-linkbar.js
2014-05-08 14:59:07 +02:00

59 lines
2.0 KiB
JavaScript

$.mobile.document.on( "pageshow", "#demo-page", function() {
var head = $( ".ui-page-active [data-role='header']" ),
foot = $( ".ui-page-active [data-role='footer']" ),
headerheight = head.outerHeight();
$.mobile.window.on( "throttledresize", function() {
$( "#sorter" ).height( $.mobile.window.height() - headerheight - 20 ).css( "top", headerheight + 18 );
});
$( "#sorter" ).height( $.mobile.window.height() - headerheight - 20 ).css( "top", headerheight + 18 );
$.mobile.window.scroll( function( e ) {
var headTop = $(window).scrollTop();
if( headTop < headerheight && headTop > 0 ) {
$( "#sorter" ).css({
"top": headerheight + 15 - headTop,
"height": $.mobile.window.height() - headerheight - 20
});
} else if ( headTop >= headerheight && headTop > 0 && parseInt( headTop + $.mobile.window.height( )) < parseInt( foot.offset().top ) ) {
$( "#sorter" ).css({
"top": "15px",
"height": $.mobile.window.height()
});
$("#sorter li").height( "3.7%" );
} else if ( parseInt( headTop + $.mobile.window.height() ) >= parseInt( foot.offset().top ) && parseInt( headTop + $.mobile.window.height() ) <= parseInt( foot.offset().top ) + foot.height() ) {
$( "#sorter" ).css({
"top": "15px",
"height": $.mobile.window.height() - ( parseInt( headTop + $.mobile.window.height() ) - parseInt( foot.offset().top ) + 8 )
});
} else if( parseInt( headTop + $.mobile.window.height() ) >= parseInt( foot.offset().top ) ) {
$( "#sorter" ).css({
"top": "15px"
});
} else {
$( "#sorter" ).css( "top", headerheight + 15 );
}
});
$( "#sorter li" ).click( function() {
var top,
letter = $( this ).text(),
divider = $( "#sortedList" ).find( "li.ui-li-divider:contains(" + letter + ")" );
if ( divider.length > 0 ) {
top = divider.offset().top;
$.mobile.silentScroll( top );
} else {
return false;
}
});
$( "#sorter li" ).hover(function() {
$( this ).addClass( "ui-btn-up-b" ).removeClass( "ui-btn-up-c" );
}, function() {
$( this ).removeClass( "ui-btn-up-b" ).addClass( "ui-btn-up-c" );
});
});