Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hide rooms on overview page while preview image fails to load #207

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions assets/css/_overview.less
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,39 @@ body.overview {
.panel-body h2 {
margin: 0;
}

&.inactive-stream {
display: none;
}
}

input.show-inactive {
display: none;
}
.show-inactive-toggle {
width: ~"calc(100% - 30px)";
margin-left: 15px;

.show-inactive-text {
display: inline;
}
.hide-inactive-text {
display: none;
}
}
input[type="checkbox"]:checked.show-inactive {
~ .room {
display: block;
}

~ .show-inactive-toggle {
.show-inactive-text {
display: none;
}
.hide-inactive-text {
display: inline;
}
}
}

.recordings a {
Expand Down
23 changes: 21 additions & 2 deletions assets/js/lustiges-script.js
Original file line number Diff line number Diff line change
Expand Up @@ -299,12 +299,28 @@ $(function() {
});
});

// update teaser images
// update teaser images, hide/show room depending on teaser image availability
$(function() {
var
roomSelector = '.room.has-preview',
previewSelector = roomSelector + ' .preview',
inactiveClass = 'inactive-stream';

$(previewSelector).each(function() {
var
$teaser = $(this),
$room = $teaser.parents(roomSelector);

$teaser.on('error', function() {
$room.addClass(inactiveClass);
});
});

setInterval(function() {
$('.rooms .lecture .teaser').each(function() {
$(previewSelector).each(function() {
var
$teaser = $(this),
$room = $teaser.parents(roomSelector),
$preload = $('<img />'),
src = $teaser.data('src');

Expand All @@ -315,6 +331,9 @@ $(function() {

$preload.on('load', function() {
$teaser.prop('src', $preload.prop('src'));
$room.removeClass(inactiveClass);
}).on('error', function() {
$room.addClass(inactiveClass);
}).prop('src', src + '?'+(new Date()).getTime());
});
}, 1000*60);
Expand Down
6 changes: 6 additions & 0 deletions template/overview.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
</div>
<? endif ?>
<div class="row room-group room-group-n<?=h($i++)?> room-group-<?=h(slugify($group))?>">
<input type="checkbox" class="show-inactive" id="show-inactive-<?=h(slugify($group))?>-toggle" />

<?
/*
Expand Down Expand Up @@ -128,6 +129,11 @@
<div class="clearfix"></div>
<? endif ?>
<? endforeach ?>
<label for="show-inactive-<?=h(slugify($group))?>-toggle" class="btn btn-default show-inactive-toggle">
<span class="show-inactive-text">Show</span>
<span class="hide-inactive-text">Hide</span>
inactive streams
</label>
</div>
<? endforeach ?>

Expand Down