This repository has been archived by the owner on Oct 8, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
/
autodividers-linkbar.js
68 lines (62 loc) · 2.31 KB
/
autodividers-linkbar.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
$.mobile.document.on( "pagecreate", "#demo-page", function(){
var head = $( ".ui-page-active [data-role='header']" );
$.mobile.document.on( "click", "#sorter li", 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" ).removeClass( "ui-li-static" );
}, function() {
$( this ).removeClass( "ui-btn" ).addClass( "ui-li-static" );
});
});
$( function(){
$.mobile.window.on( "scroll", function( e ) {
var headTop = $(window).scrollTop(),
foot = $( ".ui-page-active [data-role='footer']" ),
head = $( ".ui-page-active [data-role='header']" ),
headerheight = head.outerHeight();
if( headTop < headerheight && headTop > 0 ) {
$( "#sorter" ).css({
"top": headerheight + 15 - headTop,
"height": window.innerHeight - head[ 0 ].offsetHeight + window.pageYOffset - 10
});
$("#sorter li").height( "3.7%" );
} else if ( headTop >= headerheight && headTop > 0 && parseInt( headTop +
$.mobile.window.height( )) < parseInt( foot.offset().top ) ) {
$( "#sorter" ).css({
"top": "15px",
"height": window.innerHeight - 8
});
$("#sorter li").height( "3.7%" );
} else if ( parseInt( headTop + window.innerHeight ) >= parseInt( foot.offset().top ) &&
parseInt( headTop + window.innerHeight ) <= parseInt( foot.offset().top ) +
foot.height() ) {
$( "#sorter" ).css({
"top": "15px",
"height": window.innerHeight - ( parseInt( headTop + window.innerHeight ) -
parseInt( foot.offset().top ) + 8 )
});
} else if( parseInt( headTop + window.innerHeight ) >= parseInt( foot.offset().top ) ) {
$( "#sorter" ).css({
"top": "15px"
});
} else {
$( "#sorter" ).css( "top", headerheight + 15 );
}
});
});
$.mobile.window.on( "throttledresize", function() {
$( "#sorter" ).height( window.innerHeight - headerheight - 20 ).css( "top", headerheight + 18 );
});
$.mobile.document.on( "pageshow", "#demo-page", function() {
var headerheight = $( ".ui-page-active [data-role='header']" ).outerHeight();
$( "#sorter" ).height( window.innerHeight - headerheight - 20 ).css( "top", headerheight + 18 );
});