|
|
|
@ -58,8 +58,8 @@ goog.string.escapeChar=function(a){if(a in goog.string.jsEscapeCache_)return goo
|
|
|
|
|
goog.string.caseInsensitiveContains=function(a,b){return goog.string.contains(a.toLowerCase(),b.toLowerCase())};goog.string.countOf=function(a,b){return a&&b?a.split(b).length-1:0};goog.string.removeAt=function(a,b,c){var d=a;0<=b&&b<a.length&&0<c&&(d=a.substr(0,b)+a.substr(b+c,a.length-b-c));return d};goog.string.remove=function(a,b){var c=new RegExp(goog.string.regExpEscape(b),"");return a.replace(c,"")};
|
|
|
|
|
goog.string.removeAll=function(a,b){var c=new RegExp(goog.string.regExpEscape(b),"g");return a.replace(c,"")};goog.string.regExpEscape=function(a){return String(a).replace(/([-()\[\]{}+?*.$\^|,:#<!\\])/g,"\\$1").replace(/\x08/g,"\\x08")};goog.string.repeat=String.prototype.repeat?function(a,b){return a.repeat(b)}:function(a,b){return Array(b+1).join(a)};
|
|
|
|
|
goog.string.padNumber=function(a,b,c){a=goog.isDef(c)?a.toFixed(c):String(a);c=a.indexOf(".");-1==c&&(c=a.length);return goog.string.repeat("0",Math.max(0,b-c))+a};goog.string.makeSafe=function(a){return null==a?"":String(a)};goog.string.buildString=function(a){return Array.prototype.join.call(arguments,"")};goog.string.getRandomString=function(){return Math.floor(2147483648*Math.random()).toString(36)+Math.abs(Math.floor(2147483648*Math.random())^goog.now()).toString(36)};
|
|
|
|
|
goog.string.compareVersions=function(a,b){for(var c=0,d=goog.string.trim(String(a)).split("."),e=goog.string.trim(String(b)).split("."),f=Math.max(d.length,e.length),g=0;0==c&&g<f;g++){var h=d[g]||"",k=e[g]||"",l=RegExp("(\\d*)(\\D*)","g"),p=RegExp("(\\d*)(\\D*)","g");do{var m=l.exec(h)||["","",""],q=p.exec(k)||["","",""];if(0==m[0].length&&0==q[0].length)break;var c=0==m[1].length?0:parseInt(m[1],10),n=0==q[1].length?0:parseInt(q[1],10),c=goog.string.compareElements_(c,n)||goog.string.compareElements_(0==
|
|
|
|
|
m[2].length,0==q[2].length)||goog.string.compareElements_(m[2],q[2])}while(0==c)}return c};goog.string.compareElements_=function(a,b){return a<b?-1:a>b?1:0};goog.string.hashCode=function(a){for(var b=0,c=0;c<a.length;++c)b=31*b+a.charCodeAt(c)>>>0;return b};goog.string.uniqueStringCounter_=2147483648*Math.random()|0;goog.string.createUniqueString=function(){return"goog_"+goog.string.uniqueStringCounter_++};
|
|
|
|
|
goog.string.compareVersions=function(a,b){for(var c=0,d=goog.string.trim(String(a)).split("."),e=goog.string.trim(String(b)).split("."),f=Math.max(d.length,e.length),g=0;0==c&&g<f;g++){var h=d[g]||"",k=e[g]||"",l=RegExp("(\\d*)(\\D*)","g"),q=RegExp("(\\d*)(\\D*)","g");do{var m=l.exec(h)||["","",""],p=q.exec(k)||["","",""];if(0==m[0].length&&0==p[0].length)break;var c=0==m[1].length?0:parseInt(m[1],10),n=0==p[1].length?0:parseInt(p[1],10),c=goog.string.compareElements_(c,n)||goog.string.compareElements_(0==
|
|
|
|
|
m[2].length,0==p[2].length)||goog.string.compareElements_(m[2],p[2])}while(0==c)}return c};goog.string.compareElements_=function(a,b){return a<b?-1:a>b?1:0};goog.string.hashCode=function(a){for(var b=0,c=0;c<a.length;++c)b=31*b+a.charCodeAt(c)>>>0;return b};goog.string.uniqueStringCounter_=2147483648*Math.random()|0;goog.string.createUniqueString=function(){return"goog_"+goog.string.uniqueStringCounter_++};
|
|
|
|
|
goog.string.toNumber=function(a){var b=Number(a);return 0==b&&goog.string.isEmptyOrWhitespace(a)?NaN:b};goog.string.isLowerCamelCase=function(a){return/^[a-z]+([A-Z][a-z]*)*$/.test(a)};goog.string.isUpperCamelCase=function(a){return/^([A-Z][a-z]*)+$/.test(a)};goog.string.toCamelCase=function(a){return String(a).replace(/\-([a-z])/g,function(a,c){return c.toUpperCase()})};goog.string.toSelectorCase=function(a){return String(a).replace(/([A-Z])/g,"-$1").toLowerCase()};
|
|
|
|
|
goog.string.toTitleCase=function(a,b){var c=goog.isString(b)?goog.string.regExpEscape(b):"\\s";return a.replace(new RegExp("(^"+(c?"|["+c+"]+":"")+")([a-z])","g"),function(a,b,c){return b+c.toUpperCase()})};goog.string.capitalize=function(a){return String(a.charAt(0)).toUpperCase()+String(a.substr(1)).toLowerCase()};goog.string.parseInt=function(a){isFinite(a)&&(a=String(a));return goog.isString(a)?/^\s*-?0x/i.test(a)?parseInt(a,16):parseInt(a,10):NaN};
|
|
|
|
|
goog.string.splitLimit=function(a,b,c){a=a.split(b);for(var d=[];0<c&&a.length;)d.push(a.shift()),c--;a.length&&d.push(a.join(b));return d};goog.string.editDistance=function(a,b){var c=[],d=[];if(a==b)return 0;if(!a.length||!b.length)return Math.max(a.length,b.length);for(var e=0;e<b.length+1;e++)c[e]=e;for(e=0;e<a.length;e++){d[0]=e+1;for(var f=0;f<b.length;f++)d[f+1]=Math.min(d[f]+1,c[f+1]+1,c[f]+(a[e]!=b[f]));for(f=0;f<c.length;f++)c[f]=d[f]}return d[b.length]};goog.asserts={};goog.asserts.ENABLE_ASSERTS=goog.DEBUG;goog.asserts.AssertionError=function(a,b){b.unshift(a);goog.debug.Error.call(this,goog.string.subs.apply(null,b));b.shift();this.messagePattern=a};goog.inherits(goog.asserts.AssertionError,goog.debug.Error);goog.asserts.AssertionError.prototype.name="AssertionError";goog.asserts.DEFAULT_ERROR_HANDLER=function(a){throw a;};goog.asserts.errorHandler_=goog.asserts.DEFAULT_ERROR_HANDLER;
|
|
|
|
@ -512,7 +512,7 @@ goog.ui.ControlRenderer.TOGGLE_ARIA_STATE_MAP_=goog.object.create(goog.a11y.aria
|
|
|
|
|
goog.a11y.aria.State.SELECTED);goog.ui.ControlRenderer.prototype.getAriaRole=function(){};goog.ui.ControlRenderer.prototype.createDom=function(a){return a.getDomHelper().createDom(goog.dom.TagName.DIV,this.getClassNames(a).join(" "),a.getContent())};goog.ui.ControlRenderer.prototype.getContentElement=function(a){return a};
|
|
|
|
|
goog.ui.ControlRenderer.prototype.enableClassName=function(a,b,c){if(a=a.getElement?a.getElement():a){var d=[b];goog.userAgent.IE&&!goog.userAgent.isVersionOrHigher("7")&&(d=this.getAppliedCombinedClassNames_(goog.dom.classlist.get(a),b),d.push(b));goog.dom.classlist.enableAll(a,d,c)}};goog.ui.ControlRenderer.prototype.enableExtraClassName=function(a,b,c){this.enableClassName(a,b,c)};goog.ui.ControlRenderer.prototype.canDecorate=function(a){return!0};
|
|
|
|
|
goog.ui.ControlRenderer.prototype.decorate=function(a,b){b.id&&a.setId(b.id);var c=this.getContentElement(b);c&&c.firstChild?a.setContentInternal(c.firstChild.nextSibling?goog.array.clone(c.childNodes):c.firstChild):a.setContentInternal(null);var d=0,e=this.getCssClass(),f=this.getStructuralCssClass(),g=!1,h=!1,k=!1,l=goog.array.toArray(goog.dom.classlist.get(b));goog.array.forEach(l,function(a){g||a!=e?h||a!=f?d|=this.getStateFromClass(a):h=!0:(g=!0,f==e&&(h=!0));this.getStateFromClass(a)==goog.ui.Component.State.DISABLED&&
|
|
|
|
|
(goog.asserts.assertElement(c),goog.dom.isFocusableTabIndex(c)&&goog.dom.setFocusableTabIndex(c,!1))},this);a.setStateInternal(d);g||(l.push(e),f==e&&(h=!0));h||l.push(f);var p=a.getExtraClassNames();p&&l.push.apply(l,p);if(goog.userAgent.IE&&!goog.userAgent.isVersionOrHigher("7")){var m=this.getAppliedCombinedClassNames_(l);0<m.length&&(l.push.apply(l,m),k=!0)}g&&h&&!p&&!k||goog.dom.classlist.set(b,l.join(" "));return b};
|
|
|
|
|
(goog.asserts.assertElement(c),goog.dom.isFocusableTabIndex(c)&&goog.dom.setFocusableTabIndex(c,!1))},this);a.setStateInternal(d);g||(l.push(e),f==e&&(h=!0));h||l.push(f);var q=a.getExtraClassNames();q&&l.push.apply(l,q);if(goog.userAgent.IE&&!goog.userAgent.isVersionOrHigher("7")){var m=this.getAppliedCombinedClassNames_(l);0<m.length&&(l.push.apply(l,m),k=!0)}g&&h&&!q&&!k||goog.dom.classlist.set(b,l.join(" "));return b};
|
|
|
|
|
goog.ui.ControlRenderer.prototype.initializeDom=function(a){a.isRightToLeft()&&this.setRightToLeft(a.getElement(),!0);a.isEnabled()&&this.setFocusable(a,a.isVisible())};goog.ui.ControlRenderer.prototype.setAriaRole=function(a,b){var c=b||this.getAriaRole();if(c){goog.asserts.assert(a,"The element passed as a first parameter cannot be null.");var d=goog.a11y.aria.getRole(a);c!=d&&goog.a11y.aria.setRole(a,c)}};
|
|
|
|
|
goog.ui.ControlRenderer.prototype.setAriaStates=function(a,b){goog.asserts.assert(a);goog.asserts.assert(b);var c=a.getAriaLabel();goog.isDefAndNotNull(c)&&this.setAriaLabel(b,c);a.isVisible()||goog.a11y.aria.setState(b,goog.a11y.aria.State.HIDDEN,!a.isVisible());a.isEnabled()||this.updateAriaState(b,goog.ui.Component.State.DISABLED,!a.isEnabled());a.isSupportedState(goog.ui.Component.State.SELECTED)&&this.updateAriaState(b,goog.ui.Component.State.SELECTED,a.isSelected());a.isSupportedState(goog.ui.Component.State.CHECKED)&&
|
|
|
|
|
this.updateAriaState(b,goog.ui.Component.State.CHECKED,a.isChecked());a.isSupportedState(goog.ui.Component.State.OPENED)&&this.updateAriaState(b,goog.ui.Component.State.OPENED,a.isOpen())};goog.ui.ControlRenderer.prototype.setAriaLabel=function(a,b){goog.a11y.aria.setLabel(a,b)};goog.ui.ControlRenderer.prototype.setAllowTextSelection=function(a,b){goog.style.setUnselectable(a,!b,!goog.userAgent.IE&&!goog.userAgent.OPERA)};
|
|
|
|
@ -869,8 +869,8 @@ this.anchorX_:c.viewLeft+c.viewWidth<this.anchorX_+a+this.width_+Blockly.BlockSv
|
|
|
|
|
Blockly.Bubble.prototype.positionBubble_=function(){this.bubbleGroup_.setAttribute("transform","translate("+(this.workspace_.RTL?this.anchorX_-this.relativeLeft_-this.width_:this.anchorX_+this.relativeLeft_)+","+(this.relativeTop_+this.anchorY_)+")")};Blockly.Bubble.prototype.getBubbleSize=function(){return{width:this.width_,height:this.height_}};
|
|
|
|
|
Blockly.Bubble.prototype.setBubbleSize=function(a,b){var c=2*Blockly.Bubble.BORDER_WIDTH;a=Math.max(a,c+45);b=Math.max(b,c+20);this.width_=a;this.height_=b;this.bubbleBack_.setAttribute("width",a);this.bubbleBack_.setAttribute("height",b);this.resizeGroup_&&(this.workspace_.RTL?this.resizeGroup_.setAttribute("transform","translate("+2*Blockly.Bubble.BORDER_WIDTH+","+(b-c)+") scale(-1 1)"):this.resizeGroup_.setAttribute("transform","translate("+(a-c)+","+(b-c)+")"));this.rendered_&&(this.autoLayout_&&
|
|
|
|
|
this.layoutBubble_(),this.positionBubble_(),this.renderArrow_());Blockly.fireUiEvent(this.bubbleGroup_,"resize")};
|
|
|
|
|
Blockly.Bubble.prototype.renderArrow_=function(){var a=[],b=this.width_/2,c=this.height_/2,d=-this.relativeLeft_,e=-this.relativeTop_;if(b==d&&c==e)a.push("M "+b+","+c);else{e-=c;d-=b;this.workspace_.RTL&&(d*=-1);var f=Math.sqrt(e*e+d*d),g=Math.acos(d/f);0>e&&(g=2*Math.PI-g);var h=g+Math.PI/2;h>2*Math.PI&&(h-=2*Math.PI);var k=Math.sin(h),l=Math.cos(h),p=this.getBubbleSize(),h=(p.width+p.height)/Blockly.Bubble.ARROW_THICKNESS,h=Math.min(h,p.width,p.height)/2,p=1-Blockly.Bubble.ANCHOR_RADIUS/f,d=b+
|
|
|
|
|
p*d,e=c+p*e,p=b+h*l,m=c+h*k,b=b-h*l,c=c-h*k,k=g+this.arrow_radians_;k>2*Math.PI&&(k-=2*Math.PI);g=Math.sin(k)*f/Blockly.Bubble.ARROW_BEND;f=Math.cos(k)*f/Blockly.Bubble.ARROW_BEND;a.push("M"+p+","+m);a.push("C"+(p+f)+","+(m+g)+" "+d+","+e+" "+d+","+e);a.push("C"+d+","+e+" "+(b+f)+","+(c+g)+" "+b+","+c)}a.push("z");this.bubbleArrow_.setAttribute("d",a.join(" "))};Blockly.Bubble.prototype.setColour=function(a){this.bubbleBack_.setAttribute("fill",a);this.bubbleArrow_.setAttribute("fill",a)};
|
|
|
|
|
Blockly.Bubble.prototype.renderArrow_=function(){var a=[],b=this.width_/2,c=this.height_/2,d=-this.relativeLeft_,e=-this.relativeTop_;if(b==d&&c==e)a.push("M "+b+","+c);else{e-=c;d-=b;this.workspace_.RTL&&(d*=-1);var f=Math.sqrt(e*e+d*d),g=Math.acos(d/f);0>e&&(g=2*Math.PI-g);var h=g+Math.PI/2;h>2*Math.PI&&(h-=2*Math.PI);var k=Math.sin(h),l=Math.cos(h),q=this.getBubbleSize(),h=(q.width+q.height)/Blockly.Bubble.ARROW_THICKNESS,h=Math.min(h,q.width,q.height)/2,q=1-Blockly.Bubble.ANCHOR_RADIUS/f,d=b+
|
|
|
|
|
q*d,e=c+q*e,q=b+h*l,m=c+h*k,b=b-h*l,c=c-h*k,k=g+this.arrow_radians_;k>2*Math.PI&&(k-=2*Math.PI);g=Math.sin(k)*f/Blockly.Bubble.ARROW_BEND;f=Math.cos(k)*f/Blockly.Bubble.ARROW_BEND;a.push("M"+q+","+m);a.push("C"+(q+f)+","+(m+g)+" "+d+","+e+" "+d+","+e);a.push("C"+d+","+e+" "+(b+f)+","+(c+g)+" "+b+","+c)}a.push("z");this.bubbleArrow_.setAttribute("d",a.join(" "))};Blockly.Bubble.prototype.setColour=function(a){this.bubbleBack_.setAttribute("fill",a);this.bubbleArrow_.setAttribute("fill",a)};
|
|
|
|
|
Blockly.Bubble.prototype.dispose=function(){Blockly.Bubble.unbindDragEvents_();goog.dom.removeNode(this.bubbleGroup_);this.shape_=this.content_=this.workspace_=this.resizeGroup_=this.bubbleBack_=this.bubbleArrow_=this.bubbleGroup_=null};Blockly.Icon=function(a){this.block_=a};Blockly.Icon.prototype.collapseHidden=!0;Blockly.Icon.prototype.SIZE=17;Blockly.Icon.prototype.bubble_=null;Blockly.Icon.prototype.iconX_=0;Blockly.Icon.prototype.iconY_=0;
|
|
|
|
|
Blockly.Icon.prototype.createIcon=function(){this.iconGroup_||(this.iconGroup_=Blockly.createSvgElement("g",{"class":"blocklyIconGroup"},null),this.drawIcon_(this.iconGroup_),this.block_.getSvgRoot().appendChild(this.iconGroup_),Blockly.bindEvent_(this.iconGroup_,"mouseup",this,this.iconClick_),this.updateEditable())};Blockly.Icon.prototype.dispose=function(){goog.dom.removeNode(this.iconGroup_);this.iconGroup_=null;this.setVisible(!1);this.block_=null};
|
|
|
|
|
Blockly.Icon.prototype.updateEditable=function(){this.block_.isInFlyout||!this.block_.isEditable()?Blockly.addClass_(this.iconGroup_,"blocklyIconGroupReadonly"):Blockly.removeClass_(this.iconGroup_,"blocklyIconGroupReadonly")};Blockly.Icon.prototype.isVisible=function(){return!!this.bubble_};Blockly.Icon.prototype.iconClick_=function(a){2!=Blockly.dragMode_&&(this.block_.isInFlyout||Blockly.isRightButton(a)||this.setVisible(!this.isVisible()))};
|
|
|
|
@ -899,8 +899,8 @@ Blockly.Connection.prototype.moveTo=function(a,b){this.inDB_&&this.db_.removeCon
|
|
|
|
|
Blockly.Connection.prototype.highlight=function(){var a;this.type==Blockly.INPUT_VALUE||this.type==Blockly.OUTPUT_VALUE?(a=this.sourceBlock_.RTL?-Blockly.BlockSvg.TAB_WIDTH:Blockly.BlockSvg.TAB_WIDTH,a="m 0,0 v 5 c 0,10 "+-a+",-8 "+-a+",7.5 s "+a+",-2.5 "+a+",7.5 v 5"):a=this.sourceBlock_.RTL?"m 20,0 h -5 "+Blockly.BlockSvg.NOTCH_PATH_RIGHT+" h -5":"m -20,0 h 5 "+Blockly.BlockSvg.NOTCH_PATH_LEFT+" h 5";var b=this.sourceBlock_.getRelativeToSurfaceXY();Blockly.Connection.highlightedPath_=Blockly.createSvgElement("path",
|
|
|
|
|
{"class":"blocklyHighlightedConnectionPath",d:a,transform:"translate("+(this.x_-b.x)+","+(this.y_-b.y)+")"},this.sourceBlock_.getSvgRoot())};Blockly.Connection.prototype.unhighlight=function(){goog.dom.removeNode(Blockly.Connection.highlightedPath_);delete Blockly.Connection.highlightedPath_};
|
|
|
|
|
Blockly.Connection.prototype.tighten_=function(){var a=this.targetConnection.x_-this.x_,b=this.targetConnection.y_-this.y_;if(0!=a||0!=b){var c=this.targetBlock(),d=c.getSvgRoot();if(!d)throw"block is not rendered.";d=Blockly.getRelativeXY_(d);c.getSvgRoot().setAttribute("transform","translate("+(d.x-a)+","+(d.y-b)+")");c.moveConnections_(-a,-b)}};
|
|
|
|
|
Blockly.Connection.prototype.closest=function(a,b,c){function d(b){b=e[b];if((b.type==Blockly.OUTPUT_VALUE||b.type==Blockly.PREVIOUS_STATEMENT)&&b.targetConnection||b.type==Blockly.INPUT_VALUE&&b.targetConnection&&!b.targetBlock().isMovable()&&!b.targetBlock().isShadow()||!p.checkType_(b))return!0;var c=b.sourceBlock_;do{if(l==c)return!0;c=c.getParent()}while(c);var d=f-b.x_,c=g-b.y_,d=Math.sqrt(d*d+c*c);d<=a&&(k=b,a=d);return Math.abs(c)<a}if(this.targetConnection)return{connection:null,radius:a};
|
|
|
|
|
var e=this.dbOpposite_,f=this.x_+b,g=this.y_+c;b=0;for(var h=c=e.length-2;b<h;)e[h].y_<g?b=h:c=h,h=Math.floor((b+c)/2);c=b=h;var k=null,l=this.sourceBlock_,p=this;if(e.length){for(;0<=b&&d(b);)b--;do c++;while(c<e.length&&d(c))}return{connection:k,radius:a}};
|
|
|
|
|
Blockly.Connection.prototype.closest=function(a,b,c){function d(b){b=e[b];if((b.type==Blockly.OUTPUT_VALUE||b.type==Blockly.PREVIOUS_STATEMENT)&&b.targetConnection||b.type==Blockly.INPUT_VALUE&&b.targetConnection&&!b.targetBlock().isMovable()&&!b.targetBlock().isShadow()||!q.checkType_(b))return!0;var c=b.sourceBlock_;do{if(l==c)return!0;c=c.getParent()}while(c);var d=f-b.x_,c=g-b.y_,d=Math.sqrt(d*d+c*c);d<=a&&(k=b,a=d);return Math.abs(c)<a}if(this.targetConnection)return{connection:null,radius:a};
|
|
|
|
|
var e=this.dbOpposite_,f=this.x_+b,g=this.y_+c;b=0;for(var h=c=e.length-2;b<h;)e[h].y_<g?b=h:c=h,h=Math.floor((b+c)/2);c=b=h;var k=null,l=this.sourceBlock_,q=this;if(e.length){for(;0<=b&&d(b);)b--;do c++;while(c<e.length&&d(c))}return{connection:k,radius:a}};
|
|
|
|
|
Blockly.Connection.prototype.checkType_=function(a){var b=this.targetBlock();if(b&&!b.isMovable()&&!this.sourceBlock_.isMovable()||(b=a.targetBlock())&&!b.isMovable()&&!a.sourceBlock_.isMovable())return!1;if(!this.check_||!a.check_)return!0;for(b=0;b<this.check_.length;b++)if(-1!=a.check_.indexOf(this.check_[b]))return!0;return!1};
|
|
|
|
|
Blockly.Connection.prototype.setCheck=function(a){a?(goog.isArray(a)||(a=[a]),this.check_=a,this.targetConnection&&!this.checkType_(this.targetConnection)&&(this.isSuperior()?this.targetBlock().setParent(null):this.sourceBlock_.setParent(null),this.sourceBlock_.bumpNeighbours_())):this.check_=null;return this};Blockly.Connection.prototype.setShadowDom=function(a){this.shadowDom_=a};Blockly.Connection.prototype.getShadowDom=function(){return this.shadowDom_};
|
|
|
|
|
Blockly.Connection.prototype.neighbours_=function(a){function b(b){var f=d-c[b].x_,g=e-c[b].y_;Math.sqrt(f*f+g*g)<=a&&k.push(c[b]);return g<a}for(var c=this.dbOpposite_,d=this.x_,e=this.y_,f=0,g=c.length-2,h=g;f<h;)c[h].y_<e?f=h:g=h,h=Math.floor((f+g)/2);var g=f=h,k=[];if(c.length){for(;0<=f&&b(f);)f--;do g++;while(g<c.length&&b(g))}return k};Blockly.Connection.prototype.setHidden=function(a){(this.hidden_=a)&&this.inDB_?this.db_.removeConnection_(this):a||this.inDB_||this.db_.addConnection_(this)};
|
|
|
|
@ -947,7 +947,7 @@ b/a.contentHeight;if(-Infinity===this.ratio_||Infinity===this.ratio_||isNaN(this
|
|
|
|
|
Math.max(0,b));this.svgKnob_.setAttribute("y",this.constrainKnob_(d))}this.onScroll_()};
|
|
|
|
|
Blockly.Scrollbar.prototype.createDom_=function(){this.svgGroup_=Blockly.createSvgElement("g",{"class":"blocklyScrollbar"+(this.horizontal_?"Horizontal":"Vertical")},null);this.svgBackground_=Blockly.createSvgElement("rect",{"class":"blocklyScrollbarBackground"},this.svgGroup_);var a=Math.floor((Blockly.Scrollbar.scrollbarThickness-5)/2);this.svgKnob_=Blockly.createSvgElement("rect",{"class":"blocklyScrollbarKnob",rx:a,ry:a},this.svgGroup_);Blockly.Scrollbar.insertAfter_(this.svgGroup_,this.workspace_.getBubbleCanvas())};
|
|
|
|
|
Blockly.Scrollbar.prototype.isVisible=function(){return"none"!=this.svgGroup_.getAttribute("display")};Blockly.Scrollbar.prototype.setVisible=function(a){if(a!=this.isVisible()){if(this.pair_)throw"Unable to toggle visibility of paired scrollbars.";a?this.svgGroup_.setAttribute("display","block"):(this.workspace_.setMetrics({x:0,y:0}),this.svgGroup_.setAttribute("display","none"))}};
|
|
|
|
|
Blockly.Scrollbar.prototype.onMouseDownBar_=function(a){this.onMouseUpKnob_();if(!Blockly.isRightButton(a)){var b=Blockly.mouseToSvg(a,this.workspace_.options.svg),b=this.horizontal_?b.x:b.y,c=Blockly.getSvgXY_(this.svgKnob_,this.workspace_),c=this.horizontal_?c.x:c.y,d=parseFloat(this.svgKnob_.getAttribute(this.horizontal_?"width":"height")),e=parseFloat(this.svgKnob_.getAttribute(this.horizontal_?"x":"y")),f=.95*d;b<=c?e-=f:b>=c+d&&(e+=f);this.svgKnob_.setAttribute(this.horizontal_?"x":"y",this.constrainKnob_(e));
|
|
|
|
|
Blockly.Scrollbar.prototype.onMouseDownBar_=function(a){this.onMouseUpKnob_();if(!Blockly.isRightButton(a)){var b=Blockly.mouseToSvg(a,this.workspace_.getParentSvg()),b=this.horizontal_?b.x:b.y,c=Blockly.getSvgXY_(this.svgKnob_,this.workspace_),c=this.horizontal_?c.x:c.y,d=parseFloat(this.svgKnob_.getAttribute(this.horizontal_?"width":"height")),e=parseFloat(this.svgKnob_.getAttribute(this.horizontal_?"x":"y")),f=.95*d;b<=c?e-=f:b>=c+d&&(e+=f);this.svgKnob_.setAttribute(this.horizontal_?"x":"y",this.constrainKnob_(e));
|
|
|
|
|
this.onScroll_()}a.stopPropagation()};Blockly.Scrollbar.prototype.onMouseDownKnob_=function(a){this.onMouseUpKnob_();Blockly.isRightButton(a)||(this.startDragKnob=parseFloat(this.svgKnob_.getAttribute(this.horizontal_?"x":"y")),this.startDragMouse=this.horizontal_?a.clientX:a.clientY,Blockly.Scrollbar.onMouseUpWrapper_=Blockly.bindEvent_(document,"mouseup",this,this.onMouseUpKnob_),Blockly.Scrollbar.onMouseMoveWrapper_=Blockly.bindEvent_(document,"mousemove",this,this.onMouseMoveKnob_));a.stopPropagation()};
|
|
|
|
|
Blockly.Scrollbar.prototype.onMouseMoveKnob_=function(a){this.svgKnob_.setAttribute(this.horizontal_?"x":"y",this.constrainKnob_(this.startDragKnob+((this.horizontal_?a.clientX:a.clientY)-this.startDragMouse)));this.onScroll_()};
|
|
|
|
|
Blockly.Scrollbar.prototype.onMouseUpKnob_=function(){Blockly.removeAllRanges();Blockly.hideChaff(!0);Blockly.Scrollbar.onMouseUpWrapper_&&(Blockly.unbindEvent_(Blockly.Scrollbar.onMouseUpWrapper_),Blockly.Scrollbar.onMouseUpWrapper_=null);Blockly.Scrollbar.onMouseMoveWrapper_&&(Blockly.unbindEvent_(Blockly.Scrollbar.onMouseMoveWrapper_),Blockly.Scrollbar.onMouseMoveWrapper_=null)};
|
|
|
|
@ -969,17 +969,16 @@ d.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",a.options.pathToMed
|
|
|
|
|
Blockly.SPRITE.url);c=Blockly.createSvgElement("clipPath",{id:"blocklyZoomresetClipPath"+b},this.svgGroup_);Blockly.createSvgElement("rect",{width:32,height:32},c);b=Blockly.createSvgElement("image",{width:Blockly.SPRITE.width,height:Blockly.SPRITE.height,y:-92,"clip-path":"url(#blocklyZoomresetClipPath"+b+")"},this.svgGroup_);b.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",a.options.pathToMedia+Blockly.SPRITE.url);Blockly.bindEvent_(b,"mousedown",a,a.zoomReset);Blockly.bindEvent_(e,
|
|
|
|
|
"mousedown",null,function(b){a.zoomCenter(1);b.stopPropagation()});Blockly.bindEvent_(d,"mousedown",null,function(b){a.zoomCenter(-1);b.stopPropagation()});return this.svgGroup_};Blockly.ZoomControls.prototype.init=function(a){this.bottom_=this.MARGIN_BOTTOM_+a;return this.bottom_+this.HEIGHT_};Blockly.ZoomControls.prototype.dispose=function(){this.svgGroup_&&(goog.dom.removeNode(this.svgGroup_),this.svgGroup_=null);this.workspace_=null};
|
|
|
|
|
Blockly.ZoomControls.prototype.position=function(){var a=this.workspace_.getMetrics();a&&(this.left_=this.workspace_.RTL?this.MARGIN_SIDE_+Blockly.Scrollbar.scrollbarThickness:a.viewWidth+a.absoluteLeft-this.WIDTH_-this.MARGIN_SIDE_-Blockly.Scrollbar.scrollbarThickness,this.top_=a.viewHeight+a.absoluteTop-this.HEIGHT_-this.bottom_,this.svgGroup_.setAttribute("transform","translate("+this.left_+","+this.top_+")"))};Blockly.Xml={};Blockly.Xml.workspaceToDom=function(a){var b;a.RTL&&(b=a.getWidth());for(var c=goog.dom.createDom("xml"),d=a.getTopBlocks(!0),e=0,f;f=d[e];e++){var g=Blockly.Xml.blockToDom_(f);f=f.getRelativeToSurfaceXY();g.setAttribute("x",Math.round(a.RTL?b-f.x:f.x));g.setAttribute("y",Math.round(f.y));c.appendChild(g)}return c};
|
|
|
|
|
Blockly.Xml.blockToDom_=function(a){var b=goog.dom.createDom(a.isShadow()?"shadow":"block");b.setAttribute("type",a.type);Blockly.Realtime.isEnabled()&&b.setAttribute("id",a.id);if(a.mutationToDom){var c=a.mutationToDom();c&&(c.hasChildNodes()||c.hasAttributes())&&b.appendChild(c)}for(var c=0,d;d=a.inputList[c];c++)for(var e=0,f;f=d.fieldRow[e];e++)if(f.name&&f.EDITABLE){var g=goog.dom.createDom("field",null,f.getValue());g.setAttribute("name",f.name);b.appendChild(g)}if(c=a.getCommentText())c=goog.dom.createDom("comment",
|
|
|
|
|
null,c),"object"==typeof a.comment&&(c.setAttribute("pinned",a.comment.isVisible()),d=a.comment.getBubbleSize(),c.setAttribute("h",d.height),c.setAttribute("w",d.width)),b.appendChild(c);a.data&&(c=goog.dom.createDom("data",null,a.data),b.appendChild(c));for(c=0;d=a.inputList[c];c++){var h;f=!0;d.type!=Blockly.DUMMY_INPUT&&(g=d.connection.targetBlock(),d.type==Blockly.INPUT_VALUE?h=goog.dom.createDom("value"):d.type==Blockly.NEXT_STATEMENT&&(h=goog.dom.createDom("statement")),e=d.connection.getShadowDom(),
|
|
|
|
|
!e||g&&g.isShadow()||h.appendChild(Blockly.Xml.cloneShadow_(e)),g&&(h.appendChild(Blockly.Xml.blockToDom_(g)),f=!1),h.setAttribute("name",d.name),f||b.appendChild(h))}a.inputsInlineDefault!=a.inputsInline&&b.setAttribute("inline",a.inputsInline);a.isCollapsed()&&b.setAttribute("collapsed",!0);a.disabled&&b.setAttribute("disabled",!0);a.isDeletable()||a.isShadow()||b.setAttribute("deletable",!1);a.isMovable()||a.isShadow()||b.setAttribute("movable",!1);a.isEditable()||b.setAttribute("editable",!1);
|
|
|
|
|
if(c=a.getNextBlock())h=goog.dom.createDom("next",null,Blockly.Xml.blockToDom_(c)),b.appendChild(h);e=a.nextConnection&&a.nextConnection.getShadowDom();!e||c&&c.isShadow()||h.appendChild(Blockly.Xml.cloneShadow_(e));return b};
|
|
|
|
|
Blockly.Xml.cloneShadow_=function(a){for(var b=a=a.cloneNode(!0),c;b;)if(b.firstChild)b=b.firstChild;else{for(;b&&!b.nextSibling;)c=b,b=b.parentNode,3==c.nodeType&&""==c.data.trim()&&b.firstChild!=c&&goog.dom.removeNode(c);b&&(c=b,b=b.nextSibling,3==c.nodeType&&""==c.data.trim()&&goog.dom.removeNode(c))}return a};Blockly.Xml.domToText=function(a){return(new XMLSerializer).serializeToString(a)};
|
|
|
|
|
Blockly.Xml.blockToDom_=function(a){var b=goog.dom.createDom(a.isShadow()?"shadow":"block");b.setAttribute("type",a.type);if(a.mutationToDom){var c=a.mutationToDom();c&&(c.hasChildNodes()||c.hasAttributes())&&b.appendChild(c)}for(var c=0,d;d=a.inputList[c];c++)for(var e=0,f;f=d.fieldRow[e];e++)if(f.name&&f.EDITABLE){var g=goog.dom.createDom("field",null,f.getValue());g.setAttribute("name",f.name);b.appendChild(g)}if(c=a.getCommentText())c=goog.dom.createDom("comment",null,c),"object"==typeof a.comment&&
|
|
|
|
|
(c.setAttribute("pinned",a.comment.isVisible()),d=a.comment.getBubbleSize(),c.setAttribute("h",d.height),c.setAttribute("w",d.width)),b.appendChild(c);a.data&&(c=goog.dom.createDom("data",null,a.data),b.appendChild(c));for(c=0;d=a.inputList[c];c++){var h;f=!0;d.type!=Blockly.DUMMY_INPUT&&(g=d.connection.targetBlock(),d.type==Blockly.INPUT_VALUE?h=goog.dom.createDom("value"):d.type==Blockly.NEXT_STATEMENT&&(h=goog.dom.createDom("statement")),e=d.connection.getShadowDom(),!e||g&&g.isShadow()||h.appendChild(Blockly.Xml.cloneShadow_(e)),
|
|
|
|
|
g&&(h.appendChild(Blockly.Xml.blockToDom_(g)),f=!1),h.setAttribute("name",d.name),f||b.appendChild(h))}a.inputsInlineDefault!=a.inputsInline&&b.setAttribute("inline",a.inputsInline);a.isCollapsed()&&b.setAttribute("collapsed",!0);a.disabled&&b.setAttribute("disabled",!0);a.isDeletable()||a.isShadow()||b.setAttribute("deletable",!1);a.isMovable()||a.isShadow()||b.setAttribute("movable",!1);a.isEditable()||b.setAttribute("editable",!1);if(c=a.getNextBlock())h=goog.dom.createDom("next",null,Blockly.Xml.blockToDom_(c)),
|
|
|
|
|
b.appendChild(h);e=a.nextConnection&&a.nextConnection.getShadowDom();!e||c&&c.isShadow()||h.appendChild(Blockly.Xml.cloneShadow_(e));return b};Blockly.Xml.cloneShadow_=function(a){for(var b=a=a.cloneNode(!0),c;b;)if(b.firstChild)b=b.firstChild;else{for(;b&&!b.nextSibling;)c=b,b=b.parentNode,3==c.nodeType&&""==c.data.trim()&&b.firstChild!=c&&goog.dom.removeNode(c);b&&(c=b,b=b.nextSibling,3==c.nodeType&&""==c.data.trim()&&goog.dom.removeNode(c))}return a};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){var c;a.RTL&&(c=a.getWidth());Blockly.Field.startCache();for(var d=b.childNodes.length,e=0;e<d;e++){var f=b.childNodes[e],g=f.nodeName.toLowerCase();if("block"==g||"shadow"==g){var g=Blockly.Xml.domToBlock(a,f),h=parseInt(f.getAttribute("x"),10),f=parseInt(f.getAttribute("y"),10);isNaN(h)||isNaN(f)||g.moveBy(a.RTL?c-h:h,f)}}Blockly.Field.stopCache()};
|
|
|
|
|
Blockly.Xml.domToBlock=function(a,b){var c=Blockly.Xml.domToBlockHeadless_(a,b);if(a.rendered){c.setConnectionsHidden(!0);for(var d=c.getDescendants(),e=d.length-1;0<=e;e--)d[e].initSvg();for(e=d.length-1;0<=e;e--)d[e].render(!1);setTimeout(function(){c.workspace&&c.setConnectionsHidden(!1)},1);c.updateDisabled();Blockly.fireUiEvent(window,"resize")}return c};
|
|
|
|
|
Blockly.Xml.domToBlockHeadless_=function(a,b){var c=null,d=b.getAttribute("type");if(!d)throw"Block type unspecified: \n"+b.outerHTML;for(var e=b.getAttribute("id"),c=a.newBlock(d,e),f=null,e=0,g;g=b.childNodes[e];e++)if(3!=g.nodeType){for(var h=f=null,k=0,l;l=g.childNodes[k];k++)1==l.nodeType&&("block"==l.nodeName.toLowerCase()?f=l:"shadow"==l.nodeName.toLowerCase()&&(h=l));!f&&h&&(f=h);k=g.getAttribute("name");switch(g.nodeName.toLowerCase()){case "mutation":c.domToMutation&&(c.domToMutation(g),
|
|
|
|
|
c.initSvg&&c.initSvg());break;case "comment":c.setCommentText(g.textContent);var p=g.getAttribute("pinned");p&&!c.isInFlyout&&setTimeout(function(){c.comment&&c.comment.setVisible&&c.comment.setVisible("true"==p)},1);f=parseInt(g.getAttribute("w"),10);g=parseInt(g.getAttribute("h"),10);!isNaN(f)&&!isNaN(g)&&c.comment&&c.comment.setVisible&&c.comment.setBubbleSize(f,g);break;case "data":c.data=g.textContent;break;case "title":case "field":f=c.getField(k);if(!f){console.warn("Ignoring non-existent field "+
|
|
|
|
|
c.initSvg&&c.initSvg());break;case "comment":c.setCommentText(g.textContent);var q=g.getAttribute("pinned");q&&!c.isInFlyout&&setTimeout(function(){c.comment&&c.comment.setVisible&&c.comment.setVisible("true"==q)},1);f=parseInt(g.getAttribute("w"),10);g=parseInt(g.getAttribute("h"),10);!isNaN(f)&&!isNaN(g)&&c.comment&&c.comment.setVisible&&c.comment.setBubbleSize(f,g);break;case "data":c.data=g.textContent;break;case "title":case "field":f=c.getField(k);if(!f){console.warn("Ignoring non-existent field "+
|
|
|
|
|
k+" in block "+d);break}f.setValue(g.textContent);break;case "value":case "statement":g=c.getInput(k);if(!g){console.warn("Ignoring non-existent input "+k+" in block "+d);break}h&&g.connection.setShadowDom(h);if(f)if(f=Blockly.Xml.domToBlockHeadless_(a,f),f.outputConnection)g.connection.connect(f.outputConnection);else if(f.previousConnection)g.connection.connect(f.previousConnection);else throw"Child block does not have output or previous statement.";break;case "next":h&&c.nextConnection&&c.nextConnection.setShadowDom(h);
|
|
|
|
|
if(f){if(!c.nextConnection)throw"Next statement does not exist.";if(c.nextConnection.targetConnection)throw"Next statement is already connected.";f=Blockly.Xml.domToBlockHeadless_(a,f);if(!f.previousConnection)throw"Next block does not have previous statement.";c.nextConnection.connect(f.previousConnection)}break;default:console.warn("Ignoring unknown tag: "+g.nodeName)}}(d=b.getAttribute("inline"))&&c.setInputsInline("true"==d);(d=b.getAttribute("disabled"))&&c.setDisabled("true"==d);(d=b.getAttribute("deletable"))&&
|
|
|
|
|
c.setDeletable("true"==d);(d=b.getAttribute("movable"))&&c.setMovable("true"==d);(d=b.getAttribute("editable"))&&c.setEditable("true"==d);(d=b.getAttribute("collapsed"))&&c.setCollapsed("true"==d);"shadow"==b.nodeName.toLowerCase()&&c.setShadow(!0);c.validate&&c.validate();return c};Blockly.Xml.deleteNext=function(a){for(var b=0,c;c=a.childNodes[b];b++)if("next"==c.nodeName.toLowerCase()){a.removeChild(c);break}};goog.global.Blockly||(goog.global.Blockly={});
|
|
|
|
@ -991,38 +990,38 @@ Blockly.WorkspaceSvg.prototype.createDom=function(a){this.svgGroup_=Blockly.crea
|
|
|
|
|
this.svgGroup_,this);a=Blockly.Scrollbar.scrollbarThickness;this.options.hasTrashcan&&(a=this.addTrashcan_(a));this.options.zoomOptions&&this.options.zoomOptions.controls&&(a=this.addZoomControls_(a));Blockly.bindEvent_(this.svgGroup_,"mousedown",this,this.onMouseDown_);var b=this;Blockly.bindEvent_(this.svgGroup_,"touchstart",null,function(a){Blockly.longStart_(a,b)});this.options.zoomOptions&&this.options.zoomOptions.wheel&&Blockly.bindEvent_(this.svgGroup_,"wheel",this,this.onMouseWheel_);this.options.hasCategories?
|
|
|
|
|
this.toolbox_=new Blockly.Toolbox(this):this.options.languageTree&&this.addFlyout_();this.updateGridPattern_();return this.svgGroup_};
|
|
|
|
|
Blockly.WorkspaceSvg.prototype.dispose=function(){this.rendered=!1;Blockly.unbindEvent_(this.eventWrappers_);Blockly.WorkspaceSvg.superClass_.dispose.call(this);this.svgGroup_&&(goog.dom.removeNode(this.svgGroup_),this.svgGroup_=null);this.svgBubbleCanvas_=this.svgBlockCanvas_=null;this.toolbox_&&(this.toolbox_.dispose(),this.toolbox_=null);this.flyout_&&(this.flyout_.dispose(),this.flyout_=null);this.trashcan&&(this.trashcan.dispose(),this.trashcan=null);this.scrollbar&&(this.scrollbar.dispose(),
|
|
|
|
|
this.scrollbar=null);this.zoomControls_&&(this.zoomControls_.dispose(),this.zoomControls_=null);this.options.parentWorkspace||goog.dom.removeNode(this.options.svg)};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)};
|
|
|
|
|
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.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.addTopBlock=function(a){Blockly.WorkspaceSvg.superClass_.addTopBlock.call(this,a);Blockly.Realtime.isEnabled()&&!this.options.parentWorkspace&&Blockly.Realtime.addTopBlock(a)};
|
|
|
|
|
Blockly.WorkspaceSvg.prototype.removeTopBlock=function(a){Blockly.WorkspaceSvg.superClass_.removeTopBlock.call(this,a);Blockly.Realtime.isEnabled()&&!this.options.parentWorkspace&&Blockly.Realtime.removeTopBlock(a)};Blockly.WorkspaceSvg.prototype.getWidth=function(){return this.getMetrics().viewWidth};
|
|
|
|
|
Blockly.WorkspaceSvg.prototype.setVisible=function(a){this.options.svg.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.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.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,
|
|
|
|
|
c,a).connection){d=!0;break}d&&(c=this.RTL?c-Blockly.SNAP_RADIUS:c+Blockly.SNAP_RADIUS,a+=2*Blockly.SNAP_RADIUS)}while(d);b.moveBy(c,a)}b.select()}};Blockly.WorkspaceSvg.prototype.recordDeleteAreas=function(){this.deleteAreaTrash_=this.trashcan?this.trashcan.getRect():null;this.deleteAreaToolbox_=this.flyout_?this.flyout_.getRect():this.toolbox_?this.toolbox_.getRect():null};
|
|
|
|
|
Blockly.WorkspaceSvg.prototype.isDeleteArea=function(a){a=Blockly.mouseToSvg(a,Blockly.mainWorkspace.options.svg);a=new goog.math.Coordinate(a.x,a.y);if(this.deleteAreaTrash_){if(this.deleteAreaTrash_.contains(a))return this.trashcan.setOpen_(!0),Blockly.Css.setCursor(Blockly.Css.Cursor.DELETE),!0;this.trashcan.setOpen_(!1)}if(this.deleteAreaToolbox_&&this.deleteAreaToolbox_.contains(a))return Blockly.Css.setCursor(Blockly.Css.Cursor.DELETE),!0;Blockly.Css.setCursor(Blockly.Css.Cursor.CLOSED);return!1};
|
|
|
|
|
Blockly.WorkspaceSvg.prototype.onMouseDown_=function(a){this.markFocused();Blockly.isTargetInput_(a)||(Blockly.svgResize(this),Blockly.terminateDrag_(),Blockly.hideChaff(),a.target&&a.target.nodeName&&("svg"==a.target.nodeName.toLowerCase()||a.target==this.svgBackground_)&&Blockly.selected&&!this.options.readOnly&&Blockly.selected.unselect(),Blockly.isRightButton(a)?this.showContextMenu_(a):this.scrollbar&&(Blockly.removeAllRanges(),this.isScrolling=!0,this.startDragMouseX=a.clientX,this.startDragMouseY=
|
|
|
|
|
a.clientY,this.startDragMetrics=this.getMetrics(),this.startScrollX=this.scrollX,this.startScrollY=this.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_)),a.stopPropagation())};
|
|
|
|
|
Blockly.WorkspaceSvg.prototype.startDrag=function(a,b,c){a=Blockly.mouseToSvg(a,this.options.svg);a.x/=this.scale;a.y/=this.scale;this.dragDeltaX_=b-a.x;this.dragDeltaY_=c-a.y};Blockly.WorkspaceSvg.prototype.moveDrag=function(a){a=Blockly.mouseToSvg(a,this.options.svg);a.x/=this.scale;a.y/=this.scale;return new goog.math.Coordinate(this.dragDeltaX_+a.x,this.dragDeltaY_+a.y)};
|
|
|
|
|
Blockly.WorkspaceSvg.prototype.onMouseWheel_=function(a){Blockly.terminateDrag_();var b=0<a.deltaY?-1:1,c=Blockly.mouseToSvg(a,this.options.svg);this.zoom(c.x,c.y,b);a.preventDefault()};Blockly.WorkspaceSvg.prototype.cleanUp_=function(){for(var a=this.getTopBlocks(!0),b=0,c=0,d;d=a[c];c++){var e=d.getRelativeToSurfaceXY();d.moveBy(-e.x,b-e.y);d.snapToGrid();b=d.getRelativeToSurfaceXY().y+d.getHeightWidth().height+Blockly.BlockSvg.MIN_BLOCK_Y}Blockly.fireUiEvent(window,"resize");this.fireChangeEvent()};
|
|
|
|
|
Blockly.WorkspaceSvg.prototype.showContextMenu_=function(a){function b(a){if(a.isDeletable())p=p.concat(a.getDescendants());else{a=a.getChildren();for(var c=0;c<a.length;c++)b(a[c])}}function c(){var a=p.shift();a&&(a.workspace?(a.dispose(!1,!0),setTimeout(c,10)):c())}if(!this.options.readOnly&&!this.isFlyout){var d=[],e=this.getTopBlocks(!0),f={};f.text=Blockly.Msg.CLEAN_UP;f.enabled=1<e.length;f.callback=this.cleanUp_.bind(this);d.push(f);if(this.options.collapse){for(var g=f=!1,h=0;h<e.length;h++)for(var k=
|
|
|
|
|
e[h];k;)k.isCollapsed()?f=!0:g=!0,k=k.getNextBlock();var l=function(a){for(var b=0,c=0;c<e.length;c++)for(var d=e[c];d;)setTimeout(d.setCollapsed.bind(d,a),b),d=d.getNextBlock(),b+=10},g={enabled:g};g.text=Blockly.Msg.COLLAPSE_ALL;g.callback=function(){l(!0)};d.push(g);f={enabled:f};f.text=Blockly.Msg.EXPAND_ALL;f.callback=function(){l(!1)};d.push(f)}for(var p=[],h=0;h<e.length;h++)b(e[h]);f={text:1>=p.length?Blockly.Msg.DELETE_BLOCK:Blockly.Msg.DELETE_X_BLOCKS.replace("%1",String(p.length)),enabled:0<
|
|
|
|
|
p.length,callback:function(){(2>p.length||window.confirm(Blockly.Msg.DELETE_ALL_BLOCKS.replace("%1",String(p.length))))&&c()}};d.push(f);Blockly.ContextMenu.show(a,d,this.RTL)}};Blockly.WorkspaceSvg.prototype.loadAudio_=function(a,b){if(a.length){try{var c=new window.Audio}catch(h){return}for(var d,e=0;e<a.length;e++){var f=a[e],g=f.match(/\.(\w+)$/);if(g&&c.canPlayType("audio/"+g[1])){d=new window.Audio(f);break}}d&&d.play&&(this.SOUNDS_[b]=d)}};
|
|
|
|
|
Blockly.WorkspaceSvg.prototype.isDeleteArea=function(a){a=Blockly.mouseToSvg(a,Blockly.mainWorkspace.getParentSvg());a=new goog.math.Coordinate(a.x,a.y);if(this.deleteAreaTrash_){if(this.deleteAreaTrash_.contains(a))return this.trashcan.setOpen_(!0),Blockly.Css.setCursor(Blockly.Css.Cursor.DELETE),!0;this.trashcan.setOpen_(!1)}if(this.deleteAreaToolbox_&&this.deleteAreaToolbox_.contains(a))return Blockly.Css.setCursor(Blockly.Css.Cursor.DELETE),!0;Blockly.Css.setCursor(Blockly.Css.Cursor.CLOSED);
|
|
|
|
|
return!1};
|
|
|
|
|
Blockly.WorkspaceSvg.prototype.onMouseDown_=function(a){this.markFocused();Blockly.isTargetInput_(a)||(Blockly.svgResize(this),Blockly.terminateDrag_(),Blockly.hideChaff(),a.target&&a.target.nodeName&&("svg"==a.target.nodeName.toLowerCase()||a.target==this.svgBackground_)&&Blockly.selected&&!this.options.readOnly&&Blockly.selected.unselect(),Blockly.isRightButton(a)?this.showContextMenu_(a):this.scrollbar&&(Blockly.removeAllRanges(),this.isScrolling=!0,this.startDragMouseX=a.clientX,this.startDragMouseY=a.clientY,
|
|
|
|
|
this.startDragMetrics=this.getMetrics(),this.startScrollX=this.scrollX,this.startScrollY=this.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_)),a.stopPropagation())};
|
|
|
|
|
Blockly.WorkspaceSvg.prototype.startDrag=function(a,b,c){a=Blockly.mouseToSvg(a,this.getParentSvg());a.x/=this.scale;a.y/=this.scale;this.dragDeltaX_=b-a.x;this.dragDeltaY_=c-a.y};Blockly.WorkspaceSvg.prototype.moveDrag=function(a){a=Blockly.mouseToSvg(a,this.getParentSvg());a.x/=this.scale;a.y/=this.scale;return new goog.math.Coordinate(this.dragDeltaX_+a.x,this.dragDeltaY_+a.y)};
|
|
|
|
|
Blockly.WorkspaceSvg.prototype.onMouseWheel_=function(a){Blockly.terminateDrag_();var b=0<a.deltaY?-1:1,c=Blockly.mouseToSvg(a,this.getParentSvg());this.zoom(c.x,c.y,b);a.preventDefault()};Blockly.WorkspaceSvg.prototype.cleanUp_=function(){for(var a=this.getTopBlocks(!0),b=0,c=0,d;d=a[c];c++){var e=d.getRelativeToSurfaceXY();d.moveBy(-e.x,b-e.y);d.snapToGrid();b=d.getRelativeToSurfaceXY().y+d.getHeightWidth().height+Blockly.BlockSvg.MIN_BLOCK_Y}Blockly.fireUiEvent(window,"resize");this.fireChangeEvent()};
|
|
|
|
|
Blockly.WorkspaceSvg.prototype.showContextMenu_=function(a){function b(a){if(a.isDeletable())q=q.concat(a.getDescendants());else{a=a.getChildren();for(var c=0;c<a.length;c++)b(a[c])}}function c(){var a=q.shift();a&&(a.workspace?(a.dispose(!1,!0),setTimeout(c,10)):c())}if(!this.options.readOnly&&!this.isFlyout){var d=[],e=this.getTopBlocks(!0),f={};f.text=Blockly.Msg.CLEAN_UP;f.enabled=1<e.length;f.callback=this.cleanUp_.bind(this);d.push(f);if(this.options.collapse){for(var g=f=!1,h=0;h<e.length;h++)for(var k=
|
|
|
|
|
e[h];k;)k.isCollapsed()?f=!0:g=!0,k=k.getNextBlock();var l=function(a){for(var b=0,c=0;c<e.length;c++)for(var d=e[c];d;)setTimeout(d.setCollapsed.bind(d,a),b),d=d.getNextBlock(),b+=10},g={enabled:g};g.text=Blockly.Msg.COLLAPSE_ALL;g.callback=function(){l(!0)};d.push(g);f={enabled:f};f.text=Blockly.Msg.EXPAND_ALL;f.callback=function(){l(!1)};d.push(f)}for(var q=[],h=0;h<e.length;h++)b(e[h]);f={text:1>=q.length?Blockly.Msg.DELETE_BLOCK:Blockly.Msg.DELETE_X_BLOCKS.replace("%1",String(q.length)),enabled:0<
|
|
|
|
|
q.length,callback:function(){(2>q.length||window.confirm(Blockly.Msg.DELETE_ALL_BLOCKS.replace("%1",String(q.length))))&&c()}};d.push(f);Blockly.ContextMenu.show(a,d,this.RTL)}};Blockly.WorkspaceSvg.prototype.loadAudio_=function(a,b){if(a.length){try{var c=new window.Audio}catch(h){return}for(var d,e=0;e<a.length;e++){var f=a[e],g=f.match(/\.(\w+)$/);if(g&&c.canPlayType("audio/"+g[1])){d=new window.Audio(f);break}}d&&d.play&&(this.SOUNDS_[b]=d)}};
|
|
|
|
|
Blockly.WorkspaceSvg.prototype.preloadAudio_=function(){for(var a in this.SOUNDS_){var b=this.SOUNDS_[a];b.volume=.01;b.play();b.pause();if(goog.userAgent.IPAD||goog.userAgent.IPHONE)break}};
|
|
|
|
|
Blockly.WorkspaceSvg.prototype.playAudio=function(a,b){var c=this.SOUNDS_[a];c?(c=goog.userAgent.DOCUMENT_MODE&&9===goog.userAgent.DOCUMENT_MODE||goog.userAgent.IPAD||goog.userAgent.ANDROID?c:c.cloneNode(),c.volume=void 0===b?1:b,c.play()):this.options.parentWorkspace&&this.options.parentWorkspace.playAudio(a,b)};
|
|
|
|
|
Blockly.WorkspaceSvg.prototype.updateToolbox=function(a){if(a=Blockly.parseToolboxTree_(a)){if(!this.options.languageTree)throw"Existing toolbox is null. Can't create new toolbox.";if(this.options.hasCategories){if(!this.toolbox_)throw"Existing toolbox has no categories. Can't change mode.";this.options.languageTree=a;this.toolbox_.populate_(a);this.toolbox_.addColour_()}else{if(!this.flyout_)throw"Existing toolbox has categories. Can't change mode.";this.options.languageTree=a;this.flyout_.show(a.childNodes)}}else if(this.options.languageTree)throw"Can't nullify an existing toolbox.";
|
|
|
|
|
};Blockly.WorkspaceSvg.prototype.addChangeListener=function(a){a=Blockly.bindEvent_(this.getCanvas(),"blocklyWorkspaceChange",null,a);Array.prototype.push.apply(this.eventWrappers_,a);return a};Blockly.WorkspaceSvg.prototype.removeChangeListener=function(a){Blockly.unbindEvent_(a);a=this.eventWrappers_.indexOf(a);-1!=a&&this.eventWrappers_.splice(a,1)};
|
|
|
|
|
Blockly.WorkspaceSvg.prototype.markFocused=function(){this.options.parentWorkspace?this.options.parentWorkspace.markFocused():Blockly.mainWorkspace=this};
|
|
|
|
|
Blockly.WorkspaceSvg.prototype.zoom=function(a,b,c){var d=this.options.zoomOptions.scaleSpeed,e=this.getMetrics(),f=this.options.svg.createSVGPoint();f.x=a;f.y=b;f=f.matrixTransform(this.getCanvas().getCTM().inverse());a=f.x;b=f.y;f=this.getCanvas();c=1==c?d:1/d;d=this.scale*c;d>this.options.zoomOptions.maxScale?c=this.options.zoomOptions.maxScale/this.scale:d<this.options.zoomOptions.minScale&&(c=this.options.zoomOptions.minScale/this.scale);a=f.getCTM().translate(a*(1-c),b*(1-c)).scale(c);this.scale!=
|
|
|
|
|
Blockly.WorkspaceSvg.prototype.zoom=function(a,b,c){var d=this.options.zoomOptions.scaleSpeed,e=this.getMetrics(),f=this.getParentSvg().createSVGPoint();f.x=a;f.y=b;f=f.matrixTransform(this.getCanvas().getCTM().inverse());a=f.x;b=f.y;f=this.getCanvas();c=1==c?d:1/d;d=this.scale*c;d>this.options.zoomOptions.maxScale?c=this.options.zoomOptions.maxScale/this.scale:d<this.options.zoomOptions.minScale&&(c=this.options.zoomOptions.minScale/this.scale);a=f.getCTM().translate(a*(1-c),b*(1-c)).scale(c);this.scale!=
|
|
|
|
|
a.a&&(this.scale=a.a,this.scrollX=a.e-e.absoluteLeft,this.scrollY=a.f-e.absoluteTop,this.updateGridPattern_(),this.scrollbar?this.scrollbar.resize():this.translate(0,0),Blockly.hideChaff(!1),this.flyout_&&this.flyout_.reflow())};Blockly.WorkspaceSvg.prototype.zoomCenter=function(a){var b=this.getMetrics();this.zoom(b.viewWidth/2,b.viewHeight/2,a)};
|
|
|
|
|
Blockly.WorkspaceSvg.prototype.zoomReset=function(a){this.scale=1;this.updateGridPattern_();Blockly.hideChaff(!1);this.flyout_&&this.flyout_.reflow();this.scrollbar&&this.scrollbar.resize();var b=this.getMetrics();this.scrollbar?this.scrollbar.set((b.contentWidth-b.viewWidth)/2,(b.contentHeight-b.viewHeight)/2):this.translate(0,0);a.stopPropagation()};
|
|
|
|
|
Blockly.WorkspaceSvg.prototype.updateGridPattern_=function(){if(this.options.gridPattern){var a=this.options.gridOptions.spacing*this.scale||100;this.options.gridPattern.setAttribute("width",a);this.options.gridPattern.setAttribute("height",a);var a=Math.floor(this.options.gridOptions.spacing/2)+.5,b=a-this.options.gridOptions.length/2,c=a+this.options.gridOptions.length/2,d=this.options.gridPattern.firstChild,e=d&&d.nextSibling,a=a*this.scale,b=b*this.scale,c=c*this.scale;d&&(d.setAttribute("stroke-width",
|
|
|
|
|
this.scale),d.setAttribute("x1",b),d.setAttribute("y1",a),d.setAttribute("x2",c),d.setAttribute("y2",a));e&&(e.setAttribute("stroke-width",this.scale),e.setAttribute("x1",a),e.setAttribute("y1",b),e.setAttribute("x2",a),e.setAttribute("y2",c))}};Blockly.WorkspaceSvg.prototype.setVisible=Blockly.WorkspaceSvg.prototype.setVisible;Blockly.WorkspaceSvg.prototype.addChangeListener=Blockly.WorkspaceSvg.prototype.addChangeListener;Blockly.WorkspaceSvg.prototype.removeChangeListener=Blockly.WorkspaceSvg.prototype.removeChangeListener;Blockly.Mutator=function(a){Blockly.Mutator.superClass_.constructor.call(this,null);this.quarkNames_=a};goog.inherits(Blockly.Mutator,Blockly.Icon);Blockly.Mutator.prototype.workspaceWidth_=0;Blockly.Mutator.prototype.workspaceHeight_=0;
|
|
|
|
|
Blockly.Mutator.prototype.drawIcon_=function(a){Blockly.createSvgElement("rect",{"class":"blocklyIconShape",rx:"4",ry:"4",height:"16",width:"16"},a);Blockly.createSvgElement("path",{"class":"blocklyIconSymbol",d:"m4.203,7.296 0,1.368 -0.92,0.677 -0.11,0.41 0.9,1.559 0.41,0.11 1.043,-0.457 1.187,0.683 0.127,1.134 0.3,0.3 1.8,0 0.3,-0.299 0.127,-1.138 1.185,-0.682 1.046,0.458 0.409,-0.11 0.9,-1.559 -0.11,-0.41 -0.92,-0.677 0,-1.366 0.92,-0.677 0.11,-0.41 -0.9,-1.559 -0.409,-0.109 -1.046,0.458 -1.185,-0.682 -0.127,-1.138 -0.3,-0.299 -1.8,0 -0.3,0.3 -0.126,1.135 -1.187,0.682 -1.043,-0.457 -0.41,0.11 -0.899,1.559 0.108,0.409z"},a);
|
|
|
|
|
Blockly.createSvgElement("circle",{"class":"blocklyIconShape",r:"2.7",cx:"8",cy:"8"},a)};Blockly.Mutator.prototype.iconClick_=function(a){this.block_.isEditable()&&Blockly.Icon.prototype.iconClick_.call(this,a)};
|
|
|
|
|
Blockly.Mutator.prototype.createEditor_=function(){this.svgDialog_=Blockly.createSvgElement("svg",{x:Blockly.Bubble.BORDER_WIDTH,y:Blockly.Bubble.BORDER_WIDTH},null);if(this.quarkNames_.length)for(var a=goog.dom.createDom("xml"),b=0,c;c=this.quarkNames_[b];b++)a.appendChild(goog.dom.createDom("block",{type:c}));else a=null;var d=this;this.workspace_=new Blockly.WorkspaceSvg({languageTree:a,parentWorkspace:this.block_.workspace,pathToMedia:this.block_.workspace.options.pathToMedia,RTL:this.block_.RTL,
|
|
|
|
|
getMetrics:function(){return d.getFlyoutMetrics_()},setMetrics:null,svg:this.svgDialog_});this.svgDialog_.appendChild(this.workspace_.createDom("blocklyMutatorBackground"));return this.svgDialog_};Blockly.Mutator.prototype.updateEditable=function(){this.block_.isEditable()?Blockly.Icon.prototype.updateEditable.call(this):(this.setVisible(!1),this.iconGroup_&&Blockly.addClass_(this.iconGroup_,"blocklyIconGroupReadonly"))};
|
|
|
|
|
Blockly.Mutator.prototype.createEditor_=function(){this.svgDialog_=Blockly.createSvgElement("svg",{x:Blockly.Bubble.BORDER_WIDTH,y:Blockly.Bubble.BORDER_WIDTH},null);if(this.quarkNames_.length)for(var a=goog.dom.createDom("xml"),b=0,c;c=this.quarkNames_[b];b++)a.appendChild(goog.dom.createDom("block",{type:c}));else a=null;a={languageTree:a,parentWorkspace:this.block_.workspace,pathToMedia:this.block_.workspace.options.pathToMedia,RTL:this.block_.RTL,getMetrics:this.getFlyoutMetrics_.bind(this),setMetrics:null};
|
|
|
|
|
this.workspace_=new Blockly.WorkspaceSvg(a);this.svgDialog_.appendChild(this.workspace_.createDom("blocklyMutatorBackground"));return this.svgDialog_};Blockly.Mutator.prototype.updateEditable=function(){this.block_.isEditable()?Blockly.Icon.prototype.updateEditable.call(this):(this.setVisible(!1),this.iconGroup_&&Blockly.addClass_(this.iconGroup_,"blocklyIconGroupReadonly"))};
|
|
|
|
|
Blockly.Mutator.prototype.resizeBubble_=function(){var a=2*Blockly.Bubble.BORDER_WIDTH,b=this.workspace_.getCanvas().getBBox(),c;c=this.block_.RTL?-b.x:b.width+b.x;b=b.height+3*a;if(this.workspace_.flyout_)var d=this.workspace_.flyout_.getMetrics_(),b=Math.max(b,d.contentHeight+20);c+=3*a;if(Math.abs(this.workspaceWidth_-c)>a||Math.abs(this.workspaceHeight_-b)>a)this.workspaceWidth_=c,this.workspaceHeight_=b,this.bubble_.setBubbleSize(c+a,b+a),this.svgDialog_.setAttribute("width",this.workspaceWidth_),
|
|
|
|
|
this.svgDialog_.setAttribute("height",this.workspaceHeight_);this.block_.RTL&&(a="translate("+this.workspaceWidth_+",0)",this.workspace_.getCanvas().setAttribute("transform",a));this.workspace_.resize()};
|
|
|
|
|
Blockly.Mutator.prototype.setVisible=function(a){if(a!=this.isVisible())if(a){this.bubble_=new Blockly.Bubble(this.block_.workspace,this.createEditor_(),this.block_.svgPath_,this.iconX_,this.iconY_,null,null);if(a=this.workspace_.options.languageTree)this.workspace_.flyout_.init(this.workspace_),this.workspace_.flyout_.show(a.childNodes);this.rootBlock_=this.block_.decompose(this.workspace_);a=this.rootBlock_.getDescendants();for(var b=0,c;c=a[b];b++)c.render();this.rootBlock_.setMovable(!1);this.rootBlock_.setDeletable(!1);
|
|
|
|
@ -1069,8 +1068,8 @@ Blockly.Block.prototype.moveNumberedInputBefore=function(a,b){goog.asserts.asser
|
|
|
|
|
Blockly.Block.prototype.removeInput=function(a,b){for(var c=0,d;d=this.inputList[c];c++)if(d.name==a){d.connection&&d.connection.targetConnection&&d.connection.targetBlock().setParent(null);d.dispose();this.inputList.splice(c,1);this.rendered&&(this.render(),this.bumpNeighbours_());return}b||goog.asserts.fail('Input "%s" not found.',a)};Blockly.Block.prototype.getInput=function(a){for(var b=0,c;c=this.inputList[b];b++)if(c.name==a)return c;return null};
|
|
|
|
|
Blockly.Block.prototype.getInputTargetBlock=function(a){return(a=this.getInput(a))&&a.connection&&a.connection.targetBlock()};Blockly.Block.prototype.getCommentText=function(){return this.comment||""};Blockly.Block.prototype.setCommentText=function(a){this.comment=a};Blockly.Block.prototype.setWarningText=function(a){};Blockly.Block.prototype.setMutator=function(a){};Blockly.Block.prototype.getRelativeToSurfaceXY=function(){return this.xy_};
|
|
|
|
|
Blockly.Block.prototype.moveBy=function(a,b){this.xy_.translate(a,b)};Blockly.Block.BlockDB_=Object.create(null);Blockly.Block.getById=function(a){return Blockly.Block.BlockDB_[a]||null};Blockly.ContextMenu={};Blockly.ContextMenu.currentBlock=null;
|
|
|
|
|
Blockly.ContextMenu.show=function(a,b,c){Blockly.WidgetDiv.show(Blockly.ContextMenu,c,null);if(b.length){var d=new goog.ui.Menu;d.setRightToLeft(c);for(var e=0,f;f=b[e];e++){var g=new goog.ui.MenuItem(f.text);g.setRightToLeft(c);d.addChild(g,!0);g.setEnabled(f.enabled);f.enabled&&goog.events.listen(g,goog.ui.Component.EventType.ACTION,function(a){return function(){Blockly.doCommand(a)}}(f.callback))}goog.events.listen(d,goog.ui.Component.EventType.ACTION,Blockly.ContextMenu.hide);b=goog.dom.getViewportSize();
|
|
|
|
|
f=goog.style.getViewportPageOffset(document);d.render(Blockly.WidgetDiv.DIV);var h=d.getElement();Blockly.addClass_(h,"blocklyContextMenu");var g=goog.style.getSize(h),e=a.clientX+f.x,k=a.clientY+f.y;a.clientY+g.height>=b.height&&(k-=g.height);c?g.width>=a.clientX&&(e+=g.width):a.clientX+g.width>=b.width&&(e-=g.width);Blockly.WidgetDiv.position(e,k,b,f,c);d.setAllowAutoFocus(!0);setTimeout(function(){h.focus()},1);Blockly.ContextMenu.currentBlock=null}else Blockly.ContextMenu.hide()};
|
|
|
|
|
Blockly.ContextMenu.show=function(a,b,c){Blockly.WidgetDiv.show(Blockly.ContextMenu,c,null);if(b.length){var d=new goog.ui.Menu;d.setRightToLeft(c);for(var e=0,f;f=b[e];e++){var g=new goog.ui.MenuItem(f.text);g.setRightToLeft(c);d.addChild(g,!0);g.setEnabled(f.enabled);f.enabled&&goog.events.listen(g,goog.ui.Component.EventType.ACTION,f.callback)}goog.events.listen(d,goog.ui.Component.EventType.ACTION,Blockly.ContextMenu.hide);b=goog.dom.getViewportSize();f=goog.style.getViewportPageOffset(document);
|
|
|
|
|
d.render(Blockly.WidgetDiv.DIV);var h=d.getElement();Blockly.addClass_(h,"blocklyContextMenu");var g=goog.style.getSize(h),e=a.clientX+f.x,k=a.clientY+f.y;a.clientY+g.height>=b.height&&(k-=g.height);c?g.width>=a.clientX&&(e+=g.width):a.clientX+g.width>=b.width&&(e-=g.width);Blockly.WidgetDiv.position(e,k,b,f,c);d.setAllowAutoFocus(!0);setTimeout(function(){h.focus()},1);Blockly.ContextMenu.currentBlock=null}else Blockly.ContextMenu.hide()};
|
|
|
|
|
Blockly.ContextMenu.hide=function(){Blockly.WidgetDiv.hideIfOwner(Blockly.ContextMenu);Blockly.ContextMenu.currentBlock=null};Blockly.ContextMenu.callbackFactory=function(a,b){return function(){var c=Blockly.Xml.domToBlock(a.workspace,b),d=a.getRelativeToSurfaceXY();d.x=a.RTL?d.x-Blockly.SNAP_RADIUS:d.x+Blockly.SNAP_RADIUS;d.y+=2*Blockly.SNAP_RADIUS;c.moveBy(d.x,d.y);c.select()}};Blockly.BlockSvg=function(a,b,c){this.svgGroup_=Blockly.createSvgElement("g",{},null);this.svgPathDark_=Blockly.createSvgElement("path",{"class":"blocklyPathDark",transform:"translate(1,1)"},this.svgGroup_);this.svgPath_=Blockly.createSvgElement("path",{"class":"blocklyPath"},this.svgGroup_);this.svgPathLight_=Blockly.createSvgElement("path",{"class":"blocklyPathLight"},this.svgGroup_);this.svgPath_.tooltip=this;Blockly.Tooltip.bindMouseEvents(this.svgPath_);Blockly.BlockSvg.superClass_.constructor.call(this,
|
|
|
|
|
a,b,c)};goog.inherits(Blockly.BlockSvg,Blockly.Block);Blockly.BlockSvg.prototype.height=0;Blockly.BlockSvg.prototype.width=0;Blockly.BlockSvg.prototype.dragStartXY_=null;Blockly.BlockSvg.INLINE=-1;
|
|
|
|
|
Blockly.BlockSvg.prototype.initSvg=function(){goog.asserts.assert(this.workspace.rendered,"Workspace is headless.");for(var a=0,b;b=this.inputList[a];a++)b.init();b=this.getIcons();for(a=0;a<b.length;a++)b[a].createIcon();this.updateColour();this.updateMovable();if(!this.workspace.options.readOnly&&!this.eventsInit_){Blockly.bindEvent_(this.getSvgRoot(),"mousedown",this,this.onMouseDown_);var c=this;Blockly.bindEvent_(this.getSvgRoot(),"touchstart",null,function(a){Blockly.longStart_(a,c)})}goog.isFunction(this.onchange)&&
|
|
|
|
@ -1080,23 +1079,23 @@ Blockly.BlockSvg.onMouseMoveWrapper_=null;
|
|
|
|
|
Blockly.BlockSvg.terminateDrag_=function(){Blockly.BlockSvg.disconnectUiStop_();Blockly.BlockSvg.onMouseUpWrapper_&&(Blockly.unbindEvent_(Blockly.BlockSvg.onMouseUpWrapper_),Blockly.BlockSvg.onMouseUpWrapper_=null);Blockly.BlockSvg.onMouseMoveWrapper_&&(Blockly.unbindEvent_(Blockly.BlockSvg.onMouseMoveWrapper_),Blockly.BlockSvg.onMouseMoveWrapper_=null);var a=Blockly.selected;if(2==Blockly.dragMode_&&a){var b=a.getRelativeToSurfaceXY(),b=goog.math.Coordinate.difference(b,a.dragStartXY_);a.moveConnections_(b.x,
|
|
|
|
|
b.y);delete a.draggedBubbles_;a.setDragging_(!1);a.render();goog.Timer.callOnce(a.snapToGrid,Blockly.BUMP_DELAY/2,a);goog.Timer.callOnce(a.bumpNeighbours_,Blockly.BUMP_DELAY,a);Blockly.fireUiEvent(window,"resize");a.workspace.fireChangeEvent()}Blockly.dragMode_=0;Blockly.Css.setCursor(Blockly.Css.Cursor.OPEN)};
|
|
|
|
|
Blockly.BlockSvg.prototype.setParent=function(a){var b=this.getSvgRoot();if(this.parentBlock_&&b){var c=this.getRelativeToSurfaceXY();this.workspace.getCanvas().appendChild(b);b.setAttribute("transform","translate("+c.x+","+c.y+")")}Blockly.Field.startCache();Blockly.BlockSvg.superClass_.setParent.call(this,a);Blockly.Field.stopCache();a&&(c=this.getRelativeToSurfaceXY(),a.getSvgRoot().appendChild(b),a=this.getRelativeToSurfaceXY(),this.moveConnections_(a.x-c.x,a.y-c.y))};
|
|
|
|
|
Blockly.BlockSvg.prototype.getRelativeToSurfaceXY=function(){var a=0,b=0,c=this.getSvgRoot();if(c){do var d=Blockly.getRelativeXY_(c),a=a+d.x,b=b+d.y,c=c.parentNode;while(c&&c!=this.workspace.getCanvas())}return new goog.math.Coordinate(a,b)};Blockly.BlockSvg.prototype.moveBy=function(a,b){var c=this.getRelativeToSurfaceXY();this.getSvgRoot().setAttribute("transform","translate("+(c.x+a)+","+(c.y+b)+")");this.moveConnections_(a,b);Blockly.Realtime.blockChanged(this)};
|
|
|
|
|
Blockly.BlockSvg.prototype.getRelativeToSurfaceXY=function(){var a=0,b=0,c=this.getSvgRoot();if(c){do var d=Blockly.getRelativeXY_(c),a=a+d.x,b=b+d.y,c=c.parentNode;while(c&&c!=this.workspace.getCanvas())}return new goog.math.Coordinate(a,b)};Blockly.BlockSvg.prototype.moveBy=function(a,b){var c=this.getRelativeToSurfaceXY();this.getSvgRoot().setAttribute("transform","translate("+(c.x+a)+","+(c.y+b)+")");this.moveConnections_(a,b)};
|
|
|
|
|
Blockly.BlockSvg.prototype.snapToGrid=function(){if(this.workspace&&0==Blockly.dragMode_&&!this.getParent()&&!this.isInFlyout&&this.workspace.options.gridOptions&&this.workspace.options.gridOptions.snap){var a=this.workspace.options.gridOptions.spacing,b=a/2,c=this.getRelativeToSurfaceXY(),d=Math.round((c.x-b)/a)*a+b-c.x,a=Math.round((c.y-b)/a)*a+b-c.y,d=Math.round(d),a=Math.round(a);0==d&&0==a||this.moveBy(d,a)}};
|
|
|
|
|
Blockly.BlockSvg.prototype.getHeightWidth=function(){var a=this.height,b=this.width,c=this.getNextBlock();c?(c=c.getHeightWidth(),a+=c.height-4,b=Math.max(b,c.width)):this.nextConnection||this.outputConnection||(a+=2);return{height:a,width:b}};
|
|
|
|
|
Blockly.BlockSvg.prototype.setCollapsed=function(a){if(this.collapsed_!=a){for(var b=[],c=0,d;d=this.inputList[c];c++)b.push.apply(b,d.setVisible(!a));if(a){d=this.getIcons();for(c=0;c<d.length;c++)d[c].setVisible(!1);c=this.toString(Blockly.COLLAPSE_CHARS);this.appendDummyInput("_TEMP_COLLAPSED_INPUT").appendField(c).init()}else this.removeInput("_TEMP_COLLAPSED_INPUT"),this.setWarningText(null);Blockly.BlockSvg.superClass_.setCollapsed.call(this,a);b.length||(b[0]=this);if(this.rendered)for(c=0;a=
|
|
|
|
|
b[c];c++)a.render();this.workspace.fireChangeEvent()}};Blockly.BlockSvg.prototype.tab=function(a,b){for(var c=[],d=0,e;e=this.inputList[d];d++){for(var f=0,g;g=e.fieldRow[f];f++)g instanceof Blockly.FieldTextInput&&c.push(g);e.connection&&(e=e.connection.targetBlock())&&c.push(e)}d=c.indexOf(a);-1==d&&(d=b?-1:c.length);(c=c[b?d+1:d-1])?c instanceof Blockly.Field?c.showEditor_():c.tab(null,b):(c=this.getParent())&&c.tab(this,b)};
|
|
|
|
|
Blockly.BlockSvg.prototype.onMouseDown_=function(a){if(!this.isInFlyout)if(this.workspace.markFocused(),Blockly.svgResize(this.workspace),Blockly.terminateDrag_(),this.select(),Blockly.hideChaff(),Blockly.isRightButton(a))this.showContextMenu_(a);else if(this.isMovable()){Blockly.removeAllRanges();Blockly.Css.setCursor(Blockly.Css.Cursor.CLOSED);this.dragStartXY_=this.getRelativeToSurfaceXY();this.workspace.startDrag(a,this.dragStartXY_.x,this.dragStartXY_.y);Blockly.dragMode_=1;Blockly.BlockSvg.onMouseUpWrapper_=
|
|
|
|
|
Blockly.bindEvent_(document,"mouseup",this,this.onMouseUp_);Blockly.BlockSvg.onMouseMoveWrapper_=Blockly.bindEvent_(document,"mousemove",this,this.onMouseMove_);this.draggedBubbles_=[];for(var b=this.getDescendants(),c=0,d;d=b[c];c++){d=d.getIcons();for(var e=0;e<d.length;e++){var f=d[e].getIconLocation();f.bubble=d[e];this.draggedBubbles_.push(f)}}}else return;a.stopPropagation()};
|
|
|
|
|
Blockly.BlockSvg.prototype.onMouseUp_=function(a){var b=this;Blockly.doCommand(function(){Blockly.terminateDrag_();if(Blockly.selected&&Blockly.highlightedConnection_)Blockly.localConnection_.connect(Blockly.highlightedConnection_),b.rendered&&(Blockly.localConnection_.isSuperior()?Blockly.highlightedConnection_:Blockly.localConnection_).sourceBlock_.connectionUiEffect(),b.workspace.trashcan&&b.workspace.trashcan.close();else if(!b.getParent()&&Blockly.selected.isDeletable()&&b.workspace.isDeleteArea(a)){var c=
|
|
|
|
|
b.workspace.trashcan;c&&goog.Timer.callOnce(c.close,100,c);Blockly.selected.dispose(!1,!0);Blockly.fireUiEvent(window,"resize")}Blockly.highlightedConnection_&&(Blockly.highlightedConnection_.unhighlight(),Blockly.highlightedConnection_=null);Blockly.Css.setCursor(Blockly.Css.Cursor.OPEN)})};Blockly.BlockSvg.prototype.showHelp_=function(){var a=goog.isFunction(this.helpUrl)?this.helpUrl():this.helpUrl;a&&window.open(a)};
|
|
|
|
|
Blockly.BlockSvg.prototype.showContextMenu_=function(a){if(!this.workspace.options.readOnly&&this.contextMenu){var b=this,c=[];if(this.isDeletable()&&this.isMovable()&&!b.isInFlyout){var d={text:Blockly.Msg.DUPLICATE_BLOCK,enabled:!0,callback:function(){Blockly.duplicate_(b)}};this.getDescendants().length>this.workspace.remainingCapacity()&&(d.enabled=!1);c.push(d);this.isEditable()&&!this.collapsed_&&this.workspace.options.comments&&(d={enabled:!0},this.comment?(d.text=Blockly.Msg.REMOVE_COMMENT,
|
|
|
|
|
Blockly.BlockSvg.prototype.onMouseUp_=function(a){Blockly.terminateDrag_();Blockly.selected&&Blockly.highlightedConnection_?(Blockly.localConnection_.connect(Blockly.highlightedConnection_),this.rendered&&(Blockly.localConnection_.isSuperior()?Blockly.highlightedConnection_:Blockly.localConnection_).sourceBlock_.connectionUiEffect(),this.workspace.trashcan&&this.workspace.trashcan.close()):!this.getParent()&&Blockly.selected.isDeletable()&&this.workspace.isDeleteArea(a)&&((a=this.workspace.trashcan)&&
|
|
|
|
|
goog.Timer.callOnce(a.close,100,a),Blockly.selected.dispose(!1,!0),Blockly.fireUiEvent(window,"resize"));Blockly.highlightedConnection_&&(Blockly.highlightedConnection_.unhighlight(),Blockly.highlightedConnection_=null);Blockly.Css.setCursor(Blockly.Css.Cursor.OPEN)};Blockly.BlockSvg.prototype.showHelp_=function(){var a=goog.isFunction(this.helpUrl)?this.helpUrl():this.helpUrl;a&&window.open(a)};
|
|
|
|
|
Blockly.BlockSvg.prototype.showContextMenu_=function(a){if(!this.workspace.options.readOnly&&this.contextMenu){var b=this,c=[];if(this.isDeletable()&&this.isMovable()&&!b.isInFlyout){var d={text:Blockly.Msg.DUPLICATE_BLOCK,enabled:!0,callback:function(){Blockly.duplicate_(b)}};this.getDescendants().length>this.workspace.remainingCapacity()&&(d.enabled=!1);c.push(d);this.isEditable()&&!this.collapsed_&&this.workspace.options.comments&&(d={enabled:!goog.userAgent.IE},this.comment?(d.text=Blockly.Msg.REMOVE_COMMENT,
|
|
|
|
|
d.callback=function(){b.setCommentText(null)}):(d.text=Blockly.Msg.ADD_COMMENT,d.callback=function(){b.setCommentText("")}),c.push(d));if(!this.collapsed_)for(d=1;d<this.inputList.length;d++)if(this.inputList[d-1].type!=Blockly.NEXT_STATEMENT&&this.inputList[d].type!=Blockly.NEXT_STATEMENT){var d={enabled:!0},e=this.getInputsInline();d.text=e?Blockly.Msg.EXTERNAL_INPUTS:Blockly.Msg.INLINE_INPUTS;d.callback=function(){b.setInputsInline(!e)};c.push(d);break}this.workspace.options.collapse&&(this.collapsed_?
|
|
|
|
|
(d={enabled:!0},d.text=Blockly.Msg.EXPAND_BLOCK,d.callback=function(){b.setCollapsed(!1)}):(d={enabled:!0},d.text=Blockly.Msg.COLLAPSE_BLOCK,d.callback=function(){b.setCollapsed(!0)}),c.push(d));this.workspace.options.disable&&(d={text:this.disabled?Blockly.Msg.ENABLE_BLOCK:Blockly.Msg.DISABLE_BLOCK,enabled:!this.getInheritedDisabled(),callback:function(){b.setDisabled(!b.disabled)}},c.push(d));var d=this.getDescendants().length,f=this.getNextBlock();f&&(d-=f.getDescendants().length);d={text:1==d?
|
|
|
|
|
Blockly.Msg.DELETE_BLOCK:Blockly.Msg.DELETE_X_BLOCKS.replace("%1",String(d)),enabled:!0,callback:function(){b.dispose(!0,!0)}};c.push(d)}d={enabled:!(goog.isFunction(this.helpUrl)?!this.helpUrl():!this.helpUrl)};d.text=Blockly.Msg.HELP;d.callback=function(){b.showHelp_()};c.push(d);this.customContextMenu&&!b.isInFlyout&&this.customContextMenu(c);Blockly.ContextMenu.show(a,c,this.RTL);Blockly.ContextMenu.currentBlock=this}};
|
|
|
|
|
Blockly.BlockSvg.prototype.moveConnections_=function(a,b){if(this.rendered){for(var c=this.getConnections_(!1),d=0;d<c.length;d++)c[d].moveBy(a,b);c=this.getIcons();for(d=0;d<c.length;d++)c[d].computeIconLocation();for(d=0;d<this.childBlocks_.length;d++)this.childBlocks_[d].moveConnections_(a,b)}};Blockly.BlockSvg.prototype.setDragging_=function(a){a?this.addDragging():this.removeDragging();for(var b=0;b<this.childBlocks_.length;b++)this.childBlocks_[b].setDragging_(a)};
|
|
|
|
|
Blockly.BlockSvg.prototype.onMouseMove_=function(a){var b=this,c=this.workspace;Blockly.doCommand(function(){if(!("mousemove"==a.type&&1>=a.clientX&&0==a.clientY&&0==a.button)){Blockly.removeAllRanges();var d=b.getRelativeToSurfaceXY(),e=c.moveDrag(a),f=b.getSvgRoot();1==Blockly.dragMode_&&goog.math.Coordinate.distance(d,e)*c.scale>Blockly.DRAG_RADIUS&&(Blockly.dragMode_=2,Blockly.longStop_(),f.translate_="",f.skew_="",b.parentBlock_&&(b.setParent(null),b.disconnectUiEffect()),b.setDragging_(!0),
|
|
|
|
|
c.recordDeleteAreas());if(2==Blockly.dragMode_){var g=d.x-b.dragStartXY_.x,d=d.y-b.dragStartXY_.y;f.translate_="translate("+e.x+","+e.y+")";f.setAttribute("transform",f.translate_+f.skew_);for(e=0;e<b.draggedBubbles_.length;e++)f=b.draggedBubbles_[e],f.bubble.setIconLocation(f.x+g,f.y+d);for(var f=b.getConnections_(!1),h=null,k=null,l=Blockly.SNAP_RADIUS,e=0;e<f.length;e++){var p=f[e],m=p.closest(l,g,d);m.connection&&(h=m.connection,k=p,l=m.radius)}Blockly.highlightedConnection_&&Blockly.highlightedConnection_!=
|
|
|
|
|
h&&(Blockly.highlightedConnection_.unhighlight(),Blockly.highlightedConnection_=null,Blockly.localConnection_=null);h&&h!=Blockly.highlightedConnection_&&(h.highlight(),Blockly.highlightedConnection_=h,Blockly.localConnection_=k);b.isDeletable()&&c.isDeleteArea(a)}}a.stopPropagation()})};Blockly.BlockSvg.prototype.updateMovable=function(){this.isMovable()?Blockly.addClass_(this.svgGroup_,"blocklyDraggable"):Blockly.removeClass_(this.svgGroup_,"blocklyDraggable")};
|
|
|
|
|
Blockly.BlockSvg.prototype.onMouseMove_=function(a){if(!("mousemove"==a.type&&1>=a.clientX&&0==a.clientY&&0==a.button)){Blockly.removeAllRanges();var b=this.getRelativeToSurfaceXY(),c=this.workspace.moveDrag(a),d=this.getSvgRoot();1==Blockly.dragMode_&&goog.math.Coordinate.distance(b,c)*this.workspace.scale>Blockly.DRAG_RADIUS&&(Blockly.dragMode_=2,Blockly.longStop_(),d.translate_="",d.skew_="",this.parentBlock_&&(this.setParent(null),this.disconnectUiEffect()),this.setDragging_(!0),this.workspace.recordDeleteAreas());
|
|
|
|
|
if(2==Blockly.dragMode_){var e=b.x-this.dragStartXY_.x,b=b.y-this.dragStartXY_.y;d.translate_="translate("+c.x+","+c.y+")";d.setAttribute("transform",d.translate_+d.skew_);for(c=0;c<this.draggedBubbles_.length;c++)d=this.draggedBubbles_[c],d.bubble.setIconLocation(d.x+e,d.y+b);for(var d=this.getConnections_(!1),f=null,g=null,h=Blockly.SNAP_RADIUS,c=0;c<d.length;c++){var k=d[c],l=k.closest(h,e,b);l.connection&&(f=l.connection,g=k,h=l.radius)}Blockly.highlightedConnection_&&Blockly.highlightedConnection_!=
|
|
|
|
|
f&&(Blockly.highlightedConnection_.unhighlight(),Blockly.highlightedConnection_=null,Blockly.localConnection_=null);f&&f!=Blockly.highlightedConnection_&&(f.highlight(),Blockly.highlightedConnection_=f,Blockly.localConnection_=g);this.isDeletable()&&this.workspace.isDeleteArea(a)}}a.stopPropagation()};Blockly.BlockSvg.prototype.updateMovable=function(){this.isMovable()?Blockly.addClass_(this.svgGroup_,"blocklyDraggable"):Blockly.removeClass_(this.svgGroup_,"blocklyDraggable")};
|
|
|
|
|
Blockly.BlockSvg.prototype.setMovable=function(a){Blockly.BlockSvg.superClass_.setMovable.call(this,a);this.updateMovable()};Blockly.BlockSvg.prototype.setEditable=function(a){Blockly.BlockSvg.superClass_.setEditable.call(this,a);if(this.rendered)for(a=0;a<this.icons_.length;a++)this.icons_[a].updateEditable()};Blockly.BlockSvg.prototype.setShadow=function(a){Blockly.BlockSvg.superClass_.setShadow.call(this,a);this.updateColour()};Blockly.BlockSvg.prototype.getSvgRoot=function(){return this.svgGroup_};
|
|
|
|
|
Blockly.BlockSvg.SEP_SPACE_X=10;Blockly.BlockSvg.SEP_SPACE_Y=10;Blockly.BlockSvg.INLINE_PADDING_Y=5;Blockly.BlockSvg.MIN_BLOCK_Y=25;Blockly.BlockSvg.TAB_HEIGHT=20;Blockly.BlockSvg.TAB_WIDTH=8;Blockly.BlockSvg.NOTCH_WIDTH=30;Blockly.BlockSvg.CORNER_RADIUS=8;Blockly.BlockSvg.START_HAT=!1;Blockly.BlockSvg.START_HAT_PATH="c 30,-15 70,-15 100,0";Blockly.BlockSvg.START_HAT_HIGHLIGHT_LTR="c 17.8,-9.2 45.3,-14.9 75,-8.7 M 100.5,0.5";Blockly.BlockSvg.START_HAT_HIGHLIGHT_RTL="m 25,-8.7 c 29.7,-6.2 57.2,-0.5 75,8.7";
|
|
|
|
|
Blockly.BlockSvg.DISTANCE_45_INSIDE=(1-Math.SQRT1_2)*(Blockly.BlockSvg.CORNER_RADIUS-.5)+.5;Blockly.BlockSvg.DISTANCE_45_OUTSIDE=(1-Math.SQRT1_2)*(Blockly.BlockSvg.CORNER_RADIUS+.5)-.5;Blockly.BlockSvg.NOTCH_PATH_LEFT="l 6,4 3,0 6,-4";Blockly.BlockSvg.NOTCH_PATH_LEFT_HIGHLIGHT="l 6,4 3,0 6,-4";Blockly.BlockSvg.NOTCH_PATH_RIGHT="l -6,4 -3,0 -6,-4";Blockly.BlockSvg.JAGGED_TEETH="l 8,0 0,4 8,4 -16,8 8,4";Blockly.BlockSvg.JAGGED_TEETH_HEIGHT=20;Blockly.BlockSvg.JAGGED_TEETH_WIDTH=15;
|
|
|
|
@ -1106,10 +1105,11 @@ Blockly.BlockSvg.TOP_LEFT_CORNER_HIGHLIGHT="A "+(Blockly.BlockSvg.CORNER_RADIUS-
|
|
|
|
|
Blockly.BlockSvg.INNER_BOTTOM_LEFT_CORNER="a "+Blockly.BlockSvg.CORNER_RADIUS+","+Blockly.BlockSvg.CORNER_RADIUS+" 0 0,0 "+Blockly.BlockSvg.CORNER_RADIUS+","+Blockly.BlockSvg.CORNER_RADIUS;Blockly.BlockSvg.INNER_TOP_LEFT_CORNER_HIGHLIGHT_RTL="a "+Blockly.BlockSvg.CORNER_RADIUS+","+Blockly.BlockSvg.CORNER_RADIUS+" 0 0,0 "+(-Blockly.BlockSvg.DISTANCE_45_OUTSIDE-.5)+","+(Blockly.BlockSvg.CORNER_RADIUS-Blockly.BlockSvg.DISTANCE_45_OUTSIDE);
|
|
|
|
|
Blockly.BlockSvg.INNER_BOTTOM_LEFT_CORNER_HIGHLIGHT_RTL="a "+(Blockly.BlockSvg.CORNER_RADIUS+.5)+","+(Blockly.BlockSvg.CORNER_RADIUS+.5)+" 0 0,0 "+(Blockly.BlockSvg.CORNER_RADIUS+.5)+","+(Blockly.BlockSvg.CORNER_RADIUS+.5);Blockly.BlockSvg.INNER_BOTTOM_LEFT_CORNER_HIGHLIGHT_LTR="a "+(Blockly.BlockSvg.CORNER_RADIUS+.5)+","+(Blockly.BlockSvg.CORNER_RADIUS+.5)+" 0 0,0 "+(Blockly.BlockSvg.CORNER_RADIUS-Blockly.BlockSvg.DISTANCE_45_OUTSIDE)+","+(Blockly.BlockSvg.DISTANCE_45_OUTSIDE+.5);
|
|
|
|
|
Blockly.BlockSvg.prototype.dispose=function(a,b,c){Blockly.Field.startCache();this.onchangeWrapper_&&(Blockly.unbindEvent_(this.onchangeWrapper_),this.onchangeWrapper_=null);Blockly.selected==this&&Blockly.terminateDrag_();Blockly.ContextMenu.currentBlock==this&&Blockly.ContextMenu.hide();b&&this.rendered&&(this.unplug(a,!1),this.disposeUiEffect());this.rendered=!1;b=this.getIcons();for(c=0;c<b.length;c++)b[c].dispose();Blockly.BlockSvg.superClass_.dispose.call(this,a);goog.dom.removeNode(this.svgGroup_);
|
|
|
|
|
this.svgPathDark_=this.svgPathLight_=this.svgPath_=this.svgGroup_=null;Blockly.Field.stopCache()};Blockly.BlockSvg.prototype.disposeUiEffect=function(){this.workspace.playAudio("delete");var a=Blockly.getSvgXY_(this.svgGroup_,this.workspace),b=this.svgGroup_.cloneNode(!0);b.translateX_=a.x;b.translateY_=a.y;b.setAttribute("transform","translate("+b.translateX_+","+b.translateY_+")");this.workspace.options.svg.appendChild(b);b.bBox_=b.getBBox();Blockly.BlockSvg.disposeUiStep_(b,this.RTL,new Date,this.workspace.scale)};
|
|
|
|
|
this.svgPathDark_=this.svgPathLight_=this.svgPath_=this.svgGroup_=null;Blockly.Field.stopCache()};
|
|
|
|
|
Blockly.BlockSvg.prototype.disposeUiEffect=function(){this.workspace.playAudio("delete");var a=Blockly.getSvgXY_(this.svgGroup_,this.workspace),b=this.svgGroup_.cloneNode(!0);b.translateX_=a.x;b.translateY_=a.y;b.setAttribute("transform","translate("+b.translateX_+","+b.translateY_+")");this.workspace.getParentSvg().appendChild(b);b.bBox_=b.getBBox();Blockly.BlockSvg.disposeUiStep_(b,this.RTL,new Date,this.workspace.scale)};
|
|
|
|
|
Blockly.BlockSvg.disposeUiStep_=function(a,b,c,d){var e=(new Date-c)/150;1<e?goog.dom.removeNode(a):(a.setAttribute("transform","translate("+(a.translateX_+(b?-1:1)*a.bBox_.width*d/2*e)+","+(a.translateY_+a.bBox_.height*d*e)+") scale("+(1-e)*d+")"),setTimeout(function(){Blockly.BlockSvg.disposeUiStep_(a,b,c,d)},10))};
|
|
|
|
|
Blockly.BlockSvg.prototype.connectionUiEffect=function(){this.workspace.playAudio("click");if(!(1>this.workspace.scale)){var a=Blockly.getSvgXY_(this.svgGroup_,this.workspace);this.outputConnection?(a.x+=(this.RTL?3:-3)*this.workspace.scale,a.y+=13*this.workspace.scale):this.previousConnection&&(a.x+=(this.RTL?-23:23)*this.workspace.scale,a.y+=3*this.workspace.scale);a=Blockly.createSvgElement("circle",{cx:a.x,cy:a.y,r:0,fill:"none",stroke:"#888","stroke-width":10},this.workspace.options.svg);Blockly.BlockSvg.connectionUiStep_(a,
|
|
|
|
|
new Date,this.workspace.scale)}};Blockly.BlockSvg.connectionUiStep_=function(a,b,c){var d=(new Date-b)/150;1<d?goog.dom.removeNode(a):(a.setAttribute("r",25*d*c),a.style.opacity=1-d,Blockly.BlockSvg.disconnectUiStop_.pid_=setTimeout(function(){Blockly.BlockSvg.connectionUiStep_(a,b,c)},10))};
|
|
|
|
|
Blockly.BlockSvg.prototype.connectionUiEffect=function(){this.workspace.playAudio("click");if(!(1>this.workspace.scale)){var a=Blockly.getSvgXY_(this.svgGroup_,this.workspace);this.outputConnection?(a.x+=(this.RTL?3:-3)*this.workspace.scale,a.y+=13*this.workspace.scale):this.previousConnection&&(a.x+=(this.RTL?-23:23)*this.workspace.scale,a.y+=3*this.workspace.scale);a=Blockly.createSvgElement("circle",{cx:a.x,cy:a.y,r:0,fill:"none",stroke:"#888","stroke-width":10},this.workspace.getParentSvg());
|
|
|
|
|
Blockly.BlockSvg.connectionUiStep_(a,new Date,this.workspace.scale)}};Blockly.BlockSvg.connectionUiStep_=function(a,b,c){var d=(new Date-b)/150;1<d?goog.dom.removeNode(a):(a.setAttribute("r",25*d*c),a.style.opacity=1-d,Blockly.BlockSvg.disconnectUiStop_.pid_=setTimeout(function(){Blockly.BlockSvg.connectionUiStep_(a,b,c)},10))};
|
|
|
|
|
Blockly.BlockSvg.prototype.disconnectUiEffect=function(){this.workspace.playAudio("disconnect");if(!(1>this.workspace.scale)){var a=this.getHeightWidth().height,a=Math.atan(10/a)/Math.PI*180;this.RTL||(a*=-1);Blockly.BlockSvg.disconnectUiStep_(this.svgGroup_,a,new Date)}};
|
|
|
|
|
Blockly.BlockSvg.disconnectUiStep_=function(a,b,c){var d=(new Date-c)/200;1<d?a.skew_="":(a.skew_="skewX("+Math.round(Math.sin(d*Math.PI*3)*(1-d)*b)+")",Blockly.BlockSvg.disconnectUiStop_.group=a,Blockly.BlockSvg.disconnectUiStop_.pid=setTimeout(function(){Blockly.BlockSvg.disconnectUiStep_(a,b,c)},10));a.setAttribute("transform",a.translate_+a.skew_)};
|
|
|
|
|
Blockly.BlockSvg.disconnectUiStop_=function(){if(Blockly.BlockSvg.disconnectUiStop_.group){clearTimeout(Blockly.BlockSvg.disconnectUiStop_.pid);var a=Blockly.BlockSvg.disconnectUiStop_.group;a.skew_="";a.setAttribute("transform",a.translate_);Blockly.BlockSvg.disconnectUiStop_.group=null}};Blockly.BlockSvg.disconnectUiStop_.pid=0;Blockly.BlockSvg.disconnectUiStop_.group=null;
|
|
|
|
@ -1121,28 +1121,28 @@ Blockly.BlockSvg.prototype.setWarningText=function(a,b){this.setWarningText.pid_
|
|
|
|
|
e.setWarningText(a,c))},100)}else{this.isInFlyout&&(a=null);d=this.getSurroundParent();for(var f=null;d;)d.isCollapsed()&&(f=d),d=d.getSurroundParent();f&&f.setWarningText(a,"collapsed "+this.id+" "+c);d=!1;goog.isString(a)?(this.warning||(this.warning=new Blockly.Warning(this),d=!0),this.warning.setText(a,c)):this.warning&&!c?(this.warning.dispose(),d=!0):this.warning&&(d=this.warning.getText(),this.warning.setText("",c),(f=this.warning.getText())||this.warning.dispose(),d=d==f);d&&this.rendered&&
|
|
|
|
|
(this.render(),this.bumpNeighbours_())}};Blockly.BlockSvg.prototype.setMutator=function(a){this.mutator&&this.mutator!==a&&this.mutator.dispose();a&&(a.block_=this,this.mutator=a,a.createIcon())};Blockly.BlockSvg.prototype.setDisabled=function(a){this.disabled!=a&&(Blockly.BlockSvg.superClass_.setDisabled.call(this,a),this.rendered&&this.updateDisabled(),this.workspace.fireChangeEvent())};Blockly.BlockSvg.prototype.addSelect=function(){Blockly.addClass_(this.svgGroup_,"blocklySelected");this.svgGroup_.parentNode.appendChild(this.svgGroup_)};
|
|
|
|
|
Blockly.BlockSvg.prototype.removeSelect=function(){Blockly.removeClass_(this.svgGroup_,"blocklySelected")};Blockly.BlockSvg.prototype.addDragging=function(){Blockly.addClass_(this.svgGroup_,"blocklyDragging")};Blockly.BlockSvg.prototype.removeDragging=function(){Blockly.removeClass_(this.svgGroup_,"blocklyDragging")};
|
|
|
|
|
Blockly.BlockSvg.prototype.render=function(a){Blockly.Field.startCache();this.rendered=!0;var b=Blockly.BlockSvg.SEP_SPACE_X;this.RTL&&(b=-b);for(var c=this.getIcons(),d=0;d<c.length;d++)b=c[d].renderIcon(b);b+=this.RTL?Blockly.BlockSvg.SEP_SPACE_X:-Blockly.BlockSvg.SEP_SPACE_X;c=this.renderCompute_(b);this.renderDraw_(b,c);!1!==a&&((a=this.getParent())?a.render(!0):Blockly.fireUiEvent(window,"resize"));Blockly.Field.stopCache();Blockly.Realtime.blockChanged(this)};
|
|
|
|
|
Blockly.BlockSvg.prototype.render=function(a){Blockly.Field.startCache();this.rendered=!0;var b=Blockly.BlockSvg.SEP_SPACE_X;this.RTL&&(b=-b);for(var c=this.getIcons(),d=0;d<c.length;d++)b=c[d].renderIcon(b);b+=this.RTL?Blockly.BlockSvg.SEP_SPACE_X:-Blockly.BlockSvg.SEP_SPACE_X;c=this.renderCompute_(b);this.renderDraw_(b,c);!1!==a&&((a=this.getParent())?a.render(!0):Blockly.fireUiEvent(window,"resize"));Blockly.Field.stopCache()};
|
|
|
|
|
Blockly.BlockSvg.prototype.renderFields_=function(a,b,c){c+=Blockly.BlockSvg.INLINE_PADDING_Y;this.RTL&&(b=-b);for(var d=0,e;e=a[d];d++){var f=e.getSvgRoot();f&&(this.RTL?(b-=e.renderSep+e.renderWidth,f.setAttribute("transform","translate("+b+","+c+")"),e.renderWidth&&(b-=Blockly.BlockSvg.SEP_SPACE_X)):(f.setAttribute("transform","translate("+(b+e.renderSep)+","+c+")"),e.renderWidth&&(b+=e.renderSep+e.renderWidth+Blockly.BlockSvg.SEP_SPACE_X)))}return this.RTL?-b:b};
|
|
|
|
|
Blockly.BlockSvg.prototype.renderCompute_=function(a){var b=this.inputList,c=[];c.rightEdge=a+2*Blockly.BlockSvg.SEP_SPACE_X;if(this.previousConnection||this.nextConnection)c.rightEdge=Math.max(c.rightEdge,Blockly.BlockSvg.NOTCH_WIDTH+Blockly.BlockSvg.SEP_SPACE_X);for(var d=0,e=0,f=!1,g=!1,h=!1,k=void 0,l=this.getInputsInline()&&!this.isCollapsed(),p=0,m;m=b[p];p++)if(m.isVisible()){var q;l&&k&&k!=Blockly.NEXT_STATEMENT&&m.type!=Blockly.NEXT_STATEMENT?q=c[c.length-1]:(k=m.type,q=[],q.type=l&&m.type!=
|
|
|
|
|
Blockly.NEXT_STATEMENT?Blockly.BlockSvg.INLINE:m.type,q.height=0,c.push(q));q.push(m);m.renderHeight=Blockly.BlockSvg.MIN_BLOCK_Y;m.renderWidth=l&&m.type==Blockly.INPUT_VALUE?Blockly.BlockSvg.TAB_WIDTH+1.25*Blockly.BlockSvg.SEP_SPACE_X:0;if(m.connection&&m.connection.targetConnection){var n=m.connection.targetBlock().getHeightWidth();m.renderHeight=Math.max(m.renderHeight,n.height);m.renderWidth=Math.max(m.renderWidth,n.width)}l||p!=b.length-1?!l&&m.type==Blockly.INPUT_VALUE&&b[p+1]&&b[p+1].type==
|
|
|
|
|
Blockly.NEXT_STATEMENT&&m.renderHeight--:m.renderHeight--;q.height=Math.max(q.height,m.renderHeight);m.fieldWidth=0;1==c.length&&(m.fieldWidth+=this.RTL?-a:a);for(var n=!1,r=0,t;t=m.fieldRow[r];r++){0!=r&&(m.fieldWidth+=Blockly.BlockSvg.SEP_SPACE_X);var u=t.getSize();t.renderWidth=u.width;t.renderSep=n&&t.EDITABLE?Blockly.BlockSvg.SEP_SPACE_X:0;m.fieldWidth+=t.renderWidth+t.renderSep;q.height=Math.max(q.height,u.height);n=t.EDITABLE}q.type!=Blockly.BlockSvg.INLINE&&(q.type==Blockly.NEXT_STATEMENT?
|
|
|
|
|
(g=!0,e=Math.max(e,m.fieldWidth)):(q.type==Blockly.INPUT_VALUE?f=!0:q.type==Blockly.DUMMY_INPUT&&(h=!0),d=Math.max(d,m.fieldWidth)))}for(a=0;q=c[a];a++)if(q.thicker=!1,q.type==Blockly.BlockSvg.INLINE)for(b=0;m=q[b];b++)if(m.type==Blockly.INPUT_VALUE){q.height+=2*Blockly.BlockSvg.INLINE_PADDING_Y;q.thicker=!0;break}c.statementEdge=2*Blockly.BlockSvg.SEP_SPACE_X+e;g&&(c.rightEdge=Math.max(c.rightEdge,c.statementEdge+Blockly.BlockSvg.NOTCH_WIDTH));f?c.rightEdge=Math.max(c.rightEdge,d+2*Blockly.BlockSvg.SEP_SPACE_X+
|
|
|
|
|
Blockly.BlockSvg.prototype.renderCompute_=function(a){var b=this.inputList,c=[];c.rightEdge=a+2*Blockly.BlockSvg.SEP_SPACE_X;if(this.previousConnection||this.nextConnection)c.rightEdge=Math.max(c.rightEdge,Blockly.BlockSvg.NOTCH_WIDTH+Blockly.BlockSvg.SEP_SPACE_X);for(var d=0,e=0,f=!1,g=!1,h=!1,k=void 0,l=this.getInputsInline()&&!this.isCollapsed(),q=0,m;m=b[q];q++)if(m.isVisible()){var p;l&&k&&k!=Blockly.NEXT_STATEMENT&&m.type!=Blockly.NEXT_STATEMENT?p=c[c.length-1]:(k=m.type,p=[],p.type=l&&m.type!=
|
|
|
|
|
Blockly.NEXT_STATEMENT?Blockly.BlockSvg.INLINE:m.type,p.height=0,c.push(p));p.push(m);m.renderHeight=Blockly.BlockSvg.MIN_BLOCK_Y;m.renderWidth=l&&m.type==Blockly.INPUT_VALUE?Blockly.BlockSvg.TAB_WIDTH+1.25*Blockly.BlockSvg.SEP_SPACE_X:0;if(m.connection&&m.connection.targetConnection){var n=m.connection.targetBlock().getHeightWidth();m.renderHeight=Math.max(m.renderHeight,n.height);m.renderWidth=Math.max(m.renderWidth,n.width)}l||q!=b.length-1?!l&&m.type==Blockly.INPUT_VALUE&&b[q+1]&&b[q+1].type==
|
|
|
|
|
Blockly.NEXT_STATEMENT&&m.renderHeight--:m.renderHeight--;p.height=Math.max(p.height,m.renderHeight);m.fieldWidth=0;1==c.length&&(m.fieldWidth+=this.RTL?-a:a);for(var n=!1,r=0,t;t=m.fieldRow[r];r++){0!=r&&(m.fieldWidth+=Blockly.BlockSvg.SEP_SPACE_X);var u=t.getSize();t.renderWidth=u.width;t.renderSep=n&&t.EDITABLE?Blockly.BlockSvg.SEP_SPACE_X:0;m.fieldWidth+=t.renderWidth+t.renderSep;p.height=Math.max(p.height,u.height);n=t.EDITABLE}p.type!=Blockly.BlockSvg.INLINE&&(p.type==Blockly.NEXT_STATEMENT?
|
|
|
|
|
(g=!0,e=Math.max(e,m.fieldWidth)):(p.type==Blockly.INPUT_VALUE?f=!0:p.type==Blockly.DUMMY_INPUT&&(h=!0),d=Math.max(d,m.fieldWidth)))}for(a=0;p=c[a];a++)if(p.thicker=!1,p.type==Blockly.BlockSvg.INLINE)for(b=0;m=p[b];b++)if(m.type==Blockly.INPUT_VALUE){p.height+=2*Blockly.BlockSvg.INLINE_PADDING_Y;p.thicker=!0;break}c.statementEdge=2*Blockly.BlockSvg.SEP_SPACE_X+e;g&&(c.rightEdge=Math.max(c.rightEdge,c.statementEdge+Blockly.BlockSvg.NOTCH_WIDTH));f?c.rightEdge=Math.max(c.rightEdge,d+2*Blockly.BlockSvg.SEP_SPACE_X+
|
|
|
|
|
Blockly.BlockSvg.TAB_WIDTH):h&&(c.rightEdge=Math.max(c.rightEdge,d+2*Blockly.BlockSvg.SEP_SPACE_X));c.hasValue=f;c.hasStatement=g;c.hasDummy=h;return c};
|
|
|
|
|
Blockly.BlockSvg.prototype.renderDraw_=function(a,b){this.startHat_=!1;if(this.outputConnection)this.squareBottomLeftCorner_=this.squareTopLeftCorner_=!0;else{this.squareBottomLeftCorner_=this.squareTopLeftCorner_=!1;if(this.previousConnection){var c=this.previousConnection.targetBlock();c&&c.getNextBlock()==this&&(this.squareTopLeftCorner_=!0)}else Blockly.BlockSvg.START_HAT&&(this.startHat_=this.squareTopLeftCorner_=!0,b.rightEdge=Math.max(b.rightEdge,100));this.getNextBlock()&&(this.squareBottomLeftCorner_=
|
|
|
|
|
!0)}var d=this.getRelativeToSurfaceXY(),e=[],f=[],c=[],g=[];this.renderDrawTop_(e,c,d,b.rightEdge);var h=this.renderDrawRight_(e,c,f,g,d,b,a);this.renderDrawBottom_(e,c,d,h);this.renderDrawLeft_(e,c,d,h);d=e.join(" ")+"\n"+f.join(" ");this.svgPath_.setAttribute("d",d);this.svgPathDark_.setAttribute("d",d);d=c.join(" ")+"\n"+g.join(" ");this.svgPathLight_.setAttribute("d",d);this.RTL&&(this.svgPath_.setAttribute("transform","scale(-1 1)"),this.svgPathLight_.setAttribute("transform","scale(-1 1)"),
|
|
|
|
|
this.svgPathDark_.setAttribute("transform","translate(1,1) scale(-1 1)"))};
|
|
|
|
|
Blockly.BlockSvg.prototype.renderDrawTop_=function(a,b,c,d){this.squareTopLeftCorner_?(a.push("m 0,0"),b.push("m 0.5,0.5"),this.startHat_&&(a.push(Blockly.BlockSvg.START_HAT_PATH),b.push(this.RTL?Blockly.BlockSvg.START_HAT_HIGHLIGHT_RTL:Blockly.BlockSvg.START_HAT_HIGHLIGHT_LTR))):(a.push(Blockly.BlockSvg.TOP_LEFT_CORNER_START),b.push(this.RTL?Blockly.BlockSvg.TOP_LEFT_CORNER_START_HIGHLIGHT_RTL:Blockly.BlockSvg.TOP_LEFT_CORNER_START_HIGHLIGHT_LTR),a.push(Blockly.BlockSvg.TOP_LEFT_CORNER),b.push(Blockly.BlockSvg.TOP_LEFT_CORNER_HIGHLIGHT));
|
|
|
|
|
this.previousConnection&&(a.push("H",Blockly.BlockSvg.NOTCH_WIDTH-15),b.push("H",Blockly.BlockSvg.NOTCH_WIDTH-15),a.push(Blockly.BlockSvg.NOTCH_PATH_LEFT),b.push(Blockly.BlockSvg.NOTCH_PATH_LEFT_HIGHLIGHT),this.previousConnection.moveTo(c.x+(this.RTL?-Blockly.BlockSvg.NOTCH_WIDTH:Blockly.BlockSvg.NOTCH_WIDTH),c.y));a.push("H",d);b.push("H",d-.5);this.width=d};
|
|
|
|
|
Blockly.BlockSvg.prototype.renderDrawRight_=function(a,b,c,d,e,f,g){for(var h,k=0,l,p,m=0,q;q=f[m];m++){h=Blockly.BlockSvg.SEP_SPACE_X;0==m&&(h+=this.RTL?-g:g);b.push("M",f.rightEdge-.5+","+(k+.5));if(this.isCollapsed()){var n=q[0];l=k;this.renderFields_(n.fieldRow,h,l);a.push(Blockly.BlockSvg.JAGGED_TEETH);b.push("h 8");n=q.height-Blockly.BlockSvg.JAGGED_TEETH_HEIGHT;a.push("v",n);this.RTL&&(b.push("v 3.9 l 7.2,3.4 m -14.5,8.9 l 7.3,3.5"),b.push("v",n-.7));this.width+=Blockly.BlockSvg.JAGGED_TEETH_WIDTH}else if(q.type==
|
|
|
|
|
Blockly.BlockSvg.INLINE){for(var r=0;n=q[r];r++)l=k,q.thicker&&(l+=Blockly.BlockSvg.INLINE_PADDING_Y),h=this.renderFields_(n.fieldRow,h,l),n.type!=Blockly.DUMMY_INPUT&&(h+=n.renderWidth+Blockly.BlockSvg.SEP_SPACE_X),n.type==Blockly.INPUT_VALUE&&(c.push("M",h-Blockly.BlockSvg.SEP_SPACE_X+","+(k+Blockly.BlockSvg.INLINE_PADDING_Y)),c.push("h",Blockly.BlockSvg.TAB_WIDTH-2-n.renderWidth),c.push(Blockly.BlockSvg.TAB_PATH_DOWN),c.push("v",n.renderHeight+1-Blockly.BlockSvg.TAB_HEIGHT),c.push("h",n.renderWidth+
|
|
|
|
|
Blockly.BlockSvg.prototype.renderDrawRight_=function(a,b,c,d,e,f,g){for(var h,k=0,l,q,m=0,p;p=f[m];m++){h=Blockly.BlockSvg.SEP_SPACE_X;0==m&&(h+=this.RTL?-g:g);b.push("M",f.rightEdge-.5+","+(k+.5));if(this.isCollapsed()){var n=p[0];l=k;this.renderFields_(n.fieldRow,h,l);a.push(Blockly.BlockSvg.JAGGED_TEETH);b.push("h 8");n=p.height-Blockly.BlockSvg.JAGGED_TEETH_HEIGHT;a.push("v",n);this.RTL&&(b.push("v 3.9 l 7.2,3.4 m -14.5,8.9 l 7.3,3.5"),b.push("v",n-.7));this.width+=Blockly.BlockSvg.JAGGED_TEETH_WIDTH}else if(p.type==
|
|
|
|
|
Blockly.BlockSvg.INLINE){for(var r=0;n=p[r];r++)l=k,p.thicker&&(l+=Blockly.BlockSvg.INLINE_PADDING_Y),h=this.renderFields_(n.fieldRow,h,l),n.type!=Blockly.DUMMY_INPUT&&(h+=n.renderWidth+Blockly.BlockSvg.SEP_SPACE_X),n.type==Blockly.INPUT_VALUE&&(c.push("M",h-Blockly.BlockSvg.SEP_SPACE_X+","+(k+Blockly.BlockSvg.INLINE_PADDING_Y)),c.push("h",Blockly.BlockSvg.TAB_WIDTH-2-n.renderWidth),c.push(Blockly.BlockSvg.TAB_PATH_DOWN),c.push("v",n.renderHeight+1-Blockly.BlockSvg.TAB_HEIGHT),c.push("h",n.renderWidth+
|
|
|
|
|
2-Blockly.BlockSvg.TAB_WIDTH),c.push("z"),this.RTL?(d.push("M",h-Blockly.BlockSvg.SEP_SPACE_X-2.5+Blockly.BlockSvg.TAB_WIDTH-n.renderWidth+","+(k+Blockly.BlockSvg.INLINE_PADDING_Y+.5)),d.push(Blockly.BlockSvg.TAB_PATH_DOWN_HIGHLIGHT_RTL),d.push("v",n.renderHeight-Blockly.BlockSvg.TAB_HEIGHT+2.5),d.push("h",n.renderWidth-Blockly.BlockSvg.TAB_WIDTH+2)):(d.push("M",h-Blockly.BlockSvg.SEP_SPACE_X+.5+","+(k+Blockly.BlockSvg.INLINE_PADDING_Y+.5)),d.push("v",n.renderHeight+1),d.push("h",Blockly.BlockSvg.TAB_WIDTH-
|
|
|
|
|
2-n.renderWidth),d.push("M",h-n.renderWidth-Blockly.BlockSvg.SEP_SPACE_X+.9+","+(k+Blockly.BlockSvg.INLINE_PADDING_Y+Blockly.BlockSvg.TAB_HEIGHT-.7)),d.push("l",.46*Blockly.BlockSvg.TAB_WIDTH+",-2.1")),l=this.RTL?e.x-h-Blockly.BlockSvg.TAB_WIDTH+Blockly.BlockSvg.SEP_SPACE_X+n.renderWidth+1:e.x+h+Blockly.BlockSvg.TAB_WIDTH-Blockly.BlockSvg.SEP_SPACE_X-n.renderWidth-1,p=e.y+k+Blockly.BlockSvg.INLINE_PADDING_Y+1,n.connection.moveTo(l,p),n.connection.targetConnection&&n.connection.tighten_());h=Math.max(h,
|
|
|
|
|
f.rightEdge);this.width=Math.max(this.width,h);a.push("H",h);b.push("H",h-.5);a.push("v",q.height);this.RTL&&b.push("v",q.height-1)}else q.type==Blockly.INPUT_VALUE?(n=q[0],l=k,n.align!=Blockly.ALIGN_LEFT&&(r=f.rightEdge-n.fieldWidth-Blockly.BlockSvg.TAB_WIDTH-2*Blockly.BlockSvg.SEP_SPACE_X,n.align==Blockly.ALIGN_RIGHT?h+=r:n.align==Blockly.ALIGN_CENTRE&&(h+=r/2)),this.renderFields_(n.fieldRow,h,l),a.push(Blockly.BlockSvg.TAB_PATH_DOWN),r=q.height-Blockly.BlockSvg.TAB_HEIGHT,a.push("v",r),this.RTL?
|
|
|
|
|
(b.push(Blockly.BlockSvg.TAB_PATH_DOWN_HIGHLIGHT_RTL),b.push("v",r+.5)):(b.push("M",f.rightEdge-5+","+(k+Blockly.BlockSvg.TAB_HEIGHT-.7)),b.push("l",.46*Blockly.BlockSvg.TAB_WIDTH+",-2.1")),l=e.x+(this.RTL?-f.rightEdge-1:f.rightEdge+1),p=e.y+k,n.connection.moveTo(l,p),n.connection.targetConnection&&(n.connection.tighten_(),this.width=Math.max(this.width,f.rightEdge+n.connection.targetBlock().getHeightWidth().width-Blockly.BlockSvg.TAB_WIDTH+1))):q.type==Blockly.DUMMY_INPUT?(n=q[0],l=k,n.align!=Blockly.ALIGN_LEFT&&
|
|
|
|
|
(r=f.rightEdge-n.fieldWidth-2*Blockly.BlockSvg.SEP_SPACE_X,f.hasValue&&(r-=Blockly.BlockSvg.TAB_WIDTH),n.align==Blockly.ALIGN_RIGHT?h+=r:n.align==Blockly.ALIGN_CENTRE&&(h+=r/2)),this.renderFields_(n.fieldRow,h,l),a.push("v",q.height),this.RTL&&b.push("v",q.height-1)):q.type==Blockly.NEXT_STATEMENT&&(n=q[0],0==m&&(a.push("v",Blockly.BlockSvg.SEP_SPACE_Y),this.RTL&&b.push("v",Blockly.BlockSvg.SEP_SPACE_Y-1),k+=Blockly.BlockSvg.SEP_SPACE_Y),l=k,n.align!=Blockly.ALIGN_LEFT&&(r=f.statementEdge-n.fieldWidth-
|
|
|
|
|
2*Blockly.BlockSvg.SEP_SPACE_X,n.align==Blockly.ALIGN_RIGHT?h+=r:n.align==Blockly.ALIGN_CENTRE&&(h+=r/2)),this.renderFields_(n.fieldRow,h,l),h=f.statementEdge+Blockly.BlockSvg.NOTCH_WIDTH,a.push("H",h),a.push(Blockly.BlockSvg.INNER_TOP_LEFT_CORNER),a.push("v",q.height-2*Blockly.BlockSvg.CORNER_RADIUS),a.push(Blockly.BlockSvg.INNER_BOTTOM_LEFT_CORNER),a.push("H",f.rightEdge),this.RTL?(b.push("M",h-Blockly.BlockSvg.NOTCH_WIDTH+Blockly.BlockSvg.DISTANCE_45_OUTSIDE+","+(k+Blockly.BlockSvg.DISTANCE_45_OUTSIDE)),
|
|
|
|
|
b.push(Blockly.BlockSvg.INNER_TOP_LEFT_CORNER_HIGHLIGHT_RTL),b.push("v",q.height-2*Blockly.BlockSvg.CORNER_RADIUS),b.push(Blockly.BlockSvg.INNER_BOTTOM_LEFT_CORNER_HIGHLIGHT_RTL)):(b.push("M",h-Blockly.BlockSvg.NOTCH_WIDTH+Blockly.BlockSvg.DISTANCE_45_OUTSIDE+","+(k+q.height-Blockly.BlockSvg.DISTANCE_45_OUTSIDE)),b.push(Blockly.BlockSvg.INNER_BOTTOM_LEFT_CORNER_HIGHLIGHT_LTR)),b.push("H",f.rightEdge-.5),l=e.x+(this.RTL?-h:h+1),p=e.y+k+1,n.connection.moveTo(l,p),n.connection.targetConnection&&(n.connection.tighten_(),
|
|
|
|
|
this.width=Math.max(this.width,f.statementEdge+n.connection.targetBlock().getHeightWidth().width)),m==f.length-1||f[m+1].type==Blockly.NEXT_STATEMENT)&&(a.push("v",Blockly.BlockSvg.SEP_SPACE_Y),this.RTL&&b.push("v",Blockly.BlockSvg.SEP_SPACE_Y-1),k+=Blockly.BlockSvg.SEP_SPACE_Y);k+=q.height}f.length||(k=Blockly.BlockSvg.MIN_BLOCK_Y,a.push("V",k),this.RTL&&b.push("V",k-1));return k};
|
|
|
|
|
2-n.renderWidth),d.push("M",h-n.renderWidth-Blockly.BlockSvg.SEP_SPACE_X+.9+","+(k+Blockly.BlockSvg.INLINE_PADDING_Y+Blockly.BlockSvg.TAB_HEIGHT-.7)),d.push("l",.46*Blockly.BlockSvg.TAB_WIDTH+",-2.1")),l=this.RTL?e.x-h-Blockly.BlockSvg.TAB_WIDTH+Blockly.BlockSvg.SEP_SPACE_X+n.renderWidth+1:e.x+h+Blockly.BlockSvg.TAB_WIDTH-Blockly.BlockSvg.SEP_SPACE_X-n.renderWidth-1,q=e.y+k+Blockly.BlockSvg.INLINE_PADDING_Y+1,n.connection.moveTo(l,q),n.connection.targetConnection&&n.connection.tighten_());h=Math.max(h,
|
|
|
|
|
f.rightEdge);this.width=Math.max(this.width,h);a.push("H",h);b.push("H",h-.5);a.push("v",p.height);this.RTL&&b.push("v",p.height-1)}else p.type==Blockly.INPUT_VALUE?(n=p[0],l=k,n.align!=Blockly.ALIGN_LEFT&&(r=f.rightEdge-n.fieldWidth-Blockly.BlockSvg.TAB_WIDTH-2*Blockly.BlockSvg.SEP_SPACE_X,n.align==Blockly.ALIGN_RIGHT?h+=r:n.align==Blockly.ALIGN_CENTRE&&(h+=r/2)),this.renderFields_(n.fieldRow,h,l),a.push(Blockly.BlockSvg.TAB_PATH_DOWN),r=p.height-Blockly.BlockSvg.TAB_HEIGHT,a.push("v",r),this.RTL?
|
|
|
|
|
(b.push(Blockly.BlockSvg.TAB_PATH_DOWN_HIGHLIGHT_RTL),b.push("v",r+.5)):(b.push("M",f.rightEdge-5+","+(k+Blockly.BlockSvg.TAB_HEIGHT-.7)),b.push("l",.46*Blockly.BlockSvg.TAB_WIDTH+",-2.1")),l=e.x+(this.RTL?-f.rightEdge-1:f.rightEdge+1),q=e.y+k,n.connection.moveTo(l,q),n.connection.targetConnection&&(n.connection.tighten_(),this.width=Math.max(this.width,f.rightEdge+n.connection.targetBlock().getHeightWidth().width-Blockly.BlockSvg.TAB_WIDTH+1))):p.type==Blockly.DUMMY_INPUT?(n=p[0],l=k,n.align!=Blockly.ALIGN_LEFT&&
|
|
|
|
|
(r=f.rightEdge-n.fieldWidth-2*Blockly.BlockSvg.SEP_SPACE_X,f.hasValue&&(r-=Blockly.BlockSvg.TAB_WIDTH),n.align==Blockly.ALIGN_RIGHT?h+=r:n.align==Blockly.ALIGN_CENTRE&&(h+=r/2)),this.renderFields_(n.fieldRow,h,l),a.push("v",p.height),this.RTL&&b.push("v",p.height-1)):p.type==Blockly.NEXT_STATEMENT&&(n=p[0],0==m&&(a.push("v",Blockly.BlockSvg.SEP_SPACE_Y),this.RTL&&b.push("v",Blockly.BlockSvg.SEP_SPACE_Y-1),k+=Blockly.BlockSvg.SEP_SPACE_Y),l=k,n.align!=Blockly.ALIGN_LEFT&&(r=f.statementEdge-n.fieldWidth-
|
|
|
|
|
2*Blockly.BlockSvg.SEP_SPACE_X,n.align==Blockly.ALIGN_RIGHT?h+=r:n.align==Blockly.ALIGN_CENTRE&&(h+=r/2)),this.renderFields_(n.fieldRow,h,l),h=f.statementEdge+Blockly.BlockSvg.NOTCH_WIDTH,a.push("H",h),a.push(Blockly.BlockSvg.INNER_TOP_LEFT_CORNER),a.push("v",p.height-2*Blockly.BlockSvg.CORNER_RADIUS),a.push(Blockly.BlockSvg.INNER_BOTTOM_LEFT_CORNER),a.push("H",f.rightEdge),this.RTL?(b.push("M",h-Blockly.BlockSvg.NOTCH_WIDTH+Blockly.BlockSvg.DISTANCE_45_OUTSIDE+","+(k+Blockly.BlockSvg.DISTANCE_45_OUTSIDE)),
|
|
|
|
|
b.push(Blockly.BlockSvg.INNER_TOP_LEFT_CORNER_HIGHLIGHT_RTL),b.push("v",p.height-2*Blockly.BlockSvg.CORNER_RADIUS),b.push(Blockly.BlockSvg.INNER_BOTTOM_LEFT_CORNER_HIGHLIGHT_RTL)):(b.push("M",h-Blockly.BlockSvg.NOTCH_WIDTH+Blockly.BlockSvg.DISTANCE_45_OUTSIDE+","+(k+p.height-Blockly.BlockSvg.DISTANCE_45_OUTSIDE)),b.push(Blockly.BlockSvg.INNER_BOTTOM_LEFT_CORNER_HIGHLIGHT_LTR)),b.push("H",f.rightEdge-.5),l=e.x+(this.RTL?-h:h+1),q=e.y+k+1,n.connection.moveTo(l,q),n.connection.targetConnection&&(n.connection.tighten_(),
|
|
|
|
|
this.width=Math.max(this.width,f.statementEdge+n.connection.targetBlock().getHeightWidth().width)),m==f.length-1||f[m+1].type==Blockly.NEXT_STATEMENT)&&(a.push("v",Blockly.BlockSvg.SEP_SPACE_Y),this.RTL&&b.push("v",Blockly.BlockSvg.SEP_SPACE_Y-1),k+=Blockly.BlockSvg.SEP_SPACE_Y);k+=p.height}f.length||(k=Blockly.BlockSvg.MIN_BLOCK_Y,a.push("V",k),this.RTL&&b.push("V",k-1));return k};
|
|
|
|
|
Blockly.BlockSvg.prototype.renderDrawBottom_=function(a,b,c,d){this.height=d+1;this.nextConnection&&(a.push("H",Blockly.BlockSvg.NOTCH_WIDTH+(this.RTL?.5:-.5)+" "+Blockly.BlockSvg.NOTCH_PATH_RIGHT),this.nextConnection.moveTo(this.RTL?c.x-Blockly.BlockSvg.NOTCH_WIDTH:c.x+Blockly.BlockSvg.NOTCH_WIDTH,c.y+d+1),this.nextConnection.targetConnection&&this.nextConnection.tighten_(),this.height+=4);this.squareBottomLeftCorner_?(a.push("H 0"),this.RTL||b.push("M","0.5,"+(d-.5))):(a.push("H",Blockly.BlockSvg.CORNER_RADIUS),
|
|
|
|
|
a.push("a",Blockly.BlockSvg.CORNER_RADIUS+","+Blockly.BlockSvg.CORNER_RADIUS+" 0 0,1 -"+Blockly.BlockSvg.CORNER_RADIUS+",-"+Blockly.BlockSvg.CORNER_RADIUS),this.RTL||(b.push("M",Blockly.BlockSvg.DISTANCE_45_INSIDE+","+(d-Blockly.BlockSvg.DISTANCE_45_INSIDE)),b.push("A",Blockly.BlockSvg.CORNER_RADIUS-.5+","+(Blockly.BlockSvg.CORNER_RADIUS-.5)+" 0 0,1 0.5,"+(d-Blockly.BlockSvg.CORNER_RADIUS))))};
|
|
|
|
|
Blockly.BlockSvg.prototype.renderDrawLeft_=function(a,b,c,d){this.outputConnection?(this.outputConnection.moveTo(c.x,c.y),a.push("V",Blockly.BlockSvg.TAB_HEIGHT),a.push("c 0,-10 -"+Blockly.BlockSvg.TAB_WIDTH+",8 -"+Blockly.BlockSvg.TAB_WIDTH+",-7.5 s "+Blockly.BlockSvg.TAB_WIDTH+",2.5 "+Blockly.BlockSvg.TAB_WIDTH+",-7.5"),this.RTL?(b.push("M",-.25*Blockly.BlockSvg.TAB_WIDTH+",8.4"),b.push("l",-.45*Blockly.BlockSvg.TAB_WIDTH+",-2.1")):(b.push("V",Blockly.BlockSvg.TAB_HEIGHT-1.5),b.push("m",-.92*Blockly.BlockSvg.TAB_WIDTH+
|
|
|
|
@ -1167,7 +1167,7 @@ Blockly.FieldAngle.prototype.updateGraph_=function(){if(this.gauge_){var a=goog.
|
|
|
|
|
","+Blockly.FieldAngle.HALF+" h "+Blockly.FieldAngle.RADIUS+" A "+Blockly.FieldAngle.RADIUS+","+Blockly.FieldAngle.RADIUS+" 0 "+(a>Math.PI?1:0)+" 0 "+b+","+c+" z");this.line_.setAttribute("x2",b);this.line_.setAttribute("y2",c)}}};Blockly.FieldAngle.angleValidator=function(a){a=Blockly.FieldTextInput.numberValidator(a);null!==a&&(a%=360,0>a&&(a+=360),a=String(a));return a};Blockly.FieldCheckbox=function(a,b){Blockly.FieldCheckbox.superClass_.constructor.call(this,"");this.setChangeHandler(b);this.setValue(a)};goog.inherits(Blockly.FieldCheckbox,Blockly.Field);Blockly.FieldCheckbox.prototype.CURSOR="default";
|
|
|
|
|
Blockly.FieldCheckbox.prototype.init=function(a){this.sourceBlock_||(Blockly.FieldCheckbox.superClass_.init.call(this,a),this.checkElement_=Blockly.createSvgElement("text",{"class":"blocklyText",x:-3,y:14},this.fieldGroup_),a=document.createTextNode("\u2713"),this.checkElement_.appendChild(a),this.checkElement_.style.display=this.state_?"block":"none")};Blockly.FieldCheckbox.prototype.getValue=function(){return String(this.state_).toUpperCase()};
|
|
|
|
|
Blockly.FieldCheckbox.prototype.setValue=function(a){a="TRUE"==a;this.state_!==a&&(this.state_=a,this.checkElement_&&(this.checkElement_.style.display=a?"block":"none"),this.sourceBlock_&&this.sourceBlock_.rendered&&this.sourceBlock_.workspace.fireChangeEvent())};Blockly.FieldCheckbox.prototype.showEditor_=function(){var a=!this.state_;if(this.sourceBlock_&&this.changeHandler_){var b=this.changeHandler_(a);void 0!==b&&(a=b)}null!==a&&(this.sourceBlock_.setShadow(!1),this.setValue(String(a).toUpperCase()))};Blockly.FieldColour=function(a,b){Blockly.FieldColour.superClass_.constructor.call(this,"\u00a0\u00a0\u00a0");this.setChangeHandler(b);this.setValue(a)};goog.inherits(Blockly.FieldColour,Blockly.Field);Blockly.FieldColour.prototype.colours_=null;Blockly.FieldColour.prototype.columns_=0;Blockly.FieldColour.prototype.init=function(a){Blockly.FieldColour.superClass_.init.call(this,a);this.borderRect_.style.fillOpacity=1;this.setValue(this.getValue())};Blockly.FieldColour.prototype.CURSOR="default";
|
|
|
|
|
Blockly.FieldColour.prototype.dispose=function(){Blockly.WidgetDiv.hideIfOwner(this);Blockly.FieldColour.superClass_.dispose.call(this)};Blockly.FieldColour.prototype.getValue=function(){return this.colour_};Blockly.FieldColour.prototype.setValue=function(a){this.colour_=a;this.borderRect_&&(this.borderRect_.style.fill=a);this.sourceBlock_&&this.sourceBlock_.rendered&&(Blockly.Realtime.blockChanged(this.sourceBlock_),this.sourceBlock_.workspace.fireChangeEvent())};
|
|
|
|
|
Blockly.FieldColour.prototype.dispose=function(){Blockly.WidgetDiv.hideIfOwner(this);Blockly.FieldColour.superClass_.dispose.call(this)};Blockly.FieldColour.prototype.getValue=function(){return this.colour_};Blockly.FieldColour.prototype.setValue=function(a){this.colour_=a;this.borderRect_&&(this.borderRect_.style.fill=a);this.sourceBlock_&&this.sourceBlock_.rendered&&this.sourceBlock_.workspace.fireChangeEvent()};
|
|
|
|
|
Blockly.FieldColour.prototype.getText=function(){var a=this.colour_,b=a.match(/^#(.)\1(.)\2(.)\3$/);b&&(a="#"+b[1]+b[2]+b[3]);return a};Blockly.FieldColour.COLOURS=goog.ui.ColorPicker.SIMPLE_GRID_COLORS;Blockly.FieldColour.COLUMNS=7;Blockly.FieldColour.prototype.setColours=function(a){this.colours_=a;return this};Blockly.FieldColour.prototype.setColumns=function(a){this.columns_=a;return this};
|
|
|
|
|
Blockly.FieldColour.prototype.showEditor_=function(){Blockly.WidgetDiv.show(this,this.sourceBlock_.RTL,Blockly.FieldColour.widgetDispose_);var a=new goog.ui.ColorPicker;a.setSize(this.columns_||Blockly.FieldColour.COLUMNS);a.setColors(this.colours_||Blockly.FieldColour.COLOURS);var b=goog.dom.getViewportSize(),c=goog.style.getViewportPageOffset(document),d=this.getAbsoluteXY_(),e=this.getScaledBBox_();a.render(Blockly.WidgetDiv.DIV);a.setSelectedColor(this.getValue());var f=goog.style.getSize(a.getElement());
|
|
|
|
|
d.y=d.y+f.height+e.height>=b.height+c.y?d.y-(f.height-1):d.y+(e.height-1);this.sourceBlock_.RTL?(d.x+=e.width,d.x-=f.width,d.x<c.x&&(d.x=c.x)):d.x>b.width+c.x-f.width&&(d.x=b.width+c.x-f.width);Blockly.WidgetDiv.position(d.x,d.y,b,c,this.sourceBlock_.RTL);var g=this;Blockly.FieldColour.changeEventKey_=goog.events.listen(a,goog.ui.ColorPicker.EventType.CHANGE,function(a){a=a.target.getSelectedColor()||"#000000";Blockly.WidgetDiv.hide();if(g.sourceBlock_&&g.changeHandler_){var b=g.changeHandler_(a);
|
|
|
|
@ -1203,10 +1203,10 @@ Blockly.Names.prototype.getName=function(a,b){var c=a.toLowerCase()+"_"+b,d=b==B
|
|
|
|
|
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()};Blockly.Procedures={};Blockly.Procedures.NAME_TYPE="PROCEDURE";Blockly.Procedures.allProcedures=function(a){a=a.getAllBlocks();for(var b=[],c=[],d=0;d<a.length;d++)if(a[d].getProcedureDef){var e=a[d].getProcedureDef();e&&(e[2]?b.push(e):c.push(e))}c.sort(Blockly.Procedures.procTupleComparator_);b.sort(Blockly.Procedures.procTupleComparator_);return[c,b]};Blockly.Procedures.procTupleComparator_=function(a,b){return a[0].toLowerCase().localeCompare(b[0].toLowerCase())};
|
|
|
|
|
Blockly.Procedures.findLegalName=function(a,b){if(b.isInFlyout)return a;for(;!Blockly.Procedures.isLegalName(a,b.workspace,b);){var c=a.match(/^(.*?)(\d+)$/);a=c?c[1]+(parseInt(c[2],10)+1):a+"2"}return a};Blockly.Procedures.isLegalName=function(a,b,c){b=b.getAllBlocks();for(var d=0;d<b.length;d++)if(b[d]!=c&&b[d].getProcedureDef){var e=b[d].getProcedureDef();if(Blockly.Names.equals(e[0],a))return!1}return!0};
|
|
|
|
|
Blockly.Procedures.rename=function(a){a=a.replace(/^[\s\xa0]+|[\s\xa0]+$/g,"");a=Blockly.Procedures.findLegalName(a,this.sourceBlock_);for(var b=this.sourceBlock_.workspace.getAllBlocks(),c=0;c<b.length;c++)b[c].renameProcedure&&b[c].renameProcedure(this.text_,a);return a};
|
|
|
|
|
Blockly.Procedures.flyoutCategory=function(a){function b(a,b){for(var d=0;d<a.length;d++){var h=a[d][0],k=a[d][1],l=goog.dom.createDom("block");l.setAttribute("type",b);l.setAttribute("gap",16);var p=goog.dom.createDom("mutation");p.setAttribute("name",h);l.appendChild(p);for(h=0;h<k.length;h++){var m=goog.dom.createDom("arg");m.setAttribute("name",k[h]);p.appendChild(m)}c.push(l)}}var c=[];if(Blockly.Blocks.procedures_defnoreturn){var d=goog.dom.createDom("block");d.setAttribute("type","procedures_defnoreturn");
|
|
|
|
|
Blockly.Procedures.flyoutCategory=function(a){function b(a,b){for(var d=0;d<a.length;d++){var h=a[d][0],k=a[d][1],l=goog.dom.createDom("block");l.setAttribute("type",b);l.setAttribute("gap",16);var q=goog.dom.createDom("mutation");q.setAttribute("name",h);l.appendChild(q);for(h=0;h<k.length;h++){var m=goog.dom.createDom("arg");m.setAttribute("name",k[h]);q.appendChild(m)}c.push(l)}}var c=[];if(Blockly.Blocks.procedures_defnoreturn){var d=goog.dom.createDom("block");d.setAttribute("type","procedures_defnoreturn");
|
|
|
|
|
d.setAttribute("gap",16);c.push(d)}Blockly.Blocks.procedures_defreturn&&(d=goog.dom.createDom("block"),d.setAttribute("type","procedures_defreturn"),d.setAttribute("gap",16),c.push(d));Blockly.Blocks.procedures_ifreturn&&(d=goog.dom.createDom("block"),d.setAttribute("type","procedures_ifreturn"),d.setAttribute("gap",16),c.push(d));c.length&&c[c.length-1].setAttribute("gap",24);a=Blockly.Procedures.allProcedures(a);b(a[0],"procedures_callnoreturn");b(a[1],"procedures_callreturn");return c};
|
|
|
|
|
Blockly.Procedures.getCallers=function(a,b){for(var c=[],d=b.getAllBlocks(),e=0;e<d.length;e++)if(d[e].getProcedureCall){var f=d[e].getProcedureCall();f&&Blockly.Names.equals(f,a)&&c.push(d[e])}return c};Blockly.Procedures.disposeCallers=function(a,b){for(var c=Blockly.Procedures.getCallers(a,b),d=0;d<c.length;d++)c[d].dispose(!0,!1)};Blockly.Procedures.mutateCallers=function(a,b,c,d){a=Blockly.Procedures.getCallers(a,b);for(b=0;b<a.length;b++)a[b].setProcedureParameters(c,d)};
|
|
|
|
|
Blockly.Procedures.getDefinition=function(a,b){for(var c=b.getAllBlocks(),d=0;d<c.length;d++)if(c[d].getProcedureDef){var e=c[d].getProcedureDef();if(e&&Blockly.Names.equals(e[0],a))return c[d]}return null};Blockly.Flyout=function(a){var b=this;a.getMetrics=function(){return b.getMetrics_()};a.setMetrics=function(a){return b.setMetrics_(a)};this.workspace_=new Blockly.WorkspaceSvg(a);this.workspace_.isFlyout=!0;this.RTL=!!a.RTL;this.eventWrappers_=[];this.buttons_=[];this.listeners_=[]};Blockly.Flyout.prototype.autoClose=!0;Blockly.Flyout.prototype.CORNER_RADIUS=8;Blockly.Flyout.prototype.SCROLLBAR_PADDING=2;Blockly.Flyout.prototype.width_=0;Blockly.Flyout.prototype.height_=0;
|
|
|
|
|
Blockly.Procedures.getDefinition=function(a,b){for(var c=b.getAllBlocks(),d=0;d<c.length;d++)if(c[d].getProcedureDef){var e=c[d].getProcedureDef();if(e&&Blockly.Names.equals(e[0],a))return c[d]}return null};Blockly.Flyout=function(a){a.getMetrics=this.getMetrics_.bind(this);a.setMetrics=this.setMetrics_.bind(this);this.workspace_=new Blockly.WorkspaceSvg(a);this.workspace_.isFlyout=!0;this.RTL=!!a.RTL;this.eventWrappers_=[];this.buttons_=[];this.listeners_=[]};Blockly.Flyout.prototype.autoClose=!0;Blockly.Flyout.prototype.CORNER_RADIUS=8;Blockly.Flyout.prototype.SCROLLBAR_PADDING=2;Blockly.Flyout.prototype.width_=0;Blockly.Flyout.prototype.height_=0;
|
|
|
|
|
Blockly.Flyout.prototype.createDom=function(){this.svgGroup_=Blockly.createSvgElement("g",{"class":"blocklyFlyout"},null);this.svgBackground_=Blockly.createSvgElement("path",{"class":"blocklyFlyoutBackground"},this.svgGroup_);this.svgGroup_.appendChild(this.workspace_.createDom());return this.svgGroup_};
|
|
|
|
|
Blockly.Flyout.prototype.init=function(a){this.targetWorkspace_=a;this.workspace_.targetWorkspace=a;this.scrollbar_=new Blockly.Scrollbar(this.workspace_,!1,!1);this.hide();Array.prototype.push.apply(this.eventWrappers_,Blockly.bindEvent_(this.svgGroup_,"wheel",this,this.wheel_));this.autoClose||Array.prototype.push.apply(this.eventWrappers_,Blockly.bindEvent_(this.targetWorkspace_.getCanvas(),"blocklyWorkspaceChange",this,this.filterForCapacity_));Array.prototype.push.apply(this.eventWrappers_,Blockly.bindEvent_(this.svgGroup_,
|
|
|
|
|
"mousedown",this,this.onMouseDown_))};Blockly.Flyout.prototype.dispose=function(){this.hide();Blockly.unbindEvent_(this.eventWrappers_);this.scrollbar_&&(this.scrollbar_.dispose(),this.scrollbar_=null);this.workspace_&&(this.workspace_.targetWorkspace=null,this.workspace_.dispose(),this.workspace_=null);this.svgGroup_&&(goog.dom.removeNode(this.svgGroup_),this.svgGroup_=null);this.targetWorkspace_=this.svgBackground_=null};
|
|
|
|
@ -1231,14 +1231,14 @@ g=e.getSvgRoot();if(!g)throw"block is not rendered.";g=Blockly.getSvgXY_(g,c);g.
|
|
|
|
|
Blockly.Flyout.prototype.getRect=function(){var a=Blockly.mainWorkspace,b=Blockly.getSvgXY_(this.svgGroup_,a).x;this.RTL||(b-=1E9);return new goog.math.Rect(b,-1E9,1E9+this.width_*(this.targetWorkspace_==a?1:a.scale),2E9)};
|
|
|
|
|
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.Toolbox=function(a){this.workspace_=a};Blockly.Toolbox.prototype.width=0;Blockly.Toolbox.prototype.selectedOption_=null;Blockly.Toolbox.prototype.lastCategory_=null;Blockly.Toolbox.prototype.CONFIG_={indentWidth:19,cssRoot:"blocklyTreeRoot",cssHideRoot:"blocklyHidden",cssItem:"",cssTreeRow:"blocklyTreeRow",cssItemLabel:"blocklyTreeLabel",cssTreeIcon:"blocklyTreeIcon",cssExpandedFolderIcon:"blocklyTreeIconOpen",cssFileIcon:"blocklyTreeIconNone",cssSelectedRow:"blocklyTreeSelected"};
|
|
|
|
|
Blockly.Toolbox.prototype.init=function(){var a=this.workspace_;this.HtmlDiv=goog.dom.createDom("div","blocklyToolboxDiv");this.HtmlDiv.setAttribute("dir",a.RTL?"RTL":"LTR");document.body.appendChild(this.HtmlDiv);Blockly.bindEvent_(this.HtmlDiv,"mousedown",this,function(a){Blockly.isRightButton(a)||a.target==this.HtmlDiv?Blockly.hideChaff(!1):Blockly.hideChaff(!0)});this.flyout_=new Blockly.Flyout({disabledPatternId:a.options.disabledPatternId,parentWorkspace:a,RTL:a.RTL,svg:a.options.svg});goog.dom.insertSiblingAfter(this.flyout_.createDom(),
|
|
|
|
|
Blockly.Toolbox.prototype.init=function(){var a=this.workspace_;this.HtmlDiv=goog.dom.createDom("div","blocklyToolboxDiv");this.HtmlDiv.setAttribute("dir",a.RTL?"RTL":"LTR");document.body.appendChild(this.HtmlDiv);Blockly.bindEvent_(this.HtmlDiv,"mousedown",this,function(a){Blockly.isRightButton(a)||a.target==this.HtmlDiv?Blockly.hideChaff(!1):Blockly.hideChaff(!0)});this.flyout_=new Blockly.Flyout({disabledPatternId:a.options.disabledPatternId,parentWorkspace:a,RTL:a.RTL});goog.dom.insertSiblingAfter(this.flyout_.createDom(),
|
|
|
|
|
a.svgGroup_);this.flyout_.init(a);this.CONFIG_.cleardotPath=a.options.pathToMedia+"1x1.gif";this.CONFIG_.cssCollapsedFolderIcon="blocklyTreeIconClosed"+(a.RTL?"Rtl":"Ltr");var b=new Blockly.Toolbox.TreeControl(this,this.CONFIG_);this.tree_=b;b.setShowRootNode(!1);b.setShowLines(!1);b.setShowExpandIcons(!1);b.setSelectedItem(null);this.populate_(a.options.languageTree);b.render(this.HtmlDiv);this.addColour_();this.position()};
|
|
|
|
|
Blockly.Toolbox.prototype.dispose=function(){this.flyout_.dispose();this.tree_.dispose();goog.dom.removeNode(this.HtmlDiv);this.lastCategory_=this.workspace_=null};
|
|
|
|
|
Blockly.Toolbox.prototype.position=function(){var a=this.HtmlDiv;if(a){var b=this.workspace_.options.svg,c=goog.style.getPageOffset(b),b=Blockly.svgSize(b);a.style.left=this.workspace_.RTL?c.x+b.width-a.offsetWidth+"px":c.x+"px";a.style.height=b.height+"px";a.style.top=c.y+"px";this.width=a.offsetWidth;this.workspace_.RTL||--this.width;this.flyout_.position()}};
|
|
|
|
|
Blockly.Toolbox.prototype.position=function(){var a=this.HtmlDiv;if(a){var b=this.workspace_.getParentSvg(),c=goog.style.getPageOffset(b),b=Blockly.svgSize(b);a.style.left=this.workspace_.RTL?c.x+b.width-a.offsetWidth+"px":c.x+"px";a.style.height=b.height+"px";a.style.top=c.y+"px";this.width=a.offsetWidth;this.workspace_.RTL||--this.width;this.flyout_.position()}};
|
|
|
|
|
Blockly.Toolbox.prototype.populate_=function(a){function b(a,f){for(var g=0,h;h=a.childNodes[g];g++)if(h.tagName)switch(h.tagName.toUpperCase()){case "CATEGORY":var k=c.createNode(h.getAttribute("name"));k.blocks=[];f.add(k);var l=h.getAttribute("custom");l?k.blocks=l:b(h,k);l=h.getAttribute("colour");goog.isString(l)?(l.match(/^#[0-9a-fA-F]{6}$/)?k.hexColour=l:k.hexColour=Blockly.hueToRgb(l),d=!0):k.hexColour="";"true"==h.getAttribute("expanded")?(k.blocks.length&&c.setSelectedItem(k),k.setExpanded(!0)):
|
|
|
|
|
k.setExpanded(!1);break;case "SEP":f.add(new Blockly.Toolbox.TreeSeparator);break;case "BLOCK":case "SHADOW":f.blocks.push(h)}}var c=this.tree_;c.removeChildren();c.blocks=[];var d=!1;b(a,this.tree_);this.hasColours_=d;if(c.blocks.length)throw"Toolbox cannot have both blocks and categories in the root level.";Blockly.fireUiEvent(window,"resize")};
|
|
|
|
|
Blockly.Toolbox.prototype.addColour_=function(a){a=(a||this.tree_).getChildren();for(var b=0,c;c=a[b];b++){var d=c.getRowElement();if(d){var e=this.hasColours_?"8px solid "+(c.hexColour||"#ddd"):"none";this.workspace_.RTL?d.style.borderRight=e:d.style.borderLeft=e}this.addColour_(c)}};Blockly.Toolbox.prototype.clearSelection=function(){this.tree_.setSelectedItem(null)};
|
|
|
|
|
Blockly.Toolbox.prototype.getRect=function(){var a=this.workspace_.RTL?Blockly.svgSize(this.workspace_.options.svg).width-this.width:-1E7;return new goog.math.Rect(a,-1E7,1E7+this.width,2E7)};Blockly.Toolbox.TreeControl=function(a,b){this.toolbox_=a;goog.ui.tree.TreeControl.call(this,goog.html.SafeHtml.EMPTY,b)};goog.inherits(Blockly.Toolbox.TreeControl,goog.ui.tree.TreeControl);
|
|
|
|
|
Blockly.Toolbox.prototype.getRect=function(){var a=this.workspace_.RTL?Blockly.svgSize(this.workspace_.getParentSvg()).width-this.width:-1E7;return new goog.math.Rect(a,-1E7,1E7+this.width,2E7)};Blockly.Toolbox.TreeControl=function(a,b){this.toolbox_=a;goog.ui.tree.TreeControl.call(this,goog.html.SafeHtml.EMPTY,b)};goog.inherits(Blockly.Toolbox.TreeControl,goog.ui.tree.TreeControl);
|
|
|
|
|
Blockly.Toolbox.TreeControl.prototype.enterDocument=function(){Blockly.Toolbox.TreeControl.superClass_.enterDocument.call(this);if(goog.events.BrowserFeature.TOUCH_ENABLED){var a=this.getElement();Blockly.bindEvent_(a,goog.events.EventType.TOUCHSTART,this,this.handleTouchEvent_)}};Blockly.Toolbox.TreeControl.prototype.handleTouchEvent_=function(a){a.preventDefault();var b=this.getNodeFromEvent_(a);b&&a.type===goog.events.EventType.TOUCHSTART&&setTimeout(function(){b.onMouseDown(a)},1)};
|
|
|
|
|
Blockly.Toolbox.TreeControl.prototype.createNode=function(a){return new Blockly.Toolbox.TreeNode(this.toolbox_,a?goog.html.SafeHtml.htmlEscape(a):goog.html.SafeHtml.EMPTY,this.getConfig(),this.getDomHelper())};
|
|
|
|
|
Blockly.Toolbox.TreeControl.prototype.setSelectedItem=function(a){Blockly.removeAllRanges();var b=this.toolbox_;if(a!=this.selectedItem_&&a!=b.tree_){b.lastCategory_&&(b.lastCategory_.getRowElement().style.backgroundColor="");if(a){var c=a.hexColour||"#57e";a.getRowElement().style.backgroundColor=c;b.addColour_(a)}goog.ui.tree.TreeControl.prototype.setSelectedItem.call(this,a);a&&a.blocks&&a.blocks.length?(b.flyout_.show(a.blocks),b.lastCategory_!=a&&b.flyout_.scrollToTop()):b.flyout_.hide();a&&(b.lastCategory_=
|
|
|
|
@ -1267,20 +1267,20 @@ Blockly.Css.CONTENT=[".blocklySvg {","background-color: #fff;","outline: none;",
|
|
|
|
|
"border-top: 1px solid #ccc;","margin: 4px 0;","padding: 0;","}",""];Blockly.WidgetDiv={};Blockly.WidgetDiv.DIV=null;Blockly.WidgetDiv.owner_=null;Blockly.WidgetDiv.dispose_=null;Blockly.WidgetDiv.createDom=function(){Blockly.WidgetDiv.DIV||(Blockly.WidgetDiv.DIV=goog.dom.createDom("div","blocklyWidgetDiv"),document.body.appendChild(Blockly.WidgetDiv.DIV))};
|
|
|
|
|
Blockly.WidgetDiv.show=function(a,b,c){Blockly.WidgetDiv.hide();Blockly.WidgetDiv.owner_=a;Blockly.WidgetDiv.dispose_=c;a=goog.style.getViewportPageOffset(document);Blockly.WidgetDiv.DIV.style.top=a.y+"px";Blockly.WidgetDiv.DIV.style.direction=b?"rtl":"ltr";Blockly.WidgetDiv.DIV.style.display="block"};
|
|
|
|
|
Blockly.WidgetDiv.hide=function(){Blockly.WidgetDiv.owner_&&(Blockly.WidgetDiv.DIV.style.display="none",Blockly.WidgetDiv.DIV.style.left="",Blockly.WidgetDiv.DIV.style.top="",Blockly.WidgetDiv.DIV.style.height="",Blockly.WidgetDiv.dispose_&&Blockly.WidgetDiv.dispose_(),Blockly.WidgetDiv.owner_=null,Blockly.WidgetDiv.dispose_=null,goog.dom.removeChildren(Blockly.WidgetDiv.DIV))};Blockly.WidgetDiv.isVisible=function(){return!!Blockly.WidgetDiv.owner_};
|
|
|
|
|
Blockly.WidgetDiv.hideIfOwner=function(a){Blockly.WidgetDiv.owner_==a&&Blockly.WidgetDiv.hide()};Blockly.WidgetDiv.position=function(a,b,c,d,e){b<d.y&&(b=d.y);e?a>c.width+d.x&&(a=c.width+d.x):a<d.x&&(a=d.x);Blockly.WidgetDiv.DIV.style.left=a+"px";Blockly.WidgetDiv.DIV.style.top=b+"px";Blockly.WidgetDiv.DIV.style.height=c.height-b+d.y+"px"};Blockly.inject=function(a,b){goog.isString(a)&&(a=document.getElementById(a));if(!goog.dom.contains(document,a))throw"Error: container is not in current document.";var c=Blockly.parseOptions_(b||{}),d,e=function(){var b=Blockly.createDom_(a,c);d=Blockly.createMainWorkspace_(b,c);Blockly.init_(d);d.markFocused();Blockly.bindEvent_(b,"focus",d,d.markFocused)};if(c.enableRealtime){var f=document.getElementById("realtime");f&&(f.style.display="block");Blockly.Realtime.startRealtime(e,a,c.realtimeOptions)}else e();
|
|
|
|
|
return d};Blockly.parseToolboxTree_=function(a){a?("string"!=typeof a&&"undefined"==typeof XSLTProcessor&&(a=a.outerHTML),"string"==typeof a&&(a=Blockly.Xml.textToDom(a))):a=null;return a};
|
|
|
|
|
Blockly.parseOptions_=function(a){var b=!!a.readOnly;if(b)var c=null,d=!1,e=!1,f=!1,g=!1,h=!1,k=!1;else c=Blockly.parseToolboxTree_(a.toolbox),d=Boolean(c&&c.getElementsByTagName("category").length),e=a.trashcan,void 0===e&&(e=d),f=a.collapse,void 0===f&&(f=d),g=a.comments,void 0===g&&(g=d),h=a.disable,void 0===h&&(h=d),k=a.sounds,void 0===k&&(k=!0);var l=a.scrollbars;void 0===l&&(l=d);var p=a.css;void 0===p&&(p=!0);var m=a.grid||{},q={};q.spacing=parseFloat(m.spacing)||0;q.colour=m.colour||"#888";
|
|
|
|
|
q.length=parseFloat(m.length)||1;q.snap=0<q.spacing&&!!m.snap;m="https://blockly-demo.appspot.com/static/media/";a.media?m=a.media:a.path&&(m=a.path+"media/");var n=a.zoom||{},r={};r.controls=void 0===n.controls?!1:!!n.controls;r.wheel=void 0===n.wheel?!1:!!n.wheel;r.startScale=void 0===n.startScale?1:parseFloat(n.startScale);r.maxScale=void 0===n.maxScale?3:parseFloat(n.maxScale);r.minScale=void 0===n.minScale?.3:parseFloat(n.minScale);r.scaleSpeed=void 0===n.scaleSpeed?1.2:parseFloat(n.scaleSpeed);
|
|
|
|
|
n=!!a.realtime;return{RTL:!!a.rtl,collapse:f,comments:g,disable:h,readOnly:b,maxBlocks:a.maxBlocks||Infinity,pathToMedia:m,hasCategories:d,hasScrollbars:l,hasTrashcan:e,hasSounds:k,hasCss:p,languageTree:c,gridOptions:q,zoomOptions:r,enableRealtime:n,realtimeOptions:n?a.realtimeOptions:void 0}};
|
|
|
|
|
Blockly.WidgetDiv.hideIfOwner=function(a){Blockly.WidgetDiv.owner_==a&&Blockly.WidgetDiv.hide()};Blockly.WidgetDiv.position=function(a,b,c,d,e){b<d.y&&(b=d.y);e?a>c.width+d.x&&(a=c.width+d.x):a<d.x&&(a=d.x);Blockly.WidgetDiv.DIV.style.left=a+"px";Blockly.WidgetDiv.DIV.style.top=b+"px";Blockly.WidgetDiv.DIV.style.height=c.height-b+d.y+"px"};Blockly.inject=function(a,b){goog.isString(a)&&(a=document.getElementById(a));if(!goog.dom.contains(document,a))throw"Error: container is not in current document.";var c=Blockly.parseOptions_(b||{}),d=Blockly.createDom_(a,c),c=Blockly.createMainWorkspace_(d,c);Blockly.init_(c);c.markFocused();Blockly.bindEvent_(d,"focus",c,c.markFocused);return c};
|
|
|
|
|
Blockly.parseToolboxTree_=function(a){a?("string"!=typeof a&&"undefined"==typeof XSLTProcessor&&(a=a.outerHTML),"string"==typeof a&&(a=Blockly.Xml.textToDom(a))):a=null;return a};
|
|
|
|
|
Blockly.parseOptions_=function(a){var b=!!a.readOnly;if(b)var c=null,d=!1,e=!1,f=!1,g=!1,h=!1,k=!1;else c=Blockly.parseToolboxTree_(a.toolbox),d=Boolean(c&&c.getElementsByTagName("category").length),e=a.trashcan,void 0===e&&(e=d),f=a.collapse,void 0===f&&(f=d),g=a.comments,void 0===g&&(g=d),h=a.disable,void 0===h&&(h=d),k=a.sounds,void 0===k&&(k=!0);var l=a.scrollbars;void 0===l&&(l=d);var q=a.css;void 0===q&&(q=!0);var m=a.grid||{},p={};p.spacing=parseFloat(m.spacing)||0;p.colour=m.colour||"#888";
|
|
|
|
|
p.length=parseFloat(m.length)||1;p.snap=0<p.spacing&&!!m.snap;m="https://blockly-demo.appspot.com/static/media/";a.media?m=a.media:a.path&&(m=a.path+"media/");var n=a.zoom||{},r={};r.controls=void 0===n.controls?!1:!!n.controls;r.wheel=void 0===n.wheel?!1:!!n.wheel;r.startScale=void 0===n.startScale?1:parseFloat(n.startScale);r.maxScale=void 0===n.maxScale?3:parseFloat(n.maxScale);r.minScale=void 0===n.minScale?.3:parseFloat(n.minScale);r.scaleSpeed=void 0===n.scaleSpeed?1.2:parseFloat(n.scaleSpeed);
|
|
|
|
|
n=!!a.realtime;return{RTL:!!a.rtl,collapse:f,comments:g,disable:h,readOnly:b,maxBlocks:a.maxBlocks||Infinity,pathToMedia:m,hasCategories:d,hasScrollbars:l,hasTrashcan:e,hasSounds:k,hasCss:q,languageTree:c,gridOptions:p,zoomOptions:r,enableRealtime:n,realtimeOptions:n?a.realtimeOptions:void 0}};
|
|
|
|
|
Blockly.createDom_=function(a,b){a.setAttribute("dir","LTR");goog.ui.Component.setDefaultRightToLeft(b.RTL);Blockly.Css.inject(b.hasCss,b.pathToMedia);var c=Blockly.createSvgElement("svg",{xmlns:"http://www.w3.org/2000/svg","xmlns:html":"http://www.w3.org/1999/xhtml","xmlns:xlink":"http://www.w3.org/1999/xlink",version:"1.1","class":"blocklySvg"},a),d=Blockly.createSvgElement("defs",{},c),e=String(Math.random()).substring(2),f=Blockly.createSvgElement("filter",{id:"blocklyEmbossFilter"+e},d);Blockly.createSvgElement("feGaussianBlur",
|
|
|
|
|
{"in":"SourceAlpha",stdDeviation:1,result:"blur"},f);var g=Blockly.createSvgElement("feSpecularLighting",{"in":"blur",surfaceScale:1,specularConstant:.5,specularExponent:10,"lighting-color":"white",result:"specOut"},f);Blockly.createSvgElement("fePointLight",{x:-5E3,y:-1E4,z:2E4},g);Blockly.createSvgElement("feComposite",{"in":"specOut",in2:"SourceAlpha",operator:"in",result:"specOut"},f);Blockly.createSvgElement("feComposite",{"in":"SourceGraphic",in2:"specOut",operator:"arithmetic",k1:0,k2:1,k3:1,
|
|
|
|
|
k4:0},f);b.embossFilterId=f.id;f=Blockly.createSvgElement("pattern",{id:"blocklyDisabledPattern"+e,patternUnits:"userSpaceOnUse",width:10,height:10},d);Blockly.createSvgElement("rect",{width:10,height:10,fill:"#aaa"},f);Blockly.createSvgElement("path",{d:"M 0 0 L 10 10 M 10 0 L 0 10",stroke:"#cc0"},f);b.disabledPatternId=f.id;d=Blockly.createSvgElement("pattern",{id:"blocklyGridPattern"+e,patternUnits:"userSpaceOnUse"},d);0<b.gridOptions.length&&0<b.gridOptions.spacing&&(Blockly.createSvgElement("line",
|
|
|
|
|
{stroke:b.gridOptions.colour},d),1<b.gridOptions.length&&Blockly.createSvgElement("line",{stroke:b.gridOptions.colour},d));b.gridPattern=d;return b.svg=c};
|
|
|
|
|
{stroke:b.gridOptions.colour},d),1<b.gridOptions.length&&Blockly.createSvgElement("line",{stroke:b.gridOptions.colour},d));b.gridPattern=d;return c};
|
|
|
|
|
Blockly.createMainWorkspace_=function(a,b){b.parentWorkspace=null;b.getMetrics=Blockly.getMainWorkspaceMetrics_;b.setMetrics=Blockly.setMainWorkspaceMetrics_;var c=new Blockly.WorkspaceSvg(b);c.scale=b.zoomOptions.startScale;a.appendChild(c.createDom("blocklyMainBackground"));c.translate(0,0);c.markFocused();b.readOnly||b.hasScrollbars||c.addChangeListener(function(){if(0==Blockly.dragMode_){var a=c.getMetrics(),e=a.viewLeft+a.absoluteLeft,f=a.viewTop+a.absoluteTop;if(a.contentTop<f||a.contentTop+
|
|
|
|
|
a.contentHeight>a.viewHeight+f||a.contentLeft<(b.RTL?a.viewLeft:e)||a.contentLeft+a.contentWidth>(b.RTL?a.viewWidth:a.viewWidth+e))for(var g=c.getTopBlocks(!1),h=0,k;k=g[h];h++){var l=k.getRelativeToSurfaceXY(),p=k.getHeightWidth(),m=f+25-p.height-l.y;0<m&&k.moveBy(0,m);m=f+a.viewHeight-25-l.y;0>m&&k.moveBy(0,m);m=25+e-l.x-(b.RTL?0:p.width);0<m&&k.moveBy(m,0);m=e+a.viewWidth-25-l.x+(b.RTL?p.width:0);0>m&&k.moveBy(m,0)}}});Blockly.svgResize(c);Blockly.WidgetDiv.createDom();Blockly.Tooltip.createDom();
|
|
|
|
|
a.contentHeight>a.viewHeight+f||a.contentLeft<(b.RTL?a.viewLeft:e)||a.contentLeft+a.contentWidth>(b.RTL?a.viewWidth:a.viewWidth+e))for(var g=c.getTopBlocks(!1),h=0,k;k=g[h];h++){var l=k.getRelativeToSurfaceXY(),q=k.getHeightWidth(),m=f+25-q.height-l.y;0<m&&k.moveBy(0,m);m=f+a.viewHeight-25-l.y;0>m&&k.moveBy(0,m);m=25+e-l.x-(b.RTL?0:q.width);0<m&&k.moveBy(m,0);m=e+a.viewWidth-25-l.x+(b.RTL?q.width:0);0>m&&k.moveBy(m,0)}}});Blockly.svgResize(c);Blockly.WidgetDiv.createDom();Blockly.Tooltip.createDom();
|
|
|
|
|
return c};
|
|
|
|
|
Blockly.init_=function(a){var b=a.options;Blockly.bindEvent_(a.options.svg,"contextmenu",null,function(a){Blockly.isTargetInput_(a)||a.preventDefault()});Blockly.bindEvent_(window,"resize",null,function(){Blockly.svgResize(a)});Blockly.documentEventsBound_||(Blockly.bindEvent_(document,"keydown",null,Blockly.onKeyDown_),Blockly.bindEvent_(document,"touchend",null,Blockly.longStop_),Blockly.bindEvent_(document,"touchcancel",null,Blockly.longStop_),document.addEventListener("mouseup",Blockly.onMouseUp_,!1),
|
|
|
|
|
goog.userAgent.IPAD&&Blockly.bindEvent_(window,"orientationchange",document,function(){Blockly.fireUiEvent(window,"resize")}),Blockly.documentEventsBound_=!0);if(b.languageTree)if(a.toolbox_)a.toolbox_.init(a);else if(a.flyout_){a.flyout_.init(a);a.flyout_.show(b.languageTree.childNodes);a.scrollX=a.flyout_.width_;b.RTL&&(a.scrollX*=-1);var c="translate("+a.scrollX+",0)";a.getCanvas().setAttribute("transform",c);a.getBubbleCanvas().setAttribute("transform",c)}b.hasScrollbars&&(a.scrollbar=new Blockly.ScrollbarPair(a),
|
|
|
|
|
Blockly.init_=function(a){var b=a.options,c=a.getParentSvg();Blockly.bindEvent_(c,"contextmenu",null,function(a){Blockly.isTargetInput_(a)||a.preventDefault()});Blockly.bindEvent_(window,"resize",null,function(){Blockly.svgResize(a)});Blockly.documentEventsBound_||(Blockly.bindEvent_(document,"keydown",null,Blockly.onKeyDown_),Blockly.bindEvent_(document,"touchend",null,Blockly.longStop_),Blockly.bindEvent_(document,"touchcancel",null,Blockly.longStop_),document.addEventListener("mouseup",Blockly.onMouseUp_,
|
|
|
|
|
!1),goog.userAgent.IPAD&&Blockly.bindEvent_(window,"orientationchange",document,function(){Blockly.fireUiEvent(window,"resize")}),Blockly.documentEventsBound_=!0);b.languageTree&&(a.toolbox_?a.toolbox_.init(a):a.flyout_&&(a.flyout_.init(a),a.flyout_.show(b.languageTree.childNodes),a.scrollX=a.flyout_.width_,b.RTL&&(a.scrollX*=-1),c="translate("+a.scrollX+",0)",a.getCanvas().setAttribute("transform",c),a.getBubbleCanvas().setAttribute("transform",c)));b.hasScrollbars&&(a.scrollbar=new Blockly.ScrollbarPair(a),
|
|
|
|
|
a.scrollbar.resize());if(b.hasSounds){a.loadAudio_([b.pathToMedia+"click.mp3",b.pathToMedia+"click.wav",b.pathToMedia+"click.ogg"],"click");a.loadAudio_([b.pathToMedia+"disconnect.wav",b.pathToMedia+"disconnect.mp3",b.pathToMedia+"disconnect.ogg"],"disconnect");a.loadAudio_([b.pathToMedia+"delete.mp3",b.pathToMedia+"delete.ogg",b.pathToMedia+"delete.wav"],"delete");var d=[],b=function(){for(;d.length;)Blockly.unbindEvent_(d.pop());a.preloadAudio_()};d.push(Blockly.bindEvent_(document,"mousemove",
|
|
|
|
|
null,b));d.push(Blockly.bindEvent_(document,"touchstart",null,b))}};Blockly.updateToolbox=function(a){console.warn("Deprecated call to Blockly.updateToolbox, use workspace.updateToolbox instead.");Blockly.getMainWorkspace().updateToolbox(a)};Blockly.utils={};Blockly.addClass_=function(a,b){var c=a.getAttribute("class")||"";-1==(" "+c+" ").indexOf(" "+b+" ")&&(c&&(c+=" "),a.setAttribute("class",c+b))};Blockly.removeClass_=function(a,b){var c=a.getAttribute("class");if(-1!=(" "+c+" ").indexOf(" "+b+" ")){for(var c=c.split(/\s+/),d=0;d<c.length;d++)c[d]&&c[d]!=b||(c.splice(d,1),d--);c.length?a.setAttribute("class",c.join(" ")):a.removeAttribute("class")}};
|
|
|
|
|
Blockly.hasClass_=function(a,b){return-1!=(" "+a.getAttribute("class")+" ").indexOf(" "+b+" ")};Blockly.bindEvent_=function(a,b,c,d){var e=c?function(a){d.call(c,a)}:d;a.addEventListener(b,e,!1);var f=[[a,b,e]];if(b in Blockly.bindEvent_.TOUCH_MAP)for(var e=function(a){if(1==a.changedTouches.length){var b=a.changedTouches[0];a.clientX=b.clientX;a.clientY=b.clientY}d.call(c,a);a.preventDefault()},g=0,h;h=Blockly.bindEvent_.TOUCH_MAP[b][g];g++)a.addEventListener(h,e,!1),f.push([a,h,e]);return f};
|
|
|
|
@ -1289,16 +1289,16 @@ Blockly.fireUiEventNow=function(a,b){var c=Blockly.fireUiEvent.DB_[b];if(c){var
|
|
|
|
|
Blockly.fireUiEvent=function(a,b){var c=Blockly.fireUiEvent.DB_[b];if(c){if(-1!=c.indexOf(a))return;c.push(a)}else Blockly.fireUiEvent.DB_[b]=[a];setTimeout(function(){Blockly.fireUiEventNow(a,b)},0)};Blockly.fireUiEvent.DB_={};Blockly.noEvent=function(a){a.preventDefault();a.stopPropagation()};
|
|
|
|
|
Blockly.isTargetInput_=function(a){return"textarea"==a.target.type||"text"==a.target.type||"number"==a.target.type||"email"==a.target.type||"password"==a.target.type||"search"==a.target.type||"tel"==a.target.type||"url"==a.target.type||a.target.isContentEditable};
|
|
|
|
|
Blockly.getRelativeXY_=function(a){var b=new goog.math.Coordinate(0,0),c=a.getAttribute("x");c&&(b.x=parseInt(c,10));if(c=a.getAttribute("y"))b.y=parseInt(c,10);if(a=(a=a.getAttribute("transform"))&&a.match(Blockly.getRelativeXY_.XY_REGEXP_))b.x+=parseFloat(a[1]),a[3]&&(b.y+=parseFloat(a[3]));return b};Blockly.getRelativeXY_.XY_REGEXP_=/translate\(\s*([-+\d.e]+)([ ,]\s*([-+\d.e]+)\s*\))?/;
|
|
|
|
|
Blockly.getSvgXY_=function(a,b){var c=0,d=0,e=1;if(goog.dom.contains(b.getCanvas(),a)||goog.dom.contains(b.getBubbleCanvas(),a))e=b.scale;do{var f=Blockly.getRelativeXY_(a);if(a==b.getCanvas()||a==b.getBubbleCanvas())e=1;c+=f.x*e;d+=f.y*e;a=a.parentNode}while(a&&a!=b.options.svg);return new goog.math.Coordinate(c,d)};
|
|
|
|
|
Blockly.getSvgXY_=function(a,b){var c=0,d=0,e=1;if(goog.dom.contains(b.getCanvas(),a)||goog.dom.contains(b.getBubbleCanvas(),a))e=b.scale;do{var f=Blockly.getRelativeXY_(a);if(a==b.getCanvas()||a==b.getBubbleCanvas())e=1;c+=f.x*e;d+=f.y*e;a=a.parentNode}while(a&&a!=b.getParentSvg());return new goog.math.Coordinate(c,d)};
|
|
|
|
|
Blockly.createSvgElement=function(a,b,c,d){a=document.createElementNS(Blockly.SVG_NS,a);for(var e in b)a.setAttribute(e,b[e]);document.body.runtimeStyle&&(a.runtimeStyle=a.currentStyle=a.style);c&&c.appendChild(a);return a};Blockly.removeAllRanges=function(){window.getSelection&&setTimeout(function(){try{var a=window.getSelection();a.isCollapsed||a.removeAllRanges()}catch(b){}},0)};Blockly.isRightButton=function(a){return a.ctrlKey&&goog.userAgent.MAC?!0:2==a.button};
|
|
|
|
|
Blockly.mouseToSvg=function(a,b){var c=b.createSVGPoint();c.x=a.clientX;c.y=a.clientY;var d=b.getScreenCTM(),d=d.inverse();return c.matrixTransform(d)};Blockly.shortestStringLength=function(a){if(!a.length)return 0;for(var b=a[0].length,c=1;c<a.length;c++)b=Math.min(b,a[c].length);return b};
|
|
|
|
|
Blockly.commonWordPrefix=function(a,b){if(!a.length)return 0;if(1==a.length)return a[0].length;for(var c=0,d=b||Blockly.shortestStringLength(a),e=0;e<d;e++){for(var f=a[0][e],g=1;g<a.length;g++)if(f!=a[g][e])return c;" "==f&&(c=e+1)}for(g=1;g<a.length;g++)if((f=a[g][e])&&" "!=f)return c;return d};
|
|
|
|
|
Blockly.commonWordSuffix=function(a,b){if(!a.length)return 0;if(1==a.length)return a[0].length;for(var c=0,d=b||Blockly.shortestStringLength(a),e=0;e<d;e++){for(var f=a[0].substr(-e-1,1),g=1;g<a.length;g++)if(f!=a[g].substr(-e-1,1))return c;" "==f&&(c=e+1)}for(g=1;g<a.length;g++)if((f=a[g].charAt(a[g].length-e-1))&&" "!=f)return c;return d};Blockly.isNumber=function(a){return!!a.match(/^\s*-?\d+(\.\d+)?\s*$/)};
|
|
|
|
|
Blockly.tokenizeInterpolation=function(a){var b=[];a=a.split("");a.push("");for(var c=0,d=[],e=null,f=0;f<a.length;f++){var g=a[f];0==c?"%"==g?c=1:d.push(g):1==c?"%"==g?(d.push(g),c=0):"0"<=g&&"9">=g?(c=2,e=g,(g=d.join(""))&&b.push(g),d.length=0):(d.push("%",g),c=0):2==c&&("0"<=g&&"9">=g?e+=g:(b.push(parseInt(e,10)),f--,c=0))}(g=d.join(""))&&b.push(g);return b};
|
|
|
|
|
Blockly.genUid=function(){var a=Blockly.genUid.soup_.length,b=[];if(Blockly.genUid.crypto_){var c=new Uint32Array(20);Blockly.genUid.crypto_.getRandomValues(c);for(var d=0;20>d;d++)b[d]=Blockly.genUid.soup_.charAt(c[d]%a)}else for(d=0;20>d;d++)b[d]=Blockly.genUid.soup_.charAt(Math.random()*a);return b.join("")};Blockly.genUid.crypto_=this.crypto;Blockly.genUid.soup_="!#$%()*+,-./:;=?@[]^_`{|}~ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";Blockly.Realtime={isEnabled:function(){return!1},blockChanged:function(){},doCommand:function(a){a()}};var CLOSURE_DEFINES={"goog.DEBUG":!1};Blockly.SVG_NS="http://www.w3.org/2000/svg";Blockly.HTML_NS="http://www.w3.org/1999/xhtml";Blockly.HSV_SATURATION=.45;Blockly.HSV_VALUE=.65;Blockly.SPRITE={width:96,height:124,url:"sprites.png"};Blockly.hueToRgb=function(a){return goog.color.hsvToHex(a,Blockly.HSV_SATURATION,255*Blockly.HSV_VALUE)};Blockly.INPUT_VALUE=1;Blockly.OUTPUT_VALUE=2;
|
|
|
|
|
Blockly.NEXT_STATEMENT=3;Blockly.PREVIOUS_STATEMENT=4;Blockly.DUMMY_INPUT=5;Blockly.ALIGN_LEFT=-1;Blockly.ALIGN_CENTRE=0;Blockly.ALIGN_RIGHT=1;Blockly.OPPOSITE_TYPE=[];Blockly.OPPOSITE_TYPE[Blockly.INPUT_VALUE]=Blockly.OUTPUT_VALUE;Blockly.OPPOSITE_TYPE[Blockly.OUTPUT_VALUE]=Blockly.INPUT_VALUE;Blockly.OPPOSITE_TYPE[Blockly.NEXT_STATEMENT]=Blockly.PREVIOUS_STATEMENT;Blockly.OPPOSITE_TYPE[Blockly.PREVIOUS_STATEMENT]=Blockly.NEXT_STATEMENT;Blockly.selected=null;Blockly.highlightedConnection_=null;
|
|
|
|
|
Blockly.localConnection_=null;Blockly.DRAG_RADIUS=5;Blockly.SNAP_RADIUS=20;Blockly.BUMP_DELAY=250;Blockly.COLLAPSE_CHARS=30;Blockly.LONGPRESS=750;Blockly.mainWorkspace=null;Blockly.clipboardXml_=null;Blockly.clipboardSource_=null;Blockly.dragMode_=0;Blockly.onTouchUpWrapper_=null;Blockly.svgSize=function(a){return{width:a.cachedWidth_,height:a.cachedHeight_}};
|
|
|
|
|
Blockly.svgResize=function(a){for(;a.options.parentWorkspace;)a=a.options.parentWorkspace;var b=a.options.svg,c=b.parentNode;if(c){var d=c.offsetWidth,c=c.offsetHeight;b.cachedWidth_!=d&&(b.setAttribute("width",d+"px"),b.cachedWidth_=d);b.cachedHeight_!=c&&(b.setAttribute("height",c+"px"),b.cachedHeight_=c);a.resize()}};
|
|
|
|
|
Blockly.genUid=function(){var a=Blockly.genUid.soup_.length,b=[];if(Blockly.genUid.crypto_){var c=new Uint32Array(20);Blockly.genUid.crypto_.getRandomValues(c);for(var d=0;20>d;d++)b[d]=Blockly.genUid.soup_.charAt(c[d]%a)}else for(d=0;20>d;d++)b[d]=Blockly.genUid.soup_.charAt(Math.random()*a);return b.join("")};Blockly.genUid.crypto_=this.crypto;Blockly.genUid.soup_="!#$%()*+,-./:;=?@[]^_`{|}~ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";var CLOSURE_DEFINES={"goog.DEBUG":!1};Blockly.SVG_NS="http://www.w3.org/2000/svg";Blockly.HTML_NS="http://www.w3.org/1999/xhtml";Blockly.HSV_SATURATION=.45;Blockly.HSV_VALUE=.65;Blockly.SPRITE={width:96,height:124,url:"sprites.png"};Blockly.hueToRgb=function(a){return goog.color.hsvToHex(a,Blockly.HSV_SATURATION,255*Blockly.HSV_VALUE)};Blockly.INPUT_VALUE=1;Blockly.OUTPUT_VALUE=2;Blockly.NEXT_STATEMENT=3;Blockly.PREVIOUS_STATEMENT=4;Blockly.DUMMY_INPUT=5;Blockly.ALIGN_LEFT=-1;
|
|
|
|
|
Blockly.ALIGN_CENTRE=0;Blockly.ALIGN_RIGHT=1;Blockly.OPPOSITE_TYPE=[];Blockly.OPPOSITE_TYPE[Blockly.INPUT_VALUE]=Blockly.OUTPUT_VALUE;Blockly.OPPOSITE_TYPE[Blockly.OUTPUT_VALUE]=Blockly.INPUT_VALUE;Blockly.OPPOSITE_TYPE[Blockly.NEXT_STATEMENT]=Blockly.PREVIOUS_STATEMENT;Blockly.OPPOSITE_TYPE[Blockly.PREVIOUS_STATEMENT]=Blockly.NEXT_STATEMENT;Blockly.selected=null;Blockly.highlightedConnection_=null;Blockly.localConnection_=null;Blockly.DRAG_RADIUS=5;Blockly.SNAP_RADIUS=20;Blockly.BUMP_DELAY=250;
|
|
|
|
|
Blockly.COLLAPSE_CHARS=30;Blockly.LONGPRESS=750;Blockly.mainWorkspace=null;Blockly.clipboardXml_=null;Blockly.clipboardSource_=null;Blockly.dragMode_=0;Blockly.onTouchUpWrapper_=null;Blockly.svgSize=function(a){return{width:a.cachedWidth_,height:a.cachedHeight_}};
|
|
|
|
|
Blockly.svgResize=function(a){for(;a.options.parentWorkspace;)a=a.options.parentWorkspace;var b=a.getParentSvg(),c=b.parentNode;if(c){var d=c.offsetWidth,c=c.offsetHeight;b.cachedWidth_!=d&&(b.setAttribute("width",d+"px"),b.cachedWidth_=d);b.cachedHeight_!=c&&(b.setAttribute("height",c+"px"),b.cachedHeight_=c);a.resize()}};
|
|
|
|
|
Blockly.onMouseUp_=function(a){a=Blockly.getMainWorkspace();Blockly.Css.setCursor(Blockly.Css.Cursor.OPEN);a.isScrolling=!1;Blockly.onTouchUpWrapper_&&(Blockly.unbindEvent_(Blockly.onTouchUpWrapper_),Blockly.onTouchUpWrapper_=null);Blockly.onMouseMoveWrapper_&&(Blockly.unbindEvent_(Blockly.onMouseMoveWrapper_),Blockly.onMouseMoveWrapper_=null)};
|
|
|
|
|
Blockly.onMouseMove_=function(a){if(!(a.touches&&2<=a.touches.length)){var b=Blockly.getMainWorkspace();if(b.isScrolling){Blockly.removeAllRanges();var c=a.clientX-b.startDragMouseX,d=a.clientY-b.startDragMouseY,e=b.startDragMetrics,f=b.startScrollX+c,g=b.startScrollY+d,f=Math.min(f,-e.contentLeft),g=Math.min(g,-e.contentTop),f=Math.max(f,e.viewWidth-e.contentLeft-e.contentWidth),g=Math.max(g,e.viewHeight-e.contentTop-e.contentHeight);b.scrollbar.set(-f-e.contentLeft,-g-e.contentTop);Math.sqrt(c*
|
|
|
|
|
c+d*d)>Blockly.DRAG_RADIUS&&Blockly.longStop_();a.stopPropagation()}}};
|
|
|
|
@ -1306,8 +1306,7 @@ Blockly.onKeyDown_=function(a){if(!Blockly.isTargetInput_(a)){var b=!1;if(27==a.
|
|
|
|
|
Blockly.clipboardSource_.paste(Blockly.clipboardXml_);b&&(Blockly.hideChaff(),Blockly.selected.dispose(2!=Blockly.dragMode_,!0),Blockly.highlightedConnection_&&(Blockly.highlightedConnection_.unhighlight(),Blockly.highlightedConnection_=null))}};Blockly.terminateDrag_=function(){Blockly.BlockSvg.terminateDrag_();Blockly.Flyout.terminateDrag_()};Blockly.longPid_=0;Blockly.longStart_=function(a,b){Blockly.longStop_();Blockly.longPid_=setTimeout(function(){a.button=2;b.onMouseDown_(a)},Blockly.LONGPRESS)};
|
|
|
|
|
Blockly.longStop_=function(){Blockly.longPid_&&(clearTimeout(Blockly.longPid_),Blockly.longPid_=0)};Blockly.copy_=function(a){var b=Blockly.Xml.blockToDom_(a);2!=Blockly.dragMode_&&Blockly.Xml.deleteNext(b);var c=a.getRelativeToSurfaceXY();b.setAttribute("x",a.RTL?-c.x:c.x);b.setAttribute("y",c.y);Blockly.clipboardXml_=b;Blockly.clipboardSource_=a.workspace};
|
|
|
|
|
Blockly.duplicate_=function(a){var b=Blockly.clipboardXml_,c=Blockly.clipboardSource_;Blockly.copy_(a);a.workspace.paste(Blockly.clipboardXml_);Blockly.clipboardXml_=b;Blockly.clipboardSource_=c};Blockly.onContextMenu_=function(a){Blockly.isTargetInput_(a)||a.preventDefault()};Blockly.hideChaff=function(a){Blockly.Tooltip.hide();Blockly.WidgetDiv.hide();a||(a=Blockly.getMainWorkspace(),a.toolbox_&&a.toolbox_.flyout_&&a.toolbox_.flyout_.autoClose&&a.toolbox_.clearSelection())};
|
|
|
|
|
Blockly.getMainWorkspaceMetrics_=function(){var a=Blockly.svgSize(this.options.svg);this.toolbox_&&(a.width-=this.toolbox_.width);var b=Blockly.Flyout.prototype.CORNER_RADIUS-1,c=a.width-b,d=a.height-b;try{var e=this.getCanvas().getBBox()}catch(l){return null}var f=e.width*this.scale,g=e.height*this.scale,h=e.x*this.scale,k=e.y*this.scale;this.scrollbar?(b=Math.min(h-c/2,h+f-c),c=Math.max(h+f+c/2,h+c),f=Math.min(k-d/2,k+g-d),e=Math.max(k+g+d/2,k+d)):(b=e.x,c=b+e.width,f=e.y,e=f+e.height);d=0;!this.RTL&&
|
|
|
|
|
Blockly.getMainWorkspaceMetrics_=function(){var a=Blockly.svgSize(this.getParentSvg());this.toolbox_&&(a.width-=this.toolbox_.width);var b=Blockly.Flyout.prototype.CORNER_RADIUS-1,c=a.width-b,d=a.height-b;try{var e=this.getCanvas().getBBox()}catch(l){return null}var f=e.width*this.scale,g=e.height*this.scale,h=e.x*this.scale,k=e.y*this.scale;this.scrollbar?(b=Math.min(h-c/2,h+f-c),c=Math.max(h+f+c/2,h+c),f=Math.min(k-d/2,k+g-d),e=Math.max(k+g+d/2,k+d)):(b=e.x,c=b+e.width,f=e.y,e=f+e.height);d=0;!this.RTL&&
|
|
|
|
|
this.toolbox_&&(d=this.toolbox_.width);return{viewHeight:a.height,viewWidth:a.width,contentHeight:e-f,contentWidth:c-b,viewTop:-this.scrollY,viewLeft:-this.scrollX,contentTop:f,contentLeft:b,absoluteTop:0,absoluteLeft:d}};
|
|
|
|
|
Blockly.setMainWorkspaceMetrics_=function(a){if(!this.scrollbar)throw"Attempt to set main workspace scroll without scrollbars.";var b=this.getMetrics();goog.isNumber(a.x)&&(this.scrollX=-b.contentWidth*a.x-b.contentLeft);goog.isNumber(a.y)&&(this.scrollY=-b.contentHeight*a.y-b.contentTop);a=this.scrollX+b.absoluteLeft;b=this.scrollY+b.absoluteTop;this.translate(a,b);this.options.gridPattern&&(this.options.gridPattern.setAttribute("x",a),this.options.gridPattern.setAttribute("y",b),goog.userAgent.IE&&
|
|
|
|
|
this.updateGridPattern_())};Blockly.doCommand=function(a){Blockly.Realtime.isEnabled()?Blockly.Realtime.doCommand(a):a()};Blockly.addChangeListener=function(a){console.warn("Deprecated call to Blockly.addChangeListener, use workspace.addChangeListener instead.");return Blockly.getMainWorkspace().addChangeListener(a)};Blockly.getMainWorkspace=function(){return Blockly.mainWorkspace};goog.global.Blockly||(goog.global.Blockly={});goog.global.Blockly.getMainWorkspace=Blockly.getMainWorkspace;
|
|
|
|
|
goog.global.Blockly.addChangeListener=Blockly.addChangeListener;
|
|
|
|
|
this.updateGridPattern_())};Blockly.addChangeListener=function(a){console.warn("Deprecated call to Blockly.addChangeListener, use workspace.addChangeListener instead.");return Blockly.getMainWorkspace().addChangeListener(a)};Blockly.getMainWorkspace=function(){return Blockly.mainWorkspace};goog.global.Blockly||(goog.global.Blockly={});goog.global.Blockly.getMainWorkspace=Blockly.getMainWorkspace;goog.global.Blockly.addChangeListener=Blockly.addChangeListener;
|