Skip to content

Commit a3700de

Browse files
committed
fix sticky header display when no favorites or no specials
1 parent 9b11c21 commit a3700de

File tree

5 files changed

+32
-13
lines changed

5 files changed

+32
-13
lines changed

intranet/static/css/eighth.signup.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,12 @@ h5.hidden {
392392
display: none;
393393
}
394394

395+
h5.no-activities {
396+
/* fixes sticky headers */
397+
visibility: hidden;
398+
height: 0;
399+
}
400+
395401
h5.search-header {
396402
margin-top: 1px;
397403
}

intranet/static/js/eighth/signup.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,9 +294,9 @@ $(function() {
294294
});
295295
renderActivitiesInContainer(specials, $(".special-activities", this.el));
296296
if (specials.length === 0) {
297-
$(".special-header").addClass("hidden");
297+
$(".special-header").addClass("no-activities");
298298
} else {
299-
$(".special-header").removeClass("hidden");
299+
$(".special-header").removeClass("no-activities");
300300
}
301301

302302
if (!$("#activity-picker").hasClass("different-user")) {

intranet/static/js/eighth/signup.search.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -238,14 +238,16 @@ $(document).ready(function() {
238238
$("#activity-list > ul[data-header]").each(function() {
239239
var vis = $("li:not(.search-hide)[data-activity-id]", $(this));
240240
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");
242244
console.log(vis.size(), cat);
243245
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();
246248
} else {
247-
if(cat != "all-header") $(this).show();
248-
$(".sticky-header." + cat).show();
249+
if(hideUl) $(this).show();
250+
if(hideHeader) sticky.show();
249251
}
250252
});
251253

intranet/static/js/eighth/signupUI.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,16 @@ $(function() {
123123
// Sticky headers for activity picker
124124
function stickyHeaders(headers) {
125125
this.load = function() {
126+
var firstEmpty = false;
126127
headers.each(function(i) {
127128
var id = Math.floor((i + 1) * Math.random() * 99999);
128129
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");
131136
} else {
132137
stuckCopy.addClass("hidden stuck");
133138
}
@@ -144,8 +149,14 @@ function stickyHeaders(headers) {
144149
thrdHeader = headers.eq(i - 2);
145150
var top = thisHeader.position().top;
146151

152+
if(prevHeader.hasClass("empty")) {
153+
prevHeader = thrdHeader;
154+
}
155+
147156
if (top <= 0) {
148-
$("#" + thisHeader.attr("id") + "-stuck").removeClass("hidden");
157+
if(!thisHeader.hasClass("empty")) {
158+
$("#" + thisHeader.attr("id") + "-stuck").removeClass("hidden");
159+
}
149160
headers.each(function(j) {
150161
var loopHeader = $(this);
151162
if(j != i) $("#" + loopHeader.attr("id") + "-stuck").addClass("hidden");

intranet/templates/eighth/signup.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -414,11 +414,11 @@ <h5 class="search-header">
414414
<i class="fa fa-chevron-left"></i>
415415
</div>
416416
<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>
418418
<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>
420420
<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>
422422
<ul class="all-activities" data-header="all-header"></ul>
423423
<ul class="search-noresults">
424424
<li>

0 commit comments

Comments
 (0)