diff --git a/blockly_compressed.js b/blockly_compressed.js index 7d2aa06fc..4887ac565 100644 --- a/blockly_compressed.js +++ b/blockly_compressed.js @@ -993,8 +993,8 @@ Blockly.WorkspaceSvg.prototype.dispose=function(){this.rendered=!1;Blockly.unbin this.scrollbar=null);this.zoomControls_&&(this.zoomControls_.dispose(),this.zoomControls_=null);this.options.parentWorkspace||goog.dom.removeNode(this.getParentSvg())};Blockly.WorkspaceSvg.prototype.newBlock=function(a,b){return new Blockly.BlockSvg(this,a,b)};Blockly.WorkspaceSvg.prototype.addTrashcan_=function(a){this.trashcan=new Blockly.Trashcan(this);var b=this.trashcan.createDom();this.svgGroup_.insertBefore(b,this.svgBlockCanvas_);return this.trashcan.init(a)}; Blockly.WorkspaceSvg.prototype.addZoomControls_=function(a){this.zoomControls_=new Blockly.ZoomControls(this);var b=this.zoomControls_.createDom();this.svgGroup_.appendChild(b);return this.zoomControls_.init(a)};Blockly.WorkspaceSvg.prototype.addFlyout_=function(){this.flyout_=new Blockly.Flyout({disabledPatternId:this.options.disabledPatternId,parentWorkspace:this,RTL:this.RTL});this.flyout_.autoClose=!1;var a=this.flyout_.createDom();this.svgGroup_.insertBefore(a,this.svgBlockCanvas_)}; Blockly.WorkspaceSvg.prototype.resize=function(){this.toolbox_&&this.toolbox_.position();this.flyout_&&this.flyout_.position();this.trashcan&&this.trashcan.position();this.zoomControls_&&this.zoomControls_.position();this.scrollbar&&this.scrollbar.resize()};Blockly.WorkspaceSvg.prototype.getCanvas=function(){return this.svgBlockCanvas_};Blockly.WorkspaceSvg.prototype.getBubbleCanvas=function(){return this.svgBubbleCanvas_}; -Blockly.WorkspaceSvg.prototype.getParentSvg=function(){if(this.getParentSvg.cachedParentSvg_)return this.getParentSvg.cachedParentSvg_;for(var a=this.svgGroup_;a;){if("svg"==a.tagName)return this.getParentSvg.cachedParentSvg_=a;a=a.parentNode}return null};Blockly.WorkspaceSvg.prototype.translate=function(a,b){var c="translate("+a+","+b+") scale("+this.scale+")";this.svgBlockCanvas_.setAttribute("transform",c);this.svgBubbleCanvas_.setAttribute("transform",c)}; -Blockly.WorkspaceSvg.prototype.getWidth=function(){return this.getMetrics().viewWidth};Blockly.WorkspaceSvg.prototype.setVisible=function(a){this.getParentSvg().style.display=a?"block":"none";this.toolbox_&&(this.toolbox_.HtmlDiv.style.display=a?"block":"none");a?(this.render(),this.toolbox_&&this.toolbox_.position()):Blockly.hideChaff(!0)};Blockly.WorkspaceSvg.prototype.render=function(){for(var a=this.getAllBlocks(),b=a.length-1;0<=b;b--)a[b].render(!1)}; +Blockly.WorkspaceSvg.prototype.getParentSvg=function(){if(this.cachedParentSvg_)return this.cachedParentSvg_;for(var a=this.svgGroup_;a;){if("svg"==a.tagName)return this.cachedParentSvg_=a;a=a.parentNode}return null};Blockly.WorkspaceSvg.prototype.translate=function(a,b){var c="translate("+a+","+b+") scale("+this.scale+")";this.svgBlockCanvas_.setAttribute("transform",c);this.svgBubbleCanvas_.setAttribute("transform",c)};Blockly.WorkspaceSvg.prototype.getWidth=function(){return this.getMetrics().viewWidth}; +Blockly.WorkspaceSvg.prototype.setVisible=function(a){this.getParentSvg().style.display=a?"block":"none";this.toolbox_&&(this.toolbox_.HtmlDiv.style.display=a?"block":"none");a?(this.render(),this.toolbox_&&this.toolbox_.position()):Blockly.hideChaff(!0)};Blockly.WorkspaceSvg.prototype.render=function(){for(var a=this.getAllBlocks(),b=a.length-1;0<=b;b--)a[b].render(!1)}; Blockly.WorkspaceSvg.prototype.traceOn=function(a){this.traceOn_=a;this.traceWrapper_&&(Blockly.unbindEvent_(this.traceWrapper_),this.traceWrapper_=null);a&&(this.traceWrapper_=Blockly.bindEvent_(this.svgBlockCanvas_,"blocklySelectChange",this,function(){this.traceOn_=!1}))}; Blockly.WorkspaceSvg.prototype.highlightBlock=function(a){this.traceOn_&&0!=Blockly.dragMode_&&this.traceOn(!1);if(this.traceOn_){var b=null;if(a&&(b=Blockly.Block.getById(a),!b))return;this.traceOn(!1);b?b.select():Blockly.selected&&Blockly.selected.unselect();var c=this;setTimeout(function(){c.traceOn(!0)},1)}};Blockly.WorkspaceSvg.prototype.fireChangeEvent=function(){this.rendered&&this.svgBlockCanvas_&&Blockly.fireUiEvent(this.svgBlockCanvas_,"blocklyWorkspaceChange")}; Blockly.WorkspaceSvg.prototype.paste=function(a){if(this.rendered&&!(a.getElementsByTagName("block").length>=this.remainingCapacity())){Blockly.terminateDrag_();var b=Blockly.Xml.domToBlock(this,a),c=parseInt(a.getAttribute("x"),10);a=parseInt(a.getAttribute("y"),10);if(!isNaN(c)&&!isNaN(a)){this.RTL&&(c=-c);do{for(var d=!1,e=this.getAllBlocks(),f=0,g;g=e[f];f++)if(g=g.getRelativeToSurfaceXY(),1>=Math.abs(c-g.x)&&1>=Math.abs(a-g.y)){d=!0;break}if(!d)for(e=b.getConnections_(!1),f=0;g=e[f];f++)if(g.closest(Blockly.SNAP_RADIUS, diff --git a/core/workspace_svg.js b/core/workspace_svg.js index 5243f7962..185255a54 100644 --- a/core/workspace_svg.js +++ b/core/workspace_svg.js @@ -345,13 +345,13 @@ Blockly.WorkspaceSvg.prototype.getBubbleCanvas = function() { * @return {!Element} SVG element. */ Blockly.WorkspaceSvg.prototype.getParentSvg = function() { - if (this.getParentSvg.cachedParentSvg_) { - return this.getParentSvg.cachedParentSvg_; + if (this.cachedParentSvg_) { + return this.cachedParentSvg_; } var element = this.svgGroup_; while (element) { if (element.tagName == 'svg') { - this.getParentSvg.cachedParentSvg_ = element; + this.cachedParentSvg_ = element; return element; } element = element.parentNode; diff --git a/demos/code/code.js b/demos/code/code.js index 0b06a75a9..66ca98a81 100644 --- a/demos/code/code.js +++ b/demos/code/code.js @@ -517,7 +517,9 @@ Code.discard = function() { if (count < 2 || window.confirm(Blockly.Msg.DELETE_ALL_BLOCKS.replace('%1', count))) { Code.workspace.clear(); - window.location.hash = ''; + if (window.location.hash) { + window.location.hash = ''; + } } }; diff --git a/demos/graph/index.html b/demos/graph/index.html index daa318e58..83a6b71e2 100644 --- a/demos/graph/index.html +++ b/demos/graph/index.html @@ -60,35 +60,86 @@