function changeShiftTime(e) { var shiftLength = ""; if (startTimeCalendar.dates.picked.length != 1 || finishTimeCalendar.dates.picked.length != 1) { } else { var startTime = getHours(moment(startTimeCalendar.dates.lastPicked)); var endTime = getHours(moment(finishTimeCalendar.dates.lastPicked)); if (startTime < endTime) { shiftLength = formatHours(endTime - startTime); } else { shiftLength = formatHours(24 - startTime + endTime) + " and is overnight."; } } $("#shift-length").text(shiftLength); } function formatHours (hours) { var str = Math.floor(hours).toString() + " hours"; if (Math.floor(hours) !== Math.ceil(hours)) { str += " and " + ((hours * 60) - (Math.floor(hours) * 60)).toString() + " minutes"; } return str; } function getHours(dateTime){ var hours = dateTime.hour(); var minutes = 0.0; if (dateTime.minute() !== 0) minutes = dateTime.minute()/60; return hours + minutes; } $(".renderDate").each(function(){ var ctrl = $(this); if(ctrl.attr("data")) { ctrl.text(moment.parseZone(ctrl.attr("data")).local().format("DD/MM/YYYY HH:mm")); } else{ ctrl.text(""); } }); (function(webapi, $){ function safeAjax(ajaxOptions) { var deferredAjax = $.Deferred(); shell.getTokenDeferred().done(function (token) { // add headers for AJAX if (!ajaxOptions.headers) { $.extend(ajaxOptions, { headers: { "__RequestVerificationToken": token } }); } else { ajaxOptions.headers["__RequestVerificationToken"] = token; } $.ajax(ajaxOptions) .done(function(data, textStatus, jqXHR) { validateLoginSession(data, textStatus, jqXHR, deferredAjax.resolve); }).fail(deferredAjax.reject); //AJAX }).fail(function () { deferredAjax.rejectWith(this, arguments); // on token failure pass the token AJAX and args }); return deferredAjax.promise(); } webapi.safeAjax = safeAjax; })(window.webapi = window.webapi || {}, jQuery) function checkMFAAuth(next, url) { var authId = sessionStorage.getItem("authKey"); var urlParams = new URLSearchParams(window.location.search); if (url === undefined || authId === "" || url === null) var url = window.location.pathname + window.location.search; if (authId === undefined || authId === "" || authId === null || !location.search.contains("authId") || sessionStorage.getItem("authKey") != urlParams.get("authId")) { window.location.replace('/my-details-access/?redir=' + encodeURIComponent(url)); } else { fetch('/mydetails-mfa-check/?id=' + authId).then(response => { return response.json(); }).then(resp => { if (resp.result) if ((next === null || next === undefined)) { if (url != location.pathname + location.search) window.location.assign(url); } else next(); else window.location.replace('/my-details-access/?redir=' + encodeURIComponent(url)); }); } } function ReplaceButton(existingButtonName, newButtonId, newFunction) { var newButton = $("#" + existingButtonName).clone(); newButton.prop('id', newButtonId); newButton.removeAttr('onclick'); newButton.on('click', SetProcessing); newButton.on('click', newFunction); $("#" + existingButtonName).parent().append(newButton); // $("#" + newButtonId).show(); $("#" + existingButtonName).hide(); } function SetProcessing(existingButton) { existingButton.target.value = "Processing..."; } "use strict"; function setFieldValue(value, crmField, datatype) { var attribute = $("#" + crmField).first(); if (attribute === undefined || attribute === null) { alert("CRMField: " + crmField + " is not currently on the form. Please update the form or configuration."); } switch (datatype) { case "string": case "decimal": case "number": attribute.val(value); break; case "boolean": if (attribute.prop("class").indexOf("boolean-dropdown") !== -1) { if (value === true) { attribute.val("1"); } else if (value === false) { attribute.val("0"); } } if (attribute.prop("class").indexOf("boolean-radio") !== -1) { if (value === true) { $("#" + crmField + "_1").first().prop("checked", true); } else if (value === false) { $("#" + crmField + "_0").first().prop("checked", true); } } if (attribute.attr("type") === "checkbox") { attribute.prop("checked", value); } break; case "date": var $displayField = attribute.nextAll(".datetimepicker").children("input"); var dateFormat = $displayField.attr("data-date-format"); attribute.val(moment(value).format("YYYY-MM-DDTHH:mm:ss.SSSSSSS")); $displayField.val(moment(value).format(dateFormat)); break; default: alert("Attempted to set data type that is not supported. Please contact your system administrator or support@beyondcrm.com.au"); } } function getFieldValue(crmField, datatype) { var attribute = $("#" + crmField).first(); if (attribute === undefined || attribute === null) { alert("CRMField: " + crmField + " is not currently on the form. Please update the form or configuration."); } switch (datatype) { case "string": case "decimal": case "number": return attribute.val(); case "boolean": if (attribute.prop("class").indexOf("boolean-dropdown") !== -1) { if (attribute.val() === "1") return true; else if (attribute.val() === "0") return false; else return null; } if (attribute.prop("class").indexOf("boolean-radio") !== -1) { if ($("#" + crmField + "_1").first().prop("checked") === true) return true; if ($("#" + crmField + "_0").first().prop("checked") === true) return false; else return null; } if (attribute.attr("type") === "checkbox") { return attribute.prop("checked"); } return null; default: alert("Attempted to set data type that is not supported. Please contact your system administrator or support@beyondcrm.com.au"); return null; } } function changeReadOnly(t, e) { e ? ($("#" + t).addClass("readonly"), $("#" + t).prop("readonly", !0)) : ($("#" + t).removeClass("readonly"), $("#" + t).prop("readonly", !1)) } function SetFieldReadOnly(fieldName, readOnly, type) { try { type = type.toLowerCase(); switch (type) { case "date": case "time": case "datetime": SetDateTimeFieldReadOnly(fieldName, readOnly); break; case "lookup": SetLookupFieldReadOnly(fieldName, readOnly); break; case "checkbox": SetCheckboxFieldReadOnly(fieldName, readOnly); break; case "radio": SetRadioFieldReadOnly(fieldName, readOnly); break; case "dropdown": SetDropdownFieldReadOnly(fieldName, readOnly); break; default: if (!!readOnly) { $("#" + fieldName).attr("readonly", true); $("#" + fieldName).css("cursor", "not-allowed"); $("#" + fieldName).on("mousedown", function (e) { e.preventDefault(); return false; }); } else { $("#" + fieldName).attr("readonly", false); $("#" + fieldName).css("cursor", "default"); $("#" + fieldName).off("mousedown"); } break; } } catch (err) { console.error("Error SetFieldReadOnly: " + err.message); return; } }; function SetDateTimeFieldReadOnly(fieldName, readOnly) { if (readOnly) { $('#' + fieldName).siblings("div.datetimepicker").find("input, .input-group-addon").attr("readonly", true); $('#' + fieldName).siblings("div.datetimepicker").find("input, .input-group-addon").css("cursor", "not-allowed"); $('#' + fieldName).siblings("div.datetimepicker").find("input, .input-group-addon").on("mousedown", function (e) { e.preventDefault(); return false; }); } else { $('#' + fieldName).siblings("div.datetimepicker").find("input, .input-group-addon").attr("readonly", false); $('#' + fieldName).siblings("div.datetimepicker").find("input, .input-group-addon").css("cursor", "default"); $('#' + fieldName).siblings("div.datetimepicker").find("input, .input-group-addon").off("mousedown"); } }; function SetLookupFieldReadOnly(fieldName, readOnly) { if (readOnly) { $('#' + fieldName).siblings("div.input-group-btn").find("button").prop("disabled", true); $('#' + fieldName).siblings("div.input-group-btn").hide(); } else { $('#' + fieldName).siblings("div.input-group-btn").find("button").prop("disabled", false); $('#' + fieldName).siblings("div.input-group-btn").show(); } }; function SetCheckboxFieldReadOnly(fieldName, readOnly) { if (readOnly) { $('#' + fieldName).prop("disabled", true); } else { $('#' + fieldName).prop("disabled", false); } }; function SetRadioFieldReadOnly(fieldName, readOnly) { if (readOnly) { $('#' + fieldName).find("input[type='radio']").prop("disabled", true); } else { $('#' + fieldName).find("input[type='radio']").prop("disabled", false); } }; function SetDropdownFieldReadOnly(fieldName, readOnly) { if (readOnly) { $('#' + fieldName).attr("readonly", true); $('#' + fieldName).css("pointer-events", "none"); } else { $('#' + fieldName).attr("readonly", false); $('#' + fieldName).css("pointer-events", "auto"); } }; function addPortalValidator(t, e, a, n) { if ("undefined" != typeof Page_Validators) { var r = document.createElement("span"); r.style.display = "none", r.id = t, r.controltovalidate = e, r.errormessage = a, r.evaluationfunction = n, Page_Validators.push(r) } } function showHideField(t, e) { e ? $("#" + t).closest("td").show() : $("#" + t).closest("td").hide() } function showHideSection(t, e) { e ? $('table[data-name="' + t + '"]').closest("fieldset").show() : $('table[data-name="' + t + '"]').closest("fieldset").hide() } function markRequired(t, e) { e ? $("#" + t + "_label").parent().addClass("info required") : $("#" + t + "_label").parent().removeClass("info required") } function clearAllValidationErrors() { ValidationSummaryEntityFormView.style = "display: none;", ValidationSummaryEntityFormView.innerHTML = "" } function showNewValidationError(t) { if ("display: none;" === ValidationSummaryEntityFormView.style.cssText && (ValidationSummaryEntityFormView.innerHTML = ValidationSummaryEntityFormView.headertext, ValidationSummaryEntityFormView.style = ""), 0 === ValidationSummaryEntityFormView.getElementsByTagName("ul").length) { var e = document.createElement("ul"); ValidationSummaryEntityFormView.appendChild(e) } var a = document.createElement("li"); a.innerText = t, ValidationSummaryEntityFormView.getElementsByTagName("ul")[0].appendChild(a) } function doEditButtonSetup() { $(".tab.clearfix:has(:input:not(.readonly):not(:button):not(:submit):not(:hidden):not(:reset):not([placeholder='Search']))").each(function (t, e) { var a = $(''); a.val("Update"), a.prop("data-name", e.getAttribute("data-name")), a.addClass("btn btn-primary pull-right action"), a.css("margin-right", "38px"), a.on("click", RunOnEdit), a.prop("id", e.getAttribute("data-name").replace(/[^a-z0-9\s]/gi, "").replace(/[_\s]/g, "-") + "-edit"), a.wrapAll('
'), $(e).find(":input:not(.readonly):not(:button):not(select):not(:hidden)").each(function (t, e) { $(e).addClass("readonly reenablerequired"), $(e).prop("disabled", !0) }), $(e).find("select").each(function (t, e) { $copy = $(e).clone(), $copy.removeAttr("id"), $copy.attr("id", "hideOnEdit"), $copy.removeAttr("name"), $copy.prop("disabled", "disabled"), $(e).addClass("readonly reenablerequired"), $(e).parent().prepend($copy), $(e).hide() }), $(e).prepend(a.parents().last()) }) } function RunOnEdit(t) { var e = $("#" + t.srcElement.id); e.prop("disabled", !0), e.val("Updating"), $("[data-name='" + e.prop("data-name") + "']").find(":input.reenablerequired:not(select)").each(function (t, e) { $(e).removeClass("readonly"), $(e).removeClass("reenablerequired"), $(e).prop("disabled", !1) }), $("[data-name='" + e.prop("data-name") + "']").find("select.reenablerequired").each(function (t, e) { $(e).removeClass("readonly"), $(e).removeClass("reenablerequired"), $(e).show(), $(e).prev().hide() }) } $(document).ready(function () { if (0 !== $("p.text-danger").length && "undefined" != typeof ValidationSummaryEntityFormView) { if ($("p.text-danger").first().parent().hide(), "display: none;" === ValidationSummaryEntityFormView.style.cssText && (ValidationSummaryEntityFormView.innerHTML = ValidationSummaryEntityFormView.headertext, ValidationSummaryEntityFormView.style = ""), 0 === ValidationSummaryEntityFormView.getElementsByTagName("ul").length) { var t = document.createElement("ul"); ValidationSummaryEntityFormView.appendChild(t) } var e = document.createElement("li"); e.innerText = $("p.text-danger").first().text(), ValidationSummaryEntityFormView.getElementsByTagName("ul")[0].appendChild(e) } }); /* from designer */ // page init jQuery(function () { initMobileNav(); initSlickCarousel(); // initCustomHover(); initAnchors(); initSlc(); initAccordion(); }); // accordion menu init function initAccordion() { ResponsiveHelper.addRange({ '..1200': { on: function () { jQuery('.acc-accordion').slideAccordion({ opener: '.acc-opener', slider: '.acc-slide', animSpeed: 300 }); }, off: function () { jQuery('.acc-accordion').slideAccordion('destroy'); } } }); } function initSlc() { var slider = $('.top-stories-slider'); var settings = { slidesToScroll: 1, rows: 0, slidesToShow: 1, arrows: false, mobileFirst: true, responsive: [{ breakpoint: 767, settings: "unslick" }] }; slider.slick(settings); $(window).on('resize', function () { if ($(window).width() > 767) { return; } if (!slider.hasClass('slick-initialized')) { return slider.slick(settings); } }); } // initialize smooth anchor links function initAnchors() { new SmoothScroll({ anchorLinks: '.back-to-top', extraOffset: 0, wheelBehavior: 'none' }); } // add classes on hover/touch function initCustomHover() { jQuery('.navigation .dropdown').touchHover({}); } // mobile menu init function initMobileNav() { jQuery('body').mobileNav({ menuActiveClass: 'active', menuOpener: '.opener' }); } // slick init function initSlickCarousel() { jQuery('.proudly-supported-slider').slick({ slidesToScroll: 1, rows: 0, infinite: true, slidesToShow: 5, arrows: false, autoplay: true, autoplaySpeed: 2000, responsive: [{ breakpoint: 480, settings: { slidesToScroll: 1, slidesToShow: 1, centerMode: true, centerPadding: '50px', } }] }); jQuery('.latest-news-slider').slick({ slidesToScroll: 1, rows: 0, slidesToShow: 3, autoplay: true, autoplaySpeed: 2000, arrows: false, responsive: [{ breakpoint: 768, settings: { slidesToScroll: 1, slidesToShow: 1, } }] }); } /* * Simple Mobile Navigation */ ; (function ($) { function MobileNav(options) { this.options = $.extend({ container: null, hideOnClickOutside: false, menuActiveClass: 'nav-active', menuOpener: '.nav-opener', menuDrop: '.nav-drop', toggleEvent: 'click', outsideClickEvent: 'click touchstart pointerdown MSPointerDown' }, options); this.initStructure(); this.attachEvents(); } MobileNav.prototype = { initStructure: function () { this.page = $('html'); this.container = $(this.options.container); this.opener = this.container.find(this.options.menuOpener); this.drop = this.container.find(this.options.menuDrop); }, attachEvents: function () { var self = this; if (activateResizeHandler) { activateResizeHandler(); activateResizeHandler = null; } this.outsideClickHandler = function (e) { if (self.isOpened()) { var target = $(e.target); if (!target.closest(self.opener).length && !target.closest(self.drop).length) { self.hide(); } } }; this.openerClickHandler = function (e) { e.preventDefault(); self.toggle(); }; this.opener.on(this.options.toggleEvent, this.openerClickHandler); }, isOpened: function () { return this.container.hasClass(this.options.menuActiveClass); }, show: function () { this.container.addClass(this.options.menuActiveClass); if (this.options.hideOnClickOutside) { this.page.on(this.options.outsideClickEvent, this.outsideClickHandler); } }, hide: function () { this.container.removeClass(this.options.menuActiveClass); if (this.options.hideOnClickOutside) { this.page.off(this.options.outsideClickEvent, this.outsideClickHandler); } }, toggle: function () { if (this.isOpened()) { this.hide(); } else { this.show(); } }, destroy: function () { this.container.removeClass(this.options.menuActiveClass); this.opener.off(this.options.toggleEvent, this.clickHandler); this.page.off(this.options.outsideClickEvent, this.outsideClickHandler); } }; var activateResizeHandler = function () { var win = $(window), doc = $('html'), resizeClass = 'resize-active', flag, timer; var removeClassHandler = function () { flag = false; doc.removeClass(resizeClass); }; var resizeHandler = function () { if (!flag) { flag = true; doc.addClass(resizeClass); } clearTimeout(timer); timer = setTimeout(removeClassHandler, 500); }; win.on('resize orientationchange', resizeHandler); }; $.fn.mobileNav = function (options) { return this.each(function () { var params = $.extend({}, options, { container: this }), instance = new MobileNav(params); $.data(this, 'MobileNav', instance); }); }; }(jQuery)); /* _ _ _ _ ___| (_) ___| | __ (_)___ / __| | |/ __| |/ / | / __| \__ \ | | (__| < _ | \__ \ |___/_|_|\___|_|\_(_)/ |___/ |__/ Version: 1.9.0 Author: Ken Wheeler Website: http://kenwheeler.github.io Docs: http://kenwheeler.github.io/slick Repo: http://github.com/kenwheeler/slick Issues: http://github.com/kenwheeler/slick/issues */ (function (i) { "use strict"; "function" == typeof define && define.amd ? define(["jquery"], i) : "undefined" != typeof exports ? module.exports = i(require("jquery")) : i(jQuery) })(function (i) { "use strict"; var e = window.Slick || {}; e = function () { function e(e, o) { var s, n = this; n.defaults = { accessibility: !0, adaptiveHeight: !1, appendArrows: i(e), appendDots: i(e), arrows: !0, asNavFor: null, prevArrow: '', nextArrow: '', autoplay: !1, autoplaySpeed: 3e3, centerMode: !1, centerPadding: "50px", cssEase: "ease", customPaging: function (e, t) { return i('