meraproject/content/admin/js/all.min.js

1 line
31 KiB
JavaScript
Raw Normal View History

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=