Explose form Functions as globals

This commit is contained in:
marudor 2018-08-03 13:58:25 +02:00
parent 608fb3dad6
commit db16772d01
No known key found for this signature in database
GPG Key ID: D64C68DA9EB642AD
1 changed files with 7 additions and 7 deletions

View File

@ -4,7 +4,7 @@
* @param {string} id Id of the element containing all the checkboxes * @param {string} id Id of the element containing all the checkboxes
* @param {bool} checked True if the checkboxes should be checked * @param {bool} checked True if the checkboxes should be checked
*/ */
function checkAll(id, checked) { global.checkAll = (id, checked) => {
$("#" + id + " input[type='checkbox']").each(function () { $("#" + id + " input[type='checkbox']").each(function () {
this.checked = checked; this.checked = checked;
}); });
@ -16,7 +16,7 @@ function checkAll(id, checked) {
* @param {string} id The elements ID * @param {string} id The elements ID
* @param {list} shifts_list A list of numbers * @param {list} shifts_list A list of numbers
*/ */
function checkOwnTypes(id, shifts_list) { global.checkOwnTypes = (id, shifts_list) => {
$("#" + id + " input[type='checkbox']").each(function () { $("#" + id + " input[type='checkbox']").each(function () {
this.checked = $.inArray(parseInt(this.value), shifts_list) != -1; this.checked = $.inArray(parseInt(this.value), shifts_list) != -1;
}); });
@ -25,14 +25,14 @@ function checkOwnTypes(id, shifts_list) {
/** /**
* @param {moment} date * @param {moment} date
*/ */
function formatDay(date) { global.formatDay = (date) => {
return date.format("YYYY-MM-DD"); return date.format("YYYY-MM-DD");
} }
/** /**
* @param {moment} date * @param {moment} date
*/ */
function formatTime(date) { global.formatTime = (date) => {
return date.format("HH:mm"); return date.format("HH:mm");
} }
@ -40,7 +40,7 @@ function formatTime(date) {
* @param {moment} from * @param {moment} from
* @param {moment} to * @param {moment} to
*/ */
function setInput(from, to) { global.setInput = (from, to) => {
var fromDay = $("#start_day"), fromTime = $("#start_time"), toDay = $("#end_day"), toTime = $("#end_time"); var fromDay = $("#start_day"), fromTime = $("#start_time"), toDay = $("#end_day"), toTime = $("#end_time");
fromDay.val(formatDay(from)); fromDay.val(formatDay(from));
@ -50,7 +50,7 @@ function setInput(from, to) {
toTime.val(formatTime(to)); toTime.val(formatTime(to));
} }
function setDay(days) { global.setDay = (days) => {
days = days || 0; days = days || 0;
var from = moment(); var from = moment();
@ -64,7 +64,7 @@ function setDay(days) {
setInput(from, to); setInput(from, to);
} }
function setHours(hours) { global.setHours = (hours) => {
hours = hours || 1; hours = hours || 1;
var from = moment(); var from = moment();