Commit c1fedcff authored by carlospamg's avatar carlospamg

Fixing conflicts with upstream merge/rebase

parents 662aa5a5 03e3bef4
......@@ -828,7 +828,7 @@ c.setAttribute("h",d.height),c.setAttribute("w",d.width),b.appendChild(c));d=!1;
!0);a.disabled&&b.setAttribute("disabled",!0);a.isDeletable()||b.setAttribute("deletable",!1);a.isMovable()||b.setAttribute("movable",!1);a.isEditable()||b.setAttribute("editable",!1);if(a=a.getNextBlock())h=goog.dom.createDom("next",null,Blockly.Xml.blockToDom_(a)),b.appendChild(h);return b};Blockly.Xml.domToText=function(a){return(new XMLSerializer).serializeToString(a)};
Blockly.Xml.domToPrettyText=function(a){a=Blockly.Xml.domToText(a).split("<");for(var b="",c=1;c<a.length;c++){var d=a[c];"/"==d[0]&&(b=b.substring(2));a[c]=b+"<"+d;"/"!=d[0]&&"/>"!=d.slice(-2)&&(b+=" ")}a=a.join("\n");a=a.replace(/(<(\w+)\b[^>]*>[^\n]*)\n *<\/\2>/g,"$1</$2>");return a.replace(/^\n/,"")};
Blockly.Xml.textToDom=function(a){a=(new DOMParser).parseFromString(a,"text/xml");if(!a||!a.firstChild||"xml"!=a.firstChild.nodeName.toLowerCase()||a.firstChild!==a.lastChild)throw"Blockly.Xml.textToDom did not obtain a valid XML tree.";return a.firstChild};
Blockly.Xml.domToWorkspace=function(a,b){if(Blockly.RTL)var c=a.getMetrics().viewWidth;for(var d=0,e;e=b.childNodes[d];d++)if("block"==e.nodeName.toLowerCase()){var f=Blockly.Xml.domToBlock(a,e),g=parseInt(e.getAttribute("x"),10);e=parseInt(e.getAttribute("y"),10);isNaN(g)||isNaN(e)||f.moveBy(Blockly.RTL?c-g:g,e)}};
Blockly.Xml.domToWorkspace=function(a,b){var c;Blockly.RTL&&(c=a.getMetrics().viewWidth);for(var d=0,e;e=b.childNodes[d];d++)if("block"==e.nodeName.toLowerCase()){var f=Blockly.Xml.domToBlock(a,e),g=parseInt(e.getAttribute("x"),10);e=parseInt(e.getAttribute("y"),10);isNaN(g)||isNaN(e)||f.moveBy(Blockly.RTL?c-g:g,e)}};
Blockly.Xml.domToBlock=function(a,b,c){var d=null,e=b.getAttribute("type");if(!e)throw"Block type unspecified: \n"+b.outerHTML;var f=b.getAttribute("id");if(c&&f){d=Blockly.Block.getById(f,a);if(!d)throw"Couldn't get Block with id: "+f;f=d.getParent();d.workspace&&d.dispose(!0,!1,!0);d.fill(a,e);d.parent_=f}else d=Blockly.Block.obtain(a,e);d.svg_||d.initSvg();(f=b.getAttribute("inline"))&&d.setInputsInline("true"==f);(f=b.getAttribute("disabled"))&&d.setDisabled("true"==f);(f=b.getAttribute("deletable"))&&
d.setDeletable("true"==f);(f=b.getAttribute("movable"))&&d.setMovable("true"==f);(f=b.getAttribute("editable"))&&d.setEditable("true"==f);for(var g=null,f=0,h;h=b.childNodes[f];f++)if(3!=h.nodeType||!h.data.match(/^\s*$/)){for(var g=null,k=0,l;l=h.childNodes[k];k++)3==l.nodeType&&l.data.match(/^\s*$/)||(g=l);k=h.getAttribute("name");switch(h.nodeName.toLowerCase()){case "mutation":d.domToMutation&&d.domToMutation(h);break;case "comment":d.setCommentText(h.textContent);var p=h.getAttribute("pinned");
p&&setTimeout(function(){d.comment.setVisible("true"==p)},1);g=parseInt(h.getAttribute("w"),10);h=parseInt(h.getAttribute("h"),10);isNaN(g)||isNaN(h)||d.comment.setBubbleSize(g,h);break;case "title":case "field":d.setFieldValue(h.textContent,k);break;case "value":case "statement":h=d.getInput(k);if(!h)throw"Input "+k+" does not exist in block "+e;if(g&&"block"==g.nodeName.toLowerCase())if(g=Blockly.Xml.domToBlock(a,g,c),g.outputConnection)h.connection.connect(g.outputConnection);else if(g.previousConnection)h.connection.connect(g.previousConnection);
......@@ -952,7 +952,7 @@ Blockly.Mutator.prototype.createEditor_=function(){this.svgDialog_=Blockly.creat
return this.svgDialog_};Blockly.Mutator.prototype.updateEditable=function(){this.block_.isEditable()?Blockly.Icon.prototype.updateEditable.call(this):(this.setVisible(!1),Blockly.removeClass_(this.iconGroup_,"blocklyIconGroup"))};
Blockly.Mutator.prototype.resizeBubble_=function(){var a=2*Blockly.Bubble.BORDER_WIDTH,b=this.workspace_.getCanvas().getBBox(),c=this.flyout_.getMetrics_(),d;d=Blockly.RTL?-b.x:b.width+b.x;b=Math.max(b.height+3*a,c.contentHeight+20);d+=3*a;if(Math.abs(this.workspaceWidth_-d)>a||Math.abs(this.workspaceHeight_-b)>a)this.workspaceWidth_=d,this.workspaceHeight_=b,this.bubble_.setBubbleSize(d+a,b+a),this.svgDialog_.setAttribute("width",this.workspaceWidth_),this.svgDialog_.setAttribute("height",this.workspaceHeight_);
Blockly.RTL&&(a="translate("+this.workspaceWidth_+",0)",this.workspace_.getCanvas().setAttribute("transform",a))};
Blockly.Mutator.prototype.setVisible=function(a){if(a!=this.isVisible())if(a){this.bubble_=new Blockly.Bubble(this.block_.workspace,this.createEditor_(),this.block_.svg_.svgPath_,this.iconX_,this.iconY_,null,null);var b=this;this.flyout_.init(this.workspace_);this.flyout_.show(this.quarkXml_);this.rootBlock_=this.block_.decompose(this.workspace_);a=this.rootBlock_.getDescendants();for(var c=0,d;d=a[c];c++)d.render();this.rootBlock_.setMovable(!1);this.rootBlock_.setDeletable(!1);a=2*this.flyout_.CORNER_RADIUS;
Blockly.Mutator.prototype.setVisible=function(a){if(a!=this.isVisible())if(a){this.bubble_=new Blockly.Bubble(this.block_.workspace,this.createEditor_(),this.block_.svg_.svgPath_,this.iconX_,this.iconY_,null,null);var b=this;this.flyout_.init(this.workspace_,!1);this.flyout_.show(this.quarkXml_);this.rootBlock_=this.block_.decompose(this.workspace_);a=this.rootBlock_.getDescendants();for(var c=0,d;d=a[c];c++)d.render();this.rootBlock_.setMovable(!1);this.rootBlock_.setDeletable(!1);a=2*this.flyout_.CORNER_RADIUS;
c=this.flyout_.width_+a;Blockly.RTL&&(c=-c);this.rootBlock_.moveBy(c,a);this.block_.saveConnections&&(this.block_.saveConnections(this.rootBlock_),this.sourceListener_=Blockly.bindEvent_(this.block_.workspace.getCanvas(),"blocklyWorkspaceChange",this.block_,function(){b.block_.saveConnections(b.rootBlock_)}));this.resizeBubble_();Blockly.bindEvent_(this.workspace_.getCanvas(),"blocklyWorkspaceChange",this.block_,function(){b.workspaceChanged_()});this.updateColour()}else this.svgDialog_=null,this.flyout_.dispose(),
this.flyout_=null,this.workspace_.dispose(),this.rootBlock_=this.workspace_=null,this.bubble_.dispose(),this.bubble_=null,this.workspaceHeight_=this.workspaceWidth_=0,this.sourceListener_&&(Blockly.unbindEvent_(this.sourceListener_),this.sourceListener_=null)};
Blockly.Mutator.prototype.workspaceChanged_=function(){if(0==Blockly.Block.dragMode_)for(var a=this.workspace_.getTopBlocks(!1),b=0,c;c=a[b];b++){var d=c.getRelativeToSurfaceXY(),e=c.getHeightWidth();c.isDeletable()&&(Blockly.RTL?d.x>-this.flyout_.width_+20:d.x<this.flyout_.width_-20)?c.dispose(!1,!0):20>d.y+e.height&&c.moveBy(0,20-e.height-d.y)}this.rootBlock_.workspace==this.workspace_&&(a=this.block_.rendered,this.block_.rendered=!1,this.block_.compose(this.rootBlock_),this.block_.rendered=a,this.block_.rendered&&
......@@ -971,7 +971,7 @@ Blockly.Block.prototype.initSvg=function(){this.svg_=new Blockly.BlockSvg(this);
Blockly.Block.terminateDrag_=function(){Blockly.Block.onMouseUpWrapper_&&(Blockly.unbindEvent_(Blockly.Block.onMouseUpWrapper_),Blockly.Block.onMouseUpWrapper_=null);Blockly.Block.onMouseMoveWrapper_&&(Blockly.unbindEvent_(Blockly.Block.onMouseMoveWrapper_),Blockly.Block.onMouseMoveWrapper_=null);var a=Blockly.selected;if(2==Blockly.Block.dragMode_&&a){var b=a.getRelativeToSurfaceXY();a.moveConnections_(b.x-a.startDragX,b.y-a.startDragY);delete a.draggedBubbles_;a.setDragging_(!1);a.render();goog.Timer.callOnce(a.bumpNeighbours_,
Blockly.BUMP_DELAY,a);Blockly.fireUiEvent(window,"resize")}a&&a.workspace.fireChangeEvent();Blockly.Block.dragMode_=0};Blockly.Block.prototype.select=function(){goog.asserts.assertObject(this.svg_,"Block is not rendered.");Blockly.selected&&Blockly.selected.unselect();Blockly.selected=this;this.svg_.addSelect();Blockly.fireUiEvent(this.workspace.getCanvas(),"blocklySelectChange")};
Blockly.Block.prototype.unselect=function(){goog.asserts.assertObject(this.svg_,"Block is not rendered.");Blockly.selected=null;this.svg_.removeSelect();Blockly.fireUiEvent(this.workspace.getCanvas(),"blocklySelectChange")};
Blockly.Block.prototype.dispose=function(a,b,c){this.rendered=!1;this.unplug(a,!1);b&&this.svg_&&this.svg_.disposeUiEffect();this.workspace&&!c&&(this.workspace.removeTopBlock(this),this.workspace=null);Blockly.selected==this&&(Blockly.selected=null,Blockly.terminateDrag_());Blockly.ContextMenu.currentBlock==this&&Blockly.ContextMenu.hide();for(a=this.childBlocks_.length-1;0<=a;a--)this.childBlocks_[a].dispose(!1);b=this.getIcons();for(a=0;a<b.length;a++)b[a].dispose();for(a=0;b=this.inputList[a];a++)b.dispose();
Blockly.Block.prototype.dispose=function(a,b,c){this.rendered=!1;this.unplug(a);b&&this.svg_&&this.svg_.disposeUiEffect();this.workspace&&!c&&(this.workspace.removeTopBlock(this),this.workspace=null);Blockly.selected==this&&(Blockly.selected=null,Blockly.terminateDrag_());Blockly.ContextMenu.currentBlock==this&&Blockly.ContextMenu.hide();for(a=this.childBlocks_.length-1;0<=a;a--)this.childBlocks_[a].dispose(!1);b=this.getIcons();for(a=0;a<b.length;a++)b[a].dispose();for(a=0;b=this.inputList[a];a++)b.dispose();
this.inputList=[];b=this.getConnections_(!0);for(a=0;a<b.length;a++)c=b[a],c.targetConnection&&c.disconnect(),b[a].dispose();this.svg_&&(this.svg_.dispose(),this.svg_=null);Blockly.Realtime.isEnabled()&&!Blockly.Realtime.withinSync&&Blockly.Realtime.removeBlock(this)};
Blockly.Block.prototype.unplug=function(a,b){b=b&&!!this.getParent();if(this.outputConnection)this.outputConnection.targetConnection&&this.setParent(null);else{var c=null;this.previousConnection&&this.previousConnection.targetConnection&&(c=this.previousConnection.targetConnection,this.setParent(null));var d=this.getNextBlock();if(a&&d){var e=this.nextConnection.targetConnection;d.setParent(null);c&&c.connect(e)}}b&&this.moveBy(Blockly.SNAP_RADIUS*(Blockly.RTL?-1:1),2*Blockly.SNAP_RADIUS)};
Blockly.Block.prototype.getRelativeToSurfaceXY=function(){var a=0,b=0;if(this.svg_){var c=this.svg_.getRootElement();do var d=Blockly.getRelativeXY_(c),a=a+d.x,b=b+d.y,c=c.parentNode;while(c&&c!=this.workspace.getCanvas())}return{x:a,y:b}};Blockly.Block.prototype.moveBy=function(a,b){var c=this.getRelativeToSurfaceXY();this.svg_.getRootElement().setAttribute("transform","translate("+(c.x+a)+", "+(c.y+b)+")");this.moveConnections_(a,b);Blockly.Realtime.blockChanged(this)};
......@@ -1068,11 +1068,11 @@ Blockly.Flyout.prototype.createDom=function(){this.svgGroup_=Blockly.createSvgEl
Blockly.Flyout.prototype.dispose=function(){this.hide();Blockly.unbindEvent_(this.eventWrappers_);this.eventWrappers_.length=0;this.scrollbar_&&(this.scrollbar_.dispose(),this.scrollbar_=null);this.workspace_=null;this.svgGroup_&&(goog.dom.removeNode(this.svgGroup_),this.svgGroup_=null);this.targetWorkspace_=this.svgBackground_=null};
Blockly.Flyout.prototype.getMetrics_=function(){if(!this.isVisible())return null;var a=this.height_-2*this.CORNER_RADIUS,b=this.width_;try{var c=this.workspace_.getCanvas().getBBox()}catch(d){c={height:0,y:0}}return{viewHeight:a,viewWidth:b,contentHeight:c.height+c.y,viewTop:-this.workspace_.scrollY,contentTop:0,absoluteTop:this.CORNER_RADIUS,absoluteLeft:0}};
Blockly.Flyout.prototype.setMetrics_=function(a){var b=this.getMetrics_();b&&(goog.isNumber(a.y)&&(this.workspace_.scrollY=-b.contentHeight*a.y-b.contentTop),a=this.workspace_.scrollY+b.absoluteTop,this.workspace_.getCanvas().setAttribute("transform","translate(0,"+a+")"))};
Blockly.Flyout.prototype.init=function(a){this.targetWorkspace_=a;this.scrollbar_=new Blockly.Scrollbar(this.workspace_,!1,!1);this.hide();this.eventWrappers_.concat(Blockly.bindEvent_(window,goog.events.EventType.RESIZE,this,this.position_));this.position_();this.eventWrappers_.concat(Blockly.bindEvent_(this.svgGroup_,"wheel",this,this.wheel_));this.eventWrappers_.concat(Blockly.bindEvent_(this.svgGroup_,"mousewheel",this,this.wheel_));this.eventWrappers_.concat(Blockly.bindEvent_(this.targetWorkspace_.getCanvas(),
"blocklyWorkspaceChange",this,this.filterForCapacity_));this.eventWrappers_.concat(Blockly.bindEvent_(this.svgGroup_,"mousedown",this,this.onMouseDown_))};
Blockly.Flyout.prototype.init=function(a,b){this.targetWorkspace_=a;b&&(this.scrollbar_=new Blockly.Scrollbar(this.workspace_,!1,!1));this.hide();this.eventWrappers_.concat(Blockly.bindEvent_(window,goog.events.EventType.RESIZE,this,this.position_));this.position_();this.eventWrappers_.concat(Blockly.bindEvent_(this.svgGroup_,"wheel",this,this.wheel_));this.eventWrappers_.concat(Blockly.bindEvent_(this.svgGroup_,"mousewheel",this,this.wheel_));this.eventWrappers_.concat(Blockly.bindEvent_(this.targetWorkspace_.getCanvas(),
"blocklyWorkspaceChange",this,this.filterForCapacity_))};
Blockly.Flyout.prototype.position_=function(){if(this.isVisible()){var a=this.targetWorkspace_.getMetrics();if(a){var b=this.width_-this.CORNER_RADIUS;Blockly.RTL&&(b*=-1);var c=["M "+(Blockly.RTL?this.width_:0)+",0"];c.push("h",b);c.push("a",this.CORNER_RADIUS,this.CORNER_RADIUS,0,0,Blockly.RTL?0:1,Blockly.RTL?-this.CORNER_RADIUS:this.CORNER_RADIUS,this.CORNER_RADIUS);c.push("v",Math.max(0,a.viewHeight-2*this.CORNER_RADIUS));c.push("a",this.CORNER_RADIUS,this.CORNER_RADIUS,0,0,Blockly.RTL?0:1,Blockly.RTL?
this.CORNER_RADIUS:-this.CORNER_RADIUS,this.CORNER_RADIUS);c.push("h",-b);c.push("z");this.svgBackground_.setAttribute("d",c.join(" "));b=a.absoluteLeft;Blockly.RTL&&(b+=a.viewWidth,b-=this.width_);this.svgGroup_.setAttribute("transform","translate("+b+","+a.absoluteTop+")");this.height_=a.viewHeight;this.scrollbar_&&this.scrollbar_.resize()}}};
Blockly.Flyout.prototype.wheel_=function(a){var b=a.deltaY||-a.wheelDeltaY;if(b){goog.userAgent.GECKO&&(b*=10);var c=this.getMetrics_(),b=c.viewTop+b,b=Math.min(b,c.contentHeight-c.viewHeight),b=Math.max(b,0);this.scrollbar_.set(b);a.preventDefault()}};Blockly.Flyout.prototype.isVisible=function(){return this.svgGroup_&&"block"==this.svgGroup_.style.display};
Blockly.Flyout.prototype.wheel_=function(a){var b=a.deltaY||-a.wheelDeltaY;if(b){goog.userAgent.GECKO&&(b*=10);var c=this.getMetrics_(),b=c.viewTop+b,b=Math.max(b,0),b=Math.min(b,c.contentHeight-c.viewHeight);this.scrollbar_.set(b);a.preventDefault()}};Blockly.Flyout.prototype.isVisible=function(){return this.svgGroup_&&"block"==this.svgGroup_.style.display};
Blockly.Flyout.prototype.hide=function(){if(this.isVisible()){this.svgGroup_.style.display="none";for(var a=0,b;b=this.listeners_[a];a++)Blockly.unbindEvent_(b);this.listeners_.length=0;this.reflowWrapper_&&(Blockly.unbindEvent_(this.reflowWrapper_),this.reflowWrapper_=null)}};
Blockly.Flyout.prototype.show=function(a){this.hide();for(var b=this.workspace_.getTopBlocks(!1),c=0,d;d=b[c];c++)d.workspace==this.workspace_&&d.dispose(!1,!1);for(var c=0,e;e=this.buttons_[c];c++)goog.dom.removeNode(e);this.buttons_.length=0;var f=this.CORNER_RADIUS;this.svgGroup_.style.display="block";var b=[],g=[];if(a==Blockly.Variables.NAME_TYPE)Blockly.Variables.flyoutCategory(b,g,f,this.workspace_);else if(a==Blockly.Procedures.NAME_TYPE)Blockly.Procedures.flyoutCategory(b,g,f,this.workspace_);
else for(var h=0;d=a[h];h++)d.tagName&&"BLOCK"==d.tagName.toUpperCase()&&(d=Blockly.Xml.domToBlock(this.workspace_,d),b.push(d),g.push(3*f));a=f;for(h=0;d=b[h];h++){c=d.getDescendants();e=0;for(var k;k=c[e];e++)k.isInFlyout=!0,k.setCommentText(null);d.render();k=d.getSvgRoot();e=d.getHeightWidth();c=Blockly.RTL?0:f+Blockly.BlockSvg.TAB_WIDTH;d.moveBy(c,a);a+=e.height+g[h];e=Blockly.createSvgElement("rect",{"fill-opacity":0},null);this.workspace_.getCanvas().insertBefore(e,d.getSvgRoot());d.flyoutRect_=
......@@ -1080,19 +1080,16 @@ e;this.buttons_[h]=e;this.autoClose?this.listeners_.push(Blockly.bindEvent_(k,"m
d.svg_,d.svg_.addSelect));this.listeners_.push(Blockly.bindEvent_(e,"mouseout",d.svg_,d.svg_.removeSelect))}this.listeners_.push(Blockly.bindEvent_(this.svgBackground_,"mouseover",this,function(a){a=this.workspace_.getTopBlocks(!1);for(var b=0,c;c=a[b];b++)c.svg_.removeSelect()}));this.width_=0;this.reflow();this.filterForCapacity_();Blockly.fireUiEventNow(window,"resize");this.reflowWrapper_=Blockly.bindEvent_(this.workspace_.getCanvas(),"blocklyWorkspaceChange",this,this.reflow);this.workspace_.fireChangeEvent()};
Blockly.Flyout.prototype.reflow=function(){for(var a=0,b=this.CORNER_RADIUS,c=this.workspace_.getTopBlocks(!1),d=0,e;e=c[d];d++){e.getSvgRoot();var f=e.getHeightWidth(),a=Math.max(a,f.width)}a+=b+Blockly.BlockSvg.TAB_WIDTH+b/2+Blockly.Scrollbar.scrollbarThickness;if(this.width_!=a){for(d=0;e=c[d];d++){var f=e.getHeightWidth(),g=e.getRelativeToSurfaceXY();if(Blockly.RTL){var h=a-b-Blockly.BlockSvg.TAB_WIDTH-g.x;e.moveBy(h,0);g.x+=h}e.flyoutRect_&&(e.flyoutRect_.setAttribute("width",f.width),e.flyoutRect_.setAttribute("height",
f.height),e.flyoutRect_.setAttribute("x",Blockly.RTL?g.x-f.width:g.x),e.flyoutRect_.setAttribute("y",g.y))}this.width_=a;Blockly.fireUiEvent(window,"resize")}};Blockly.Block.prototype.moveTo=function(a,b){var c=this.getRelativeToSurfaceXY();this.svg_.getRootElement().setAttribute("transform","translate("+a+", "+b+")");this.moveConnections_(a-c.x,b-c.y)};
Blockly.Flyout.prototype.blockMouseDown_=function(a){var b=this;return function(c){Blockly.terminateDrag_();Blockly.hideChaff();Blockly.isRightButton(c)?a.showContextMenu_(c):(Blockly.removeAllRanges(),Blockly.setCursorHand_(!0),Blockly.Flyout.startDownEvent_=c,Blockly.Flyout.startBlock_=a,Blockly.Flyout.startFlyout_=b,Blockly.Flyout.onMouseUpWrapper_=Blockly.bindEvent_(document,"mouseup",this,Blockly.terminateDrag_),Blockly.Flyout.onMouseMoveBlockWrapper_=Blockly.bindEvent_(document,"mousemove",
this,b.onMouseMoveBlock_));c.stopPropagation()}};Blockly.Flyout.prototype.onMouseDown_=function(a){Blockly.isRightButton(a)||(Blockly.hideChaff(!0),Blockly.Flyout.terminateDrag_(),this.startDragMouseY_=a.clientY,Blockly.Flyout.onMouseMoveWrapper_=Blockly.bindEvent_(document,"mousemove",this,this.onMouseMove_),Blockly.Flyout.onMouseUpWrapper_=Blockly.bindEvent_(document,"mouseup",this,Blockly.Flyout.terminateDrag_),a.preventDefault(),a.stopPropagation())};
Blockly.Flyout.prototype.onMouseMove_=function(a){var b=a.clientY-this.startDragMouseY_;this.startDragMouseY_=a.clientY;a=this.getMetrics_();b=a.viewTop-b;b=Math.min(b,a.contentHeight-a.viewHeight);b=Math.max(b,0);this.scrollbar_.set(b)};
Blockly.Flyout.prototype.onMouseMoveBlock_=function(a){if("mousemove"==a.type&&1>=a.clientX&&0==a.clientY&&0==a.button)a.stopPropagation();else{Blockly.removeAllRanges();var b=a.clientY-Blockly.Flyout.startDownEvent_.clientY;Math.sqrt(Math.pow(a.clientX-Blockly.Flyout.startDownEvent_.clientX,2)+Math.pow(b,2))>Blockly.DRAG_RADIUS&&Blockly.Flyout.startFlyout_.createBlockFunc_(Blockly.Flyout.startBlock_)(Blockly.Flyout.startDownEvent_)}};
Blockly.Flyout.prototype.blockMouseDown_=function(a){var b=this;return function(c){Blockly.terminateDrag_();Blockly.hideChaff();Blockly.isRightButton(c)?a.showContextMenu_(c):(Blockly.removeAllRanges(),Blockly.setCursorHand_(!0),Blockly.Flyout.startDownEvent_=c,Blockly.Flyout.startBlock_=a,Blockly.Flyout.startFlyout_=b,Blockly.Flyout.onMouseUpWrapper_=Blockly.bindEvent_(document,"mouseup",this,Blockly.terminateDrag_),Blockly.Flyout.onMouseMoveWrapper_=Blockly.bindEvent_(document,"mousemove",this,
b.onMouseMove_));c.stopPropagation()}};Blockly.Flyout.prototype.onMouseMove_=function(a){if("mousemove"==a.type&&1>=a.clientX&&0==a.clientY&&0==a.button)a.stopPropagation();else{Blockly.removeAllRanges();var b=a.clientY-Blockly.Flyout.startDownEvent_.clientY;Math.sqrt(Math.pow(a.clientX-Blockly.Flyout.startDownEvent_.clientX,2)+Math.pow(b,2))>Blockly.DRAG_RADIUS&&Blockly.Flyout.startFlyout_.createBlockFunc_(Blockly.Flyout.startBlock_)(Blockly.Flyout.startDownEvent_)}};
Blockly.Flyout.prototype.createBlockFunc_=function(a){var b=this;return function(c){if(!Blockly.isRightButton(c)&&!a.disabled){var d=Blockly.Xml.blockToDom_(a),d=Blockly.Xml.domToBlock(b.targetWorkspace_,d),e=a.getSvgRoot();if(!e)throw"originBlock is not rendered.";var e=Blockly.getSvgXY_(e),f=d.getSvgRoot();if(!f)throw"block is not rendered.";f=Blockly.getSvgXY_(f);d.moveBy(e.x-f.x,e.y-f.y);b.autoClose?b.hide():b.filterForCapacity_();d.onMouseDown_(c)}}};
Blockly.Flyout.prototype.filterForCapacity_=function(){for(var a=this.targetWorkspace_.remainingCapacity(),b=this.workspace_.getTopBlocks(!1),c=0,d;d=b[c];c++){var e=d.getDescendants().length>a;d.setDisabled(e)}};
Blockly.Flyout.terminateDrag_=function(){Blockly.Flyout.onMouseUpWrapper_&&(Blockly.unbindEvent_(Blockly.Flyout.onMouseUpWrapper_),Blockly.Flyout.onMouseUpWrapper_=null);Blockly.Flyout.onMouseMoveBlockWrapper_&&(Blockly.unbindEvent_(Blockly.Flyout.onMouseMoveBlockWrapper_),Blockly.Flyout.onMouseMoveBlockWrapper_=null);Blockly.Flyout.onMouseMoveWrapper_&&(Blockly.unbindEvent_(Blockly.Flyout.onMouseMoveWrapper_),Blockly.Flyout.onMouseMoveWrapper_=null);Blockly.Flyout.onMouseUpWrapper_&&(Blockly.unbindEvent_(Blockly.Flyout.onMouseUpWrapper_),
Blockly.Flyout.onMouseUpWrapper_=null);Blockly.Flyout.startDownEvent_=null;Blockly.Flyout.startBlock_=null;Blockly.Flyout.startFlyout_=null};
Blockly.Flyout.terminateDrag_=function(){Blockly.Flyout.onMouseUpWrapper_&&(Blockly.unbindEvent_(Blockly.Flyout.onMouseUpWrapper_),Blockly.Flyout.onMouseUpWrapper_=null);Blockly.Flyout.onMouseMoveWrapper_&&(Blockly.unbindEvent_(Blockly.Flyout.onMouseMoveWrapper_),Blockly.Flyout.onMouseMoveWrapper_=null);Blockly.Flyout.startDownEvent_=null;Blockly.Flyout.startBlock_=null;Blockly.Flyout.startFlyout_=null};
// Copyright 2011 Google Inc. Apache License 2.0
Blockly.Toolbox={};Blockly.Toolbox.width=0;Blockly.Toolbox.selectedOption_=null;Blockly.Toolbox.CONFIG_={indentWidth:19,cssRoot:"blocklyTreeRoot",cssHideRoot:"blocklyHidden",cssItem:"",cssTreeRow:"blocklyTreeRow",cssItemLabel:"blocklyTreeLabel",cssTreeIcon:"blocklyTreeIcon",cssExpandedFolderIcon:"blocklyTreeIconOpen",cssFileIcon:"blocklyTreeIconNone",cssSelectedRow:"blocklyTreeSelected"};
Blockly.Toolbox.createDom=function(a,b){Blockly.Toolbox.HtmlDiv=goog.dom.createDom("div","blocklyToolboxDiv");Blockly.Toolbox.HtmlDiv.setAttribute("dir",Blockly.RTL?"RTL":"LTR");b.appendChild(Blockly.Toolbox.HtmlDiv);Blockly.Toolbox.flyout_=new Blockly.Flyout;a.appendChild(Blockly.Toolbox.flyout_.createDom());Blockly.bindEvent_(Blockly.Toolbox.HtmlDiv,"mousedown",null,function(a){Blockly.isRightButton(a)||a.target==Blockly.Toolbox.HtmlDiv?Blockly.hideChaff(!1):Blockly.hideChaff(!0)})};
Blockly.Toolbox.init=function(){Blockly.Toolbox.CONFIG_.cleardotPath=Blockly.pathToBlockly+"media/1x1.gif";Blockly.Toolbox.CONFIG_.cssCollapsedFolderIcon="blocklyTreeIconClosed"+(Blockly.RTL?"Rtl":"Ltr");var a=new Blockly.Toolbox.TreeControl(goog.html.SafeHtml.EMPTY,Blockly.Toolbox.CONFIG_);Blockly.Toolbox.tree_=a;a.setShowRootNode(!1);a.setShowLines(!1);a.setShowExpandIcons(!1);a.setSelectedItem(null);Blockly.Toolbox.HtmlDiv.style.display="block";Blockly.Toolbox.flyout_.init(Blockly.mainWorkspace);
Blockly.Toolbox.populate_();a.render(Blockly.Toolbox.HtmlDiv);goog.events.listen(window,goog.events.EventType.RESIZE,Blockly.Toolbox.position_);Blockly.Toolbox.position_()};
Blockly.Toolbox.init=function(){Blockly.Toolbox.CONFIG_.cleardotPath=Blockly.pathToBlockly+"media/1x1.gif";Blockly.Toolbox.CONFIG_.cssCollapsedFolderIcon="blocklyTreeIconClosed"+(Blockly.RTL?"Rtl":"Ltr");var a=new Blockly.Toolbox.TreeControl(goog.html.SafeHtml.EMPTY,Blockly.Toolbox.CONFIG_);Blockly.Toolbox.tree_=a;a.setShowRootNode(!1);a.setShowLines(!1);a.setShowExpandIcons(!1);a.setSelectedItem(null);Blockly.Toolbox.HtmlDiv.style.display="block";Blockly.Toolbox.flyout_.init(Blockly.mainWorkspace,
!0);Blockly.Toolbox.populate_();a.render(Blockly.Toolbox.HtmlDiv);goog.events.listen(window,goog.events.EventType.RESIZE,Blockly.Toolbox.position_);Blockly.Toolbox.position_()};
Blockly.Toolbox.position_=function(){var a=Blockly.Toolbox.HtmlDiv,b=goog.style.getBorderBox(Blockly.svg),c=Blockly.svgSize();Blockly.RTL?(b=Blockly.convertCoordinates(0,0,!1),a.style.left=b.x+c.width-a.offsetWidth+"px"):a.style.marginLeft=b.left;a.style.height=c.height+1+"px";Blockly.Toolbox.width=a.offsetWidth;Blockly.RTL||(Blockly.Toolbox.width-=1)};
Blockly.Toolbox.populate_=function(){function a(c,d){for(var e=0,f;f=c.childNodes[e];e++)if(f.tagName){var g=f.tagName.toUpperCase();if("CATEGORY"==g){g=b.createNode(f.getAttribute("name"));g.blocks=[];d.add(g);var h=f.getAttribute("custom");h?g.blocks=h:a(f,g)}else"BLOCK"==g&&d.blocks.push(f)}}var b=Blockly.Toolbox.tree_;b.removeChildren();b.blocks=[];a(Blockly.languageTree,Blockly.Toolbox.tree_);if(b.blocks.length)throw"Toolbox cannot have both blocks and categories in the root level.";Blockly.fireUiEvent(window,
"resize")};Blockly.Toolbox.clearSelection=function(){Blockly.Toolbox.tree_.setSelectedItem(null)};Blockly.Toolbox.TreeControl=function(a,b,c){goog.ui.tree.TreeControl.call(this,a,b,c)};goog.inherits(Blockly.Toolbox.TreeControl,goog.ui.tree.TreeControl);
......@@ -1111,13 +1108,14 @@ Blockly.FieldVariable.prototype.clone=function(){return new Blockly.FieldVariabl
Blockly.FieldVariable.dropdownCreate=function(){var a=Blockly.Variables.allVariables(),b=this.getText();b&&-1==a.indexOf(b)&&a.push(b);a.sort(goog.string.caseInsensitiveCompare);a.push(Blockly.Msg.RENAME_VARIABLE);a.push(Blockly.Msg.NEW_VARIABLE);for(var b=[],c=0;c<a.length;c++)b[c]=[a[c],a[c]];return b};
Blockly.FieldVariable.dropdownChange=function(a){function b(a,b){Blockly.hideChaff();var c=window.prompt(a,b);return c&&c.replace(/[\s\xa0]+/g," ").replace(/^ | $/g,"")}if(a==Blockly.Msg.RENAME_VARIABLE){var c=this.getText();(a=b(Blockly.Msg.RENAME_VARIABLE_TITLE.replace("%1",c),c))&&Blockly.Variables.renameVariable(c,a);return null}if(a==Blockly.Msg.NEW_VARIABLE)return(a=b(Blockly.Msg.NEW_VARIABLE_TITLE,""))?(Blockly.Variables.renameVariable(a,a),a):null};
// Copyright 2012 Google Inc. Apache License 2.0
Blockly.Generator=function(a){this.name_=a;this.RESERVED_WORDS_="";this.FUNCTION_NAME_PLACEHOLDER_REGEXP_=new RegExp(this.FUNCTION_NAME_PLACEHOLDER_,"g")};Blockly.Generator.NAME_TYPE="generated_function";Blockly.Generator.prototype.INFINITE_LOOP_TRAP=null;Blockly.Generator.prototype.STATEMENT_PREFIX=null;
Blockly.Generator=function(a){this.name_=a;this.RESERVED_WORDS_=""};Blockly.Generator.NAME_TYPE="generated_function";Blockly.Generator.prototype.INFINITE_LOOP_TRAP=null;Blockly.Generator.prototype.STATEMENT_PREFIX=null;
Blockly.Generator.prototype.workspaceToCode=function(){var a=[];this.init();for(var b=Blockly.mainWorkspace.getTopBlocks(!0),c=0,d;d=b[c];c++){var e=this.blockToCode(d);goog.isArray(e)&&(e=e[0]);e&&(d.outputConnection&&this.scrubNakedValue&&(e=this.scrubNakedValue(e)),a.push(e))}a=a.join("\n");a=this.finish(a);a=a.replace(/^\s+\n/,"");a=a.replace(/\n\s+$/,"\n");return a=a.replace(/[ \t]+\n/g,"\n")};Blockly.Generator.prototype.prefixLines=function(a,b){return b+a.replace(/\n(.)/g,"\n"+b+"$1")};
Blockly.Generator.prototype.allNestedComments=function(a){var b=[];a=a.getDescendants();for(var c=0;c<a.length;c++){var d=a[c].getCommentText();d&&b.push(d)}b.length&&b.push("");return b.join("\n")};
Blockly.Generator.prototype.blockToCode=function(a){if(!a)return"";if(a.disabled)return this.blockToCode(a.getNextBlock());var b=this[a.type];if(!b)throw'Language "'+this.name_+'" does not know how to generate code for block type "'+a.type+'".';b=b.call(a,a);if(goog.isArray(b))return[this.scrub_(a,b[0]),b[1]];if(goog.isString(b))return this.STATEMENT_PREFIX&&(b=this.STATEMENT_PREFIX.replace(/%1/g,"'"+a.id+"'")+b),this.scrub_(a,b);if(null===b)return"";throw"Invalid code generated: "+b;};
Blockly.Generator.prototype.valueToCode=function(a,b,c){if(isNaN(c))throw'Expecting valid order from block "'+a.type+'".';a=a.getInputTargetBlock(b);if(!a)return"";var d=this.blockToCode(a);if(""===d)return"";if(!goog.isArray(d))throw'Expecting tuple from value block "'+a.type+'".';b=d[0];d=d[1];if(isNaN(d))throw'Expecting valid order from value block "'+a.type+'".';b&&c<=d&&c!=d&&0!=c&&99!=c&&(b="("+b+")");return b};
Blockly.Generator.prototype.statementToCode=function(a,b){var c=a.getInputTargetBlock(b),d=this.blockToCode(c);if(!goog.isString(d))throw'Expecting code from statement block "'+c.type+'".';d&&(d=this.prefixLines(d,this.INDENT));return d};Blockly.Generator.prototype.addLoopTrap=function(a,b){this.INFINITE_LOOP_TRAP&&(a=this.INFINITE_LOOP_TRAP.replace(/%1/g,"'"+b+"'")+a);this.STATEMENT_PREFIX&&(a+=this.prefixLines(this.STATEMENT_PREFIX.replace(/%1/g,"'"+b+"'"),this.INDENT));return a};
Blockly.Generator.prototype.INDENT=" ";Blockly.Generator.prototype.addReservedWords=function(a){this.RESERVED_WORDS_+=a+","};Blockly.Generator.prototype.FUNCTION_NAME_PLACEHOLDER_="{leCUI8hutHZI4480Dc}";Blockly.Generator.prototype.provideFunction_=function(a,b){if(!this.definitions_[a]){var c=this.variableDB_.getDistinctName(a,this.NAME_TYPE);this.functionNames_[a]=c;this.definitions_[a]=b.join("\n").replace(this.FUNCTION_NAME_PLACEHOLDER_REGEXP_,c)}return this.functionNames_[a]};
Blockly.Generator.prototype.INDENT=" ";Blockly.Generator.prototype.addReservedWords=function(a){this.RESERVED_WORDS_+=a+","};Blockly.Generator.prototype.FUNCTION_NAME_PLACEHOLDER_="{leCUI8hutHZI4480Dc}";Blockly.Generator.prototype.FUNCTION_NAME_PLACEHOLDER_REGEXP_=new RegExp(Blockly.Generator.prototype.FUNCTION_NAME_PLACEHOLDER_,"g");
Blockly.Generator.prototype.provideFunction_=function(a,b){if(!this.definitions_[a]){var c=this.variableDB_.getDistinctName(a,this.NAME_TYPE);this.functionNames_[a]=c;this.definitions_[a]=b.join("\n").replace(this.FUNCTION_NAME_PLACEHOLDER_REGEXP_,c)}return this.functionNames_[a]};
// Copyright 2012 Google Inc. Apache License 2.0
Blockly.Names=function(a){this.reservedDict_=Object.create(null);if(a){a=a.split(",");for(var b=0;b<a.length;b++)this.reservedDict_[a[b]]=!0}this.reset()};Blockly.Names.prototype.reset=function(){this.db_=Object.create(null);this.dbReverse_=Object.create(null)};Blockly.Names.prototype.getName=function(a,b){var c=a.toLowerCase()+"_"+b;if(c in this.db_)return this.db_[c];var d=this.getDistinctName(a,b);return this.db_[c]=d};
Blockly.Names.prototype.getDistinctName=function(a,b){for(var c=this.safeName_(a),d="";this.dbReverse_[c+d]||c+d in this.reservedDict_;)d=d?d+1:2;c+=d;this.dbReverse_[c]=!0;return c};Blockly.Names.prototype.safeName_=function(a){a?(a=encodeURI(a.replace(/ /g,"_")).replace(/[^\w]/g,"_"),-1!="0123456789".indexOf(a[0])&&(a="my_"+a)):a="unnamed";return a};Blockly.Names.equals=function(a,b){return a.toLowerCase()==b.toLowerCase()};
......@@ -1199,13 +1197,13 @@ Blockly.createDom_=function(a){a.setAttribute("dir","LTR");goog.ui.Component.set
stdDeviation:1,result:"blur"},d);e=Blockly.createSvgElement("feSpecularLighting",{"in":"blur",surfaceScale:1,specularConstant:.5,specularExponent:10,"lighting-color":"white",result:"specOut"},d);Blockly.createSvgElement("fePointLight",{x:-5E3,y:-1E4,z:2E4},e);Blockly.createSvgElement("feComposite",{"in":"specOut",in2:"SourceAlpha",operator:"in",result:"specOut"},d);Blockly.createSvgElement("feComposite",{"in":"SourceGraphic",in2:"specOut",operator:"arithmetic",k1:0,k2:1,k3:1,k4:0},d);d=Blockly.createSvgElement("filter",
{id:"blocklyTrashcanShadowFilter"},c);Blockly.createSvgElement("feGaussianBlur",{"in":"SourceAlpha",stdDeviation:2,result:"blur"},d);Blockly.createSvgElement("feOffset",{"in":"blur",dx:1,dy:1,result:"offsetBlur"},d);d=Blockly.createSvgElement("feMerge",{},d);Blockly.createSvgElement("feMergeNode",{"in":"offsetBlur"},d);Blockly.createSvgElement("feMergeNode",{"in":"SourceGraphic"},d);d=Blockly.createSvgElement("filter",{id:"blocklyShadowFilter"},c);Blockly.createSvgElement("feGaussianBlur",{stdDeviation:2},
d);c=Blockly.createSvgElement("pattern",{id:"blocklyDisabledPattern",patternUnits:"userSpaceOnUse",width:10,height:10},c);Blockly.createSvgElement("rect",{width:10,height:10,fill:"#aaa"},c);Blockly.createSvgElement("path",{d:"M 0 0 L 10 10 M 10 0 L 0 10",stroke:"#cc0"},c);Blockly.mainWorkspace=new Blockly.Workspace(Blockly.getMainWorkspaceMetrics_,Blockly.setMainWorkspaceMetrics_);b.appendChild(Blockly.mainWorkspace.createDom());Blockly.mainWorkspace.maxBlocks=Blockly.maxBlocks;Blockly.readOnly||
(Blockly.hasCategories?Blockly.Toolbox.createDom(b,a):(Blockly.mainWorkspace.flyout_=new Blockly.Flyout,c=Blockly.mainWorkspace.flyout_,d=c.createDom(),c.autoClose=!1,goog.dom.insertSiblingBefore(d,Blockly.mainWorkspace.svgGroup_),Blockly.addChangeListener(function(){if(0==Blockly.Block.dragMode_){var a=Blockly.mainWorkspace.getMetrics();if(0>a.contentTop||a.contentTop+a.contentHeight>a.viewHeight+a.viewTop||a.contentLeft<(Blockly.RTL?a.viewLeft:0)||a.contentLeft+a.contentWidth>(Blockly.RTL?a.viewWidth:
a.viewWidth+a.viewLeft))for(var b=Blockly.mainWorkspace.getTopBlocks(!1),c=0,d;d=b[c];c++){var e=d.getRelativeToSurfaceXY(),p=d.getHeightWidth(),m=a.viewTop+25-p.height-e.y;0<m&&d.moveBy(0,m);m=a.viewTop+a.viewHeight-25-e.y;0>m&&d.moveBy(0,m);m=25+a.viewLeft-e.x-(Blockly.RTL?0:p.width);0<m&&d.moveBy(m,0);m=a.viewLeft+a.viewWidth-25-e.x+(Blockly.RTL?p.width:0);0>m&&d.moveBy(m,0);d.isDeletable()&&50<(Blockly.RTL?e.x-a.viewWidth:-e.x)&&d.dispose(!1,!0)}}})));b.appendChild(Blockly.Tooltip.createDom());
(Blockly.hasCategories?Blockly.Toolbox.createDom(b,a):(Blockly.mainWorkspace.flyout_=new Blockly.Flyout,c=Blockly.mainWorkspace.flyout_,d=c.createDom(),c.init(Blockly.mainWorkspace,!0),c.autoClose=!1,goog.dom.insertSiblingBefore(d,Blockly.mainWorkspace.svgGroup_),Blockly.addChangeListener(function(){if(0==Blockly.Block.dragMode_){var a=Blockly.mainWorkspace.getMetrics();if(0>a.contentTop||a.contentTop+a.contentHeight>a.viewHeight+a.viewTop||a.contentLeft<(Blockly.RTL?a.viewLeft:0)||a.contentLeft+
a.contentWidth>(Blockly.RTL?a.viewWidth:a.viewWidth+a.viewLeft))for(var b=Blockly.mainWorkspace.getTopBlocks(!1),c=0,d;d=b[c];c++){var e=d.getRelativeToSurfaceXY(),p=d.getHeightWidth(),m=a.viewTop+25-p.height-e.y;0<m&&d.moveBy(0,m);m=a.viewTop+a.viewHeight-25-e.y;0>m&&d.moveBy(0,m);m=25+a.viewLeft-e.x-(Blockly.RTL?0:p.width);0<m&&d.moveBy(m,0);m=a.viewLeft+a.viewWidth-25-e.x+(Blockly.RTL?p.width:0);0>m&&d.moveBy(m,0);d.isDeletable()&&50<(Blockly.RTL?e.x-a.viewWidth:-e.x)&&d.dispose(!1,!0)}}})));b.appendChild(Blockly.Tooltip.createDom());
a.appendChild(b);Blockly.svg=b;Blockly.svgResize();Blockly.WidgetDiv.DIV=goog.dom.createDom("div","blocklyWidgetDiv");Blockly.WidgetDiv.DIV.style.direction=Blockly.RTL?"rtl":"ltr";document.body.appendChild(Blockly.WidgetDiv.DIV)};
Blockly.init_=function(){var a=[],b=function(){for(;a.length;)Blockly.unbindEvent_(a.pop());Blockly.preloadAudio_()};a.push(Blockly.bindEvent_(document,"mousemove",null,b));a.push(Blockly.bindEvent_(document,"touchstart",null,b));Blockly.bindEvent_(Blockly.svg,"mousedown",null,Blockly.onMouseDown_);Blockly.bindEvent_(Blockly.svg,"contextmenu",null,Blockly.onContextMenu_);Blockly.bindEvent_(Blockly.WidgetDiv.DIV,"contextmenu",null,Blockly.onContextMenu_);Blockly.documentEventsBound_||(Blockly.bindEvent_(window,
"resize",document,Blockly.svgResize),Blockly.bindEvent_(document,"keydown",null,Blockly.onKeyDown_),document.addEventListener("mouseup",Blockly.onMouseUp_,!1),goog.userAgent.IPAD&&Blockly.bindEvent_(window,"orientationchange",document,function(){Blockly.fireUiEvent(window,"resize")}),Blockly.documentEventsBound_=!0);Blockly.languageTree&&(Blockly.hasCategories?Blockly.Toolbox.init():(Blockly.mainWorkspace.flyout_.init(Blockly.mainWorkspace),Blockly.mainWorkspace.flyout_.show(Blockly.languageTree.childNodes),
Blockly.mainWorkspace.scrollX=Blockly.mainWorkspace.flyout_.width_,Blockly.RTL&&(Blockly.mainWorkspace.scrollX*=-1),b="translate("+Blockly.mainWorkspace.scrollX+", 0)",Blockly.mainWorkspace.getCanvas().setAttribute("transform",b),Blockly.mainWorkspace.getBubbleCanvas().setAttribute("transform",b)));Blockly.hasScrollbars&&(Blockly.mainWorkspace.scrollbar=new Blockly.ScrollbarPair(Blockly.mainWorkspace),Blockly.mainWorkspace.scrollbar.resize());Blockly.mainWorkspace.addTrashcan();Blockly.loadAudio_(["media/click.mp3",
"media/click.wav","media/click.ogg"],"click");Blockly.loadAudio_(["media/delete.mp3","media/delete.ogg","media/delete.wav"],"delete")};
Blockly.init_=function(){var a=[],b=function(){for(;a.length;)Blockly.unbindEvent_(a.pop());Blockly.preloadAudio_()};a.push(Blockly.bindEvent_(document,"mousemove",null,b));a.push(Blockly.bindEvent_(document,"touchstart",null,b));Blockly.bindEvent_(Blockly.svg,"mousedown",null,Blockly.onMouseDown_);Blockly.bindEvent_(Blockly.svg,"mousemove",null,Blockly.onMouseMove_);Blockly.bindEvent_(Blockly.svg,"contextmenu",null,Blockly.onContextMenu_);Blockly.bindEvent_(Blockly.WidgetDiv.DIV,"contextmenu",null,
Blockly.onContextMenu_);Blockly.documentEventsBound_||(Blockly.bindEvent_(window,"resize",document,Blockly.svgResize),Blockly.bindEvent_(document,"keydown",null,Blockly.onKeyDown_),document.addEventListener("mouseup",Blockly.onMouseUp_,!1),goog.userAgent.IPAD&&Blockly.bindEvent_(window,"orientationchange",document,function(){Blockly.fireUiEvent(window,"resize")}),Blockly.documentEventsBound_=!0);Blockly.languageTree&&(Blockly.hasCategories?Blockly.Toolbox.init():(Blockly.mainWorkspace.flyout_.init(Blockly.mainWorkspace,
!0),Blockly.mainWorkspace.flyout_.show(Blockly.languageTree.childNodes),Blockly.mainWorkspace.scrollX=Blockly.mainWorkspace.flyout_.width_,Blockly.RTL&&(Blockly.mainWorkspace.scrollX*=-1),b="translate("+Blockly.mainWorkspace.scrollX+", 0)",Blockly.mainWorkspace.getCanvas().setAttribute("transform",b),Blockly.mainWorkspace.getBubbleCanvas().setAttribute("transform",b)));Blockly.hasScrollbars&&(Blockly.mainWorkspace.scrollbar=new Blockly.ScrollbarPair(Blockly.mainWorkspace),Blockly.mainWorkspace.scrollbar.resize());
Blockly.mainWorkspace.addTrashcan();Blockly.loadAudio_(["media/click.mp3","media/click.wav","media/click.ogg"],"click");Blockly.loadAudio_(["media/delete.mp3","media/delete.ogg","media/delete.wav"],"delete")};
Blockly.updateToolbox=function(a){if(a=Blockly.parseToolboxTree_(a)){if(!Blockly.languageTree)throw"Existing toolbox is null. Can't create new toolbox.";if(a.getElementsByTagName("category").length){if(!Blockly.hasCategories)throw"Existing toolbox has no categories. Can't change mode.";Blockly.languageTree=a;Blockly.Toolbox.populate_()}else{if(Blockly.hasCategories)throw"Existing toolbox has categories. Can't change mode.";Blockly.languageTree=a;Blockly.mainWorkspace.flyout_.show(Blockly.languageTree.childNodes)}}else if(Blockly.languageTree)throw"Can't nullify an existing toolbox.";
};
// Copyright 2012 Google Inc. Apache License 2.0
......@@ -1224,8 +1222,8 @@ Blockly.ALIGN_RIGHT=1;Blockly.OPPOSITE_TYPE=[];Blockly.OPPOSITE_TYPE[Blockly.INP
Blockly.SNAP_RADIUS=20;Blockly.BUMP_DELAY=250;Blockly.COLLAPSE_CHARS=30;Blockly.mainWorkspace=null;Blockly.clipboard_=null;Blockly.onTouchUpWrapper_=null;Blockly.svgSize=function(){return{width:Blockly.svg.cachedWidth_,height:Blockly.svg.cachedHeight_}};
Blockly.svgResize=function(){var a=Blockly.svg,b=a.parentNode,c=b.offsetWidth,b=b.offsetHeight;a.cachedWidth_!=c&&(a.setAttribute("width",c+"px"),a.cachedWidth_=c);a.cachedHeight_!=b&&(a.setAttribute("height",b+"px"),a.cachedHeight_=b);Blockly.mainWorkspace.scrollbar&&Blockly.mainWorkspace.scrollbar.resize()};
Blockly.onMouseDown_=function(a){Blockly.svgResize();Blockly.terminateDrag_();Blockly.hideChaff();var b=a.target&&a.target.nodeName&&"svg"==a.target.nodeName.toLowerCase();!Blockly.readOnly&&Blockly.selected&&b&&Blockly.selected.unselect();a.target==Blockly.svg&&Blockly.isRightButton(a)?Blockly.showContextMenu_(a):(Blockly.readOnly||b)&&Blockly.mainWorkspace.scrollbar&&(Blockly.mainWorkspace.dragMode=!0,Blockly.mainWorkspace.startDragMouseX=a.clientX,Blockly.mainWorkspace.startDragMouseY=a.clientY,
Blockly.mainWorkspace.startDragMetrics=Blockly.mainWorkspace.getMetrics(),Blockly.mainWorkspace.startScrollX=Blockly.mainWorkspace.scrollX,Blockly.mainWorkspace.startScrollY=Blockly.mainWorkspace.scrollY,"mouseup"in Blockly.bindEvent_.TOUCH_MAP&&(Blockly.onTouchUpWrapper_=Blockly.bindEvent_(document,"mouseup",null,Blockly.onMouseUp_)),Blockly.onMouseMoveWrapper_=Blockly.bindEvent_(document,"mousemove",null,Blockly.onMouseMove_))};
Blockly.onMouseUp_=function(a){Blockly.setCursorHand_(!1);Blockly.mainWorkspace.dragMode=!1;Blockly.onTouchUpWrapper_&&(Blockly.unbindEvent_(Blockly.onTouchUpWrapper_),Blockly.onTouchUpWrapper_=null);Blockly.onMouseMoveWrapper_&&(Blockly.unbindEvent_(Blockly.onMouseMoveWrapper_),Blockly.onMouseMoveWrapper_=null)};
Blockly.mainWorkspace.startDragMetrics=Blockly.mainWorkspace.getMetrics(),Blockly.mainWorkspace.startScrollX=Blockly.mainWorkspace.scrollX,Blockly.mainWorkspace.startScrollY=Blockly.mainWorkspace.scrollY,"mouseup"in Blockly.bindEvent_.TOUCH_MAP&&(Blockly.onTouchUpWrapper_=Blockly.bindEvent_(document,"mouseup",null,Blockly.onMouseUp_)))};
Blockly.onMouseUp_=function(a){Blockly.setCursorHand_(!1);Blockly.mainWorkspace.dragMode=!1;Blockly.onTouchUpWrapper_&&(Blockly.unbindEvent_(Blockly.onTouchUpWrapper_),Blockly.onTouchUpWrapper_=null)};
Blockly.onMouseMove_=function(a){if(Blockly.mainWorkspace.dragMode){Blockly.removeAllRanges();var b=Blockly.mainWorkspace.startDragMetrics,c=Blockly.mainWorkspace.startScrollX+(a.clientX-Blockly.mainWorkspace.startDragMouseX),d=Blockly.mainWorkspace.startScrollY+(a.clientY-Blockly.mainWorkspace.startDragMouseY),c=Math.min(c,-b.contentLeft),d=Math.min(d,-b.contentTop),c=Math.max(c,b.viewWidth-b.contentLeft-b.contentWidth),d=Math.max(d,b.viewHeight-b.contentTop-b.contentHeight);Blockly.mainWorkspace.scrollbar.set(-c-
b.contentLeft,-d-b.contentTop);a.stopPropagation()}};
Blockly.onKeyDown_=function(a){if(!Blockly.isTargetInput_(a))if(27==a.keyCode)Blockly.hideChaff();else if(8==a.keyCode||46==a.keyCode)try{Blockly.selected&&Blockly.selected.isDeletable()&&(Blockly.hideChaff(),Blockly.selected.dispose(!0,!0))}finally{a.preventDefault()}else if(a.altKey||a.ctrlKey||a.metaKey)Blockly.selected&&Blockly.selected.isDeletable()&&Blockly.selected.isMovable()&&Blockly.selected.workspace==Blockly.mainWorkspace&&(Blockly.hideChaff(),67==a.keyCode?Blockly.copy_(Blockly.selected):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment