dojo.provide("parus.themeEditor");dojo.require("parus.parus8");if(!parus){parus={}}if(!parus.parus8){dojo.mixin(parus,{parus8:{}})}dojo.mixin(parus.parus8,{_nativeCSS:"",_themeCSSNode:null,_imageNames:null,_inspecting:false,_inspectingTimeout:null,toColor:function(b){var a=Number(b).toString(16);while(a.length<6){a="0"+a}return"#"+a},toColorIndex:function(_3){return eval(_3.split("rgb").join("(function(r,g,b){return r*256*256+g*256+b;})"))},themeEditor:function(){this._themeEditorMode=true;dojo.cookie("bc","",{expires:-1});parus.parus8._nativeCSS=dojo.cache("parus","theme/custom/theme.css");parus.parus8._themeCSSNode=dojo.place('<style type="text/css"></style>',document.head,"last");parus.parus8._imageNames=eval(dojo.cache("parus","theme/images.js"));parus.parus8._colorNames=eval(dojo.cache("parus","theme/colors.js"));parus.parus8._indexedCSS=parus.parus8._nativeCSS;dojo.forEach(parus.parus8._colorNames,function(_4,_5){parus.parus8._indexedCSS=parus.parus8._indexedCSS.split("custom-"+_4.name+"-custom").join(parus.parus8.toColor(_5))});parus.parus8.themeChanged()},blinkColor:function(c){var b=[{name:"custom-custom-custom",value:"custom"}];dojo.xhrGet({url:document.location.protocol+"//editor/theme.less",handleAs:"text",sync:true,load:function(e){dojo.forEach(e.split(";"),function(g,f){if(f>=1){g=g.split(":");if(g.length>1){b.push({name:"custom-"+dojo.trim(g[0]||"").split("@").join("")+"-custom",value:dojo.trim(g[1]||"")})}}})}});var d=parus.parus8._nativeCSS;dojo.forEach(parus.parus8._imageNames,function(f,e){d=d.split("../images/"+f.name).join(document.location.protocol+"//editor/img?idx="+e);d=d.split("images/"+f.name).join(document.location.protocol+"//editor/img?idx="+e)});var a=["white","black","green","red","blue","fuchsia","white","black","green","red","blue","fuchsia","white","black","green","red","blue","fuchsia"];setTimeout(function(){var e=d;if(a.length){dojo.forEach(b,function(f){e=e.split(f.name).join((f.name=="custom-"+c+"-custom")?a.shift():f.value)});setTimeout(arguments.callee,150)}else{dojo.forEach(b,function(f){e=e.split(f.name).join(f.value)})}parus.parus8._themeCSSNode.innerHTML=e},150)},themeChanged:function(){var a=[{name:"custom-custom-custom",value:"custom"}];dojo.xhrGet({url:document.location.protocol+"//editor/theme.less",handleAs:"text",sync:true,load:function(d){dojo.forEach(d.split(";"),function(e,f){if(f>=1){e=e.split(":");if(e.length>1){a.push({name:"custom-"+dojo.trim(e[0]||"").split("@").join("")+"-custom",value:dojo.trim(e[1]||"")})}}})}});var c=parus.parus8._nativeCSS;dojo.forEach(a,function(d){c=c.split(d.name).join(d.value)});var b=(+(new Date));dojo.forEach(parus.parus8._imageNames,function(e,d){c=c.split("../images/"+e.name).join(document.location.protocol+"//editor/img?idx="+d+"&preventCache="+b);c=c.split("images/"+e.name).join(document.location.protocol+"//editor/img?idx="+d+"&preventCache="+b)});parus.parus8._themeCSSNode.innerHTML=c},selectElementColors:function(q){var o=parus.parus8._themeCSSNode.innerHTML;parus.parus8._themeCSSNode.innerHTML=parus.parus8._indexedCSS;var m=[];while(q){var h=document.styleSheets;for(var p=0;p<h.length;p++){if(!h[p].href){var f=h[p].rules;for(var n=0;n<f.length;n++){var d=f[n];var c=document.querySelectorAll(d.selectorText.split("custom-custom-custom").join("custom"));for(var g=0;g<c.length;g++){if(c[g]==q){var b=d.cssText.match(/rgb\([0-9, ]*\)/g);if(b){for(var e=0;e<b.length;e++){var a=parus.parus8.toColorIndex(b[e]);if(dojo.indexOf(m,a)<0){m.push(a)}}}}}}}}q=q.parentNode}parus.parus8._themeCSSNode.innerHTML=o;if(m.length){dojo.xhrGet({url:document.location.protocol+"//editor/selectColor?idx="+m.join(","),handleAs:"text",sync:true,loaded:function(){}})}else{alert("Не удалось получить цвета элемента.")}},_inspectEvents:["click","auxclick","contextmenu","dblclick","mousedown","onfocus","onfocusin","dragstart","pointerdown","pointerup","selectstart","mouseup"],inspectElementClick:function(b){if(parus.parus8._inspecting){var a=b.target;b.stopPropagation();b.stopImmediatePropagation();b.preventDefault();b.cancelBubble=true;b.bubbles=false;b.returnValue=true;b.target=null;if(!parus.parus8._inspectingTimeout){parus.parus8._inspectingTimeout=setTimeout(dojo.hitch(function(){parus.parus8._inspectingTimeout=null;setTimeout(parus.parus8.unInspectElement,500);parus.parus8.selectElementColors(a)}),100)}}return false},inspectElement:function(){parus.parus8.unInspectElement();dojo.forEach(parus.parus8._inspectEvents,function(a){window.addEventListener(a,parus.parus8.inspectElementClick,true)});parus.parus8._inspecting=true},unInspectElement:function(){parus.parus8._inspecting=false;dojo.forEach(parus.parus8._inspectEvents,function(a){window.removeEventListener(a,parus.parus8.inspectElementClick,true)});if(parus.parus8._inspectingTimeout){clearTimeout(parus.parus8._inspectingTimeout);parus.parus8._inspectingTimeout=null}}});