!function(){"use strict";jQuery(document).ready((function(e){e.chrysalio={shortDelay:12e3,state:Cookies.getJSON("CIO_STATE")||{},transition:"all .4s ease-in-out",i18n:{en:{no_file_api:"Your browser does not support new File API!\nPlease upgrade.",file_too_big:"File too big!",please_wait:"Please wait…"},fr:{no_file_api:"Votre  navigateur ne supporte pas l'API fichier !\nVeuillez le mettre à jour.",file_too_big:"Fichier trop volumineux !",please_wait:"Veuillez patienter…"}}},e.chrysalio.i18nMessage=function(i){var t=e("html").attr("lang");return e.chrysalio.i18n[t]&&e.chrysalio.i18n[t][i]?e.chrysalio.i18n[t][i]:e.chrysalio.i18n.en&&e.chrysalio.i18n.en[i]?e.chrysalio.i18n.en[i]:i},e.chrysalio.saveState=function(){Cookies.set("CIO_STATE",e.chrysalio.state,{sameSite:"strict"})},e("#cioFlash, #cioFlashAlert").hide().slideDown("slow").delay(e.chrysalio.shortDelay).slideUp("slow");var i=e("#cioFlashSnackbar, #cioFlashAlertSnackbar");i.length&&(i.click((function(){i.addClass("hide"),setTimeout((function(){i.hide()}),1500)})),setTimeout((function(){i.addClass("hide"),setTimeout((function(){i.hide()}),1500)}),e.chrysalio.shortDelay));var t=document.getElementById("cioDialog");if(t){t.addEventListener("keydown",(function(e){var i;switch(e.keyCode){case 13:"TEXTAREA"!=document.activeElement.tagName&&(i=t.getElementsByClassName("cioOk")).length&&(e.preventDefault(),i[0].click());break;case 27:(i=t.getElementsByClassName("cioCancel")).length&&(e.preventDefault(),i[0].click())}}));var a=t.getElementsByClassName("cioFormItem");a.length&&setTimeout((function(){a[0].getElementsByTagName("div")[0].firstChild.focus()}),200)}e(".cioAutoSubmit").on("change",(function(e){this.form.submit()})),e("#check_all").removeAttr("id").prepend(e('<label for="check_all" class="cioCustomCheckbox"> </label>')).prepend(e('<input id="check_all" name="check_all" type="checkbox" value="1" class="cioCustomCheckbox"/>')).find("#check_all").click((function(){e("input.cioSelect, .cioSelect input.cioCustomCheckbox").prop("checked",e(this).prop("checked"))})),e(".cioTabsetToc li a").click((function(){var i=e(this),t=i.parents(".cioTabset");return t.find("li").removeClass("cioCurrent"),i.parent().addClass("cioCurrent"),t.children(".cioTabContent").addClass("cioHidden"),t.children("#"+i.parent().attr("id")+"_").removeClass("cioHidden"),e.chrysalio.state[t.attr("id")]=i.parent().attr("id"),e.chrysalio.saveState(),!1})),e(".cioTabset").each((function(){var i=e(this).attr("id"),t=window.location.hash.replace("#","");t.substring(0,i.length)!=i&&(t=e.chrysalio.state[i]),t||(t=i+"0");var a=e("#"+t).children("a");a.length&&a.is(":visible")?a.click():e("#"+i+"0").children("a").click()})),e(".cioInputFile").click((function(){var i=e(this),t=i.prev("input[type='file']");return t.length?(t.on("change",(function(a){var n=e("<input type='submit' class='cioHidden' name='"+i.attr("name").replace("?","!")+"'"+(t.attr("multiple")?" multiple='multiple'":"")+"/>");n.click((function(){if(!window.File&&window.FileReader&&window.FileList&&window.Blob)return alert(e.chrysalio.i18nMessage("no_file_api")),window.location=window.location.pathname,!1;var a=parseInt(t.data("max-size")||"0");if(a){var n=0;if(e(t.get(0).files).each((function(e,i){n+=i.size})),n>a)return alert(e.chrysalio.i18nMessage("file_too_big")),window.location=window.location.pathname,!1}var o=i.parents("form"),s=i.parent().find(".cioProgress");return i.hide(),s.removeClass("cioHidden"),e.ajax({type:"POST",data:new FormData(o.get(0)),contentType:!1,cache:!1,processData:!1,mimeType:"multipart/form-data",xhr:function(){var i=e.ajaxSettings.xhr();return i.upload&&i.upload.addEventListener("progress",(function(i){var t=0,a=i.loaded||i.position,n=i.total;i.lengthComputable&&(t=Math.ceil(a/n*100)),s.children(".cioBar").css("width",t+"%"),s.children(".cioPercent").text(t<100?t+"%":e.chrysalio.i18nMessage("please_wait"))}),!0),i}}).done((function(){window.location=window.location.pathname})),!1})),t.after(n),n.click()})).click(),!1):null})),e(".cioPanel").each((function(){var i=e(this),t=e("body"),a=Math.round(i.outerWidth()/t.width()*100)+"%";i.hasClass("cioWasOpen")||(t.removeClass("cioHasOpenPanel"),i.css("margin-left","-"+a),setTimeout((function(){t.children().css("transition",e.chrysalio.transition),t.addClass("cioHasOpenPanel"),i.css({transition:e.chrysalio.transition,"margin-left":"0"})}),100)),i.find(".cioClose a").click((function(){return e.getJSON("/panel/close/"+i.data("uid")),t.children().css("transition",e.chrysalio.transition),t.removeClass("cioHasOpenPanel"),i.css({transition:e.chrysalio.transition,"-webkit-transform":"translateX(-100%)",transform:"translateX(-100%)"}),setTimeout((function(){i.remove()}),600),!1}))}))}))}();
