55 lines
2.5 KiB
JavaScript
55 lines
2.5 KiB
JavaScript
$(function() {
|
|
$('[data-total]').each(function() {
|
|
var total = $(this).data('total');
|
|
var booked = $(this).data('booked');
|
|
$(this).find('.occupation-bar').css('max-width', 100 * booked / total + '%');
|
|
});
|
|
$('.date-title').on('click', function() {
|
|
$(this).parent().find('.date-picker').toggle();
|
|
});
|
|
$('.date-picker-opener').on('click', function() { $('.date-title').trigger('click'); });
|
|
$('.date-picker button').on('click', function() {
|
|
if ($('[name=day]').val()) {
|
|
window.location = '../../../' + $('[name=year]').val() + '/' + $('[name=month]').val() + '/' + $('[name=day]').val() + '/';
|
|
} else if ($('[name=month]').val()) {
|
|
window.location = '../../' + $('[name=year]').val() + '/' + $('[name=month]').val() + '/';
|
|
} else {
|
|
window.location = '../../../' + $('[name=year]').val() + '/week/' + $('[name=week]').val() + '/';
|
|
}
|
|
return false;
|
|
});
|
|
|
|
if (window.navigator.userAgent.indexOf('MSIE') > 0 || window.navigator.userAgent.match(/Trident.*rv\:11\./)) {
|
|
// IE doesn't support percentage units inside table cells so we have to go
|
|
// over all <div>s and convert the values to pixels.
|
|
var td_height = $('table.agenda-table tbody td').height();
|
|
$('table.agenda-table tbody td div').each(function(idx, elem) {
|
|
var parsed_height = $(elem).attr('style').match(/height: ([0-9]+)%/)[1];
|
|
$(elem).css('height', (parseInt(parsed_height) * td_height / 100) + 'px');
|
|
var parsed_top = $(elem).attr('style').match(/top: ([0-9]+)%/)[1];
|
|
$(elem).css('top', (parseInt(parsed_top) * td_height / 100) + 'px');
|
|
var parsed_min_height = $(elem).attr('style').match(/min-height: ([0-9]+)%/);
|
|
if (parsed_min_height) {
|
|
$(elem).css('min-height', (parseInt(parsed_min_height[1]) * td_height / 100) + 'px');
|
|
}
|
|
});
|
|
}
|
|
|
|
if ($('#add-custom-field-form').length) {
|
|
var property_forms = $('.custom-field-form');
|
|
var total_form = $('#id_form-TOTAL_FORMS');
|
|
var form_num = property_forms.length - 1;
|
|
$('#add-custom-field-form').on('click', function() {
|
|
var new_form = $(property_forms[0]).clone();
|
|
var form_regex = RegExp(`form-(\\d){1}-`,'g');
|
|
form_num++;
|
|
new_form.html(new_form.html().replace(form_regex, `form-${form_num}-`));
|
|
new_form.appendTo('#custom-field-forms tbody');
|
|
$('#id_form-' + form_num + '-varname').val('');
|
|
$('#id_form-' + form_num + '-label').val('');
|
|
$('#id_form-' + form_num + '-field_type').val('');
|
|
total_form.val(form_num + 1);
|
|
})
|
|
}
|
|
});
|