File tree Expand file tree Collapse file tree 5 files changed +32
-13
lines changed Expand file tree Collapse file tree 5 files changed +32
-13
lines changed Original file line number Diff line number Diff line change @@ -392,6 +392,12 @@ h5.hidden {
392
392
display : none;
393
393
}
394
394
395
+ h5 .no-activities {
396
+ /* fixes sticky headers */
397
+ visibility : hidden;
398
+ height : 0 ;
399
+ }
400
+
395
401
h5 .search-header {
396
402
margin-top : 1px ;
397
403
}
Original file line number Diff line number Diff line change @@ -294,9 +294,9 @@ $(function() {
294
294
} ) ;
295
295
renderActivitiesInContainer ( specials , $ ( ".special-activities" , this . el ) ) ;
296
296
if ( specials . length === 0 ) {
297
- $ ( ".special-header" ) . addClass ( "hidden " ) ;
297
+ $ ( ".special-header" ) . addClass ( "no-activities " ) ;
298
298
} else {
299
- $ ( ".special-header" ) . removeClass ( "hidden " ) ;
299
+ $ ( ".special-header" ) . removeClass ( "no-activities " ) ;
300
300
}
301
301
302
302
if ( ! $ ( "#activity-picker" ) . hasClass ( "different-user" ) ) {
Original file line number Diff line number Diff line change @@ -238,14 +238,16 @@ $(document).ready(function() {
238
238
$ ( "#activity-list > ul[data-header]" ) . each ( function ( ) {
239
239
var vis = $ ( "li:not(.search-hide)[data-activity-id]" , $ ( this ) ) ;
240
240
var cat = $ ( this ) . attr ( "data-header" ) ;
241
-
241
+ var hideUl = ( cat != "all-header" ) ;
242
+ var sticky = $ ( ".sticky-header." + cat ) ;
243
+ var hideHeader = ! sticky . hasClass ( "no-activities" ) ;
242
244
console . log ( vis . size ( ) , cat ) ;
243
245
if ( vis . size ( ) == 0 ) {
244
- if ( cat != "all-header" ) $ ( this ) . hide ( ) ;
245
- $ ( ".sticky-header." + cat ) . hide ( ) ;
246
+ if ( hideUl ) $ ( this ) . hide ( ) ;
247
+ if ( hideHeader ) sticky . hide ( ) ;
246
248
} else {
247
- if ( cat != "all-header" ) $ ( this ) . show ( ) ;
248
- $ ( ".sticky-header." + cat ) . show ( ) ;
249
+ if ( hideUl ) $ ( this ) . show ( ) ;
250
+ if ( hideHeader ) sticky . show ( ) ;
249
251
}
250
252
} ) ;
251
253
Original file line number Diff line number Diff line change @@ -123,11 +123,16 @@ $(function() {
123
123
// Sticky headers for activity picker
124
124
function stickyHeaders ( headers ) {
125
125
this . load = function ( ) {
126
+ var firstEmpty = false ;
126
127
headers . each ( function ( i ) {
127
128
var id = Math . floor ( ( i + 1 ) * Math . random ( ) * 99999 ) ;
128
129
var stuckCopy = $ ( this ) . clone ( ) . prependTo ( $ ( "#activity-picker" ) ) ;
129
- if ( i == 0 ) {
130
- stuckCopy . addClass ( "stuck" ) ;
130
+ var empty = $ ( this ) . hasClass ( "empty" ) ;
131
+ if ( i == 0 && empty ) {
132
+ firstEmpty = true ;
133
+ }
134
+ if ( ( i == 0 && ! empty ) || ( i == 1 && firstEmpty ) ) {
135
+ stuckCopy . addClass ( "stuck" ) ;
131
136
} else {
132
137
stuckCopy . addClass ( "hidden stuck" ) ;
133
138
}
@@ -144,8 +149,14 @@ function stickyHeaders(headers) {
144
149
thrdHeader = headers . eq ( i - 2 ) ;
145
150
var top = thisHeader . position ( ) . top ;
146
151
152
+ if ( prevHeader . hasClass ( "empty" ) ) {
153
+ prevHeader = thrdHeader ;
154
+ }
155
+
147
156
if ( top <= 0 ) {
148
- $ ( "#" + thisHeader . attr ( "id" ) + "-stuck" ) . removeClass ( "hidden" ) ;
157
+ if ( ! thisHeader . hasClass ( "empty" ) ) {
158
+ $ ( "#" + thisHeader . attr ( "id" ) + "-stuck" ) . removeClass ( "hidden" ) ;
159
+ }
149
160
headers . each ( function ( j ) {
150
161
var loopHeader = $ ( this ) ;
151
162
if ( j != i ) $ ( "#" + loopHeader . attr ( "id" ) + "-stuck" ) . addClass ( "hidden" ) ;
Original file line number Diff line number Diff line change @@ -414,11 +414,11 @@ <h5 class="search-header">
414
414
< i class ="fa fa-chevron-left "> </ i >
415
415
</ div >
416
416
< div id ="activity-list " data-toggle-favorite-endpoint ="{% url 'eighth_toggle_favorite' %} ">
417
- < h5 class ="sticky-header favorites-header "> Favorites</ h5 >
417
+ < h5 class ="sticky-header favorites-header " data-header =" favorites-header " > Favorites</ h5 >
418
418
< ul class ="favorite-activities " data-header ="favorites-header "> </ ul >
419
- < h5 class ="sticky-header special-header "> Special</ h5 >
419
+ < h5 class ="sticky-header special-header " data-header =" special-header " > Special</ h5 >
420
420
< ul class ="special-activities " data-header ="special-header "> </ ul >
421
- < h5 class ="sticky-header all-header "> All</ h5 >
421
+ < h5 class ="sticky-header all-header " data-header =" all-header " > All</ h5 >
422
422
< ul class ="all-activities " data-header ="all-header "> </ ul >
423
423
< ul class ="search-noresults ">
424
424
< li >
You can’t perform that action at this time.
0 commit comments