/*! UEditorPlus v2.0.0*/ function ue_callback(a,b){function c(a,b,c,d){var e,f=0,g=0,h=a.width||c,i=a.height||d;(h>b||i>b)&&(h>=i?(f=h-b)&&(e=(f/h).toFixed(2),a.height=i-i*e,a.width=b):(g=i-b)&&(e=(g/i).toFixed(2),a.width=h-h*e,a.height=b))}var d=document,e=$G("J_picBoard"),f=d.createElement("img");removeMaskLayer(),"SUCCESS"==b?(e.innerHTML="",f.onload=function(){c(this,300),e.appendChild(f);var a=new scrawl;a.btn2Highlight("J_removeImg"),a.btn2Highlight("J_sacleBoard")},f.src=a):alert(b)}function removeMaskLayer(){var a=$G("J_maskLayer");a.className="maskLayerNull",a.innerHTML="",dialog.buttons[0].setDisabled(!1)}function addMaskLayer(a){var b=$G("J_maskLayer");dialog.buttons[0].setDisabled(!0),b.className="maskLayer",b.innerHTML=a}function exec(scrawlObj){if(scrawlObj.isScrawl){addMaskLayer(lang.scrawlUpLoading);var base64=scrawlObj.getCanvasData();if(base64){var options={timeout:1e5,headers:editor.options.serverHeaders||{},onsuccess:function(xhr){if(!scrawlObj.isCancelScrawl){var responseObj;if(responseObj=eval("("+xhr.responseText+")"),"SUCCESS"===responseObj.state){var imgObj={},url=editor.options.scrawlUrlPrefix+responseObj.url;imgObj.src=url,imgObj._src=url,imgObj.alt=responseObj.original||"",editor.execCommand("insertImage",imgObj),dialog.close(),editor.fireEvent("uploadsuccess",{res:responseObj,type:"scrawl"})}else alert(responseObj.state)}},onerror:function(){alert(lang.imageError),dialog.close()}};options[editor.getOpt("scrawlFieldName")]=base64;var actionUrl=editor.getActionUrl(editor.getOpt("scrawlActionName")),params=utils.serializeParam(editor.queryCommandValue("serverparam"))||"",url=utils.formatUrl(actionUrl+(actionUrl.indexOf("?")==-1?"?":"&")+params);ajax.request(url,options)}}else addMaskLayer(lang.noScarwl+"   ")}var scrawl=function(a){a&&this.initOptions(a)};!function(){var a=$G("J_brushBoard"),b=a.getContext("2d"),c=[],d=0;scrawl.prototype={isScrawl:!1,brushWidth:-1,brushColor:"",initOptions:function(a){var b=this;b.originalState(a),b._buildToolbarColor(a.colorList),b._addBoardListener(a.saveNum),b._addOPerateListener(a.saveNum),b._addColorBarListener(),b._addBrushBarListener(),b._addEraserBarListener(),b._addAddImgListener(),b._addRemoveImgListenter(),b._addScalePicListenter(),b._addClearSelectionListenter(),b._originalColorSelect(a.drawBrushColor),b._originalBrushSelect(a.drawBrushSize),b._clearSelection()},originalState:function(a){var c=this;c.brushWidth=a.drawBrushSize,c.brushColor=a.drawBrushColor,b.lineWidth=c.brushWidth,b.strokeStyle=c.brushColor,b.fillStyle="transparent",b.lineCap="round",b.fill()},_buildToolbarColor:function(a){var b=null,c=[];c.push("");for(var d,e=0;d=a[e++];)(e-1)%5==0&&(1!=e&&c.push(""),c.push("")),b="#"+d,c.push("");c.push("
"),$G("J_colorBar").innerHTML=c.join("")},_addBoardListener:function(e){var f,g=this,h=0,i=-1,j=-1,k=!1,l=!1,m=!1,n=0,o="";h=parseInt(domUtils.getComputedStyle($G("J_wrap"),"margin-left")),c.push(b.getImageData(0,0,b.canvas.width,b.canvas.height)),d+=1,domUtils.on(a,["mousedown","mousemove","mouseup","mouseout"],function(a){switch(f=browser.webkit?a.which:n,a.type){case"mousedown":n=1,o=1,k=!0,m=!1,l=!1,g.isScrawl=!0,i=a.clientX-h,j=a.clientY-h,b.beginPath();break;case"mousemove":if(!o&&0==f)return;if(!o&&f&&(i=a.clientX-h,j=a.clientY-h,b.beginPath(),o=1),m||!k)return;var c=a.clientX-h,d=a.clientY-h;b.moveTo(i,j),b.lineTo(c,d),b.stroke(),i=c,j=d,l=!0;break;case"mouseup":if(n=0,!k)return;l||(b.arc(i,j,b.lineWidth,0,2*Math.PI,!1),b.fillStyle=b.strokeStyle,b.fill()),b.closePath(),g._saveOPerate(e),k=!1,l=!1,m=!0,i=-1,j=-1;break;case"mouseout":if(o="",n=0,1==f)return;b.closePath()}})},_addOPerateListener:function(a){var e=this;domUtils.on($G("J_previousStep"),"click",function(){d>1&&(d-=1,b.clearRect(0,0,b.canvas.width,b.canvas.height),b.putImageData(c[d-1],0,0),e.btn2Highlight("J_nextStep"),1==d&&e.btn2disable("J_previousStep"))}),domUtils.on($G("J_nextStep"),"click",function(){d>0&&d");return c.innerHTML=b.join(""),c}var c=[[1,1,-1,-1],[0,1,0,-1],[0,1,1,-1],[1,0,-1,0],[0,0,1,0],[1,0,-1,1],[0,0,0,1],[0,0,1,1]];ScaleBoy.prototype={init:function(){a();var c=this,d=c.dom=b();return c.scaleMousemove.fp=c,domUtils.on(d,"mousedown",function(a){var b=a.target||a.srcElement;c.start={x:a.clientX,y:a.clientY},b.className.indexOf("hand")!=-1&&(c.dir=b.className.replace("hand","")),domUtils.on(document.body,"mousemove",c.scaleMousemove),a.stopPropagation?a.stopPropagation():a.cancelBubble=!0}),domUtils.on(document.body,"mouseup",function(a){c.start&&(domUtils.un(document.body,"mousemove",c.scaleMousemove),c.moved&&c.updateScaledElement({position:{x:d.style.left,y:d.style.top},size:{w:d.style.width,h:d.style.height}}),delete c.start,delete c.moved,delete c.dir)}),d},startScale:function(a){var b=this,c=b.dom;c.style.cssText="visibility:visible;top:"+a.style.top+";left:"+a.style.left+";width:"+a.offsetWidth+"px;height:"+a.offsetHeight+"px;",b.scalingElement=a},updateScaledElement:function(a){var b=this.scalingElement,c=a.position,d=a.size;c&&("undefined"!=typeof c.x&&(b.style.left=c.x),"undefined"!=typeof c.y&&(b.style.top=c.y)),d&&(d.w&&(b.style.width=d.w),d.h&&(b.style.height=d.h))},updateStyleByDir:function(a,b){var d,e=this,f=e.dom;c.def=[1,1,0,0],0!=c[a][0]&&(d=parseInt(f.style.left)+b.x,f.style.left=e._validScaledProp("left",d)+"px"),0!=c[a][1]&&(d=parseInt(f.style.top)+b.y,f.style.top=e._validScaledProp("top",d)+"px"),0!=c[a][2]&&(d=f.clientWidth+c[a][2]*b.x,f.style.width=e._validScaledProp("width",d)+"px"),0!=c[a][3]&&(d=f.clientHeight+c[a][3]*b.y,f.style.height=e._validScaledProp("height",d)+"px"),"def"===a&&e.updateScaledElement({position:{x:f.style.left,y:f.style.top}})},scaleMousemove:function(a){var b=arguments.callee.fp,c=b.start,d=b.dir||"def",e={x:a.clientX-c.x,y:a.clientY-c.y};b.updateStyleByDir(d,e),arguments.callee.fp.start={x:a.clientX,y:a.clientY},arguments.callee.fp.moved=1},_validScaledProp:function(a,b){var c=this.dom,d=$G("J_picBoard");switch(b=isNaN(b)?0:b,a){case"left":return b<0?0:b+c.clientWidth>d.clientWidth?d.clientWidth-c.clientWidth:b;case"top":return b<0?0:b+c.clientHeight>d.clientHeight?d.clientHeight-c.clientHeight:b;case"width":return b<=0?1:b+c.offsetLeft>d.clientWidth?d.clientWidth-c.offsetLeft:b;case"height":return b<=0?1:b+c.offsetTop>d.clientHeight?d.clientHeight-c.offsetTop:b}}}}();