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
|
||
|
* @param {bool} checked True if the checkboxes should be checked
|
||
8 years ago
|
*/
|
||
|
function checkAll(id, checked) {
|
||
7 years ago
|
$("#" + id + " input[type='checkbox']").each(function () {
|
||
|
this.checked = checked;
|
||
|
});
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Sets the checkboxes according to the given type
|
||
|
*
|
||
|
* @param {string} id The elements ID
|
||
|
* @param {list} shifts_list A list of numbers
|
||
|
*/
|
||
|
function checkOwnTypes(id, shifts_list) {
|
||
7 years ago
|
$("#" + id + " input[type='checkbox']").each(function () {
|
||
|
this.checked = $.inArray(parseInt(this.value), shifts_list) != -1;
|
||
7 years ago
|
});
|
||
13 years ago
|
}
|
||
10 years ago
|
|
||
7 years ago
|
/**
|
||
|
* @param {moment} date
|
||
|
*/
|
||
|
function formatDay(date) {
|
||
7 years ago
|
return date.format("YYYY-MM-DD");
|
||
7 years ago
|
}
|
||
|
|
||
|
/**
|
||
|
* @param {moment} date
|
||
|
*/
|
||
|
function formatTime(date) {
|
||
7 years ago
|
return date.format("HH:mm");
|
||
7 years ago
|
}
|
||
|
|
||
|
/**
|
||
|
* @param {moment} from
|
||
|
* @param {moment} to
|
||
|
*/
|
||
|
function setInput(from, to) {
|
||
7 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));
|
||
7 years ago
|
}
|
||
|
|
||
|
function setDay(days) {
|
||
|
days = days || 0;
|
||
|
|
||
|
var from = moment();
|
||
|
from.hours(0).minutes(0).seconds(0);
|
||
|
|
||
7 years ago
|
from.add(days, "d");
|
||
7 years ago
|
|
||
|
var to = from.clone();
|
||
|
to.hours(23).minutes(59);
|
||
|
|
||
7 years ago
|
setInput(from, to);
|
||
7 years ago
|
}
|
||
|
|
||
|
function setHours(hours) {
|
||
|
hours = hours || 1;
|
||
|
|
||
|
var from = moment();
|
||
|
var to = from.clone();
|
||
|
|
||
7 years ago
|
to.add(hours, "h");
|
||
7 years ago
|
if (to < from) {
|
||
|
setInput(to, from);
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
setInput(from, to);
|
||
|
}
|
||
|
|
||
8 years ago
|
$(function () {
|
||
|
/**
|
||
|
* Disable every submit button after clicking (to prevent double-clicking)
|
||
|
*/
|
||
|
$("form").submit(function (ev) {
|
||
|
$("input[type='submit']").prop("readonly", true).addClass("disabled");
|
||
|
return true;
|
||
|
});
|
||
7 years ago
|
|
||
|
$(".dropdown-menu").css("max-height", function () {
|
||
|
return ($(window).height() - 50) + "px";
|
||
7 years ago
|
}).css("overflow-y", "scroll");
|
||
10 years ago
|
});
|