diff --git a/dist/entry.js b/dist/entry.js index 63b8007fa2..b09440ad10 100644 --- a/dist/entry.js +++ b/dist/entry.js @@ -6756,6 +6756,14 @@ Entry.Utils.addFilters = function(a, b) { b.elem("feOffset", {result:"offOut", in:"SourceGraphic", dx:0, dy:0}); b.elem("feColorMatrix", {result:"matrixOut", in:"offOut", type:"matrix", values:"1.3 0 0 0 0 0 1.3 0 0 0 0 0 1.3 0 0 0 0 0 1 0"}); }; +Entry.Utils.addBlockPattern = function(a, b) { + a = a.elem("pattern", {id:"blockHoverPattern_" + b, class:"blockHoverPattern", patternUnits:"userSpaceOnUse", patternTransform:"translate(12, 0)", x:0, y:0, width:125, height:33, style:"display: none"}); + b = a.elem("g"); + for (var c = b.elem("rect", {x:0, y:0, width:125, height:33}), d = Entry.mediaFilePath + "block_pattern_(order).png", e = 1;5 > e;e++) { + b.elem("image", {class:"pattern" + e, href:d.replace("(order)", e), x:0, y:0, width:125, height:33}); + } + return {pattern:a, rect:c}; +}; Entry.Utils.COLLISION = {NONE:0, UP:1, RIGHT:2, LEFT:3, DOWN:4}; Entry.Utils.createMouseEvent = function(a, b) { var c = document.createEvent("MouseEvent"); @@ -12235,31 +12243,31 @@ Entry.BlockDriver = function() { } console.log((new Date).getTime() - b.getTime()); }; - a._convertBlock = function(a) { - function c(a) { - var b = {type:a.getAttribute("type"), index:{}}; - a = $(a).children(); - if (!a) { - return b; + a._convertBlock = function(b) { + function a(b) { + var d = {type:b.getAttribute("type"), index:{}}; + b = $(b).children(); + if (!b) { + return d; } - for (var d = 0;d < a.length;d++) { - var e = a[d], f = e.tagName, g = $(e).children()[0], h = e.getAttribute("name"); - "value" === f ? "block" == g.nodeName && (b.params || (b.params = []), b.params.push(c(g)), b.index[h] = b.params.length - 1) : "field" === f && (b.params || (b.params = []), b.params.push(e.textContent), b.index[h] = b.params.length - 1); + for (var e = 0;e < b.length;e++) { + var f = b[e], g = f.tagName, h = $(f).children()[0], u = f.getAttribute("name"); + "value" === g ? "block" == h.nodeName && (d.params || (d.params = []), d.params.push(a(h)), d.index[u] = d.params.length - 1) : "field" === g && (d.params || (d.params = []), d.params.push(f.textContent), d.index[u] = d.params.length - 1); } - return b; + return d; } - var d = Blockly.Blocks[a], e = EntryStatic.blockInfo[a], f, g; + var d = Blockly.Blocks[b], e = EntryStatic.blockInfo[b], f, g; if (e && (f = e.class, g = e.isNotFor, e = e.xml)) { - var e = $.parseXML(e), h = c(e.childNodes[0]) + var e = $.parseXML(e), h = a(e.childNodes[0]) } - d = (new Entry.BlockMockup(d, h, a)).toJSON(); + d = (new Entry.BlockMockup(d, h, b)).toJSON(); d.class = f; d.isNotFor = g; _.isEmpty(d.paramsKeyMap) && delete d.paramsKeyMap; _.isEmpty(d.statementsKeyMap) && delete d.statementsKeyMap; - d.func = Entry.block[a]; - -1 < "NUMBER TRUE FALSE TEXT FUNCTION_PARAM_BOOLEAN FUNCTION_PARAM_STRING TRUE_UN".split(" ").indexOf(a.toUpperCase()) && (d.isPrimitive = !0); - Entry.block[a] = d; + d.func = Entry.block[b]; + -1 < "NUMBER TRUE FALSE TEXT FUNCTION_PARAM_BOOLEAN FUNCTION_PARAM_STRING TRUE_UN".split(" ").indexOf(b.toUpperCase()) && (d.isPrimitive = !0); + Entry.block[b] = d; }; })(Entry.BlockDriver.prototype); Entry.BlockMockup = function(a, b, c) { @@ -12278,25 +12286,25 @@ Entry.BlockMockup = function(a, b, c) { this.def = this.definition; }; (function(a) { - a.simulate = function(a) { - a.sensorList && (this.sensorList = a.sensorList); - a.portList && (this.portList = a.portList); - a.init.call(this); - a.whenAdd && (this.events.blockViewAdd || (this.events.blockViewAdd = []), this.events.blockViewAdd.push(a.whenAdd)); - a.whenRemove && (this.events.blockViewDestroy || (this.events.blockViewDestroy = []), this.events.blockViewDestroy.push(a.whenRemove)); + a.simulate = function(b) { + b.sensorList && (this.sensorList = b.sensorList); + b.portList && (this.portList = b.portList); + b.init.call(this); + b.whenAdd && (this.events.blockViewAdd || (this.events.blockViewAdd = []), this.events.blockViewAdd.push(b.whenAdd)); + b.whenRemove && (this.events.blockViewDestroy || (this.events.blockViewDestroy = []), this.events.blockViewDestroy.push(b.whenRemove)); }; a.toJSON = function() { - function a(c) { - if (c && (c = c.params)) { - for (var d = 0;d < c.length;d++) { - var e = c[d]; - e && (delete e.index, a(e)); + function b(a) { + if (a && (a = a.params)) { + for (var c = 0;c < a.length;c++) { + var d = a[c]; + d && (delete d.index, b(d)); } } } - var c = ""; - this.output ? c = "Boolean" === this.output ? "basic_boolean_field" : "basic_string_field" : !this.isPrev && this.isNext ? c = "basic_event" : 1 == this.statements.length ? c = "basic_loop" : 2 == this.statements.length ? c = "basic_double_loop" : this.isPrev && this.isNext ? c = "basic" : this.isPrev && !this.isNext && (c = "basic_without_next"); - a(this.def); + var a = ""; + this.output ? a = "Boolean" === this.output ? "basic_boolean_field" : "basic_string_field" : !this.isPrev && this.isNext ? a = "basic_event" : 1 == this.statements.length ? a = "basic_loop" : 2 == this.statements.length ? a = "basic_double_loop" : this.isPrev && this.isNext ? a = "basic" : this.isPrev && !this.isNext && (a = "basic_without_next"); + b(this.def); var d = /dummy_/mi, e; for (e in this.paramsKeyMap) { d.test(e) && delete this.paramsKeyMap[e]; @@ -12304,7 +12312,7 @@ Entry.BlockMockup = function(a, b, c) { for (e in this.statementsKeyMap) { d.test(e) && delete this.statementsKeyMap[e]; } - return {color:this.color, skeleton:c, statements:this.statements, template:this.templates.filter(function(a) { + return {color:this.color, skeleton:a, statements:this.statements, template:this.templates.filter(function(a) { return "string" === typeof a; }).join(" "), params:this.params, events:this.events, def:this.def, paramsKeyMap:this.paramsKeyMap, statementsKeyMap:this.statementsKeyMap}; }; @@ -16971,6 +16979,9 @@ Entry.BlockMenu = function(a, b, c, d) { this.setWidth(); this.svg = Entry.SVG(this._svgId); Entry.Utils.addFilters(this.svg, this.suffix); + b = Entry.Utils.addBlockPattern(this.svg, this.suffix); + this.patternRect = b.rect; + this.pattern = b.pattern; this.svgGroup = this.svg.elem("g"); this.svgThreadGroup = this.svgGroup.elem("g"); this.svgThreadGroup.board = this; @@ -17231,6 +17242,13 @@ Entry.BlockMenu = function(a, b, c, d) { var c = a.keyCode, d = Entry.type; a.ctrlKey && "workspace" == d && 48 < c && 58 > c && (a.preventDefault(), this.selectMenu(c - 49)); }; + a.setPatternRectFill = function(a) { + this.patternRect.attr({fill:a}); + this.pattern.attr({style:""}); + }; + a.disablePattern = function() { + this.pattern.attr({style:"display: none"}); + }; a._clearCategory = function() { this._selectedCategoryView = null; this._categories = []; @@ -17458,6 +17476,11 @@ Entry.BlockView.DRAG_RADIUS = 5; this.pathGroup = this.svgGroup.elem("g"); this._updateMagnet(); this._path = this.pathGroup.elem("path"); + this.getBoard().patternRect && ($(this._path).mouseenter(function(a) { + d._mouseEnable && d._changeFill(!0); + }), $(this._path).mouseleave(function(a) { + d._mouseEnable && d._changeFill(!1); + })); var f = this._schema.color; this.block.deletable === Entry.Block.DELETABLE_FALSE_LIGHTEN && (f = Entry.Utils.colorLighten(f)); this._fillColor = f; @@ -17601,12 +17624,14 @@ Entry.BlockView.DRAG_RADIUS = 5; $(document).unbind(".block"); m.terminateDrag(a); e && e.set({dragBlock:null}); + m._changeFill(!1); Entry.GlobalSvg.remove(); delete this.mouseDownCoordinate; delete m.dragInstance; } b.stopPropagation && b.stopPropagation(); b.preventDefault && b.preventDefault(); + this._changeFill(!1); var e = this.getBoard(); Entry.documentMousedown && Entry.documentMousedown.notify(b); if (!this.readOnly && !e.viewOnly) { @@ -17862,6 +17887,14 @@ Entry.BlockView.DRAG_RADIUS = 5; a.pop().destroy(); } }; + a._changeFill = function(a) { + var c = this.getBoard(); + if (c.patternRect && !c.dragBlock) { + var d = this._fillColor, e = this._path, c = this.getBoard(); + a ? (c.setPatternRectFill(d), d = "url(#blockHoverPattern_" + this.getBoard().suffix + ")") : c.disablePattern(); + e.attr({fill:d}); + } + }; a.addActivated = function() { this.svgGroup.addClass("activated"); }; @@ -18301,6 +18334,9 @@ Entry.Board.OPTION_CLEAR = 2; this.svgBlockGroup.board = this; a.isOverlay ? (this.wrapper.addClass("entryOverlayBoard"), this.generateButtons(), this.suffix = "overlayBoard") : this.suffix = "board"; Entry.Utils.addFilters(this.svg, this.suffix); + a = Entry.Utils.addBlockPattern(this.svg, this.suffix); + this.patternRect = a.rect; + this.pattern = a.pattern; }; a.changeCode = function(a) { this.code && this.codeListener && this.code.changeEvent.detach(this.codeListener); @@ -18668,6 +18704,13 @@ Entry.Board.OPTION_CLEAR = 2; a.dominate = function(a) { a && (a = a.getFirstBlock()) && (this.svgBlockGroup.appendChild(a.view.svgGroup), this.code.dominate(a.thread)); }; + a.setPatternRectFill = function(a) { + this.patternRect.attr({fill:a}); + this.pattern.attr({style:""}); + }; + a.disablePattern = function() { + this.pattern.attr({style:"display: none"}); + }; a._removeActivated = function() { this._activatedBlockView && (this._activatedBlockView.removeActivated(), this._activatedBlockView = null); }; diff --git a/dist/entry.min.js b/dist/entry.min.js index 4ae83dad8f..e85a6295ae 100644 --- a/dist/entry.min.js +++ b/dist/entry.min.js @@ -705,8 +705,9 @@ Entry.getMaxFloatPoint=function(a){for(var b=0,c=0,d=a.length;ce;e++)b.elem("image",{class:"pattern"+e,href:d.replace("(order)",e),x:0,y:0,width:125,height:33});return{pattern:a,rect:c}}; +Entry.Utils.COLLISION={NONE:0,UP:1,RIGHT:2,LEFT:3,DOWN:4};Entry.Utils.createMouseEvent=function(a,b){var c=document.createEvent("MouseEvent");c.initMouseEvent(a,!0,!0,window,0,0,0,b.clientX,b.clientY,!1,!1,!1,!1,0,null);return c};Entry.Utils.xmlToJsonData=function(a){a=$.parseXML(a);var b=[];a=a.childNodes[0].childNodes;for(var c in a){var d=a[c];if(d.tagName){var e={category:d.getAttribute("id"),blocks:[]},d=d.childNodes;for(c in d){var f=d[c];f.tagName&&(f=f.getAttribute("type"))&&e.blocks.push(f)}b.push(e)}}return b}; Entry.Utils.stopProjectWithToast=function(a,b){b=b||"\ub7f0\ud0c0\uc784 \uc5d0\ub7ec \ubc1c\uc0dd";Entry.toast&&Entry.toast.alert(Lang.Msgs.warn,Lang.Workspace.check_runtime_error,!0);Entry.engine&&Entry.engine.toggleStop();"workspace"===Entry.type&&(Entry.container.selectObject(a.getCode().object.id,!0),a.view.getBoard().activateBlock(a));throw Error(b);}; window.requestAnimFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||function(a){window.setTimeout(a,1E3/60)}}();Entry.Model=function(a,b){var c=Entry.Model;c.generateSchema(a);c.generateSetter(a);c.generateObserve(a);(void 0===b||b)&&Object.seal(a);return a}; (function(a){a.generateSchema=function(b){var a=b.schema;if(void 0!==a){a=JSON.parse(JSON.stringify(a));b.data={};for(var d in a)(function(d){b.data[d]=a[d];Object.defineProperty(b,d,{get:function(){return b.data[d]}})})(d);b._toJSON=this._toJSON}};a.generateSetter=function(b){b.set=this.set};a.set=function(b,a){var d={},e;for(e in this.data)void 0!==b[e]&&(b[e]===this.data[e]?delete b[e]:(d[e]=this.data[e],this.data[e]=b[e]instanceof Array?b[e].concat():b[e]));a||this.notify(Object.keys(b),d)};a.generateObserve= @@ -2004,8 +2005,8 @@ params:["1023"]},{type:"number",params:["0"]},{type:"number",params:["100"]}],ty "class":"arduino_value"},joystick_toggle_led:{parent:"arduino_toggle_led",isNotFor:["joystick"],def:{params:[{type:"arduino_get_port_number"},null,null],type:"joystick_toggle_led"},"class":"arduino_set"},joystick_toggle_pwm:{parent:"arduino_toggle_pwm",isNotFor:["joystick"],def:{params:[{type:"arduino_get_pwm_port_number"},{type:"arduino_text",params:["255"]},null],type:"joystick_toggle_pwm"},"class":"arduino_set"},joystick_convert_scale:{parent:"arduino_convert_scale",isNotFor:["joystick"],def:{params:[{type:"arduino_get_number_sensor_value", params:[{type:"arduino_get_sensor_number"}]},{type:"number",params:["0"]},{type:"number",params:["1023"]},{type:"number",params:["0"]},{type:"number",params:["100"]}],type:"joystick_convert_scale"},"class":"arduino"},ebs_if:{parent:"_if",def:{type:"_if",params:[{type:"reach_something",params:[null,"wall"]}]}},ebs_if2:{parent:"_if",def:{type:"_if",params:[{type:"reach_something",params:[null,"cwz5"]}]}}}; (function(){for(var a in Entry.block){var b=Entry.block[a];if(b.parent){var c=function(){};c.prototype=Entry.block[b.parent];var c=new c,d;for(d in b)c[d]=b[d];Entry.block[a]=c}}})();"object"==typeof exports&&(exports.block=Entry.block);Entry.BlockMenu=function(a,b,c,d){Entry.Model(this,!1);this._align=b||"CENTER";this._scroll=void 0!==d?d:!1;this._bannedClass=[];this._categories=[];this.suffix="blockMenu";a="string"===typeof a?$("#"+a):$(a);if("DIV"!==a.prop("tagName"))return console.error("Dom is not div element");this.view=a;this.visible=!0;this._svgId="blockMenu"+(new Date).getTime();this._clearCategory();this._categoryData=c;this._generateView(c);this._splitters=[];this.setWidth();this.svg=Entry.SVG(this._svgId);Entry.Utils.addFilters(this.svg, -this.suffix);this.svgGroup=this.svg.elem("g");this.svgThreadGroup=this.svgGroup.elem("g");this.svgThreadGroup.board=this;this.svgBlockGroup=this.svgGroup.elem("g");this.svgBlockGroup.board=this;this.changeEvent=new Entry.Event(this);c&&this._generateCategoryCodes(c);this.observe(this,"_handleDragBlock",["dragBlock"]);this._scroll&&(this._scroller=new Entry.BlockMenuScroller(this),this._addControl(a));Entry.documentMousedown&&Entry.documentMousedown.attach(this,this.setSelectedBlock);this._categoryCodes&& -Entry.keyPressed&&Entry.keyPressed.attach(this,this._captureKeyEvent);Entry.windowResized&&(a=_.debounce(this.updateOffset,200),Entry.windowResized.attach(this,a))}; +this.suffix);b=Entry.Utils.addBlockPattern(this.svg,this.suffix);this.patternRect=b.rect;this.pattern=b.pattern;this.svgGroup=this.svg.elem("g");this.svgThreadGroup=this.svgGroup.elem("g");this.svgThreadGroup.board=this;this.svgBlockGroup=this.svgGroup.elem("g");this.svgBlockGroup.board=this;this.changeEvent=new Entry.Event(this);c&&this._generateCategoryCodes(c);this.observe(this,"_handleDragBlock",["dragBlock"]);this._scroll&&(this._scroller=new Entry.BlockMenuScroller(this),this._addControl(a)); +Entry.documentMousedown&&Entry.documentMousedown.attach(this,this.setSelectedBlock);this._categoryCodes&&Entry.keyPressed&&Entry.keyPressed.attach(this,this._captureKeyEvent);Entry.windowResized&&(a=_.debounce(this.updateOffset,200),Entry.windowResized.attach(this,a))}; (function(a){a.schema={code:null,dragBlock:null,closeBlock:null,selectedBlockView:null};a._generateView=function(b){var a=this.view,d=this;b&&(this._categoryCol=Entry.Dom("ul",{class:"entryCategoryListWorkspace",parent:a}),this._generateCategoryView(b));this.blockMenuContainer=Entry.Dom("div",{"class":"blockMenuContainer",parent:a});this.svgDom=Entry.Dom($(''),{parent:this.blockMenuContainer});this.svgDom.mouseenter(function(b){d._scroller&& d._scroller.setOpacity(1);b=d.workspace.selectedBlockView;!Entry.playground||Entry.playground.resizing||b&&b.dragMode===Entry.DRAG_MODE_DRAG||(Entry.playground.focusBlockMenu=!0,b=d.svgGroup.getBBox(),b=b.width+b.x+64,b>Entry.interfaceState.menuWidth&&(this.widthBackup=Entry.interfaceState.menuWidth-64,$(this).stop().animate({width:b-62},200)))});this.svgDom.mouseleave(function(b){Entry.playground&&!Entry.playground.resizing&&(d._scroller&&d._scroller.setOpacity(0),(b=this.widthBackup)&&$(this).stop().animate({width:b}, 200),delete this.widthBackup,delete Entry.playground.focusBlockMenu)});$(window).scroll(function(){d.updateOffset()})};a.changeCode=function(b){if(!(b instanceof Entry.Code))return console.error("You must inject code instance");this.codeListener&&this.code.changeEvent.detach(this.codeListener);var a=this;this.set({code:b});this.codeListener=this.code.changeEvent.attach(this,function(){a.changeEvent.notify()});b.createView(this);this.align()};a.bindCodeView=function(b){this.svgBlockGroup.remove(); @@ -2020,9 +2021,10 @@ b&&Entry.playground.checkVariables();"arduino"==b&&this._generateHwCode();var d= function(){g.scroller.resizeScrollBar.call(g.scroller);h.removeClass("foldOut");Entry.windowResized.notify()});this.visible&&(a=this._categoryCodes[b],this._selectedCategoryView=d,d.addClass("entrySelectedCategory"),a.constructor!==Entry.Code&&(a=this._categoryCodes[b]=new Entry.Code(a)),this.changeCode(a));this.lastSelector=b}};a._generateCategoryCodes=function(b){this._categoryCodes={};for(var a=0;athis._bannedClass.indexOf(b)&&this._bannedClass.push(b);this.align(a)};a.unbanClass=function(b,a){b=this._bannedClass.indexOf(b);-1a&&(b.preventDefault(),this.selectMenu(a-49))};a._clearCategory=function(){this._selectedCategoryView=null;this._categories=[];var b=this._categoryElems,a;for(a in b)b[a].remove();this._categoryElems={};b=this._categoryCodes;for(a in b){var d=b[a];d.constructor==Entry.Code&&d.clear()}this._categoryCodes=null};a.setCategoryData=function(b){this._clearCategory();this._categoryData=b;this._generateCategoryView(b);this._generateCategoryCodes(b)}; -a._generateCategoryView=function(b){if(b)for(var a=0;aa&&(b.preventDefault(),this.selectMenu(a-49))};a.setPatternRectFill=function(b){this.patternRect.attr({fill:b});this.pattern.attr({style:""})};a.disablePattern=function(){this.pattern.attr({style:"display: none"})};a._clearCategory=function(){this._selectedCategoryView=null;this._categories=[];var b=this._categoryElems,a;for(a in b)b[a].remove();this._categoryElems={};b=this._categoryCodes;for(a in b){var d=b[a];d.constructor==Entry.Code&& +d.clear()}this._categoryCodes=null};a.setCategoryData=function(b){this._clearCategory();this._categoryData=b;this._generateCategoryView(b);this._generateCategoryCodes(b)};a._generateCategoryView=function(b){if(b)for(var a=0;a=a?this.setVisible(!1):this.setVisible(!0)};a._reset=function(){this.vY=0;this.vScrollbar.attr({y:this.vY});this.resizeScrollBar()};a.onMouseDown=function(b){function a(b){b.stopPropagation&&b.stopPropagation();b.preventDefault&&b.preventDefault();b=b.originalEvent&&b.originalEvent.touches?b.originalEvent.touches[0]:b;var c=e.dragInstance; @@ -2031,34 +2033,36 @@ a);g.bind("touchend.scroll",d);e.dragInstance=new Entry.DragInstance({startY:f.p (this.svgGroup.nextMagnet=this.block,this._nextGroup=this.svgGroup.elem("g"),this._observers.push(this.observe(this,"_updateMagnet",["contentHeight"])));this.isInBlockMenu=this.getBoard()instanceof Entry.BlockMenu;var e=this;this.mouseHandler=function(){var b=e.block.events;b&&b.mousedown&&b.mousedown.forEach(function(b){b(e)});e.onMouseDown.apply(e,arguments)};this._startRender(a,c);this._observers.push(this.block.observe(this,"_setMovable",["movable"]));this._observers.push(this.block.observe(this, "_setReadOnly",["movable"]));this._observers.push(this.block.observe(this,"_setCopyable",["copyable"]));this._observers.push(this.block.observe(this,"_updateColor",["deletable"],!1));this._observers.push(this.observe(this,"_updateBG",["magneting"],!1));this._observers.push(this.observe(this,"_updateOpacity",["visible"],!1));this._observers.push(this.observe(this,"_updateDisplay",["display"],!1));this._observers.push(this.observe(this,"_updateShadow",["shadow"]));this._observers.push(this.observe(this, "_updateMagnet",["offsetY"]));this._observers.push(b.code.observe(this,"_setBoard",["board"],!1));this.dragMode=Entry.DRAG_MODE_NONE;Entry.Utils.disableContextmenu(this.svgGroup.node);(b=a.events.viewAdd)&&!this.isInBlockMenu&&b.forEach(function(b){Entry.Utils.isFunction(b)&&b(a)})};Entry.BlockView.PARAM_SPACE=5;Entry.BlockView.DRAG_RADIUS=5; -(function(a){a.schema={id:0,type:Entry.STATIC.BLOCK_RENDER_MODEL,x:0,y:0,offsetX:0,offsetY:0,width:0,height:0,contentWidth:0,contentHeight:0,magneting:!1,visible:!0,animating:!1,shadow:!0,display:!0};a._startRender=function(b,a){var d=this;b=this._skeleton;this.svgGroup.attr({class:"block"});var e=b.classes;e&&0!==e.length&&e.forEach(function(b){d.svgGroup.addClass(b)});e=b.path(this);this.pathGroup=this.svgGroup.elem("g");this._updateMagnet();this._path=this.pathGroup.elem("path");var f=this._schema.color; -this.block.deletable===Entry.Block.DELETABLE_FALSE_LIGHTEN&&(f=Entry.Utils.colorLighten(f));this._fillColor=f;e={d:e,fill:f,class:"blockPath"};if(this.magnet.next||this._skeleton.nextShadow)f=this.getBoard().suffix,this.pathGroup.attr({filter:"url(#entryBlockShadowFilter_"+f+")"});else if(this.magnet.string||this.magnet.boolean)e.stroke=b.outerLine;b.outerLine&&(e["stroke-width"]="0.6");this._path.attr(e);this._moveTo(this.x,this.y,!1);this._startContentRender(a);!0!==this._board.disableMouseEvent&& -this._addControl();this.bindPrev()};a._startContentRender=function(b){b=void 0===b?Entry.Workspace.MODE_BOARD:b;this.contentSvgGroup&&this.contentSvgGroup.remove();var a=this._schema;a.statements&&a.statements.length&&this.statementSvgGroup&&this.statementSvgGroup.remove();this._contents=[];this.contentSvgGroup=this.svgGroup.elem("g");a.statements&&a.statements.length&&(this.statementSvgGroup=this.svgGroup.elem("g"));switch(b){case Entry.Workspace.MODE_BOARD:case Entry.Workspace.MODE_OVERLAYBOARD:for(var d= -/(%\d)/mi,e=(a.template?a.template:Lang.template[this.block.type]).split(d),f=a.params,g=0;gEntry.BlockView.DRAG_RADIUS)&&m.movable&&(m.isInBlockMenu?e.cloneToGlobal(b):(b=!1,m.dragMode!=Entry.DRAG_MODE_DRAG&&(m._toGlobalCoordinate(),m.dragMode=Entry.DRAG_MODE_DRAG,m.block.getThread().changeEvent.notify(),Entry.GlobalSvg.setView(m,c),b=!0),this.animating&&this.set({animating:!1}),0===m.dragInstance.height&&m.dragInstance.set({height:-1+m.height}),c=m.dragInstance,m._moveBy(d.pageX-c.offsetX,d.pageY-c.offsetY,!1),c.set({offsetX:d.pageX, -offsetY:d.pageY}),Entry.GlobalSvg.position(),m.originPos||(m.originPos={x:m.x,y:m.y}),b&&e.generateCodeMagnetMap(),m._updateCloseBlock()))}function d(b){$(document).unbind(".block");m.terminateDrag(b);e&&e.set({dragBlock:null});Entry.GlobalSvg.remove();delete this.mouseDownCoordinate;delete m.dragInstance}b.stopPropagation&&b.stopPropagation();b.preventDefault&&b.preventDefault();var e=this.getBoard();Entry.documentMousedown&&Entry.documentMousedown.notify(b);if(!this.readOnly&&!e.viewOnly){e.setSelectedBlock(this); -this.dominate();if(0===b.button||b.originalEvent&&b.originalEvent.touches){var f;f=b.originalEvent&&b.originalEvent.touches?b.originalEvent.touches[0]:b;this.mouseDownCoordinate={x:f.pageX,y:f.pageY};var g=$(document);g.bind("mousemove.block touchmove.block",c);g.bind("mouseup.block touchend.block",d);this.dragInstance=new Entry.DragInstance({startX:f.pageX,startY:f.pageY,offsetX:f.pageX,offsetY:f.pageY,height:0,mode:!0});e.set({dragBlock:this});this.addDragging();this.dragMode=Entry.DRAG_MODE_MOUSEDOWN}else if(Entry.Utils.isRightButton(b)){var h= -this,k=h.block;if(this.isInBlockMenu)return;f=[];var g={text:Lang.Blocks.Duplication_option,enable:this.copyable,callback:function(){Entry.do("cloneBlock",k)}},l={text:Lang.Blocks.CONTEXT_COPY_option,enable:this.copyable,callback:function(){h.block.copyToClipboard()}},n={text:Lang.Blocks.Delete_Blocks,enable:k.isDeletable(),callback:function(){Entry.do("destroyBlock",h.block)}};f.push(g);f.push(l);f.push(n);Entry.ContextMenu.show(f)}var m=this;e.workspace.getMode()===Entry.Workspace.MODE_VIMBOARD&& -b&&document.getElementsByClassName("CodeMirror")[0].dispatchEvent(Entry.Utils.createMouseEvent("dragStart",event))}};a.vimBoardEvent=function(b,a,d){b&&(b=Entry.Utils.createMouseEvent(a,b),d&&(b.block=d),document.getElementsByClassName("CodeMirror")[0].dispatchEvent(b))};a.terminateDrag=function(b){var a=this.getBoard(),d=this.dragMode,e=this.block,f=a.workspace.getMode();this.removeDragging();this.set({visible:!0});this.dragMode=Entry.DRAG_MODE_NONE;if(f===Entry.Workspace.MODE_VIMBOARD)a instanceof -Entry.BlockMenu?(a.terminateDrag(),this.vimBoardEvent(b,"dragEnd",e)):a.clear();else if(d===Entry.DRAG_MODE_DRAG){var f=this.dragInstance&&this.dragInstance.isNew,g=Entry.GlobalSvg,h=this.block.getPrevBlock(this.block);b=!1;switch(Entry.GlobalSvg.terminateDrag(this)){case g.DONE:g=a.magnetedBlockView;g instanceof Entry.BlockView&&(g=g.block);h&&!g?Entry.do("separateBlock",e):h||g||f?g?("next"===g.view.magneting?(h=e.getLastBlock(),this.dragMode=d,a.separate(e),this.dragMode=Entry.DRAG_MODE_NONE,Entry.do("insertBlock", -g,h).isPass(f),Entry.ConnectionRipple.setView(g.view).dispose()):(Entry.do("insertBlock",e,g).isPass(f),b=!0),createjs.Sound.play("entryMagneting")):Entry.do("moveBlock",e).isPass(f):e.getThread().view.isGlobal()?Entry.do("moveBlock",e):Entry.do("separateBlock",e);break;case g.RETURN:e=this.block;d=this.originPos;h?(this.set({animating:!1}),createjs.Sound.play("entryMagneting"),this.bindPrev(h),e.insert(h)):(f=e.getThread().view.getParent(),f instanceof Entry.Board?this._moveTo(d.x,d.y,!1):(createjs.Sound.play("entryMagneting"), -Entry.do("insertBlock",e,f)));break;case g.REMOVE:createjs.Sound.play("entryDelete"),f?this.block.destroy(!1,!0):this.block.doDestroyBelow(!1)}a.setMagnetedBlock(null);b&&Entry.ConnectionRipple.setView(e.view).dispose()}this.destroyShadow();delete this.originPos;this.dominate()};a._updateCloseBlock=function(){var b=this.getBoard(),a;if(this._skeleton.magnets){for(var d in this.magnet)if(a="next"===d?this.getBoard().getNearestMagnet(this.x,this.y+this.getBelowHeight(),d):this.getBoard().getNearestMagnet(this.x, -this.y,d))return b.setMagnetedBlock(a.view,d);b.setMagnetedBlock(null)}};a.dominate=function(){this.block.getThread().view.dominate()};a.getSvgRoot=function(){for(var b=this.getBoard().svgBlockGroup,a=this.svgGroup;a.parentNode!==b;)a=a.parentNode;return a};a.getBoard=function(){return this._board};a._setBoard=function(){this._board=this._board.code.board};a.destroy=function(b){this._destroyObservers();var a=this.svgGroup;b?$(a).fadeOut(100,function(){a.remove()}):a.remove();this._contents.forEach(function(b){b.constructor!== -Entry.Block&&b.destroy()});var d=this.block;(b=d.events.viewDestroy)&&!this.isInBlockMenu&&b.forEach(function(b){Entry.Utils.isFunction(b)&&b(d)});this._schemaChangeEvent&&this._schemaChangeEvent.destroy()};a.getShadow=function(){this._shadow||(this._shadow=Entry.SVG.createElement(this.svgGroup.cloneNode(!0),{opacity:.5}),this.getBoard().svgGroup.appendChild(this._shadow));return this._shadow};a.destroyShadow=function(){this._shadow&&(this._shadow.remove(),delete this._shadow)};a._updateMagnet=function(){if(this._skeleton.magnets){var b= -this._skeleton.magnets(this);b.next&&this._nextGroup.attr("transform","translate("+b.next.x+","+b.next.y+")");this.magnet=b;this.block.getThread().changeEvent.notify()}};a._updateBG=function(){if(this._board.dragBlock&&this._board.dragBlock.dragInstance){var b=this.svgGroup;if(this.magnet.next){if(b=this.magneting){var a=this._board.dragBlock.getShadow(),d=this.getAbsoluteCoordinate(),e;if("previous"===b)e=this.magnet.next,e="translate("+(d.x+e.x)+","+(d.y+e.y)+")";else if("next"===b){e=this.magnet.previous; -var f=this._board.dragBlock.getBelowHeight();e="translate("+(d.x+e.x)+","+(d.y+e.y-f)+")"}$(a).attr({transform:e,display:"block"});this._clonedShadow=a;this.background&&(this.background.remove(),this.nextBackground.remove(),delete this.background,delete this.nextBackground);"previous"===b&&(b=this._board.dragBlock.getBelowHeight()+this.offsetY,this.originalHeight=this.offsetY,this.set({offsetY:b}))}else this._clonedShadow&&(this._clonedShadow.attr({display:"none"}),delete this._clonedShadow),b=this.originalHeight, -void 0!==b&&(this.background&&(this.background.remove(),this.nextBackground.remove(),delete this.background,delete this.nextBackground),this.set({offsetY:b}),delete this.originalHeight);(b=this.block.thread.changeEvent)&&b.notify()}else this.magneting?(b.attr({filter:"url(#entryBlockHighlightFilter_"+this.getBoard().suffix+")"}),b.addClass("outputHighlight")):(b.removeClass("outputHighlight"),b.removeAttr("filter"))}};a.addDragging=function(){this.svgGroup.addClass("dragging")};a.removeDragging=function(){this.svgGroup.removeClass("dragging")}; -a.addSelected=function(){this.svgGroup.addClass("selected")};a.removeSelected=function(){this.svgGroup.removeClass("selected")};a.getSkeleton=function(){return this._skeleton};a.getContentPos=function(){return this._skeleton.contentPos(this)};a.renderText=function(){this._startContentRender(Entry.Workspace.MODE_VIMBOARD)};a.renderBlock=function(){this._startContentRender(Entry.Workspace.MODE_BOARD)};a._updateOpacity=function(){this.svgGroup.attr({opacity:!1===this.visible?0:1});this.visible&&this._setPosition()}; -a._updateShadow=function(){this.shadow&&Entry.Utils.colorDarken(this._schema.color,.7)};a._setMovable=function(){this.movable=null!==this.block.isMovable()?this.block.isMovable():void 0!==this._skeleton.movable?this._skeleton.movable:!0};a._setReadOnly=function(){this.readOnly=null!==this.block.isReadOnly()?this.block.isReadOnly():void 0!==this._skeleton.readOnly?this._skeleton.readOnly:!1};a._setCopyable=function(){this.copyable=null!==this.block.isCopyable()?this.block.isCopyable():void 0!==this._skeleton.copyable? -this._skeleton.copyable:!0};a.bumpAway=function(b,a){var d=this;b=b||15;a?window.setTimeout(function(){d._moveBy(b,b,!1)},a):d._moveBy(b,b,!1)};a.bindPrev=function(b){if(b){if(this._toLocalCoordinate(b.view._nextGroup),(b=b.getNextBlock())&&b!==this.block){var a=this.block.getLastBlock();a.view.magnet.next?b.view._toLocalCoordinate(a.view._nextGroup):(b.view._toGlobalCoordinate(),b.separate(),b.view.bumpAway(null,100))}}else if(b=this.block.getPrevBlock())this._toLocalCoordinate(b.view._nextGroup), -(b=this.block.getNextBlock())&&b.view&&b.view._toLocalCoordinate(this._nextGroup)};a.getAbsoluteCoordinate=function(b){b=void 0!==b?b:this.dragMode;if(b===Entry.DRAG_MODE_DRAG)return{x:this.x,y:this.y};b=this.block.getThread().view.requestAbsoluteCoordinate(this);b.x+=this.x;b.y+=this.y;return b};a.getBelowHeight=function(){return this.block.getThread().view.requestPartHeight(this)};a._updateDisplay=function(){this.svgGroup.attr({display:!1===this.display?"none":"block"});this.display&&this._setPosition()}; -a._updateColor=function(){var b=this._schema.color;this.block.deletable===Entry.Block.DELETABLE_FALSE_LIGHTEN&&(b=Entry.Utils.colorLighten(b));this._fillColor=b;this._path.attr({fill:b});this._updateContents()};a._updateContents=function(){for(var b=0;bEntry.BlockView.DRAG_RADIUS)&&m.movable&&(m.isInBlockMenu?e.cloneToGlobal(b):(b=!1,m.dragMode!=Entry.DRAG_MODE_DRAG&&(m._toGlobalCoordinate(),m.dragMode= +Entry.DRAG_MODE_DRAG,m.block.getThread().changeEvent.notify(),Entry.GlobalSvg.setView(m,c),b=!0),this.animating&&this.set({animating:!1}),0===m.dragInstance.height&&m.dragInstance.set({height:-1+m.height}),c=m.dragInstance,m._moveBy(d.pageX-c.offsetX,d.pageY-c.offsetY,!1),c.set({offsetX:d.pageX,offsetY:d.pageY}),Entry.GlobalSvg.position(),m.originPos||(m.originPos={x:m.x,y:m.y}),b&&e.generateCodeMagnetMap(),m._updateCloseBlock()))}function d(b){$(document).unbind(".block");m.terminateDrag(b);e&&e.set({dragBlock:null}); +m._changeFill(!1);Entry.GlobalSvg.remove();delete this.mouseDownCoordinate;delete m.dragInstance}b.stopPropagation&&b.stopPropagation();b.preventDefault&&b.preventDefault();this._changeFill(!1);var e=this.getBoard();Entry.documentMousedown&&Entry.documentMousedown.notify(b);if(!this.readOnly&&!e.viewOnly){e.setSelectedBlock(this);this.dominate();if(0===b.button||b.originalEvent&&b.originalEvent.touches){var f;f=b.originalEvent&&b.originalEvent.touches?b.originalEvent.touches[0]:b;this.mouseDownCoordinate= +{x:f.pageX,y:f.pageY};var g=$(document);g.bind("mousemove.block touchmove.block",c);g.bind("mouseup.block touchend.block",d);this.dragInstance=new Entry.DragInstance({startX:f.pageX,startY:f.pageY,offsetX:f.pageX,offsetY:f.pageY,height:0,mode:!0});e.set({dragBlock:this});this.addDragging();this.dragMode=Entry.DRAG_MODE_MOUSEDOWN}else if(Entry.Utils.isRightButton(b)){var h=this,k=h.block;if(this.isInBlockMenu)return;f=[];var g={text:Lang.Blocks.Duplication_option,enable:this.copyable,callback:function(){Entry.do("cloneBlock", +k)}},l={text:Lang.Blocks.CONTEXT_COPY_option,enable:this.copyable,callback:function(){h.block.copyToClipboard()}},n={text:Lang.Blocks.Delete_Blocks,enable:k.isDeletable(),callback:function(){Entry.do("destroyBlock",h.block)}};f.push(g);f.push(l);f.push(n);Entry.ContextMenu.show(f)}var m=this;e.workspace.getMode()===Entry.Workspace.MODE_VIMBOARD&&b&&document.getElementsByClassName("CodeMirror")[0].dispatchEvent(Entry.Utils.createMouseEvent("dragStart",event))}};a.vimBoardEvent=function(b,a,d){b&&(b= +Entry.Utils.createMouseEvent(a,b),d&&(b.block=d),document.getElementsByClassName("CodeMirror")[0].dispatchEvent(b))};a.terminateDrag=function(b){var a=this.getBoard(),d=this.dragMode,e=this.block,f=a.workspace.getMode();this.removeDragging();this.set({visible:!0});this.dragMode=Entry.DRAG_MODE_NONE;if(f===Entry.Workspace.MODE_VIMBOARD)a instanceof Entry.BlockMenu?(a.terminateDrag(),this.vimBoardEvent(b,"dragEnd",e)):a.clear();else if(d===Entry.DRAG_MODE_DRAG){var f=this.dragInstance&&this.dragInstance.isNew, +g=Entry.GlobalSvg,h=this.block.getPrevBlock(this.block);b=!1;switch(Entry.GlobalSvg.terminateDrag(this)){case g.DONE:g=a.magnetedBlockView;g instanceof Entry.BlockView&&(g=g.block);h&&!g?Entry.do("separateBlock",e):h||g||f?g?("next"===g.view.magneting?(h=e.getLastBlock(),this.dragMode=d,a.separate(e),this.dragMode=Entry.DRAG_MODE_NONE,Entry.do("insertBlock",g,h).isPass(f),Entry.ConnectionRipple.setView(g.view).dispose()):(Entry.do("insertBlock",e,g).isPass(f),b=!0),createjs.Sound.play("entryMagneting")): +Entry.do("moveBlock",e).isPass(f):e.getThread().view.isGlobal()?Entry.do("moveBlock",e):Entry.do("separateBlock",e);break;case g.RETURN:e=this.block;d=this.originPos;h?(this.set({animating:!1}),createjs.Sound.play("entryMagneting"),this.bindPrev(h),e.insert(h)):(f=e.getThread().view.getParent(),f instanceof Entry.Board?this._moveTo(d.x,d.y,!1):(createjs.Sound.play("entryMagneting"),Entry.do("insertBlock",e,f)));break;case g.REMOVE:createjs.Sound.play("entryDelete"),f?this.block.destroy(!1,!0):this.block.doDestroyBelow(!1)}a.setMagnetedBlock(null); +b&&Entry.ConnectionRipple.setView(e.view).dispose()}this.destroyShadow();delete this.originPos;this.dominate()};a._updateCloseBlock=function(){var b=this.getBoard(),a;if(this._skeleton.magnets){for(var d in this.magnet)if(a="next"===d?this.getBoard().getNearestMagnet(this.x,this.y+this.getBelowHeight(),d):this.getBoard().getNearestMagnet(this.x,this.y,d))return b.setMagnetedBlock(a.view,d);b.setMagnetedBlock(null)}};a.dominate=function(){this.block.getThread().view.dominate()};a.getSvgRoot=function(){for(var b= +this.getBoard().svgBlockGroup,a=this.svgGroup;a.parentNode!==b;)a=a.parentNode;return a};a.getBoard=function(){return this._board};a._setBoard=function(){this._board=this._board.code.board};a.destroy=function(b){this._destroyObservers();var a=this.svgGroup;b?$(a).fadeOut(100,function(){a.remove()}):a.remove();this._contents.forEach(function(b){b.constructor!==Entry.Block&&b.destroy()});var d=this.block;(b=d.events.viewDestroy)&&!this.isInBlockMenu&&b.forEach(function(b){Entry.Utils.isFunction(b)&& +b(d)});this._schemaChangeEvent&&this._schemaChangeEvent.destroy()};a.getShadow=function(){this._shadow||(this._shadow=Entry.SVG.createElement(this.svgGroup.cloneNode(!0),{opacity:.5}),this.getBoard().svgGroup.appendChild(this._shadow));return this._shadow};a.destroyShadow=function(){this._shadow&&(this._shadow.remove(),delete this._shadow)};a._updateMagnet=function(){if(this._skeleton.magnets){var b=this._skeleton.magnets(this);b.next&&this._nextGroup.attr("transform","translate("+b.next.x+","+b.next.y+ +")");this.magnet=b;this.block.getThread().changeEvent.notify()}};a._updateBG=function(){if(this._board.dragBlock&&this._board.dragBlock.dragInstance){var b=this.svgGroup;if(this.magnet.next){if(b=this.magneting){var a=this._board.dragBlock.getShadow(),d=this.getAbsoluteCoordinate(),e;if("previous"===b)e=this.magnet.next,e="translate("+(d.x+e.x)+","+(d.y+e.y)+")";else if("next"===b){e=this.magnet.previous;var f=this._board.dragBlock.getBelowHeight();e="translate("+(d.x+e.x)+","+(d.y+e.y-f)+")"}$(a).attr({transform:e, +display:"block"});this._clonedShadow=a;this.background&&(this.background.remove(),this.nextBackground.remove(),delete this.background,delete this.nextBackground);"previous"===b&&(b=this._board.dragBlock.getBelowHeight()+this.offsetY,this.originalHeight=this.offsetY,this.set({offsetY:b}))}else this._clonedShadow&&(this._clonedShadow.attr({display:"none"}),delete this._clonedShadow),b=this.originalHeight,void 0!==b&&(this.background&&(this.background.remove(),this.nextBackground.remove(),delete this.background, +delete this.nextBackground),this.set({offsetY:b}),delete this.originalHeight);(b=this.block.thread.changeEvent)&&b.notify()}else this.magneting?(b.attr({filter:"url(#entryBlockHighlightFilter_"+this.getBoard().suffix+")"}),b.addClass("outputHighlight")):(b.removeClass("outputHighlight"),b.removeAttr("filter"))}};a.addDragging=function(){this.svgGroup.addClass("dragging")};a.removeDragging=function(){this.svgGroup.removeClass("dragging")};a.addSelected=function(){this.svgGroup.addClass("selected")}; +a.removeSelected=function(){this.svgGroup.removeClass("selected")};a.getSkeleton=function(){return this._skeleton};a.getContentPos=function(){return this._skeleton.contentPos(this)};a.renderText=function(){this._startContentRender(Entry.Workspace.MODE_VIMBOARD)};a.renderBlock=function(){this._startContentRender(Entry.Workspace.MODE_BOARD)};a._updateOpacity=function(){this.svgGroup.attr({opacity:!1===this.visible?0:1});this.visible&&this._setPosition()};a._updateShadow=function(){this.shadow&&Entry.Utils.colorDarken(this._schema.color, +.7)};a._setMovable=function(){this.movable=null!==this.block.isMovable()?this.block.isMovable():void 0!==this._skeleton.movable?this._skeleton.movable:!0};a._setReadOnly=function(){this.readOnly=null!==this.block.isReadOnly()?this.block.isReadOnly():void 0!==this._skeleton.readOnly?this._skeleton.readOnly:!1};a._setCopyable=function(){this.copyable=null!==this.block.isCopyable()?this.block.isCopyable():void 0!==this._skeleton.copyable?this._skeleton.copyable:!0};a.bumpAway=function(b,a){var d=this; +b=b||15;a?window.setTimeout(function(){d._moveBy(b,b,!1)},a):d._moveBy(b,b,!1)};a.bindPrev=function(b){if(b){if(this._toLocalCoordinate(b.view._nextGroup),(b=b.getNextBlock())&&b!==this.block){var a=this.block.getLastBlock();a.view.magnet.next?b.view._toLocalCoordinate(a.view._nextGroup):(b.view._toGlobalCoordinate(),b.separate(),b.view.bumpAway(null,100))}}else if(b=this.block.getPrevBlock())this._toLocalCoordinate(b.view._nextGroup),(b=this.block.getNextBlock())&&b.view&&b.view._toLocalCoordinate(this._nextGroup)}; +a.getAbsoluteCoordinate=function(b){b=void 0!==b?b:this.dragMode;if(b===Entry.DRAG_MODE_DRAG)return{x:this.x,y:this.y};b=this.block.getThread().view.requestAbsoluteCoordinate(this);b.x+=this.x;b.y+=this.y;return b};a.getBelowHeight=function(){return this.block.getThread().view.requestPartHeight(this)};a._updateDisplay=function(){this.svgGroup.attr({display:!1===this.display?"none":"block"});this.display&&this._setPosition()};a._updateColor=function(){var b=this._schema.color;this.block.deletable=== +Entry.Block.DELETABLE_FALSE_LIGHTEN&&(b=Entry.Utils.colorLighten(b));this._fillColor=b;this._path.attr({fill:b});this._updateContents()};a._updateContents=function(){for(var b=0;b'), -{parent:this.wrapper});this.visible=!0;var d=this;this.svg=Entry.SVG(this._svgId);$(window).scroll(function(){d.updateOffset()});this.svgGroup=this.svg.elem("g");this.svgThreadGroup=this.svgGroup.elem("g");this.svgThreadGroup.board=this;this.svgBlockGroup=this.svgGroup.elem("g");this.svgBlockGroup.board=this;b.isOverlay?(this.wrapper.addClass("entryOverlayBoard"),this.generateButtons(),this.suffix="overlayBoard"):this.suffix="board";Entry.Utils.addFilters(this.svg,this.suffix)};a.changeCode=function(b){this.code&& -this.codeListener&&this.code.changeEvent.detach(this.codeListener);this.set({code:b});var a=this;b&&(this.codeListener=this.code.changeEvent.attach(this,function(){a.changeEvent.notify()}),b.createView(this));this.scroller.resizeScrollBar()};a.bindCodeView=function(b){this.svgBlockGroup.remove();this.svgThreadGroup.remove();this.svgBlockGroup=b.svgBlockGroup;this.svgThreadGroup=b.svgThreadGroup;this.svgGroup.appendChild(this.svgThreadGroup);this.svgGroup.appendChild(this.svgBlockGroup)};a.setMagnetedBlock= -function(b,a){if(this.magnetedBlockView){if(this.magnetedBlockView===b)return;this.magnetedBlockView.set({magneting:!1})}this.set({magnetedBlockView:b});b&&(b.set({magneting:a}),b.dominate())};a.getCode=function(){return this.code};a.findById=function(b){return this.code.findById(b)};a._addControl=function(){var b=this.svgDom,a=this;b.mousedown(function(){a.onMouseDown.apply(a,arguments)});b.bind("touchstart",function(){a.onMouseDown.apply(a,arguments)});b.on("wheel",function(){a.mouseWheel.apply(a, -arguments)});var d=a.scroller;d&&(b.mouseenter(function(b){d.setOpacity(1)}),b.mouseleave(function(b){d.setOpacity(0)}))};a.onMouseDown=function(b){function a(b){b.stopPropagation&&b.stopPropagation();b.preventDefault&&b.preventDefault();b=b.originalEvent&&b.originalEvent.touches?b.originalEvent.touches[0]:b;var c=f.dragInstance;f.scroller.scroll(b.pageX-c.offsetX,b.pageY-c.offsetY);c.set({offsetX:b.pageX,offsetY:b.pageY})}function d(b){$(document).unbind(".entryBoard");delete f.dragInstance}if(this.workspace.getMode()!= -Entry.Workspace.MODE_VIMBOARD){b.stopPropagation&&b.stopPropagation();b.preventDefault&&b.preventDefault();if(0===b.button||b.originalEvent&&b.originalEvent.touches){b=b.originalEvent&&b.originalEvent.touches?b.originalEvent.touches[0]:b;Entry.documentMousedown&&Entry.documentMousedown.notify(b);var e=$(document);e.bind("mousemove.entryBoard",a);e.bind("mouseup.entryBoard",d);e.bind("touchmove.entryBoard",a);e.bind("touchend.entryBoard",d);this.dragInstance=new Entry.DragInstance({startX:b.pageX, -startY:b.pageY,offsetX:b.pageX,offsetY:b.pageY})}else if(Entry.Utils.isRightButton(b)){if(!this.visible)return;b=[];this._contextOptions[Entry.Board.OPTION_PASTE].option.enable=!!Entry.clipboard;for(e=0;eb&&(f=f+e+10,e=0,d=15);e=Math.max(e,k.width);l=d+15;h._moveTo(f,l,!1);d=d+k.height+15}}this.scroller.resizeScrollBar()};a.clear=function(){this.svgBlockGroup.remove();this.svgThreadGroup.remove()};a.updateOffset=function(){this._offset=this.svg.getBoundingClientRect();var b=$(window),a=b.scrollTop(),b=b.scrollLeft(),d=this._offset;this.relativeOffset= -{top:d.top-a,left:d.left-b};this.btnWrapper&&this.btnWrapper.attr({transform:"translate("+(d.width/2-65)+","+(d.height-200)+")"})};a.generateButtons=function(){var b=this,a=this.svgGroup.elem("g");this.btnWrapper=a;var d=a.elem("text",{x:27,y:33,class:"entryFunctionButtonText"});d.textContent=Lang.Buttons.save;var e=a.elem("text",{x:102.5,y:33,class:"entryFunctionButtonText"});e.textContent=Lang.Buttons.cancel;var f=a.elem("circle",{cx:27.5,cy:27.5,r:27.5,class:"entryFunctionButton"}),a=a.elem("circle", -{cx:102.5,cy:27.5,r:27.5,class:"entryFunctionButton"});$(f).bind("mousedown touchstart",function(){b.save()});$(d).bind("mousedown touchstart",function(){b.save()});$(a).bind("mousedown touchstart",function(){b.cancelEdit()});$(e).bind("mousedown touchstart",function(){b.cancelEdit()})};a.cancelEdit=function(){this.workspace.setMode(Entry.Workspace.MODE_BOARD,"cancelEdit")};a.save=function(){this.workspace.setMode(Entry.Workspace.MODE_BOARD,"save")};a.generateCodeMagnetMap=function(){var b=this.code; -if(b&&this.dragBlock)for(var a in this.dragBlock.magnet){var d=this._getCodeBlocks(b,a);d.sort(function(b,a){return b.point-a.point});d.unshift({point:-Number.MAX_VALUE,blocks:[]});for(var e=1;eg.point&&(g.blocks.push(h),l++,g=d[l],g););delete f.startBlock}f.endPoint=Number.MAX_VALUE;d[e-1].endPoint=f.point}this._magnetMap[a]=d}};a._getCodeBlocks=function(b,a){b=b.getThreads();var d=[],e;switch(a){case "previous":e=this._getNextMagnets; -break;case "next":e=this._getPreviousMagnets;break;case "string":e=this._getFieldMagnets;break;case "boolean":e=this._getFieldMagnets;break;case "param":e=this._getOutputMagnets;break;default:return[]}for(var f=0;fd.endPoint)f=h+1;else{e=d.blocks;for(f=0;fb&&(f=f+e+10,e=0,d=15);e=Math.max(e,k.width);l=d+15;h._moveTo(f,l,!1);d=d+k.height+15}}this.scroller.resizeScrollBar()};a.clear=function(){this.svgBlockGroup.remove();this.svgThreadGroup.remove()};a.updateOffset=function(){this._offset=this.svg.getBoundingClientRect();var b=$(window),a=b.scrollTop(), +b=b.scrollLeft(),d=this._offset;this.relativeOffset={top:d.top-a,left:d.left-b};this.btnWrapper&&this.btnWrapper.attr({transform:"translate("+(d.width/2-65)+","+(d.height-200)+")"})};a.generateButtons=function(){var b=this,a=this.svgGroup.elem("g");this.btnWrapper=a;var d=a.elem("text",{x:27,y:33,class:"entryFunctionButtonText"});d.textContent=Lang.Buttons.save;var e=a.elem("text",{x:102.5,y:33,class:"entryFunctionButtonText"});e.textContent=Lang.Buttons.cancel;var f=a.elem("circle",{cx:27.5,cy:27.5, +r:27.5,class:"entryFunctionButton"}),a=a.elem("circle",{cx:102.5,cy:27.5,r:27.5,class:"entryFunctionButton"});$(f).bind("mousedown touchstart",function(){b.save()});$(d).bind("mousedown touchstart",function(){b.save()});$(a).bind("mousedown touchstart",function(){b.cancelEdit()});$(e).bind("mousedown touchstart",function(){b.cancelEdit()})};a.cancelEdit=function(){this.workspace.setMode(Entry.Workspace.MODE_BOARD,"cancelEdit")};a.save=function(){this.workspace.setMode(Entry.Workspace.MODE_BOARD,"save")}; +a.generateCodeMagnetMap=function(){var b=this.code;if(b&&this.dragBlock)for(var a in this.dragBlock.magnet){var d=this._getCodeBlocks(b,a);d.sort(function(b,a){return b.point-a.point});d.unshift({point:-Number.MAX_VALUE,blocks:[]});for(var e=1;eg.point&&(g.blocks.push(h),l++,g=d[l],g););delete f.startBlock}f.endPoint=Number.MAX_VALUE;d[e-1].endPoint=f.point}this._magnetMap[a]=d}};a._getCodeBlocks=function(b,a){b=b.getThreads(); +var d=[],e;switch(a){case "previous":e=this._getNextMagnets;break;case "next":e=this._getPreviousMagnets;break;case "string":e=this._getFieldMagnets;break;case "boolean":e=this._getFieldMagnets;break;case "param":e=this._getOutputMagnets;break;default:return[]}for(var f=0;fd.endPoint)f=h+1;else{e=d.blocks;for(f=0;fb||a.splice(b,1))};a.raiseEvent=function(b,a,d){b=this._eventMap[b];var e=[];if(void 0!==b){for(var f=0;f