Skip to content

Commit 58be1f7

Browse files
arschmitzGabriel Schulhof
authored and
Gabriel Schulhof
committed
Listview: linkbar demo scroll handler not working and updating to 1.4
Fixes jquery-archivegh-7129 Closes jquery-archivegh-7131
1 parent 6d14e13 commit 58be1f7

File tree

2 files changed

+51
-36
lines changed

2 files changed

+51
-36
lines changed

demos/listview-autodividers-linkbar/autodividers-linkbar.css

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
#sorter li {
22
height: 3.8%;
33
padding: 0;
4-
font-size: 14px;
4+
font-size: 8px;
55
padding-left: 5px;
66
line-height: 1.8em;
7+
text-align: left;
8+
}
9+
#sorter li span {
10+
margin-top: 8%;
11+
display: block;
712
}
813
#sorter{
914
position: fixed;
Lines changed: 45 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,68 @@
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']" );
93

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 + ")" );
118

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();
1428

1529
if( headTop < headerheight && headTop > 0 ) {
1630
$( "#sorter" ).css({
1731
"top": headerheight + 15 - headTop,
18-
"height": $.mobile.window.height() - headerheight - 20
32+
"height": window.innerHeight - head[ 0 ].offsetHeight + window.pageYOffset - 10
1933
});
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+
2138
$( "#sorter" ).css({
2239
"top": "15px",
23-
"height": $.mobile.window.height()
40+
"height": window.innerHeight - 8
2441
});
2542
$("#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+
2747
$( "#sorter" ).css({
2848
"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 )
3051
});
31-
} else if( parseInt( headTop + $.mobile.window.height() ) >= parseInt( foot.offset().top ) ) {
52+
} else if( parseInt( headTop + window.innerHeight ) >= parseInt( foot.offset().top ) ) {
3253
$( "#sorter" ).css({
3354
"top": "15px"
3455
});
3556
} else {
3657
$( "#sorter" ).css( "top", headerheight + 15 );
3758
}
3859
});
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();
3966

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 );
5868
});

0 commit comments

Comments
 (0)