!function(){"use strict";function t(){this.enableCancel=!1,this.enableSubmit=!1}t.prototype.setup=function(t){var e=GeneralFunctions.getWeekDayId(GlobalVariables.firstWeekday),a=GeneralFunctions.sortWeekDictionary(t,e);$(".working-plan tbody").empty(),$(".breaks tbody").empty();var r="regular"===GlobalVariables.timeFormat?"h:mm tt":"HH:mm";$.each(a,function(t,e){var a=this.convertValueToDay(t),n=GeneralFunctions.upperCaseFirstLetter(a);$("
",{html:[$(" | ",{html:[$("",{class:"checkbox form-check",html:[$("",{class:"form-check-input",type:"checkbox",id:t}),$("",{class:"form-check-label",text:n,for:t})]})]}),$(" | ",{html:[$("",{id:t+"-start",class:"work-start form-control input-sm"})]}),$(" | ",{html:[$("",{id:t+"-end",class:"work-start form-control input-sm"})]})]}).appendTo(".working-plan tbody"),e?($("#"+t).prop("checked",!0),$("#"+t+"-start").val(Date.parse(e.start).toString(r).toUpperCase()),$("#"+t+"-end").val(Date.parse(e.end).toString(r).toUpperCase()),e.breaks.sort(function(t,e){return t.start.localeCompare(e.start)}),e.breaks.forEach(function(t){$("
",{html:[$(" | ",{class:"break-day editable",text:n}),$(" | ",{class:"break-start editable",text:Date.parse(t.start).toString(r).toUpperCase()}),$(" | ",{class:"break-end editable",text:Date.parse(t.end).toString(r).toUpperCase()}),$(" | ",{html:[$("",{type:"button",class:"btn btn-outline-secondary btn-sm edit-break",title:EALang.edit,html:[$("",{class:"fas fa-edit"})]}),$("",{type:"button",class:"btn btn-outline-secondary btn-sm delete-break",title:EALang.delete,html:[$("",{class:"fas fa-trash-alt"})]}),$("",{type:"button",class:"btn btn-outline-secondary btn-sm save-break d-none",title:EALang.save,html:[$("",{class:"fas fa-check-circle"})]}),$("",{type:"button",class:"btn btn-outline-secondary btn-sm cancel-break d-none",title:EALang.cancel,html:[$("",{class:"fas fa-ban"})]})]})]}).appendTo(".breaks tbody")})):($("#"+t).prop("checked",!1),$("#"+t+"-start").prop("disabled",!0),$("#"+t+"-end").prop("disabled",!0))}.bind(this)),this.editableDayCell($(".breaks .break-day")),this.editableTimeCell($(".breaks").find(".break-start, .break-end"))},t.prototype.setupWorkingPlanExceptions=function(t){for(var e in t){var a=t[e];this.renderWorkingPlanExceptionRow(e,a).appendTo(".working-plan-exceptions tbody")}},t.prototype.editableDayCell=function(t){var e={};e[EALang.sunday]=EALang.sunday,e[EALang.monday]=EALang.monday,e[EALang.tuesday]=EALang.tuesday,e[EALang.wednesday]=EALang.wednesday,e[EALang.thursday]=EALang.thursday,e[EALang.friday]=EALang.friday,e[EALang.saturday]=EALang.saturday,t.editable(function(t,e){return t},{type:"select",data:e,event:"edit",height:"30px",submit:'',cancel:'',onblur:"ignore",onreset:function(t,e){if(!this.enableCancel)return!1}.bind(this),onsubmit:function(t,e){if(!this.enableSubmit)return!1}.bind(this)})},t.prototype.editableTimeCell=function(t){t.editable(function(t,e){return t},{event:"edit",height:"30px",submit:$("",{type:"button",class:"d-none submit-editable",text:EALang.save}).get(0).outerHTML,cancel:$("",{type:"button",class:"d-none cancel-editable",text:EALang.cancel}).get(0).outerHTML,onblur:"ignore",onreset:function(t,e){if(!this.enableCancel)return!1}.bind(this),onsubmit:function(t,e){if(!this.enableSubmit)return!1}.bind(this)})},t.prototype.renderWorkingPlanExceptionRow=function(t,e){var a="regular"===GlobalVariables.timeFormat?"h:mm tt":"HH:mm";return $("
",{data:{date:t,workingPlanException:e},html:[$(" | ",{class:"working-plan-exception-date",text:GeneralFunctions.formatDate(t,GlobalVariables.dateFormat,!1)}),$(" | ",{class:"working-plan-exception--start",text:Date.parse(e.start).toString(a)}),$(" | ",{class:"working-plan-exception--end",text:Date.parse(e.end).toString(a)}),$(" | ",{html:[$("",{type:"button",class:"btn btn-outline-secondary btn-sm edit-working-plan-exception",title:EALang.edit,html:[$("",{class:"fas fa-edit"})]}),$("",{type:"button",class:"btn btn-outline-secondary btn-sm delete-working-plan-exception",title:EALang.delete,html:[$("",{class:"fas fa-trash-alt"})]})]})]})},t.prototype.bindEventHandlers=function(){$(".working-plan tbody").on("click","input:checkbox",function(){var t=$(this).attr("id");!0===$(this).prop("checked")?($("#"+t+"-start").prop("disabled",!1).val("9:00 AM"),$("#"+t+"-end").prop("disabled",!1).val("6:00 PM")):($("#"+t+"-start").prop("disabled",!0).val(""),$("#"+t+"-end").prop("disabled",!0).val(""))}),$(".add-break").on("click",function(){var t="regular"===GlobalVariables.timeFormat?"h:mm tt":"HH:mm",e=$("
",{html:[$(" | ",{class:"break-day editable",text:EALang.sunday}),$(" | ",{class:"break-start editable",text:Date.parse("12:00:00").toString(t)}),$(" | ",{class:"break-end editable",text:Date.parse("14:00:00").toString(t)}),$(" | ",{html:[$("",{type:"button",class:"btn btn-outline-secondary btn-sm edit-break",title:EALang.edit,html:[$("",{class:"fas fa-edit"})]}),$("",{type:"button",class:"btn btn-outline-secondary btn-sm delete-break",title:EALang.delete,html:[$("",{class:"fas fa-trash-alt"})]}),$("",{type:"button",class:"btn btn-outline-secondary btn-sm save-break d-none",title:EALang.save,html:[$("",{class:"fas fa-check-circle"})]}),$("",{type:"button",class:"btn btn-outline-secondary btn-sm cancel-break d-none",title:EALang.cancel,html:[$("",{class:"fas fa-ban"})]})]})]}).appendTo(".breaks tbody");this.editableDayCell(e.find(".break-day")),this.editableTimeCell(e.find(".break-start, .break-end")),e.find(".edit-break").trigger("click"),$(".add-break").prop("disabled",!0)}.bind(this)),$(document).on("click",".edit-break",function(){$(this).closest("table").find(".editable").each(function(t,e){e.reset&&e.reset()}),$(this).parent().parent().children().trigger("edit"),$(this).parent().parent().find(".break-start input, .break-end input").timepicker({timeFormat:"regular"===GlobalVariables.timeFormat?"h:mm TT":"HH:mm",currentText:EALang.now,closeText:EALang.close,timeOnlyTitle:EALang.select_time,timeText:EALang.time,hourText:EALang.hour,minuteText:EALang.minutes}),$(this).parent().parent().find(".break-day select").focus();var t=$(this).closest("tr");t.find(".edit-break, .delete-break").addClass("d-none"),t.find(".save-break, .cancel-break").removeClass("d-none"),t.find("select,input:text").addClass("form-control input-sm"),$(".add-break").prop("disabled",!0)}),$(document).on("click",".delete-break",function(){$(this).parent().parent().remove()}),$(document).on("click",".cancel-break",function(t){var e=t.target,a=$(e).closest("tr");this.enableCancel=!0,a.find(".cancel-editable").trigger("click"),this.enableCancel=!1,$(e).closest("table").find(".edit-break, .delete-break").removeClass("d-none"),a.find(".save-break, .cancel-break").addClass("d-none"),$(".add-break").prop("disabled",!1)}.bind(this)),$(document).on("click",".save-break",function(t){var e=t.target,a=$(e).closest("tr"),n=Date.parse(a.find(".break-start input").val());Date.parse(a.find(".break-end input").val())