meraproject/content/admin/js/all.min.js
keboss-m 5c21d25d45 Initial commit: Merakomis portal, Docker stack and user-reader API.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-24 11:04:05 +03:00

1 line
31 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

var A,API,H;A={dropper:!1,init:function(){return A.dropper=!(void 0===window.FileReader),A.FORM.init(),A.P.init(),$.fn.DASHBOARD(),$.fn.WIDGET(),$(window).on("scroll",A.scroll)},scroll:function(){return A.P.scroll()},array_keys:function(t){var e,n;for(e in n=[],t)n.push(e);return n},FORM:{globalPrepareValidate:function(t,e){return $(".error_text",t.$wrap).remove(),t.$wrap.removeClass("error good")},globalGood:function(t,e){return t.$wrap.addClass("good")},globalBad:function(t,e){return t.$wrap.addClass("error"),t.$wrap.append($('<div class="error_text">'+e.errors.join("<br/>")+"</div>"))},init:function(){return $.fn.FORM("setGlobalGood",A.FORM.globalGood),$.fn.FORM("setGlobalBad",A.FORM.globalBad),$.fn.FORM("setPrepareValidate",A.FORM.globalPrepareValidate),$.fn.FORM("setGlobalOptions",{inputActionWithParent:!0})}},reload:function(){return window.location.reload()},display:function(t,e){return e?$(t).show():$(t).hide()},notify:function(t,e=""){return t.queue(function(){return t.html(e).show(300),t.dequeue()})},setCookie:function(t,e,n){var i,r;return" domain=*."+window.location.host+";",r=" domain=."+A.domen+";",i=t+"="+e+"; expires="+new Date(n||(new Date).getTime()+5184e6).toGMTString()+"; path=/;",document.cookie=i+r,A.getCookie("k")!==e&&(document.cookie=i),i},getCookie:function(t){return!!new RegExp("(?:; )?"+t+"=([^;]*);?").test(document.cookie)&&decodeURIComponent(RegExp.$1)},createRequestObject:function(){if("undefined"==typeof XMLHttpRequest){try{return new ActiveXObject("Msxml2.XMLHTTP.6.0")}catch(t){}try{return new ActiveXObject("Msxml2.XMLHTTP.3.0")}catch(t){}try{return new ActiveXObject("Msxml2.XMLHTTP")}catch(t){}try{return new ActiveXObject("Microsoft.XMLHTTP")}catch(t){}throw new Error("This browser does not support XMLHttpRequest.")}return new XMLHttpRequest}},$(document).ready(function(){return A.init()}),API=function(t,e={},n=null,i={}){var r;return e.nocache=(new Date).getTime(),r="/api/"+t+"/",console.log(r,e),$.ajax({url:r,type:"POST",dataType:void 0!==e.dataType?e.dataType:"html",data:e,success:function(t){if(null!==n)return"function"==typeof n?n(t,i):void 0},error:function(){return"function"==typeof n?n({error:1},i):void 0}})},A.DROPPER={id:0,getNextId:function(){return A.DROPPER.id++},create:function(t,e,n){var i;return i=new Array,A.dropper&&$(t).each(function(){var t;return t=function(t){var i,r;return i=!(null==(null!=n?n.multi:void 0)||!n.multi),(r={}).logo=$(t),r.ulogo=$(".over",r.logo),r.hlogo=$(".drop_help",r.logo),r.plogo=$(".drop_preview",r.logo),r.file=$("input[type=file]",r.logo),0===r.file.length&&(r.file=$('<div class="dib"><input '+(i?"multiple":"")+' type="file" value="Выбрать изображение" name="imgs" accept="image/jpeg,image/png,image/gif"/></div>'),r.hlogo.prepend(r.file)),r.file=$("input[type=file]",r.logo),r.file.attr("id","file_dropper_id_"+A.DROPPER.getNextId()).change(function(){var t;return t=document.getElementById(r.file.attr("id")),r.sendFiles(t.files)}),r.logo.bind("dragenter",function(){return r.logo.addClass("dopper_hover"),!1}),r.sendFiles=function(t){var a,o,s,d,l,c,u;for(o in r.loaded=0,r.links=new Array,r.count=t.length,r.plogo.children().remove(),t)if(void 0!==(a=t[o])&&void 0!==a.type&&((null!=a&&null!=(s=a.type)?s.match(/image.*/):void 0)||(null!=a&&null!=(d=a.type)?d.match(/audio.*/):void 0)||(null!=a&&null!=(l=a.type)?l.match(/text.*/):void 0)||(null!=a&&null!=(c=a.type)?c.match(/application.*/):void 0)||(null!=a&&null!=(u=a.type)?u.match(/video.*/):void 0))&&function(t){var i;return i={},r.plogo.show(),i.$div=$('<div class="block_perc"/>').text(o.name).appendTo(r.plogo),i.$prog=$("<div/>").addClass("progress").appendTo(i.$div),i.$bar=$("<div/>").addClass("bar").appendTo(i.$prog),i.$btxt=$("<div/>").addClass("bartxt").text("0%").appendTo(i.$prog),i.flogo=o,i.reader=new FileReader,i.reader.onloadend=function(a){var o,s,d;for(s in(d=A.createRequestObject()).upload.addEventListener("progress",function(t){var e;if(t.lengthComputable)return e=100*t.loaded/t.total,i.$bar.css({width:e+"%"}),i.$btxt.text(e.toFixed(0)+"%")},!1),d.onreadystatechange=function(){if(4===this.readyState&&200===this.status){if(null==(null!=n?n.multi:void 0)||!n.multi)return r.logo.css("background-image",'url("'+this.responseText+'")').addClass("have"),null!=(null!=n?n.callback:void 0)&&n.callback(this.responseText,n.cd),r.plogo.hide();if(r.loaded++,"error"!==this.responseText&&r.links.push(this.responseText),null!=(null!=n?n.callback:void 0)&&n.callback(this.responseText,n.cd),r.loaded===r.count)return null!=(null!=n?n.callbackAll:void 0)&&n.callbackAll(r.links,n.cd),r.plogo.hide(),r.hlogo.show()}},d.open("POST",e),"xxxxxxxxx",d.setRequestHeader("Content-Type","multipart/form-data; boundary=xxxxxxxxx"),d.setRequestHeader("Cache-Control","no-cache"),o="--xxxxxxxxx\r\n",o+="Content-Disposition: form-data; name='myFile'; filename='"+t.name+"'\r\n",o+="Content-Type: "+t.type+"\r\n\r\n",o+=i.reader.result+"\r\n",o+="--xxxxxxxxx\r\n",n)o+='Content-Disposition: form-data; name="'+s+'"\r\n\r\n',o+=n[s]+"\r\n",o+="--xxxxxxxxx\r\n";return d.sendAsBinary?d.sendAsBinary(o):d.send(o)},i.reader.readAsDataURL(t)}(a),!i)break;return!1},r.ulogo.bind({dragover:function(){return!1},dragleave:function(){return r.logo.removeClass("dopper_hover"),!1},drop:function(t){return r.logo.removeClass("dopper_hover"),r.files=t.originalEvent.dataTransfer.files,r.sendFiles(r.files),!1}}),r},i.push(t(this))}),i}},H={menu:{},selected:{},top_selected:null,inited:!1,dir:"",title:null,data:null,ready:function(){if(!H.inited)return $(window).on("popstate",H.switchByWindow),H.inited=!0,H.body=$("#content"),H.title=$("title")},reload:function(){return H.switch({animate:!1})},formGo:function(t){var e,n,i;return i=(e=$(t)).serialize(),void 0===(n=e.attr("action"))&&(n=window.location.pathname),H.go(n+"?"+i),!1},go:function(t,e=null,n="",i=!0){var r;if("/"===t.substr(0,1)&&(t=t.substr(1)),r="/"+t,H.data=e,history.pushState(e,n,r),i)return H.switch()},setTitle:function(t){return H.title.text(t)},switchByWindow:function(t){return H.switch(t.state)},switch:function(t={animate:!0}){var e;return e="/"===(e=H.parse().join("/"))||""===e?"/?justContent=1":`/${e}/?justContent=1`,window.location.search.length>0&&(e+="&"+window.location.search.substr(1)),$.ajax({url:e,dataType:"JSON",success:function(t){var e,n,i,r,a,o,s,d;if("string"==typeof t.location&&""!==t.location)return H.go(t.location);if(H.title.text(t.title),e=$(t.content),n=$(e[0]),$("#title").text(t.data.title),H.setTitle(t.data.title),H.body.html(n),A.P.initMini(n),e.length>1){for(s=[],i=r=1,a=e.length-1;1<=a?r<=a:r>=a;i=1<=a?++r:--r)d=document.createElement("script"),"SCRIPT"===(o=e[i].tagName)||"script"===o?(d.innerHTML=$(e[i]).html(),s.push(H.body[0].appendChild(d))):s.push(void 0);return s}},error:function(){return console.log("history error ")}})},SEARCH:{set:function(t,e=!1){var n;return n=window.location.pathname+"?"+t,H.go(n,null,"",e)},parse:function(){var t,e,n,i,r;if(n={},window.location.search.length>0)for(t in r=window.location.search.substr(1).split("&"))(e=(i=r[t]).indexOf("="))>=0?n[i.substr(0,e)]=i.substr(e+1):n[i]=null;return n},setValue:function(t,e,n=!1){var i,r;return(r=H.SEARCH.parse())[t]=e,i=H.SEARCH.toString(r),H.SEARCH.set(i)},toString:function(t){var e,n,i;for(e in n=[],t)i=t[e],n.push(e+"="+(null!=i?i:""));return n.join("&")},get:function(t){try{return decodeURI(H.SEARCH.parse()[t])}catch(e){return e,H.SEARCH.parse()[t]}}},parse:function(){var t,e,n,i,r;for(r=[],n=0,i=(t=window.location.pathname.split("/")).length;n<i;n++)""!==(e=t[n])&&r.push(e);return r}},$(window).ready(H.ready),A.P={scrollTimeout:null,getScrollTop:function(){return Math.max(A.P.body.scrollTop(),A.P.$body.scrollTop(),A.P.$html.scrollTop())},init:function(){return A.P.body=$("body"),A.P.$body=$("body"),A.P.$html=$("html"),A.P.initMini()},scroll:function(){},aScroll:function(){return A.P.$html.removeClass("scroll")},initMini:function(t=A.P.body){return A.P.initPreventLink(t),$("._module_table",t).TABLE(),A.P.initForm(t),$("._ps",t).perfectScrollbar(),$("[data-input=image]",t).IMAGE("init_upload"),$("[data-input=video]",t).VIDEO("init_upload"),$("[data-input=date] input",t).datetimepicker({yearOffset:0,lang:"ru",timepicker:!1,format:"Y-m-d",formatDate:"Y-m-d"}),$("[data-input=datetime] input",t).datetimepicker({yearOffset:0,lang:"ru",timepicker:!0,format:"Y-m-d H:i",formatDate:"Y-m-d H:i"}),$("form",t).FORM(),$("._toggle_tinymce",t).click(function(){var t,e,n,i;return t=(e=$(this)).closest("[data-input]"),n=$("textarea",t),e.is(":checked")?(i="tiny_"+(new Date).getTime(),n.attr("id",i),t.attr("data-input","tinymce"),t.attr("data-input-tinymce",i),A.P.initTiny("#"+i,{onChange:function(){return console.log("change"),n.val(tinymce.get(n.attr("id")).getContent())}})):(t.attr("data-input","textarea"),tinymce.get(n.attr("id")).remove()),e.closest(".ps-container").perfectScrollbar("update")})},initForm:function(t){return $("form [type=submit]",t).click(function(){var t;return(t=$(this)).closest("form").data("submit_clicked",t)})},initTiny:function(t,e={}){return tinymce.init({selector:t,plugins:"image",height:350,images_upload_url:"/api/common.image/uploadAccountTinyMCE/",images_reuse_filename:!0,images_upload_base_path:window.location.origin,language:"ru",valid_elements:"*[*]",relative_urls:!1,remove_script_host:!0,document_base_url:window.location.origin,setup:function(t){return t.on("BeforeSetContent",function(t){}),t.on("change",function(t){return"function"==typeof e.onChange?e.onChange():void 0})}})},initPreventLink:function(t){return $("a:not(.prevented)",$(t)).addClass("prevented").click(A.P.preventALink)},preventALink:function(t){var e,n;if(n=(e=$(this)).attr("href"),e.hasClass("propagation"))return t.preventDefault(),t.stopPropagation();if(""===n||"#"===n)return t.preventDefault();if(void 0!==n){if(e.hasClass("_to_card"))return t.preventDefault(),t.stopPropagation(),$.fn.CARD("openNew",{api:e.attr("data-module"),id:e.attr("data-id")});if("/"===n.substr(0,1))return t.preventDefault(),t.stopPropagation(),H.go($(this).attr("href"))}}},function(t){var e;t.fn.SECTION=function(n){return e[n]?e[n].apply(this,Array.prototype.slice.call(arguments,1)):"object"!=typeof n&&n?t.error("Метод с именем "+n+" не существует для jQuery.SECTION"):e.init.apply(this,arguments)},e={init:function(){},initChangingTheme:function(n){var i;return(i=t('[data-name="msPortalSection_theme"]:not(.inited)').addClass("inited").data("send_data",n)).closest("._form").FORM(),i.on("input:change",e.changeTheme).trigger("input:change")},changeTheme:function(){var e,n;return n=t(this),e=Input.init(t(this)),API("core.site.theme/getForm",{id:e.value(),data:n.data("send_data")},function(e){var i;return i=t(e),A.P.initMini(i),t(".loaded_form",n.closest("._form")).html(i),n=null})}}}(jQuery),function(t){var e;t.fn.DASHBOARD=function(n){return e[n]?e[n].apply(this,Array.prototype.slice.call(arguments,1)):"object"!=typeof n&&n?t.error("Метод с именем "+n+" не существует для jQuery.DASHBOARD"):e.init.apply(this,arguments)},e={now:0,count:0,init:function(){return e.container=t("#dashboards"),e.list_wrap=t("#dash_elements"),e.list=t(".dash_li",e.list_wrap),e.setDashboard(e.list[0].getAttribute("data-id")),e.addListeners(),t(".add_dashboard").click(e.openAddDashboard)},addListeners:function(){return t(".edit_dashboard",e.list_wrap).click(e.openEditDashboard),t(".delete_dashboard",e.list_wrap).click(e.deleteDashboard)},deleteDashboard:function(t){var n;return t.stopPropagation(),n=t.target.getAttribute("data-id"),API("ms.dashboard/deleteByIds",{ids:[n]},function(){return e.reloadList()})},openEditDashboard:function(t){var n;return t.stopPropagation(),n=t.target.getAttribute("data-id"),e.openAddDashboard(t,n)},openAddDashboard:function(e,n=0){return t.fn.WINDOW("init",{options:{x:"center",y:"center",api:"ms.dashboard/renderWindowForm"},data:{id:n}})},setDashboard:function(n){return e.now=n,e.list.removeClass("selected"),t(`[data-id=${n}]`,e.list_wrap).addClass("selected"),API("ms.dashboard/render",{id:n},function(n){var i;return i=t(n),e.container.html(i),e.initDashboard(),A.P.initMini(i),i.on("scroll",A.P.scroll)})},reloadList:function(){return API("ms.dashboard/getMyList",{},function(n){return t("#dash_elements").html(n),e.addListeners()})},initIcons:function(n=e.container){return t(".icon_td",n).click(e.iconClick)},initDashboard:function(){return t(".test_table_wrap",e.container).perfectScrollbar(),e.initIcons(),t(".grid_dash").sortable({distance:5,handle:".drag_handle",stop:function(t,e,n){var i,r;return r=n.parent().attr("data-id"),i=[],n.children().each(function(){return i.push(this.getAttribute("data-id"))}),API("ms.dashboard/updateWidgetsPos",{id:r,pos:i})}}),t(".dash_cell[data-type=2]").perfectScrollbar(),t(".dash_cell .widget_delete").click(function(e){return e.stopPropagation(),t.fn.WIDGET("deleteWidget",t(this).closest(".dash_cell").attr("data-id"))})},iconClick:function(e){var n,i,r,a,o,s,d;return i=null!=(a=(n=t(this)).attr("data-api"))?a:"ms.widget/window",r=null!=(o=n.attr("data-id"))?o:0,d=null!=(s=n.attr("data-type"))?s:0,t.fn.WINDOW("init",{options:{x:"center",y:"center",width:1e3,height:650,api:i},data:{id:r,type:d}})},addWidget:function(t,n){return t.id=n,API("ms.dashboard/addWidget",t,e.reloadDashboard)},reloadDashboard:function(){var n;return n=t(".dashboard").attr("data-id"),e.setDashboard(n)}}}(jQuery),function(t){var e;t.fn.ENTITY=function(n){return e[n]?e[n].apply(this,Array.prototype.slice.call(arguments,1)):"object"!=typeof n&&n?t.error("Метод с именем "+n+" не существует для jQuery.ENTITY"):e.init.apply(this,arguments)},e={init:function(){},updateUI:function(e){switch(e){case"ms.dashboard":t.fn.DASHBOARD("reloadList")}return t('._module_table[data-controller="'+e+'"]').each(function(){return t.fn.TABLE("reloadData",t(this).attr("id"))})},copy:function(t,n,i){return null!=i&&"function"==typeof i.stopPropagation&&i.stopPropagation(),null!=i&&"function"==typeof i.preventDefault&&i.preventDefault(),API(t+"/copy",{id:n,dataType:"JSON"},function(n){return console.log(n),e.openForm(t,n.id)})},uadd:function(n){var i,r,a,o,s;return a=(i=t(event.target)).FORM(),s=a.json(),r=t(".res",a.container).hide(300),o=i.data("submit_clicked"),a.validate({success:function(){var t;return console.log("formValues",s),t=s.controller,s.dataType="JSON",API(t+"/uadd",{values:s,dataType:"JSON"},function(i){return console.log(i),A.notify(r,i.m),e.updateUI(t),"function"==typeof n&&n(i),console.log(o),null!=o&&(o.hasClass("_save_and_window_close")&&o.closest(".window").remove(),o.hasClass("_save")&&1===parseInt(s._is_new)&&(o.closest(".window").remove(),e.openForm(t,i.id))),o=null,r=null})}}),!1},openForm:function(e,n,i){var r;return r=e+(0===n?"/renderWindowForm":"/renderWindowEdit"),t.fn.WINDOW("init",{options:{x:"center",y:"center",api:r,width:1e3,height:600},data:{id:n,init_data:i}})}}}(jQuery),function(t){var e;t.fn.IMAGE=function(n){return e[n]?e[n].apply(this,Array.prototype.slice.call(arguments,1)):"object"!=typeof n&&n?t.error("Метод с именем "+n+" не существует для jQuery.IMAGE"):e.init.apply(this,arguments)},e={init:function(){},init_upload:function(){return t(this).each(function(){var n;if(!(n=t(this)).data("image_drop_inited"))return n.data("image_drop_inited",!0),A.DROPPER.create(n,"/api/common.image/upload/",{callback:e.aUpload,cd:{$t:n}})})},aUpload:function(e,n){var i,r;if(e=JSON.parse(e),r=n.$t,i=Input.init(r),1!==e.e)return i.value(e.id),t("img",r).attr("src",e.link)}}}(jQuery),function(t){var e;t.fn.PROFILE=function(n){return e[n]?e[n].apply(this,Array.prototype.slice.call(arguments,1)):"object"!=typeof n&&n?t.error("Метод с именем "+n+" не существует для jQuery.PROFILE"):e.init.apply(this,arguments)},e={auth:function(){var e,n,i;return n=t(event.target).FORM(),i=n.json(),e=t(".res",n.container).hide(300),n.validate({success:function(){return i.dataType="JSON",API("core.user.account/login",i,function(t){return 1===t.e?A.notify(e,t.m):A.reload()})}}),!1},reg:function(){var e,n,i;return n=t(event.target).FORM(),i=n.json(),e=t(".res",n.container).hide(300),n.validate({success:function(){return i.dataType="JSON",API("core.user.account/reg",i,function(t){return 1===t.e?A.notify(e,t.m):(A.setCookie("id",t.id),A.setCookie("h",t.h),A.reload())})}}),!1},exit:function(){return API("core.user.account/exit",{},function(){return A.reload()})}}}(jQuery),function(t){var e;t.fn.TABLE=function(n){return e[n]?e[n].apply(this,Array.prototype.slice.call(arguments,1)):"object"!=typeof n&&n?t.error("Метод с именем "+n+" не существует для jQuery.TABLE"):e.init.apply(this,arguments)},e={init:function(){return t(this).each(function(){var n,i,r,a;return(i=t(this)).hasClass("need_scroll")&&i.perfectScrollbar(),a=i.attr("id"),r=i.closest(".table_wrap"),n=t("._actions",r),i.data("_wrap",r),i.data("_actions",n),e.initThead(a),e.initTbody(a),e.resetColumnWidths(a),e.initPagination(a),e.initActions(a)})},setPage:function(t,n){return e.setData(t,{page:n})},setCount:function(t,n){return e.setData(t,{7:n,page:0})},setData:function(t,n={}){return API("ms.table/setData",{name:t,data:n,draw_data:e.getDrawData(t),dataType:"JSON"},function(n,i){return e.reloadedData(t,n,i)})},getFilterData:function(e){var n,i;return n={},i=[],t(`#${e} .filter input`).each(function(){var e,r;if(""!==(r=t.trim(t(this).val())))return e=t(this).attr("name"),n[e]=r,i.push([7,e," LIKE ","%"+r+"%"])}),{data:n,filter:i}},getDrawData:function(n){var i,r;i={};try{i=JSON.parse(t(`#${n}`).attr("data-data"))}catch(t){t,i={}}return r=e.getFilterData(n),i.__filter_data=r.data,i.__filter=r.filter,i},reloadData:function(t){return API("ms.table/getData",{name:t,draw_data:e.getDrawData(t),dataType:"JSON"},function(n,i){return e.reloadedData(t,n,i)})},reloadedData:function(n,i,r){var a;return a=t(i.tbody),t(`#${n} .cell.td`).remove(),t(`#${n} .table`).append(a),t('._module_table_pagination[data-id="'+n+'"]').replaceWith(t(i.pagination)),e.initPagination(n),e.initTbody(n),t("._ps").perfectScrollbar("update")},initPagination:function(n){return t('._module_table_pagination[data-id="'+n+'"] a').click(function(){var i;return i=t(this).attr("data-page"),e.setPage(n,i)})},initActions:function(n){var i,r;return i=(r=t(`#${n}`)).data("_actions"),console.log("initActions",r,i,n),t("._delete",i).click(function(){return e.deleteChecked(n)})},deleteChecked:function(n){var i,r;if(confirm("Вы уверены что хотите удалить эти элементы?")&&(r=e.getCheckedIds(n)).length>0)return i=t(`#${n}`).attr("data-controller"),API(i+"/deleteByIds",{ids:r},function(t){return e.reloadData(n)})},resetColumnWidths:function(e){var n,i,r;return n=t(`#${e} .sticky[data-sticky=2]`),i="",r=0,n.each(function(e){var a,o;return o=(a=t(this)).attr("data-width"),a.index()===n.length?(i+="1fr ",r+=50):("auto"===o?i+=0===e&&1===n.length?"1fr ":"min-content ":(o=parseFloat(o),isNaN(o)&&(o=a.outerWidth()),i+=o+"px "),r+=a.outerWidth())}),t(`#${e} .table`).css({"grid-template-columns":i,width:r})},initThead:function(n){var i,r,a,o,s;return o=t(`#${n}`),i=t(".sticky[data-sticky=1]",o),r=t(".sticky[data-sticky=2]",o),a=t(".sticky[data-sticky=3]",o),t(i[0]).outerHeight(),t(r[0]).outerHeight(),t(".filter",o),t("input",o).change(function(){return e.reloadData(n)}),t("input",o).keyup(function(){var i,r;return null!=(r=(i=t(this)).data("_filter_interval"))&&clearTimeout(r),r=setTimeout(function(){return e.reloadData(n)},500),i.data("_filter_interval",r)}),t("select",o).change(function(){return e.reloadData(n)}),0,s=t(r[0]).outerHeight(),r.css({top:0}),a.css({top:s+0}),t("._set_count:not(.inited)",o).addClass("inited").change(function(){return e.setCount(n,t(this).val())}),t(".resizable_th:not(.inited)",o).addClass("inited").resizable({directions:["right"],start:function(t,e){return e.addClass("show_resize_bar").css({zIndex:100})},stop:function(t,i){var r,a;return i.removeClass("show_resize_bar").css({zIndex:1}).attr("data-width",a=i.outerWidth()),e.resetColumnWidths(n),i.width("auto"),r=i.attr("data-column"),API("ms.table/setColumnWidth",{name:n,col:r,width:a})}}),t("._add:not(.inited)",o).addClass("inited").click(function(i){var r,a;t(i.target),a={};try{void 0!==(r=JSON.parse(o.attr("data-data")).form_init_data)&&(a=r)}catch(t){i=t,console.log(i)}return e.openWindowForm(n,0,a)}),t("._check_all",o).click(function(){return t("._check_tr",o).prop("checked",t(this).is(":checked")),e.checkActions(n)})},getTrID:function(n){var i,r,a,o,s;return s=(i=n.closest("._module_table")).attr("id"),a=t(".td:eq(0)",i).index(),r=e.getColumns(s),o=Math.floor((n.index()-a)/r),t(`.td:eq(${o*r})`,i).attr("data-id")},openWindowForm:function(e="",n=0,i={}){var r;return r=t(`#${e}`).attr("data-controller"),t.fn.ENTITY("openForm",r,n,i)},getColumns:function(e){return t(`#${e} .table`).css("grid-template-columns").split(" ").length},initTbody:function(n){var i,r,a,o;if(i=t(`#${n}`),t("._check_tr",i).click(function(){return e.checkActions(n)}),1===parseInt(i.attr("data-sortable")))return r=t("[data-sticky=2]",i).length,o=0,a=0,t(".td[data-id]",i).draggable({clone:!0,start:function(e,n){return n.hide(),n.data("data-id",t(this).attr("data-id"))},move:function(e,n){var s,d,l,c,u,p,h;if(s=t(e.target),a=n.attr("data-oid"),s.hasClass("td")&&(p=s.attr("data-oid"))!==a)return h=e.offsetY/s.outerHeight(),d=t(`.td[data-oid=${a}]`,i),l=t(`.td[data-oid=${p}]`,i),h<.5?d.insertBefore(l.first()):d.insertAfter(l.last()),c=t("[data-id]:eq(0)",i).index(),u=t(d[0]).index(),o=(u-c)/r},stop:function(t,e,n){return e.remove(),API(i.attr("data-controller")+"/updatePosForID",{id:a,pos:o},function(t){return console.log(t)})}})},getCheckedIds:function(e){var n;return n=[],t(`#${e} ._check_tr:checked`).each(function(){return n.push(t(this).val())}),n},checkActions:function(n){var i,r;return r=e.getCheckedIds(n),i=t(`#${n}`).data("_actions"),r.length>0?i.show():i.hide()},clickTable:function(n){var i,r,a,o,s;if(i=r=t(n.target),a=!0,"INPUT"!==(o=n.target.tagName)&&"A"!==o||(a=!1),a&&(i.hasClass("td")||(i=r.closest(".td")).length>0))return n.stopPropagation(),s=e.getTrID(i),e.openWindowForm(r.closest("._module_table").attr("id"),s)}},t(document).on("click",e.clickTable)}(jQuery),function(t){var e;t.fn.VIDEO=function(n){return e[n]?e[n].apply(this,Array.prototype.slice.call(arguments,1)):"object"!=typeof n&&n?t.error("Метод с именем "+n+" не существует для jQuery.IMAGE"):e.init.apply(this,arguments)},e={init:function(){},init_upload:function(){var n;if(!(n=t(this)).data("video_drop_inited"))return n.data("video_drop_inited",!0),A.DROPPER.create(n,"/api/common.video/upload/",{callback:e.aUpload,cd:{$t:n}})},aUpload:function(e,n){var i,r;if(e=JSON.parse(e),r=n.$t,i=Input.init(r),1!==e.e)return i.value(e.id),t("video",r).attr("src",e.link)}}}(jQuery),function(t){var e;t.fn.WIDGET=function(n){return e[n]?e[n].apply(this,Array.prototype.slice.call(arguments,1)):"object"!=typeof n&&n?t.error("Метод с именем "+n+" не существует для jQuery.WIDGET"):e.init.apply(this,arguments)},e={init:function(){return t("#start").click(e.openStart)},addWidgetToDashboardByEvent:function(t,n,i){var r,a;return a=n.attr("data-type"),n.remove(),r=i.closest(".dashboard").attr("data-id"),e.addWidgetToDashboard(a,r)},addWidgetToDashboard:function(e,n){var i;return i={type:e},t.fn.DASHBOARD("addWidget",i,n)},deleteWidget:function(e){return t(`.dash_cell[data-id=${e}]`).remove(),API("ms.widget/deleteByIds",{ids:[e]},function(t){return console.log(t)})},startLoaded:function(n){return t(".drag_widget",n).draggable({clone:!0,distance:5,cloneConnect:".grid_dash",stop:e.addWidgetToDashboardByEvent}),t.fn.DASHBOARD("initIcons",n)},openStart:function(){return t.fn.WINDOW("init",{options:{x:"center",y:"center",width:960,height:720,api:"ms.widget/start",onLoad:e.startLoaded}})}}}(jQuery),function(t){var e,n,i;t.fn.WINDOW=function(e){return n[e]?n[e].apply(this,Array.prototype.slice.call(arguments,1)):"object"!=typeof e&&e?t.error("Метод с именем "+e+" не существует для jQuery.WINDOW"):n.init.apply(this,arguments)},e=t(window),i=function(){class n{constructor(n={}){var i,r,a,o,s,d,l,c,u,p,h;this.options=null!=(r=n.options)?r:{},this.init_x=null!=(a=this.options.x)?a:0,this.init_y=null!=(o=this.options.y)?o:0,this.init_width=null!=(s=this.options.width)?s:640,this.init_height=null!=(d=this.options.height)?d:480,this.api=null!=(l=this.options.api)?l:"",this.onLoad=null!=(c=this.options.onLoad)?c:null,this.data=null!=(u=n.data)?u:{},i=t('<div class="window"> <div class="window_inner"> <div class="window_header"> <div class="window_title_wrap"> <div class="window_title"></div> </div> <div class="window_tools"> <div class="window_tool window_reload"></div> <div class="window_tool window_minimize"></div> <div class="window_tool window_fullscreen"></div> <div class="window_tool window_close"></div> </div> </div> <div class="window_content_wrap"> <div class="window_content"> </div> </div> </div> </div>'),this.$container=i,this.$container.data("window",this),this.$container.mousedown(this.setActive.bind(this)),i.draggable({handle:".window_title_wrap"}),i.resizable({stop:function(t,e){var i;return(n=null!=(i=e.data("data"))?i:{}).width=e.width(),n.height=e.height(),API("ms.widget/saveWidthHeight",n)}}),t("body").append(i),p=this.init_x,h=this.init_y,"center"===p&&(p=parseInt((e.width()-800)/2)),"center"===h&&(h=parseInt((e.height()-400)/2)),p<0&&(p=0),h<0&&(h=0),i.css({transform:"translate("+p+"px,"+h+"px)",zIndex:t(".window").length,width:800,height:400}),i.on("destroyed",this.destroy.bind(this)),t(".window_close",i).on("click",this.close.bind(this)),t(".window_reload",i).on("click",this.reload.bind(this)),t(".window_fullscreen",i).on("click",this.toggleFullscreen.bind(this)),this.$content_wrap=t(".window_content_wrap",i),this.$content_wrap.perfectScrollbar(),this.$content=t(".window_content",i),this.$title=t(".window_title",i),this.firstLoad=!0,this.reload()}toggleFullscreen(){return this.$container.hasClass("fullscreen")?this.fullscreenReset():this.fullscreen()}fullscreenReset(){return this.$container.removeClass("fullscreen"),this.$container.resizable("enable"),this.$content_wrap.perfectScrollbar("update")}fullscreen(){return this.$container.addClass("fullscreen"),this.$content_wrap.perfectScrollbar("update"),this.$container.resizable("disable")}minimize(){}setTitle(t){return this.$title.html(t)}setActive(){var e,n,i,r,a;return i={},e=this.$container,n=t(".window"),r=fastdom.measure(function(){return n.each(function(){if(this!==e[0])return i[this.style.zIndex]=this})}),a=fastdom.mutate(function(){var t,r;for(r in(t=A.array_keys(i)).sort(),t)i[t[r]].style.zIndex=parseInt(r)+1;return e[0].style.zIndex=n.length}).then(function(){return fastdom.clear(r),fastdom.clear(a)})}startLoad(){return this.$container.addClass("loading"),this.$content.html("Загрузка")}finishLoad(n,i){var r,a,o,s,d,l,c;if(this.$container.addClass("loaded"),d=this.$container,setTimeout(function(){return d.removeClass("loading loaded"),d=null},500),r=t(n),this.$content.html(r),A.P.initMini(r),"function"==typeof this.onLoad&&this.onLoad(r),s=t(".edit_panel",r).length>0,this.$container.toggleClass("window_leftmenu",s),s&&t(".tab_link",r).click(function(){var e;return e=t(this),t(".tab_link",r).removeClass("selected"),t(".edit_tabs .tab",r).hide(),e.is(":last-child")?(t(".edit_tabs .tab",r).show(),e.removeClass("show")):(e.addClass("selected"),t(".edit_tabs .tab:eq("+e.index()+")",r).show(),console.log(t(".edit_tabs .tab:last-child",r)),t(".tab_link:last-child",r).addClass("show")),t("._ps",r).perfectScrollbar("update")}),null!=(a=r.attr("data-data"))&&""!==a)try{(n=JSON.parse(a)).no_scroll&&(this.$content_wrap.perfectScrollbar("disable"),this.$container.addClass("window_no_scroll")),n.table&&this.$container.addClass("window_table"),n.data&&this.$container.data("data",n.data),o={},null!=n.width&&(o.width=Math.min(n.width,.9*e.width())),null!=n.height&&(o.height=Math.min(n.height,.9*e.height())),l=this.$container.offset().left,c=this.$container.offset().top,this.firstLoad&&("center"===this.init_x&&null!=o.width&&(l=parseInt((e.width()-o.width)/2)),"center"===this.init_y&&null!=o.height&&(c=parseInt((e.height()-o.height)/2))),o.transform="translate("+l+"px,"+c+"px)",this.$container.css(o),null!=n.title&&this.setTitle(n.title)}catch(t){}return this.firstLoad=!1}reload(){return this.startLoad(),API(this.api,this.data,this.finishLoad.bind(this)),!1}close(){return t("[data-input=tinymce]",this.$container).each(function(){var e;if(e=tinymce.get(t(this).attr("data-input-tinymce")),console.log("want remove a",e),null!=e)return e.remove()}),this.$container.remove()}destroy(){return this.$content_wrap=null,this.$container=null,this.$content=null}}return n.zIndex=0,n}.call(this),n={init:function(t){return new i(t)}}}(jQuery),function(t){var e;t.fn.ITEM=function(n){return e[n]?e[n].apply(this,Array.prototype.slice.call(arguments,1)):"object"!=typeof n&&n?t.error("Метод с именем "+n+" не существует для jQuery.ITEM"):e.init.apply(this,arguments)},e={init:function(){},initChangingProperty:function(n){var i,r;return r=(i=t('[data-name="shopItemValue_property"]:not(.inited)').addClass("inited")).closest("._form").FORM(),i.data("item_id",t('[data-name="shopItemValue_item"]',r.container).val()),i.on("input:change",e.changeProperty).trigger("input:change")},changeProperty:function(){var e,n;return n=t(this),e=Input.init(t(this)),API("shop.item.value/getValues",{id:e.value(),item_id:n.data("item_id")},function(e){var i;return i=t(e),A.P.initMini(i),t(".loaded_values",n.closest("._form")).html(i),n=null})},saveCategories:function(e){var n,i,r;if(r=[],n=t(`[data-item-categories=${e}]`),t("input:checked",n).each(function(){return r.push(t(this).val())}),(i=n.closest(".window")).length>0)return i.data("window").close(),API("shop.category.item/setCategories",{id:e,arr:r},function(e){return console.log(e),t.fn.ENTITY("updateUI","shop.category.item")})}}}(jQuery),function(t){var e;t.fn.SHOP=function(n){return e[n]?e[n].apply(this,Array.prototype.slice.call(arguments,1)):"object"!=typeof n&&n?t.error("Метод с именем "+n+" не существует для jQuery.SHOP"):e.init.apply(this,arguments)},e={init:function(){},saveCategories:function(e){var n,i,r;if(console.log("saveCategories",e),r=[],n=t(`[data-shop-categories=${e}]`),t("input:checked",n).each(function(){return r.push(t(this).val())}),console.log("want ",r),(i=n.closest(".window")).length>0)return i.data("window").close(),API("shop.shop.category/setCategories",{id:e,arr:r},function(){return t.fn.ENTITY("updateUI","shop.shop.category")})},initCategories:function(){return t(".shop_categories:not(.inited)").addClass("inited").each(function(){return t("input:checked").each(function(){var e;return e=t(this).closest("li"),t("> ul ",e).hide()}),t("input[type=checkbox]").click(e.checkShopCategories)})},checkShopCategories:function(){var e,n,i;return n=t(this),e=t(this).closest("li"),i=n.is(":checked"),t("> ul ",e).toggle(!i),t("> ul ul",e).show(i),t("> ul input[type=checkbox]",e).prop("checked",!1)}}}(jQuery),function(t){var e;t.fn.PROJECT=function(n){return console.log("PROJECT method",n),e[n]?e[n].apply(this,Array.prototype.slice.call(arguments,1)):"object"!=typeof n&&n?t.error("Метод с именем "+n+" не существует для jQuery.PROJECT"):e.init.apply(this,arguments)},e={init:function(){},changePipeline:function(t,e){return console.log("changePipeline",t,e),API("pm.pipeline.stage/getListByPipeline",{pipeline:e,dataType:"JSON"},function(e){var n,i;for(n in i="",e)i+='<option value="'+n+'">'+e[n]+"</option>";return t.$input.html(i)})}}}(jQuery);