47 lines
1.8 KiB
JavaScript
47 lines
1.8 KiB
JavaScript
$(function () {
|
|
init_agenda = function(cell_id) {
|
|
$('.weeklyagenda-cell-' + cell_id + ' .previous-week').on('click', function() {
|
|
var $cell = $(this).parents('.weeklyagenda-cell-' + cell_id);
|
|
var $prev = $('li.shown', $cell).prev();
|
|
if ($prev.length) { $('li.shown', $cell).removeClass('shown'); $prev.addClass('shown'); }
|
|
return false;
|
|
});
|
|
$('.weeklyagenda-cell-' + cell_id + ' .next-week').on('click', function() {
|
|
var $cell = $(this).parents('.weeklyagenda-cell-' + cell_id);
|
|
var $next = $('li.shown', $cell).next();
|
|
if ($next.length) { $('li.shown', $cell).removeClass('shown'); $next.addClass('shown'); }
|
|
return false;
|
|
});
|
|
$('.weeklyagenda-cell-' + cell_id + ' li.day-title').each(function(idx, elem) {
|
|
/* hide empty days */
|
|
var $next = $(elem).next();
|
|
if ($next.length == 0 || $next.is('.day-title')) {
|
|
$(elem).hide();
|
|
}
|
|
});
|
|
$('.weeklyagenda-cell-' + cell_id + ' li.week').each(function(idx, elem) {
|
|
/* hide no-activity message if not empty */
|
|
if ($('.activity', $(elem)).length > 0) {
|
|
$('.no-activity', $(elem)).hide();
|
|
}
|
|
/* hide booking button if all items are disabled */
|
|
if ($('.activity', $(elem)).not('.disabled').length == 0) {
|
|
$('.booking-btn', $(elem)).hide();
|
|
}
|
|
});
|
|
$('.weeklyagenda-cell-' + cell_id).each(function(idx, elem) {
|
|
/* init first week shown */
|
|
var $cell = $(this);
|
|
$('li', $cell).removeClass('shown');
|
|
if ($('li.day-title.current', $cell).length) {
|
|
$('li.day-title.current', $cell).parent().parent().addClass('shown');
|
|
} else {
|
|
$('li', $cell).first().addClass('shown');
|
|
}
|
|
});
|
|
}
|
|
$(document).on('combo:cell-loaded', function(ev, cell) {
|
|
init_agenda($('.weeklyagenda-cell', $(cell)).data('cell-id'));
|
|
});
|
|
});
|