Merge pull request #255 from google/2016

Bug fixes from 2016 branch.
This commit is contained in:
Neil Fraser
2016-02-16 13:06:12 -08:00
9 changed files with 156 additions and 59 deletions

View File

@@ -974,7 +974,7 @@ Blockly.ZoomControls.prototype.createDom=function(){var a=this.workspace_;this.s
d.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",a.options.pathToMedia+Blockly.SPRITE.url);c=Blockly.createSvgElement("clipPath",{id:"blocklyZoominClipPath"+b},this.svgGroup_);Blockly.createSvgElement("rect",{width:32,height:32,y:43},c);var e=Blockly.createSvgElement("image",{width:Blockly.SPRITE.width,height:Blockly.SPRITE.height,x:-32,y:-49,"clip-path":"url(#blocklyZoominClipPath"+b+")"},this.svgGroup_);e.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",a.options.pathToMedia+
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.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=goog.dom.createDom("xml");a=a.getTopBlocks(!0);for(var c=0,d;d=a[c];c++)b.appendChild(Blockly.Xml.blockToDomWithXY(d));return b};Blockly.Xml.blockToDomWithXY=function(a){var b;workspace.RTL&&(b=workspace.getWidth());var c=Blockly.Xml.blockToDom(a),d=a.getRelativeToSurfaceXY();c.setAttribute("x",Math.round(a.workspace.RTL?b-d.x:d.x));c.setAttribute("y",Math.round(d.y));return c};
Blockly.Xml.blockToDom=function(a){var b=goog.dom.createDom(a.isShadow()?"shadow":"block");b.setAttribute("type",a.type);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);
@@ -1051,7 +1051,8 @@ Blockly.Block.prototype.getInputWithBlock=function(a){for(var b=0,c;c=this.input
Blockly.Block.prototype.getRootBlock=function(){var a,b=this;do a=b,b=a.parentBlock_;while(b);return a};Blockly.Block.prototype.getChildren=function(){return this.childBlocks_};
Blockly.Block.prototype.setParent=function(a){var b;Blockly.Events.isEnabled()&&!this.isShadow()&&(b=new Blockly.Events.Move(this));if(this.parentBlock_){for(var c=this.parentBlock_.childBlocks_,d,e=0;d=c[e];e++)if(d==this){c.splice(e,1);break}this.parentBlock_=null;this.previousConnection&&this.previousConnection.targetConnection&&this.previousConnection.disconnect();this.outputConnection&&this.outputConnection.targetConnection&&this.outputConnection.disconnect()}else this.workspace.removeTopBlock(this);
(this.parentBlock_=a)?a.childBlocks_.push(this):this.workspace.addTopBlock(this);b&&(b.recordNew(),Blockly.Events.fire(b))};Blockly.Block.prototype.getDescendants=function(){for(var a=[this],b,c=0;b=this.childBlocks_[c];c++)a.push.apply(a,b.getDescendants());return a};Blockly.Block.prototype.isDeletable=function(){return this.deletable_&&!this.isShadow_&&!(this.workspace&&this.workspace.options.readOnly)};Blockly.Block.prototype.setDeletable=function(a){this.deletable_=a};
Blockly.Block.prototype.isMovable=function(){return this.movable_&&!this.isShadow_&&!(this.workspace&&this.workspace.options.readOnly)};Blockly.Block.prototype.setMovable=function(a){this.movable_=a};Blockly.Block.prototype.isShadow=function(){return this.isShadow_};Blockly.Block.prototype.setShadow=function(a){this.isShadow_!=a&&(this.isShadow_=a,Blockly.Events.isEnabled()&&!a&&(a=Blockly.Xml.blockToDom(this),Blockly.Events.fire(new Blockly.Events.Create(this.workspace,a))))};
Blockly.Block.prototype.isMovable=function(){return this.movable_&&!this.isShadow_&&!(this.workspace&&this.workspace.options.readOnly)};Blockly.Block.prototype.setMovable=function(a){this.movable_=a};Blockly.Block.prototype.isShadow=function(){return this.isShadow_};
Blockly.Block.prototype.setShadow=function(a){this.isShadow_!=a&&(this.isShadow_=a,Blockly.Events.isEnabled()&&!a&&(Blockly.Events.group=Blockly.genUid(),a=Blockly.Xml.blockToDom(this),Blockly.Events.fire(new Blockly.Events.Create(this.workspace,a)),a=new Blockly.Events.Move(this),a.oldParentId=void 0,a.oldInputName=void 0,a.oldCoordinate=new goog.math.Coordinate(0,0),a.recordNew(),Blockly.Events.fire(a),Blockly.Events.group=""))};
Blockly.Block.prototype.isEditable=function(){return this.editable_&&!(this.workspace&&this.workspace.options.readOnly)};Blockly.Block.prototype.setEditable=function(a){this.editable_=a;a=0;for(var b;b=this.inputList[a];a++)for(var c=0,d;d=b.fieldRow[c];c++)d.updateEditable()};
Blockly.Block.prototype.setConnectionsHidden=function(a){if(!a&&this.isCollapsed()){if(this.outputConnection&&this.outputConnection.setHidden(a),this.previousConnection&&this.previousConnection.setHidden(a),this.nextConnection){this.nextConnection.setHidden(a);var b=this.nextConnection.targetBlock();b&&b.setConnectionsHidden(a)}}else for(var c=this.getConnections_(!0),d=0;b=c[d];d++)b.setHidden(a),b.isSuperior()&&(b=b.targetBlock())&&b.setConnectionsHidden(a)};
Blockly.Block.prototype.setHelpUrl=function(a){this.helpUrl=a};Blockly.Block.prototype.setTooltip=function(a){this.tooltip=a};Blockly.Block.prototype.getColour=function(){return this.colour_};Blockly.Block.prototype.setColour=function(a){var b=parseFloat(a);if(isNaN(b))if(goog.isString(a)&&a.match(/^#[0-9a-fA-F]{6}$/))this.colour_=a;else throw"Invalid colour: "+a;else this.colour_=Blockly.hueToRgb(b);this.rendered&&this.updateColour()};
@@ -1093,10 +1094,10 @@ Blockly.BlockSvg.prototype.snapToGrid=function(){if(this.workspace&&0==Blockly.d
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()}};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(),this.workspace.recordDeleteAreas(),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.onMouseDown_=function(a){if(!this.isInFlyout)if(this.workspace.markFocused(),Blockly.svgResize(this.workspace),Blockly.terminateDrag_(),this.select(),Blockly.hideChaff(),this.workspace.recordDeleteAreas(),Blockly.isRightButton(a))this.showContextMenu_(a);else if(this.isMovable()){Blockly.Events.group=Blockly.genUid();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){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)};
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.Events.group=""};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?
@@ -1156,12 +1157,13 @@ a.push("a",Blockly.BlockSvg.CORNER_RADIUS+","+Blockly.BlockSvg.CORNER_RADIUS+" 0
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+
",-0.5 q "+-.19*Blockly.BlockSvg.TAB_WIDTH+",-5.5 0,-11"),b.push("m",.92*Blockly.BlockSvg.TAB_WIDTH+",1 V 0.5 H 1")),this.width+=Blockly.BlockSvg.TAB_WIDTH):this.RTL||(this.squareTopLeftCorner_?b.push("V",.5):b.push("V",Blockly.BlockSvg.CORNER_RADIUS));a.push("z")};
// Copyright 2016 Google Inc. Apache License 2.0
Blockly.Events={};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={};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)}};
Blockly.Events.filter_=function(a){a=goog.array.clone(a);for(var b=0,c;c=a[b];b++)for(var d=b+1,e;e=a[d];d++)c.type==Blockly.Events.MOVE&&e.type==Blockly.Events.MOVE&&c.blockId==e.blockId?(c.newParentId=e.newParentId,c.newInputName=e.newInputName,c.newCoordinate=e.newCoordinate,a.splice(d,1),d--):c.type==Blockly.Events.CHANGE&&e.type==Blockly.Events.CHANGE&&c.blockId==e.blockId&&c.element==e.element&&c.name==e.name&&(c.newValue=e.newValue,a.splice(d,1),d--);for(b=a.length-1;0<=b;b--)a[b].isNull()&&
a.splice(b,1);return a};Blockly.Events.disable=function(){Blockly.Events.disabled_++};Blockly.Events.enable=function(){Blockly.Events.disabled_--};Blockly.Events.isEnabled=function(){return 0==Blockly.Events.disabled_};Blockly.Events.Abstract=function(){};Blockly.Events.Abstract.prototype.isNull=function(){return!1};Blockly.Events.Create=function(a,b){this.type=Blockly.Events.CREATE;this.workspaceId=a.id;this.xml=b};goog.inherits(Blockly.Events.Create,Blockly.Events.Abstract);
Blockly.Events.Delete=function(a){this.type=Blockly.Events.DELETE;this.workspaceId=a.workspace.id;this.blockId=a.id;this.oldXml=Blockly.Xml.blockToDom(a);var b=a.getParent();b&&(this.oldParentId=b.id,this.oldInput=getInputWithBlock(a).name)};goog.inherits(Blockly.Events.Delete,Blockly.Events.Abstract);Blockly.Events.Change=function(a,b,c,d,e){this.type=Blockly.Events.CHANGE;this.workspaceId=a.workspace.id;this.blockId=a.id;this.element=b;this.name=c;this.oldValue=d;this.newValue=e};
goog.inherits(Blockly.Events.Create,Blockly.Events.Abstract);Blockly.Events.Change.prototype.isNull=function(){return this.oldValue==this.newValue};Blockly.Events.Move=function(a){this.type=Blockly.Events.MOVE;this.workspaceId=a.workspace.id;this.blockId=a.id;a=this.currentLocation_();this.oldParentId=a.parentId;this.oldInputName=a.inputName;this.oldCoordinate=a.coordinate};goog.inherits(Blockly.Events.Move,Blockly.Events.Abstract);
a.splice(b,1);return a};Blockly.Events.disable=function(){Blockly.Events.disabled_++};Blockly.Events.enable=function(){Blockly.Events.disabled_--};Blockly.Events.isEnabled=function(){return 0==Blockly.Events.disabled_};Blockly.Events.Abstract=function(a){this.workspaceId=a.id;this.group=Blockly.Events.group};Blockly.Events.Abstract.prototype.isNull=function(){return!1};Blockly.Events.Create=function(a,b){Blockly.Events.Create.superClass_.constructor.call(this,a);this.xml=b};
goog.inherits(Blockly.Events.Create,Blockly.Events.Abstract);Blockly.Events.Create.prototype.type=Blockly.Events.CREATE;Blockly.Events.Delete=function(a){if(a.getParent())throw"Connected blocks cannot be deleted.";Blockly.Events.Delete.superClass_.constructor.call(this,a.workspace);this.blockId=a.id;this.oldXml=Blockly.Xml.blockToDomWithXY(a)};goog.inherits(Blockly.Events.Delete,Blockly.Events.Abstract);Blockly.Events.Delete.prototype.type=Blockly.Events.DELETE;
Blockly.Events.Change=function(a,b,c,d,e){Blockly.Events.Change.superClass_.constructor.call(this,a.workspace);this.blockId=a.id;this.element=b;this.name=c;this.oldValue=d;this.newValue=e};goog.inherits(Blockly.Events.Change,Blockly.Events.Abstract);Blockly.Events.Change.prototype.type=Blockly.Events.CHANGE;Blockly.Events.Change.prototype.isNull=function(){return this.oldValue==this.newValue};
Blockly.Events.Move=function(a){Blockly.Events.Move.superClass_.constructor.call(this,a.workspace);this.blockId=a.id;a=this.currentLocation_();this.oldParentId=a.parentId;this.oldInputName=a.inputName;this.oldCoordinate=a.coordinate};goog.inherits(Blockly.Events.Move,Blockly.Events.Abstract);Blockly.Events.Move.prototype.type=Blockly.Events.MOVE;
Blockly.Events.Move.prototype.recordNew=function(){var a=this.currentLocation_();this.newParentId=a.parentId;this.newInputName=a.inputName;this.newCoordinate=a.coordinate};Blockly.Events.Move.prototype.currentLocation_=function(){var a=Blockly.Block.getById(this.blockId),b={},c=a.getParent();if(c){if(b.parentId=c.id,a=c.getInputWithBlock(a))b.inputName=a.name}else b.coordinate=a.getRelativeToSurfaceXY();return b};
Blockly.Events.Move.prototype.isNull=function(){return this.oldParentId==this.newParentId&&this.oldInputName==this.newInputName&&goog.math.Coordinate.equals(this.oldCoordinate,this.newCoordinate)};Blockly.Msg={};goog.getMsgOrig=goog.getMsg;goog.getMsg=function(a,b){var c=goog.getMsg.blocklyMsgMap[a];c&&(a=Blockly.Msg[c]);return goog.getMsgOrig(a,b)};goog.getMsg.blocklyMsgMap={Today:"TODAY"};Blockly.FieldTextInput=function(a,b){Blockly.FieldTextInput.superClass_.constructor.call(this,a,b)};goog.inherits(Blockly.FieldTextInput,Blockly.Field);Blockly.FieldTextInput.FONTSIZE=11;Blockly.FieldTextInput.prototype.CURSOR="text";Blockly.FieldTextInput.prototype.spellcheck_=!0;Blockly.FieldTextInput.prototype.dispose=function(){Blockly.WidgetDiv.hideIfOwner(this);Blockly.FieldTextInput.superClass_.dispose.call(this)};
Blockly.FieldTextInput.prototype.setValue=function(a){if(null!==a){if(this.sourceBlock_&&this.validator_){var b=this.validator_(a);null!==b&&void 0!==b&&(a=b)}Blockly.Field.prototype.setValue.call(this,a)}};Blockly.FieldTextInput.prototype.setSpellcheck=function(a){this.spellcheck_=a};

View File

@@ -332,7 +332,7 @@ Blockly.Block.prototype.getParent = function() {
/**
* Return the input that connects to the specified block.
* @param {!Blockly.Block} A block connected to an input on this block.
* @param {!Blockly.Block} block A block connected to an input on this block.
* @return {Blockly.Input} The input that connects to the specified block.
*/
Blockly.Block.prototype.getInputWithBlock = function(block) {
@@ -511,9 +511,18 @@ Blockly.Block.prototype.setShadow = function(shadow) {
}
this.isShadow_ = shadow;
if (Blockly.Events.isEnabled() && !shadow) {
Blockly.Events.group = Blockly.genUid();
// Fire a creation event.
var xmlBlock = Blockly.Xml.blockToDom(this);
Blockly.Events.fire(new Blockly.Events.Create(this.workspace, xmlBlock));
var moveEvent = new Blockly.Events.Move(this);
// Claim that the block was at 0,0 and is being connected.
moveEvent.oldParentId = undefined;
moveEvent.oldInputName = undefined;
moveEvent.oldCoordinate = new goog.math.Coordinate(0, 0);
moveEvent.recordNew();
Blockly.Events.fire(moveEvent);
Blockly.Events.group = '';
}
};

View File

@@ -460,6 +460,7 @@ Blockly.BlockSvg.prototype.onMouseDown_ = function(e) {
// dragged instead.
return;
} else {
Blockly.Events.group = Blockly.genUid();
// Left-click (or middle click)
Blockly.removeAllRanges();
Blockly.Css.setCursor(Blockly.Css.Cursor.CLOSED);
@@ -528,6 +529,7 @@ Blockly.BlockSvg.prototype.onMouseUp_ = function(e) {
Blockly.highlightedConnection_ = null;
}
Blockly.Css.setCursor(Blockly.Css.Cursor.OPEN);
Blockly.Events.group = '';
};
/**
@@ -836,7 +838,7 @@ Blockly.BlockSvg.prototype.setMovable = function(movable) {
/**
* Set whether this block is editable or not.
* @param {boolean} movable True if editable.
* @param {boolean} editable True if editable.
*/
Blockly.BlockSvg.prototype.setEditable = function(editable) {
Blockly.BlockSvg.superClass_.setEditable.call(this, editable);

View File

@@ -27,6 +27,12 @@
goog.provide('Blockly.Events');
/**
* Group ID for new events. Grouped events are indivisible.
* @type {string}
*/
Blockly.Events.group = '';
/**
* Allow change events to be created and fired.
* @type {number}
@@ -159,10 +165,14 @@ Blockly.Events.isEnabled = function() {
};
/**
* Abstract class for a change event.
* Abstract class for an event.
* @param {!Blockly.Workspace} workspace The workspace.
* @constructor
*/
Blockly.Events.Abstract = function() {};
Blockly.Events.Abstract = function(workspace) {
this.workspaceId = workspace.id;
this.group = Blockly.Events.group;
};
/**
* Does this event record any change of state?
@@ -180,12 +190,17 @@ Blockly.Events.Abstract.prototype.isNull = function() {
* @constructor
*/
Blockly.Events.Create = function(workspace, xml) {
this.type = Blockly.Events.CREATE;
this.workspaceId = workspace.id;
Blockly.Events.Create.superClass_.constructor.call(this, workspace);
this.xml = xml;
};
goog.inherits(Blockly.Events.Create, Blockly.Events.Abstract);
/**
* Type of this event.
* @type {string}
*/
Blockly.Events.Create.prototype.type = Blockly.Events.CREATE;
/**
* Class for a block deletion event.
* @param {!Blockly.Block} block The deleted block.
@@ -193,18 +208,21 @@ goog.inherits(Blockly.Events.Create, Blockly.Events.Abstract);
* @constructor
*/
Blockly.Events.Delete = function(block) {
this.type = Blockly.Events.DELETE;
this.workspaceId = block.workspace.id;
this.blockId = block.id;
this.oldXml = Blockly.Xml.blockToDom(block);
var parent = block.getParent();
if (parent) {
this.oldParentId = parent.id;
this.oldInput = getInputWithBlock(block).name
if (block.getParent()) {
throw 'Connected blocks cannot be deleted.';
}
Blockly.Events.Delete.superClass_.constructor.call(this, block.workspace);
this.blockId = block.id;
this.oldXml = Blockly.Xml.blockToDomWithXY(block);
};
goog.inherits(Blockly.Events.Delete, Blockly.Events.Abstract);
/**
* Type of this event.
* @type {string}
*/
Blockly.Events.Delete.prototype.type = Blockly.Events.DELETE;
/**
* Class for a block change event.
* @param {!Blockly.Block} block The deleted block.
@@ -216,15 +234,20 @@ goog.inherits(Blockly.Events.Delete, Blockly.Events.Abstract);
* @constructor
*/
Blockly.Events.Change = function(block, element, name, oldValue, newValue) {
this.type = Blockly.Events.CHANGE;
this.workspaceId = block.workspace.id;
Blockly.Events.Change.superClass_.constructor.call(this, block.workspace);
this.blockId = block.id;
this.element = element;
this.name = name;
this.oldValue = oldValue;
this.newValue = newValue;
};
goog.inherits(Blockly.Events.Create, Blockly.Events.Abstract);
goog.inherits(Blockly.Events.Change, Blockly.Events.Abstract);
/**
* Type of this event.
* @type {string}
*/
Blockly.Events.Change.prototype.type = Blockly.Events.CHANGE;
/**
* Does this event record any change of state?
@@ -241,8 +264,7 @@ Blockly.Events.Change.prototype.isNull = function() {
* @constructor
*/
Blockly.Events.Move = function(block) {
this.type = Blockly.Events.MOVE;
this.workspaceId = block.workspace.id;
Blockly.Events.Move.superClass_.constructor.call(this, block.workspace);
this.blockId = block.id;
var location = this.currentLocation_();
@@ -252,6 +274,12 @@ Blockly.Events.Move = function(block) {
};
goog.inherits(Blockly.Events.Move, Blockly.Events.Abstract);
/**
* Type of this event.
* @type {string}
*/
Blockly.Events.Move.prototype.type = Blockly.Events.MOVE;
/**
* Record the block's new location. Called after the move.
*/

View File

@@ -576,6 +576,7 @@ Blockly.genUid = function() {
/**
* Determine if window.crypto or global.crypto exists.
* @this {Object}
* @type {=RandomSource}
* @private
*/

View File

@@ -37,20 +37,30 @@ goog.require('goog.dom');
* @return {!Element} XML document.
*/
Blockly.Xml.workspaceToDom = function(workspace) {
var xml = goog.dom.createDom('xml');
var blocks = workspace.getTopBlocks(true);
for (var i = 0, block; block = blocks[i]; i++) {
xml.appendChild(Blockly.Xml.blockToDomWithXY(block));
}
return xml;
};
/**
* Encode a block subtree as XML with XY coordinates.
* @param {!Blockly.Block} block The root block to encode.
* @return {!Element} Tree of XML elements.
*/
Blockly.Xml.blockToDomWithXY = function(block) {
var width; // Not used in LTR.
if (workspace.RTL) {
width = workspace.getWidth();
}
var xml = goog.dom.createDom('xml');
var blocks = workspace.getTopBlocks(true);
for (var i = 0, block; block = blocks[i]; i++) {
var element = Blockly.Xml.blockToDom(block);
var xy = block.getRelativeToSurfaceXY();
element.setAttribute('x', Math.round(workspace.RTL ? width - xy.x : xy.x));
element.setAttribute('y', Math.round(xy.y));
xml.appendChild(element);
}
return xml;
var element = Blockly.Xml.blockToDom(block);
var xy = block.getRelativeToSurfaceXY();
element.setAttribute('x',
Math.round(block.workspace.RTL ? width - xy.x : xy.x));
element.setAttribute('y', Math.round(xy.y));
return element;
};
/**

View File

@@ -85,7 +85,7 @@
maxBlocks: 5,
toolbox: document.getElementById('toolbox')});
function onchange() {
function onchange(event) {
document.getElementById('capacity').innerHTML =
workspace.remainingCapacity();
}

View File

@@ -10,7 +10,7 @@ Blockly.Msg.ADD_COMMENT = "Şərh əlavə et";
Blockly.Msg.AUTH = "Please authorize this app to enable your work to be saved and to allow it to be shared by you."; // untranslated
Blockly.Msg.CHANGE_VALUE_TITLE = "Qiyməti dəyiş:";
Blockly.Msg.CHAT = "Chat with your collaborator by typing in this box!"; // untranslated
Blockly.Msg.CLEAN_UP = "Clean up Blocks"; // untranslated
Blockly.Msg.CLEAN_UP = "Blokları təmizlə";
Blockly.Msg.COLLAPSE_ALL = "Blokları yığ";
Blockly.Msg.COLLAPSE_BLOCK = "Bloku yığ";
Blockly.Msg.COLOUR_BLEND_COLOUR1 = "rəng 1";
@@ -19,7 +19,7 @@ Blockly.Msg.COLOUR_BLEND_HELPURL = "http://meyerweb.com/eric/tools/color-blend/"
Blockly.Msg.COLOUR_BLEND_RATIO = "nisbət";
Blockly.Msg.COLOUR_BLEND_TITLE = "qarışdır";
Blockly.Msg.COLOUR_BLEND_TOOLTIP = "İki rəngi verilmiş nisbətdə (0,0 - 1,0) qarışdırır.";
Blockly.Msg.COLOUR_PICKER_HELPURL = "https://en.wikipedia.org/wiki/Color"; // untranslated
Blockly.Msg.COLOUR_PICKER_HELPURL = "https://az.wikipedia.org/wiki/Rəng";
Blockly.Msg.COLOUR_PICKER_TOOLTIP = "Palitradan bir rəng seçin.";
Blockly.Msg.COLOUR_RANDOM_HELPURL = "http://randomcolour.com"; // untranslated
Blockly.Msg.COLOUR_RANDOM_TITLE = "təsadüfi rəng";
@@ -28,7 +28,7 @@ Blockly.Msg.COLOUR_RGB_BLUE = "mavi";
Blockly.Msg.COLOUR_RGB_GREEN = "yaşıl";
Blockly.Msg.COLOUR_RGB_HELPURL = "http://www.december.com/html/spec/colorper.html";
Blockly.Msg.COLOUR_RGB_RED = "qırmızı";
Blockly.Msg.COLOUR_RGB_TITLE = "rəngin komponentləri:";
Blockly.Msg.COLOUR_RGB_TITLE = "rəng";
Blockly.Msg.COLOUR_RGB_TOOLTIP = "Qırmızı, yaşıl və mavinin göstərilən miqdarı ilə bir rəng düzəlt. Bütün qiymətlər 0 ilə 100 arasında olmalıdır.";
Blockly.Msg.CONTROLS_FLOW_STATEMENTS_HELPURL = "https://github.com/google/blockly/wiki/Loops#loop-termination-blocks"; // untranslated
Blockly.Msg.CONTROLS_FLOW_STATEMENTS_OPERATOR_BREAK = "dövrdən çıx";
@@ -53,7 +53,7 @@ Blockly.Msg.CONTROLS_IF_TOOLTIP_1 = "Əgər qiymət doğrudursa, onda bəzi əmr
Blockly.Msg.CONTROLS_IF_TOOLTIP_2 = "Əgər qiymət doğrudursa, onda birinci əmrlər blokunu yerinə yetir. Əks halda isə ikinci əmrlər blokunu yerinə yetir.";
Blockly.Msg.CONTROLS_IF_TOOLTIP_3 = "Əgər birinci qiymət doğrudursa, onda birinci əmrlər blokunu yerinə yetir. Əks halda əgər ikinci qiymət doğrudursa, onda ikinci əmrlər blokunu yerinə yetir.";
Blockly.Msg.CONTROLS_IF_TOOLTIP_4 = "Əgər birinci qiymət doğrudursa, onda birinci əmrlər blokunu yerinə yetir. Əks halda əgər ikinci qiymət doğrudursa, onda ikinci əmrlər blokunu yerinə yetir. Əgər qiymətlərdən heç biri doğru deyilsə, onda axırıncı əmrlər blokunu yerinə yetir.";
Blockly.Msg.CONTROLS_REPEAT_HELPURL = "https://en.wikipedia.org/wiki/For_loop"; // untranslated
Blockly.Msg.CONTROLS_REPEAT_HELPURL = "https://az.wikipedia.org/wiki/For_loop";
Blockly.Msg.CONTROLS_REPEAT_INPUT_DO = "icra et";
Blockly.Msg.CONTROLS_REPEAT_TITLE = "%1 dəfə təkrar et";
Blockly.Msg.CONTROLS_REPEAT_TOOLTIP = "Bəzi əmrləri bir neçə dəfə yerinə yetir.";
@@ -62,7 +62,7 @@ Blockly.Msg.CONTROLS_WHILEUNTIL_OPERATOR_UNTIL = "təkrar et, ta ki";
Blockly.Msg.CONTROLS_WHILEUNTIL_OPERATOR_WHILE = "təkrar et, hələ ki";
Blockly.Msg.CONTROLS_WHILEUNTIL_TOOLTIP_UNTIL = "Hələ ki, qiymət \"yalan\"dır, bəzi əmrləri yerinə yetir.";
Blockly.Msg.CONTROLS_WHILEUNTIL_TOOLTIP_WHILE = "Hələ ki, qiymət \"doğru\"dur, bəzi əmrləri yerinə yetir.";
Blockly.Msg.DELETE_ALL_BLOCKS = "Delete all %1 blocks?"; // untranslated
Blockly.Msg.DELETE_ALL_BLOCKS = "Bütün %1 blok silinsin?";
Blockly.Msg.DELETE_BLOCK = "Bloku sil";
Blockly.Msg.DELETE_X_BLOCKS = "%1 bloku sil";
Blockly.Msg.DISABLE_BLOCK = "Bloku söndür";
@@ -149,11 +149,11 @@ Blockly.Msg.LISTS_SPLIT_TEXT_FROM_LIST = "make text from list"; // untranslated
Blockly.Msg.LISTS_SPLIT_TOOLTIP_JOIN = "Join a list of texts into one text, separated by a delimiter."; // untranslated
Blockly.Msg.LISTS_SPLIT_TOOLTIP_SPLIT = "Split text into a list of texts, breaking at each delimiter."; // untranslated
Blockly.Msg.LISTS_SPLIT_WITH_DELIMITER = "with delimiter"; // untranslated
Blockly.Msg.LOGIC_BOOLEAN_FALSE = "yalan";
Blockly.Msg.LOGIC_BOOLEAN_FALSE = "səhf";
Blockly.Msg.LOGIC_BOOLEAN_HELPURL = "https://github.com/google/blockly/wiki/Logic#values"; // untranslated
Blockly.Msg.LOGIC_BOOLEAN_TOOLTIP = "\"doğru\" və ya \"yalan\" cavanını qaytarır.";
Blockly.Msg.LOGIC_BOOLEAN_TOOLTIP = "\"doğru\" və ya \"səhf\" cavanını qaytarır.";
Blockly.Msg.LOGIC_BOOLEAN_TRUE = "doğru";
Blockly.Msg.LOGIC_COMPARE_HELPURL = "https://en.wikipedia.org/wiki/Inequality_(mathematics)"; // untranslated
Blockly.Msg.LOGIC_COMPARE_HELPURL = "https://az.wikipedia.org/wiki/bərabərsizlik_(riyazi)";
Blockly.Msg.LOGIC_COMPARE_TOOLTIP_EQ = "Girişlər bir birinə bərabərdirsə \"doğru\" cavabını qaytarır.";
Blockly.Msg.LOGIC_COMPARE_TOOLTIP_GT = "Birinci giriş ikincidən böyükdürsə \"doğru\" cavabını qaytarır.";
Blockly.Msg.LOGIC_COMPARE_TOOLTIP_GTE = "Birinci giriş ikincidən böyük və ya bərarbərdirsə \"doğru\" cavabını qaytarır.";
@@ -162,7 +162,7 @@ Blockly.Msg.LOGIC_COMPARE_TOOLTIP_LTE = "Birinci giriş ikincidən kiçik və ya
Blockly.Msg.LOGIC_COMPARE_TOOLTIP_NEQ = "Girişlər bərabər deyillərsə \"doğru\" cavabını qaytarır.";
Blockly.Msg.LOGIC_NEGATE_HELPURL = "https://github.com/google/blockly/wiki/Logic#not"; // untranslated
Blockly.Msg.LOGIC_NEGATE_TITLE = "%1 deyil";
Blockly.Msg.LOGIC_NEGATE_TOOLTIP = "Giriş \"yalan\"-dursa \"doğru\" cavabını qaytarır. Giriş \"doğru\"-dursa \"yalan\" cavabını qaytarır.";
Blockly.Msg.LOGIC_NEGATE_TOOLTIP = "Giriş \"yalan\"-dursa \"doğru\" cavabını qaytarır. Giriş \"doğru\"-dursa \"səhf\" cavabını qaytarır.";
Blockly.Msg.LOGIC_NULL = "boş";
Blockly.Msg.LOGIC_NULL_HELPURL = "https://en.wikipedia.org/wiki/Nullable_type"; // untranslated
Blockly.Msg.LOGIC_NULL_TOOLTIP = "Boş cavab qaytarır.";
@@ -173,7 +173,7 @@ Blockly.Msg.LOGIC_OPERATION_TOOLTIP_AND = "Hər iki giriş \"doğru\"-dursa \"do
Blockly.Msg.LOGIC_OPERATION_TOOLTIP_OR = "Girişlərdən heç olmasa biri \"doğru\"-dursa \"doğru\" cavabını qaytarır.";
Blockly.Msg.LOGIC_TERNARY_CONDITION = "test";
Blockly.Msg.LOGIC_TERNARY_HELPURL = "https://en.wikipedia.org/wiki/%3F:"; // untranslated
Blockly.Msg.LOGIC_TERNARY_IF_FALSE = "əgər yalandırsa";
Blockly.Msg.LOGIC_TERNARY_IF_FALSE = "əgər səhfdirsə";
Blockly.Msg.LOGIC_TERNARY_IF_TRUE = "əgər doğrudursa";
Blockly.Msg.LOGIC_TERNARY_TOOLTIP = "'Yoxla' əmrindəki şərtə nəzər yetirin. Əgər şərt \"doğru\"-dursa \"əgər doğru\", əks halda isə \"əgər yalan\" cavabını qaytarır.";
Blockly.Msg.MATH_ADDITION_SYMBOL = "+";
@@ -186,7 +186,7 @@ Blockly.Msg.MATH_ARITHMETIC_TOOLTIP_POWER = "Birinci ədədin ikinci ədəd dər
Blockly.Msg.MATH_CHANGE_HELPURL = "https://en.wikipedia.org/wiki/Programming_idiom#Incrementing_a_counter"; // untranslated
Blockly.Msg.MATH_CHANGE_TITLE = "dəyiş: %1 buna: %2";
Blockly.Msg.MATH_CHANGE_TOOLTIP = "'%1' dəyişəninin üzərinə bir ədəd artır.";
Blockly.Msg.MATH_CONSTANT_HELPURL = "https://en.wikipedia.org/wiki/Mathematical_constant"; // untranslated
Blockly.Msg.MATH_CONSTANT_HELPURL = "https://az.wikipedia.org/wiki/Riyazi_sabitlər";
Blockly.Msg.MATH_CONSTANT_TOOLTIP = "Ümumi sabitlərdən birini qaytarır π (3.141…), e (2.718…), φ (1.618…), sqrt(2) (1.414…), sqrt(½) (0.707…), və ya ∞ (sonsuzluq).";
Blockly.Msg.MATH_CONSTRAIN_HELPURL = "https://en.wikipedia.org/wiki/Clamping_%28graphics%29"; // untranslated
Blockly.Msg.MATH_CONSTRAIN_TITLE = "%1 üçün ən aşağı %2, ən yuxarı %3 olmağı tələb et";
@@ -204,7 +204,7 @@ Blockly.Msg.MATH_MODULO_HELPURL = "https://en.wikipedia.org/wiki/Modulo_operatio
Blockly.Msg.MATH_MODULO_TITLE = "%1 ÷ %2 bölməsinin qalığı";
Blockly.Msg.MATH_MODULO_TOOLTIP = "İki ədədin nisbətindən alınan qalığı qaytarır.";
Blockly.Msg.MATH_MULTIPLICATION_SYMBOL = "×";
Blockly.Msg.MATH_NUMBER_HELPURL = "https://en.wikipedia.org/wiki/Number"; // untranslated
Blockly.Msg.MATH_NUMBER_HELPURL = "https://az.wikipedia.org/wiki/Ədəd";
Blockly.Msg.MATH_NUMBER_TOOLTIP = "Ədəd.";
Blockly.Msg.MATH_ONLIST_HELPURL = ""; // untranslated
Blockly.Msg.MATH_ONLIST_OPERATOR_AVERAGE = "siyahının ədədi ortası";
@@ -235,7 +235,7 @@ Blockly.Msg.MATH_ROUND_OPERATOR_ROUND = "yuvarlaqlaşdır";
Blockly.Msg.MATH_ROUND_OPERATOR_ROUNDDOWN = "aşağı yuvarlaqlaşdır";
Blockly.Msg.MATH_ROUND_OPERATOR_ROUNDUP = "yuxarı yuvarlaqlaşdır";
Blockly.Msg.MATH_ROUND_TOOLTIP = "Ədədi aşağı və ya yuxari yuvarlaqşdır.";
Blockly.Msg.MATH_SINGLE_HELPURL = "https://en.wikipedia.org/wiki/Square_root"; // untranslated
Blockly.Msg.MATH_SINGLE_HELPURL = "https://az.wikipedia.org/wiki/Kvadrat_kökləri";
Blockly.Msg.MATH_SINGLE_OP_ABSOLUTE = "modul";
Blockly.Msg.MATH_SINGLE_OP_ROOT = "kvadrat kök";
Blockly.Msg.MATH_SINGLE_TOOLTIP_ABS = "Ədədin modulunu qaytarır.";
@@ -250,7 +250,7 @@ Blockly.Msg.MATH_TRIG_ACOS = "arccos";
Blockly.Msg.MATH_TRIG_ASIN = "arcsin";
Blockly.Msg.MATH_TRIG_ATAN = "arctan";
Blockly.Msg.MATH_TRIG_COS = "cos";
Blockly.Msg.MATH_TRIG_HELPURL = "https://en.wikipedia.org/wiki/Trigonometric_functions"; // untranslated
Blockly.Msg.MATH_TRIG_HELPURL = "https://az.wikipedia.org/wiki/Triqonometrik_funksiyalar";
Blockly.Msg.MATH_TRIG_SIN = "sin";
Blockly.Msg.MATH_TRIG_TAN = "tg";
Blockly.Msg.MATH_TRIG_TOOLTIP_ACOS = "Ədədin arccosinusunu qaytarır.";
@@ -259,7 +259,7 @@ Blockly.Msg.MATH_TRIG_TOOLTIP_ATAN = "Ədədin arctanqensini qaytarır.";
Blockly.Msg.MATH_TRIG_TOOLTIP_COS = "Dərəcənin kosinusunu qaytarır (radianın yox).";
Blockly.Msg.MATH_TRIG_TOOLTIP_SIN = "Dərəcənin sinusunu qaytar (radianın yox).";
Blockly.Msg.MATH_TRIG_TOOLTIP_TAN = "Dərəcənin tangensini qaytar (radianın yox).";
Blockly.Msg.ME = "Me"; // untranslated
Blockly.Msg.ME = "Mənə";
Blockly.Msg.NEW_VARIABLE = "Yeni dəyişən...";
Blockly.Msg.NEW_VARIABLE_TITLE = "Yeni dəyişənin adı:";
Blockly.Msg.ORDINAL_NUMBER_SUFFIX = ""; // untranslated
@@ -353,7 +353,7 @@ Blockly.Msg.TEXT_TRIM_OPERATOR_BOTH = "Boşluqları hər iki tərəfdən pozun";
Blockly.Msg.TEXT_TRIM_OPERATOR_LEFT = "Boşluqlari yalnız sol tərəfdən pozun";
Blockly.Msg.TEXT_TRIM_OPERATOR_RIGHT = "Boşluqları yalnız sağ tərəfdən pozun";
Blockly.Msg.TEXT_TRIM_TOOLTIP = "Mətnin hər iki və ya yalnız bir tərəfdən olan boşluqları pozulmuş surətini qaytarın.";
Blockly.Msg.TODAY = "Today"; // untranslated
Blockly.Msg.TODAY = "Bugün";
Blockly.Msg.VARIABLES_DEFAULT_NAME = "element";
Blockly.Msg.VARIABLES_GET_CREATE_SET = "'%1 - i təyin et' - i yarat";
Blockly.Msg.VARIABLES_GET_HELPURL = "https://github.com/google/blockly/wiki/Variables#get"; // untranslated

View File

@@ -81,6 +81,15 @@ function start() {
scaleSpeed: 1.1
},
});
// Restore previously displayed text.
var text = sessionStorage.getItem('textarea');
if (text) {
document.getElementById('importExport').value = text;
}
taChange();
// Restore event logging state.
var state = sessionStorage.getItem('logEvents');
logEvents(Boolean(state));
}
function toXml() {
@@ -89,17 +98,49 @@ function toXml() {
output.value = Blockly.Xml.domToPrettyText(xml);
output.focus();
output.select();
taChange();
}
function fromXml() {
var input = document.getElementById('importExport');
var xml = Blockly.Xml.textToDom(input.value);
Blockly.Xml.domToWorkspace(workspace, xml);
taChange();
}
function toCode(lang) {
var output = document.getElementById('importExport');
output.value = Blockly[lang].workspaceToCode(workspace);
taChange();
}
// Disable the "Import from XML" button if the XML is invalid.
// Preserve text between page reloads.
function taChange() {
var textarea = document.getElementById('importExport');
sessionStorage.setItem('textarea', textarea.value)
var valid = true;
try {
Blockly.Xml.textToDom(textarea.value);
} catch (e) {
valid = false;
}
document.getElementById('import').disabled = !valid;
}
function logEvents(state) {
var checkbox = document.getElementById('logCheck');
checkbox.checked = state;
sessionStorage.setItem('logEvents', Number(state));
if (state) {
workspace.addChangeListener(logger);
} else {
workspace.removeChangeListener(logger);
}
}
function logger(e) {
console.log(e);
}
function airstrike(n) {
@@ -526,7 +567,7 @@ h1 {
<p>
<input type="button" value="Export to XML" onclick="toXml()">
&nbsp;
<input type="button" value="Import from XML" onclick="fromXml()">
<input type="button" value="Import from XML" onclick="fromXml()" id="import">
<br>
<input type="button" value="To JavaScript" onclick="toCode('JavaScript')">
&nbsp;
@@ -536,15 +577,19 @@ h1 {
&nbsp;
<input type="button" value="To Dart" onclick="toCode('Dart')">
<br>
<textarea id="importExport" style="width: 26%; height: 12em"></textarea>
<textarea id="importExport" style="width: 26%; height: 12em"
onchange="taChange();" onkeyup="taChange()"></textarea>
</p>
<hr>
<p>
Stress test:
Stress test: &nbsp;
<input type="button" value="Airstrike!" onclick="airstrike(100)">
<input type="button" value="Spaghetti!" onclick="spaghetti(8)">
</p>
<p>
Log events: &nbsp;
<input type="checkbox" onclick="logEvents(this.checked)" id="logCheck">
</p>
</body>
</html>