$(function(){"use strict";var n=$("#working-plan-exceptions-modal"),a=$("#working-plan-exceptions-date"),i=$("#working-plan-exceptions-start"),s=$("#working-plan-exceptions-end"),o=$("#working-plan-exceptions-breaks"),e=$("#working-plan-exceptions-save"),d=null,r=!1,t=!1;function l(){a.val(""),i.val(""),s.val(""),o.find("tbody").empty()}function c(e){e.editable(function(e){return e},{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(){if(!t)return!1},onsubmit:function(){if(!r)return!1}})}function p(e){var t="regular"===GlobalVariables.timeFormat?"h:mm tt":"HH:mm";return $("
",{html:[$(" | ",{class:"working-plan-exceptions-break-start editable",text:Date.parse(e.start).toString(t)}),$(" | ",{class:"working-plan-exceptions-break-end editable",text:Date.parse(e.end).toString(t)}),$(" | ",{html:[$("",{type:"button",class:"btn btn-outline-secondary btn-sm mr-2 working-plan-exceptions-edit-break",title:EALang.edit,html:[$("",{class:"fas fa-edit"})]}),$("",{type:"button",class:"btn btn-outline-secondary btn-sm working-plan-exceptions-delete-break",title:EALang.delete,html:[$("",{class:"fas fa-trash-alt"})]}),$("",{type:"button",class:"btn btn-outline-secondary btn-sm mr-2 working-plan-exceptions-save-break d-none",title:EALang.save,html:[$("",{class:"fas fa-check-circle"})]}),$("",{type:"button",class:"btn btn-outline-secondary btn-sm working-plan-exceptions-cancel-break d-none",title:EALang.cancel,html:[$("",{class:"fas fa-ban"})]})]})]})}function g(e){e.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})}!function(e){var t;switch(GlobalVariables.dateFormat){case"DMY":t="dd/mm/yy";break;case"MDY":t="mm/dd/yy";break;case"YMD":t="yy/mm/dd";break;default:throw new Error("Invalid date format setting provided: "+GlobalVariables.dateFormat)}e.datepicker({dateFormat:t,firstDay:GeneralFunctions.getWeekDayId(GlobalVariables.firstWeekday),minDate:0,defaultDate:Date.today(),dayNames:[EALang.sunday,EALang.monday,EALang.tuesday,EALang.wednesday,EALang.thursday,EALang.friday,EALang.saturday],dayNamesShort:[EALang.sunday.substr(0,3),EALang.monday.substr(0,3),EALang.tuesday.substr(0,3),EALang.wednesday.substr(0,3),EALang.thursday.substr(0,3),EALang.friday.substr(0,3),EALang.saturday.substr(0,3)],dayNamesMin:[EALang.sunday.substr(0,2),EALang.monday.substr(0,2),EALang.tuesday.substr(0,2),EALang.wednesday.substr(0,2),EALang.thursday.substr(0,2),EALang.friday.substr(0,2),EALang.saturday.substr(0,2)],monthNames:[EALang.january,EALang.february,EALang.march,EALang.april,EALang.may,EALang.june,EALang.july,EALang.august,EALang.september,EALang.october,EALang.november,EALang.december],prevText:EALang.previous,nextText:EALang.next,currentText:EALang.now,closeText:EALang.close})}(a),g(i),g(s),n.on("hidden.bs.modal",function(){l()}).on("click",".working-plan-exceptions-add-break",function(){var e=p({start:"12:00",end:"14:00"}).appendTo("#working-plan-exceptions-breaks tbody");c(e.find(".working-plan-exceptions-break-start, .working-plan-exceptions-break-end")),e.find(".working-plan-exceptions-edit-break").trigger("click"),$(".working-plan-exceptions-add-break").prop("disabled",!0)}).on("click",".working-plan-exceptions-edit-break",function(){$(this).closest("table").find(".editable").each(function(e,t){t.reset&&t.reset()});var e=$(this).closest("tr");e.children().trigger("edit"),g(e.find(".working-plan-exceptions-break-start input, .working-plan-exceptions-break-end input")),$(this).closest("tr").find(".working-plan-exceptions-break-start").focus(),(e=$(this).closest("tr")).find(".working-plan-exceptions-edit-break, .working-plan-exceptions-delete-break").addClass("d-none"),e.find(".working-plan-exceptions-save-break, .working-plan-exceptions-cancel-break").removeClass("d-none"),e.find("select,input:text").addClass("form-control input-sm"),$(".working-plan-exceptions-add-break").prop("disabled",!0)}).on("click",".working-plan-exceptions-delete-break",function(){$(this).closest("tr").remove()}).on("click",".working-plan-exceptions-save-break",function(){var e=$(this).closest("tr"),t=Date.parse(e.find(".working-plan-exceptions-break-start input").val());Date.parse(e.find(".working-plan-exceptions-break-end input").val())