Merge branch 'develop' into feature/drag-surface

# Conflicts:
#	core/block_svg.js
This commit is contained in:
Tim Mickel 2016-04-08 14:41:45 -04:00
commit 15ed57e7aa
40 changed files with 909 additions and 484 deletions

3
.eslintignore Normal file
View file

@ -0,0 +1,3 @@
*_compressed_*.js
*_uncompressed_*.js
/msg/*

25
.eslintrc Normal file
View file

@ -0,0 +1,25 @@
{
"rules": {
"curly": [2, "multi-line"],
"eol-last": [2],
"indent": [2, 2, {"SwitchCase": 1}], # Blockly/Google use 2-space indents
"linebreak-style": [2, "unix"],
"max-len": [2, 120, 4],
"no-trailing-spaces": [2, { "skipBlankLines": true }],
"no-unused-vars": [2, {"args": "after-used", "varsIgnorePattern": "^_"}],
"quotes": [0], # Blockly mixes single and double quotes
"semi": [2, "always"],
"space-before-function-paren": [2, "never"], # Blockly doesn't have space before function paren
"strict": [0], # Blockly uses 'use strict' in files
"no-cond-assign": [0], # Blockly often uses cond-assignment in loops
"valid-jsdoc": [2, {"requireReturn": false}]
},
"env": {
"browser": true
},
"globals": {
"Blockly": true, # Blockly global
"goog": true # goog closure libraries/includes
},
"extends": "eslint:recommended"
}

View file

@ -1,23 +1,3 @@
/**
* @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 Control blocks for Scratch (Horizontal)
* @author ascii@media.mit.edu <Andrew Sliwinski>
@ -47,7 +27,7 @@ Blockly.Blocks['control_repeat'] = {
},
{
"type": "field_image",
"src": Blockly.mainWorkspace.options.pathToMedia + "icons/control_forever.svg",
"src": Blockly.mainWorkspace.options.pathToMedia + "icons/control_repeat.svg",
"width": 40,
"height": 40,
"alt": "*",
@ -65,12 +45,6 @@ Blockly.Blocks['control_repeat'] = {
"colour": Blockly.Colours.control.primary,
"colourSecondary": Blockly.Colours.control.secondary,
"colourTertiary": Blockly.Colours.control.tertiary,
"tooltip": "",
"helpUrl": "http://www.example.com/"
});
this.setHelpUrl(function () {
return 'halp me plz. k thx bye.';
});
}
};
@ -103,12 +77,107 @@ Blockly.Blocks['control_forever'] = {
"previousStatement": null,
"colour": Blockly.Colours.control.primary,
"colourSecondary": Blockly.Colours.control.secondary,
"colourTertiary": Blockly.Colours.control.tertiary,
"tooltip": ""
});
this.setHelpUrl(function () {
return 'halp me plz. k thx bye.';
"colourTertiary": Blockly.Colours.control.tertiary
});
}
};
Blockly.Blocks['control_repeat'] = {
/**
* Block for repeat n times (external number).
* https://blockly-demo.appspot.com/static/demos/blockfactory/index.html#so57n9
* @this Blockly.Block
*/
init: function() {
this.jsonInit({
"id": "control_repeat",
"message0": "%1 %2 %3",
"args0": [
{
"type": "input_statement",
"name": "SUBSTACK"
},
{
"type": "field_image",
"src": Blockly.mainWorkspace.options.pathToMedia + "icons/control_repeat.svg",
"width": 40,
"height": 40,
"alt": "*",
"flip_rtl": true
},
{
"type": "input_value",
"name": "TIMES",
"check": "Number"
}
],
"inputsInline": true,
"previousStatement": null,
"nextStatement": null,
"colour": Blockly.Colours.control.primary,
"colourSecondary": Blockly.Colours.control.secondary,
"colourTertiary": Blockly.Colours.control.tertiary,
});
}
};
Blockly.Blocks['control_stop'] = {
/**
* Block for stop all scripts.
* @this Blockly.Block
*/
init: function() {
this.jsonInit({
"id": "control_stop",
"message0": "%1",
"args0": [
{
"type": "field_image",
"src": Blockly.mainWorkspace.options.pathToMedia + "icons/control_stop.svg",
"width": 40,
"height": 40,
"alt": "Stop"
}
],
"inputsInline": true,
"previousStatement": null,
"nextStatement": null,
"colour": Blockly.Colours.control.primary,
"colourSecondary": Blockly.Colours.control.secondary,
"colourTertiary": Blockly.Colours.control.tertiary
});
}
};
Blockly.Blocks['control_wait'] = {
/**
* Block to wait (pause) stack.
* @this Blockly.Block
*/
init: function() {
this.jsonInit({
"id": "control_wait",
"message0": "%1 %2",
"args0": [
{
"type": "field_image",
"src": Blockly.mainWorkspace.options.pathToMedia + "icons/control_wait.svg",
"width": 40,
"height": 40,
"alt": "Wait"
},
{
"type": "input_value",
"name": "DURATION",
"check": "Number"
}
],
"inputsInline": true,
"previousStatement": null,
"nextStatement": null,
"colour": Blockly.Colours.control.primary,
"colourSecondary": Blockly.Colours.control.secondary,
"colourTertiary": Blockly.Colours.control.tertiary
});
}
};

View file

@ -1,23 +1,3 @@
/**
* @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 Control blocks for Scratch (Horizontal)
* @author ascii@media.mit.edu <Andrew Sliwinski>
@ -32,7 +12,7 @@ goog.require('Blockly.Colours');
Blockly.Blocks['event_whenflagclicked'] = {
/**
* Block for repeat n times (external number).
* Block for when flag clicked.
* @this Blockly.Block
*/
init: function() {
@ -53,12 +33,63 @@ Blockly.Blocks['event_whenflagclicked'] = {
"nextStatement": null,
"colour": Blockly.Colours.event.primary,
"colourSecondary": Blockly.Colours.event.secondary,
"colourTertiary": Blockly.Colours.event.tertiary,
"tooltip": "Do stuff!"
});
this.setHelpUrl(function () {
return 'halp me plz. k thx bye.';
"colourTertiary": Blockly.Colours.event.tertiary
});
}
};
Blockly.Blocks['event_whenbroadcastreceived'] = {
/**
* Block for when broadcast received.
* @this Blockly.Block
*/
init: function() {
this.jsonInit({
"id": "event_whenbroadcastreceived",
"message0": "%1",
"args0": [
{
"type": "field_image",
"src": Blockly.mainWorkspace.options.pathToMedia + "icons/event_whenbroadcastreceived.svg",
"width": 40,
"height": 40,
"alt": "flag",
"flip_rtl": true
}
],
"inputsInline": true,
"nextStatement": null,
"colour": Blockly.Colours.event.primary,
"colourSecondary": Blockly.Colours.event.secondary,
"colourTertiary": Blockly.Colours.event.tertiary
});
}
};
Blockly.Blocks['event_broadcast'] = {
/**
* Block to send a broadcast.
* @this Blockly.Block
*/
init: function() {
this.jsonInit({
"id": "event_broadcast",
"message0": "%1",
"args0": [
{
"type": "field_image",
"src": Blockly.mainWorkspace.options.pathToMedia + "icons/event_broadcast.svg",
"width": 40,
"height": 40,
"alt": "Broadcast"
}
],
"inputsInline": true,
"previousStatement": null,
"nextStatement": null,
"colour": Blockly.Colours.event.primary,
"colourSecondary": Blockly.Colours.event.secondary,
"colourTertiary": Blockly.Colours.event.tertiary
});
}
};

View file

@ -1,69 +0,0 @@
/**
* @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');
goog.require('Blockly.Colours');
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": "String"
}
],
"inputsInline": true,
"previousStatement": null,
"nextStatement": null,
"colour": Blockly.Colours.looks.primary,
"colourSecondary": Blockly.Colours.looks.secondary,
"colourTertiary": Blockly.Colours.looks.tertiary,
"tooltip": ""
});
this.setHelpUrl(function () {
return 'halp me plz. k thx bye.';
});
}
};

View file

@ -1,64 +0,0 @@
/**
* @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 Control blocks for Scratch (Horizontal)
* @author ascii@media.mit.edu <Andrew Sliwinski>
*/
'use strict';
goog.provide('Blockly.Blocks.motion');
goog.require('Blockly.Blocks');
goog.require('Blockly.Colours');
Blockly.Blocks['motion_moveright'] = {
/**
* Block for move right (external number)
* https://blockly-demo.appspot.com/static/demos/blockfactory/index.html#ed5ch5
* @this Blockly.Block
*/
init: function() {
this.jsonInit({
"id": "motion_moveright",
"message0": "%1",
"args0": [
{
"type": "field_image",
"src": Blockly.mainWorkspace.options.pathToMedia + "icons/motion_moveright.svg",
"width": 40,
"height": 40,
"alt": "*"
}
],
"previousStatement": null,
"nextStatement": null,
"colour": Blockly.Colours.motion.primary,
"colourSecondary": Blockly.Colours.motion.secondary,
"colourTertiary": Blockly.Colours.motion.tertiary,
"tooltip": ""
});
this.setHelpUrl(function () {
return 'halp me plz. k thx bye.';
});
}
};

187
blocks_horizontal/wedo.js Normal file
View file

@ -0,0 +1,187 @@
/**
* @fileoverview Wedo blocks for Scratch (Horizontal)
* @author ascii@media.mit.edu <Andrew Sliwinski>
*/
'use strict';
goog.provide('Blockly.Blocks.wedo');
goog.require('Blockly.Blocks');
goog.require('Blockly.Colours');
Blockly.Blocks['wedo_setcolor'] = {
/**
* Block to set color of LED
* @this Blockly.Block
*/
init: function() {
this.jsonInit({
"id": "wedo_setcolor",
"message0": "%1",
"args0": [
{
"type": "field_image",
"src": Blockly.mainWorkspace.options.pathToMedia + "icons/wedo_setcolor.svg",
"width": 40,
"height": 40,
"alt": "Set Color"
}
],
"inputsInline": true,
"previousStatement": null,
"nextStatement": null,
"colour": Blockly.Colours.looks.primary,
"colourSecondary": Blockly.Colours.looks.secondary,
"colourTertiary": Blockly.Colours.looks.tertiary
});
}
};
Blockly.Blocks['wedo_motorclockwise'] = {
/**
* Block to spin motor clockwise.
* @this Blockly.Block
*/
init: function() {
this.jsonInit({
"id": "wedo_motorclockwise",
"message0": "%1 %2",
"args0": [
{
"type": "field_image",
"src": Blockly.mainWorkspace.options.pathToMedia + "icons/wedo_motorclockwise.svg",
"width": 40,
"height": 40,
"alt": "Motor Clockwise"
},
{
"type": "input_value",
"name": "DURATION",
"check": "Number"
}
],
"inputsInline": true,
"previousStatement": null,
"nextStatement": null,
"colour": Blockly.Colours.motion.primary,
"colourSecondary": Blockly.Colours.motion.secondary,
"colourTertiary": Blockly.Colours.motion.tertiary
});
}
};
Blockly.Blocks['wedo_motorcounterclockwise'] = {
/**
* Block to spin motor counter-clockwise.
* @this Blockly.Block
*/
init: function() {
this.jsonInit({
"id": "wedo_motorcounterclockwise",
"message0": "%1 %2",
"args0": [
{
"type": "field_image",
"src": Blockly.mainWorkspace.options.pathToMedia + "icons/wedo_motorcounterclockwise.svg",
"width": 40,
"height": 40,
"alt": "Motor Counter-Clockwise"
},
{
"type": "input_value",
"name": "DURATION",
"check": "Number"
}
],
"inputsInline": true,
"previousStatement": null,
"nextStatement": null,
"colour": Blockly.Colours.motion.primary,
"colourSecondary": Blockly.Colours.motion.secondary,
"colourTertiary": Blockly.Colours.motion.tertiary
});
}
};
Blockly.Blocks['wedo_motorspeed'] = {
/**
* Block to set motor speed.
* @this Blockly.Block
*/
init: function() {
this.jsonInit({
"id": "wedo_motorspeed",
"message0": "%1",
"args0": [
{
"type": "field_image",
"src": Blockly.mainWorkspace.options.pathToMedia + "icons/wedo_motorspeed.svg",
"width": 40,
"height": 40,
"alt": "Motor Speed"
}
],
"inputsInline": true,
"previousStatement": null,
"nextStatement": null,
"colour": Blockly.Colours.motion.primary,
"colourSecondary": Blockly.Colours.motion.secondary,
"colourTertiary": Blockly.Colours.motion.tertiary
});
}
};
Blockly.Blocks['wedo_whentilt'] = {
/**
* Block for when tilted.
* @this Blockly.Block
*/
init: function() {
this.jsonInit({
"id": "wedo_whentilt",
"message0": "%1",
"args0": [
{
"type": "field_image",
"src": Blockly.mainWorkspace.options.pathToMedia + "icons/wedo_whentilt.svg",
"width": 40,
"height": 40,
"alt": "When Tilted"
}
],
"inputsInline": true,
"nextStatement": null,
"colour": Blockly.Colours.event.primary,
"colourSecondary": Blockly.Colours.event.secondary,
"colourTertiary": Blockly.Colours.event.tertiary
});
}
};
Blockly.Blocks['wedo_whendistanceclose'] = {
/**
* Block for when distance sensor is close.
* @this Blockly.Block
*/
init: function() {
this.jsonInit({
"id": "wedo_whendistanceclose",
"message0": "%1",
"args0": [
{
"type": "field_image",
"src": Blockly.mainWorkspace.options.pathToMedia + "icons/wedo_whendistanceclose.svg",
"width": 40,
"height": 40,
"alt": "When Distance Close"
}
],
"inputsInline": true,
"nextStatement": null,
"colour": Blockly.Colours.event.primary,
"colourSecondary": Blockly.Colours.event.secondary,
"colourTertiary": Blockly.Colours.event.tertiary
});
}
};

View file

@ -100,10 +100,8 @@ Blockly.Block = function(workspace, prototypeName, opt_id) {
/** @type {boolean} */
this.RTL = workspace.RTL;
/** @type {Blockly.Block} */
this.ghostBlock_ = null;
/** @type {boolean} */
this.isGhost_ = false;
this.isInsertionMarker_ = false;
// Copy the type-specific functions and data from the prototype.
if (prototypeName) {
@ -208,10 +206,6 @@ Blockly.Block.prototype.dispose = function(healStack) {
Blockly.selected = null;
}
if (this.ghostBlock_) {
this.ghostBlock_.dispose();
}
// First, dispose of all my children.
for (var i = this.childBlocks_.length - 1; i >= 0; i--) {
this.childBlocks_[i].dispose(false);
@ -553,23 +547,23 @@ Blockly.Block.prototype.setShadow = function(shadow) {
};
/**
* Get whether this block is a ghost block or not.
* @return {boolean} True if a ghost.
* Get whether this block is an insertion marker block or not.
* @return {boolean} True if an insertion marker.
*/
Blockly.Block.prototype.isGhost = function() {
return this.isGhost_;
Blockly.Block.prototype.isInsertionMarker = function() {
return this.isInsertionMarker_;
};
/**
* Set whether this block is a ghost block or not.
* @param {boolean} ghost True if a ghost.
* Set whether this block is an insertion marker block or not.
* @param {boolean} insertionMarker True if an insertion marker.
*/
Blockly.Block.prototype.setGhost = function(ghost) {
if (this.isGhost_ == ghost) {
Blockly.Block.prototype.setInsertionMarker = function(insertionMarker) {
if (this.isInsertionMarker_ == insertionMarker) {
return; // No change.
}
this.isGhost_ = ghost;
if (this.isGhost_) {
this.isInsertionMarker_ = insertionMarker;
if (this.isInsertionMarker_) {
this.setColour("#949494");
}
};
@ -632,7 +626,7 @@ Blockly.Block.prototype.setConnectionsHidden = function(hidden) {
/**
* Find the connection on this block that corresponds to the given connection
* on the other block.
* Used to match connections between a block and its ghost.
* Used to match connections between a block and its insertion marker.
* @param {!Blockly.Block} otherBlock The other block to match against.
* @param {!Blockly.Connection} conn The other connection to match.
* @return {Blockly.Connection} the matching connection on this block, or null.

View file

@ -51,7 +51,7 @@ Blockly.BlockSvg.SEP_SPACE_Y = 3 * Blockly.BlockSvg.GRID_UNIT;
* Vertical space above blocks with statements.
* @const
*/
Blockly.BlockSvg.STATEMENT_BLOCK_SPACE = 4 * Blockly.BlockSvg.GRID_UNIT;
Blockly.BlockSvg.STATEMENT_BLOCK_SPACE = 3 * Blockly.BlockSvg.GRID_UNIT;
/**
* Height of user inputs
@ -63,6 +63,13 @@ Blockly.BlockSvg.FIELD_HEIGHT = 8 * Blockly.BlockSvg.GRID_UNIT;
* @const
*/
Blockly.BlockSvg.FIELD_WIDTH = 12 * Blockly.BlockSvg.GRID_UNIT;
/**
* Top padding of user inputs
* @const
*/
Blockly.BlockSvg.FIELD_TOP_PADDING = 1.5 * Blockly.BlockSvg.GRID_UNIT;
/**
* Corner radius of number inputs
* @const
@ -77,7 +84,7 @@ Blockly.BlockSvg.TEXT_FIELD_CORNER_RADIUS = 1 * Blockly.BlockSvg.GRID_UNIT;
* Minimum width of a block.
* @const
*/
Blockly.BlockSvg.MIN_BLOCK_X = 16 * Blockly.BlockSvg.GRID_UNIT;
Blockly.BlockSvg.MIN_BLOCK_X = 1/2 * 16 * Blockly.BlockSvg.GRID_UNIT;
/**
* Minimum height of a block.
@ -308,11 +315,7 @@ Blockly.BlockSvg.prototype.renderCompute_ = function() {
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;
}
metrics.fieldRadius = field.getBorderRadius();
}
}
}
@ -393,7 +396,7 @@ Blockly.BlockSvg.prototype.renderDraw_ = function(metrics) {
iconX = -metrics.width + Blockly.BlockSvg.SEP_SPACE_X / 1.5;
}
}
if (this.isGhost()) {
if (this.isInsertionMarker()) {
icon.setAttribute('display', 'none');
}
icon.setAttribute('transform',

View file

@ -237,13 +237,13 @@ Blockly.BlockSvg.terminateDrag_ = function() {
if (Blockly.dragMode_ == Blockly.DRAG_FREE) {
// Terminate a drag operation.
if (selected) {
if (selected.ghostBlock_) {
if (Blockly.insertionMarker_) {
Blockly.Events.disable();
if (Blockly.localGhostConnection_) {
selected.disconnectGhost();
if (Blockly.insertionMarkerConnection_) {
Blockly.BlockSvg.disconnectInsertionMarker();
}
selected.ghostBlock_.dispose();
selected.ghostBlock_ = null;
Blockly.insertionMarker_.dispose();
Blockly.insertionMarker_ = null;
Blockly.Events.enable();
}
// Update the connection locations.
@ -309,6 +309,11 @@ Blockly.BlockSvg.prototype.setParent = function(newParent) {
var newXY = this.getRelativeToSurfaceXY();
// Move the connections to match the child's new position.
this.moveConnections_(newXY.x - oldXY.x, newXY.y - oldXY.y);
// If we are a shadow block, inherit tertiary colour.
if (this.isShadow()) {
this.setColour(this.getColour(), this.getColourSecondary(),
newParent.getColourTertiary());
}
}
};
@ -397,7 +402,8 @@ Blockly.BlockSvg.prototype.snapToGrid = function() {
/**
* Returns a bounding box describing the dimensions of this block
* and any blocks stacked below it.
* @return {!{height: number, width: number}} Object with height and width properties.
* @return {!{height: number, width: number}} Object with height and width
* properties.
*/
Blockly.BlockSvg.prototype.getHeightWidth = function() {
var height = this.height;
@ -416,10 +422,10 @@ Blockly.BlockSvg.prototype.getHeightWidth = function() {
};
/**
* Returns the coordinates of a bounding box describing the dimensions of this block
* and any blocks stacked below it.
* Returns the coordinates of a bounding box describing the dimensions of this
* block and any blocks stacked below it.
* @return {!{topLeft: goog.math.Coordinate, bottomRight: goog.math.Coordinate}}
* Object with top left and bottom right coordinates of the bounding box.
* Object with top left and bottom right coordinates of the bounding box.
*/
Blockly.BlockSvg.prototype.getBoundingRectangle = function() {
var blockXY = this.getRelativeToSurfaceXY(this);
@ -429,10 +435,12 @@ Blockly.BlockSvg.prototype.getBoundingRectangle = function() {
var bottomRight;
if (this.RTL) {
// Width has the tab built into it already so subtract it here.
topLeft = new goog.math.Coordinate(blockXY.x - (blockBounds.width - tab), blockXY.y);
topLeft = new goog.math.Coordinate(blockXY.x - (blockBounds.width - tab),
blockXY.y);
// Add the width of the tab/puzzle piece knob to the x coordinate
// since X is the corner of the rectangle, not the whole puzzle piece.
bottomRight = new goog.math.Coordinate(blockXY.x + tab, blockXY.y + blockBounds.height);
bottomRight = new goog.math.Coordinate(blockXY.x + tab,
blockXY.y + blockBounds.height);
} else {
// Subtract the width of the tab/puzzle piece knob to the x coordinate
// since X is the corner of the rectangle, not the whole puzzle piece.
@ -605,7 +613,17 @@ Blockly.BlockSvg.prototype.onMouseUp_ = function(e) {
Blockly.setPageSelectable(true);
Blockly.terminateDrag_();
if (Blockly.selected && Blockly.highlightedConnection_) {
if (Blockly.localConnection_ == Blockly.selected.nextConnection) {
if (Blockly.localConnection_ ==
Blockly.selected.getFirstStatementConnection()) {
// Snap to match the position of the pre-existing stack. Since this is a
// C-block, shift to take into account how the block will stretch as it
// surrounds the internal blocks.
Blockly.selected.moveBy(
Blockly.highlightedConnection_.x_ - Blockly.localConnection_.x_,
Blockly.highlightedConnection_.y_ - Blockly.localConnection_.y_ -
(Blockly.highlightedConnection_.sourceBlock_.getHeightWidth().height -
Blockly.BlockSvg.MIN_BLOCK_Y));
} else if (Blockly.localConnection_.type == Blockly.NEXT_STATEMENT) {
// Snap to match the position of the pre-existing stack.
Blockly.selected.moveBy(
Blockly.highlightedConnection_.x_ - Blockly.localConnection_.x_,
@ -777,8 +795,11 @@ Blockly.BlockSvg.prototype.setDragging_ = function(adding) {
group.translate_ = '';
group.skew_ = '';
this.addDragging();
Blockly.draggingConnections_ =
Blockly.draggingConnections_.concat(this.getConnections_(true));
} else {
this.removeDragging();
Blockly.draggingConnections_ = [];
}
// Recurse through all blocks attached under this one.
for (var i = 0; i < this.childBlocks_.length; i++) {
@ -881,8 +902,10 @@ Blockly.BlockSvg.prototype.onMouseMove_ = function(e) {
}
}
var candidateIsLast = (localConnection == lastOnStack);
this.updatePreviews(closestConnection, localConnection, radiusConnection,
e, newXY.x - this.dragStartXY_.x, newXY.y - this.dragStartXY_.y);
e, newXY.x - this.dragStartXY_.x, newXY.y - this.dragStartXY_.y,
candidateIsLast);
}
// This event has been handled. No need to bubble up to the document.
e.stopPropagation();
@ -901,59 +924,81 @@ Blockly.BlockSvg.prototype.onMouseMove_ = function(e) {
* point in the drag.
* @param {number} dy The y distance the block has moved onscreen up to this
* point in the drag.
* @param {boolean} candidateIsLast True if the dragging stack is more than one
* block long and localConnection is the last connection on the stack.
*/
Blockly.BlockSvg.prototype.updatePreviews = function(closestConnection,
localConnection, radiusConnection, e, dx, dy) {
// Don't fire events for ghost block creation or movement.
localConnection, radiusConnection, e, dx, dy, candidateIsLast) {
// Don't fire events for insertion marker creation or movement.
Blockly.Events.disable();
// Remove a ghost if needed. For Scratch-Blockly we are using ghosts instead
// of highlighting the connection; for compatibility with Web Blockly the
// name "highlightedConnection" will still be used.
// Remove an insertion marker if needed. For Scratch-Blockly we are using
// grayed-out blocks instead of highlighting the connection; for compatibility
// with Web Blockly the name "highlightedConnection" will still be used.
if (Blockly.highlightedConnection_ &&
Blockly.highlightedConnection_ != closestConnection) {
if (this.ghostBlock_ && Blockly.localGhostConnection_) {
this.disconnectGhost();
if (Blockly.insertionMarker_ && Blockly.insertionMarkerConnection_) {
Blockly.BlockSvg.disconnectInsertionMarker();
}
// If there's already an insertion marker but it's representing the wrong
// block, delete it so we can create the correct one.
if (Blockly.insertionMarker_ &&
(candidateIsLast && Blockly.localConnection_.sourceBlock_ == this) ||
(!candidateIsLast && Blockly.localConnection_.sourceBlock_ != this)) {
Blockly.insertionMarker_.dispose();
Blockly.insertionMarker_ = null;
}
Blockly.highlightedConnection_ = null;
Blockly.localConnection_ = null;
}
// Add a ghost if needed.
// Add an insertion marker if needed.
if (closestConnection &&
closestConnection != Blockly.highlightedConnection_ &&
!closestConnection.sourceBlock_.isGhost()) {
!closestConnection.sourceBlock_.isInsertionMarker()) {
Blockly.highlightedConnection_ = closestConnection;
Blockly.localConnection_ = localConnection;
if (!this.ghostBlock_){
this.ghostBlock_ = this.workspace.newBlock(this.type);
this.ghostBlock_.setGhost(true);
this.ghostBlock_.initSvg();
if (!Blockly.insertionMarker_) {
Blockly.insertionMarker_ =
this.workspace.newBlock(Blockly.localConnection_.sourceBlock_.type);
Blockly.insertionMarker_.setInsertionMarker(true);
Blockly.insertionMarker_.initSvg();
}
var ghostBlock = this.ghostBlock_;
var localGhostConnection = ghostBlock.getMatchingConnection(this,
localConnection);
if (localGhostConnection != Blockly.localGhostConnection_) {
ghostBlock.getSvgRoot().setAttribute('visibility', 'visible');
ghostBlock.rendered = true;
var insertionMarker = Blockly.insertionMarker_;
var insertionMarkerConnection = insertionMarker.getMatchingConnection(
localConnection.sourceBlock_, localConnection);
if (insertionMarkerConnection != Blockly.insertionMarkerConnection_) {
insertionMarker.getSvgRoot().setAttribute('visibility', 'visible');
insertionMarker.rendered = true;
// Move the preview to the correct location before the existing block.
if (localGhostConnection.type == Blockly.NEXT_STATEMENT) {
var relativeXy = this.getRelativeToSurfaceXY();
if (insertionMarkerConnection.type == Blockly.NEXT_STATEMENT) {
var relativeXy = localConnection.sourceBlock_.getRelativeToSurfaceXY();
var connectionOffsetX = (localConnection.x_ - (relativeXy.x - dx));
var connectionOffsetY = (localConnection.y_ - (relativeXy.y - dy));
var newX = closestConnection.x_ - connectionOffsetX;
var newY = closestConnection.y_ - connectionOffsetY;
var ghostPosition = ghostBlock.getRelativeToSurfaceXY();
ghostBlock.moveBy(newX - ghostPosition.x, newY - ghostPosition.y, true);
var insertionPosition = insertionMarker.getRelativeToSurfaceXY();
// If it's the first statement connection of a c-block, this block is
// going to get taller as soon as render() is called below.
if (insertionMarkerConnection != insertionMarker.nextConnection) {
newY -= closestConnection.sourceBlock_.getHeightWidth().height -
Blockly.BlockSvg.MIN_BLOCK_Y;
}
insertionMarker.moveBy(newX - insertionPosition.x,
newY - insertionPosition.y);
}
if (localGhostConnection.type == Blockly.PREVIOUS_STATEMENT &&
!ghostBlock.nextConnection) {
if (insertionMarkerConnection.type == Blockly.PREVIOUS_STATEMENT &&
!insertionMarker.nextConnection) {
Blockly.bumpedConnection_ = closestConnection.targetConnection;
}
// Renders ghost.
localGhostConnection.connect(closestConnection);
Blockly.localGhostConnection_ = localGhostConnection;
// Renders insertin marker.
insertionMarkerConnection.connect(closestConnection);
// Render dragging block so it appears on top.
Blockly.insertionMarkerConnection_ = insertionMarkerConnection;
}
}
// Reenable events.
@ -967,40 +1012,42 @@ Blockly.BlockSvg.prototype.updatePreviews = function(closestConnection,
};
/**
* Disconnect the current ghost block from the stack, and heal the stack to its
* previous state.
* Disconnect the current insertion marker from the stack, and heal the stack to
* its previous state.
*/
Blockly.BlockSvg.prototype.disconnectGhost = function() {
// The ghost block is the first block in a stack, either because it doesn't
// have a previous connection or because the previous connection is not
// connection. Unplug won't do anything in that case. Instead, unplug the
Blockly.BlockSvg.disconnectInsertionMarker = function() {
// The insertion marker is the first block in a stack, either because it
// doesn't have a previous connection or because the previous connection is
// not connected. Unplug won't do anything in that case. Instead, unplug the
// following block.
if (Blockly.localGhostConnection_ == this.ghostBlock_.nextConnection &&
(!this.ghostBlock_.previousConnection ||
!this.ghostBlock_.previousConnection.targetConnection)) {
Blockly.localGhostConnection_.targetBlock().unplug(false);
if (Blockly.insertionMarkerConnection_ ==
Blockly.insertionMarker_.nextConnection &&
(!Blockly.insertionMarker_.previousConnection ||
!Blockly.insertionMarker_.previousConnection.targetConnection)) {
Blockly.insertionMarkerConnection_.targetBlock().unplug(false);
}
// Inside of a C-block, first statement connection.
else if (Blockly.localGhostConnection_.type == Blockly.NEXT_STATEMENT &&
Blockly.localGhostConnection_ != this.ghostBlock_.nextConnection) {
var innerConnection = Blockly.localGhostConnection_.targetConnection;
else if (Blockly.insertionMarkerConnection_.type == Blockly.NEXT_STATEMENT &&
Blockly.insertionMarkerConnection_ !=
Blockly.insertionMarker_.nextConnection) {
var innerConnection = Blockly.insertionMarkerConnection_.targetConnection;
innerConnection.sourceBlock_.unplug(false);
var previousBlockNextConnection =
this.ghostBlock_.previousConnection.targetConnection;
this.ghostBlock_.unplug(true);
Blockly.insertionMarker_.previousConnection.targetConnection;
Blockly.insertionMarker_.unplug(true);
if (previousBlockNextConnection) {
previousBlockNextConnection.connect(innerConnection);
}
}
else {
this.ghostBlock_.unplug(true /* healStack */);
Blockly.insertionMarker_.unplug(true /* healStack */);
}
if (Blockly.localGhostConnection_.targetConnection) {
throw 'LocalGhostConnection still connected at the end of disconnectGhost';
if (Blockly.insertionMarkerConnection_.targetConnection) {
throw 'insertionMarkerConnection still connected at the end of disconnectInsertionMarker';
}
Blockly.localGhostConnection_ = null;
this.ghostBlock_.getSvgRoot().setAttribute('visibility', 'hidden');
Blockly.insertionMarkerConnection_ = null;
Blockly.insertionMarker_.getSvgRoot().setAttribute('visibility', 'hidden');
};
/**
@ -1048,11 +1095,11 @@ Blockly.BlockSvg.prototype.setShadow = function(shadow) {
};
/**
* Set whether this block is a ghost block or not.
* @param {boolean} ghost True if a ghost.
* Set whether this block is an insertion marker block or not.
* @param {boolean} insertionMarker True if an insertion marker.
*/
Blockly.BlockSvg.prototype.setGhost = function(ghost) {
Blockly.BlockSvg.superClass_.setGhost.call(this, ghost);
Blockly.BlockSvg.prototype.setInsertionMarker = function(insertionMarker) {
Blockly.BlockSvg.superClass_.setInsertionMarker.call(this, insertionMarker);
this.updateColour();
};
@ -1332,11 +1379,15 @@ Blockly.BlockSvg.prototype.removeDragging = function() {
/**
* Change the colour of a block.
* @param {number|string} colour HSV hue value, or #RRGGBB string.
* @param {number|string} colourSecondary Secondary HSV hue value, or #RRGGBB string.
* @param {number|string} colourTertiary Tertiary HSV hue value, or #RRGGBB string.
* @param {number|string} colourSecondary Secondary HSV hue value, or #RRGGBB
* string.
* @param {number|string} colourTertiary Tertiary HSV hue value, or #RRGGBB
* string.
*/
Blockly.BlockSvg.prototype.setColour = function(colour, colourSecondary, colourTertiary) {
Blockly.BlockSvg.superClass_.setColour.call(this, colour, colourSecondary, colourTertiary);
Blockly.BlockSvg.prototype.setColour = function(colour, colourSecondary,
colourTertiary) {
Blockly.BlockSvg.superClass_.setColour.call(this, colour, colourSecondary,
colourTertiary);
if (this.rendered) {
this.updateColour();

View file

@ -83,16 +83,30 @@ Blockly.highlightedConnection_ = null;
Blockly.localConnection_ = null;
/**
* Connection on ghost block that matches Blockly.localConnecxtion_ on the
* dragged block.
* List of all of the connections on all of the blocks that are being dragged.
* @private
*/
Blockly.draggingConnections_ = [];
/**
* Connection on the insertion marker block that matches
* Blockly.localConnection_ on the dragged block.
* @type {Blockly.Connection}
* @private
*/
Blockly.localGhostConnection_ = null;
Blockly.insertionMarkerConnection_ = null;
/**
* Connection that was bumped out of the way by a ghost block, and may need
* to be put back as the drag continues.
* Grayed-out block that indicates to the user what will happen if they release
* a drag immediately.
* @type {Blockly.Block}
* @private
*/
Blockly.insertionMarker_ = null;
/**
* Connection that was bumped out of the way by an insertion marker, and may
* need to be put back as the drag continues.
* @type {Blockly.Connection}
* @private
*/

View file

@ -296,11 +296,11 @@ Blockly.Connection.prototype.dispose = function() {
};
/**
* @return true if the connection is not connected or is connected to a ghost
* block, false otherwise.
* @return {boolean} true if the connection is not connected or is connected to
* an insertion marker, false otherwise.
*/
Blockly.Connection.prototype.isConnectedToNonGhost = function() {
return this.targetConnection && !this.targetBlock().isGhost();
Blockly.Connection.prototype.isConnectedToNonInsertionMarker = function() {
return this.targetConnection && !this.targetBlock().isInsertionMarker();
};
/**
@ -416,10 +416,11 @@ Blockly.Connection.prototype.isConnectionAllowed = function(candidate,
return false;
}
if (candidate.targetConnection) {
// If the other side of this connection is the active ghost
// If the other side of this connection is the active insertion marker
// connection, we've obviously already decided that this is a good
// connection.
if (candidate.targetConnection == Blockly.localGhostConnection_) {
if (candidate.targetConnection ==
Blockly.insertionMarkerConnection_) {
return true;
} else {
return false;
@ -431,7 +432,7 @@ Blockly.Connection.prototype.isConnectionAllowed = function(candidate,
// If this is a c-shaped block, statement blocks cannot be connected
// anywhere other than inside the first statement input.
if (firstStatementConnection) {
// Can't connect if there is alread a block inside the first statement
// Can't connect if there is already a block inside the first statement
// input.
if (this == firstStatementConnection) {
if (this.targetConnection) {
@ -441,7 +442,7 @@ Blockly.Connection.prototype.isConnectionAllowed = function(candidate,
// Can't connect this block's next connection unless we're connecting
// in front of the first block on a stack.
else if (this == this.sourceBlock_.nextConnection &&
candidate.isConnectedToNonGhost()) {
candidate.isConnectedToNonInsertionMarker()) {
return false;
}
}
@ -473,13 +474,13 @@ Blockly.Connection.prototype.isConnectionAllowed = function(candidate,
// block on a stack or there's already a block connected inside the c.
if (firstStatementConnection &&
this == this.sourceBlock_.previousConnection &&
candidate.isConnectedToNonGhost() &&
candidate.isConnectedToNonInsertionMarker() &&
!firstStatementConnection.targetConnection) {
return false;
}
// Don't let a block with no next connection bump other blocks out of the
// stack.
if (candidate.isConnectedToNonGhost() &&
if (candidate.isConnectedToNonInsertionMarker() &&
!this.sourceBlock_.nextConnection) {
return false;
}
@ -490,7 +491,11 @@ Blockly.Connection.prototype.isConnectionAllowed = function(candidate,
}
// Don't let blocks try to connect to themselves or ones they nest.
return !this.isAncestor_(candidate);
if (Blockly.draggingConnections_.indexOf(candidate) != -1) {
return false;
}
return true;
};
/**
@ -505,8 +510,8 @@ Blockly.Connection.prototype.checkBasicCompatibility_ = function(candidate,
return false;
}
// Don't consider ghost blocks.
if (candidate.sourceBlock_.isGhost()) {
// Don't consider insertion markers.
if (candidate.sourceBlock_.isInsertionMarker()) {
return false;
}
@ -520,27 +525,6 @@ Blockly.Connection.prototype.checkBasicCompatibility_ = function(candidate,
return true;
};
/**
* Checks if a candidate connection is on this connection's source block or a
* nested block.
* @param {Blockly.Connection} candidate The candidate connection to check.
* @return Whether the candidate connection is on this connection's source block
* or descendant blocks.
*/
Blockly.Connection.prototype.isAncestor_ = function(candidate) {
var targetSourceBlock = candidate.sourceBlock_;
var sourceBlock = this.sourceBlock_;
if (targetSourceBlock && sourceBlock) {
do {
if (sourceBlock == targetSourceBlock) {
return true;
}
targetSourceBlock = targetSourceBlock.getParent();
} while (targetSourceBlock);
}
return false;
};
/**
* Connect this connection to another connection.
* @param {!Blockly.Connection} otherConnection Connection to connect to.

View file

@ -35,7 +35,7 @@ Blockly.DRAG_RADIUS = 5;
/**
* Maximum misalignment between connections for them to snap together.
*/
Blockly.SNAP_RADIUS = 20;
Blockly.SNAP_RADIUS = 72;
/**
* Delay in ms between trigger and bumping unconnected block out of alignment.

View file

@ -152,6 +152,16 @@ Blockly.Css.CONTENT = [
'z-index: 999;',
'}',
'.blocklyWidgetDiv.fieldTextInput {',
'overflow: hidden;',
'border: 1px solid;',
'box-sizing: border-box;',
'transform-origin: 0 0;',
'-ms-transform-origin: 0 0;',
'-moz-transform-origin: 0 0;',
'-webkit-transform-origin: 0 0;',
'}',
'.blocklyNonSelectable {',
'user-select: none;',
'-moz-user-select: none;',
@ -310,14 +320,13 @@ Blockly.Css.CONTENT = [
'.blocklyHtmlInput {',
'border: none;',
'border-radius: 4px;',
'font-family: sans-serif;',
'height: 100%;',
'margin: 0;',
'outline: none;',
'padding: 0 1px;',
'padding: 2px 0;',
'width: 100%;',
'text-align: center',
'text-align: center;',
'}',
'.blocklyMainBackground {',

View file

@ -134,25 +134,21 @@ Blockly.Field.prototype.init = function(block) {
if (!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);
// Adjust X to be flipped for RTL. Position is relative to horizontal start of source block.
var fieldX = (this.sourceBlock_.RTL) ? -this.size_.width / 2 : this.size_.width / 2;
/** @type {!Element} */
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,
'x': fieldX,
'y': this.size_.height / 2 + Blockly.BlockSvg.FIELD_TOP_PADDING,
'text-anchor': 'middle'},
this.fieldGroup_);
this.updateEditable();
block.getSvgRoot().appendChild(this.fieldGroup_);
this.mouseUpWrapper_ =
Blockly.bindEvent_(this.fieldGroup_, 'mouseup', this, this.onMouseUp_);
Blockly.bindEvent_(this.getClickTarget_(), 'mouseup', this,
this.onMouseUp_);
// Force a render.
this.updateTextNode_();
if (Blockly.Events.isEnabled()) {
@ -173,7 +169,6 @@ Blockly.Field.prototype.dispose = function() {
goog.dom.removeNode(this.fieldGroup_);
this.fieldGroup_ = null;
this.textElement_ = null;
this.borderRect_ = null;
this.validator_ = null;
};
@ -189,13 +184,13 @@ Blockly.Field.prototype.updateEditable = function() {
'blocklyEditableText');
Blockly.removeClass_(/** @type {!Element} */ (this.fieldGroup_),
'blocklyNoNEditableText');
this.fieldGroup_.style.cursor = this.CURSOR;
this.getClickTarget_().style.cursor = this.CURSOR;
} else {
Blockly.addClass_(/** @type {!Element} */ (this.fieldGroup_),
'blocklyNonEditableText');
Blockly.removeClass_(/** @type {!Element} */ (this.fieldGroup_),
'blocklyEditableText');
this.fieldGroup_.style.cursor = '';
this.getClickTarget_().style.cursor = '';
}
};
@ -263,10 +258,6 @@ Blockly.Field.prototype.render_ = function() {
Blockly.Field.cacheWidths_[key] = width;
}
}
if (this.borderRect_) {
this.borderRect_.setAttribute('width',
width + Blockly.BlockSvg.SEP_SPACE_X);
}
} else {
var width = 0;
}
@ -313,10 +304,10 @@ Blockly.Field.prototype.getSize = function() {
* @private
*/
Blockly.Field.prototype.getScaledBBox_ = function() {
var bBox = this.borderRect_.getBBox();
// Create new object, as getBBox can return an uneditable SVGRect in IE.
return new goog.math.Size(bBox.width * this.sourceBlock_.workspace.scale,
bBox.height * this.sourceBlock_.workspace.scale);
var size = this.getSize();
// Create new object, so as to not return an uneditable SVGRect in IE.
return new goog.math.Size(size.width * this.sourceBlock_.workspace.scale,
size.height * this.sourceBlock_.workspace.scale);
};
/**
@ -446,6 +437,31 @@ Blockly.Field.prototype.setTooltip = function(newTip) {
// Non-abstract sub-classes may wish to implement this. See FieldLabel.
};
/**
* Select the element to bind the click handler to. When this element is
* clicked on an editable field, the editor will open.
*
* <p>If the block has multiple fields, this is just the group containing the
* field. If the block has only one field, we handle clicks over the whole
* block.
*
* @return {!Element} Element to bind click handler to.
* @private
*/
Blockly.Field.prototype.getClickTarget_ = function() {
var nFields = 0;
for (var i = 0, input; input = this.sourceBlock_.inputList[i]; i++) {
nFields += input.fieldRow.length;
}
if (nFields <= 1) {
return this.sourceBlock_.getSvgRoot();
} else {
return this.getSvgRoot();
}
};
/**
* Return the absolute coordinates of the top-left corner of this field.
* The origin (0,0) is the top-left corner of the page body.
@ -453,5 +469,5 @@ Blockly.Field.prototype.setTooltip = function(newTip) {
* @private
*/
Blockly.Field.prototype.getAbsoluteXY_ = function() {
return goog.style.getPageOffset(this.borderRect_);
return goog.style.getPageOffset(this.getClickTarget_());
};

View file

@ -70,7 +70,12 @@ Blockly.FieldColour.prototype.columns_ = 0;
*/
Blockly.FieldColour.prototype.init = function(block) {
Blockly.FieldColour.superClass_.init.call(this, block);
this.borderRect_.style['fillOpacity'] = 1;
// TODO(#163): borderRect_ has been removed from the field.
// When fixing field_colour, we should re-color the shadow block instead,
// or re-implement a rectangle in the field.
if (this.borderRect_) {
this.borderRect_.style['fillOpacity'] = 1;
}
this.setValue(this.getValue());
};

View file

@ -127,11 +127,13 @@ Blockly.FieldTextInput.prototype.showEditor_ = function(opt_quietInput) {
Blockly.WidgetDiv.show(this, this.sourceBlock_.RTL, this.widgetDispose_());
var div = Blockly.WidgetDiv.DIV;
// Apply text-input-specific fixed CSS
div.className += ' fieldTextInput';
// Create the input.
var htmlInput = goog.dom.createDom('input', 'blocklyHtmlInput');
htmlInput.setAttribute('spellcheck', this.spellcheck_);
var fontSize =
(Blockly.FieldTextInput.FONTSIZE * this.workspace_.scale) + 'pt';
(Blockly.FieldTextInput.FONTSIZE) + 'pt';
div.style.fontSize = fontSize;
htmlInput.style.fontSize = fontSize;
/** @type {!HTMLInputElement} */
@ -225,40 +227,63 @@ Blockly.FieldTextInput.prototype.validate_ = function() {
* @private
*/
Blockly.FieldTextInput.prototype.resizeEditor_ = function() {
var scale = this.sourceBlock_.workspace.scale;
var div = Blockly.WidgetDiv.DIV;
var bBox = this.fieldGroup_.getBBox();
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 bBox = this.getScaledBBox_();
// The width of this box must be at least FIELD_WIDTH * scale.
// It may be smaller as bBox is based on the content size.
var width = Math.max(bBox.width, Blockly.BlockSvg.FIELD_WIDTH * scale);
// Add 1px to width and height to account for border (pre-scale)
div.style.width = (width / scale + 1) + 'px';
div.style.height = (bBox.height / scale + 1) + 'px';
div.style.transform = 'scale(' + scale + ')';
// Add 0.5px to account for slight difference between SVG and CSS border
var borderRadius = this.getBorderRadius() + 0.5;
div.style.borderRadius = borderRadius + 'px';
// Pull stroke colour from the existing shadow block
var strokeColour = this.sourceBlock_.getColourTertiary();
div.style.borderColor = strokeColour;
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;
// Account for border width, post-scale
xy.x -= scale / 2;
xy.y -= scale / 2;
// 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) {
var borderBBox = this.getScaledBBox_();
xy.x += borderBBox.width;
xy.x += width;
xy.x -= div.offsetWidth;
}
// Shift by a few pixels to line up exactly.
xy.y += 1;
xy.y += 1 * scale;
if (goog.userAgent.GECKO && Blockly.WidgetDiv.DIV.style.top) {
// Firefox mis-reports the location of the border by a pixel
// once the WidgetDiv is moved into position.
xy.x -= 1;
xy.y -= 1;
xy.x += 2 * scale;
xy.y += 1 * scale;
}
if (goog.userAgent.WEBKIT) {
xy.y -= 3;
xy.x += 0.5;
xy.y -= 1 * scale;
}
// Finally, set the actual style
div.style.left = xy.x + 'px';
div.style.top = xy.y + 'px';
};
/**
* Determine border radius based on the type of the owning shadow block.
* @return {Number} Border radius in px.
*/
Blockly.Field.prototype.getBorderRadius = function() {
if (this.sourceBlock_.type === 'math_number') {
return Blockly.BlockSvg.NUMBER_FIELD_CORNER_RADIUS;
} else {
return Blockly.BlockSvg.TEXT_FIELD_CORNER_RADIUS;
}
};
/**
* Close the editor, save the results, and dispose of the editable
* text field's elements.
@ -294,6 +319,8 @@ Blockly.FieldTextInput.prototype.widgetDispose_ = function() {
style.width = 'auto';
style.height = 'auto';
style.fontSize = '';
// Reset class
Blockly.WidgetDiv.DIV.className = 'blocklyWidgetDiv';
};
};

View file

@ -10,12 +10,7 @@ Blockly.JavaScript.ORDER_LOGICAL_AND=13;Blockly.JavaScript.ORDER_LOGICAL_OR=14;B
Blockly.JavaScript.init=function(a){Blockly.JavaScript.definitions_=Object.create(null);Blockly.JavaScript.functionNames_=Object.create(null);Blockly.JavaScript.variableDB_?Blockly.JavaScript.variableDB_.reset():Blockly.JavaScript.variableDB_=new Blockly.Names(Blockly.JavaScript.RESERVED_WORDS_);var b=[];a=Blockly.Variables.allVariables(a);for(var c=0;c<a.length;c++)b[c]="var "+Blockly.JavaScript.variableDB_.getName(a[c],Blockly.Variables.NAME_TYPE)+";";Blockly.JavaScript.definitions_.variables=b.join("\n")};
Blockly.JavaScript.finish=function(a){var b=[],c;for(c in Blockly.JavaScript.definitions_)b.push(Blockly.JavaScript.definitions_[c]);delete Blockly.JavaScript.definitions_;delete Blockly.JavaScript.functionNames_;Blockly.JavaScript.variableDB_.reset();return b.join("\n\n")+"\n\n\n"+a};Blockly.JavaScript.scrubNakedValue=function(a){return a+";\n"};Blockly.JavaScript.quote_=function(a){a=a.replace(/\\/g,"\\\\").replace(/\n/g,"\\\n").replace(/'/g,"\\'");return"'"+a+"'"};
Blockly.JavaScript.scrub_=function(a,b){var c="";if(!a.outputConnection||!a.outputConnection.targetConnection){var d=a.getCommentText();d&&(c+=Blockly.JavaScript.prefixLines(d,"// ")+"\n");for(var e=0;e<a.inputList.length;e++)a.inputList[e].type==Blockly.INPUT_VALUE&&(d=a.inputList[e].connection.targetBlock())&&(d=Blockly.JavaScript.allNestedComments(d))&&(c+=Blockly.JavaScript.prefixLines(d,"// "))}e=a.nextConnection&&a.nextConnection.targetBlock();e=Blockly.JavaScript.blockToCode(e);return c+b+
e};Blockly.JavaScript.colour={};Blockly.JavaScript.colour_picker=function(a){return["'"+a.getFieldValue("COLOUR")+"'",Blockly.JavaScript.ORDER_ATOMIC]};Blockly.JavaScript.colour_random=function(a){return[Blockly.JavaScript.provideFunction_("colour_random",["function "+Blockly.JavaScript.FUNCTION_NAME_PLACEHOLDER_+"() {"," var num = Math.floor(Math.random() * Math.pow(2, 24));"," return '#' + ('00000' + num.toString(16)).substr(-6);","}"])+"()",Blockly.JavaScript.ORDER_FUNCTION_CALL]};
Blockly.JavaScript.colour_rgb=function(a){var b=Blockly.JavaScript.valueToCode(a,"RED",Blockly.JavaScript.ORDER_COMMA)||0,c=Blockly.JavaScript.valueToCode(a,"GREEN",Blockly.JavaScript.ORDER_COMMA)||0;a=Blockly.JavaScript.valueToCode(a,"BLUE",Blockly.JavaScript.ORDER_COMMA)||0;return[Blockly.JavaScript.provideFunction_("colour_rgb",["function "+Blockly.JavaScript.FUNCTION_NAME_PLACEHOLDER_+"(r, g, b) {"," r = Math.max(Math.min(Number(r), 100), 0) * 2.55;"," g = Math.max(Math.min(Number(g), 100), 0) * 2.55;",
" b = Math.max(Math.min(Number(b), 100), 0) * 2.55;"," r = ('0' + (Math.round(r) || 0).toString(16)).slice(-2);"," g = ('0' + (Math.round(g) || 0).toString(16)).slice(-2);"," b = ('0' + (Math.round(b) || 0).toString(16)).slice(-2);"," return '#' + r + g + b;","}"])+"("+b+", "+c+", "+a+")",Blockly.JavaScript.ORDER_FUNCTION_CALL]};
Blockly.JavaScript.colour_blend=function(a){var b=Blockly.JavaScript.valueToCode(a,"COLOUR1",Blockly.JavaScript.ORDER_COMMA)||"'#000000'",c=Blockly.JavaScript.valueToCode(a,"COLOUR2",Blockly.JavaScript.ORDER_COMMA)||"'#000000'";a=Blockly.JavaScript.valueToCode(a,"RATIO",Blockly.JavaScript.ORDER_COMMA)||.5;return[Blockly.JavaScript.provideFunction_("colour_blend",["function "+Blockly.JavaScript.FUNCTION_NAME_PLACEHOLDER_+"(c1, c2, ratio) {"," ratio = Math.max(Math.min(Number(ratio), 1), 0);"," var r1 = parseInt(c1.substring(1, 3), 16);",
" var g1 = parseInt(c1.substring(3, 5), 16);"," var b1 = parseInt(c1.substring(5, 7), 16);"," var r2 = parseInt(c2.substring(1, 3), 16);"," var g2 = parseInt(c2.substring(3, 5), 16);"," var b2 = parseInt(c2.substring(5, 7), 16);"," var r = Math.round(r1 * (1 - ratio) + r2 * ratio);"," var g = Math.round(g1 * (1 - ratio) + g2 * ratio);"," var b = Math.round(b1 * (1 - ratio) + b2 * ratio);"," r = ('0' + (r || 0).toString(16)).slice(-2);"," g = ('0' + (g || 0).toString(16)).slice(-2);"," b = ('0' + (b || 0).toString(16)).slice(-2);",
" return '#' + r + g + b;","}"])+"("+b+", "+c+", "+a+")",Blockly.JavaScript.ORDER_FUNCTION_CALL]};Blockly.JavaScript.control={};Blockly.JavaScript.control_repeat=function(a){var b=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);return a+("for (var "+d+" = 0; "+d+" < "+b+"; "+d+"++) {\n"+c+"}\n")};
e};
// Copyright 2016 Google Inc. Apache License 2.0
Blockly.JavaScript.event={};Blockly.JavaScript.event_whenflagclicked=function(a){return"flagClicked();\n"};Blockly.JavaScript.lists={};Blockly.JavaScript.lists_create_empty=function(a){return["[]",Blockly.JavaScript.ORDER_ATOMIC]};Blockly.JavaScript.lists_create_with=function(a){for(var b=Array(a.itemCount_),c=0;c<a.itemCount_;c++)b[c]=Blockly.JavaScript.valueToCode(a,"ADD"+c,Blockly.JavaScript.ORDER_COMMA)||"null";b="["+b.join(", ")+"]";return[b,Blockly.JavaScript.ORDER_ATOMIC]};
Blockly.JavaScript.lists_repeat=function(a){var b=Blockly.JavaScript.provideFunction_("lists_repeat",["function "+Blockly.JavaScript.FUNCTION_NAME_PLACEHOLDER_+"(value, n) {"," var array = [];"," for (var i = 0; i < n; i++) {"," array[i] = value;"," }"," return array;","}"]),c=Blockly.JavaScript.valueToCode(a,"ITEM",Blockly.JavaScript.ORDER_COMMA)||"null";a=Blockly.JavaScript.valueToCode(a,"NUM",Blockly.JavaScript.ORDER_COMMA)||"0";return[b+"("+c+", "+a+")",Blockly.JavaScript.ORDER_FUNCTION_CALL]};
@ -30,20 +25,7 @@ Blockly.JavaScript.lists_setIndex=function(a){function b(){if(c.match(/^\w+$/))r
c+".splice("+c+".length - "+f+", 0, "+a+");\n"}else if("RANDOM"==e){e=b();f=Blockly.JavaScript.variableDB_.getDistinctName("tmp_x",Blockly.Variables.NAME_TYPE);e+="var "+f+" = Math.floor(Math.random() * "+c+".length);\n";if("SET"==d)return e+=c+"["+f+"] = "+a+";\n";if("INSERT"==d)return e+=c+".splice("+f+", 0, "+a+");\n"}throw"Unhandled combination (lists_setIndex).";};
Blockly.JavaScript.lists_getSublist=function(a){var b=Blockly.JavaScript.valueToCode(a,"LIST",Blockly.JavaScript.ORDER_MEMBER)||"[]",c=a.getFieldValue("WHERE1"),d=a.getFieldValue("WHERE2"),e=Blockly.JavaScript.valueToCode(a,"AT1",Blockly.JavaScript.ORDER_NONE)||"1";a=Blockly.JavaScript.valueToCode(a,"AT2",Blockly.JavaScript.ORDER_NONE)||"1";return["FIRST"==c&&"LAST"==d?b+".concat()":Blockly.JavaScript.provideFunction_("lists_get_sublist",["function "+Blockly.JavaScript.FUNCTION_NAME_PLACEHOLDER_+
"(list, where1, at1, where2, at2) {"," function getAt(where, at) {"," if (where == 'FROM_START') {"," at--;"," } else if (where == 'FROM_END') {"," at = list.length - at;"," } else if (where == 'FIRST') {"," at = 0;"," } else if (where == 'LAST') {"," at = list.length - 1;"," } else {"," throw 'Unhandled option (lists_getSublist).';"," }"," return at;"," }"," at1 = getAt(where1, at1);"," at2 = getAt(where2, at2) + 1;"," return list.slice(at1, at2);",
"}"])+"("+b+", '"+c+"', "+e+", '"+d+"', "+a+")",Blockly.JavaScript.ORDER_FUNCTION_CALL]};Blockly.JavaScript.lists_split=function(a){var b=Blockly.JavaScript.valueToCode(a,"INPUT",Blockly.JavaScript.ORDER_MEMBER),c=Blockly.JavaScript.valueToCode(a,"DELIM",Blockly.JavaScript.ORDER_NONE)||"''";a=a.getFieldValue("MODE");if("SPLIT"==a)b||(b="''"),a="split";else if("JOIN"==a)b||(b="[]"),a="join";else throw"Unknown mode: "+a;return[b+"."+a+"("+c+")",Blockly.JavaScript.ORDER_FUNCTION_CALL]};Blockly.JavaScript.logic={};
Blockly.JavaScript.controls_if=function(a){for(var b=0,c=Blockly.JavaScript.valueToCode(a,"IF"+b,Blockly.JavaScript.ORDER_NONE)||"false",d=Blockly.JavaScript.statementToCode(a,"DO"+b),e="if ("+c+") {\n"+d+"}",b=1;b<=a.elseifCount_;b++)c=Blockly.JavaScript.valueToCode(a,"IF"+b,Blockly.JavaScript.ORDER_NONE)||"false",d=Blockly.JavaScript.statementToCode(a,"DO"+b),e+=" else if ("+c+") {\n"+d+"}";a.elseCount_&&(d=Blockly.JavaScript.statementToCode(a,"ELSE"),e+=" else {\n"+d+"}");return e+"\n"};
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.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"};
Blockly.JavaScript.controls_for=function(a){var b=Blockly.JavaScript.variableDB_.getName(a.getFieldValue("VAR"),Blockly.Variables.NAME_TYPE),c=Blockly.JavaScript.valueToCode(a,"FROM",Blockly.JavaScript.ORDER_ASSIGNMENT)||"0",d=Blockly.JavaScript.valueToCode(a,"TO",Blockly.JavaScript.ORDER_ASSIGNMENT)||"0",e=Blockly.JavaScript.valueToCode(a,"BY",Blockly.JavaScript.ORDER_ASSIGNMENT)||"1",f=Blockly.JavaScript.statementToCode(a,"DO"),f=Blockly.JavaScript.addLoopTrap(f,a.id);if(Blockly.isNumber(c)&&Blockly.isNumber(d)&&
Blockly.isNumber(e)){var g=parseFloat(c)<=parseFloat(d);a="for ("+b+" = "+c+"; "+b+(g?" <= ":" >= ")+d+"; "+b;b=Math.abs(parseFloat(e));a=(1==b?a+(g?"++":"--"):a+((g?" += ":" -= ")+b))+(") {\n"+f+"}\n")}else a="",g=c,c.match(/^\w+$/)||Blockly.isNumber(c)||(g=Blockly.JavaScript.variableDB_.getDistinctName(b+"_start",Blockly.Variables.NAME_TYPE),a+="var "+g+" = "+c+";\n"),c=d,d.match(/^\w+$/)||Blockly.isNumber(d)||(c=Blockly.JavaScript.variableDB_.getDistinctName(b+"_end",Blockly.Variables.NAME_TYPE),
a+="var "+c+" = "+d+";\n"),d=Blockly.JavaScript.variableDB_.getDistinctName(b+"_inc",Blockly.Variables.NAME_TYPE),a+="var "+d+" = ",a=Blockly.isNumber(e)?a+(Math.abs(e)+";\n"):a+("Math.abs("+e+");\n"),a+="if ("+g+" > "+c+") {\n",a+=Blockly.JavaScript.INDENT+d+" = -"+d+";\n",a+="}\n",a+="for ("+b+" = "+g+";\n "+d+" >= 0 ? "+b+" <= "+c+" : "+b+" >= "+c+";\n "+b+" += "+d+") {\n"+f+"}\n";return a};
Blockly.JavaScript.controls_forEach=function(a){var b=Blockly.JavaScript.variableDB_.getName(a.getFieldValue("VAR"),Blockly.Variables.NAME_TYPE),c=Blockly.JavaScript.valueToCode(a,"LIST",Blockly.JavaScript.ORDER_ASSIGNMENT)||"[]",d=Blockly.JavaScript.statementToCode(a,"DO"),d=Blockly.JavaScript.addLoopTrap(d,a.id);a="";var e=c;c.match(/^\w+$/)||(e=Blockly.JavaScript.variableDB_.getDistinctName(b+"_list",Blockly.Variables.NAME_TYPE),a+="var "+e+" = "+c+";\n");c=Blockly.JavaScript.variableDB_.getDistinctName(b+
"_index",Blockly.Variables.NAME_TYPE);d=Blockly.JavaScript.INDENT+b+" = "+e+"["+c+"];\n"+d;return a+("for (var "+c+" in "+e+") {\n"+d+"}\n")};Blockly.JavaScript.controls_flow_statements=function(a){switch(a.getFieldValue("FLOW")){case "BREAK":return"break;\n";case "CONTINUE":return"continue;\n"}throw"Unknown flow statement.";};Blockly.JavaScript.math={};Blockly.JavaScript.math_number=function(a){return[parseFloat(a.getFieldValue("NUM")),Blockly.JavaScript.ORDER_ATOMIC]};
"}"])+"("+b+", '"+c+"', "+e+", '"+d+"', "+a+")",Blockly.JavaScript.ORDER_FUNCTION_CALL]};Blockly.JavaScript.lists_split=function(a){var b=Blockly.JavaScript.valueToCode(a,"INPUT",Blockly.JavaScript.ORDER_MEMBER),c=Blockly.JavaScript.valueToCode(a,"DELIM",Blockly.JavaScript.ORDER_NONE)||"''";a=a.getFieldValue("MODE");if("SPLIT"==a)b||(b="''"),a="split";else if("JOIN"==a)b||(b="[]"),a="join";else throw"Unknown mode: "+a;return[b+"."+a+"("+c+")",Blockly.JavaScript.ORDER_FUNCTION_CALL]};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.motion={};Blockly.JavaScript.motion_moveright=function(a){return"moveRight();\n"};Blockly.JavaScript.math={};Blockly.JavaScript.math_number=function(a){return[parseFloat(a.getFieldValue("NUM")),Blockly.JavaScript.ORDER_ATOMIC]};
Blockly.JavaScript.math_arithmetic=function(a){var b={ADD:[" + ",Blockly.JavaScript.ORDER_ADDITION],MINUS:[" - ",Blockly.JavaScript.ORDER_SUBTRACTION],MULTIPLY:[" * ",Blockly.JavaScript.ORDER_MULTIPLICATION],DIVIDE:[" / ",Blockly.JavaScript.ORDER_DIVISION],POWER:[null,Blockly.JavaScript.ORDER_COMMA]}[a.getFieldValue("OP")],c=b[0],b=b[1],d=Blockly.JavaScript.valueToCode(a,"A",b)||"0";a=Blockly.JavaScript.valueToCode(a,"B",b)||"0";return c?[d+c+a,b]:["Math.pow("+d+", "+a+")",Blockly.JavaScript.ORDER_FUNCTION_CALL]};
Blockly.JavaScript.math_single=function(a){var b=a.getFieldValue("OP"),c;if("NEG"==b)return a=Blockly.JavaScript.valueToCode(a,"NUM",Blockly.JavaScript.ORDER_UNARY_NEGATION)||"0","-"==a[0]&&(a=" "+a),["-"+a,Blockly.JavaScript.ORDER_UNARY_NEGATION];a="SIN"==b||"COS"==b||"TAN"==b?Blockly.JavaScript.valueToCode(a,"NUM",Blockly.JavaScript.ORDER_DIVISION)||"0":Blockly.JavaScript.valueToCode(a,"NUM",Blockly.JavaScript.ORDER_NONE)||"0";switch(b){case "ABS":c="Math.abs("+a+")";break;case "ROOT":c="Math.sqrt("+
a+")";break;case "LN":c="Math.log("+a+")";break;case "EXP":c="Math.exp("+a+")";break;case "POW10":c="Math.pow(10,"+a+")";break;case "ROUND":c="Math.round("+a+")";break;case "ROUNDUP":c="Math.ceil("+a+")";break;case "ROUNDDOWN":c="Math.floor("+a+")";break;case "SIN":c="Math.sin("+a+" / 180 * Math.PI)";break;case "COS":c="Math.cos("+a+" / 180 * Math.PI)";break;case "TAN":c="Math.tan("+a+" / 180 * Math.PI)"}if(c)return[c,Blockly.JavaScript.ORDER_FUNCTION_CALL];switch(b){case "LOG10":c="Math.log("+a+
@ -62,7 +44,12 @@ Blockly.JavaScript.math_on_list=function(a){var b=a.getFieldValue("OP");switch(b
"LIST",Blockly.JavaScript.ORDER_NONE)||"[]";a=b+"("+a+")";break;default:throw"Unknown operator: "+b;}return[a,Blockly.JavaScript.ORDER_FUNCTION_CALL]};Blockly.JavaScript.math_modulo=function(a){var b=Blockly.JavaScript.valueToCode(a,"DIVIDEND",Blockly.JavaScript.ORDER_MODULUS)||"0";a=Blockly.JavaScript.valueToCode(a,"DIVISOR",Blockly.JavaScript.ORDER_MODULUS)||"0";return[b+" % "+a,Blockly.JavaScript.ORDER_MODULUS]};
Blockly.JavaScript.math_constrain=function(a){var b=Blockly.JavaScript.valueToCode(a,"VALUE",Blockly.JavaScript.ORDER_COMMA)||"0",c=Blockly.JavaScript.valueToCode(a,"LOW",Blockly.JavaScript.ORDER_COMMA)||"0";a=Blockly.JavaScript.valueToCode(a,"HIGH",Blockly.JavaScript.ORDER_COMMA)||"Infinity";return["Math.min(Math.max("+b+", "+c+"), "+a+")",Blockly.JavaScript.ORDER_FUNCTION_CALL]};
Blockly.JavaScript.math_random_int=function(a){var b=Blockly.JavaScript.valueToCode(a,"FROM",Blockly.JavaScript.ORDER_COMMA)||"0";a=Blockly.JavaScript.valueToCode(a,"TO",Blockly.JavaScript.ORDER_COMMA)||"0";return[Blockly.JavaScript.provideFunction_("math_random_int",["function "+Blockly.JavaScript.FUNCTION_NAME_PLACEHOLDER_+"(a, b) {"," if (a > b) {"," // Swap a and b to ensure a is smaller."," var c = a;"," a = b;"," b = c;"," }"," return Math.floor(Math.random() * (b - a + 1) + a);",
"}"])+"("+b+", "+a+")",Blockly.JavaScript.ORDER_FUNCTION_CALL]};Blockly.JavaScript.math_random_float=function(a){return["Math.random()",Blockly.JavaScript.ORDER_FUNCTION_CALL]};Blockly.JavaScript.motion={};Blockly.JavaScript.motion_moveright=function(a){return"moveRight();\n"};Blockly.JavaScript.procedures={};
"}"])+"("+b+", "+a+")",Blockly.JavaScript.ORDER_FUNCTION_CALL]};Blockly.JavaScript.math_random_float=function(a){return["Math.random()",Blockly.JavaScript.ORDER_FUNCTION_CALL]};Blockly.JavaScript.variables={};Blockly.JavaScript.variables_get=function(a){return[Blockly.JavaScript.variableDB_.getName(a.getFieldValue("VAR"),Blockly.Variables.NAME_TYPE),Blockly.JavaScript.ORDER_ATOMIC]};Blockly.JavaScript.variables_set=function(a){var b=Blockly.JavaScript.valueToCode(a,"VALUE",Blockly.JavaScript.ORDER_ASSIGNMENT)||"0";return Blockly.JavaScript.variableDB_.getName(a.getFieldValue("VAR"),Blockly.Variables.NAME_TYPE)+" = "+b+";\n"};Blockly.JavaScript.colour={};Blockly.JavaScript.colour_picker=function(a){return["'"+a.getFieldValue("COLOUR")+"'",Blockly.JavaScript.ORDER_ATOMIC]};Blockly.JavaScript.colour_random=function(a){return[Blockly.JavaScript.provideFunction_("colour_random",["function "+Blockly.JavaScript.FUNCTION_NAME_PLACEHOLDER_+"() {"," var num = Math.floor(Math.random() * Math.pow(2, 24));"," return '#' + ('00000' + num.toString(16)).substr(-6);","}"])+"()",Blockly.JavaScript.ORDER_FUNCTION_CALL]};
Blockly.JavaScript.colour_rgb=function(a){var b=Blockly.JavaScript.valueToCode(a,"RED",Blockly.JavaScript.ORDER_COMMA)||0,c=Blockly.JavaScript.valueToCode(a,"GREEN",Blockly.JavaScript.ORDER_COMMA)||0;a=Blockly.JavaScript.valueToCode(a,"BLUE",Blockly.JavaScript.ORDER_COMMA)||0;return[Blockly.JavaScript.provideFunction_("colour_rgb",["function "+Blockly.JavaScript.FUNCTION_NAME_PLACEHOLDER_+"(r, g, b) {"," r = Math.max(Math.min(Number(r), 100), 0) * 2.55;"," g = Math.max(Math.min(Number(g), 100), 0) * 2.55;",
" b = Math.max(Math.min(Number(b), 100), 0) * 2.55;"," r = ('0' + (Math.round(r) || 0).toString(16)).slice(-2);"," g = ('0' + (Math.round(g) || 0).toString(16)).slice(-2);"," b = ('0' + (Math.round(b) || 0).toString(16)).slice(-2);"," return '#' + r + g + b;","}"])+"("+b+", "+c+", "+a+")",Blockly.JavaScript.ORDER_FUNCTION_CALL]};
Blockly.JavaScript.colour_blend=function(a){var b=Blockly.JavaScript.valueToCode(a,"COLOUR1",Blockly.JavaScript.ORDER_COMMA)||"'#000000'",c=Blockly.JavaScript.valueToCode(a,"COLOUR2",Blockly.JavaScript.ORDER_COMMA)||"'#000000'";a=Blockly.JavaScript.valueToCode(a,"RATIO",Blockly.JavaScript.ORDER_COMMA)||.5;return[Blockly.JavaScript.provideFunction_("colour_blend",["function "+Blockly.JavaScript.FUNCTION_NAME_PLACEHOLDER_+"(c1, c2, ratio) {"," ratio = Math.max(Math.min(Number(ratio), 1), 0);"," var r1 = parseInt(c1.substring(1, 3), 16);",
" var g1 = parseInt(c1.substring(3, 5), 16);"," var b1 = parseInt(c1.substring(5, 7), 16);"," var r2 = parseInt(c2.substring(1, 3), 16);"," var g2 = parseInt(c2.substring(3, 5), 16);"," var b2 = parseInt(c2.substring(5, 7), 16);"," var r = Math.round(r1 * (1 - ratio) + r2 * ratio);"," var g = Math.round(g1 * (1 - ratio) + g2 * ratio);"," var b = Math.round(b1 * (1 - ratio) + b2 * ratio);"," r = ('0' + (r || 0).toString(16)).slice(-2);"," g = ('0' + (g || 0).toString(16)).slice(-2);"," b = ('0' + (b || 0).toString(16)).slice(-2);",
" return '#' + r + g + b;","}"])+"("+b+", "+c+", "+a+")",Blockly.JavaScript.ORDER_FUNCTION_CALL]};Blockly.JavaScript.procedures={};
Blockly.JavaScript.procedures_defreturn=function(a){var b=Blockly.JavaScript.variableDB_.getName(a.getFieldValue("NAME"),Blockly.Procedures.NAME_TYPE),c=Blockly.JavaScript.statementToCode(a,"STACK");Blockly.JavaScript.STATEMENT_PREFIX&&(c=Blockly.JavaScript.prefixLines(Blockly.JavaScript.STATEMENT_PREFIX.replace(/%1/g,"'"+a.id+"'"),Blockly.JavaScript.INDENT)+c);Blockly.JavaScript.INFINITE_LOOP_TRAP&&(c=Blockly.JavaScript.INFINITE_LOOP_TRAP.replace(/%1/g,"'"+a.id+"'")+c);var d=Blockly.JavaScript.valueToCode(a,
"RETURN",Blockly.JavaScript.ORDER_NONE)||"";d&&(d=" return "+d+";\n");for(var e=[],f=0;f<a.arguments_.length;f++)e[f]=Blockly.JavaScript.variableDB_.getName(a.arguments_[f],Blockly.Variables.NAME_TYPE);c="function "+b+"("+e.join(", ")+") {\n"+c+d+"}";c=Blockly.JavaScript.scrub_(a,c);Blockly.JavaScript.definitions_[b]=c;return null};Blockly.JavaScript.procedures_defnoreturn=Blockly.JavaScript.procedures_defreturn;
Blockly.JavaScript.procedures_callreturn=function(a){for(var b=Blockly.JavaScript.variableDB_.getName(a.getFieldValue("NAME"),Blockly.Procedures.NAME_TYPE),c=[],d=0;d<a.arguments_.length;d++)c[d]=Blockly.JavaScript.valueToCode(a,"ARG"+d,Blockly.JavaScript.ORDER_COMMA)||"null";return[b+"("+c.join(", ")+")",Blockly.JavaScript.ORDER_FUNCTION_CALL]};
@ -80,4 +67,17 @@ d+"', "+a+")",Blockly.JavaScript.ORDER_FUNCTION_CALL]};
Blockly.JavaScript.text_changeCase=function(a){var b={UPPERCASE:".toUpperCase()",LOWERCASE:".toLowerCase()",TITLECASE:null}[a.getFieldValue("CASE")];b?(a=Blockly.JavaScript.valueToCode(a,"TEXT",Blockly.JavaScript.ORDER_MEMBER)||"''",a+=b):(b=Blockly.JavaScript.provideFunction_("text_toTitleCase",["function "+Blockly.JavaScript.FUNCTION_NAME_PLACEHOLDER_+"(str) {"," return str.replace(/\\S+/g,"," function(txt) {return txt[0].toUpperCase() + txt.substring(1).toLowerCase();});","}"]),a=Blockly.JavaScript.valueToCode(a,
"TEXT",Blockly.JavaScript.ORDER_NONE)||"''",a=b+"("+a+")");return[a,Blockly.JavaScript.ORDER_FUNCTION_CALL]};Blockly.JavaScript.text_trim=function(a){var b={LEFT:".replace(/^[\\s\\xa0]+/, '')",RIGHT:".replace(/[\\s\\xa0]+$/, '')",BOTH:".trim()"}[a.getFieldValue("MODE")];return[(Blockly.JavaScript.valueToCode(a,"TEXT",Blockly.JavaScript.ORDER_MEMBER)||"''")+b,Blockly.JavaScript.ORDER_FUNCTION_CALL]};
Blockly.JavaScript.text_print=function(a){return"window.alert("+(Blockly.JavaScript.valueToCode(a,"TEXT",Blockly.JavaScript.ORDER_NONE)||"''")+");\n"};Blockly.JavaScript.text_prompt_ext=function(a){var b="window.prompt("+(a.getField("TEXT")?Blockly.JavaScript.quote_(a.getFieldValue("TEXT")):Blockly.JavaScript.valueToCode(a,"TEXT",Blockly.JavaScript.ORDER_NONE)||"''")+")";"NUMBER"==a.getFieldValue("TYPE")&&(b="parseFloat("+b+")");return[b,Blockly.JavaScript.ORDER_FUNCTION_CALL]};
Blockly.JavaScript.text_prompt=Blockly.JavaScript.text_prompt_ext;Blockly.JavaScript.variables={};Blockly.JavaScript.variables_get=function(a){return[Blockly.JavaScript.variableDB_.getName(a.getFieldValue("VAR"),Blockly.Variables.NAME_TYPE),Blockly.JavaScript.ORDER_ATOMIC]};Blockly.JavaScript.variables_set=function(a){var b=Blockly.JavaScript.valueToCode(a,"VALUE",Blockly.JavaScript.ORDER_ASSIGNMENT)||"0";return Blockly.JavaScript.variableDB_.getName(a.getFieldValue("VAR"),Blockly.Variables.NAME_TYPE)+" = "+b+";\n"};
Blockly.JavaScript.text_prompt=Blockly.JavaScript.text_prompt_ext;Blockly.JavaScript.control={};Blockly.JavaScript.control_repeat=function(a){var b=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);return a+("for (var "+d+" = 0; "+d+" < "+b+"; "+d+"++) {\n"+c+"}\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"};
Blockly.JavaScript.controls_for=function(a){var b=Blockly.JavaScript.variableDB_.getName(a.getFieldValue("VAR"),Blockly.Variables.NAME_TYPE),c=Blockly.JavaScript.valueToCode(a,"FROM",Blockly.JavaScript.ORDER_ASSIGNMENT)||"0",d=Blockly.JavaScript.valueToCode(a,"TO",Blockly.JavaScript.ORDER_ASSIGNMENT)||"0",e=Blockly.JavaScript.valueToCode(a,"BY",Blockly.JavaScript.ORDER_ASSIGNMENT)||"1",f=Blockly.JavaScript.statementToCode(a,"DO"),f=Blockly.JavaScript.addLoopTrap(f,a.id);if(Blockly.isNumber(c)&&Blockly.isNumber(d)&&
Blockly.isNumber(e)){var g=parseFloat(c)<=parseFloat(d);a="for ("+b+" = "+c+"; "+b+(g?" <= ":" >= ")+d+"; "+b;b=Math.abs(parseFloat(e));a=(1==b?a+(g?"++":"--"):a+((g?" += ":" -= ")+b))+(") {\n"+f+"}\n")}else a="",g=c,c.match(/^\w+$/)||Blockly.isNumber(c)||(g=Blockly.JavaScript.variableDB_.getDistinctName(b+"_start",Blockly.Variables.NAME_TYPE),a+="var "+g+" = "+c+";\n"),c=d,d.match(/^\w+$/)||Blockly.isNumber(d)||(c=Blockly.JavaScript.variableDB_.getDistinctName(b+"_end",Blockly.Variables.NAME_TYPE),
a+="var "+c+" = "+d+";\n"),d=Blockly.JavaScript.variableDB_.getDistinctName(b+"_inc",Blockly.Variables.NAME_TYPE),a+="var "+d+" = ",a=Blockly.isNumber(e)?a+(Math.abs(e)+";\n"):a+("Math.abs("+e+");\n"),a+="if ("+g+" > "+c+") {\n",a+=Blockly.JavaScript.INDENT+d+" = -"+d+";\n",a+="}\n",a+="for ("+b+" = "+g+";\n "+d+" >= 0 ? "+b+" <= "+c+" : "+b+" >= "+c+";\n "+b+" += "+d+") {\n"+f+"}\n";return a};
Blockly.JavaScript.controls_forEach=function(a){var b=Blockly.JavaScript.variableDB_.getName(a.getFieldValue("VAR"),Blockly.Variables.NAME_TYPE),c=Blockly.JavaScript.valueToCode(a,"LIST",Blockly.JavaScript.ORDER_ASSIGNMENT)||"[]",d=Blockly.JavaScript.statementToCode(a,"DO"),d=Blockly.JavaScript.addLoopTrap(d,a.id);a="";var e=c;c.match(/^\w+$/)||(e=Blockly.JavaScript.variableDB_.getDistinctName(b+"_list",Blockly.Variables.NAME_TYPE),a+="var "+e+" = "+c+";\n");c=Blockly.JavaScript.variableDB_.getDistinctName(b+
"_index",Blockly.Variables.NAME_TYPE);d=Blockly.JavaScript.INDENT+b+" = "+e+"["+c+"];\n"+d;return a+("for (var "+c+" in "+e+") {\n"+d+"}\n")};Blockly.JavaScript.controls_flow_statements=function(a){switch(a.getFieldValue("FLOW")){case "BREAK":return"break;\n";case "CONTINUE":return"continue;\n"}throw"Unknown flow statement.";};Blockly.JavaScript.logic={};
Blockly.JavaScript.controls_if=function(a){for(var b=0,c=Blockly.JavaScript.valueToCode(a,"IF"+b,Blockly.JavaScript.ORDER_NONE)||"false",d=Blockly.JavaScript.statementToCode(a,"DO"+b),e="if ("+c+") {\n"+d+"}",b=1;b<=a.elseifCount_;b++)c=Blockly.JavaScript.valueToCode(a,"IF"+b,Blockly.JavaScript.ORDER_NONE)||"false",d=Blockly.JavaScript.statementToCode(a,"DO"+b),e+=" else if ("+c+") {\n"+d+"}";a.elseCount_&&(d=Blockly.JavaScript.statementToCode(a,"ELSE"),e+=" else {\n"+d+"}");return e+"\n"};
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]};

View file

@ -1,17 +1 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 19.2.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 48 48" style="enable-background:new 0 0 48 48;" xml:space="preserve">
<style type="text/css">
.st0{fill:#CC9823;}
.st1{fill:#FFFFFF;}
</style>
<path class="st0" d="M24,43.4H11.1c-1.8,0-3.2-1.4-3.2-3.2s1.4-3.2,3.2-3.2H24c5.3,0,9.7-4.3,9.7-9.7c0-5.3-4.3-9.7-9.7-9.7h-9.7
c-1.8,0-3.2-1.4-3.2-3.2s1.4-3.2,3.2-3.2H24c8.9,0,16.2,7.2,16.2,16.2C40.2,36.1,32.9,43.4,24,43.4z"/>
<path class="st0" d="M17.5,24c-0.8,0-1.7-0.3-2.3-0.9l-6.5-6.5c-1.3-1.3-1.3-3.3,0-4.6l6.5-6.5c1.3-1.3,3.3-1.3,4.6,0
c1.3,1.3,1.3,3.3,0,4.6l-4.2,4.2l4.2,4.2c1.3,1.3,1.3,3.3,0,4.6C19.2,23.7,18.4,24,17.5,24z"/>
<path class="st1" d="M24,42.6H11.1c-1.3,0-2.4-1.1-2.4-2.4s1.1-2.4,2.4-2.4H24c5.8,0,10.5-4.7,10.5-10.5c0-5.8-4.7-10.5-10.5-10.5
h-9.7c-1.3,0-2.4-1.1-2.4-2.4s1.1-2.4,2.4-2.4H24c8.5,0,15.3,6.9,15.3,15.3S32.5,42.6,24,42.6z"/>
<path class="st1" d="M17.5,23.2c-0.6,0-1.2-0.2-1.7-0.7L9.4,16c-0.9-0.9-0.9-2.5,0-3.4l6.5-6.5c0.9-0.9,2.5-0.9,3.4,0
c0.9,0.9,0.9,2.5,0,3.4l-4.7,4.7l4.7,4.7c0.9,0.9,0.9,2.5,0,3.4C18.8,23,18.2,23.2,17.5,23.2z"/>
</svg>
<svg id="9dce02ee-5dfa-4fe3-ab06-de76c03363d4" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 30.12 32.06"><defs><style>.b10cf7d3-67e1-4fe1-8394-45ab860180ba{fill:#cf8b17;}.\35 3930b19-b39b-41ac-92c6-a00c4c3b5231{fill:#ffab19;}.f5914cc2-3f5b-4d3d-85de-d930450e14ab{fill:#fff;}</style></defs><title>control_forever</title><path class="b10cf7d3-67e1-4fe1-8394-45ab860180ba" d="M13.77,25.34l0.06,0.33a5.69,5.69,0,0,0,.18.81c0.06,0.25.19,0.61,0.34,1A11.4,11.4,0,0,0,15,28.83a9.44,9.44,0,0,0,2.41,2.68,9,9,0,0,0,3.66,1.62,10,10,0,0,0,1.08.14c0.25,0,.58,0,0.92,0a8.52,8.52,0,0,0,4.82-1.75,10.12,10.12,0,0,0,1-.87,8.78,8.78,0,0,0,.62-0.76,5.32,5.32,0,0,0,.35-0.52L30,29.2,30,29.05a4,4,0,1,1,6.72,4.38c-0.07.11-.16,0.23-0.24,0.33l-0.28.34c-0.19.22-.44,0.56-0.81,0.94A16.58,16.58,0,0,1,34,36.37a17.57,17.57,0,0,1-2,1.44,15.86,15.86,0,0,1-5.75,2.06A15.15,15.15,0,0,1,21,39.75a16,16,0,0,1-1.62-.41,15,15,0,0,1-9.19-8.1,16.52,16.52,0,0,1-.78-2.16,15.63,15.63,0,0,1-.37-1.78,9.1,9.1,0,0,1-.11-1l0-.33A2.43,2.43,0,0,1,13.77,25.34Z" transform="translate(-8.95 -7.98)"/><path class="53930b19-b39b-41ac-92c6-a00c4c3b5231" d="M36.56,38.78a1.41,1.41,0,0,1-1-.42l-8.82-8.84a1.43,1.43,0,0,1,1-2.44h8.83A1.43,1.43,0,0,1,38,28.52v8.83a1.44,1.44,0,0,1-1.44,1.43h0Z" transform="translate(-8.95 -7.98)"/><path class="b10cf7d3-67e1-4fe1-8394-45ab860180ba" d="M27.74,27.58h8.83a0.93,0.93,0,0,1,.93.93v8.83a0.93,0.93,0,0,1-.94.93A0.91,0.91,0,0,1,35.91,38l-8.82-8.84a0.93,0.93,0,0,1,.66-1.59m0-1h0a1.93,1.93,0,0,0-1.37,3.29l8.82,8.84a1.91,1.91,0,0,0,1.36.57,1.94,1.94,0,0,0,1.94-1.93V28.52a1.93,1.93,0,0,0-1.93-1.93H27.75Z" transform="translate(-8.95 -7.98)"/><path class="f5914cc2-3f5b-4d3d-85de-d930450e14ab" d="M27.09,29.17L35.91,38a0.93,0.93,0,0,0,1.59-.66V28.52a0.93,0.93,0,0,0-.93-0.93H27.74A0.93,0.93,0,0,0,27.09,29.17Z" transform="translate(-8.95 -7.98)"/><path class="f5914cc2-3f5b-4d3d-85de-d930450e14ab" d="M12.66,25.47l0.06,0.33a7,7,0,0,0,.19.86,12.06,12.06,0,0,0,.39,1.19A12.46,12.46,0,0,0,14,29.33a10.53,10.53,0,0,0,2.69,3,10.11,10.11,0,0,0,4.09,1.82,11.12,11.12,0,0,0,1.18.15c0.31,0,.69,0,1.06,0a9.55,9.55,0,0,0,5.42-1.94,11.07,11.07,0,0,0,1.08-1,9.78,9.78,0,0,0,.71-0.85,6.22,6.22,0,0,0,.4-0.58l0.14-.21,0.08-.12a3,3,0,1,1,5,3.28,3.13,3.13,0,0,1-.19.26l-0.26.32c-0.18.2-.41,0.52-0.77,0.88a15.56,15.56,0,0,1-1.31,1.24A16.59,16.59,0,0,1,31.46,37a14.83,14.83,0,0,1-5.38,1.89,14.07,14.07,0,0,1-4.85-.14,15.13,15.13,0,0,1-1.53-.39,14.12,14.12,0,0,1-5.39-3.19,14,14,0,0,1-3.09-4.38,15.42,15.42,0,0,1-.71-2,14.36,14.36,0,0,1-.32-1.63,9,9,0,0,1-.1-1l0-.33A1.31,1.31,0,0,1,12.66,25.47Z" transform="translate(-8.95 -7.98)"/><path class="b10cf7d3-67e1-4fe1-8394-45ab860180ba" d="M34.25,22.67l-0.06-.33A5.7,5.7,0,0,0,34,21.54c-0.06-.25-0.19-0.61-0.34-1A11.39,11.39,0,0,0,33,19.18a9.44,9.44,0,0,0-2.41-2.68,9,9,0,0,0-3.66-1.62,10,10,0,0,0-1.08-.14c-0.25,0-.58,0-0.92,0a8.52,8.52,0,0,0-4.82,1.75,10.1,10.1,0,0,0-1,.87,8.75,8.75,0,0,0-.62.76,5.34,5.34,0,0,0-.35.52l-0.12.18L18,19a4,4,0,0,1-6.72-4.38c0.07-.11.16-0.23,0.24-0.33l0.28-.34c0.19-.22.44-0.56,0.82-0.94A16.57,16.57,0,0,1,14,11.64a17.59,17.59,0,0,1,2-1.44,15.86,15.86,0,0,1,5.75-2.06A15.46,15.46,0,0,1,25.17,8,15.64,15.64,0,0,1,27,8.26a16,16,0,0,1,1.62.41,15,15,0,0,1,9.19,8.1,16.52,16.52,0,0,1,.78,2.16,15.63,15.63,0,0,1,.37,1.78,9.08,9.08,0,0,1,.11,1l0,0.33A2.43,2.43,0,0,1,34.25,22.67Z" transform="translate(-8.95 -7.98)"/><path class="53930b19-b39b-41ac-92c6-a00c4c3b5231" d="M11.44,20.92A1.43,1.43,0,0,1,10,19.49V10.66a1.44,1.44,0,0,1,1.44-1.43,1.41,1.41,0,0,1,1,.42l8.82,8.84a1.43,1.43,0,0,1-1,2.44H11.44Z" transform="translate(-8.95 -7.98)"/><path class="b10cf7d3-67e1-4fe1-8394-45ab860180ba" d="M11.46,9.73a0.91,0.91,0,0,1,.65.27l8.82,8.84a0.93,0.93,0,0,1-.66,1.59H11.44a0.93,0.93,0,0,1-.93-0.93V10.66a0.93,0.93,0,0,1,.94-0.93m0-1a1.94,1.94,0,0,0-1.94,1.93v8.83a1.93,1.93,0,0,0,1.93,1.93h8.83a1.93,1.93,0,0,0,1.37-3.29L12.82,9.3a1.91,1.91,0,0,0-1.36-.57h0Z" transform="translate(-8.95 -7.98)"/><path class="f5914cc2-3f5b-4d3d-85de-d930450e14ab" d="M20.93,18.84L12.11,10a0.93,0.93,0,0,0-1.59.66v8.83a0.93,0.93,0,0,0,.93.93h8.83A0.93,0.93,0,0,0,20.93,18.84Z" transform="translate(-8.95 -7.98)"/><path class="f5914cc2-3f5b-4d3d-85de-d930450e14ab" d="M35.35,22.54l-0.06-.33a7,7,0,0,0-.19-0.86,12.08,12.08,0,0,0-.39-1.19A12.45,12.45,0,0,0,34,18.68a10.53,10.53,0,0,0-2.69-3,10.11,10.11,0,0,0-4.09-1.82A11.06,11.06,0,0,0,26,13.7c-0.31,0-.69,0-1.06,0a9.55,9.55,0,0,0-5.42,1.94,11.09,11.09,0,0,0-1.08,1,9.78,9.78,0,0,0-.71.85,6.22,6.22,0,0,0-.4.58l-0.14.21-0.08.12a3,3,0,0,1-5-3.28,3.1,3.1,0,0,1,.19-0.26l0.26-.32c0.18-.2.41-0.52,0.77-0.88a15.57,15.57,0,0,1,1.31-1.24,16.56,16.56,0,0,1,1.9-1.33,14.83,14.83,0,0,1,5.38-1.89,14.08,14.08,0,0,1,4.85.14,15.13,15.13,0,0,1,1.53.39,14.12,14.12,0,0,1,5.39,3.19,14,14,0,0,1,3.09,4.38,15.43,15.43,0,0,1,.71,2,14.37,14.37,0,0,1,.32,1.63,8.94,8.94,0,0,1,.1,1l0,0.33A1.31,1.31,0,0,1,35.35,22.54Z" transform="translate(-8.95 -7.98)"/></svg>

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 4.8 KiB

Before After
Before After

View file

@ -0,0 +1 @@
<svg id="ad39a354-f9c4-4215-91cf-8efe7a0b3cbc" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24.71 33.12"><defs><style>.ce0a9b14-7d5e-4df6-8987-9c322028ec44{fill:#ffab19;}.bbcb34a3-2c18-4787-8b6a-84cf60f33763{fill:#cf8b17;}.\37 30754f1-9a53-43fd-b548-938220956cb1{fill:#fff;}</style></defs><title>control_repeat</title><path class="ce0a9b14-7d5e-4df6-8987-9c322028ec44" d="M20.82,24.63a1.54,1.54,0,0,1-1.09-.46l-7.1-7.08a1.56,1.56,0,0,1,0-2.2l7.08-7.09a1.54,1.54,0,0,1,1.09-.46,1.56,1.56,0,0,1,1.56,1.56V23.07a1.54,1.54,0,0,1-.45,1.1A1.59,1.59,0,0,1,20.82,24.63Z" transform="translate(-11.68 -6.83)"/><path class="bbcb34a3-2c18-4787-8b6a-84cf60f33763" d="M20.81,7.83a1.05,1.05,0,0,1,1.06,1.06V23.07a1.05,1.05,0,0,1-1.06,1.06,1,1,0,0,1-.74-0.31L13,16.73a1.06,1.06,0,0,1,0-1.49l7.08-7.1a1,1,0,0,1,.74-0.31m0-1h0a2,2,0,0,0-1.45.61l-7.08,7.1a2.06,2.06,0,0,0,0,2.91l7.1,7.08a2,2,0,0,0,1.44.6,2.07,2.07,0,0,0,1.42-.56,2,2,0,0,0,.64-1.5V8.89a2.06,2.06,0,0,0-2.06-2.06h0Z" transform="translate(-11.68 -6.83)"/><path class="bbcb34a3-2c18-4787-8b6a-84cf60f33763" d="M22.33,34l0.42,0,0.5,0h0.15l0.09,0,0.2,0a7.12,7.12,0,0,0,1.19-.35,5.6,5.6,0,0,0,.73-0.33,5,5,0,0,0,.76-0.45,6.73,6.73,0,0,0,1.48-1.33A6.63,6.63,0,0,0,29,29.57a6.94,6.94,0,0,0,.55-2.24c0-.19,0-0.4,0-0.59V26.5h0s0,0.32,0,.16V26.6l0-.44A5.23,5.23,0,0,0,29.37,25a7.06,7.06,0,0,0-2.47-3.74,7.76,7.76,0,0,0-1.79-1,7.24,7.24,0,0,0-1.77-.39c-0.28,0-.55,0-0.81,0l-1.11,0-1.85.07L18,20a4,4,0,1,1-.29-8H18L19.58,12l1.85,0.07,1.17,0a16.49,16.49,0,0,1,1.71.15A14.75,14.75,0,0,1,28,13.37a15.08,15.08,0,0,1,3.59,2.3,14.18,14.18,0,0,1,4.53,7.84,13.82,13.82,0,0,1,.25,2.3v0.88l0,0.29c0,0.38,0,.76-0.1,1.14a13.58,13.58,0,0,1-1.31,4.25A13.74,13.74,0,0,1,29.69,38a10.73,10.73,0,0,1-1.45.75,11.53,11.53,0,0,1-1.37.52,12.69,12.69,0,0,1-2.4.53L24,39.9l-0.39,0H22.63A3,3,0,0,1,22.33,34Z" transform="translate(-11.68 -6.83)"/><path class="730754f1-9a53-43fd-b548-938220956cb1" d="M21.87,8.89V23.07a1.06,1.06,0,0,1-1.8.75L13,16.73a1.06,1.06,0,0,1,0-1.49l7.08-7.1A1.06,1.06,0,0,1,21.87,8.89Z" transform="translate(-11.68 -6.83)"/><path class="730754f1-9a53-43fd-b548-938220956cb1" d="M22.38,35l0.42,0a5.66,5.66,0,0,0,1-.13,7.82,7.82,0,0,0,1.38-.39A6.47,6.47,0,0,0,26,34.07a5.81,5.81,0,0,0,.87-0.51,7.67,7.67,0,0,0,1.68-1.49A7.59,7.59,0,0,0,29.89,30a7.9,7.9,0,0,0,.64-2.53c0-.22,0-0.45,0-0.67V26.5h0s0,0.22,0,.11V26.55l0-.44a6.77,6.77,0,0,0-.21-1.34,8,8,0,0,0-2.78-4.29,8.73,8.73,0,0,0-2-1.16,8.22,8.22,0,0,0-2-.46c-0.32-.05-0.63,0-0.92,0l-1.12,0-1.85.06L18,19a3,3,0,1,1-.21-6H18L19.58,13l1.85,0.06,1.16,0a15.59,15.59,0,0,1,1.59.14,13.77,13.77,0,0,1,3.44,1A14.1,14.1,0,0,1,31,16.42a13.2,13.2,0,0,1,4.21,7.3,12.89,12.89,0,0,1,.23,2.14v0.81l0,0.27c0,0.36,0,.71-0.1,1.06a12.61,12.61,0,0,1-1.22,4,12.78,12.78,0,0,1-4.88,5.27,9.83,9.83,0,0,1-1.35.7,10.59,10.59,0,0,1-1.28.49,11.72,11.72,0,0,1-2.21.49A9.21,9.21,0,0,1,23,39H22.58A2,2,0,0,1,22.38,35Z" transform="translate(-11.68 -6.83)"/></svg>

After

Width:  |  Height:  |  Size: 2.9 KiB

View file

@ -0,0 +1 @@
<svg id="2fc1d17e-9f65-4f7c-8b61-7ff27c05545c" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 36.32 36.32"><defs><style>.\35 8ccf0a6-fd25-4bd8-b50c-4127ab2beb86{fill:#ec9c13;}.cb59c955-5d7f-4993-b9b6-8ae4cc27e09e{fill:#fff;stroke:#cf8b17;stroke-linecap:round;stroke-linejoin:round;}.e4366cc0-d1f5-458b-8531-27bc1636e030{fill:#070707;opacity:0.1;}</style></defs><title>control_stop</title><path class="58ccf0a6-fd25-4bd8-b50c-4127ab2beb86" d="M32.66,6l9,9A2.71,2.71,0,0,1,42.51,17v12.8a2.71,2.71,0,0,1-.79,1.92l-9,9a2.71,2.71,0,0,1-1.92.79H18A2.71,2.71,0,0,1,16,40.75l-9-9a2.71,2.71,0,0,1-.79-1.92V17A2.71,2.71,0,0,1,7,15.07l9-9A2.71,2.71,0,0,1,18,5.23h12.8A2.71,2.71,0,0,1,32.66,6Z" transform="translate(-6.19 -5.23)"/><path class="cb59c955-5d7f-4993-b9b6-8ae4cc27e09e" d="M26.82,19.54l0.72-7.6a1.56,1.56,0,0,1,1.7-1.66c1.73,0.13,1.48,2,1.48,2l-0.6,6.37s-0.28,5.49.75,6.4a8.45,8.45,0,0,1,2.48-3C35,21,35.1,19.41,37.43,20s0.5,2.51,0,3.2S35,27.61,34.29,29s-3.2,4.61-4,4.85a8.49,8.49,0,0,1-1.41.28l-0.57,1.55S28.26,37,23,37s-5.56-1.65-5.56-1.65a12.5,12.5,0,0,0,0-3.3c-0.28-.75-1.46-1.37-1.65-3.67S15,16.4,15,16.4s-0.38-2,1.18-2.17,1.55,1.65,1.55,2.12,0.38,5.27.38,5.27L19,21.3,18.7,12.82s-0.42-2.07,1.46-2.31,1.74,2.17,1.74,2.17l0.38,7.91,0.33-.09,0.28-9.79S22.7,8.4,24.49,8.35,26,10.66,26,10.66l0,8.95Z" transform="translate(-6.19 -5.23)"/><path class="e4366cc0-d1f5-458b-8531-27bc1636e030" d="M30.4,24.12a8.91,8.91,0,0,0-5.94,2.72c-2.16,2.28-1.75,3.07-1.37,3s0.47-.93,2.06-2.28a12.05,12.05,0,0,1,5.72-2.5Z" transform="translate(-6.19 -5.23)"/></svg>

After

Width:  |  Height:  |  Size: 1.5 KiB

View file

@ -0,0 +1 @@
<svg id="251060d0-24ac-47b6-b9f8-dcee1324b5a1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 29.63 33.62"><defs><style>.db614437-ae43-484e-9f98-dc6e68c24d00{fill:#cf8b17;}.\34 9d88d05-fd01-4ae3-9cfd-2eba84ebc112{fill:#fff;}.\30 058a59a-74a3-4494-9001-a2cf4da76b81,.\32 4f524ee-46f6-48ff-bd7a-f2023c4b2eec,.\34 9d88d05-fd01-4ae3-9cfd-2eba84ebc112{stroke:#cf8b17;stroke-miterlimit:10;}.a1267e51-402f-44e1-be41-116232209772{fill:#070707;opacity:0.1;}.\32 4f524ee-46f6-48ff-bd7a-f2023c4b2eec,.fc16d8b2-4b6d-429d-b23f-804e20b57326{fill:#ffab19;}.fc16d8b2-4b6d-429d-b23f-804e20b57326{opacity:0.5;}.\30 058a59a-74a3-4494-9001-a2cf4da76b81{fill:none;stroke-width:1.5px;}</style></defs><title>control_wait</title><rect class="db614437-ae43-484e-9f98-dc6e68c24d00" x="12.24" width="5.6" height="3.29" rx="1.39" ry="1.39"/><rect class="db614437-ae43-484e-9f98-dc6e68c24d00" x="13.6" y="2.88" width="2.8" height="1.79"/><ellipse class="49d88d05-fd01-4ae3-9cfd-2eba84ebc112" cx="14.82" cy="18.77" rx="14.07" ry="14.1"/><path class="a1267e51-402f-44e1-be41-116232209772" d="M38.93,26A14.07,14.07,0,1,1,10.8,26a14.6,14.6,0,0,1,.14-2,14.06,14.06,0,0,0,27.85,0A14.6,14.6,0,0,1,38.93,26Z" transform="translate(-10.04 -7.22)"/><path class="db614437-ae43-484e-9f98-dc6e68c24d00" d="M35.2,13h1.62a0.6,0.6,0,0,1,.6.6v1.8a1.19,1.19,0,0,1-1.19,1.19H35.79a1.19,1.19,0,0,1-1.19-1.19v-1.8A0.6,0.6,0,0,1,35.2,13Z" transform="translate(10.9 -28.33) rotate(44.91)"/><path class="fc16d8b2-4b6d-429d-b23f-804e20b57326" d="M25,14.59V27.42L35.06,21S33,14.66,25,14.59Z" transform="translate(-10.04 -7.22)"/><rect class="db614437-ae43-484e-9f98-dc6e68c24d00" x="23.43" y="22.5" width="13.2" height="1.98" rx="0.88" ry="0.88" transform="translate(-17.67 10.32) rotate(-29.05)"/><ellipse class="0058a59a-74a3-4494-9001-a2cf4da76b81" cx="14.82" cy="18.77" rx="14.07" ry="14.1"/><circle class="24f524ee-46f6-48ff-bd7a-f2023c4b2eec" cx="15.35" cy="18.54" r="1.75"/></svg>

After

Width:  |  Height:  |  Size: 1.9 KiB

View file

@ -0,0 +1 @@
<svg id="4792f792-1d28-491a-9bb5-ebc58d69bbb0" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 37.76 21.81"><defs><style>.\35 787807a-c781-4950-9776-5aa0f9ec2915,.ebd44fa2-be35-497d-8d7e-da4ce04d4c34{fill:#96f;}.\35 a941e99-6bc2-4e22-b809-bda40fce7c75{fill:#231f20;stroke:#231f20;opacity:0.1;}.\35 0696b67-a80c-4484-a848-ebfb166c8e27,.\35 a941e99-6bc2-4e22-b809-bda40fce7c75,.ebd44fa2-be35-497d-8d7e-da4ce04d4c34,.ee6efca6-59a2-438f-ac94-07ff07bebd40{stroke-linecap:round;stroke-linejoin:round;}.\35 0696b67-a80c-4484-a848-ebfb166c8e27,.ee6efca6-59a2-438f-ac94-07ff07bebd40{fill:none;}.\35 0696b67-a80c-4484-a848-ebfb166c8e27,.ebd44fa2-be35-497d-8d7e-da4ce04d4c34{stroke:#774dcb;}.ee6efca6-59a2-438f-ac94-07ff07bebd40{stroke:#fff;stroke-width:1.5px;}</style></defs><title>event_messagesend</title><path class="5787807a-c781-4950-9776-5aa0f9ec2915" d="M40.75,34.52H16.13a1.75,1.75,0,0,1-1.75-1.76l0.1-17.3a1.75,1.75,0,0,1,1.75-1.74H40.75a1.75,1.75,0,0,1,1.75,1.75v17.3A1.75,1.75,0,0,1,40.75,34.52Z" transform="translate(-5.25 -13.22)"/><path class="5a941e99-6bc2-4e22-b809-bda40fce7c75" d="M22.31,27.87L14.93,34a1.52,1.52,0,0,0,1.2.47Z" transform="translate(-5.25 -13.22)"/><path class="5a941e99-6bc2-4e22-b809-bda40fce7c75" d="M34.72,27.87L42.1,34a1.52,1.52,0,0,1-1.2.47Z" transform="translate(-5.25 -13.22)"/><polyline class="50696b67-a80c-4484-a848-ebfb166c8e27" points="10.11 20.43 23.25 9.5 36.38 20.43"/><path class="5a941e99-6bc2-4e22-b809-bda40fce7c75" d="M42.51,16.47L30.66,28.8a3,3,0,0,1-4.33,0L14.48,16.46h28Z" transform="translate(-5.25 -13.22)"/><path class="ebd44fa2-be35-497d-8d7e-da4ce04d4c34" d="M42.51,15.47L30.45,25.83a3,3,0,0,1-3.91,0L14.49,15.46" transform="translate(-5.25 -13.22)"/><line class="ee6efca6-59a2-438f-ac94-07ff07bebd40" x1="6.75" y1="2.78" x2="4.28" y2="2.78"/><line class="ee6efca6-59a2-438f-ac94-07ff07bebd40" x1="6.75" y1="10.81" x2="4.28" y2="10.81"/><line class="ee6efca6-59a2-438f-ac94-07ff07bebd40" x1="6.75" y1="18.78" x2="4.28" y2="18.78"/><line class="ee6efca6-59a2-438f-ac94-07ff07bebd40" x1="6.75" y1="14.78" x2="0.75" y2="14.78"/><line class="ee6efca6-59a2-438f-ac94-07ff07bebd40" x1="6.75" y1="6.78" x2="0.75" y2="6.78"/><path class="50696b67-a80c-4484-a848-ebfb166c8e27" d="M40.75,34.52H16.13a1.75,1.75,0,0,1-1.75-1.76l0.1-17.3a1.75,1.75,0,0,1,1.75-1.74H40.75a1.75,1.75,0,0,1,1.75,1.75v17.3A1.75,1.75,0,0,1,40.75,34.52Z" transform="translate(-5.25 -13.22)"/></svg>

After

Width:  |  Height:  |  Size: 2.4 KiB

View file

@ -0,0 +1 @@
<svg id="45ed7241-5e19-43ad-a9a3-700778291c9c" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 37.38 36.28"><defs><style>.a0ad6acc-4020-41fb-a57b-72685135fca0{fill:#96f;}.a0ad6acc-4020-41fb-a57b-72685135fca0,.f897a734-5276-40b8-b400-52c1293f2475{stroke:#774dcb;}.a0ad6acc-4020-41fb-a57b-72685135fca0,.b71db816-5d92-4f3b-95c8-3db323c6ed55,.d862eeda-2ec7-4e50-8664-cd1379004859,.f897a734-5276-40b8-b400-52c1293f2475{stroke-linecap:round;stroke-linejoin:round;}.f897a734-5276-40b8-b400-52c1293f2475{fill:#f9f8ff;}.d862eeda-2ec7-4e50-8664-cd1379004859{fill:#231f20;stroke:#231f20;opacity:0.1;}.b71db816-5d92-4f3b-95c8-3db323c6ed55{fill:none;stroke:#fff;stroke-width:1.5px;}</style></defs><title>event_messagereceive</title><path class="a0ad6acc-4020-41fb-a57b-72685135fca0" d="M38,41H9.87a2,2,0,0,1-2-2L8,22a2,2,0,0,1,.8-1.59L22.8,9.9a2,2,0,0,1,2.4,0l14,10.5A2,2,0,0,1,40,22V39A2,2,0,0,1,38,41Z" transform="translate(-5.3 -5.22)"/><rect class="f897a734-5276-40b8-b400-52c1293f2475" x="6.7" y="7.78" width="24" height="20" rx="2" ry="2"/><path class="d862eeda-2ec7-4e50-8664-cd1379004859" d="M40,22v1L29.88,29.33l-3,1.84-1.87,1.17a2,2,0,0,1-2.12,0L21,31.16l-3-1.85L8,23V21.76a2,2,0,0,1,.79-1.35l0.67-.5,11.6,7.24,1.74-1.26a2,2,0,0,1,2.39,0l1.74,1.27,11.61-7.25L39.2,20.4A2,2,0,0,1,40,22Z" transform="translate(-5.3 -5.22)"/><path class="a0ad6acc-4020-41fb-a57b-72685135fca0" d="M40,23L25.06,32.34a2,2,0,0,1-2.12,0L8,23V39a2,2,0,0,0,2,2H38a2,2,0,0,0,2-2V23Z" transform="translate(-5.3 -5.22)"/><path class="a0ad6acc-4020-41fb-a57b-72685135fca0" d="M8.86,40L22.8,29.89a2,2,0,0,1,2.39,0L39,40" transform="translate(-5.3 -5.22)"/><line class="b71db816-5d92-4f3b-95c8-3db323c6ed55" x1="10.52" y1="3.92" x2="8.85" y2="0.75"/><line class="b71db816-5d92-4f3b-95c8-3db323c6ed55" x1="4" y1="10.82" x2="0.75" y2="8.37"/><line class="b71db816-5d92-4f3b-95c8-3db323c6ed55" x1="26.87" y1="3.92" x2="28.53" y2="0.75"/><line class="b71db816-5d92-4f3b-95c8-3db323c6ed55" x1="33.38" y1="10.82" x2="36.63" y2="8.37"/></svg>

After

Width:  |  Height:  |  Size: 2 KiB

View file

@ -1,11 +0,0 @@
<?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>

Before

Width:  |  Height:  |  Size: 849 B

View file

@ -1,37 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 19.2.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 76 76" style="enable-background:new 0 0 76 76;" xml:space="preserve">
<style type="text/css">
.st0{fill:#308BA0;}
.st1{fill:#FFFFFF;}
</style>
<g>
<path class="st0" d="M17.2,33.1c0-3-2.4-5.4-5.4-5.4h-1.4c-3,0-5.4,2.4-5.4,5.4v10.8c0,3,2.4,5.4,5.4,5.4h1.4c3,0,5.4-2.4,5.4-5.4
V33.1z"/>
<path class="st1" d="M15.8,33.1c0-2.2-1.8-4.1-4.1-4.1h-1.4c-2.2,0-4.1,1.8-4.1,4.1v10.8c0,2.2,1.8,4.1,4.1,4.1h1.4
c2.2,0,4.1-1.8,4.1-4.1V33.1z"/>
</g>
<g>
<path class="st0" d="M30.7,33.1c0-3-2.4-5.4-5.4-5.4h-1.4c-3,0-5.4,2.4-5.4,5.4v10.8c0,3,2.4,5.4,5.4,5.4h1.4c3,0,5.4-2.4,5.4-5.4
V33.1z"/>
<path class="st1" d="M29.3,33.1c0-2.2-1.8-4.1-4.1-4.1h-1.4c-2.2,0-4.1,1.8-4.1,4.1v10.8c0,2.2,1.8,4.1,4.1,4.1h1.4
c2.2,0,4.1-1.8,4.1-4.1V33.1z"/>
</g>
<g id="Layer_2">
<g id="fd">
<g>
<path class="st0" d="M32.2,32.2c0-1.2,0.4-2.3,1.2-3.1c1.1-0.9,2.5-1.4,4-1.2l3.5,0.6c0.7,0.1,1.4-0.1,1.7-0.4
c0.2-0.2,0.4-0.5,0.4-0.8c0-0.1-0.4-5.7-0.4-5.7c0-0.1,0-0.4,0-0.6c0-2.3,1.6-4.9,6.1-4.9c4.8,0,17,14.1,20.7,18.6
c1,0.9,1.5,2.1,1.5,3.4c0,1.3-0.5,2.5-1.5,3.4C66.8,44.7,54.2,60,48.8,60c-1.9,0-3.4-0.4-4.5-1.3c-1-0.8-1.6-2.1-1.6-3.5l0,0
c0-0.2,0-0.5,0-0.8l0.3-5.4c0-0.1,0-0.2,0-0.3c0-0.3-0.1-0.6-0.4-0.8c-0.4-0.4-1-0.5-1.8-0.4l-3.5,0.6c-1.6,0.2-2.9-0.3-4-1.2
c-0.9-0.8-1.3-1.9-1.3-3.1L32.2,32.2L32.2,32.2z"/>
</g>
<g>
<path class="st1" d="M68.5,40.5c1.5-1.4,1.5-3.6,0-5c0,0-15.2-18.2-19.8-18.2c-3.4,0-4.9,1.8-4.7,4.1l0.3,5.5
c0.2,1.9-1.4,3.2-3.6,3l-3.5-0.6c-2.2-0.2-3.7,0.9-3.7,2.8v12.2c0,1.9,1.5,3,3.7,2.8l3.5-0.6c2.2-0.2,3.8,1.1,3.6,3l-0.3,5.5
c-0.3,2.2,0.9,4.1,4.7,4.1C53.9,58.7,68.5,40.5,68.5,40.5z"/>
</g>
</g>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 1.9 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 5.7 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 5.6 KiB

View file

@ -0,0 +1 @@
<svg id="3f1d0737-81cd-4793-8d78-bcac7820ec61" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 33 29.46"><defs><style>.e798989a-bb16-43ff-b95a-8f1592d6ed78{fill:#fff;stroke:#3d79cc;}.\32 b6cc367-e2ff-4d28-bece-868d91a27c1c,.\33 9e8da49-5b4e-4b39-b20d-bc79457dcc1b,.\36 b833640-c4fa-4456-9874-9ca8ebad992e,.bbcbfca2-2563-43f3-beb7-8f5fc0933af9,.dc6eeea6-c445-485b-9b47-8e52f4b6bd9e,.e798989a-bb16-43ff-b95a-8f1592d6ed78{stroke-linecap:round;stroke-linejoin:round;}.\32 b6cc367-e2ff-4d28-bece-868d91a27c1c,.dc6eeea6-c445-485b-9b47-8e52f4b6bd9e{fill:none;}.\32 b6cc367-e2ff-4d28-bece-868d91a27c1c,.bbcbfca2-2563-43f3-beb7-8f5fc0933af9,.dc6eeea6-c445-485b-9b47-8e52f4b6bd9e{stroke:#4c97ff;}.\32 b6cc367-e2ff-4d28-bece-868d91a27c1c{opacity:0.5;}.\36 b833640-c4fa-4456-9874-9ca8ebad992e{fill:#231f20;stroke:#231f20;opacity:0.1;}.\33 9e8da49-5b4e-4b39-b20d-bc79457dcc1b{fill:#ffab19;stroke:#cf8b17;}.bbcbfca2-2563-43f3-beb7-8f5fc0933af9{fill:#4c97ff;opacity:0.3;}.dc6eeea6-c445-485b-9b47-8e52f4b6bd9e{stroke-width:1.5px;}</style></defs><title>motion_motorspeed</title><path class="e798989a-bb16-43ff-b95a-8f1592d6ed78" d="M40,23.74a16,16,0,0,1-5.28,13.18,2,2,0,0,1-2.89-.24,10,10,0,0,0-15.52,0,2,2,0,0,1-2.9.24A16,16,0,1,1,40,23.74Z" transform="translate(-7.5 -8.5)"/><line class="2b6cc367-e2ff-4d28-bece-868d91a27c1c" x1="16.5" y1="4.5" x2="16.5" y2="2.5"/><line class="2b6cc367-e2ff-4d28-bece-868d91a27c1c" x1="11.91" y1="5.41" x2="11.14" y2="3.57"/><line class="2b6cc367-e2ff-4d28-bece-868d91a27c1c" x1="8.01" y1="8.02" x2="6.6" y2="6.6"/><line class="2b6cc367-e2ff-4d28-bece-868d91a27c1c" x1="26.4" y1="26.4" x2="24.99" y2="24.99"/><line class="2b6cc367-e2ff-4d28-bece-868d91a27c1c" x1="5.41" y1="11.91" x2="3.56" y2="11.14"/><line class="2b6cc367-e2ff-4d28-bece-868d91a27c1c" x1="29.44" y1="21.86" x2="27.59" y2="21.1"/><line class="2b6cc367-e2ff-4d28-bece-868d91a27c1c" x1="4.5" y1="16.5" x2="2.5" y2="16.5"/><line class="2b6cc367-e2ff-4d28-bece-868d91a27c1c" x1="30.5" y1="16.5" x2="28.5" y2="16.5"/><line class="2b6cc367-e2ff-4d28-bece-868d91a27c1c" x1="5.41" y1="21.1" x2="3.56" y2="21.86"/><line class="2b6cc367-e2ff-4d28-bece-868d91a27c1c" x1="29.44" y1="11.14" x2="27.59" y2="11.91"/><line class="2b6cc367-e2ff-4d28-bece-868d91a27c1c" x1="8.01" y1="24.99" x2="6.6" y2="26.4"/><line class="2b6cc367-e2ff-4d28-bece-868d91a27c1c" x1="26.4" y1="6.6" x2="24.99" y2="8.02"/><circle class="6b833640-c4fa-4456-9874-9ca8ebad992e" cx="16.52" cy="17.15" r="2.73"/><line class="2b6cc367-e2ff-4d28-bece-868d91a27c1c" x1="21.86" y1="3.57" x2="21.09" y2="5.41"/><path class="39e8da49-5b4e-4b39-b20d-bc79457dcc1b" d="M21.48,24.9h0a2.61,2.61,0,0,1,1.28-2.24l8.89-5.28-5.32,8.87a2.61,2.61,0,0,1-2.24,1.27h0A2.61,2.61,0,0,1,21.48,24.9Z" transform="translate(-7.5 -8.5)"/><path class="bbcbfca2-2563-43f3-beb7-8f5fc0933af9" d="M37.67,25.82c-0.85-6.18-6.36-12.07-13-12.39-7.32-.34-13.46,5.73-14.37,12.38a10.92,10.92,0,0,1-.12-1.69c0-7.47,6.56-13.48,14.49-13.11,6.85,0.33,12.52,5.57,13,12.07A13.08,13.08,0,0,1,37.67,25.82Z" transform="translate(-7.5 -8.5)"/><path class="dc6eeea6-c445-485b-9b47-8e52f4b6bd9e" d="M22.36,15.34A9.94,9.94,0,0,1,24,15.2a9.83,9.83,0,0,1,4.71,1.19" transform="translate(-7.5 -8.5)"/><path class="dc6eeea6-c445-485b-9b47-8e52f4b6bd9e" d="M17.1,18a9.9,9.9,0,0,1,2.53-1.8" transform="translate(-7.5 -8.5)"/><path class="dc6eeea6-c445-485b-9b47-8e52f4b6bd9e" d="M19.87,19.94a6.41,6.41,0,0,1,5.62-1.37" transform="translate(-7.5 -8.5)"/></svg>

After

Width:  |  Height:  |  Size: 3.4 KiB

View file

@ -0,0 +1 @@
<svg id="f7884830-71b4-419d-a605-0ff01123c17d" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24.07 36.68"><defs><style>.\33 f4a0a0c-d779-4d3c-9d06-08f104bd1007,.b8aa6e53-d4f1-4ae4-9e0b-b2eb807b441f{fill:#fff;}.\33 d286c7f-088a-458a-baec-3889458eaae1{fill:#31d8ff;}.cc492f85-2991-4d56-8cef-73981bcf87a5{fill:#33ff8a;}.ae63b835-46a7-49fe-a786-672d6aee0b42{fill:#e6ff33;}.b101ce40-36f9-45c5-a7b5-2495b241b01f{fill:#ff339e;}.\30 7b31d7d-790c-498f-8eb1-e36f1780ea32{fill:#ffa233;}.f94daa82-101e-4af8-858e-37f3e50f826c{fill:#f35;}.\38 5d2ea03-5073-4611-915d-3495fb9886c4{fill:none;stroke:#774dcb;stroke-linecap:round;stroke-linejoin:round;}.\33 f4a0a0c-d779-4d3c-9d06-08f104bd1007{opacity:0.5;}</style></defs><title>looks_ledcolor</title><path class="b8aa6e53-d4f1-4ae4-9e0b-b2eb807b441f" d="M24,26.71" transform="translate(-11.99 -5.63)"/><path class="b8aa6e53-d4f1-4ae4-9e0b-b2eb807b441f" d="M24,26.71" transform="translate(-11.99 -5.63)"/><path class="b8aa6e53-d4f1-4ae4-9e0b-b2eb807b441f" d="M24,26.71" transform="translate(-11.99 -5.63)"/><path class="b8aa6e53-d4f1-4ae4-9e0b-b2eb807b441f" d="M24,26.71" transform="translate(-11.99 -5.63)"/><path class="3d286c7f-088a-458a-baec-3889458eaae1" d="M32.18,25.82a8.57,8.57,0,0,0-2.43,5.26H18.3a8.57,8.57,0,0,0-2.43-5.26A11.53,11.53,0,1,1,32.18,25.82Z" transform="translate(-11.99 -5.63)"/><path class="3d286c7f-088a-458a-baec-3889458eaae1" d="M31.25,26.92a8.64,8.64,0,0,0-1.49,4.15H18.3a8.64,8.64,0,0,0-1.49-4.15H31.25Z" transform="translate(-11.99 -5.63)"/><path class="cc492f85-2991-4d56-8cef-73981bcf87a5" d="M34.38,22.77a11.11,11.11,0,0,1-2.19,3,8.48,8.48,0,0,0-.94,1.1H16.82a8.48,8.48,0,0,0-.94-1.1,11.11,11.11,0,0,1-2.19-3H34.38Z" transform="translate(-11.99 -5.63)"/><path class="ae63b835-46a7-49fe-a786-672d6aee0b42" d="M35.52,18.6a11.38,11.38,0,0,1-1.14,4.17H13.68a11.38,11.38,0,0,1-1.15-4.17h23Z" transform="translate(-11.99 -5.63)"/><path class="b101ce40-36f9-45c5-a7b5-2495b241b01f" d="M35.11,14.45H13a11.32,11.32,0,0,1,2.21-4.15H32.9A11.32,11.32,0,0,1,35.11,14.45Z" transform="translate(-11.99 -5.63)"/><path class="07b31d7d-790c-498f-8eb1-e36f1780ea32" d="M35.52,18.6h-23A11.14,11.14,0,0,1,13,14.45H35.11A11.14,11.14,0,0,1,35.52,18.6Z" transform="translate(-11.99 -5.63)"/><path class="f94daa82-101e-4af8-858e-37f3e50f826c" d="M32.9,10.29H15.16a9.48,9.48,0,0,1,.72-0.79,11.52,11.52,0,0,1,16.31,0A9.48,9.48,0,0,1,32.9,10.29Z" transform="translate(-11.99 -5.63)"/><path class="85d2ea03-5073-4611-915d-3495fb9886c4" d="M32.18,25.82a8.57,8.57,0,0,0-2.43,5.26H18.3a8.57,8.57,0,0,0-2.43-5.26A11.53,11.53,0,1,1,32.18,25.82Z" transform="translate(-11.99 -5.63)"/><path class="3f4a0a0c-d779-4d3c-9d06-08f104bd1007" d="M31,36.64a1.86,1.86,0,0,1-1.85,1.86h-2.4a2.3,2.3,0,0,1,.06.54,2.77,2.77,0,1,1-5.55,0,2.3,2.3,0,0,1,.06-0.54h-2.4a1.86,1.86,0,0,1,0-3.71,1.86,1.86,0,0,1,0-3.71H29.15a1.86,1.86,0,0,1,0,3.71A1.85,1.85,0,0,1,31,36.64Z" transform="translate(-11.99 -5.63)"/><path class="85d2ea03-5073-4611-915d-3495fb9886c4" d="M26.8,39a2.77,2.77,0,0,1-5.54,0" transform="translate(-11.99 -5.63)"/><path class="85d2ea03-5073-4611-915d-3495fb9886c4" d="M31,36.64a1.86,1.86,0,0,1-1.85,1.86H18.91a1.86,1.86,0,0,1,0-3.71,1.86,1.86,0,0,1,0-3.71H29.15a1.86,1.86,0,0,1,0,3.71A1.85,1.85,0,0,1,31,36.64Z" transform="translate(-11.99 -5.63)"/><line class="85d2ea03-5073-4611-915d-3495fb9886c4" x1="17.16" y1="29.16" x2="12" y2="29.16"/></svg>

After

Width:  |  Height:  |  Size: 3.3 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 5.5 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 6.5 KiB

View file

@ -2,9 +2,11 @@
"name": "blockly",
"version": "1.0.0",
"description": "Blockly is a library for building visual programming editors.",
"keywords": ["blockly"],
"keywords": [
"blockly"
],
"scripts": {
"lint": "jshint ."
"lint": "eslint ."
},
"repository": {
"type": "git",
@ -20,11 +22,19 @@
"license": "Apache-2.0",
"private": true,
"devDependencies": {
"eslint": "^2.7.0",
"jshint": "latest"
},
"jshintConfig": {
"globalstrict": true,
"predef": ["Blockly", "goog", "window", "document", "soy", "XMLHttpRequest"],
"predef": [
"Blockly",
"goog",
"window",
"document",
"soy",
"XMLHttpRequest"
],
"sub": true,
"undef": true,
"unused": true

View file

@ -15,8 +15,7 @@
<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 src="../blocks_horizontal/wedo.js"></script>
<script>
'use strict';
// Depending on the URL argument, render as LTR or RTL.
@ -152,23 +151,13 @@ 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>
<block type="event_whenbroadcastreceived"></block>
<block type="event_broadcast"></block>
</category>
<category name="Motion">
<block type="motion_moveright"></block>
</category>
<!-- <block type="control_repeat"></block> -->
<category name="Pants">
<category name="Control">
<block type="control_forever"></block>
<block type="control_repeat">
<value name="TIMES">
@ -177,6 +166,35 @@ h1 {
</shadow>
</value>
</block>
<block type="control_stop"></block>
<block type="control_wait">
<value name="DURATION">
<shadow type="math_number">
<field name="NUM">10</field>
</shadow>
</value>
</block>
</category>
<category name="Wedo">
<block type="wedo_setcolor"></block>
<block type="wedo_motorclockwise">
<value name="DURATION">
<shadow type="math_number">
<field name="NUM">10</field>
</shadow>
</value>
</block>
<block type="wedo_motorcounterclockwise">
<value name="DURATION">
<shadow type="math_number">
<field name="NUM">10</field>
</shadow>
</value>
</block>
<block type="wedo_motorspeed"></block>
<block type="wedo_whentilt"></block>
<block type="wedo_whendistanceclose"></block>
</category>
</xml>

View file

@ -282,7 +282,7 @@ function helper_makeSourceBlock(sharedWorkspace) {
movable_: true,
isMovable: function() { return true; },
isShadow: function() { return false; },
isGhost: function() { return false; },
isInsertionMarker: function() { return false; },
getFirstStatementConnection: function() { return null; }
};
}

View file

@ -298,18 +298,18 @@ function test_isConnectionAllowed_NoNext() {
assertFalse(two.isConnectionAllowed(one, 1000.0));
}
function test_isConnectionAllowed_Ghost() {
function test_isConnectionAllowed_InsertionMarker() {
var sharedWorkspace = {};
// Two connections of opposite types near each other.
var one = helper_createConnection(5 /* x */, 10 /* y */,
Blockly.INPUT_VALUE);
one.sourceBlock_ = helper_makeSourceBlock(sharedWorkspace);
// The second one is a ghost.
// The second one is an insertion marker.
var two = helper_createConnection(10 /* x */, 15 /* y */,
Blockly.OUTPUT_VALUE);
two.sourceBlock_ = helper_makeSourceBlock(sharedWorkspace);
two.sourceBlock_.isGhost = function() {
two.sourceBlock_.isInsertionMarker = function() {
return true;
};

View file

@ -15,5 +15,9 @@
<script src="names_test.js"></script>
<script src="workspace_test.js"></script>
<script src="xml_test.js"></script>
<script src="svg_test.js"></script>
<div id="blocklyDiv" style="display: none; height: 480px; width: 600px;"></div>
<xml id="toolbox" style="display: none"></xml>
</body>
</html>

159
tests/jsunit/svg_test.js Normal file
View file

@ -0,0 +1,159 @@
/**
* @license
* Blockly Tests
*
* Copyright 2016 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.
*/
'use strict';
var svgTest_workspace;
function svgTest_setUp() {
svgTest_workspace = Blockly.inject('blocklyDiv',
{toolbox: document.getElementById('toolbox')});
}
function svgTest_tearDown() {
svgTest_workspace.dispose();
svgTest_workspace = null;
}
/**
* Create a block with one field. Must be called after svgTest_setUp().
* @return {!Blockly.Block} The new block with one field.
*/
function svgTest_newOneFieldBlock() {
Blockly.Blocks['one_field_block'] = {
init: function() {
this.jsonInit({
'message0': '%1',
'args0': [
{
'type': 'field_input',
'name': 'FIELD'
}
]
});
}
};
var block = svgTest_workspace.newBlock('one_field_block');
block.initSvg();
block.render(false);
return block;
}
/**
* Create a block with two fields. Must be called after svgTest_setUp().
* @return {!Blockly.Block} The new block with two fields.
*/
function svgTest_newTwoFieldBlock() {
Blockly.Blocks['two_field_block'] = {
init: function() {
this.jsonInit({
'message0': 'text_field %1',
'args0': [
{
'type': 'field_input',
'name': 'FIELD'
}
]
});
}
};
var block = svgTest_workspace.newBlock('two_field_block');
block.initSvg();
block.render(false);
return block;
}
/**
* Check that the clicking the block shows the editor when the block has one
* field.
*/
function test_oneFieldBlock_blockClickShowsEditor() {
svgTest_setUp();
try {
var block = svgTest_newOneFieldBlock();
var showEditorCalled = false;
block.getField('FIELD').showEditor_ = function() {
showEditorCalled = true;
};
block.getSvgRoot().dispatchEvent(new Event('mouseup'));
assertTrue('showEditor_() not called', showEditorCalled);
} finally {
svgTest_tearDown();
}
}
/**
* Check that the clicking the field shows the editor when the block has more
* than one field.
*/
function test_twoFieldBlock_fieldClickShowsEditor() {
svgTest_setUp();
try {
var block = svgTest_newTwoFieldBlock();
var showEditorCalled = false;
block.getField('FIELD').showEditor_ = function() {
showEditorCalled = true;
};
block.getField('FIELD').getSvgRoot().dispatchEvent(new Event('mouseup'));
assertTrue('showEditor_() not called', showEditorCalled);
} finally {
svgTest_tearDown();
}
}
/**
* Check that blocks with one field have the text cursor style.
*/
function test_oneFieldBlock_blockCursorStyleIsText() {
svgTest_setUp();
try {
var block = svgTest_newOneFieldBlock();
assertEquals('text', block.getSvgRoot().style.cursor);
} finally {
svgTest_tearDown();
}
}
/**
* Check that blocks with two fields have the text cursor style on the field
* group.
*/
function test_twoFieldBlock_fieldCursorStyleIsText() {
svgTest_setUp();
try {
var block = svgTest_newTwoFieldBlock();
assertEquals('text', block.getField('FIELD').getSvgRoot().style.cursor);
} finally {
svgTest_tearDown();
}
}

View file

@ -15,5 +15,9 @@
<script src="names_test.js"></script>
<script src="workspace_test.js"></script>
<script src="xml_test.js"></script>
<script src="svg_test.js"></script>
<div id="blocklyDiv" style="display: none; height: 480px; width: 600px;"></div>
<xml id="toolbox" style="display: none"></xml>
</body>
</html>

View file

@ -9,7 +9,7 @@
<script src="../blocks_compressed.js"></script>
<script src="../blocks_horizontal/event.js"></script>
<script src="../blocks_horizontal/control.js"></script>
<script src="../blocks_horizontal/motion.js"></script>
<script src="../blocks_horizontal/wedo.js"></script>
<script>
'use strict';
// Depending on the URL argument, render as LTR or RTL.
@ -104,8 +104,6 @@ h1 {
<xml id="toolbox" style="display: none">
<block type="event_whenflagclicked"></block>
<block type="motion_moveright"></block>
<!-- <block type="control_repeat"></block> -->
<block type="control_forever"></block>
<block type="control_repeat">
<value name="TIMES">