You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
95 lines
2.0 KiB
JavaScript
95 lines
2.0 KiB
JavaScript
8 years ago
|
/**
|
||
7 years ago
|
* Sets all checkboxes to the wanted state
|
||
8 years ago
|
*
|
||
7 years ago
|
* @param {string} id Id of the element containing all the checkboxes
|
||
6 years ago
|
* @param {boolean} checked True if the checkboxes should be checked
|
||
8 years ago
|
*/
|
||
6 years ago
|
global.checkAll = (id, checked) => {
|
||
6 years ago
|
$('#' + id + ' input[type="checkbox"]').each(function () {
|
||
7 years ago
|
this.checked = checked;
|
||
|
});
|
||
6 years ago
|
};
|
||
7 years ago
|
|
||
|
/**
|
||
|
* Sets the checkboxes according to the given type
|
||
|
*
|
||
|
* @param {string} id The elements ID
|
||
|
* @param {list} shifts_list A list of numbers
|
||
|
*/
|
||
6 years ago
|
global.checkOwnTypes = (id, shiftsList) => {
|
||
6 years ago
|
$('#' + id + ' input[type="checkbox"]').each(function () {
|
||
6 years ago
|
this.checked = $.inArray(parseInt(this.value), shiftsList) != -1;
|
||
7 years ago
|
});
|
||
6 years ago
|
};
|
||
10 years ago
|
|
||
7 years ago
|
/**
|
||
|
* @param {moment} date
|
||
|
*/
|
||
6 years ago
|
global.formatDay = (date) => {
|
||
6 years ago
|
return date.format('YYYY-MM-DD');
|
||
6 years ago
|
};
|
||
7 years ago
|
|
||
|
/**
|
||
|
* @param {moment} date
|
||
|
*/
|
||
6 years ago
|
global.formatTime = (date) => {
|
||
6 years ago
|
return date.format('HH:mm');
|
||
6 years ago
|
};
|
||
7 years ago
|
|
||
|
/**
|
||
|
* @param {moment} from
|
||
|
* @param {moment} to
|
||
|
*/
|
||
6 years ago
|
global.setInput = (from, to) => {
|
||
6 years ago
|
var fromDay = $('#start_day'), fromTime = $('#start_time'), toDay = $('#end_day'), toTime = $('#end_time');
|
||
7 years ago
|
|
||
7 years ago
|
fromDay.val(formatDay(from));
|
||
|
fromTime.val(formatTime(from));
|
||
7 years ago
|
|
||
7 years ago
|
toDay.val(formatDay(to));
|
||
|
toTime.val(formatTime(to));
|
||
6 years ago
|
};
|
||
7 years ago
|
|
||
6 years ago
|
global.setDay = (days) => {
|
||
7 years ago
|
days = days || 0;
|
||
|
|
||
|
var from = moment();
|
||
|
from.hours(0).minutes(0).seconds(0);
|
||
|
|
||
6 years ago
|
from.add(days, 'd');
|
||
7 years ago
|
|
||
|
var to = from.clone();
|
||
|
to.hours(23).minutes(59);
|
||
|
|
||
7 years ago
|
setInput(from, to);
|
||
6 years ago
|
};
|
||
7 years ago
|
|
||
6 years ago
|
global.setHours = (hours) => {
|
||
7 years ago
|
hours = hours || 1;
|
||
|
|
||
|
var from = moment();
|
||
|
var to = from.clone();
|
||
|
|
||
6 years ago
|
to.add(hours, 'h');
|
||
7 years ago
|
if (to < from) {
|
||
|
setInput(to, from);
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
setInput(from, to);
|
||
6 years ago
|
};
|
||
7 years ago
|
|
||
8 years ago
|
$(function () {
|
||
|
/**
|
||
|
* Disable every submit button after clicking (to prevent double-clicking)
|
||
|
*/
|
||
6 years ago
|
$('form').submit(function (ev) {
|
||
|
$('input[type="submit"]').prop('readonly', true).addClass('disabled');
|
||
8 years ago
|
return true;
|
||
|
});
|
||
7 years ago
|
|
||
6 years ago
|
$('.dropdown-menu').css('max-height', function () {
|
||
|
return ($(window).height() - 50) + 'px';
|
||
|
}).css('overflow-y', 'scroll');
|
||
10 years ago
|
});
|