Merge pull request from rschamp/feature/input-rendering

Match string and number inputs to spec
This commit is contained in:
Ray Schamp 2016-02-23 17:48:11 -05:00
commit 9defd1ae79
13 changed files with 324 additions and 77 deletions

View file

@ -913,9 +913,10 @@ Blockly.Connection.prototype.hideAll=function(){this.setHidden(!0);if(this.targe
Blockly.Connection.prototype.unhideAll=function(){this.setHidden(!1);var a=[];if(this.type!=Blockly.INPUT_VALUE&&this.type!=Blockly.NEXT_STATEMENT)return a;var b=this.targetBlock();if(b){var c;b.isCollapsed()?(c=[],b.outputConnection&&c.push(b.outputConnection),b.nextConnection&&c.push(b.nextConnection),b.previousConnection&&c.push(b.previousConnection)):c=b.getConnections_(!0);for(var d=0;d<c.length;d++)a.push.apply(a,c[d].unhideAll());0==a.length&&(a[0]=b)}return a};Blockly.ConnectionDB=function(){};
Blockly.ConnectionDB.prototype=[];Blockly.ConnectionDB.constructor=Blockly.ConnectionDB;Blockly.ConnectionDB.prototype.addConnection_=function(a){if(a.inDB_)throw"Connection already in database.";if(!a.sourceBlock_.isInFlyout){for(var b=0,c=this.length;b<c;){var d=Math.floor((b+c)/2);if(this[d].y_<a.y_)b=d+1;else if(this[d].y_>a.y_)c=d;else{b=d;break}}this.splice(b,0,a);a.inDB_=!0}};
Blockly.ConnectionDB.prototype.removeConnection_=function(a){if(!a.inDB_)throw"Connection not in database.";a.inDB_=!1;for(var b=0,c=this.length-2,d=c;b<d;)this[d].y_<a.y_?b=d:c=d,d=Math.floor((b+c)/2);for(c=b=d;0<=b&&this[b].y_==a.y_;){if(this[b]==a){this.splice(b,1);return}b--}do{if(this[c]==a){this.splice(c,1);return}c++}while(c<this.length&&this[c].y_==a.y_);throw"Unable to find connection in connectionDB.";};
Blockly.ConnectionDB.init=function(a){var b=[];b[Blockly.INPUT_VALUE]=new Blockly.ConnectionDB;b[Blockly.OUTPUT_VALUE]=new Blockly.ConnectionDB;b[Blockly.NEXT_STATEMENT]=new Blockly.ConnectionDB;b[Blockly.PREVIOUS_STATEMENT]=new Blockly.ConnectionDB;a.connectionDBList=b};Blockly.Field=function(a,b){this.size_=new goog.math.Size(0,25);this.setValue(a);this.setValidator(b)};Blockly.Field.cacheWidths_=null;Blockly.Field.cacheReference_=0;Blockly.Field.prototype.name=void 0;Blockly.Field.prototype.maxDisplayLength=50;Blockly.Field.prototype.text_="";Blockly.Field.prototype.sourceBlock_=null;Blockly.Field.prototype.visible_=!0;Blockly.Field.prototype.validator_=null;Blockly.Field.NBSP="\u00a0";Blockly.Field.prototype.EDITABLE=!0;
Blockly.Field.prototype.init=function(a){this.sourceBlock_||(this.sourceBlock_=a,this.fieldGroup_=Blockly.createSvgElement("g",{},null),this.visible_||(this.fieldGroup_.style.display="none"),this.borderRect_=Blockly.createSvgElement("rect",{rx:4,ry:4,x:-Blockly.BlockSvg.SEP_SPACE_X/2,y:0,height:16},this.fieldGroup_,this.sourceBlock_.workspace),this.textElement_=Blockly.createSvgElement("text",{"class":"blocklyText",y:this.size_.height-12.5},this.fieldGroup_),this.updateEditable(),a.getSvgRoot().appendChild(this.fieldGroup_),
this.mouseUpWrapper_=Blockly.bindEvent_(this.fieldGroup_,"mouseup",this,this.onMouseUp_),this.updateTextNode_(),Blockly.Events.isEnabled()&&Blockly.Events.fire(new Blockly.Events.Change(this.sourceBlock_,"field",this.name,"",this.getValue())))};
Blockly.ConnectionDB.init=function(a){var b=[];b[Blockly.INPUT_VALUE]=new Blockly.ConnectionDB;b[Blockly.OUTPUT_VALUE]=new Blockly.ConnectionDB;b[Blockly.NEXT_STATEMENT]=new Blockly.ConnectionDB;b[Blockly.PREVIOUS_STATEMENT]=new Blockly.ConnectionDB;a.connectionDBList=b};Blockly.Field=function(a,b){this.size_=new goog.math.Size(Blockly.BlockSvg.FIELD_WIDTH,Blockly.BlockSvg.FIELD_HEIGHT);this.setValue(a);this.setValidator(b)};Blockly.Field.cacheWidths_=null;Blockly.Field.cacheReference_=0;Blockly.Field.prototype.name=void 0;Blockly.Field.prototype.maxDisplayLength=5;Blockly.Field.prototype.text_="";Blockly.Field.prototype.sourceBlock_=null;Blockly.Field.prototype.visible_=!0;Blockly.Field.prototype.validator_=null;Blockly.Field.NBSP="\u00a0";
Blockly.Field.prototype.EDITABLE=!0;
Blockly.Field.prototype.init=function(a){this.sourceBlock_||(this.sourceBlock_=a,this.fieldGroup_=Blockly.createSvgElement("g",{},null),this.visible_||(this.fieldGroup_.style.display="none"),this.borderRect_=Blockly.createSvgElement("rect",{rx:4,ry:4,x:-Blockly.BlockSvg.SEP_SPACE_X/2,y:0,height:Blockly.BlockSvg.FIELD_HEIGHT},this.fieldGroup_,this.sourceBlock_.workspace),this.textElement_=Blockly.createSvgElement("text",{"class":"blocklyText",y:this.size_.height/2+6.25,x:Blockly.BlockSvg.FIELD_WIDTH/
2,width:Blockly.BlockSvg.FIELD_WIDTH-Blockly.BlockSvg.SEP_SPACE_X,"text-anchor":"middle"},this.fieldGroup_),this.updateEditable(),a.getSvgRoot().appendChild(this.fieldGroup_),this.mouseUpWrapper_=Blockly.bindEvent_(this.fieldGroup_,"mouseup",this,this.onMouseUp_),this.updateTextNode_(),Blockly.Events.isEnabled()&&Blockly.Events.fire(new Blockly.Events.Change(this.sourceBlock_,"field",this.name,"",this.getValue())))};
Blockly.Field.prototype.dispose=function(){this.mouseUpWrapper_&&(Blockly.unbindEvent_(this.mouseUpWrapper_),this.mouseUpWrapper_=null);this.sourceBlock_=null;goog.dom.removeNode(this.fieldGroup_);this.validator_=this.borderRect_=this.textElement_=this.fieldGroup_=null};
Blockly.Field.prototype.updateEditable=function(){this.EDITABLE&&this.sourceBlock_&&(this.sourceBlock_.isEditable()?(Blockly.addClass_(this.fieldGroup_,"blocklyEditableText"),Blockly.removeClass_(this.fieldGroup_,"blocklyNoNEditableText"),this.fieldGroup_.style.cursor=this.CURSOR):(Blockly.addClass_(this.fieldGroup_,"blocklyNonEditableText"),Blockly.removeClass_(this.fieldGroup_,"blocklyEditableText"),this.fieldGroup_.style.cursor=""))};Blockly.Field.prototype.isVisible=function(){return this.visible_};
Blockly.Field.prototype.setVisible=function(a){if(this.visible_!=a){this.visible_=a;var b=this.getSvgRoot();b&&(b.style.display=a?"block":"none",this.render_())}};Blockly.Field.prototype.setValidator=function(a){this.validator_=a};Blockly.Field.prototype.getSvgRoot=function(){return this.fieldGroup_};
@ -1108,7 +1109,8 @@ Blockly.BlockSvg.prototype.onMouseMove_=function(a){if(!("mousemove"==a.type&&1>
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=8;Blockly.BlockSvg.SEP_SPACE_Y=8;Blockly.BlockSvg.INLINE_PADDING_Y=5;Blockly.BlockSvg.MIN_BLOCK_Y=25;Blockly.BlockSvg.TAB_WIDTH=8;Blockly.BlockSvg.CORNER_RADIUS=4;Blockly.BlockSvg.HAT_CORNER_RADIUS=16;Blockly.BlockSvg.NOTCH_RADIUS=2.5;Blockly.BlockSvg.NOTCH_BASE_HEIGHT=32;Blockly.BlockSvg.NOTCH_HEIGHT=Blockly.BlockSvg.NOTCH_BASE_HEIGHT+Blockly.BlockSvg.NOTCH_RADIUS;Blockly.BlockSvg.NOTCH_WIDTH=Blockly.BlockSvg.NOTCH_BASE_HEIGHT/4;
Blockly.BlockSvg.SEP_SPACE_X=8;Blockly.BlockSvg.SEP_SPACE_Y=8;Blockly.BlockSvg.INLINE_PADDING_Y=5;Blockly.BlockSvg.FIELD_HEIGHT=32;Blockly.BlockSvg.FIELD_WIDTH=48;Blockly.BlockSvg.NUMBER_FIELD_CORNER_RADIUS=16;Blockly.BlockSvg.TEXT_FIELD_CORNER_RADIUS=4;Blockly.BlockSvg.MIN_BLOCK_X=40;Blockly.BlockSvg.TAB_WIDTH=8;Blockly.BlockSvg.CORNER_RADIUS=4;Blockly.BlockSvg.HAT_CORNER_RADIUS=16;Blockly.BlockSvg.NOTCH_RADIUS=2.5;Blockly.BlockSvg.NOTCH_BASE_HEIGHT=32;
Blockly.BlockSvg.NOTCH_HEIGHT=Blockly.BlockSvg.NOTCH_BASE_HEIGHT+Blockly.BlockSvg.NOTCH_RADIUS;Blockly.BlockSvg.NOTCH_WIDTH=Blockly.BlockSvg.NOTCH_BASE_HEIGHT/4;
Blockly.BlockSvg.NOTCH_PATH_DOWN="a "+-Blockly.BlockSvg.NOTCH_RADIUS+","+Blockly.BlockSvg.NOTCH_RADIUS+" 0 0 0 "+Blockly.BlockSvg.NOTCH_RADIUS/2+","+Blockly.BlockSvg.NOTCH_RADIUS+" l "+(Blockly.BlockSvg.NOTCH_BASE_HEIGHT/4-Blockly.BlockSvg.NOTCH_RADIUS)+","+(Blockly.BlockSvg.NOTCH_BASE_HEIGHT/4-Blockly.BlockSvg.NOTCH_RADIUS)+" a "+-Blockly.BlockSvg.NOTCH_RADIUS+","+Blockly.BlockSvg.NOTCH_RADIUS+" 0 0 1 "+Blockly.BlockSvg.NOTCH_RADIUS/2+","+Blockly.BlockSvg.NOTCH_RADIUS+" v "+(Blockly.BlockSvg.NOTCH_BASE_HEIGHT/
2-Blockly.BlockSvg.NOTCH_RADIUS)+" a "+-Blockly.BlockSvg.NOTCH_RADIUS+","+Blockly.BlockSvg.NOTCH_RADIUS+" 0 0 1 "+-Blockly.BlockSvg.NOTCH_RADIUS/2+","+Blockly.BlockSvg.NOTCH_RADIUS+" l "+(-Blockly.BlockSvg.NOTCH_BASE_HEIGHT/4+Blockly.BlockSvg.NOTCH_RADIUS)+","+(Blockly.BlockSvg.NOTCH_BASE_HEIGHT/4-Blockly.BlockSvg.NOTCH_RADIUS)+" a "+-Blockly.BlockSvg.NOTCH_RADIUS+","+Blockly.BlockSvg.NOTCH_RADIUS+" 0 0 0 "+-Blockly.BlockSvg.NOTCH_RADIUS/2+","+Blockly.BlockSvg.NOTCH_RADIUS;
Blockly.BlockSvg.NOTCH_PATH_UP="a "+Blockly.BlockSvg.NOTCH_RADIUS+","+-Blockly.BlockSvg.NOTCH_RADIUS+" 0 0 1 "+Blockly.BlockSvg.NOTCH_RADIUS/2+","+-Blockly.BlockSvg.NOTCH_RADIUS+" l "+(Blockly.BlockSvg.NOTCH_BASE_HEIGHT/4-Blockly.BlockSvg.NOTCH_RADIUS)+","+-1*(Blockly.BlockSvg.NOTCH_BASE_HEIGHT/4-Blockly.BlockSvg.NOTCH_RADIUS)+" a "+Blockly.BlockSvg.NOTCH_RADIUS+","+-Blockly.BlockSvg.NOTCH_RADIUS+" 0 0 0 "+Blockly.BlockSvg.NOTCH_RADIUS/2+","+-Blockly.BlockSvg.NOTCH_RADIUS+" v "+-1*(Blockly.BlockSvg.NOTCH_BASE_HEIGHT/
@ -1123,25 +1125,28 @@ Blockly.BlockSvg.connectionUiStep_=function(a,b,c){var d=(new Date-b)/150;1<d?go
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;
Blockly.BlockSvg.prototype.updateColour=function(){var a=this.getColour(),b=goog.color.hexToRgb(a);this.isShadow()&&(b=goog.color.lighten(b,.6),a=goog.color.rgbArrayToHex(b));this.svgPath_.setAttribute("fill",a);a=goog.color.darken(b,.1);a=goog.color.rgbArrayToHex(a);this.svgPath_.setAttribute("stroke",a);for(a=0;b=this.inputList[a];a++)for(var c=0,d;d=b.fieldRow[c];c++)d.setText(null)};Blockly.BlockSvg.prototype.updateDisabled=function(){};
Blockly.BlockSvg.prototype.updateColour=function(){var a=this.parentBlock_?this.parentBlock_.getColour():this.getColour(),b=goog.color.hexToRgb(a);this.isShadow()?this.svgPath_.setAttribute("fill","#ffffff"):this.svgPath_.setAttribute("fill",a);a=goog.color.darken(b,.1);a=goog.color.rgbArrayToHex(a);this.svgPath_.setAttribute("stroke",a);for(a=0;b=this.inputList[a];a++)for(var c=0,d;d=b.fieldRow[c];c++)d.setText(null)};Blockly.BlockSvg.prototype.updateDisabled=function(){};
Blockly.BlockSvg.prototype.getCommentText=function(){return this.comment?this.comment.getText().replace(/\s+$/,"").replace(/ +\n/g,"\n"):""};Blockly.BlockSvg.prototype.setCommentText=function(a){var b=!1;goog.isString(a)?(this.comment||(this.comment=new Blockly.Comment(this),b=!0),this.comment.setText(a)):this.comment&&(this.comment.dispose(),b=!0);b&&this.rendered&&(this.render(),this.bumpNeighbours_())};
Blockly.BlockSvg.prototype.setWarningText=function(a,b){this.setWarningText.pid_||(this.setWarningText.pid_=Object.create(null));var c=b||"";if(c)this.setWarningText.pid_[c]&&(clearTimeout(this.setWarningText.pid_[c]),delete this.setWarningText.pid_[c]);else for(var d in this.setWarningText.pid_)clearTimeout(this.setWarningText.pid_[d]),delete this.setWarningText.pid_[d];if(2==Blockly.dragMode_){var e=this;this.setWarningText.pid_[c]=setTimeout(function(){e.workspace&&(delete e.setWarningText.pid_[c],
e.setWarningText(a,c))},100)}else{this.isInFlyout&&(a=null);d=!1;if(goog.isString(a))this.warning||(this.warning=new Blockly.Warning(this),d=!0),this.warning.setText(a,c);else if(this.warning&&!c)this.warning.dispose(),d=!0;else if(this.warning){d=this.warning.getText();this.warning.setText("",c);var f=this.warning.getText();f||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.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=this.renderCompute_();this.height=b.height;this.width=b.width;this.renderDraw_(b);!1!==a&&((a=this.getParent())?a.render(!0):Blockly.fireUiEvent(window,"resize"));Blockly.Field.stopCache()};
Blockly.BlockSvg.prototype.renderCompute_=function(){for(var a={statement:null,icon:null,width:0,height:0,bayHeight:0,bayWidth:0},b=0,c;c=this.inputList[b];b++){if(c.type==Blockly.NEXT_STATEMENT&&(a.statement=c,a.bayHeight=Blockly.BlockSvg.NOTCH_HEIGHT+16+3*Blockly.BlockSvg.CORNER_RADIUS,a.bayWidth=2*Blockly.BlockSvg.NOTCH_WIDTH+Blockly.BlockSvg.SEP_SPACE_X,c.connection&&c.connection.targetConnection)){var d=c.connection.targetBlock().getHeightWidth();a.bayHeight=Math.max(a.bayHeight,d.height);a.bayWidth=
Math.max(a.bayWidth,d.width)}for(var d=0,e;e=c.fieldRow[d];d++)e instanceof Blockly.FieldImage&&(a.icon=e)}b=a.icon?a.icon.getSize():new goog.math.Size(0,0);a.width=2*Blockly.BlockSvg.SEP_SPACE_X+b.width+a.bayWidth;a.statement&&(a.width+=2*Blockly.BlockSvg.CORNER_RADIUS+8);a.height=Math.max(2*Blockly.BlockSvg.SEP_SPACE_Y+b.height,Blockly.BlockSvg.NOTCH_HEIGHT+16+2*Blockly.BlockSvg.CORNER_RADIUS,a.bayHeight+Blockly.BlockSvg.SEP_SPACE_Y);return a};
Blockly.BlockSvg.prototype.renderCompute_=function(){var a={statement:null,valueInput:null,icon:null,width:0,height:0,bayHeight:0,bayWidth:0,fieldWidth:0,fieldHeight:0,fieldRadius:0,startHat:!1,endHat:!1};this.nextConnection&&!this.previousConnection&&(a.startHat=!0);this.previousConnection&&!this.nextConnection&&(a.endHat=!0);for(var b=0,c;c=this.inputList[b];b++){if(c.type==Blockly.NEXT_STATEMENT&&(a.statement=c,a.bayHeight=Blockly.BlockSvg.NOTCH_HEIGHT+16+3*Blockly.BlockSvg.CORNER_RADIUS,a.bayWidth=
2*Blockly.BlockSvg.NOTCH_WIDTH+Blockly.BlockSvg.MIN_BLOCK_X,c.connection&&c.connection.targetConnection)){var d=c.connection.targetBlock().getHeightWidth();a.bayHeight=Math.max(a.bayHeight,d.height);a.bayWidth=Math.max(a.bayWidth,d.width)}for(var d=0,e;e=c.fieldRow[d];d++)if(e instanceof Blockly.FieldImage&&(a.icon=e),e instanceof Blockly.FieldTextInput){var f=e.textElement_.getBBox();a.fieldWidth=f.width+Blockly.BlockSvg.SEP_SPACE_X;a.fieldHeight=f.height;a.fieldRadius="math_number"===e.sourceBlock_.type?
Blockly.BlockSvg.NUMBER_FIELD_CORNER_RADIUS:Blockly.BlockSvg.TEXT_FIELD_CORNER_RADIUS}}for(b=0;c=this.childBlocks_[b];b++)c.isShadow()&&(a.valueInput=c);b=a.icon?a.icon.getSize():new goog.math.Size(0,0);a.width=2*Blockly.BlockSvg.SEP_SPACE_X+b.width+a.bayWidth;a.statement&&(a.width+=2*Blockly.BlockSvg.CORNER_RADIUS+8);this.outputConnection?(a.height=Blockly.BlockSvg.FIELD_HEIGHT,a.width=Blockly.BlockSvg.FIELD_WIDTH):a.height=Math.max(2*Blockly.BlockSvg.SEP_SPACE_Y+b.height,Blockly.BlockSvg.NOTCH_HEIGHT+
16+2*Blockly.BlockSvg.CORNER_RADIUS,a.bayHeight+Blockly.BlockSvg.SEP_SPACE_Y);return a};
Blockly.BlockSvg.prototype.renderDraw_=function(a){var b=this.getRelativeToSurfaceXY(),c=[];this.renderDrawLeft_(c,b,a);this.renderDrawBottom_(c,b,a);this.renderDrawRight_(c,b,a);this.renderDrawTop_(c,b,a);b=c.join(" ");this.svgPath_.setAttribute("d",b);this.RTL&&this.svgPath_.setAttribute("transform","scale(-1 1)");a.icon&&(b=a.icon.getSvgRoot(),c=a.icon.getSize(),b.setAttribute("transform","translate("+(a.width-c.width-Blockly.BlockSvg.SEP_SPACE_X/2)+","+(a.height-c.height-Blockly.BlockSvg.SEP_SPACE_Y)+
")"))};
Blockly.BlockSvg.prototype.renderDrawLeft_=function(a,b,c){this.previousConnection?(a.push(Blockly.BlockSvg.TOP_LEFT_CORNER_START),a.push(Blockly.BlockSvg.TOP_LEFT_CORNER),a.push("V",c.height-Blockly.BlockSvg.CORNER_RADIUS-8-Blockly.BlockSvg.NOTCH_HEIGHT),a.push(Blockly.BlockSvg.NOTCH_PATH_DOWN),this.previousConnection.moveTo(b.x,b.y+c.height-2*Blockly.BlockSvg.CORNER_RADIUS),a.push("V",c.height-Blockly.BlockSvg.CORNER_RADIUS)):(a.push(Blockly.BlockSvg.HAT_TOP_LEFT_CORNER_START),a.push(Blockly.BlockSvg.HAT_TOP_LEFT_CORNER),a.push("V",
c.height-Blockly.BlockSvg.HAT_CORNER_RADIUS))};
Blockly.BlockSvg.prototype.renderDrawBottom_=function(a,b,c){this.previousConnection?a.push("a",Blockly.BlockSvg.CORNER_RADIUS+","+Blockly.BlockSvg.CORNER_RADIUS+" 0 0,0 "+Blockly.BlockSvg.CORNER_RADIUS+","+Blockly.BlockSvg.CORNER_RADIUS):a.push("a",Blockly.BlockSvg.HAT_CORNER_RADIUS+","+Blockly.BlockSvg.HAT_CORNER_RADIUS+" 0 0,0 "+Blockly.BlockSvg.HAT_CORNER_RADIUS+","+Blockly.BlockSvg.HAT_CORNER_RADIUS);c.statement&&(a.push("h",8),a.push("a",Blockly.BlockSvg.CORNER_RADIUS+","+Blockly.BlockSvg.CORNER_RADIUS+
" 0 0,0 "+Blockly.BlockSvg.CORNER_RADIUS+",-"+Blockly.BlockSvg.CORNER_RADIUS),a.push("v",-8),a.push(Blockly.BlockSvg.NOTCH_PATH_UP),a.push("v",-c.bayHeight+3*Blockly.BlockSvg.CORNER_RADIUS+Blockly.BlockSvg.NOTCH_HEIGHT+8),a.push("a",Blockly.BlockSvg.CORNER_RADIUS+","+Blockly.BlockSvg.CORNER_RADIUS+" 0 0,1 "+Blockly.BlockSvg.CORNER_RADIUS+",-"+Blockly.BlockSvg.CORNER_RADIUS),a.push("h",c.bayWidth-2*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),a.push("v",c.bayHeight-3*Blockly.BlockSvg.CORNER_RADIUS-Blockly.BlockSvg.NOTCH_HEIGHT-8),a.push(Blockly.BlockSvg.NOTCH_PATH_DOWN),a.push("v",8),a.push("a",Blockly.BlockSvg.CORNER_RADIUS+","+Blockly.BlockSvg.CORNER_RADIUS+" 0 0,0 "+Blockly.BlockSvg.CORNER_RADIUS+","+Blockly.BlockSvg.CORNER_RADIUS),c.statement.connection.moveTo(b.x+2*Blockly.BlockSvg.CORNER_RADIUS+8,b.y+c.height-2*Blockly.BlockSvg.CORNER_RADIUS),c.statement.connection.targetConnection&&
c.statement.connection.tighten_());this.nextConnection?a.push("H",c.width-Blockly.BlockSvg.CORNER_RADIUS):a.push("H",c.width-Blockly.BlockSvg.HAT_CORNER_RADIUS)};
Blockly.BlockSvg.prototype.renderDrawRight_=function(a,b,c){this.nextConnection?a.push("a",Blockly.BlockSvg.CORNER_RADIUS+","+Blockly.BlockSvg.CORNER_RADIUS+" 0 0,0 "+Blockly.BlockSvg.CORNER_RADIUS+",-"+Blockly.BlockSvg.CORNER_RADIUS):a.push("a",Blockly.BlockSvg.HAT_CORNER_RADIUS+","+Blockly.BlockSvg.HAT_CORNER_RADIUS+" 0 0,0 "+Blockly.BlockSvg.HAT_CORNER_RADIUS+",-"+Blockly.BlockSvg.HAT_CORNER_RADIUS);a.push("v",-8);this.nextConnection?(a.push(Blockly.BlockSvg.NOTCH_PATH_UP),this.nextConnection.moveTo(b.x+
c.width,b.y+c.height-2*Blockly.BlockSvg.CORNER_RADIUS),this.nextConnection.targetConnection&&this.nextConnection.tighten_(),this.height+=4,a.push("V",Blockly.BlockSvg.CORNER_RADIUS)):a.push("V",Blockly.BlockSvg.HAT_CORNER_RADIUS)};
Blockly.BlockSvg.prototype.renderDrawTop_=function(a,b,c){this.nextConnection?a.push("a",Blockly.BlockSvg.CORNER_RADIUS+","+Blockly.BlockSvg.CORNER_RADIUS+" 0 0,0 -"+Blockly.BlockSvg.CORNER_RADIUS+",-"+Blockly.BlockSvg.CORNER_RADIUS):a.push("a",Blockly.BlockSvg.HAT_CORNER_RADIUS+","+Blockly.BlockSvg.HAT_CORNER_RADIUS+" 0 0,0 -"+Blockly.BlockSvg.HAT_CORNER_RADIUS+",-"+Blockly.BlockSvg.HAT_CORNER_RADIUS);a.push("z")};
")"));a.valueInput&&(b=a.valueInput.getSvgRoot(),b.getBBox(),b.setAttribute("transform","translate("+(Blockly.BlockSvg.NOTCH_WIDTH+(a.bayWidth?8+2*Blockly.BlockSvg.NOTCH_WIDTH:0)+a.bayWidth)+","+(a.height-8)+")"))};
Blockly.BlockSvg.prototype.renderDrawLeft_=function(a,b,c){c.startHat?(a.push(Blockly.BlockSvg.HAT_TOP_LEFT_CORNER_START),a.push(Blockly.BlockSvg.HAT_TOP_LEFT_CORNER),a.push("V",c.height-Blockly.BlockSvg.HAT_CORNER_RADIUS)):this.previousConnection?(a.push(Blockly.BlockSvg.TOP_LEFT_CORNER_START),a.push(Blockly.BlockSvg.TOP_LEFT_CORNER),a.push("V",c.height-Blockly.BlockSvg.CORNER_RADIUS-8-Blockly.BlockSvg.NOTCH_HEIGHT),a.push(Blockly.BlockSvg.NOTCH_PATH_DOWN),this.previousConnection.moveTo(b.x,b.y+
c.height-2*Blockly.BlockSvg.CORNER_RADIUS),a.push("V",c.height-Blockly.BlockSvg.CORNER_RADIUS)):(a.push("m",c.fieldRadius+",0"),a.push("A",c.fieldRadius+","+c.fieldRadius,"0","0,0","0,"+c.fieldRadius),a.push("V",c.height-c.fieldRadius))};
Blockly.BlockSvg.prototype.renderDrawBottom_=function(a,b,c){c.startHat?a.push("a",Blockly.BlockSvg.HAT_CORNER_RADIUS+","+Blockly.BlockSvg.HAT_CORNER_RADIUS+" 0 0,0 "+Blockly.BlockSvg.HAT_CORNER_RADIUS+","+Blockly.BlockSvg.HAT_CORNER_RADIUS):this.previousConnection?a.push("a",Blockly.BlockSvg.CORNER_RADIUS+","+Blockly.BlockSvg.CORNER_RADIUS+" 0 0,0 "+Blockly.BlockSvg.CORNER_RADIUS+","+Blockly.BlockSvg.CORNER_RADIUS):a.push("a",c.fieldRadius+","+c.fieldRadius,"0","0,0",c.fieldRadius+","+c.fieldRadius);
c.statement&&(a.push("h",8),a.push("a",Blockly.BlockSvg.CORNER_RADIUS+","+Blockly.BlockSvg.CORNER_RADIUS+" 0 0,0 "+Blockly.BlockSvg.CORNER_RADIUS+",-"+Blockly.BlockSvg.CORNER_RADIUS),a.push("v",-8),a.push(Blockly.BlockSvg.NOTCH_PATH_UP),a.push("v",-c.bayHeight+3*Blockly.BlockSvg.CORNER_RADIUS+Blockly.BlockSvg.NOTCH_HEIGHT+8),a.push("a",Blockly.BlockSvg.CORNER_RADIUS+","+Blockly.BlockSvg.CORNER_RADIUS+" 0 0,1 "+Blockly.BlockSvg.CORNER_RADIUS+",-"+Blockly.BlockSvg.CORNER_RADIUS),a.push("h",c.bayWidth-
2*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),a.push("v",c.bayHeight-3*Blockly.BlockSvg.CORNER_RADIUS-Blockly.BlockSvg.NOTCH_HEIGHT-8),a.push(Blockly.BlockSvg.NOTCH_PATH_DOWN),a.push("v",8),a.push("a",Blockly.BlockSvg.CORNER_RADIUS+","+Blockly.BlockSvg.CORNER_RADIUS+" 0 0,0 "+Blockly.BlockSvg.CORNER_RADIUS+","+Blockly.BlockSvg.CORNER_RADIUS),c.statement.connection.moveTo(b.x+
2*Blockly.BlockSvg.CORNER_RADIUS+8,b.y+c.height-2*Blockly.BlockSvg.CORNER_RADIUS),c.statement.connection.targetConnection&&c.statement.connection.tighten_());c.endHat?a.push("H",c.width-Blockly.BlockSvg.HAT_CORNER_RADIUS):this.nextConnection?a.push("H",c.width-Blockly.BlockSvg.CORNER_RADIUS):a.push("H",c.width-c.fieldRadius)};
Blockly.BlockSvg.prototype.renderDrawRight_=function(a,b,c){c.endHat?(a.push("a",Blockly.BlockSvg.HAT_CORNER_RADIUS+","+Blockly.BlockSvg.HAT_CORNER_RADIUS+" 0 0,0 "+Blockly.BlockSvg.HAT_CORNER_RADIUS+",-"+Blockly.BlockSvg.HAT_CORNER_RADIUS),a.push("v",-8)):this.nextConnection?(a.push("a",Blockly.BlockSvg.CORNER_RADIUS+","+Blockly.BlockSvg.CORNER_RADIUS+" 0 0,0 "+Blockly.BlockSvg.CORNER_RADIUS+",-"+Blockly.BlockSvg.CORNER_RADIUS),a.push("v",-8)):(a.push("a",c.fieldRadius+","+c.fieldRadius,"0","0,0",
c.fieldRadius+","+-1*c.fieldRadius),a.push("v",-1*(c.height-2*c.fieldRadius)));c.endHat?a.push("V",Blockly.BlockSvg.HAT_CORNER_RADIUS):this.nextConnection&&(a.push(Blockly.BlockSvg.NOTCH_PATH_UP),this.nextConnection.moveTo(b.x+c.width,b.y+c.height-2*Blockly.BlockSvg.CORNER_RADIUS),this.nextConnection.targetConnection&&this.nextConnection.tighten_(),this.height+=4,a.push("V",Blockly.BlockSvg.CORNER_RADIUS))};
Blockly.BlockSvg.prototype.renderDrawTop_=function(a,b,c){c.endHat?a.push("a",Blockly.BlockSvg.HAT_CORNER_RADIUS+","+Blockly.BlockSvg.HAT_CORNER_RADIUS+" 0 0,0 -"+Blockly.BlockSvg.HAT_CORNER_RADIUS+",-"+Blockly.BlockSvg.HAT_CORNER_RADIUS):this.nextConnection?a.push("a",Blockly.BlockSvg.CORNER_RADIUS+","+Blockly.BlockSvg.CORNER_RADIUS+" 0 0,0 -"+Blockly.BlockSvg.CORNER_RADIUS+",-"+Blockly.BlockSvg.CORNER_RADIUS):a.push("a",c.fieldRadius+","+c.fieldRadius,"0","0,0","-"+c.fieldRadius+",-"+c.fieldRadius);
a.push("z")};
// Copyright 2016 Google Inc. Apache License 2.0
Blockly.Events={};Blockly.Events.group="";Blockly.Events.disabled_=0;Blockly.Events.CREATE="create";Blockly.Events.DELETE="delete";Blockly.Events.CHANGE="change";Blockly.Events.MOVE="move";Blockly.Events.FIRE_QUEUE_=[];Blockly.Events.fire=function(a){Blockly.Events.isEnabled()&&(0==Blockly.Events.FIRE_QUEUE_.length&&setTimeout(Blockly.Events.fireNow_,0),Blockly.Events.FIRE_QUEUE_.push(a))};
Blockly.Events.fireNow_=function(){for(var a=Blockly.Events.filter_(Blockly.Events.FIRE_QUEUE_),b=Blockly.Events.FIRE_QUEUE_.length=0,c;c=a[b];b++){var d=Blockly.Workspace.getById(c.workspaceId);d&&d.fireChangeListener(c)}};
@ -1157,7 +1162,8 @@ this.spellcheck_);var e=Blockly.FieldTextInput.FONTSIZE*b.scale+"pt";c.style.fon
d.onWorkspaceChangeWrapper_=this.resizeEditor_.bind(this);b.addChangeListener(d.onWorkspaceChangeWrapper_)}};Blockly.FieldTextInput.prototype.onHtmlInputKeyDown_=function(a){var b=Blockly.FieldTextInput.htmlInput_;13==a.keyCode?Blockly.WidgetDiv.hide():27==a.keyCode?(b.value=b.defaultValue,Blockly.WidgetDiv.hide()):9==a.keyCode&&(Blockly.WidgetDiv.hide(),this.sourceBlock_.tab(this,!a.shiftKey),a.preventDefault())};
Blockly.FieldTextInput.prototype.onHtmlInputChange_=function(a){a=Blockly.FieldTextInput.htmlInput_;var b=a.value;b!==a.oldValue_?(a.oldValue_=b,this.setValue(b),this.validate_()):goog.userAgent.WEBKIT&&this.sourceBlock_.render();this.resizeEditor_()};
Blockly.FieldTextInput.prototype.validate_=function(){var a=!0;goog.asserts.assertObject(Blockly.FieldTextInput.htmlInput_);var b=Blockly.FieldTextInput.htmlInput_;this.sourceBlock_&&this.validator_&&(a=this.validator_(b.value));null===a?Blockly.addClass_(b,"blocklyInvalidInput"):Blockly.removeClass_(b,"blocklyInvalidInput")};
Blockly.FieldTextInput.prototype.resizeEditor_=function(){var a=Blockly.WidgetDiv.DIV,b=this.fieldGroup_.getBBox();a.style.width=b.width*this.sourceBlock_.workspace.scale+"px";a.style.height=b.height*this.sourceBlock_.workspace.scale+"px";b=this.getAbsoluteXY_();if(this.sourceBlock_.RTL){var c=this.getScaledBBox_();b.x+=c.width;b.x-=a.offsetWidth}b.y+=1;goog.userAgent.GECKO&&Blockly.WidgetDiv.DIV.style.top&&(--b.x,--b.y);goog.userAgent.WEBKIT&&(b.y-=3);a.style.left=b.x+"px";a.style.top=b.y+"px"};
Blockly.FieldTextInput.prototype.resizeEditor_=function(){var a=Blockly.WidgetDiv.DIV,b=this.fieldGroup_.getBBox(),c=b.height*this.sourceBlock_.workspace.scale;a.style.width=Math.max(b.width,Blockly.BlockSvg.FIELD_WIDTH-Blockly.BlockSvg.SEP_SPACE_X)*this.sourceBlock_.workspace.scale+"px";a.style.height=c+"px";b=this.getAbsoluteXY_();b.x+=Blockly.BlockSvg.SEP_SPACE_X*this.sourceBlock_.workspace.scale;b.y+=Blockly.BlockSvg.FIELD_HEIGHT*this.sourceBlock_.workspace.scale/2-c/2+3;this.sourceBlock_.RTL&&
(c=this.getScaledBBox_(),b.x+=c.width,b.x-=a.offsetWidth);b.y+=1;goog.userAgent.GECKO&&Blockly.WidgetDiv.DIV.style.top&&(--b.x,--b.y);goog.userAgent.WEBKIT&&(b.y-=3);a.style.left=b.x+"px";a.style.top=b.y+"px"};
Blockly.FieldTextInput.prototype.widgetDispose_=function(){var a=this;return function(){var b=Blockly.FieldTextInput.htmlInput_,c=b.value;if(a.sourceBlock_&&a.validator_){var d=a.validator_(c);null===d?c=b.defaultValue:void 0!==d&&(c=d)}a.setValue(c);a.sourceBlock_.rendered&&a.sourceBlock_.render();Blockly.unbindEvent_(b.onKeyDownWrapper_);Blockly.unbindEvent_(b.onKeyUpWrapper_);Blockly.unbindEvent_(b.onKeyPressWrapper_);a.sourceBlock_.workspace.removeChangeListener(b.onWorkspaceChangeWrapper_);Blockly.FieldTextInput.htmlInput_=
null;b=Blockly.WidgetDiv.DIV.style;b.width="auto";b.height="auto";b.fontSize=""}};Blockly.FieldTextInput.numberValidator=function(a){if(null===a)return null;a=String(a);a=a.replace(/O/ig,"0");a=a.replace(/,/g,"");a=parseFloat(a||0);return isNaN(a)?null:String(a)};Blockly.FieldTextInput.nonnegativeIntegerValidator=function(a){(a=Blockly.FieldTextInput.numberValidator(a))&&(a=String(Math.max(0,Math.floor(a))));return a};Blockly.FieldAngle=function(a,b){this.symbol_=Blockly.createSvgElement("tspan",{},null);this.symbol_.appendChild(document.createTextNode("\u00b0"));Blockly.FieldAngle.superClass_.constructor.call(this,a,b)};goog.inherits(Blockly.FieldAngle,Blockly.FieldTextInput);
Blockly.FieldAngle.prototype.setValidator=function(a){Blockly.FieldAngle.superClass_.setValidator.call(this,a?function(b){var c=a.call(this,b);if(null===c)var d=c;else void 0===c&&(c=b),d=Blockly.FieldAngle.angleValidator.call(this,c),void 0===d&&(d=c);return d===b?void 0:d}:Blockly.FieldAngle.angleValidator)};Blockly.FieldAngle.ROUND=15;Blockly.FieldAngle.HALF=50;Blockly.FieldAngle.CLOCKWISE=!1;Blockly.FieldAngle.OFFSET=0;Blockly.FieldAngle.WRAP=360;
@ -1272,9 +1278,9 @@ Blockly.Css.CONTENT=[".blocklySvg {","background-color: #fff;","outline: none;",
"fill: #aaa;","}",".blocklyResizeSW {","cursor: sw-resize;","fill: #aaa;","}",".blocklyResizeLine {","stroke: #888;","stroke-width: 1;","}",".blocklyHighlightedConnectionPath {","fill: none;","stroke: #fc3;","stroke-width: 4px;","}",".blocklyPath {","stroke-width: 1.5px;","}",".blocklySelected>.blocklyPath {","}",".blocklyDragging>.blocklyPath {","fill-opacity: .8;","stroke-opacity: .8;","}",".blocklyDisabled>.blocklyPath {","fill-opacity: .5;","stroke-opacity: .5;","}",".blocklyText {","cursor: default;",
"fill: #fff;","font-family: sans-serif;","font-size: 11pt;","}",".blocklyNonEditableText>text {","pointer-events: none;","}",".blocklyNonEditableText>rect,",".blocklyEditableText>rect {","fill: #fff;","fill-opacity: .6;","}",".blocklyNonEditableText>text,",".blocklyEditableText>text {","fill: #000;","}",".blocklyEditableText:hover>rect {","stroke: #fff;","stroke-width: 2;","}",".blocklyBubbleText {","fill: #000;","}",".blocklySvg text {","user-select: none;","-moz-user-select: none;","-webkit-user-select: none;",
"cursor: inherit;","}",".blocklyHidden {","display: none;","}",".blocklyFieldDropdown:not(.blocklyHidden) {","display: block;","}",".blocklyIconGroup {","cursor: default;","}",".blocklyIconGroup:not(:hover),",".blocklyIconGroupReadonly {","opacity: .6;","}",".blocklyIconShape {","fill: #00f;","stroke: #fff;","stroke-width: 1px;","}",".blocklyIconSymbol {","fill: #fff;","}",".blocklyMinimalBody {","margin: 0;","padding: 0;","}",".blocklyCommentTextarea {","background-color: #ffc;","border: 0;","margin: 0;",
"padding: 2px;","resize: none;","}",".blocklyHtmlInput {","border: none;","border-radius: 4px;","font-family: sans-serif;","height: 100%;","margin: 0;","outline: none;","padding: 0 1px;","width: 100%","}",".blocklyMainBackground {","stroke-width: 1;","stroke: #c6c6c6;","}",".blocklyMutatorBackground {","fill: #fff;","stroke: #ddd;","stroke-width: 1;","}",".blocklyFlyoutBackground {","fill: #ddd;","fill-opacity: .8;","}",".blocklyScrollbarBackground {","opacity: 0;","}",".blocklyScrollbarKnob {","fill: #ccc;",
"}",".blocklyScrollbarBackground:hover+.blocklyScrollbarKnob,",".blocklyScrollbarKnob:hover {","fill: #bbb;","}",".blocklyZoom>image {","opacity: .4;","}",".blocklyZoom>image:hover {","opacity: .6;","}",".blocklyZoom>image:active {","opacity: .8;","}",".blocklyFlyout .blocklyScrollbarKnob {","fill: #bbb;","}",".blocklyFlyout .blocklyScrollbarBackground:hover+.blocklyScrollbarKnob,",".blocklyFlyout .blocklyScrollbarKnob:hover {","fill: #aaa;","}",".blocklyInvalidInput {","background: #faa;","}",".blocklyAngleCircle {",
"stroke: #444;","stroke-width: 1;","fill: #ddd;","fill-opacity: .8;","}",".blocklyAngleMarks {","stroke: #444;","stroke-width: 1;","}",".blocklyAngleGauge {","fill: #f88;","fill-opacity: .8;","}",".blocklyAngleLine {","stroke: #f00;","stroke-width: 2;","stroke-linecap: round;","}",".blocklyContextMenu {","border-radius: 4px;","}",".blocklyDropdownMenu {","padding: 0 !important;","}",".blocklyWidgetDiv .goog-option-selected .goog-menuitem-checkbox,",".blocklyWidgetDiv .goog-option-selected .goog-menuitem-icon {",
"padding: 2px;","resize: none;","}",".blocklyHtmlInput {","border: none;","border-radius: 4px;","font-family: sans-serif;","height: 100%;","margin: 0;","outline: none;","padding: 0 1px;","width: 100%;","text-align: center","}",".blocklyMainBackground {","stroke-width: 1;","stroke: #c6c6c6;","}",".blocklyMutatorBackground {","fill: #fff;","stroke: #ddd;","stroke-width: 1;","}",".blocklyFlyoutBackground {","fill: #ddd;","fill-opacity: .8;","}",".blocklyScrollbarBackground {","opacity: 0;","}",".blocklyScrollbarKnob {",
"fill: #ccc;","}",".blocklyScrollbarBackground:hover+.blocklyScrollbarKnob,",".blocklyScrollbarKnob:hover {","fill: #bbb;","}",".blocklyZoom>image {","opacity: .4;","}",".blocklyZoom>image:hover {","opacity: .6;","}",".blocklyZoom>image:active {","opacity: .8;","}",".blocklyFlyout .blocklyScrollbarKnob {","fill: #bbb;","}",".blocklyFlyout .blocklyScrollbarBackground:hover+.blocklyScrollbarKnob,",".blocklyFlyout .blocklyScrollbarKnob:hover {","fill: #aaa;","}",".blocklyInvalidInput {","background: #faa;",
"}",".blocklyAngleCircle {","stroke: #444;","stroke-width: 1;","fill: #ddd;","fill-opacity: .8;","}",".blocklyAngleMarks {","stroke: #444;","stroke-width: 1;","}",".blocklyAngleGauge {","fill: #f88;","fill-opacity: .8;","}",".blocklyAngleLine {","stroke: #f00;","stroke-width: 2;","stroke-linecap: round;","}",".blocklyContextMenu {","border-radius: 4px;","}",".blocklyDropdownMenu {","padding: 0 !important;","}",".blocklyWidgetDiv .goog-option-selected .goog-menuitem-checkbox,",".blocklyWidgetDiv .goog-option-selected .goog-menuitem-icon {",
"background: url(<<<PATH>>>/sprites.png) no-repeat -48px -16px !important;","}",".blocklyToolboxDiv {","background-color: #ddd;","overflow-x: visible;","overflow-y: auto;","position: absolute;","}",".blocklyTreeRoot {","padding: 4px 0;","}",".blocklyTreeRoot:focus {","outline: none;","}",".blocklyTreeRow {","height: 22px;","line-height: 22px;","margin-bottom: 3px;","padding-right: 8px;","white-space: nowrap;","}",".blocklyHorizontalTree {","float: left;","margin: 1px 5px 8px 0px;","}",".blocklyHorizontalTreeRtl {",
"float: right;","margin: 1px 0px 8px 5px;","}",'.blocklyToolboxDiv[dir="RTL"] .blocklyTreeRow {',"margin-left: 8px;","}",".blocklyTreeRow:not(.blocklyTreeSelected):hover {","background-color: #e4e4e4;","}",".blocklyTreeSeparator {","border-bottom: solid #e5e5e5 1px;","height: 0px;","margin: 5px 0;","}",".blocklyTreeSeparatorHorizontal {","border-right: solid #e5e5e5 1px;","width: 0px;","padding: 5px 0;","margin: 0 5px;","}",".blocklyTreeIcon {","background-image: url(<<<PATH>>>/sprites.png);","height: 16px;",
"vertical-align: middle;","width: 16px;","}",".blocklyTreeIconClosedLtr {","background-position: -32px -1px;","}",".blocklyTreeIconClosedRtl {","background-position: 0px -1px;","}",".blocklyTreeIconOpen {","background-position: -16px -1px;","}",".blocklyTreeSelected>.blocklyTreeIconClosedLtr {","background-position: -32px -17px;","}",".blocklyTreeSelected>.blocklyTreeIconClosedRtl {","background-position: 0px -17px;","}",".blocklyTreeSelected>.blocklyTreeIconOpen {","background-position: -16px -17px;",

View file

@ -913,9 +913,10 @@ Blockly.Connection.prototype.hideAll=function(){this.setHidden(!0);if(this.targe
Blockly.Connection.prototype.unhideAll=function(){this.setHidden(!1);var a=[];if(this.type!=Blockly.INPUT_VALUE&&this.type!=Blockly.NEXT_STATEMENT)return a;var b=this.targetBlock();if(b){var c;b.isCollapsed()?(c=[],b.outputConnection&&c.push(b.outputConnection),b.nextConnection&&c.push(b.nextConnection),b.previousConnection&&c.push(b.previousConnection)):c=b.getConnections_(!0);for(var d=0;d<c.length;d++)a.push.apply(a,c[d].unhideAll());0==a.length&&(a[0]=b)}return a};Blockly.ConnectionDB=function(){};
Blockly.ConnectionDB.prototype=[];Blockly.ConnectionDB.constructor=Blockly.ConnectionDB;Blockly.ConnectionDB.prototype.addConnection_=function(a){if(a.inDB_)throw"Connection already in database.";if(!a.sourceBlock_.isInFlyout){for(var b=0,c=this.length;b<c;){var d=Math.floor((b+c)/2);if(this[d].y_<a.y_)b=d+1;else if(this[d].y_>a.y_)c=d;else{b=d;break}}this.splice(b,0,a);a.inDB_=!0}};
Blockly.ConnectionDB.prototype.removeConnection_=function(a){if(!a.inDB_)throw"Connection not in database.";a.inDB_=!1;for(var b=0,c=this.length-2,d=c;b<d;)this[d].y_<a.y_?b=d:c=d,d=Math.floor((b+c)/2);for(c=b=d;0<=b&&this[b].y_==a.y_;){if(this[b]==a){this.splice(b,1);return}b--}do{if(this[c]==a){this.splice(c,1);return}c++}while(c<this.length&&this[c].y_==a.y_);throw"Unable to find connection in connectionDB.";};
Blockly.ConnectionDB.init=function(a){var b=[];b[Blockly.INPUT_VALUE]=new Blockly.ConnectionDB;b[Blockly.OUTPUT_VALUE]=new Blockly.ConnectionDB;b[Blockly.NEXT_STATEMENT]=new Blockly.ConnectionDB;b[Blockly.PREVIOUS_STATEMENT]=new Blockly.ConnectionDB;a.connectionDBList=b};Blockly.Field=function(a,b){this.size_=new goog.math.Size(0,25);this.setValue(a);this.setValidator(b)};Blockly.Field.cacheWidths_=null;Blockly.Field.cacheReference_=0;Blockly.Field.prototype.name=void 0;Blockly.Field.prototype.maxDisplayLength=50;Blockly.Field.prototype.text_="";Blockly.Field.prototype.sourceBlock_=null;Blockly.Field.prototype.visible_=!0;Blockly.Field.prototype.validator_=null;Blockly.Field.NBSP="\u00a0";Blockly.Field.prototype.EDITABLE=!0;
Blockly.Field.prototype.init=function(a){this.sourceBlock_||(this.sourceBlock_=a,this.fieldGroup_=Blockly.createSvgElement("g",{},null),this.visible_||(this.fieldGroup_.style.display="none"),this.borderRect_=Blockly.createSvgElement("rect",{rx:4,ry:4,x:-Blockly.BlockSvg.SEP_SPACE_X/2,y:0,height:16},this.fieldGroup_,this.sourceBlock_.workspace),this.textElement_=Blockly.createSvgElement("text",{"class":"blocklyText",y:this.size_.height-12.5},this.fieldGroup_),this.updateEditable(),a.getSvgRoot().appendChild(this.fieldGroup_),
this.mouseUpWrapper_=Blockly.bindEvent_(this.fieldGroup_,"mouseup",this,this.onMouseUp_),this.updateTextNode_(),Blockly.Events.isEnabled()&&Blockly.Events.fire(new Blockly.Events.Change(this.sourceBlock_,"field",this.name,"",this.getValue())))};
Blockly.ConnectionDB.init=function(a){var b=[];b[Blockly.INPUT_VALUE]=new Blockly.ConnectionDB;b[Blockly.OUTPUT_VALUE]=new Blockly.ConnectionDB;b[Blockly.NEXT_STATEMENT]=new Blockly.ConnectionDB;b[Blockly.PREVIOUS_STATEMENT]=new Blockly.ConnectionDB;a.connectionDBList=b};Blockly.Field=function(a,b){this.size_=new goog.math.Size(Blockly.BlockSvg.FIELD_WIDTH,Blockly.BlockSvg.FIELD_HEIGHT);this.setValue(a);this.setValidator(b)};Blockly.Field.cacheWidths_=null;Blockly.Field.cacheReference_=0;Blockly.Field.prototype.name=void 0;Blockly.Field.prototype.maxDisplayLength=5;Blockly.Field.prototype.text_="";Blockly.Field.prototype.sourceBlock_=null;Blockly.Field.prototype.visible_=!0;Blockly.Field.prototype.validator_=null;Blockly.Field.NBSP="\u00a0";
Blockly.Field.prototype.EDITABLE=!0;
Blockly.Field.prototype.init=function(a){this.sourceBlock_||(this.sourceBlock_=a,this.fieldGroup_=Blockly.createSvgElement("g",{},null),this.visible_||(this.fieldGroup_.style.display="none"),this.borderRect_=Blockly.createSvgElement("rect",{rx:4,ry:4,x:-Blockly.BlockSvg.SEP_SPACE_X/2,y:0,height:Blockly.BlockSvg.FIELD_HEIGHT},this.fieldGroup_,this.sourceBlock_.workspace),this.textElement_=Blockly.createSvgElement("text",{"class":"blocklyText",y:this.size_.height/2+6.25,x:Blockly.BlockSvg.FIELD_WIDTH/
2,width:Blockly.BlockSvg.FIELD_WIDTH-Blockly.BlockSvg.SEP_SPACE_X,"text-anchor":"middle"},this.fieldGroup_),this.updateEditable(),a.getSvgRoot().appendChild(this.fieldGroup_),this.mouseUpWrapper_=Blockly.bindEvent_(this.fieldGroup_,"mouseup",this,this.onMouseUp_),this.updateTextNode_(),Blockly.Events.isEnabled()&&Blockly.Events.fire(new Blockly.Events.Change(this.sourceBlock_,"field",this.name,"",this.getValue())))};
Blockly.Field.prototype.dispose=function(){this.mouseUpWrapper_&&(Blockly.unbindEvent_(this.mouseUpWrapper_),this.mouseUpWrapper_=null);this.sourceBlock_=null;goog.dom.removeNode(this.fieldGroup_);this.validator_=this.borderRect_=this.textElement_=this.fieldGroup_=null};
Blockly.Field.prototype.updateEditable=function(){this.EDITABLE&&this.sourceBlock_&&(this.sourceBlock_.isEditable()?(Blockly.addClass_(this.fieldGroup_,"blocklyEditableText"),Blockly.removeClass_(this.fieldGroup_,"blocklyNoNEditableText"),this.fieldGroup_.style.cursor=this.CURSOR):(Blockly.addClass_(this.fieldGroup_,"blocklyNonEditableText"),Blockly.removeClass_(this.fieldGroup_,"blocklyEditableText"),this.fieldGroup_.style.cursor=""))};Blockly.Field.prototype.isVisible=function(){return this.visible_};
Blockly.Field.prototype.setVisible=function(a){if(this.visible_!=a){this.visible_=a;var b=this.getSvgRoot();b&&(b.style.display=a?"block":"none",this.render_())}};Blockly.Field.prototype.setValidator=function(a){this.validator_=a};Blockly.Field.prototype.getSvgRoot=function(){return this.fieldGroup_};
@ -1158,7 +1159,8 @@ this.spellcheck_);var e=Blockly.FieldTextInput.FONTSIZE*b.scale+"pt";c.style.fon
d.onWorkspaceChangeWrapper_=this.resizeEditor_.bind(this);b.addChangeListener(d.onWorkspaceChangeWrapper_)}};Blockly.FieldTextInput.prototype.onHtmlInputKeyDown_=function(a){var b=Blockly.FieldTextInput.htmlInput_;13==a.keyCode?Blockly.WidgetDiv.hide():27==a.keyCode?(b.value=b.defaultValue,Blockly.WidgetDiv.hide()):9==a.keyCode&&(Blockly.WidgetDiv.hide(),this.sourceBlock_.tab(this,!a.shiftKey),a.preventDefault())};
Blockly.FieldTextInput.prototype.onHtmlInputChange_=function(a){a=Blockly.FieldTextInput.htmlInput_;var b=a.value;b!==a.oldValue_?(a.oldValue_=b,this.setValue(b),this.validate_()):goog.userAgent.WEBKIT&&this.sourceBlock_.render();this.resizeEditor_()};
Blockly.FieldTextInput.prototype.validate_=function(){var a=!0;goog.asserts.assertObject(Blockly.FieldTextInput.htmlInput_);var b=Blockly.FieldTextInput.htmlInput_;this.sourceBlock_&&this.validator_&&(a=this.validator_(b.value));null===a?Blockly.addClass_(b,"blocklyInvalidInput"):Blockly.removeClass_(b,"blocklyInvalidInput")};
Blockly.FieldTextInput.prototype.resizeEditor_=function(){var a=Blockly.WidgetDiv.DIV,b=this.fieldGroup_.getBBox();a.style.width=b.width*this.sourceBlock_.workspace.scale+"px";a.style.height=b.height*this.sourceBlock_.workspace.scale+"px";b=this.getAbsoluteXY_();if(this.sourceBlock_.RTL){var c=this.getScaledBBox_();b.x+=c.width;b.x-=a.offsetWidth}b.y+=1;goog.userAgent.GECKO&&Blockly.WidgetDiv.DIV.style.top&&(--b.x,--b.y);goog.userAgent.WEBKIT&&(b.y-=3);a.style.left=b.x+"px";a.style.top=b.y+"px"};
Blockly.FieldTextInput.prototype.resizeEditor_=function(){var a=Blockly.WidgetDiv.DIV,b=this.fieldGroup_.getBBox(),c=b.height*this.sourceBlock_.workspace.scale;a.style.width=Math.max(b.width,Blockly.BlockSvg.FIELD_WIDTH-Blockly.BlockSvg.SEP_SPACE_X)*this.sourceBlock_.workspace.scale+"px";a.style.height=c+"px";b=this.getAbsoluteXY_();b.x+=Blockly.BlockSvg.SEP_SPACE_X*this.sourceBlock_.workspace.scale;b.y+=Blockly.BlockSvg.FIELD_HEIGHT*this.sourceBlock_.workspace.scale/2-c/2+3;this.sourceBlock_.RTL&&
(c=this.getScaledBBox_(),b.x+=c.width,b.x-=a.offsetWidth);b.y+=1;goog.userAgent.GECKO&&Blockly.WidgetDiv.DIV.style.top&&(--b.x,--b.y);goog.userAgent.WEBKIT&&(b.y-=3);a.style.left=b.x+"px";a.style.top=b.y+"px"};
Blockly.FieldTextInput.prototype.widgetDispose_=function(){var a=this;return function(){var b=Blockly.FieldTextInput.htmlInput_,c=b.value;if(a.sourceBlock_&&a.validator_){var d=a.validator_(c);null===d?c=b.defaultValue:void 0!==d&&(c=d)}a.setValue(c);a.sourceBlock_.rendered&&a.sourceBlock_.render();Blockly.unbindEvent_(b.onKeyDownWrapper_);Blockly.unbindEvent_(b.onKeyUpWrapper_);Blockly.unbindEvent_(b.onKeyPressWrapper_);a.sourceBlock_.workspace.removeChangeListener(b.onWorkspaceChangeWrapper_);Blockly.FieldTextInput.htmlInput_=
null;b=Blockly.WidgetDiv.DIV.style;b.width="auto";b.height="auto";b.fontSize=""}};Blockly.FieldTextInput.numberValidator=function(a){if(null===a)return null;a=String(a);a=a.replace(/O/ig,"0");a=a.replace(/,/g,"");a=parseFloat(a||0);return isNaN(a)?null:String(a)};Blockly.FieldTextInput.nonnegativeIntegerValidator=function(a){(a=Blockly.FieldTextInput.numberValidator(a))&&(a=String(Math.max(0,Math.floor(a))));return a};Blockly.FieldAngle=function(a,b){this.symbol_=Blockly.createSvgElement("tspan",{},null);this.symbol_.appendChild(document.createTextNode("\u00b0"));Blockly.FieldAngle.superClass_.constructor.call(this,a,b)};goog.inherits(Blockly.FieldAngle,Blockly.FieldTextInput);
Blockly.FieldAngle.prototype.setValidator=function(a){Blockly.FieldAngle.superClass_.setValidator.call(this,a?function(b){var c=a.call(this,b);if(null===c)var d=c;else void 0===c&&(c=b),d=Blockly.FieldAngle.angleValidator.call(this,c),void 0===d&&(d=c);return d===b?void 0:d}:Blockly.FieldAngle.angleValidator)};Blockly.FieldAngle.ROUND=15;Blockly.FieldAngle.HALF=50;Blockly.FieldAngle.CLOCKWISE=!1;Blockly.FieldAngle.OFFSET=0;Blockly.FieldAngle.WRAP=360;
@ -1273,9 +1275,9 @@ Blockly.Css.CONTENT=[".blocklySvg {","background-color: #fff;","outline: none;",
"fill: #aaa;","}",".blocklyResizeSW {","cursor: sw-resize;","fill: #aaa;","}",".blocklyResizeLine {","stroke: #888;","stroke-width: 1;","}",".blocklyHighlightedConnectionPath {","fill: none;","stroke: #fc3;","stroke-width: 4px;","}",".blocklyPath {","stroke-width: 1.5px;","}",".blocklySelected>.blocklyPath {","}",".blocklyDragging>.blocklyPath {","fill-opacity: .8;","stroke-opacity: .8;","}",".blocklyDisabled>.blocklyPath {","fill-opacity: .5;","stroke-opacity: .5;","}",".blocklyText {","cursor: default;",
"fill: #fff;","font-family: sans-serif;","font-size: 11pt;","}",".blocklyNonEditableText>text {","pointer-events: none;","}",".blocklyNonEditableText>rect,",".blocklyEditableText>rect {","fill: #fff;","fill-opacity: .6;","}",".blocklyNonEditableText>text,",".blocklyEditableText>text {","fill: #000;","}",".blocklyEditableText:hover>rect {","stroke: #fff;","stroke-width: 2;","}",".blocklyBubbleText {","fill: #000;","}",".blocklySvg text {","user-select: none;","-moz-user-select: none;","-webkit-user-select: none;",
"cursor: inherit;","}",".blocklyHidden {","display: none;","}",".blocklyFieldDropdown:not(.blocklyHidden) {","display: block;","}",".blocklyIconGroup {","cursor: default;","}",".blocklyIconGroup:not(:hover),",".blocklyIconGroupReadonly {","opacity: .6;","}",".blocklyIconShape {","fill: #00f;","stroke: #fff;","stroke-width: 1px;","}",".blocklyIconSymbol {","fill: #fff;","}",".blocklyMinimalBody {","margin: 0;","padding: 0;","}",".blocklyCommentTextarea {","background-color: #ffc;","border: 0;","margin: 0;",
"padding: 2px;","resize: none;","}",".blocklyHtmlInput {","border: none;","border-radius: 4px;","font-family: sans-serif;","height: 100%;","margin: 0;","outline: none;","padding: 0 1px;","width: 100%","}",".blocklyMainBackground {","stroke-width: 1;","stroke: #c6c6c6;","}",".blocklyMutatorBackground {","fill: #fff;","stroke: #ddd;","stroke-width: 1;","}",".blocklyFlyoutBackground {","fill: #ddd;","fill-opacity: .8;","}",".blocklyScrollbarBackground {","opacity: 0;","}",".blocklyScrollbarKnob {","fill: #ccc;",
"}",".blocklyScrollbarBackground:hover+.blocklyScrollbarKnob,",".blocklyScrollbarKnob:hover {","fill: #bbb;","}",".blocklyZoom>image {","opacity: .4;","}",".blocklyZoom>image:hover {","opacity: .6;","}",".blocklyZoom>image:active {","opacity: .8;","}",".blocklyFlyout .blocklyScrollbarKnob {","fill: #bbb;","}",".blocklyFlyout .blocklyScrollbarBackground:hover+.blocklyScrollbarKnob,",".blocklyFlyout .blocklyScrollbarKnob:hover {","fill: #aaa;","}",".blocklyInvalidInput {","background: #faa;","}",".blocklyAngleCircle {",
"stroke: #444;","stroke-width: 1;","fill: #ddd;","fill-opacity: .8;","}",".blocklyAngleMarks {","stroke: #444;","stroke-width: 1;","}",".blocklyAngleGauge {","fill: #f88;","fill-opacity: .8;","}",".blocklyAngleLine {","stroke: #f00;","stroke-width: 2;","stroke-linecap: round;","}",".blocklyContextMenu {","border-radius: 4px;","}",".blocklyDropdownMenu {","padding: 0 !important;","}",".blocklyWidgetDiv .goog-option-selected .goog-menuitem-checkbox,",".blocklyWidgetDiv .goog-option-selected .goog-menuitem-icon {",
"padding: 2px;","resize: none;","}",".blocklyHtmlInput {","border: none;","border-radius: 4px;","font-family: sans-serif;","height: 100%;","margin: 0;","outline: none;","padding: 0 1px;","width: 100%;","text-align: center","}",".blocklyMainBackground {","stroke-width: 1;","stroke: #c6c6c6;","}",".blocklyMutatorBackground {","fill: #fff;","stroke: #ddd;","stroke-width: 1;","}",".blocklyFlyoutBackground {","fill: #ddd;","fill-opacity: .8;","}",".blocklyScrollbarBackground {","opacity: 0;","}",".blocklyScrollbarKnob {",
"fill: #ccc;","}",".blocklyScrollbarBackground:hover+.blocklyScrollbarKnob,",".blocklyScrollbarKnob:hover {","fill: #bbb;","}",".blocklyZoom>image {","opacity: .4;","}",".blocklyZoom>image:hover {","opacity: .6;","}",".blocklyZoom>image:active {","opacity: .8;","}",".blocklyFlyout .blocklyScrollbarKnob {","fill: #bbb;","}",".blocklyFlyout .blocklyScrollbarBackground:hover+.blocklyScrollbarKnob,",".blocklyFlyout .blocklyScrollbarKnob:hover {","fill: #aaa;","}",".blocklyInvalidInput {","background: #faa;",
"}",".blocklyAngleCircle {","stroke: #444;","stroke-width: 1;","fill: #ddd;","fill-opacity: .8;","}",".blocklyAngleMarks {","stroke: #444;","stroke-width: 1;","}",".blocklyAngleGauge {","fill: #f88;","fill-opacity: .8;","}",".blocklyAngleLine {","stroke: #f00;","stroke-width: 2;","stroke-linecap: round;","}",".blocklyContextMenu {","border-radius: 4px;","}",".blocklyDropdownMenu {","padding: 0 !important;","}",".blocklyWidgetDiv .goog-option-selected .goog-menuitem-checkbox,",".blocklyWidgetDiv .goog-option-selected .goog-menuitem-icon {",
"background: url(<<<PATH>>>/sprites.png) no-repeat -48px -16px !important;","}",".blocklyToolboxDiv {","background-color: #ddd;","overflow-x: visible;","overflow-y: auto;","position: absolute;","}",".blocklyTreeRoot {","padding: 4px 0;","}",".blocklyTreeRoot:focus {","outline: none;","}",".blocklyTreeRow {","height: 22px;","line-height: 22px;","margin-bottom: 3px;","padding-right: 8px;","white-space: nowrap;","}",".blocklyHorizontalTree {","float: left;","margin: 1px 5px 8px 0px;","}",".blocklyHorizontalTreeRtl {",
"float: right;","margin: 1px 0px 8px 5px;","}",'.blocklyToolboxDiv[dir="RTL"] .blocklyTreeRow {',"margin-left: 8px;","}",".blocklyTreeRow:not(.blocklyTreeSelected):hover {","background-color: #e4e4e4;","}",".blocklyTreeSeparator {","border-bottom: solid #e5e5e5 1px;","height: 0px;","margin: 5px 0;","}",".blocklyTreeSeparatorHorizontal {","border-right: solid #e5e5e5 1px;","width: 0px;","padding: 5px 0;","margin: 0 5px;","}",".blocklyTreeIcon {","background-image: url(<<<PATH>>>/sprites.png);","height: 16px;",
"vertical-align: middle;","width: 16px;","}",".blocklyTreeIconClosedLtr {","background-position: -32px -1px;","}",".blocklyTreeIconClosedRtl {","background-position: 0px -1px;","}",".blocklyTreeIconOpen {","background-position: -16px -1px;","}",".blocklyTreeSelected>.blocklyTreeIconClosedLtr {","background-position: -32px -17px;","}",".blocklyTreeSelected>.blocklyTreeIconClosedRtl {","background-position: 0px -17px;","}",".blocklyTreeSelected>.blocklyTreeIconOpen {","background-position: -16px -17px;",

View file

@ -56,7 +56,7 @@ goog.addDependency("../../../" + dir + "/core/field_date.js", ['Blockly.FieldDat
goog.addDependency("../../../" + dir + "/core/field_dropdown.js", ['Blockly.FieldDropdown'], ['Blockly.Field', 'goog.dom', 'goog.events', 'goog.style', 'goog.ui.Menu', 'goog.ui.MenuItem', 'goog.userAgent']);
goog.addDependency("../../../" + dir + "/core/field_image.js", ['Blockly.FieldImage'], ['Blockly.Field', 'goog.dom', 'goog.math.Size', 'goog.userAgent']);
goog.addDependency("../../../" + dir + "/core/field_label.js", ['Blockly.FieldLabel'], ['Blockly.Field', 'Blockly.Tooltip', 'goog.dom', 'goog.math.Size']);
goog.addDependency("../../../" + dir + "/core/field_textinput.js", ['Blockly.FieldTextInput'], ['Blockly.Field', 'Blockly.Msg', 'goog.asserts', 'goog.dom', 'goog.userAgent']);
goog.addDependency("../../../" + dir + "/core/field_textinput.js", ['Blockly.FieldTextInput'], ['Blockly.BlockSvg', 'Blockly.Field', 'Blockly.Msg', 'goog.asserts', 'goog.dom', 'goog.userAgent']);
goog.addDependency("../../../" + dir + "/core/field_variable.js", ['Blockly.FieldVariable'], ['Blockly.FieldDropdown', 'Blockly.Msg', 'Blockly.Variables', 'goog.string']);
goog.addDependency("../../../" + dir + "/core/flyout.js", ['Blockly.Flyout'], ['Blockly.Block', 'Blockly.Comment', 'Blockly.WorkspaceSvg', 'goog.dom', 'goog.events', 'goog.math.Rect', 'goog.userAgent']);
goog.addDependency("../../../" + dir + "/core/generator.js", ['Blockly.Generator'], ['Blockly.Block', 'goog.asserts']);

View file

@ -56,7 +56,7 @@ goog.addDependency("../../../" + dir + "/core/field_date.js", ['Blockly.FieldDat
goog.addDependency("../../../" + dir + "/core/field_dropdown.js", ['Blockly.FieldDropdown'], ['Blockly.Field', 'goog.dom', 'goog.events', 'goog.style', 'goog.ui.Menu', 'goog.ui.MenuItem', 'goog.userAgent']);
goog.addDependency("../../../" + dir + "/core/field_image.js", ['Blockly.FieldImage'], ['Blockly.Field', 'goog.dom', 'goog.math.Size', 'goog.userAgent']);
goog.addDependency("../../../" + dir + "/core/field_label.js", ['Blockly.FieldLabel'], ['Blockly.Field', 'Blockly.Tooltip', 'goog.dom', 'goog.math.Size']);
goog.addDependency("../../../" + dir + "/core/field_textinput.js", ['Blockly.FieldTextInput'], ['Blockly.Field', 'Blockly.Msg', 'goog.asserts', 'goog.dom', 'goog.userAgent']);
goog.addDependency("../../../" + dir + "/core/field_textinput.js", ['Blockly.FieldTextInput'], ['Blockly.BlockSvg', 'Blockly.Field', 'Blockly.Msg', 'goog.asserts', 'goog.dom', 'goog.userAgent']);
goog.addDependency("../../../" + dir + "/core/field_variable.js", ['Blockly.FieldVariable'], ['Blockly.FieldDropdown', 'Blockly.Msg', 'Blockly.Variables', 'goog.string']);
goog.addDependency("../../../" + dir + "/core/flyout.js", ['Blockly.Flyout'], ['Blockly.Block', 'Blockly.Comment', 'Blockly.WorkspaceSvg', 'goog.dom', 'goog.events', 'goog.math.Rect', 'goog.userAgent']);
goog.addDependency("../../../" + dir + "/core/generator.js", ['Blockly.Generator'], ['Blockly.Block', 'goog.asserts']);

View file

@ -0,0 +1,65 @@
/**
* @license
* Visual Blocks Editor
*
* Copyright 2016 MIT
* https://github.com/lkjashdflkjahsdf
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @fileoverview Looks blocks for Scratch (Horizontal)
* @author rschamp@media.mit.edu <Ray Schamp>
*/
'use strict';
goog.provide('Blockly.Blocks.looks');
goog.require('Blockly.Blocks');
Blockly.Blocks['looks_say'] = {
/**
* Block to say something.
* @this Blockly.Block
*/
init: function() {
this.jsonInit({
"id": "looks_say",
"message0": "%1 %2",
"args0": [
{
"type": "field_image",
"src": Blockly.mainWorkspace.options.pathToMedia + "icons/looks_say.svg",
"width": 40,
"height": 40,
"alt": "say"
},
{
"type": "input_value",
"name": "MESSAGE",
"check": "Number"
}
],
"inputsInline": true,
"previousStatement": null,
"nextStatement": null,
"colour": '#6971E7',
"tooltip": ""
});
this.setHelpUrl(function () {
return 'halp me plz. k thx bye.';
});
}
};

View file

@ -780,10 +780,30 @@ Blockly.BlockSvg.SEP_SPACE_Y = 8;
*/
Blockly.BlockSvg.INLINE_PADDING_Y = 5;
/**
* Minimum height of a block.
* Height of user inputs
* @const
*/
Blockly.BlockSvg.MIN_BLOCK_Y = 25;
Blockly.BlockSvg.FIELD_HEIGHT = 32;
/**
* Width of user inputs
* @const
*/
Blockly.BlockSvg.FIELD_WIDTH = 48;
/**
* Corner radius of number inputs
* @const
*/
Blockly.BlockSvg.NUMBER_FIELD_CORNER_RADIUS = 16;
/**
* Corner radius of text inputs
* @const
*/
Blockly.BlockSvg.TEXT_FIELD_CORNER_RADIUS = 4;
/**
* Minimum width of a block.
* @const
*/
Blockly.BlockSvg.MIN_BLOCK_X = 40;
/**
* Width of horizontal puzzle tab.
* @const
@ -1122,13 +1142,13 @@ Blockly.BlockSvg.disconnectUiStop_.group = null;
*/
Blockly.BlockSvg.prototype.updateColour = function() {
// Render block fill
var hexColour = this.getColour();
var hexColour = this.parentBlock_ ? this.parentBlock_.getColour() : this.getColour();
var rgb = goog.color.hexToRgb(hexColour);
if (this.isShadow()) {
rgb = goog.color.lighten(rgb, 0.6);
hexColour = goog.color.rgbArrayToHex(rgb);
this.svgPath_.setAttribute('fill', '#ffffff');
} else {
this.svgPath_.setAttribute('fill', hexColour);
}
this.svgPath_.setAttribute('fill', hexColour);
// Render block stroke
var colorShift = goog.color.darken(rgb, 0.1);
@ -1345,13 +1365,26 @@ Blockly.BlockSvg.prototype.render = function(opt_bubble) {
Blockly.BlockSvg.prototype.renderCompute_ = function() {
var metrics = {
statement: null,
valueInput: null,
icon: null,
width: 0,
height: 0,
bayHeight: 0,
bayWidth: 0
bayWidth: 0,
fieldWidth: 0,
fieldHeight: 0,
fieldRadius: 0,
startHat: false,
endHat: false
};
if (this.nextConnection && !this.previousConnection) {
metrics.startHat = true;
}
if (this.previousConnection && !this.nextConnection) {
metrics.endHat = true;
}
// Does block have a statement?
for (var i = 0, input; input = this.inputList[i]; i++) {
if (input.type == Blockly.NEXT_STATEMENT) {
@ -1361,7 +1394,7 @@ Blockly.BlockSvg.prototype.renderCompute_ = function() {
metrics.bayHeight = Blockly.BlockSvg.NOTCH_HEIGHT + 16 +
Blockly.BlockSvg.CORNER_RADIUS * 3;
metrics.bayWidth = Blockly.BlockSvg.NOTCH_WIDTH * 2 +
Blockly.BlockSvg.SEP_SPACE_X;
Blockly.BlockSvg.MIN_BLOCK_X;
// Expand input size if there is a connection.
if (input.connection && input.connection.targetConnection) {
var linkedBlock = input.connection.targetBlock();
@ -1376,6 +1409,22 @@ Blockly.BlockSvg.prototype.renderCompute_ = function() {
if (field instanceof Blockly.FieldImage) {
metrics.icon = field;
}
if (field instanceof Blockly.FieldTextInput) {
var fieldBBox = field.textElement_.getBBox();
metrics.fieldWidth = fieldBBox.width + Blockly.BlockSvg.SEP_SPACE_X;
metrics.fieldHeight = fieldBBox.height;
if (field.sourceBlock_.type === 'math_number') {
metrics.fieldRadius = Blockly.BlockSvg.NUMBER_FIELD_CORNER_RADIUS;
} else {
metrics.fieldRadius = Blockly.BlockSvg.TEXT_FIELD_CORNER_RADIUS;
}
}
}
}
for (var i = 0, child; child = this.childBlocks_[i]; i++) {
if (child.isShadow()) {
metrics.valueInput = child;
}
}
@ -1385,11 +1434,16 @@ Blockly.BlockSvg.prototype.renderCompute_ = function() {
if (metrics.statement) {
metrics.width += 2 * Blockly.BlockSvg.CORNER_RADIUS + 8;
}
metrics.height = Math.max(
Blockly.BlockSvg.SEP_SPACE_Y * 2 + iconSize.height,
Blockly.BlockSvg.NOTCH_HEIGHT + 16 + Blockly.BlockSvg.CORNER_RADIUS * 2,
metrics.bayHeight + Blockly.BlockSvg.SEP_SPACE_Y
);
if (this.outputConnection) {
metrics.height = Blockly.BlockSvg.FIELD_HEIGHT;
metrics.width = Blockly.BlockSvg.FIELD_WIDTH;
} else {
metrics.height = Math.max(
Blockly.BlockSvg.SEP_SPACE_Y * 2 + iconSize.height,
Blockly.BlockSvg.NOTCH_HEIGHT + 16 + Blockly.BlockSvg.CORNER_RADIUS * 2,
metrics.bayHeight + Blockly.BlockSvg.SEP_SPACE_Y
);
}
return metrics;
};
@ -1433,6 +1487,16 @@ Blockly.BlockSvg.prototype.renderDraw_ = function(metrics) {
(metrics.height - iconSize.height - Blockly.BlockSvg.SEP_SPACE_Y) + ')');
// @todo RTL
}
// Position value input
if (metrics.valueInput) {
var input = metrics.valueInput.getSvgRoot();
var inputBBox = input.getBBox();
var transformation = 'translate(' +
(Blockly.BlockSvg.NOTCH_WIDTH + (metrics.bayWidth ? 8 + Blockly.BlockSvg.NOTCH_WIDTH*2 : 0) + metrics.bayWidth) + ',' +
(metrics.height - 8) + ')';
input.setAttribute('transform', transformation);
}
};
/**
@ -1446,7 +1510,15 @@ Blockly.BlockSvg.prototype.renderDrawLeft_ =
function(steps, connectionsXY, metrics) {
// Top edge.
if (this.previousConnection) {
if (metrics.startHat) {
// Hat block
// Position the cursor at the top-left starting point.
steps.push(Blockly.BlockSvg.HAT_TOP_LEFT_CORNER_START);
// Top-left rounded corner.
steps.push(Blockly.BlockSvg.HAT_TOP_LEFT_CORNER);
steps.push('V', metrics.height - Blockly.BlockSvg.HAT_CORNER_RADIUS);
} else if (this.previousConnection) {
// Regular block
// Position the cursor at the top-left starting point.
steps.push(Blockly.BlockSvg.TOP_LEFT_CORNER_START);
// Top-left rounded corner.
@ -1461,11 +1533,15 @@ Blockly.BlockSvg.prototype.renderDrawLeft_ =
// This connection will be tightened when the parent renders.
steps.push('V', metrics.height - Blockly.BlockSvg.CORNER_RADIUS);
} else {
// Input
// Position the cursor at the top-left starting point.
steps.push(Blockly.BlockSvg.HAT_TOP_LEFT_CORNER_START);
steps.push('m', metrics.fieldRadius + ',0');
// Top-left rounded corner.
steps.push(Blockly.BlockSvg.HAT_TOP_LEFT_CORNER);
steps.push('V', metrics.height - Blockly.BlockSvg.HAT_CORNER_RADIUS);
steps.push(
'A', metrics.fieldRadius + ',' + metrics.fieldRadius,
'0', '0,0', '0,' + metrics.fieldRadius);
steps.push(
'V', metrics.height - metrics.fieldRadius);
}
};
@ -1482,16 +1558,21 @@ Blockly.BlockSvg.prototype.renderDrawLeft_ =
Blockly.BlockSvg.prototype.renderDrawBottom_ = function(steps,
connectionsXY, metrics) {
if (this.previousConnection) {
if (metrics.startHat) {
steps.push('a', Blockly.BlockSvg.HAT_CORNER_RADIUS + ',' +
Blockly.BlockSvg.HAT_CORNER_RADIUS + ' 0 0,0 ' +
Blockly.BlockSvg.HAT_CORNER_RADIUS + ',' +
Blockly.BlockSvg.HAT_CORNER_RADIUS);
} else if (this.previousConnection) {
steps.push('a', Blockly.BlockSvg.CORNER_RADIUS + ',' +
Blockly.BlockSvg.CORNER_RADIUS + ' 0 0,0 ' +
Blockly.BlockSvg.CORNER_RADIUS + ',' +
Blockly.BlockSvg.CORNER_RADIUS);
} else {
steps.push('a', Blockly.BlockSvg.HAT_CORNER_RADIUS + ',' +
Blockly.BlockSvg.HAT_CORNER_RADIUS + ' 0 0,0 ' +
Blockly.BlockSvg.HAT_CORNER_RADIUS + ',' +
Blockly.BlockSvg.HAT_CORNER_RADIUS);
// Input
steps.push(
'a', metrics.fieldRadius + ',' + metrics.fieldRadius,
'0', '0,0', metrics.fieldRadius + ',' + metrics.fieldRadius);
}
// Has statement
@ -1533,10 +1614,13 @@ Blockly.BlockSvg.prototype.renderDrawBottom_ = function(steps,
}
}
if (this.nextConnection) {
if (metrics.endHat) {
steps.push('H', metrics.width - Blockly.BlockSvg.HAT_CORNER_RADIUS);
} else if (this.nextConnection) {
steps.push('H', metrics.width - Blockly.BlockSvg.CORNER_RADIUS);
} else {
steps.push('H', metrics.width - Blockly.BlockSvg.HAT_CORNER_RADIUS);
// input
steps.push('H', metrics.width - metrics.fieldRadius);
}
};
@ -1549,20 +1633,29 @@ Blockly.BlockSvg.prototype.renderDrawBottom_ = function(steps,
*/
Blockly.BlockSvg.prototype.renderDrawRight_ =
function(steps, connectionsXY, metrics) {
if (this.nextConnection) {
if (metrics.endHat) {
steps.push('a', Blockly.BlockSvg.HAT_CORNER_RADIUS + ',' +
Blockly.BlockSvg.HAT_CORNER_RADIUS + ' 0 0,0 ' +
Blockly.BlockSvg.HAT_CORNER_RADIUS + ',-' +
Blockly.BlockSvg.HAT_CORNER_RADIUS);
steps.push('v', -8);
} else if (this.nextConnection) {
steps.push('a', Blockly.BlockSvg.CORNER_RADIUS + ',' +
Blockly.BlockSvg.CORNER_RADIUS + ' 0 0,0 ' +
Blockly.BlockSvg.CORNER_RADIUS + ',-' +
Blockly.BlockSvg.CORNER_RADIUS);
steps.push('v', -8);
} else {
steps.push('a', Blockly.BlockSvg.HAT_CORNER_RADIUS + ',' +
Blockly.BlockSvg.HAT_CORNER_RADIUS + ' 0 0,0 ' +
Blockly.BlockSvg.HAT_CORNER_RADIUS + ',-' +
Blockly.BlockSvg.HAT_CORNER_RADIUS);
// Input
steps.push(
'a', metrics.fieldRadius + ',' + metrics.fieldRadius,
'0', '0,0', metrics.fieldRadius + ',' + -1*metrics.fieldRadius);
steps.push('v', -1*(metrics.height - metrics.fieldRadius*2));
}
steps.push('v', -8);
if (this.nextConnection) {
if (metrics.endHat) {
steps.push('V', Blockly.BlockSvg.HAT_CORNER_RADIUS);
} else if (this.nextConnection) {
steps.push(Blockly.BlockSvg.NOTCH_PATH_UP);
// Create next block connection.
@ -1579,8 +1672,6 @@ Blockly.BlockSvg.prototype.renderDrawRight_ =
}
this.height += 4; // Height of tab.
steps.push('V', Blockly.BlockSvg.CORNER_RADIUS);
} else {
steps.push('V', Blockly.BlockSvg.HAT_CORNER_RADIUS);
}
};
@ -1593,16 +1684,20 @@ Blockly.BlockSvg.prototype.renderDrawRight_ =
*/
Blockly.BlockSvg.prototype.renderDrawTop_ =
function(steps, connectionsXY, metrics) {
if (this.nextConnection) {
if (metrics.endHat) {
steps.push('a', Blockly.BlockSvg.HAT_CORNER_RADIUS + ',' +
Blockly.BlockSvg.HAT_CORNER_RADIUS + ' 0 0,0 -' +
Blockly.BlockSvg.HAT_CORNER_RADIUS + ',-' +
Blockly.BlockSvg.HAT_CORNER_RADIUS);
} else if (this.nextConnection) {
steps.push('a', Blockly.BlockSvg.CORNER_RADIUS + ',' +
Blockly.BlockSvg.CORNER_RADIUS + ' 0 0,0 -' +
Blockly.BlockSvg.CORNER_RADIUS + ',-' +
Blockly.BlockSvg.CORNER_RADIUS);
} else {
steps.push('a', Blockly.BlockSvg.HAT_CORNER_RADIUS + ',' +
Blockly.BlockSvg.HAT_CORNER_RADIUS + ' 0 0,0 -' +
Blockly.BlockSvg.HAT_CORNER_RADIUS + ',-' +
Blockly.BlockSvg.HAT_CORNER_RADIUS);
steps.push(
'a', metrics.fieldRadius + ',' + metrics.fieldRadius,
'0', '0,0', '-' + metrics.fieldRadius + ',-' + metrics.fieldRadius);
}
steps.push('z');
};

View file

@ -288,7 +288,8 @@ Blockly.Css.CONTENT = [
'margin: 0;',
'outline: none;',
'padding: 0 1px;',
'width: 100%',
'width: 100%;',
'text-align: center',
'}',
'.blocklyMainBackground {',

View file

@ -45,7 +45,9 @@ goog.require('goog.userAgent');
* @constructor
*/
Blockly.Field = function(text, opt_validator) {
this.size_ = new goog.math.Size(0, 25);
this.size_ = new goog.math.Size(
Blockly.BlockSvg.FIELD_WIDTH,
Blockly.BlockSvg.FIELD_HEIGHT);
this.setValue(text);
this.setValidator(opt_validator);
};
@ -76,7 +78,7 @@ Blockly.Field.prototype.name = undefined;
* Maximum characters of text to display before adding an ellipsis.
* @type {number}
*/
Blockly.Field.prototype.maxDisplayLength = 50;
Blockly.Field.prototype.maxDisplayLength = 5;
/**
* Visible text to display.
@ -137,10 +139,14 @@ Blockly.Field.prototype.init = function(block) {
'ry': 4,
'x': -Blockly.BlockSvg.SEP_SPACE_X / 2,
'y': 0,
'height': 16}, this.fieldGroup_, this.sourceBlock_.workspace);
'height': Blockly.BlockSvg.FIELD_HEIGHT}, this.fieldGroup_, this.sourceBlock_.workspace);
/** @type {!Element} */
this.textElement_ = Blockly.createSvgElement('text',
{'class': 'blocklyText', 'y': this.size_.height - 12.5},
{'class': 'blocklyText',
'y': this.size_.height/2 + 6.25,
'x': Blockly.BlockSvg.FIELD_WIDTH / 2,
'width': Blockly.BlockSvg.FIELD_WIDTH - Blockly.BlockSvg.SEP_SPACE_X,
'text-anchor': 'middle'},
this.fieldGroup_);
this.updateEditable();

View file

@ -26,6 +26,7 @@
goog.provide('Blockly.FieldTextInput');
goog.require('Blockly.BlockSvg');
goog.require('Blockly.Field');
goog.require('Blockly.Msg');
goog.require('goog.asserts');
@ -225,9 +226,16 @@ Blockly.FieldTextInput.prototype.validate_ = function() {
Blockly.FieldTextInput.prototype.resizeEditor_ = function() {
var div = Blockly.WidgetDiv.DIV;
var bBox = this.fieldGroup_.getBBox();
div.style.width = bBox.width * this.sourceBlock_.workspace.scale + 'px';
div.style.height = bBox.height * this.sourceBlock_.workspace.scale + 'px';
var height = bBox.height * this.sourceBlock_.workspace.scale;
var width = Math.max(
bBox.width, Blockly.BlockSvg.FIELD_WIDTH-Blockly.BlockSvg.SEP_SPACE_X) *
this.sourceBlock_.workspace.scale
div.style.width = width + 'px';
div.style.height = height + 'px';
var xy = this.getAbsoluteXY_();
xy.x += Blockly.BlockSvg.SEP_SPACE_X * this.sourceBlock_.workspace.scale;
// @todo Why 3?
xy.y += (Blockly.BlockSvg.FIELD_HEIGHT * this.sourceBlock_.workspace.scale)/2 - height/2 + 3;
// In RTL mode block fields and LTR input fields the left edge moves,
// whereas the right edge is fixed. Reposition the editor.
if (this.sourceBlock_.RTL) {

View file

@ -0,0 +1,41 @@
/**
* @license
* Visual Blocks Language
*
* Copyright 2012 Google Inc.
* https://developers.google.com/blockly/
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @fileoverview Generating JavaScript for looks blocks.
* @author rschamp@media.mit.edu (Ray Schamp)
*/
'use strict';
goog.provide('Blockly.JavaScript.looks');
goog.require('Blockly.JavaScript');
Blockly.JavaScript['looks_say'] = function(block) {
// Say something.
var message = Blockly.JavaScript.valueToCode(block, 'MESSAGE',
Blockly.JavaScript.ORDER_ASSIGNMENT) || '0';
var code = '';
var loopVar = Blockly.JavaScript.variableDB_.getDistinctName(
'message', Blockly.Variables.NAME_TYPE);
code += 'console.log(' + message + ');\n';
return code;
};

View file

@ -35,7 +35,7 @@ Blockly.JavaScript.controls_if=function(a){for(var b=0,c=Blockly.JavaScript.valu
Blockly.JavaScript.logic_compare=function(a){var b={EQ:"==",NEQ:"!=",LT:"<",LTE:"<=",GT:">",GTE:">="}[a.getFieldValue("OP")],c="=="==b||"!="==b?Blockly.JavaScript.ORDER_EQUALITY:Blockly.JavaScript.ORDER_RELATIONAL,d=Blockly.JavaScript.valueToCode(a,"A",c)||"0";a=Blockly.JavaScript.valueToCode(a,"B",c)||"0";return[d+" "+b+" "+a,c]};
Blockly.JavaScript.logic_operation=function(a){var b="AND"==a.getFieldValue("OP")?"&&":"||",c="&&"==b?Blockly.JavaScript.ORDER_LOGICAL_AND:Blockly.JavaScript.ORDER_LOGICAL_OR,d=Blockly.JavaScript.valueToCode(a,"A",c);a=Blockly.JavaScript.valueToCode(a,"B",c);if(d||a){var e="&&"==b?"true":"false";d||(d=e);a||(a=e)}else a=d="false";return[d+" "+b+" "+a,c]};
Blockly.JavaScript.logic_negate=function(a){var b=Blockly.JavaScript.ORDER_LOGICAL_NOT;return["!"+(Blockly.JavaScript.valueToCode(a,"BOOL",b)||"true"),b]};Blockly.JavaScript.logic_boolean=function(a){return["TRUE"==a.getFieldValue("BOOL")?"true":"false",Blockly.JavaScript.ORDER_ATOMIC]};Blockly.JavaScript.logic_null=function(a){return["null",Blockly.JavaScript.ORDER_ATOMIC]};
Blockly.JavaScript.logic_ternary=function(a){var b=Blockly.JavaScript.valueToCode(a,"IF",Blockly.JavaScript.ORDER_CONDITIONAL)||"false",c=Blockly.JavaScript.valueToCode(a,"THEN",Blockly.JavaScript.ORDER_CONDITIONAL)||"null";a=Blockly.JavaScript.valueToCode(a,"ELSE",Blockly.JavaScript.ORDER_CONDITIONAL)||"null";return[b+" ? "+c+" : "+a,Blockly.JavaScript.ORDER_CONDITIONAL]};Blockly.JavaScript.loops={};
Blockly.JavaScript.logic_ternary=function(a){var b=Blockly.JavaScript.valueToCode(a,"IF",Blockly.JavaScript.ORDER_CONDITIONAL)||"false",c=Blockly.JavaScript.valueToCode(a,"THEN",Blockly.JavaScript.ORDER_CONDITIONAL)||"null";a=Blockly.JavaScript.valueToCode(a,"ELSE",Blockly.JavaScript.ORDER_CONDITIONAL)||"null";return[b+" ? "+c+" : "+a,Blockly.JavaScript.ORDER_CONDITIONAL]};Blockly.JavaScript.looks={};Blockly.JavaScript.looks_say=function(a){a=Blockly.JavaScript.valueToCode(a,"MESSAGE",Blockly.JavaScript.ORDER_ASSIGNMENT)||"0";var b="";Blockly.JavaScript.variableDB_.getDistinctName("message",Blockly.Variables.NAME_TYPE);return b+("console.log("+a+");\n")};Blockly.JavaScript.loops={};
Blockly.JavaScript.controls_repeat_ext=function(a){var b=a.getField("TIMES")?String(Number(a.getFieldValue("TIMES"))):Blockly.JavaScript.valueToCode(a,"TIMES",Blockly.JavaScript.ORDER_ASSIGNMENT)||"0",c=Blockly.JavaScript.statementToCode(a,"DO"),c=Blockly.JavaScript.addLoopTrap(c,a.id);a="";var d=Blockly.JavaScript.variableDB_.getDistinctName("count",Blockly.Variables.NAME_TYPE),e=b;b.match(/^\w+$/)||Blockly.isNumber(b)||(e=Blockly.JavaScript.variableDB_.getDistinctName("repeat_end",Blockly.Variables.NAME_TYPE),
a+="var "+e+" = "+b+";\n");return a+("for (var "+d+" = 0; "+d+" < "+e+"; "+d+"++) {\n"+c+"}\n")};Blockly.JavaScript.controls_repeat=Blockly.JavaScript.controls_repeat_ext;
Blockly.JavaScript.controls_whileUntil=function(a){var b="UNTIL"==a.getFieldValue("MODE"),c=Blockly.JavaScript.valueToCode(a,"BOOL",b?Blockly.JavaScript.ORDER_LOGICAL_NOT:Blockly.JavaScript.ORDER_NONE)||"false",d=Blockly.JavaScript.statementToCode(a,"DO"),d=Blockly.JavaScript.addLoopTrap(d,a.id);b&&(c="!"+c);return"while ("+c+") {\n"+d+"}\n"};

11
media/icons/looks_say.svg Normal file
View file

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 19.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 40 40" style="enable-background:new 0 0 40 40;" xml:space="preserve">
<style type="text/css">
.st0{fill:#FFFFFF;stroke:#545DAA;stroke-width:4;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:10;}
</style>
<path class="st0" d="M37.4,18.3c0,7.4-7.6,13.3-17,13.5c-1.7,0-3.3,0.2-4.9,0.5c-1,0.2-1.9,0.4-2.8,0.6c-2.3,0.7-4.4,1.5-6.1,2.3
c-1,0.5-1.9-0.6-1.4-1.5c0.8-1.3,1.5-2.9,1.6-4.2c0.2-1.1,0-2.2-0.8-3c0,0-0.1-0.1-0.1-0.1c-1.8-1.9-3-4.3-3.3-6.9
c0-0.4-0.1-0.7-0.1-1.1c0-0.2,0-0.3,0-0.5c0.3-7.3,8-13.1,17.4-13.1C29.6,4.7,37.4,10.8,37.4,18.3z"/>
</svg>

After

(image error) Size: 849 B

View file

@ -6,13 +6,16 @@
<script src="../blockly_uncompressed_horizontal.js"></script>
<script src="../generators/javascript.js"></script>
<script src="../generators/javascript/control.js"></script>
<script src="../generators/javascript/looks.js"></script>
<script src="../generators/javascript/math.js"></script>
<script src="../generators/javascript/motion.js"></script>
<script src="../generators/javascript/event.js"></script>
<script src="../msg/messages.js"></script>
<script src="../blocks/math.js"></script>
<script src="../blocks_horizontal/event.js"></script>
<script src="../blocks/text.js"></script>
<script src="../blocks_horizontal/control.js"></script>
<script src="../blocks_horizontal/event.js"></script>
<script src="../blocks_horizontal/looks.js"></script>
<script src="../blocks_horizontal/motion.js"></script>
<script>
'use strict';
@ -149,6 +152,15 @@ h1 {
<div id="blocklyDiv"></div>
<xml id="toolbox" style="display: none">
<category name="Looks">
<block type="looks_say">
<value name="MESSAGE">
<shadow type="text">
<field name="TEXT">Hey!</field>
</shadow>
</value>
</block>
</category>
<category name="Events">
<block type="event_whenflagclicked"></block>
</category>