From ba4ab7dbc102c43a861654910ba33989021e9c8b Mon Sep 17 00:00:00 2001 From: marudor Date: Thu, 3 May 2018 17:33:49 +0200 Subject: add documentation, include old custom font again --- frontend/js/forms.js | 94 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 frontend/js/forms.js (limited to 'frontend/js/forms.js') diff --git a/frontend/js/forms.js b/frontend/js/forms.js new file mode 100644 index 00000000..5aa4f25a --- /dev/null +++ b/frontend/js/forms.js @@ -0,0 +1,94 @@ +/** + * Sets all checkboxes to the wanted state + * + * @param {string} id Id of the element containing all the checkboxes + * @param {bool} checked True if the checkboxes should be checked + */ +function checkAll(id, checked) { + $("#" + 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) { + $("#" + id + " input[type='checkbox']").each(function () { + this.checked = $.inArray(parseInt(this.value), shifts_list) != -1; + }); +} + +/** + * @param {moment} date + */ +function formatDay(date) { + return date.format("YYYY-MM-DD"); +} + +/** + * @param {moment} date + */ +function formatTime(date) { + return date.format("HH:mm"); +} + +/** + * @param {moment} from + * @param {moment} to + */ +function setInput(from, to) { + var fromDay = $("#start_day"), fromTime = $("#start_time"), toDay = $("#end_day"), toTime = $("#end_time"); + + fromDay.val(formatDay(from)); + fromTime.val(formatTime(from)); + + toDay.val(formatDay(to)); + toTime.val(formatTime(to)); +} + +function setDay(days) { + days = days || 0; + + var from = moment(); + from.hours(0).minutes(0).seconds(0); + + from.add(days, "d"); + + var to = from.clone(); + to.hours(23).minutes(59); + + setInput(from, to); +} + +function setHours(hours) { + hours = hours || 1; + + var from = moment(); + var to = from.clone(); + + to.add(hours, "h"); + if (to < from) { + setInput(to, from); + return; + } + + setInput(from, to); +} + +$(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; + }); + + $(".dropdown-menu").css("max-height", function () { + return ($(window).height() - 50) + "px"; + }).css("overflow-y", "scroll"); +}); -- cgit v1.2.3-54-g00ecf From db16772d01a68fe1eaafbf0b50bda2ad93c0d897 Mon Sep 17 00:00:00 2001 From: marudor Date: Fri, 3 Aug 2018 13:58:25 +0200 Subject: Explose form Functions as globals --- frontend/js/forms.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'frontend/js/forms.js') diff --git a/frontend/js/forms.js b/frontend/js/forms.js index 5aa4f25a..67b14b32 100644 --- a/frontend/js/forms.js +++ b/frontend/js/forms.js @@ -4,7 +4,7 @@ * @param {string} id Id of the element containing all the checkboxes * @param {bool} checked True if the checkboxes should be checked */ -function checkAll(id, checked) { +global.checkAll = (id, checked) => { $("#" + id + " input[type='checkbox']").each(function () { this.checked = checked; }); @@ -16,7 +16,7 @@ function checkAll(id, checked) { * @param {string} id The elements ID * @param {list} shifts_list A list of numbers */ -function checkOwnTypes(id, shifts_list) { +global.checkOwnTypes = (id, shifts_list) => { $("#" + id + " input[type='checkbox']").each(function () { this.checked = $.inArray(parseInt(this.value), shifts_list) != -1; }); @@ -25,14 +25,14 @@ function checkOwnTypes(id, shifts_list) { /** * @param {moment} date */ -function formatDay(date) { +global.formatDay = (date) => { return date.format("YYYY-MM-DD"); } /** * @param {moment} date */ -function formatTime(date) { +global.formatTime = (date) => { return date.format("HH:mm"); } @@ -40,7 +40,7 @@ function formatTime(date) { * @param {moment} from * @param {moment} to */ -function setInput(from, to) { +global.setInput = (from, to) => { var fromDay = $("#start_day"), fromTime = $("#start_time"), toDay = $("#end_day"), toTime = $("#end_time"); fromDay.val(formatDay(from)); @@ -50,7 +50,7 @@ function setInput(from, to) { toTime.val(formatTime(to)); } -function setDay(days) { +global.setDay = (days) => { days = days || 0; var from = moment(); @@ -64,7 +64,7 @@ function setDay(days) { setInput(from, to); } -function setHours(hours) { +global.setHours = (hours) => { hours = hours || 1; var from = moment(); -- cgit v1.2.3-54-g00ecf From 28349b69a8e591ddd2472bd53a3029de96444696 Mon Sep 17 00:00:00 2001 From: Bot Date: Sat, 11 Aug 2018 22:16:57 +0200 Subject: Changed JS to use single quotes instead of double quotes --- frontend/js/forms.js | 26 +++++++++++++------------- frontend/js/moment-countdown.js | 12 ++++++------ frontend/js/sticky-headers.js | 22 +++++++++++----------- frontend/js/vendor.js | 2 +- includes/helper/graph_helper.php | 2 +- includes/sys_form.php | 22 +++++++++++----------- includes/sys_template.php | 10 +++++----- includes/view/UserDriverLicenses_view.php | 14 +++++++------- public/index.php | 2 +- templates/layout.html | 2 +- 10 files changed, 57 insertions(+), 57 deletions(-) (limited to 'frontend/js/forms.js') diff --git a/frontend/js/forms.js b/frontend/js/forms.js index 67b14b32..db1a3f83 100644 --- a/frontend/js/forms.js +++ b/frontend/js/forms.js @@ -2,10 +2,10 @@ * Sets all checkboxes to the wanted state * * @param {string} id Id of the element containing all the checkboxes - * @param {bool} checked True if the checkboxes should be checked + * @param {boolean} checked True if the checkboxes should be checked */ global.checkAll = (id, checked) => { - $("#" + id + " input[type='checkbox']").each(function () { + $('#' + id + ' input[type="checkbox"]').each(function () { this.checked = checked; }); } @@ -17,7 +17,7 @@ global.checkAll = (id, checked) => { * @param {list} shifts_list A list of numbers */ 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; }); } @@ -26,14 +26,14 @@ global.checkOwnTypes = (id, shifts_list) => { * @param {moment} date */ global.formatDay = (date) => { - return date.format("YYYY-MM-DD"); + return date.format('YYYY-MM-DD'); } /** * @param {moment} date */ global.formatTime = (date) => { - return date.format("HH:mm"); + return date.format('HH:mm'); } /** @@ -41,7 +41,7 @@ global.formatTime = (date) => { * @param {moment} 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)); fromTime.val(formatTime(from)); @@ -56,7 +56,7 @@ global.setDay = (days) => { var from = moment(); from.hours(0).minutes(0).seconds(0); - from.add(days, "d"); + from.add(days, 'd'); var to = from.clone(); to.hours(23).minutes(59); @@ -70,7 +70,7 @@ global.setHours = (hours) => { var from = moment(); var to = from.clone(); - to.add(hours, "h"); + to.add(hours, 'h'); if (to < from) { setInput(to, from); return; @@ -83,12 +83,12 @@ $(function () { /** * Disable every submit button after clicking (to prevent double-clicking) */ - $("form").submit(function (ev) { - $("input[type='submit']").prop("readonly", true).addClass("disabled"); + $('form').submit(function (ev) { + $('input[type="submit"]').prop('readonly', true).addClass('disabled'); return true; }); - $(".dropdown-menu").css("max-height", function () { - return ($(window).height() - 50) + "px"; - }).css("overflow-y", "scroll"); + $('.dropdown-menu').css('max-height', function () { + return ($(window).height() - 50) + 'px'; + }).css('overflow-y', 'scroll'); }); diff --git a/frontend/js/moment-countdown.js b/frontend/js/moment-countdown.js index feb7b604..f5effbc0 100644 --- a/frontend/js/moment-countdown.js +++ b/frontend/js/moment-countdown.js @@ -1,18 +1,18 @@ /* * Initialize all moment countdowns on the page. A moment countdown has the - * class "moment-countdown" and the attribute "data-timestamp" which defines the + * class 'moment-countdown' and the attribute 'data-timestamp' which defines the * countdown's time goal. */ $(document).ready(function () { - if (typeof moment !== "undefined") { - $.each($(".moment-countdown"), function (i, e) { + if (typeof moment !== 'undefined') { + $.each($('.moment-countdown'), function (i, e) { var span = $(e); var text = span.html(); /* global moment */ - var timestamp = moment(parseInt(span.attr("data-timestamp") * 1000)); - span.html(text.replace("%c", timestamp.fromNow())); + var timestamp = moment(parseInt(span.attr('data-timestamp') * 1000)); + span.html(text.replace('%c', timestamp.fromNow())); setInterval(function () { - span.html(text.replace("%c", timestamp.fromNow())); + span.html(text.replace('%c', timestamp.fromNow())); }, 1000); }); } diff --git a/frontend/js/sticky-headers.js b/frontend/js/sticky-headers.js index 6e6a75e2..c664387c 100644 --- a/frontend/js/sticky-headers.js +++ b/frontend/js/sticky-headers.js @@ -2,29 +2,29 @@ * Enables the fixed headers and time lane for the shift-calendar and datatables */ $(document).ready(function () { - if ($(".shift-calendar").length) { - var timeLanes = $(".shift-calendar .time"); - var headers = $(".shift-calendar .header"); - var topReference = $(".container-fluid .row"); + if ($('.shift-calendar').length) { + var timeLanes = $('.shift-calendar .time'); + var headers = $('.shift-calendar .header'); + var topReference = $('.container-fluid .row'); timeLanes.css({ - "position": "relative", - "z-index": 999 + 'position': 'relative', + 'z-index': 999 }); headers.css({ - "position": "relative", - "z-index": 900 + 'position': 'relative', + 'z-index': 900 }); $(window).scroll( function () { var top = headers.parent().offset().top; var left = 15; timeLanes.css({ - "left": Math.max(0, $(window).scrollLeft() - left) + "px" + 'left': Math.max(0, $(window).scrollLeft() - left) + 'px' }); headers.css({ - "top": Math.max(0, $(window).scrollTop() - top + 'top': Math.max(0, $(window).scrollTop() - top + topReference.offset().top) - + "px" + + 'px' }); }); } diff --git a/frontend/js/vendor.js b/frontend/js/vendor.js index 467fa2ac..dd6b66b3 100644 --- a/frontend/js/vendor.js +++ b/frontend/js/vendor.js @@ -12,5 +12,5 @@ require('./sticky-headers'); require('./moment-countdown'); $(function () { - moment.locale("%locale%"); + moment.locale($('html').attr('lang')); }); diff --git a/includes/helper/graph_helper.php b/includes/helper/graph_helper.php index 12c7df6c..f49ab635 100644 --- a/includes/helper/graph_helper.php +++ b/includes/helper/graph_helper.php @@ -33,7 +33,7 @@ function bargraph($dom_id, $key, $row_names, $colors, $data) return ' @@ -73,13 +73,13 @@ function form_date($name, $label, $value, $start_date = '', $end_date = '') diff --git a/includes/sys_template.php b/includes/sys_template.php index a988ca7c..986270b5 100644 --- a/includes/sys_template.php +++ b/includes/sys_template.php @@ -231,12 +231,12 @@ function toolbar_popover($glyphicon, $label, $content, $class = '') . ' '; diff --git a/includes/view/UserDriverLicenses_view.php b/includes/view/UserDriverLicenses_view.php index b92f5f07..be21ca53 100644 --- a/includes/view/UserDriverLicenses_view.php +++ b/includes/view/UserDriverLicenses_view.php @@ -53,18 +53,18 @@ function UserDriverLicense_edit_view($user_source, $wants_to_drive, $user_driver ]), '