0byt3m1n1
Path:
/
home
/
mgatv524
/
giga.mgaplay.com.br
/
web
/
dist
/
core
/
[
Home
]
File: xibo-cms.js
var timelineForm,lastForm,gridTimeouts=[],buttonsTemplate,autoSubmitTemplate=null;function XiboInitialise(t){null!=t&&""!=t||(t=" "),$(t+" .XiboGrid").each((function(){var e=$(this).data().gridName,t=$(this).find(".XiboFilter form");if(null!=e){var a;try{null==(a=JSON.parse(localStorage.getItem(e)))&&(localStorage.setItem(e,JSON.stringify(t.serializeArray())),a=JSON.parse(localStorage.getItem(e)))}catch(e){a=[]}const o=new URL(window.location.href);var n=new URLSearchParams(o.search.slice(1));$.each(a,(function(e,a){var o=a.name.replace(/\[\]/,"\\\\[\\\\]");try{var r=t.find("input[name="+o+"], select[name="+o+"]");null!==n.get(o)?r.val(n.get(o)):r.length>0&&r.val(a.value)}catch(e){console.log("Error populating form saved value with selector input[name="+a.name+"], select[name="+a.name+"]")}}))}var o=_.debounce((function(){null!=e&&localStorage.setItem(e,JSON.stringify(t.serializeArray())),$(this).closest(".XiboGrid").find("table.dataTable").DataTable().ajax.reload()}),500);$(this).find(".XiboFilter form").on("keydown",(function(e){if(13==e.keyCode)return e.preventDefault(),!1})),$(this).find(".XiboFilter form input").on("keyup",o),$(this).find('.XiboFilter form input[type="checkbox"]').on("change",o),$(this).find(".XiboFilter form select").on("change",o),$(this).find(".XiboFilter form #folderId").on("change",o);var r=rememberFolderTreeStateGlobally?"grid-folder-tree-state":"grid_"+e;initJsTreeAjax($(this).find("#container-folder-tree"),r,!1)})),$(t+" .XiboFormButton").click((function(){var e=$(this).data("eventStart"),t=$(this).data("eventEnd");if(void 0!==e&&void 0!==t){var a={eventStart:e,eventEnd:t};XiboFormRender($(this),a)}else XiboFormRender($(this));return!1})),$(t+" .XiboCustomFormButton").click((function(){return XiboCustomFormRender($(this)),!1})),$(t+" .XiboRedirectButton").click((function(){window.location=$(this).attr("href")})),$(t+" .XiboHoverButton").hover((function(e){return XiboHoverRender($(this).attr("href"),e.pageX,e.pageY),!1}),(function(){return!1})),$(t+" .XiboForm").validate({submitHandler:XiboFormSubmit,errorElement:"span",highlight:function(e){$(e).closest(".form-group").removeClass("has-success").addClass("has-error")},success:function(e){$(e).closest(".form-group").removeClass("has-error").addClass("has-success")},invalidHandler:function(e,t){$(this).closest(".modal-dialog").find(".saving").remove(),$(this).closest(".modal-dialog").find(".save-button").removeClass("disabled")}}),$(t+" .XiboAjaxSubmit").click((function(){return $.ajax({type:"post",url:$(this).attr("href"),cache:!1,dataType:"json",success:XiboSubmitResponse}),!1})),$(t+" .XiboAutoForm").submit((function(){return XiboFormSubmit(this),!1})),$(t+" .XiboTextForm").validate({submitHandler:XiboFormSubmit,errorElement:"span",highlight:function(e){$(e).closest(".form-group").removeClass("has-success").addClass("has-error")},success:function(e){$(e).closest(".form-group").removeClass("has-error").addClass("has-success")}}),$(t+" .XiboHelpButton").click((function(){var e=$(this).attr("href");return window.open(e),!1})),$(t+" .dropdown-menu").on("click",(function(e){$(this).hasClass("dropdown-menu-form")&&e.stopPropagation()})),$(t+" .datePicker:not(.datePickerHelper)").each((function(){"Jalali"==calendarType?initDatePicker($(this),systemDateFormat,jsDateOnlyFormat,{altFieldFormatter:function(e){var t=moment.unix(e/1e3);return t.set("hour",0),t.set("minute",0),t.set("second",0),t.format(systemDateFormat)}}):initDatePicker($(this),systemDateFormat,jsDateOnlyFormat)})),$(t+" .dateTimePicker:not(.datePickerHelper)").each((function(){var e=dateFormat.includes("s"),t=!dateFormat.includes("A");"Jalali"==calendarType?initDatePicker($(this),systemDateFormat,jsDateFormat,{timePicker:{enabled:!0,second:{enabled:e}}}):initDatePicker($(this),systemDateFormat,jsDateFormat,{enableTime:!0,time_24hr:t,enableSeconds:e,altFormat:jsDateFormat})})),$(t+" .dateMonthPicker:not(.datePickerHelper)").each((function(){"Jalali"==calendarType?($(this).data().linkFormat,initDatePicker($(this),systemDateFormat,jsDateFormat,{format:"MMMM YYYY",viewMode:"month",dayPicker:{enabled:!1},altFieldFormatter:function(e){var t=moment.unix(e/1e3);return t.set("date",1),t.set("hour",0),t.set("minute",0),t.set("second",0),t.format(systemDateFormat)}})):initDatePicker($(this),systemDateFormat,jsDateFormat,{plugins:[new flatpickrMonthSelectPlugin({shorthand:!1,dateFormat:systemDateFormat,altFormat:"MMMM Y",parseDate:function(e,t){return moment(e,t,!0).toDate()},formatDate:function(e,t,a){return moment(e).format(t)}})]})})),$(t+" .timePicker:not(.datePickerHelper)").each((function(){var e=dateFormat.includes("s");"Jalali"==calendarType?initDatePicker($(this),systemTimeFormat,jsTimeFormat,{onlyTimePicker:!0,format:jsTimeFormat,timePicker:{second:{enabled:e}},altFieldFormatter:function(e){var t=moment.unix(e/1e3);return t.set("second",0),t.format(systemTimeFormat)}}):initDatePicker($(this),systemTimeFormat,jsTimeFormat,{enableTime:!0,noCalendar:!0,enableSeconds:e,time_24hr:!0,altFormat:jsTimeFormat})})),$(t+" .selectPicker select.form-control").select2({dropdownParent:$(t).hasClass("modal")?$(t):$("body"),templateResult:function(e){if(!e.id)return e.text;var t=$(e.element);return void 0!==t.data().content?$(t.data().content):e.text}}),$(t+" .pagedSelect select.form-control").each((function(){var e=$(this).data("anchorElement");makePagedSelect($(this),void 0!==e&&""!==e?$(e):$("body"))})),$(t+" .localSelect select.form-control").each((function(){makeLocalSelect($(this),$(t).hasClass("modal")?$(t):$("body"))})),$(t+" span.notification-date").each((function(){$(this).html(moment($(this).html(),"X").fromNow())})),$(t+" input.bootstrap-switch-target").each((function(){$(this).bootstrapSwitch()})),$(t+" .colorpicker-input").each((function(){$(this).colorpicker()})),$(t+" input[data-role=tagsInputInline], "+t+" input[data-role=tagsInputForm], "+t+" select[multiple][data-role=tagsInputForm]").each((function(){var e=this,t=$(e).data("autoCompleteUrl");if(null!=t&&""!=t){var a=new Bloodhound({datumTokenizer:Bloodhound.tokenizers.whitespace,queryTokenizer:Bloodhound.tokenizers.whitespace,initialize:!1,remote:{url:t,prepare:function(e,t){return t.data={tag:e},t},filter:function(e){return $.map(e.data,(function(e){return{tag:e.tag}}))}},sorter:function(e,t){var a=e.tag.toUpperCase(),n=t.tag.toUpperCase();return a<n?-1:a>n?1:0}});a.initialize().done((function(){$(e).tagsinput({typeaheadjs:{name:"tags",displayKey:"tag",valueKey:"tag",source:a.ttAdapter()}})})).fail((function(){console.info("Auto-complete for tag failed! Using default..."),$(e).tagsinput()}))}else $(e).tagsinput()})),$(t+" .tags-with-value").length>0&&tagsWithValues($(t).find("form").attr("id")),$(t+" .XiboCommand").each((function(){var t=$(this),a=t.find("input");a.hide();var n={freetext:translations.freeTextCommand,tpv_led:"Philips Android",rs232:"RS232",intent:"Android Intent",http:"HTTP"},o=function(e){var n=a.val(),o=r(a.val()),s=t.find(".command-inputs"),l=Handlebars.compile($("#command-input-"+e+"-template").html());if(s.html(l({value:o.value,initVal:n,unique:(new Date).valueOf()})),"intent"==e){var d=Handlebars.compile($("#command-input-intent-extra-template").html());null!=o.value.extras&&o.value.extras.forEach((function(e){s.find(".intent-extra-container").append(d(e))})),s.find(".intent-add-extra").on("click",(function(){s.find(".intent-extra-container").append(d({})),i(e)})),s.off("click",".intent-remove-extra").on("click",".intent-remove-extra",(function(){$(this).parents(".intent-extra-element").remove(),i(e)}))}if("http"==e){var c=Handlebars.compile($("#command-input-http-key-value-template").html()),u=[".query-builder-container",".http-headers-container",".http-data-container"],f=[null!=o.value&&null!=o.value.query?o.value.query:null,null!=o.value&&null!=o.value.requestOptions&&null!=o.value.requestOptions.headers?o.value.requestOptions.headers:null,null!=o.value&&null!=o.value.requestOptions&&null!=o.value.requestOptions.body?o.value.requestOptions.body:null],m=function(e,t){e.find(".http-key-value-container").empty();for(let a=0;a<Object.keys(t).length;a++)e.find(".http-key-value-container").append(c({key:Object.keys(t)[a],value:Object.values(t)[a]}))},p=function(e){e=null!=e&&e;var t,a,n=$(this).parents(".request-section"),o=function(e){var t;try{t=JSON.parse(e)}catch(e){console.warn("Value not a JSON!")}return t},r=s.find(".http-contenttype").val();$(this).is(":checked")||e?n.find("textarea").hasClass("http-data")&&"application/json"!=r?"application/x-www-form-urlencoded"==r&&n.find("textarea").val(function(e){var t={};return e.find(".http-key-value-container .http-key-value-element").each((function(){var e=$(this),a=e.find(".http-key").val(),n=e.find(".http-value").val();[a,n].includes("")||(t[a]=n)})),Object.keys(t).map((e=>e+"="+t[e])).join("&")}(n)):n.find("textarea").val((a={},n.find(".http-key-value-container .http-key-value-element").each((function(){var e=$(this),t=e.find(".http-key").val(),n=e.find(".http-value").val();[t,n].includes("")?e.addClass("invalid"):(a[t]=n,e.removeClass("invalid"))})),JSON.stringify(a))):(n.find("textarea").hasClass("http-data")&&"application/json"!=r?"application/x-www-form-urlencoded"==r&&(t=o(function(e){var t;try{t='{"'+decodeURI(e.replace(/&/g,'","').replace(/=/g,'":"'))+'"}'}catch(e){console.warn("Decode URI failed!")}return t}(n.find("textarea").val()))):t=o(n.find("textarea").val()),t&&m(n,t))};for(let t=0;t<f.length;t++){var h=f[t],g=s.find(u[t]);null!=h&&m(g,h),g.find(".http-key-value-add").on("click",(function(t){$(this).parent().find(".http-key-value-container").append(c({})),i(e)})),g.off("click",".http-key-value-remove").on("click",".http-key-value-remove",(function(t){$(this).parents(".http-key-value-element").remove(),i(e)})),g.parent().find('.form-check input[type="checkbox"]').off("change").on("change",(function(){$(this).hasClass("show-raw-headers")||$(this).hasClass("show-raw-data")?p.bind(this)():i(e);var t=$(this).parents(".request-section");t.find($(this).data("toggleElement")).toggleClass($(this).data("toggleClass"),$(this).is(":checked")),t.find($(this).data("toggleElementReverse")).toggleClass($(this).data("toggleClass"),!$(this).is(":checked"))})),g.parent().off("change",".http-key-value-container .http-key-value-element input").on("change",".http-key-value-container .http-key-value-element input",(function(){p.bind(this)(!0)})),p.bind(g)(!0)}s.find(".http-contenttype").off("change").on("change",(function(){var e="text/plain"==$(this).val();s.find(".show-raw-data").parent().toggleClass("d-none",e),s.find(".show-raw-data").prop("checked",e).trigger("change"),e||p.bind($(".http-data-container"))(!0)}))}s.off("change","input:not(.ignore-change), select, textarea").on("change","input:not(.ignore-change), select, textarea",(function(){i(e)})),i(e)},r=function(e){var t={};if(""==e||null==e)t.type="freetext",t.value="";else{var a=e.split("|");if(1==a.length)t.type="freetext",t.value=e;else switch(t.type=a[0],t.type){case"intent":t.value={type:a[1],name:a[2],extras:a.length>3?JSON.parse(a[3]):[]};break;case"rs232":var n=a[1].split(","),o={deviceName:n[0],baudRate:n[1],dataBits:n[2],parity:n[3],stopBits:n[4],handshake:n[5],hexSupport:n[6]};t.value={cs:o,command:a[2]};break;case"tpv_led":t.type="tpv_led",t.value=a[1];break;case"http":var r={},i=a[2];if(null!=a[3])try{r=JSON.parse(a[3])}catch(e){console.warn("Skip JSON parse!")}if(null!=r.headers)try{r.headers=JSON.parse(r.headers)}catch(e){console.warn("Skip headers JSON parse!")}if(null!=r.body)try{if(i)if("application/json"==i)r.body=JSON.parse(r.body);else if("application/x-www-form-urlencoded"==i){var s=decodeURI(r.body).split("&"),l={};s.forEach((e=>{var t=e.split("=");(t.length=2)&&(l[t[0]]=t[1])})),r.body=l}}catch(e){console.warn("Skip body parse!")}t.type="http",t.value={url:a[1],contenttype:a[2],requestOptions:r};break;default:t.type="freetext",t.value=e}}return t},i=function(n){var o="",r=!1,i=t.find(".command-inputs");switch(n){case"tpv_led":o="tpv_led|"+i.find(".tpv-led-command").val();break;case"http":var s=i.find(".http-url").val(),l={};if(""==s?(r=!0,i.find(".http-url").addClass("invalid")):i.find(".http-url").removeClass("invalid"),i.find(".show-query-builder").is(":checked")){if(2==s.split("?").length){var d=s.split("?")[1],c=[];try{c=decodeURI(d).split("&")}catch(e){console.warn("malformed URI:"+e)}s=s.split("?")[0];for(let e=0;e<c.length;e++){var u=c[e].split("=");2==u.length&&(l[u[0]]=u[1])}}i.find(".query-builder-container .http-key-value-container .http-key-value-element").each((function(){var t=$(this);t.removeClass("invalid");var a=t.find(".http-key").val(),n=t.find(".http-value").val();try{a=encodeURI(a),n=encodeURI(n)}catch(t){console.warn("malformed URI:"+e),a="",n=""}[a,n].includes("")?(r=!0,t.addClass("invalid")):(l[a]=n,t.removeClass("invalid"))}));var f=Object.keys(l).map((e=>e+"="+l[e])).join("&");s+=""!=f?"?"+encodeURI(f):""}var m={};m.method=i.find(".http-method").val();var p=i.find(".http-contenttype").val(),h=i.find(".http-headers").val();i.find(".http-headers").parent().removeClass("invalid");try{JSON.parse(h),m.headers=h}catch(e){console.warn("Invalid headers: "+e),r=!0,i.find(".http-headers").parent().addClass("invalid")}var g=i.find(".http-data").val();i.find(".http-data").parent().removeClass("invalid");try{"application/json"==p?JSON.parse(g):"application/x-www-form-urlencoded"==p&&decodeURI(g),m.body=g}catch(e){console.warn("Invalid body: "+e),r=!0,i.find(".http-data").parent().addClass("invalid")}"object"==typeof m&&(m=JSON.stringify(m)),o="http|",o+=s+"|",o+=p+"|",o+=m;break;case"rs232":var v=i.find(".rs232-device-name").val(),b=i.find(".rs232-baud-rate").val(),y=i.find(".rs232-data-bits").val(),x=i.find(".rs232-parity").val(),k=i.find(".rs232-stop-bits").val(),T=i.find(".rs232-handshake").val(),w=i.find(".rs232-hex-support").val(),F=i.find(".rs232-command").val();i.find(".rs232-device-name").toggleClass("invalid",""==v),i.find(".rs232-baud-rate").toggleClass("invalid",""==b),i.find(".rs232-data-bits").toggleClass("invalid",""==y),[v,b,y].includes("")&&(r=!0),o="rs232|",o+=""!=v?v+",":"",o+=""!=b?b+",":"",o+=""!=y?y+",":"",o+=""!=x?x+",":"",o+=""!=k?k+",":"",o+=""!=T?T+",":"",o+=w,o+="|"+F;break;case"intent":o="intent|"+i.find(".intent-type").val()+"|"+i.find(".intent-name").val(),""==i.find(".intent-name").val()?(i.find(".intent-name").addClass("invalid"),r=!0):i.find(".intent-name").removeClass("invalid");var C=[];i.find(".intent-extra-element").each((function(){var e=$(this);e.removeClass("invalid");var t=e.find(".extra-name").val(),a=e.find(".extra-type").val(),n=e.find(".extra-value").val();if("intArray"==a){n=n.replace(" ","").split(",").map((function(e){return""!=e?Number(e):""}));for(var o=0;o<n.length;o++){var i=n[o];if(isNaN(i)||""==i){n="";break}}}else"int"==a&&""!=n?n=isNaN(Number(n))?"":Number(n):"bool"==a&&""!=n&&(n="true"==n);[t,a,n].includes("")?(r=!0,e.addClass("invalid")):C.push({name:t,type:a,value:n})})),C.length>0&&(o+="|"+JSON.stringify(C));break;default:o=i.find(".free-text").val()}r?(a.val(""),t.find(".command-preview code").text(t.find(".command-preview").data("invalidMessage")),t.find(".command-preview").addClass("invalid")):(a.val(o),t.find(".command-preview code").text(o),t.find(".command-preview").removeClass("invalid"))},s=r(a.val()).type,l=Handlebars.compile($("#command-input-main-template").html());a.before(l({types:n,type:s,unique:(new Date).valueOf()})),o(s),$(this).find(".command-type").change((function(){o($(this).val())})),$(this).find(".show-command-preview").change((function(){t.find(".command-preview").toggle($(this).is(":checked"))})),a.attr("readonly","readonly")})),$(t+" .XiboColorPicker").each((function(){createColorPicker(this)})),$(t+" .XiboData").on("shown.bs.dropdown",".dropdown-menu-container",(function(e){var t=$(this).find(".dropdown-menu.show");setTimeout((function(){t.offset().top<0&&t.offset({top:0,left:t.offset().left})}),200)}))}function dataTableProcessing(e,t,a){a?$(e.target).closest(".widget").children(".widget-title").append('<span class="saving fa fa-cog fa-spin p-1"></span>'):$(e.target).closest(".widget").closest(".widget").find(".saving").remove()}function dataTableDraw(e,t,a){var n=$("#"+e.target.id),o=n.find("div.dropdown-menu a.multi-select-button"),r=n.closest(".XiboGrid").find(".FilterDiv #tags"),i=n.closest(".XiboGrid").find(".folder-controller");if(o.length>0){n.find("tbody").off("click","tr").on("click","tr",(function(){$(this).toggleClass("selected"),n.data().initialised=!0}));var s=Handlebars.compile($("#multiselect-button-template").html()),l=[];$(o).each((function(){(function(e,t,a){for(var n in e)if(e[n].id==a)return!0;return!1})(l,0,$(this).data("id"))||l.push({id:$(this).data("id"),gridId:e.target.id,text:$(this).data("text"),customHandler:$(this).data("customHandler"),customHandlerUrl:$(this).data("customHandlerUrl"),contentIdName:$(this).data("contentIdName"),sortGroup:null!=$(this).data("sortGroup")?$(this).data("sortGroup"):0})})),r.length>0&&1==userRoutePermissions.tags&&l.push({id:r.attr("id"),gridId:e.target.id,text:translations.editTags,contentType:n.data("contentType"),contentIdName:n.data("contentIdName"),customHandler:"XiboMultiSelectTagFormRender",sortGroup:0});var d=0;if((l=l.sort((function(e,t){return e.sortGroup>t.sortGroup?1:-1}))).length>1)for(var c=0;c<l.length;c++){var u=l[c];u.sortGroup>d&&c>0&&(l.splice(c,0,{divider:!0}),d=u.sortGroup)}var f=s({selectAll:translations.selectAll,withSelected:translations.withselected,buttons:l});n.closest(".dataTables_wrapper").find(".dataTables_info").prepend(f),n.closest(".dataTables_wrapper").find(".dataTables_info a.XiboMultiSelectFormButton").click((function(){null!=$(this).data("customHandler")&&"function"==typeof window[$(this).data("customHandler")]?window[$(this).data("customHandler")](this):XiboMultiSelectFormRender(this)})),n.closest(".dataTables_wrapper").find(".dataTables_info a.XiboMultiSelectFormCustomButton").click((function(){window[$(this).data("customHandler")](this)})),n.closest(".dataTables_wrapper").find(".dataTables_info button.select-all").click((function(){var e=n.find("tbody tr");n.find("tbody tr.selected").length>e.length/2?e.removeClass("selected"):e.addClass("selected")}))}i.length>0&&0==n.closest(".dataTables_wrapper").find(".dataTables_folder .folder-controller").length&&(i.appendTo(".dataTables_folder"),i.removeClass("d-none").addClass("d-inline-flex")),"function"==typeof a&&a(),XiboInitialise("#"+e.target.id)}function dataTableButtonsColumn(e,t,a,n){return"display"!=t?"":(null==buttonsTemplate&&(buttonsTemplate=Handlebars.compile($("#buttons-template").html())),buttonsTemplate({buttons:e.buttons}))}function dataTableTickCrossColumn(e,t,a){return"display"!=t?e:"<span class='fa "+(1==e?"fa-check":0==e?"fa-times":"fa-exclamation")+"'></span>"}function dataTableTickCrossInverseColumn(e,t,a){return"display"!=t?e:"<span class='fa "+(1==e?"fa-times":0==e?"fa-check":"fa-exclamation")+"'></span>"}function dataTableDateFromIso(e,t,a){return"display"!==t&&"export"!==t?e:null==e?"":moment(e,systemDateFormat).format(jsDateFormat)}function dataTableDateFromUnix(e,t,a){return"display"!==t&&"export"!==t?e:null==e||0==e?"":moment(e,"X").tz?moment(e,"X").tz(timezone).format(jsDateFormat):moment(e,"X").format(jsDateFormat)}function dataTableTimeFromSeconds(e,t,a){if("display"!==t&&"export"!==t)return e;if(null==e||0==e)return"";var n=moment.duration(1e3*e),o=Math.floor(n.asHours());return(o<10?"0"+o:o)+moment.utc(n.asMilliseconds()).format(":mm:ss")}function dataTableSpacingPreformatted(e,t,a){return"display"!==t?e:null===e||""===e?"":'<span class="spacing-whitespace-pre">'+e+"</span>"}function dataTableCreateTags(e,t){if("display"!==t)return e.tags;var a="";return void 0!==typeof e.tags&&null!=e.tags&&(a+='<div id="tagDiv">',e.tags.split(",").forEach((e=>a+='<li class="btn btn-sm btn-white btn-tag">'+e+"</span></li>")),a+="</div>"),a}function dataTableCreatePermissions(e,t){if("display"!==t)return e;var a="";if(null!=typeof e&&null!=e){var n=e.split(",");a+='<div class="permissionsDiv">';for(var o=0;o<n.length;o++)""!=n[o]&&(a+='<li class="badge">'+n[o]+"</span></li>");a+="</div>"}return a}function dataTableCreateTagEvents(e,t){var a=$("#"+e.target.id),n=e.target.id,o=e.data.form;a.off("click"),a.on("click",".btn-tag",(function(e){var t=$(this).text();o.find("#tags").val(),"playlistLibraryMedia"==n?(o.find("#filterMediaTag").val(),o.find("#filterMediaTag").tagsinput("add",t,{allowDuplicates:!1})):"displayGroupDisplays"==n?(o.find("#dynamicCriteriaTags").val(),o.find("#dynamicCriteriaTags").tagsinput("add",t,{allowDuplicates:!1})):o.find("#tags").tagsinput("add",t,{allowDuplicates:!1}),a.DataTable().ajax.reload()}))}function dataTableConfigureRefresh(e,t,a){for(var n=a>10?a:10,o=gridTimeouts.length-1;o>=0;o--)gridTimeouts[o].label===e&&(clearTimeout(gridTimeouts[o].timer),gridTimeouts.splice(o,1));gridTimeouts.push({label:e,timer:setTimeout((function(){t.reload()}),1e3*n)})}function dataTableAddButtons(e,t,a){(a=void 0===a||a)?new $.fn.dataTable.Buttons(e,{buttons:[{extend:"colvis",columns:":not(.rowMenu)",text:function(e,t,a){return e.i18n("buttons.colvis")}},{extend:"print",text:function(e,t,a){return e.i18n("buttons.print")},exportOptions:{orthogonal:"export",format:{body:function(e,t,a,n){return null===e||""===e||"null"===e?"":e}}},customize:function(e){let t=$(e.document.body).find("table");t.removeClass("nowrap responsive dataTable no-footer dtr-inline"),t.find("th").length>16&&(t.addClass("table-sm"),t.css("font-size","6px"))}},{extend:"csv",exportOptions:{orthogonal:"export",format:{body:function(e,t,a,n){return null===e||""===e?"":e}}}}]}):new $.fn.dataTable.Buttons(e,{buttons:[{extend:"colvis",text:function(e,t,a){return e.i18n("buttons.colvis")}}]}),e.buttons(0,null).container().prependTo(t),$(t).addClass("text-right"),$(".ColVis_MasterButton").addClass("btn"),$(t).find(".dt-buttons button.btn-secondary").addClass("btn-outline-primary").removeClass("btn-secondary")}function dataTableStateLoadCallback(e,t){var a=$("#"+e.sTableId).data().statePreferenceName,n=void 0!==a?a:e.sTableId+"Grid",o={};return $.ajax({type:"GET",async:!1,url:userPreferencesUrl+"?preference="+n,dataType:"json",success:function(e){try{e.success&&(o=JSON.parse(e.data.value))}catch(e){}}}),o}function dataTableStateSaveCallback(e,t){var a=$("#"+e.sTableId).data().statePreferenceName;updateUserPref([{option:void 0!==a?a:e.sTableId+"Grid",value:JSON.stringify(t)}],(function(){}))}function XiboFormRender(sourceObj,data=null){var formUrl="";return"string"==typeof sourceObj||sourceObj instanceof String?formUrl=sourceObj:(formUrl=sourceObj.attr("href"),sourceObj.removeAttr("href")),null==formUrl||(bootbox.hideAll(),(formUrl.indexOf("region/form/timeline")>-1||formUrl.indexOf("playlist/form/timeline")>-1)&&(timelineForm={url:formUrl,data:data}),lastForm=formUrl,$.ajax({type:"get",url:formUrl,cache:!1,dataType:"json",data:data,success:function(response){if(("object"==typeof sourceObj||sourceObj instanceof Object)&&sourceObj.attr("href",lastForm),response.success){if(!("string"==typeof sourceObj||sourceObj instanceof String)){var commitUrl=sourceObj.data().commitUrl;if(response.autoSubmit&&void 0!==commitUrl)return $.ajax({type:sourceObj.data().commitMethod||"POST",url:commitUrl,cache:!1,dataType:"json",success:function(e){e.success?(""!==e.message&&SystemMessage(e.message,!0),XiboRefreshAllGrids()):e.login?LoginBox(e.message):SystemMessageInline(e.message)},error:function(e){SystemMessageInline(e.responseText)}}),!1}var dialogTitle="";null!=response.dialogTitle&&""!=response.dialogTitle&&(dialogTitle=response.dialogTitle);var id=(new Date).getTime(),size="large";sourceObj&&"object"==typeof sourceObj&&(size=sourceObj.data().modalSize||"large");var dialog=bootbox.dialog({message:response.html,title:dialogTitle,animate:!1,size:size}).attr("id",id);if(dialog.data("extra",response.extra),""!==response.buttons){var footer=$("<div>").addClass("modal-footer");dialog.find(".modal-content").append(footer);var i=0,count=Object.keys(response.buttons).length;$.each(response.buttons,(function(index,value){i++;var extrabutton=$('<button id="dialog_btn_'+i+'" class="btn">').html(index);i===count?extrabutton.addClass("btn-primary save-button"):extrabutton.addClass("btn-white"),extrabutton.click((function(e){e.preventDefault();var $button=$(this);if($button.hasClass("save-button")){if($button.hasClass("disabled"))return!1;$button.append(' <span class="saving fa fa-cog fa-spin"></span>'),$button.addClass("disabled")}return value.indexOf("DialogClose")>-1&&(lastForm.indexOf("playlist/widget/form")>-1||lastForm.indexOf("playlist/form/library/assign")>-1)&&null!=timelineForm?XiboFormRender(timelineForm.url,timelineForm.value):eval(value),!1})),footer.append(extrabutton)})),"string"==typeof sourceObj||sourceObj instanceof String||sourceObj.data().autoSubmit&&(null===autoSubmitTemplate&&(autoSubmitTemplate=Handlebars.compile($("#auto-submit-field-template").html())),footer.prepend(autoSubmitTemplate()))}$("input[type=text]",dialog).not(".dateControl").eq(0).focus(),$("input[type=text]",dialog).each((function(e,t){formRenderDetectSpacingIssues(t),$(t).on("keyup",_.debounce((function(){formRenderDetectSpacingIssues(t)}),500))})),""!=response.fieldActions&&$.each(response.fieldActions,(function(e,t){if("init"==t.trigger){var a=$("#"+t.field).val();("not"==t.operation?a!=t.value:"is:checked"==t.operation?t.value==$("#"+t.field).is(":checked"):a==t.value)&&$.each(t.actions,(function(e,t){var a=$(e);a.data("initActioned")||a.css(t).data("initActioned",!0)}))}else $("#"+t.field).on(t.trigger,(function(){var e=$(this).val();("not"==t.operation?e!=t.value:"is:checked"==t.operation?t.value==$("#"+t.field).is(":checked"):e==t.value)&&$.each(t.actions,(function(e,t){$(e).css(t)}))}))})),$('a[data-toggle="tab"]',dialog).on("shown.bs.tab",(function(e){1===$(e.target).data().enlarge?$(e.target).closest(".modal").addClass("modal-big"):$(e.target).closest(".modal").removeClass("modal-big")})),$('a[data-toggle="tab"]',dialog).each((function(){1===$(this).data().enlarge&&$(this).closest("li").hasClass("active")&&$(this).closest(".modal").addClass("modal-big")})),0!=$("#folder-tree-form-modal").length&&$("#folder-tree-form-modal").remove(),XiboInitialise("#"+dialog.attr("id")),null!=dialog.find(".XiboForm").attr("id")&&(void 0!==$("#container-folder-tree").jstree("get_selected",!0)[0]&&""==$("#"+dialog.find(".XiboForm").attr("id")+" #folderId").val()&&$("#"+dialog.find(".XiboForm").attr("id")+" #folderId").val($("#container-folder-tree").jstree("get_selected",!0)[0].id),initJsTreeAjax("#container-folder-form-tree",dialog.find(".XiboForm").attr("id"),!0,600)),""!==response.callBack&&void 0!==response.callBack&&eval(response.callBack)(dialog)}else{if(response.login)return LoginBox(response.message),!1;null==response.message?SystemMessage(response):SystemMessage(response.message)}return!1},error:function(e){SystemMessage(e.responseText)}})),!1}function XiboCustomFormRender(e){var t;return t=e.attr("href"),e.removeAttr("href"),null==t||(lastForm=t,$.ajax({type:"get",url:t,cache:!1,dataType:"json",success:function(t){if(("object"==typeof e||e instanceof Object)&&e.attr("href",lastForm),t.success){var a={id:(new Date).getTime(),buttons:t.buttons,data:t.data,title:t.dialogTitle,message:t.html,extra:t.extra};""!==t.callBack&&void 0!==t.callBack&&window[t.callBack](a)}else{if(t.login)return LoginBox(t.message),!1;null==t.message?SystemMessage(t):SystemMessage(t.message)}return!1},error:function(e){SystemMessage(e.responseText)}})),!1}function XiboRemoteRequest(e,t,a){$.ajax({type:"post",url:e,cache:!1,dataType:"json",data:t,success:a,error:function(e){SystemMessage(e.responseText)}})}function formRenderDetectSpacingIssues(e){var t=$(e),a=t.val();if(""!==a&&(a.startsWith(" ")||a.endsWith(" ")||a.indexOf(" ")>-1)){console.log("Field with strange spacing: "+t.attr("name"));var n=$("<span></span>").addClass("fa fa-exclamation-circle spacing-warning-icon").attr("title",translations.spacesWarning);t.parent().append(n)}else t.parent().find(".spacing-warning-icon").remove()}function XiboMultiSelectFormRender(button){var buttonId=$(button).data().buttonId,matches=[],formOpenCallback=null,message;$("."+buttonId).each((function(){$(this).closest("tr").hasClass("selected")&&(matches.push($(this)),1===matches.length&&(formOpenCallback=$(this).data().formCallback,formConfirm=$(this).data().formConfirm))})),message=matches.length>0?translations.multiselectMessage.replace("%1",""+matches.length).replace("%2",$(button).html()):translations.multiselectNoItemsMessage;var dialog=bootbox.dialog({message:message,title:translations.multiselect,animate:!1,size:"large"}),dialogContent=dialog.find(".modal-body"),footer=$("<div>").addClass("modal-footer"),extrabutton;dialog.find(".modal-content").append(footer),null!=formOpenCallback&&eval(formOpenCallback)(dialog),matches.length>0&&(extrabutton=$('<button class="btn">').html(translations.save).addClass("btn-primary save-button"),formConfirm&&extrabutton.prop("disabled",!0),extrabutton.click((function(){return $(this).append(' <span class="saving fa fa-cog fa-spin"></span>'),window.queue=$.jqmq({delay:-1,batch:1,callback:function(e){var t=$(e).data();void 0!==dialog.data().commitData&&(t=$.extend({},t,dialog.data().commitData)),$.ajax({type:t.commitMethod,url:t.commitUrl,cache:!1,dataType:"json",data:t,success:function(e,a,n){e.success?(dialogContent.append($("<div>").html(t.rowtitle+": "+translations.success)),queue.next()):e.login?LoginBox(e.message):(dialogContent.append($("<div>").html(t.rowtitle+": "+translations.failure)),footer.find(".saving").remove(),SystemMessageInline(e.message,footer.closest(".modal")))},error:function(e){SystemMessage(e,!1)}})},complete:function(){footer.find(".saving").parent().remove(),XiboRefreshAllGrids()}}),$(matches).each((function(){queue.add(this)})),queue.start(),!1})),footer.append(extrabutton)),extrabutton=$('<button class="btn">').html(translations.close).addClass("btn-white"),extrabutton.click((function(){return $(this).append(' <span class="saving fa fa-cog fa-spin"></span>'),dialog.modal("hide"),$(".modal").hasClass("in")&&$("body").addClass("modal-open"),!1})),footer.append(extrabutton)}function XiboMultiSelectPermissionsFormOpen(e){var t=$(e).parents(".XiboGrid").find(".dataTable"),a=t.find("tr.selected"),n=t.DataTable(),o=$(e).data("customHandlerUrl"),r=$(e).data("contentIdName"),i=[];a.each((function(e,t){var a=n.row(t).data();i.push(a[r])})),0==a.length?bootbox.dialog({message:translations.multiselectNoItemsMessage,title:translations.multiselect,animate:!1,size:"large",buttons:{cancel:{label:translations.close,className:"btn-white btn-bb-cancel"}}}):XiboFormRender(o,{ids:i.toString()})}function XiboMultiSelectTagFormRender(e){var t=$(e).data("contentType"),a=$(e).data("contentIdName"),n=[],o=$(e).parents(".XiboGrid").find(".dataTable"),r=o.DataTable(),i="",s="multiselectTagEditForm",l=[],d=[];o.find("tr.selected").each((function(){n.push($(this))})),0==n.length?i=translations.multiselectNoItemsMessage:(n.forEach((function(e){var t=r.row(e).data();l.push(t[a]),-1===["",null].indexOf(t.tags)&&t.tags.split(",").forEach((function(e){-1===d.indexOf(e)&&d.push(e)}))})),i=Handlebars.compile($("#multiselect-tag-edit-form-template").html()));var c,u=bootbox.dialog({message:i,title:translations.multiselect,size:"large",animate:!1}),f=u.find(".modal-body"),m=$("<div>").addClass("modal-footer");if(u.find(".modal-content").append(m),u.attr("id",s),n.length>0){if((c=$('<button class="btn">').html(translations.save).addClass("btn-primary save-button")).click((function(){var e,a=f.find("#tagsToRemove").val().split(","),n=f.find("#requestURL").val(),o={targetIds:l.toString(),targetType:t,addTags:f.find("#tagsToAdd").val(),removeTags:(e=[],d.forEach((function(t){-1==a.indexOf(t)&&e.push(t)})),e).toString()};return $(this).append('<span class="saving fa fa-cog fa-spin"></span>'),$.ajax({type:"PUT",url:n,cache:!1,dataType:"json",data:o,success:function(e,t,a){e.success?(toastr.success(e.message),u.modal("hide"),r.ajax.reload(null,!1)):(e.login?LoginBox(e.message):(m.find(".saving").remove(),SystemMessageInline(e.message,m.closest(".modal"))),$(this).find(".saving").remove())},error:function(e){SystemMessage(e,!1),$(this).find(".saving").remove()}}),!1})),m.append(c),d.length>0){var p=d.toString();f.find("#tagsToRemove").val(p)}else f.find("#tagsToRemoveContainer").hide();f.find("#requestURL").val(f.find("#requestURL").val().replace("[type]",t)),f.find("#tagsToRemove").on("beforeItemAdd",(function(e){e.cancel=-1==d.indexOf(e.item)}))}(c=$('<button class="btn">').html(translations.close).addClass("btn-white")).click((function(){return $(this).append(' <span class="saving fa fa-cog fa-spin"></span>'),u.modal("hide"),$(".modal").hasClass("in")&&$("body").addClass("modal-open"),!1})),m.append(c),XiboInitialise("#"+s)}function XiboHelpRender(e){window.open(e)}function XiboPing(e,t){$.ajax({type:"get",url:e,cache:!1,dataType:"json",success:function(e){if(e.success)null!=t&&$(t).html(e.html),e.clockUpdate&&XiboClockUpdate(e.html);else if(e.login)return LoginBox(e.message),!1;return!1}})}function XiboClockUpdate(e){$("#XiboClock").html(e)}function XiboFormSubmit(e,t,a){var n=$(e),o=n.attr("action");for(var r in CKEDITOR.instances){var i=new RegExp(CKEDITOR_DEFAULT_CONFIG.imageDownloadUrl.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&").replace(":id","([0-9]+)"),"g"),s=CKEDITOR.instances[r].getData().replace(i,(function(e,t){return"["+t+"]"}));$("#"+r).val(s)}return $.ajax({type:n.attr("method"),url:o,cache:!1,dataType:"json",data:n.serialize(),success:function(t,o,r){if(XiboSubmitResponse(t,e),null!=a&&null!=a)a(t,e);else{var i=n.data("submitCallBack");i&&"function"==typeof window[i]&&window[i](t,e)}},error:function(e,t,a){SystemMessage(e.responseText,!1)}}),n.closest(".modal-dialog").find("input[name=autoSubmit]").is(":checked")&&updateUserPref([{option:"autoSubmit."+n.attr("id"),value:!0}]),!1}function XiboSubmitResponse(response,form){$(form).closest(".modal-dialog").find(".saving").remove();var apply=$(form).data("apply");if($(form).data("apply",!1),response.success){if(""!=response.message&&SystemMessage(response.message,!0),null!=apply&&apply?($(form).data("applyCallback")&&eval($(form).data("applyCallback"))(form),$(form).closest(".modal-dialog").find(".form-error").remove(),$("input[type=text]",form).eq(0).focus()):bootbox.hideAll(),XiboRefreshAllGrids(),!apply)if(void 0!==$(form).data("nextFormUrl")){var responseId=void 0===$(form).data("nextFormIdProperty")?response.id:response.data[$(form).data("nextFormIdProperty")];XiboFormRender($(form).data().nextFormUrl.replace(":id",responseId))}else null!=lastForm&&(lastForm.indexOf("playlist/widget/form")>-1||lastForm.indexOf("playlist/form/library/assign")>-1)&&null!=timelineForm&&XiboFormRender(timelineForm.url,timelineForm.value)}else response.login?LoginBox(response.message):SystemMessageInline(response.message,$(form).closest(".modal"));return!1}function XiboHoverRender(url,x,y){return $.ajax({type:"get",url:url,cache:!1,dataType:"json",success:function(response){if(response.success){var dialogWidth="500",dialogHeight="500";response.dialogSize&&(dialogWidth=response.dialogWidth,dialogHeight=response.dialogHeight),$("body").append('<div class="XiboHover"></div>'),$(".XiboHover").css("position","absolute").css({display:"none",width:dialogWidth,height:dialogHeight,top:y,left:x}).fadeIn("slow").hover((function(){return!1}),(function(){return $(".XiboHover").hide().remove(),!1})),$(".XiboHover").html(response.html),""!=response.callBack&&null!=response.callBack&&eval(response.callBack)(name),XiboInitialise(".XiboHover")}else{if(response.login)return LoginBox(response.message),!1;null==response.message?SystemMessage(response):SystemMessage(response.message)}return!1}}),!1}function XiboDialogClose(){bootbox.hideAll()}function XiboDialogApply(e){var t=$(e);t.data("apply",!0),t.submit()}function XiboSwapDialog(e,t){bootbox.hideAll(),XiboFormRender(e,t)}function XiboRefreshAllGrids(){$(" .XiboGrid table.dataTable").each((function(){const e=$(this).closest(".XiboGrid").data("refreshOnFormSubmit");(null==e||e)&&$(this).DataTable().ajax.reload(null,!1)}))}function XiboRedirect(e){window.location.href=e}function LoginBox(e){window.location.href=window.location.href,location.reload()}function updateUserPref(e,t){null==t&&(t=function(e){return e.success?SystemMessage(e.message,!0):e.login?LoginBox(e.message):SystemMessage(e.message,e.success),!1}),$.ajax({type:"post",url:userPreferencesUrl,cache:!1,dataType:"json",data:{preference:e},success:t})}function SystemMessage(e,t){if(""!=e&&null!=e)if(t)toastr.success(e);else var a=bootbox.dialog({message:e,title:"Application Message",size:"large",buttons:[{label:"Close",className:"btn-bb-close",callback:function(){null!=lastForm&&lastForm.indexOf("playlist/widget/form")>-1&&null!=timelineForm?XiboFormRender(timelineForm.url,timelineForm.value):a.modal("hide")}}],animate:!1})}function SystemMessageInline(e,t){""!=e&&null!=e&&(null!=t&&null!=t&&0!=t.length||(t=$(".modal")),t.length<=0?toastr.error(e):($(".form-error",t).remove(),$(t).find(".btn").removeClass("disabled"),$("<div/>",{class:"card bg-light p-3 text-danger col-sm-12 text-center form-error",html:e}).appendTo(t.find(".modal-footer"))))}function ToggleFilterView(e){"none"==$(e).css("display")?$(e).fadeIn("slow"):$(e).fadeOut("slow")}function makePagedSelect(e,t){if(e.select2({dropdownParent:null==t?$("body"):$(t),ajax:{url:e.data("searchUrl"),dataType:"json",data:function(t){var a={start:0,length:10},n=t.term;if(null!=n&&null!=e.data("searchTermTags")){var o=n.match(/\[([^}]+)\]/),r="";null!=o&&(r=o[1],n=n.replace(o[0],""),a[e.data("searchTermTags")]=r)}return a[e.data("searchTerm")]=n,void 0!==e.data("filterOptions")&&(a=$.extend({},a,e.data("filterOptions"))),null!=t.page&&(a.start=10*(t.page-1)),a},processResults:function(t,a){var n=[],o=e;$.each(t.data,(function(e,t){var a={id:t[o.data("idProperty")],text:t[o.data("textProperty")]};void 0!==o.data("thumbnail")&&(a.thumbnail=t[o.data("thumbnail")]),n.push(a)}));var r=a.page||1;return{results:n,pagination:{more:10*(r=r>1?r-1:r)<t.recordsTotal}}}},templateResult:function(e){var t="";return e.thumbnail&&(t+="<span class='option-thumbnail mr-3'><img style='width: 100px; height: 60px; object-fit: cover;' src='"+e.thumbnail+"' /></span>"),t+="<span class='option-text'>"+e.text+"</span></span>",$(t)}}),null!=e.data("initialValue")&&null!=e.data("initialKey")){var a=e.data("initialValue"),n={};n[e.data("initialKey")]=a,$.ajax({url:e.data("searchUrl"),type:"GET",data:n}).then((function(t){var a=new Option(t.data[0][e.data("textProperty")],t.data[0][e.data("idProperty")],!0,!0);e.append(a).trigger("change"),e.trigger({type:"select2:select",params:{data:t}})}))}}function makeLocalSelect(e,t){e.select2({dropdownParent:null==t?$("body"):$(t),matcher:function(e,t){var a=function(e,a){var n=$(t.element).data()[a],o=null!=n?n.replace(" ","").split(","):[];return null!=e&&""!=e&&!o.includes(e)},n=$(t.element.parentElement).data().filterClass;if(Array.isArray(n)){for(var o=0;o<n.length;o++)if(a(n[o],"filter"+o+"Class"))return null}else if(a(n,"filterClass"))return null;if(""===$.trim(e.term))return t;var r=e.term.match(/\[([^}]+)\]/),i=e.term,s="";for(null!=r&&(s=r[1],i=e.term.replace(r[0],"")),i=i.replace(" ","").split(","),s=s.replace(" ","").split(","),o=0;o<i.length;o++){var l=i[o];if(""!=l&&t.text.toUpperCase().indexOf(l.toUpperCase())>-1)return t}for(o=0;o<s.length;o++){var d=s[o];if(""!=d&&null!=$(t.element).data("tags")&&$(t.element).data("tags").toUpperCase().indexOf(d.toUpperCase())>-1)return t}return null},templateResult:function(e){if(!e.id)return e.text;var t=$(e.element);return void 0!==t.data().content?$(t.data().content):e.text}})}function userPreferencesFormSubmit(){var e=$("#userPreferences");e.find('input[type="checkbox"]').each((function(){var e=$(this).is(":checked")?"on":"off",t=$(this).attr("id");$('<input type="hidden">').attr("id",t).attr("name",t).val(e).appendTo($(this).parent()),$(this).attr("disabled",!0)})),e.submit()}function initDatePicker(e,t,a,n,o,r,i){if(n=void 0===n?{}:n,o=void 0===o?null:o,r=void 0===r||r,i=void 0===i?null:i,null==t||null==a)return console.error("baseFormat and displayFormat needs to be defined!"),!1;e.data("customFormat")&&(t=e.data("customFormat"));var s=e,l=e.val();"Jalali"==calendarType?(null!=n.altField?s=$(n.altField):(s=$('<input type="text" class="form-control" id="'+e.attr("id")+'Link">'),e.after(s).hide()),s.persianDatepicker(Object.assign({initialValue:null!=l&&l,altField:"#"+e.attr("id"),altFieldFormatter:function(e){return moment.unix(e/1e3).format(t)},onSelect:function(){e.trigger("change"),s.trigger("change")}},n)),s.attr("readonly","readonly")):"Gregorian"==calendarType&&(e.parents(".bootbox.modal").removeAttr("tabindex"),flatpickr.l10ns.default.firstDayOfWeek=parseInt(moment().startOf("week").format("d")),flatpickr(e,Object.assign({altInput:!0,allowInput:!1,defaultDate:null!=l?l:null,altInputClass:"datePickerHelper "+e.attr("class"),altFormat:a,dateFormat:t,locale:"en-GB"!=language?language:"default",getWeek:function(e){return moment(e).week()},parseDate:function(e,t){return moment(e,t,!0).toDate()},formatDate:function(e,t,a){return moment(e).format(t)}},n))),s.change((function(){null!=o&&"function"==typeof o&&o()})),r&&s.parent().find(".date-clear-button").removeClass("d-none").click((function(){updateDatePicker(s,""),null!=i&&"function"==typeof i&&i()})),s.parent().find(".date-open-button").click((function(){"Gregorian"==calendarType?null!=s[0]._flatpickr&&s[0]._flatpickr.open():"Jalali"==calendarType&&s.data().datepicker.show()}))}function updateDatePicker(e,t,a,n){n=void 0!==n&&n,"Gregorian"==calendarType?null!=e[0]._flatpickr&&(""==t?(e.val("").trigger("change"),e[0]._flatpickr.setDate("")):null!=a?e[0]._flatpickr.setDate(t,n,a):e[0]._flatpickr.setDate(t)):"Jalali"==calendarType&&(""==t?(e.val("").trigger("change"),$("#"+e.attr("id")+"Link").val("").trigger("change")):$("#"+e.attr("id")+"Link").data().datepicker.setDate(1e3*moment(t,a).unix()))}function destroyDatePicker(e){"Gregorian"==calendarType?(null!=e[0]._flatpickr&&e[0]._flatpickr.destroy(),null!=e.attr("value")&&e.val(e.attr("value"))):"Jalali"==calendarType&&$("#"+e.attr("id")+"Link").data().datepicker.destroy(),e.parent().find(".date-open-button").off("click")}function initJsTreeAjax(e,t,a,n,o=null,r=null,i=null,s=[]){var l;if(a=void 0!==a&&a,n=void 0!==n&&n,0===$("#folder-tree-form-modal").length&&$("#"+t+" #folderId").length&&$("#select-folder-button").length){var d=Handlebars.compile($("#folder-tree-template").html());$("body").append(d({container:"container-folder-form-tree",modal:"folder-tree-form-modal"})),$("#folder-tree-form-modal").on("hidden.bs.modal",(function(){$(".modal:visible").length&&$(document.body).addClass("modal-open"),$(this).data("bs.modal",null)}))}var c={};$(e).length&&(c=a?{key:t+"_folder_tree",ttl:n}:{key:t+"_folder_tree"},$(e).jstree({state:c,plugins:["contextmenu","state","unique","sort","themes","types"].concat(s),contextmenu:{items:function(t,n){var o={},r=$(e).jstree(!0),s=null;$.ajax({url:foldersUrl+"/contextButtons/"+t.id,method:"GET",dataType:"json",success:function(e){(s=e).create&&(o.Create={separator_before:!1,separator_after:!1,label:translations.folderTreeCreate,action:function(e){t=r.create_node(t),r.edit(t)}}),s.modify&&(o.Rename={separator_before:!1,separator_after:!1,label:translations.folderTreeEdit,action:function(e){r.edit(t)}}),s.delete&&(o.Remove={separator_before:!0,separator_after:!1,label:translations.folderTreeDelete,action:function(e){r.delete_node(t)}}),!1===a&&s.share&&(o.Share={separator_before:!0,separator_after:!1,label:translations.folderTreeShare,_class:"XiboFormRender",action:function(e){XiboFormRender(permissionsUrl.replace(":entity","form/Folder/")+t.id)}}),!1===a&&s.move&&(o.Move={separator_before:!0,separator_after:!1,label:translations.folderTreeMove,_class:"XiboFormRender",action:function(e){XiboFormRender(foldersUrl+"/form/"+t.id+"/move")}}),null!==i&&i instanceof Function&&(o=i(t,o))},complete:function(e){n(o)}})}},themes:{responsive:!0},types:{root:{icon:"fa fa-file text-warning"},home:{icon:"fa fa-home text-success"},default:{icon:"fa fa-folder text-warning"},open:{icon:"fa fa-folder-open text-warning"}},core:{check_callback:function(e,t,a,n,o){return"delete_node"!==e&&"rename_node"!==e||"#"!==t.id&&"1"!==t.id||(toastr.error(translations.folderTreeError),!1)},data:{url:foldersUrl}}}).bind("ready.jstree",(function(n,r){if(void 0!==localStorage.getItem("hideFolderTree")&&null!==localStorage.getItem("hideFolderTree")&&JSON.parse(localStorage.getItem("hideFolderTree"))!==$("#grid-folder-filter").is(":hidden")&&adjustDatatableSize(!1),$.each(r.instance._model.data,(function(a,n){if(void 0!==n.li_attr&&n.li_attr.disabled){var o=$(e).jstree().get_node(n.id);0===n.children.length?$(e).jstree().hide_node(o):$(e).jstree().disable_node(o)}if(void 0!==n.type&&"home"===n.type){l=n.id,null==localStorage.getItem(t+"_folder_tree")&&$(e).jstree(!0).select_node(l)}})),a){var i="#"+t+" #folderId";0===$(i).length&&(i="#formFolderId");var s=$(i).val();void 0!==s&&""!==s&&($(this).jstree("select_node",s),$("#originalFormFolder").length&&$("#originalFormFolder").text($(this).jstree().get_path($(this).jstree("get_selected",!0)[0]," > ")),$("#selectedFormFolder").length&&"#formFolderId"===i&&$("#selectedFormFolder").text($(this).jstree().get_path($(this).jstree("get_selected",!0)[0]," > ")))}o&&o instanceof Function&&o($(e).jstree(!0),$(e))})).bind("rename_node.jstree",(function(t,a){var n={},o=a.node.id;n.text=a.text,$.ajax({url:foldersUrl+"/"+o,method:"PUT",dataType:"json",data:n,success:function(t){"#container-folder-form-tree"===e&&$("#container-folder-tree").jstree(!0).refresh()}})})).bind("create_node.jstree",(function(t,a){var n=a.node;n.text=translations.folderNew;var o={};o.parentId=a.parent,o.text=a.node.text,$.ajax({url:foldersUrl,method:"POST",dataType:"json",data:o,success:function(t){$(e).jstree(!0).set_id(n,t.data.id),"#container-folder-form-tree"===e&&$("#container-folder-tree").jstree(!0).refresh()}})})).bind("delete_node.jstree",(function(t,a){var n={};n.parentId=a.parent,n.text=a.node.text;var o=a.node.id;$.ajax({url:foldersUrl+"/"+o,method:"DELETE",dataType:"json",data:n,success:function(t){t.success?(toastr.success(translations.done),"#container-folder-form-tree"===e&&$("#container-folder-tree").jstree(!0).refresh()):(toastr.error(translations.folderWithContent),console.log(t.message),$(e).jstree(!0).refresh())}})})).bind("changed.jstree",(function(n,o){var i=o.selected[0],s=a?"#"+t+" #folderId":"#folderId",l=$(e).jstree("get_selected",!0);a&&0===$(s).length&&(s="#formFolderId"),void 0!==i&&!1===a&&($("#breadcrumbs").text($(e).jstree().get_path(l[0]," > ")).hide(),$("#folder-tree-clear-selection-button").prop("checked",!1)),$(s).val()!=i&&!1===a&&(void 0!==i?$(s).val(i).trigger("change"):($("#breadcrumbs").text(""),$("#folder-tree-clear-selection-button").prop("checked",!0),$(".XiboFilter").find("#folderId").val(null).trigger("change"))),a&&void 0!==i&&($(s).val(i).trigger("change"),$("#selectedFormFolder").length&&$("#selectedFormFolder").text($(e).jstree().get_path(l[0]," > "))),r&&r instanceof Function&&r(o)})).bind("open_node.jstree",(function(e,t){"root"!==t.node.type&&"home"!==t.node.type&&t.instance.set_type(t.node,"open")})).bind("close_node.jstree",(function(e,t){"root"!==t.node.type&&"home"!==t.node.type&&t.instance.set_type(t.node,"default")})),$(".btnCloseInnerModal").on("click",(function(e){e.preventDefault(),$(a?"#folder-tree-form-modal":"#folder-tree-modal").modal("hide")})),$("#folder-tree-clear-selection-button").on("click",(function(){$("#folder-tree-clear-selection-button").is(":checked")?($(e).jstree("deselect_all"),$(".XiboFilter").find("#folderId").val(null).trigger("change")):$(e).jstree("select_node",l??1)})),$("#folder-tree-select-folder-button").off("click").on("click",adjustDatatableSize))}function adjustDatatableSize(e){function t(){"function"==typeof refreshDisplayMap&&refreshDisplayMap()}e=void 0===e||e,$("#grid-folder-filter").is(":hidden")&&($("#datatable-container").addClass("col-sm-10").removeClass("col-sm-12"),t()),$("#grid-folder-filter").toggle("fast",(function(){$(this).is(":hidden")?($("#folder-tree-clear-selection-button").is(":checked")||$("#breadcrumbs").show("slow"),$("#datatable-container").addClass("col-sm-12").removeClass("col-sm-10"),t()):$("#breadcrumbs").hide("slow"),e&&$(this).closest(".XiboGrid").find("table.dataTable").DataTable().ajax.reload(),localStorage.setItem("hideFolderTree",JSON.stringify($("#grid-folder-filter").is(":hidden")))}))}function disableFolders(){$("#folder-tree-select-folder-button").parent().remove(),$("#container-folder-tree").remove(),$("#grid-folder-filter").remove(),$("#datatable-container").addClass("col-sm-12").removeClass("col-sm-10")}function createMiniLayoutPreview(e){if(0==$(".page-content").find(".mini-layout-preview").length){var t=Handlebars.compile($("#mini-player-template").html());$(".page-content").append(t())}var a=$(".mini-layout-preview"),n=a.find("#content"),o=Handlebars.compile('<iframe scrolling="no" src="{{url}}" width="{{width}}px" height="{{height}}px" style="border:0;"></iframe>');n.html(""),a.find("#playBtn").show().off().on("click",(function(){$(this).hide(),a.find("#content").append(o({url:e,width:a.hasClass("large")?"760":"440",height:a.hasClass("large")?"420":"240"}))})),a.find("#closeBtn").off().on("click",(function(){a.find("#content").html(""),a.removeClass("show"),a.remove()})),a.find("#newTabBtn").off().on("click",(function(){window.open(e,"_blank")})),a.find("#sizeBtn").off().on("click",(function(){a.find("#content").html(""),a.toggleClass("large"),$(this).toggleClass("fa-arrow-circle-down",a.hasClass("large")),$(this).toggleClass("fa-arrow-circle-up",!a.hasClass("large")),a.find("#playBtn").show()})),a.addClass("show")}function formatBytes(e,t){if(0===e)return"0 Bytes";const a=0>t?0:t,n=Math.floor(Math.log(e)/Math.log(1024));return parseFloat((e/Math.pow(1024,n)).toFixed(a))+" "+["Bytes","KB","MB","GB","TB","PB","EB","ZB","YB"][n]}function createColorPicker(e,t){var a=$(e);a.attr("autocomplete","off"),a.colorpicker(Object.assign({format:"hex"},t))}function destroyColorPicker(e){$(e).colorpicker("destroy")}String.prototype.startsWith||(String.prototype.startsWith=function(e,t){return t=t||0,this.indexOf(e,t)===t}),String.prototype.endsWith||(String.prototype.endsWith=function(e){return-1!==this.indexOf(e,this.length-e.length)}),$.fn.dataTable.ext.errMode=function(e,t,a){console.log(a)},$(document).delegate('*[data-toggle="lightbox"]',"click",(function(e){e.preventDefault(),$(this).ekkoLightbox({onContentLoaded:function(){var e=$(".ekko-lightbox-container");e.css({"max-height":e.height(),height:"","max-width":e.width()}),e.parents(".modal-content").css({width:"fit-content"})}})})),$(document).ready((function(){buttonsTemplate=null,window.console||function(){var e,t=["log","debug","info","warn","error","assert","dir","dirxml","group","groupEnd","time","timeEnd","count","trace","profile","profileEnd"],a=t.length;for(window.console={},e=0;e<a;e++)window.console[t[e]]=function(){}}(),setInterval("XiboPing('"+clockUrl+"')",6e4),setInterval("XiboPing('"+pingUrl+"')",18e4),XiboInitialise("")}));