define("player/assert/js/toolbarmgr",[],function(require,exports){function a(){function a(a){null!=j&&(j.strokeStyle=a,j.fillStyle=a,m=a)}function d(a,c){j&&(j.lineWidth=c,j.lineJoin="round",j.lineCap="round",a===b.Pen?l=c:a===b.Eraser&&(n=c))}function e(c){$("#penSelectorDiv").hide(),$("#eraserSelectorDiv").hide(),c===b.Mouse&&(p=b.Mouse,f(),$("#cursorHackDiv").hide(),i.unbind(),i.css("pointer-events","none"),k.css("pointer-events","none")),c===b.Pen&&(p=b.Pen,f(),g(),j.globalCompositeOperation="source-over",d(b.Pen,l),a(m),i.css("cursor","url(player/assert/images/penCursor.cur),auto"),$("#cursorHackDiv").hide(),$("#penSelectorDiv").show(),i.css("pointer-events","auto"),k.css("pointer-events","auto")),c===b.Eraser&&(p=b.Eraser,f(),g(),j.globalCompositeOperation="destination-out",d("eraser",n),i.css("cursor","url(player/assert/images/bc_54f.cur),auto"),$("#cursorHackDiv").show(),$("#eraserSelectorDiv").show(),i.css("pointer-events","auto"),k.css("pointer-events","auto"))}function f(){i?(k.show(),k.append(i),$("#mainContainer").append(k),i.show()):(i=$("<canvas>").attr("class","pen_canvas").css({position:"absolute",left:"0px",top:"0px",zIndex:3}),k.append(i),$("#mainContainer").append(k),i.attr("width",k.width()),i.attr("height",k.height()),j=i[0].getContext("2d"))}function g(){i.unbind();var c={x:0,y:0},e={x:0,y:0};o=!1,i.mousedown(function(f){$("#penSelectorDiv").hide(),$("#eraserSelectorDiv").hide();var g=f.offsetX,h=f.offsetY;j.beginPath(),p===b.Pen?(c.x=g+4.5,c.y=h+4.5,e.x=g+4.5+.01,e.y=h+4.5+.01,d("pen",l),a(m),j.moveTo(c.x,c.y),j.lineTo(e.x,e.y),j.stroke()):p===b.Eraser&&(c.x=g,c.y=h,j.clearRect(c.x,c.y,n,n),j.globalCompositeOperation="destination-out",d(b.Eraser,n)),o=!0}),i.mousemove(function(a){o&&(p===b.Pen?(e.x=a.offsetX+4.5,e.y=a.offsetY+4.5,j.lineTo(e.x,e.y),j.stroke()):p===b.Eraser&&(e.x=a.offsetX,e.y=a.offsetY,j.clearRect(e.x,e.y,n,n)))}),i.mouseup(function(){o=!1}),i.mouseout(function(){p===b.Pen&&(o=!1)})}function h(){$("#btnMouse").click(function(){e(b.Mouse)}),$("#btnPen").click(function(){"red"===m&&$("#btnRedPen").find("span").css({border:"2px solid #ffe294",marginLeft:"-1px",marginTop:"-1px"})," white"===m&&$("#btnBluePen").find("span").css({border:"2px solid #ffe294",marginLeft:"-1px",marginTop:"-1px"}),"black"===m&&$("#btnBlackPen").find("span").css({border:"2px solid #ffe294",marginLeft:"-1px",marginTop:"-1px"}),e(b.Pen)}),$("#penSelector").children().click(function(){e(b.Pen),a($(this).attr("pcolor")),$("#penSelector").children().find("span").css({border:"1px solid #eae8e8"}),$(this).find("span").css({border:"2px solid #ffe294",marginLeft:"-1px",marginTop:"-1px"})}),$("#btnEraser").click(function(){e(b.Eraser)}),$("#eraserSelector").find("img").click(function(a){"point"===$(this).attr("etype")&&e(b.Eraser),"clear"===$(this).attr("etype")&&(_self.clearCanvas(),q?(e(b.Pen),$("#penSelectorDiv").hide()):e(b.Mouse)),a.preventDefault()})}var i,j,_self=this,k=$("<div/>").attr("class","paint_container").css({position:"absolute",left:"0px",top:"0px",width:"100%",height:"100%"}),l=4,m="red",n=c.Big,o=!1,p=b.Mouse,q=!1;this.getStrokeCanvas=function(){return i},this.getStrokeCanvasDataUrl=function(){return i[0].toDataURL()},this.loadStrokeCanvasFromDataUrl=function(a,b){if(_self.clearCanvas(),j.globalCompositeOperation="source-over",a){var c=new Image;c.src=a,c.onload=function(){j.drawImage(c,0,0)}}b?(_self.changeToPenMode(),q=!0):q=!1},this.changeToMouseMode=function(){e(b.Mouse)},this.changeToPenMode=function(){e(b.Pen),$("#penSelectorDiv").hide()},this.getCanvasContainer=function(){return k},this.init=function(){h(),e(b.Mouse)},this.disposePaintCanvas=function(){k.find(".pen_canvas").remove(),i=null},this.clearCanvas=function(){j&&j.clearRect(0,0,i.width(),i.height())}}var b={Mouse:"mouse",Pen:"pen",Eraser:"eraser"},c={Big:54};exports.PaintCanvas=new a});