mirror of
https://github.com/scratchfoundation/scratch-blocks.git
synced 2025-06-27 04:30:22 -04:00
All remaining lint in core
This commit is contained in:
parent
49eca4eee0
commit
fc0da3e070
29 changed files with 225 additions and 223 deletions
core
block.jsblock_drag_surface.jsblock_render_svg_horizontal.jsblock_render_svg_vertical.jsblock_svg.jsblockly.jsconnection.jsdata_category.jsdragged_connection_manager.jsdropdowndiv.jsfield.jsfield_angle.jsfield_colour_slider.jsfield_dropdown.jsfield_iconmenu.jsfield_image.jsfield_label.jsfield_number.jsfield_numberdropdown.jsfield_textdropdown.jsfield_textinput.jsfield_variable.jsfield_vertical_separator.jsflyout_horizontal.jsflyout_vertical.jsgesture.jsinject.jsscratch_blocks_utils.jsworkspace_svg.js
|
@ -790,15 +790,13 @@ Blockly.Block.prototype.setColour = function(colour, colourSecondary, colourTert
|
||||||
this.colourSecondary_ = this.makeColour_(colourSecondary);
|
this.colourSecondary_ = this.makeColour_(colourSecondary);
|
||||||
} else {
|
} else {
|
||||||
this.colourSecondary_ = goog.color.rgbArrayToHex(
|
this.colourSecondary_ = goog.color.rgbArrayToHex(
|
||||||
goog.color.darken(goog.color.hexToRgb(this.colour_),
|
goog.color.darken(goog.color.hexToRgb(this.colour_), 0.1));
|
||||||
0.1));
|
|
||||||
}
|
}
|
||||||
if (colourTertiary !== undefined) {
|
if (colourTertiary !== undefined) {
|
||||||
this.colourTertiary_ = this.makeColour_(colourTertiary);
|
this.colourTertiary_ = this.makeColour_(colourTertiary);
|
||||||
} else {
|
} else {
|
||||||
this.colourTertiary_ = goog.color.rgbArrayToHex(
|
this.colourTertiary_ = goog.color.rgbArrayToHex(
|
||||||
goog.color.darken(goog.color.hexToRgb(this.colour_),
|
goog.color.darken(goog.color.hexToRgb(this.colour_), 0.2));
|
||||||
0.2));
|
|
||||||
}
|
}
|
||||||
if (this.rendered) {
|
if (this.rendered) {
|
||||||
this.updateColour();
|
this.updateColour();
|
||||||
|
|
|
@ -112,13 +112,14 @@ Blockly.BlockDragSurfaceSvg.prototype.createDom = function() {
|
||||||
if (this.SVG_) {
|
if (this.SVG_) {
|
||||||
return; // Already created.
|
return; // Already created.
|
||||||
}
|
}
|
||||||
this.SVG_ = Blockly.utils.createSvgElement('svg', {
|
this.SVG_ = Blockly.utils.createSvgElement('svg',
|
||||||
'xmlns': Blockly.SVG_NS,
|
{
|
||||||
'xmlns:html': Blockly.HTML_NS,
|
'xmlns': Blockly.SVG_NS,
|
||||||
'xmlns:xlink': 'http://www.w3.org/1999/xlink',
|
'xmlns:html': Blockly.HTML_NS,
|
||||||
'version': '1.1',
|
'xmlns:xlink': 'http://www.w3.org/1999/xlink',
|
||||||
'class': 'blocklyBlockDragSurface'
|
'version': '1.1',
|
||||||
}, this.container_);
|
'class': 'blocklyBlockDragSurface'
|
||||||
|
}, this.container_);
|
||||||
this.dragGroup_ = Blockly.utils.createSvgElement('g', {}, this.SVG_);
|
this.dragGroup_ = Blockly.utils.createSvgElement('g', {}, this.SVG_);
|
||||||
// Belongs in Scratch Blocks, but not Blockly.
|
// Belongs in Scratch Blocks, but not Blockly.
|
||||||
var defs = Blockly.utils.createSvgElement('defs', {}, this.SVG_);
|
var defs = Blockly.utils.createSvgElement('defs', {}, this.SVG_);
|
||||||
|
@ -152,7 +153,7 @@ Blockly.BlockDragSurfaceSvg.prototype.createDropShadowDom_ = function(defs) {
|
||||||
},
|
},
|
||||||
dragShadowFilter);
|
dragShadowFilter);
|
||||||
var componentTransfer = Blockly.utils.createSvgElement(
|
var componentTransfer = Blockly.utils.createSvgElement(
|
||||||
'feComponentTransfer', {'result': 'offsetBlur'}, dragShadowFilter);
|
'feComponentTransfer', {'result': 'offsetBlur'}, dragShadowFilter);
|
||||||
// Shadow opacity is specified in the adjustable colour library,
|
// Shadow opacity is specified in the adjustable colour library,
|
||||||
// since the darkness of the shadow largely depends on the workspace colour.
|
// since the darkness of the shadow largely depends on the workspace colour.
|
||||||
Blockly.utils.createSvgElement('feFuncA',
|
Blockly.utils.createSvgElement('feFuncA',
|
||||||
|
|
|
@ -679,10 +679,10 @@ Blockly.BlockSvg.prototype.renderDrawLeft_ = function(steps, connectionsXY, metr
|
||||||
steps.push('m', metrics.fieldRadius + ',0');
|
steps.push('m', metrics.fieldRadius + ',0');
|
||||||
// Top-left rounded corner.
|
// Top-left rounded corner.
|
||||||
steps.push(
|
steps.push(
|
||||||
'A', metrics.fieldRadius + ',' + metrics.fieldRadius,
|
'A', metrics.fieldRadius + ',' + metrics.fieldRadius,
|
||||||
'0', '0,0', '0,' + metrics.fieldRadius);
|
'0', '0,0', '0,' + metrics.fieldRadius);
|
||||||
steps.push(
|
steps.push(
|
||||||
'V', metrics.height - metrics.fieldRadius);
|
'V', metrics.height - metrics.fieldRadius);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -710,8 +710,8 @@ Blockly.BlockSvg.prototype.renderDrawBottom_ = function(steps,
|
||||||
} else {
|
} else {
|
||||||
// Input
|
// Input
|
||||||
steps.push(
|
steps.push(
|
||||||
'a', metrics.fieldRadius + ',' + metrics.fieldRadius,
|
'a', metrics.fieldRadius + ',' + metrics.fieldRadius,
|
||||||
'0', '0,0', metrics.fieldRadius + ',' + metrics.fieldRadius);
|
'0', '0,0', metrics.fieldRadius + ',' + metrics.fieldRadius);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Has statement
|
// Has statement
|
||||||
|
@ -787,8 +787,8 @@ Blockly.BlockSvg.prototype.renderDrawRight_ = function(steps, connectionsXY, met
|
||||||
} else {
|
} else {
|
||||||
// Input
|
// Input
|
||||||
steps.push(
|
steps.push(
|
||||||
'a', metrics.fieldRadius + ',' + metrics.fieldRadius,
|
'a', metrics.fieldRadius + ',' + metrics.fieldRadius,
|
||||||
'0', '0,0', metrics.fieldRadius + ',' + -1 * metrics.fieldRadius);
|
'0', '0,0', metrics.fieldRadius + ',' + -1 * metrics.fieldRadius);
|
||||||
steps.push('v', -1 * (metrics.height - metrics.fieldRadius * 2));
|
steps.push('v', -1 * (metrics.height - metrics.fieldRadius * 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -833,8 +833,8 @@ Blockly.BlockSvg.prototype.renderDrawTop_ = function(steps, connectionsXY, metri
|
||||||
Blockly.BlockSvg.CORNER_RADIUS);
|
Blockly.BlockSvg.CORNER_RADIUS);
|
||||||
} else {
|
} else {
|
||||||
steps.push(
|
steps.push(
|
||||||
'a', metrics.fieldRadius + ',' + metrics.fieldRadius,
|
'a', metrics.fieldRadius + ',' + metrics.fieldRadius,
|
||||||
'0', '0,0', '-' + metrics.fieldRadius + ',-' + metrics.fieldRadius);
|
'0', '0,0', '-' + metrics.fieldRadius + ',-' + metrics.fieldRadius);
|
||||||
}
|
}
|
||||||
steps.push('z');
|
steps.push('z');
|
||||||
};
|
};
|
||||||
|
|
|
@ -672,9 +672,8 @@ Blockly.BlockSvg.prototype.render = function(opt_bubble) {
|
||||||
* @return {number} X-coordinate of the end of the field row (plus a gap).
|
* @return {number} X-coordinate of the end of the field row (plus a gap).
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
Blockly.BlockSvg.prototype.renderFields_ =
|
Blockly.BlockSvg.prototype.renderFields_ = function(fieldList, cursorX,
|
||||||
function(fieldList, cursorX, cursorY) {
|
cursorY) {
|
||||||
/* eslint-disable indent */
|
|
||||||
if (this.RTL) {
|
if (this.RTL) {
|
||||||
cursorX = -cursorX;
|
cursorX = -cursorX;
|
||||||
}
|
}
|
||||||
|
@ -738,8 +737,7 @@ Blockly.BlockSvg.prototype.renderFields_ =
|
||||||
translateX += field.renderWidth;
|
translateX += field.renderWidth;
|
||||||
}
|
}
|
||||||
root.setAttribute('transform',
|
root.setAttribute('transform',
|
||||||
'translate(' + translateX + ', ' + translateY + ') ' + scale
|
'translate(' + translateX + ', ' + translateY + ') ' + scale);
|
||||||
);
|
|
||||||
|
|
||||||
// Fields are invisible on insertion marker.
|
// Fields are invisible on insertion marker.
|
||||||
if (this.isInsertionMarker()) {
|
if (this.isInsertionMarker()) {
|
||||||
|
@ -747,7 +745,7 @@ Blockly.BlockSvg.prototype.renderFields_ =
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return this.RTL ? -cursorX : cursorX;
|
return this.RTL ? -cursorX : cursorX;
|
||||||
}; /* eslint-enable indent */
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Computes the height and widths for each row and field.
|
* Computes the height and widths for each row and field.
|
||||||
|
@ -1198,7 +1196,6 @@ Blockly.BlockSvg.prototype.renderClassify_ = function() {
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
Blockly.BlockSvg.prototype.renderDrawTop_ = function(steps, rightEdge) {
|
Blockly.BlockSvg.prototype.renderDrawTop_ = function(steps, rightEdge) {
|
||||||
/* eslint-disable indent */
|
|
||||||
if (this.type == Blockly.PROCEDURES_DEFINITION_BLOCK_TYPE) {
|
if (this.type == Blockly.PROCEDURES_DEFINITION_BLOCK_TYPE) {
|
||||||
steps.push('m 0, 0');
|
steps.push('m 0, 0');
|
||||||
steps.push(Blockly.BlockSvg.TOP_LEFT_CORNER_DEFINE_HAT);
|
steps.push(Blockly.BlockSvg.TOP_LEFT_CORNER_DEFINE_HAT);
|
||||||
|
@ -1231,7 +1228,7 @@ Blockly.BlockSvg.prototype.renderDrawTop_ = function(steps, rightEdge) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.width = rightEdge;
|
this.width = rightEdge;
|
||||||
}; /* eslint-enable indent */
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Render the right edge of the block.
|
* Render the right edge of the block.
|
||||||
|
@ -1379,8 +1376,7 @@ Blockly.BlockSvg.prototype.renderInputShape_ = function(input, x, y) {
|
||||||
inputShapeY = y - (Blockly.BlockSvg.INPUT_SHAPE_HEIGHT / 2);
|
inputShapeY = y - (Blockly.BlockSvg.INPUT_SHAPE_HEIGHT / 2);
|
||||||
inputShape.setAttribute('d', inputShapeInfo.path);
|
inputShape.setAttribute('d', inputShapeInfo.path);
|
||||||
inputShape.setAttribute('transform',
|
inputShape.setAttribute('transform',
|
||||||
'translate(' + inputShapeX + ',' + inputShapeY + ')'
|
'translate(' + inputShapeX + ',' + inputShapeY + ')');
|
||||||
);
|
|
||||||
inputShape.setAttribute('data-argument-type', inputShapeInfo.argType);
|
inputShape.setAttribute('data-argument-type', inputShapeInfo.argType);
|
||||||
inputShape.setAttribute('style', 'visibility: visible');
|
inputShape.setAttribute('style', 'visibility: visible');
|
||||||
}
|
}
|
||||||
|
@ -1481,9 +1477,8 @@ Blockly.BlockSvg.prototype.drawEdgeShapeRight_ = function(steps) {
|
||||||
* @param {!Blockly.Connection} existingConnection The connection on the
|
* @param {!Blockly.Connection} existingConnection The connection on the
|
||||||
* existing block, which newBlock should line up with.
|
* existing block, which newBlock should line up with.
|
||||||
*/
|
*/
|
||||||
Blockly.BlockSvg.prototype.positionNewBlock =
|
Blockly.BlockSvg.prototype.positionNewBlock = function(newBlock, newConnection,
|
||||||
function(newBlock, newConnection, existingConnection) {
|
existingConnection) {
|
||||||
/* eslint-disable indent */
|
|
||||||
// We only need to position the new block if it's before the existing one,
|
// We only need to position the new block if it's before the existing one,
|
||||||
// otherwise its position is set by the previous block.
|
// otherwise its position is set by the previous block.
|
||||||
if (newConnection.type == Blockly.NEXT_STATEMENT) {
|
if (newConnection.type == Blockly.NEXT_STATEMENT) {
|
||||||
|
@ -1492,7 +1487,7 @@ Blockly.BlockSvg.prototype.positionNewBlock =
|
||||||
|
|
||||||
newBlock.moveBy(dx, dy);
|
newBlock.moveBy(dx, dy);
|
||||||
}
|
}
|
||||||
}; /* eslint-enable indent */
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Draw the outline of a statement input, starting at the top right corner.
|
* Draw the outline of a statement input, starting at the top right corner.
|
||||||
|
|
|
@ -304,7 +304,7 @@ Blockly.BlockSvg.prototype.setParent = function(newParent) {
|
||||||
// If we are a shadow block, inherit tertiary colour.
|
// If we are a shadow block, inherit tertiary colour.
|
||||||
if (this.isShadow()) {
|
if (this.isShadow()) {
|
||||||
this.setColour(this.getColour(), this.getColourSecondary(),
|
this.setColour(this.getColour(), this.getColourSecondary(),
|
||||||
newParent.getColourTertiary());
|
newParent.getColourTertiary());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -444,10 +444,9 @@ Blockly.bindEventWithChecks_ = function(node, name, thisObject, func,
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
for (var i = 0, eventName;
|
for (var i = 0, type; type = Blockly.Touch.TOUCH_MAP[name][i]; i++) {
|
||||||
eventName = Blockly.Touch.TOUCH_MAP[name][i]; i++) {
|
node.addEventListener(type, touchWrapFunc, false);
|
||||||
node.addEventListener(eventName, touchWrapFunc, false);
|
bindData.push([node, type, touchWrapFunc]);
|
||||||
bindData.push([node, eventName, touchWrapFunc]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return bindData;
|
return bindData;
|
||||||
|
@ -494,10 +493,9 @@ Blockly.bindEvent_ = function(node, name, thisObject, func) {
|
||||||
// Stop the browser from scrolling/zooming the page.
|
// Stop the browser from scrolling/zooming the page.
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
};
|
};
|
||||||
for (var i = 0, eventName;
|
for (var i = 0, type; type = Blockly.Touch.TOUCH_MAP[name][i]; i++) {
|
||||||
eventName = Blockly.Touch.TOUCH_MAP[name][i]; i++) {
|
node.addEventListener(type, touchWrapFunc, false);
|
||||||
node.addEventListener(eventName, touchWrapFunc, false);
|
bindData.push([node, type, touchWrapFunc]);
|
||||||
bindData.push([node, eventName, touchWrapFunc]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return bindData;
|
return bindData;
|
||||||
|
|
|
@ -455,10 +455,10 @@ Blockly.Connection.prototype.isConnectionAllowed = function(candidate) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Blockly.NEXT_STATEMENT: {
|
case Blockly.NEXT_STATEMENT: {
|
||||||
// Scratch-specific behaviour:
|
// Scratch-specific behaviour:
|
||||||
// If this is a c-block, we can't connect this block's
|
// If this is a c-block, we can't connect this block's
|
||||||
// previous connection unless we're connecting to the end of the last
|
// previous connection unless we're connecting to the end of the last
|
||||||
// block on a stack or there's already a block connected inside the c.
|
// block on a stack or there's already a block connected inside the c.
|
||||||
if (firstStatementConnection &&
|
if (firstStatementConnection &&
|
||||||
this == this.sourceBlock_.previousConnection &&
|
this == this.sourceBlock_.previousConnection &&
|
||||||
candidate.isConnectedToNonInsertionMarker() &&
|
candidate.isConnectedToNonInsertionMarker() &&
|
||||||
|
|
|
@ -120,7 +120,7 @@ Blockly.DataCategory.addSetVariableTo = function(xmlList, variable) {
|
||||||
// </value>
|
// </value>
|
||||||
// </block>
|
// </block>
|
||||||
Blockly.DataCategory.addBlock(xmlList, variable, 'data_setvariableto',
|
Blockly.DataCategory.addBlock(xmlList, variable, 'data_setvariableto',
|
||||||
'VARIABLE', ['VALUE', 'text', 0]);
|
'VARIABLE', ['VALUE', 'text', 0]);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -140,7 +140,7 @@ Blockly.DataCategory.addChangeVariableBy = function(xmlList, variable) {
|
||||||
// </value>
|
// </value>
|
||||||
// </block>
|
// </block>
|
||||||
Blockly.DataCategory.addBlock(xmlList, variable, 'data_changevariableby',
|
Blockly.DataCategory.addBlock(xmlList, variable, 'data_changevariableby',
|
||||||
'VARIABLE', ['VALUE', 'math_number', 1]);
|
'VARIABLE', ['VALUE', 'math_number', 1]);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -155,7 +155,7 @@ Blockly.DataCategory.addShowVariable = function(xmlList, variable) {
|
||||||
// </value>
|
// </value>
|
||||||
// </block>
|
// </block>
|
||||||
Blockly.DataCategory.addBlock(xmlList, variable, 'data_showvariable',
|
Blockly.DataCategory.addBlock(xmlList, variable, 'data_showvariable',
|
||||||
'VARIABLE');
|
'VARIABLE');
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -170,7 +170,7 @@ Blockly.DataCategory.addHideVariable = function(xmlList, variable) {
|
||||||
// </value>
|
// </value>
|
||||||
// </block>
|
// </block>
|
||||||
Blockly.DataCategory.addBlock(xmlList, variable, 'data_hidevariable',
|
Blockly.DataCategory.addBlock(xmlList, variable, 'data_hidevariable',
|
||||||
'VARIABLE');
|
'VARIABLE');
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -202,7 +202,7 @@ Blockly.DataCategory.addAddToList = function(xmlList, variable) {
|
||||||
// </value>
|
// </value>
|
||||||
// </block>
|
// </block>
|
||||||
Blockly.DataCategory.addBlock(xmlList, variable, 'data_addtolist', 'LIST',
|
Blockly.DataCategory.addBlock(xmlList, variable, 'data_addtolist', 'LIST',
|
||||||
['ITEM', 'text', 'thing']);
|
['ITEM', 'text', 'thing']);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -220,7 +220,7 @@ Blockly.DataCategory.addDeleteOfList = function(xmlList, variable) {
|
||||||
// </value>
|
// </value>
|
||||||
// </block>
|
// </block>
|
||||||
Blockly.DataCategory.addBlock(xmlList, variable, 'data_deleteoflist', 'LIST',
|
Blockly.DataCategory.addBlock(xmlList, variable, 'data_deleteoflist', 'LIST',
|
||||||
['INDEX', 'math_integer', 1]);
|
['INDEX', 'math_integer', 1]);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -243,7 +243,7 @@ Blockly.DataCategory.addInsertAtList = function(xmlList, variable) {
|
||||||
// </value>
|
// </value>
|
||||||
// </block>
|
// </block>
|
||||||
Blockly.DataCategory.addBlock(xmlList, variable, 'data_insertatlist', 'LIST',
|
Blockly.DataCategory.addBlock(xmlList, variable, 'data_insertatlist', 'LIST',
|
||||||
['INDEX', 'math_integer', 1], ['ITEM', 'text', 'thing']);
|
['INDEX', 'math_integer', 1], ['ITEM', 'text', 'thing']);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -266,7 +266,7 @@ Blockly.DataCategory.addReplaceItemOfList = function(xmlList, variable) {
|
||||||
// </value>
|
// </value>
|
||||||
// </block>
|
// </block>
|
||||||
Blockly.DataCategory.addBlock(xmlList, variable, 'data_replaceitemoflist',
|
Blockly.DataCategory.addBlock(xmlList, variable, 'data_replaceitemoflist',
|
||||||
'LIST', ['INDEX', 'math_integer', 1], ['ITEM', 'text', 'thing']);
|
'LIST', ['INDEX', 'math_integer', 1], ['ITEM', 'text', 'thing']);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -284,7 +284,7 @@ Blockly.DataCategory.addItemOfList = function(xmlList, variable) {
|
||||||
// </value>
|
// </value>
|
||||||
// </block>
|
// </block>
|
||||||
Blockly.DataCategory.addBlock(xmlList, variable, 'data_itemoflist', 'LIST',
|
Blockly.DataCategory.addBlock(xmlList, variable, 'data_itemoflist', 'LIST',
|
||||||
['INDEX', 'math_integer', 1]);
|
['INDEX', 'math_integer', 1]);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -314,7 +314,7 @@ Blockly.DataCategory.addListContainsItem = function(xmlList, variable) {
|
||||||
// </value>
|
// </value>
|
||||||
// </block>
|
// </block>
|
||||||
Blockly.DataCategory.addBlock(xmlList, variable, 'data_listcontainsitem',
|
Blockly.DataCategory.addBlock(xmlList, variable, 'data_listcontainsitem',
|
||||||
'LIST', ['ITEM', 'text', 'thing']);
|
'LIST', ['ITEM', 'text', 'thing']);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -361,7 +361,7 @@ Blockly.DataCategory.addCreateButton = function(xmlList, workspace, type) {
|
||||||
callbackKey = 'CREATE_LIST';
|
callbackKey = 'CREATE_LIST';
|
||||||
callback = function(button) {
|
callback = function(button) {
|
||||||
Blockly.Variables.createVariable(button.getTargetWorkspace(), null,
|
Blockly.Variables.createVariable(button.getTargetWorkspace(), null,
|
||||||
Blockly.LIST_VARIABLE_TYPE);};
|
Blockly.LIST_VARIABLE_TYPE);};
|
||||||
}
|
}
|
||||||
button.setAttribute('text', msg);
|
button.setAttribute('text', msg);
|
||||||
button.setAttribute('callbackKey', callbackKey);
|
button.setAttribute('callbackKey', callbackKey);
|
||||||
|
@ -383,18 +383,18 @@ Blockly.DataCategory.addCreateButton = function(xmlList, workspace, type) {
|
||||||
* @param {?Array.<string>} opt_secondValue Optional array containing the value
|
* @param {?Array.<string>} opt_secondValue Optional array containing the value
|
||||||
* name and shadow type of a second pair of value tags.
|
* name and shadow type of a second pair of value tags.
|
||||||
*/
|
*/
|
||||||
Blockly.DataCategory.addBlock = function(xmlList,
|
Blockly.DataCategory.addBlock = function(xmlList, variable, blockType,
|
||||||
variable, blockType, fieldName, opt_value, opt_secondValue) {
|
fieldName, opt_value, opt_secondValue) {
|
||||||
if (Blockly.Blocks[blockType]) {
|
if (Blockly.Blocks[blockType]) {
|
||||||
var firstValueField;
|
var firstValueField;
|
||||||
var secondValueField;
|
var secondValueField;
|
||||||
if (opt_value) {
|
if (opt_value) {
|
||||||
firstValueField = Blockly.DataCategory.createValue(opt_value[0],
|
firstValueField = Blockly.DataCategory.createValue(opt_value[0],
|
||||||
opt_value[1], opt_value[2]);
|
opt_value[1], opt_value[2]);
|
||||||
}
|
}
|
||||||
if (opt_secondValue) {
|
if (opt_secondValue) {
|
||||||
secondValueField = Blockly.DataCategory.createValue(opt_secondValue[0],
|
secondValueField = Blockly.DataCategory.createValue(opt_secondValue[0],
|
||||||
opt_secondValue[1], opt_value[2]);
|
opt_secondValue[1], opt_value[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
var gap = 8;
|
var gap = 8;
|
||||||
|
|
|
@ -173,8 +173,8 @@ Blockly.DraggedConnectionManager.prototype.update = function(dxy, deleteArea, is
|
||||||
this.closestConnection_ = null;
|
this.closestConnection_ = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prefer connecting over dropping into the trash can, but prefer dragging to
|
// Prefer connecting over dropping into the trash can, but prefer dragging to
|
||||||
// the toolbox over connecting to other blocks.
|
// the toolbox over connecting to other blocks.
|
||||||
var wouldConnect = !!this.closestConnection_ &&
|
var wouldConnect = !!this.closestConnection_ &&
|
||||||
deleteArea != Blockly.DELETE_AREA_TOOLBOX;
|
deleteArea != Blockly.DELETE_AREA_TOOLBOX;
|
||||||
var wouldDelete = !!deleteArea && !this.topBlock_.getParent() &&
|
var wouldDelete = !!deleteArea && !this.topBlock_.getParent() &&
|
||||||
|
|
|
@ -183,7 +183,7 @@ Blockly.DropDownDiv.setCategory = function(category) {
|
||||||
* @return {boolean} True if the menu rendered below block; false if above.
|
* @return {boolean} True if the menu rendered below block; false if above.
|
||||||
*/
|
*/
|
||||||
Blockly.DropDownDiv.showPositionedByBlock = function(owner, block,
|
Blockly.DropDownDiv.showPositionedByBlock = function(owner, block,
|
||||||
opt_onHide, opt_secondaryYOffset) {
|
opt_onHide, opt_secondaryYOffset) {
|
||||||
var scale = block.workspace.scale;
|
var scale = block.workspace.scale;
|
||||||
var bBox = {width: block.width, height: block.height};
|
var bBox = {width: block.width, height: block.height};
|
||||||
bBox.width *= scale;
|
bBox.width *= scale;
|
||||||
|
@ -306,16 +306,16 @@ Blockly.DropDownDiv.getPositionMetrics = function(primaryX, primaryY, secondaryX
|
||||||
renderX -= centerX;
|
renderX -= centerX;
|
||||||
// Fit horizontally in the bounds.
|
// Fit horizontally in the bounds.
|
||||||
renderX = Math.max(
|
renderX = Math.max(
|
||||||
boundPosition.left,
|
boundPosition.left,
|
||||||
Math.min(renderX, boundPosition.left + boundSize.width - divSize.width)
|
Math.min(renderX, boundPosition.left + boundSize.width - divSize.width)
|
||||||
);
|
);
|
||||||
// After we've finished caclulating renderX, adjust the arrow to be relative to it.
|
// After we've finished caclulating renderX, adjust the arrow to be relative to it.
|
||||||
arrowX -= renderX;
|
arrowX -= renderX;
|
||||||
|
|
||||||
// Pad the arrow by some pixels, primarily so that it doesn't render on top of a rounded border.
|
// Pad the arrow by some pixels, primarily so that it doesn't render on top of a rounded border.
|
||||||
arrowX = Math.max(
|
arrowX = Math.max(
|
||||||
Blockly.DropDownDiv.ARROW_HORIZONTAL_PADDING,
|
Blockly.DropDownDiv.ARROW_HORIZONTAL_PADDING,
|
||||||
Math.min(arrowX, divSize.width - Blockly.DropDownDiv.ARROW_HORIZONTAL_PADDING - Blockly.DropDownDiv.ARROW_SIZE)
|
Math.min(arrowX, divSize.width - Blockly.DropDownDiv.ARROW_HORIZONTAL_PADDING - Blockly.DropDownDiv.ARROW_SIZE)
|
||||||
);
|
);
|
||||||
|
|
||||||
// Calculate arrow Y. If we rendered secondary, add on bottom.
|
// Calculate arrow Y. If we rendered secondary, add on bottom.
|
||||||
|
|
|
@ -48,8 +48,8 @@ goog.require('goog.userAgent');
|
||||||
*/
|
*/
|
||||||
Blockly.Field = function(text, opt_validator) {
|
Blockly.Field = function(text, opt_validator) {
|
||||||
this.size_ = new goog.math.Size(
|
this.size_ = new goog.math.Size(
|
||||||
Blockly.BlockSvg.FIELD_WIDTH,
|
Blockly.BlockSvg.FIELD_WIDTH,
|
||||||
Blockly.BlockSvg.FIELD_HEIGHT);
|
Blockly.BlockSvg.FIELD_HEIGHT);
|
||||||
this.setValue(text);
|
this.setValue(text);
|
||||||
this.setValidator(opt_validator);
|
this.setValidator(opt_validator);
|
||||||
|
|
||||||
|
@ -236,22 +236,22 @@ Blockly.Field.prototype.init = function() {
|
||||||
var fieldX = (this.sourceBlock_.RTL) ? -size.width / 2 : size.width / 2;
|
var fieldX = (this.sourceBlock_.RTL) ? -size.width / 2 : size.width / 2;
|
||||||
/** @type {!Element} */
|
/** @type {!Element} */
|
||||||
this.textElement_ = Blockly.utils.createSvgElement('text',
|
this.textElement_ = Blockly.utils.createSvgElement('text',
|
||||||
{'class': this.className_,
|
{
|
||||||
'x': fieldX,
|
'class': this.className_,
|
||||||
'y': size.height / 2 + Blockly.BlockSvg.FIELD_TOP_PADDING,
|
'x': fieldX,
|
||||||
'dominant-baseline': 'middle',
|
'y': size.height / 2 + Blockly.BlockSvg.FIELD_TOP_PADDING,
|
||||||
'dy': goog.userAgent.EDGE_OR_IE ? Blockly.Field.IE_TEXT_OFFSET : '0',
|
'dominant-baseline': 'middle',
|
||||||
'text-anchor': 'middle'},
|
'dy': goog.userAgent.EDGE_OR_IE ? Blockly.Field.IE_TEXT_OFFSET : '0',
|
||||||
this.fieldGroup_);
|
'text-anchor': 'middle'
|
||||||
|
}, this.fieldGroup_);
|
||||||
|
|
||||||
this.updateEditable();
|
this.updateEditable();
|
||||||
this.sourceBlock_.getSvgRoot().appendChild(this.fieldGroup_);
|
this.sourceBlock_.getSvgRoot().appendChild(this.fieldGroup_);
|
||||||
// Force a render.
|
// Force a render.
|
||||||
this.render_();
|
this.render_();
|
||||||
this.size_.width = 0;
|
this.size_.width = 0;
|
||||||
this.mouseDownWrapper_ =
|
this.mouseDownWrapper_ = Blockly.bindEventWithChecks_(
|
||||||
Blockly.bindEventWithChecks_(this.getClickTarget_(), 'mousedown', this,
|
this.getClickTarget_(), 'mousedown', this, this.onMouseDown_);
|
||||||
this.onMouseDown_);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -224,20 +224,18 @@ Blockly.FieldAngle.prototype.showEditor_ = function() {
|
||||||
'r': Blockly.FieldAngle.HANDLE_RADIUS,
|
'r': Blockly.FieldAngle.HANDLE_RADIUS,
|
||||||
'class': 'blocklyAngleDragHandle'
|
'class': 'blocklyAngleDragHandle'
|
||||||
}, this.handle_);
|
}, this.handle_);
|
||||||
this.arrowSvg_ = Blockly.utils.createSvgElement(
|
this.arrowSvg_ = Blockly.utils.createSvgElement('image',
|
||||||
'image',
|
{
|
||||||
{
|
'width': Blockly.FieldAngle.ARROW_WIDTH,
|
||||||
'width': Blockly.FieldAngle.ARROW_WIDTH,
|
'height': Blockly.FieldAngle.ARROW_WIDTH,
|
||||||
'height': Blockly.FieldAngle.ARROW_WIDTH,
|
'x': -Blockly.FieldAngle.ARROW_WIDTH / 2,
|
||||||
'x': -Blockly.FieldAngle.ARROW_WIDTH / 2,
|
'y': -Blockly.FieldAngle.ARROW_WIDTH / 2
|
||||||
'y': -Blockly.FieldAngle.ARROW_WIDTH / 2
|
},
|
||||||
},
|
this.handle_);
|
||||||
this.handle_
|
|
||||||
);
|
|
||||||
this.arrowSvg_.setAttributeNS(
|
this.arrowSvg_.setAttributeNS(
|
||||||
'http://www.w3.org/1999/xlink',
|
'http://www.w3.org/1999/xlink',
|
||||||
'xlink:href',
|
'xlink:href',
|
||||||
Blockly.mainWorkspace.options.pathToMedia + Blockly.FieldAngle.ARROW_SVG_PATH
|
Blockly.mainWorkspace.options.pathToMedia + Blockly.FieldAngle.ARROW_SVG_PATH
|
||||||
);
|
);
|
||||||
|
|
||||||
Blockly.DropDownDiv.setColour(this.sourceBlock_.parentBlock_.getColour(),
|
Blockly.DropDownDiv.setColour(this.sourceBlock_.parentBlock_.getColour(),
|
||||||
|
|
|
@ -152,15 +152,15 @@ Blockly.FieldColourSlider.prototype.createColourStops_ = function(channel) {
|
||||||
Blockly.FieldColourSlider.prototype.setGradient_ = function(node, channel) {
|
Blockly.FieldColourSlider.prototype.setGradient_ = function(node, channel) {
|
||||||
var gradient = this.createColourStops_(channel).join(',');
|
var gradient = this.createColourStops_(channel).join(',');
|
||||||
goog.style.setStyle(node, 'background',
|
goog.style.setStyle(node, 'background',
|
||||||
'-moz-linear-gradient(left, ' + gradient + ')');
|
'-moz-linear-gradient(left, ' + gradient + ')');
|
||||||
goog.style.setStyle(node, 'background',
|
goog.style.setStyle(node, 'background',
|
||||||
'-webkit-linear-gradient(left, ' + gradient + ')');
|
'-webkit-linear-gradient(left, ' + gradient + ')');
|
||||||
goog.style.setStyle(node, 'background',
|
goog.style.setStyle(node, 'background',
|
||||||
'-o-linear-gradient(left, ' + gradient + ')');
|
'-o-linear-gradient(left, ' + gradient + ')');
|
||||||
goog.style.setStyle(node, 'background',
|
goog.style.setStyle(node, 'background',
|
||||||
'-ms-linear-gradient(left, ' + gradient + ')');
|
'-ms-linear-gradient(left, ' + gradient + ')');
|
||||||
goog.style.setStyle(node, 'background',
|
goog.style.setStyle(node, 'background',
|
||||||
'linear-gradient(left, ' + gradient + ')');
|
'linear-gradient(left, ' + gradient + ')');
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -250,7 +250,7 @@ Blockly.FieldColourSlider.prototype.sliderCallbackFactory_ = function(channel) {
|
||||||
}
|
}
|
||||||
var colour = goog.color.hsvToHex(hsv[0], hsv[1], hsv[2]);
|
var colour = goog.color.hsvToHex(hsv[0], hsv[1], hsv[2]);
|
||||||
if (thisField.sourceBlock_) {
|
if (thisField.sourceBlock_) {
|
||||||
// Call any validation function, and allow it to override.
|
// Call any validation function, and allow it to override.
|
||||||
colour = thisField.callValidator(colour);
|
colour = thisField.callValidator(colour);
|
||||||
}
|
}
|
||||||
if (colour !== null) {
|
if (colour !== null) {
|
||||||
|
@ -301,9 +301,8 @@ Blockly.FieldColourSlider.prototype.showEditor_ = function() {
|
||||||
this.hueSlider_.setMoveToPointEnabled(true);
|
this.hueSlider_.setMoveToPointEnabled(true);
|
||||||
this.hueSlider_.render(div);
|
this.hueSlider_.render(div);
|
||||||
|
|
||||||
var saturationElements = this.createLabelDom_(
|
var saturationElements =
|
||||||
Blockly.Msg.COLOUR_SATURATION_LABEL
|
this.createLabelDom_(Blockly.Msg.COLOUR_SATURATION_LABEL);
|
||||||
);
|
|
||||||
div.appendChild(saturationElements[0]);
|
div.appendChild(saturationElements[0]);
|
||||||
this.saturationReadout_ = saturationElements[1];
|
this.saturationReadout_ = saturationElements[1];
|
||||||
this.saturationSlider_ = new goog.ui.Slider();
|
this.saturationSlider_ = new goog.ui.Slider();
|
||||||
|
@ -314,9 +313,8 @@ Blockly.FieldColourSlider.prototype.showEditor_ = function() {
|
||||||
this.saturationSlider_.setMaximum(1.0);
|
this.saturationSlider_.setMaximum(1.0);
|
||||||
this.saturationSlider_.render(div);
|
this.saturationSlider_.render(div);
|
||||||
|
|
||||||
var brightnessElements = this.createLabelDom_(
|
var brightnessElements =
|
||||||
Blockly.Msg.COLOUR_BRIGHTNESS_LABEL
|
this.createLabelDom_(Blockly.Msg.COLOUR_BRIGHTNESS_LABEL);
|
||||||
);
|
|
||||||
div.appendChild(brightnessElements[0]);
|
div.appendChild(brightnessElements[0]);
|
||||||
this.brightnessReadout_ = brightnessElements[1];
|
this.brightnessReadout_ = brightnessElements[1];
|
||||||
this.brightnessSlider_ = new goog.ui.Slider();
|
this.brightnessSlider_ = new goog.ui.Slider();
|
||||||
|
@ -327,14 +325,14 @@ Blockly.FieldColourSlider.prototype.showEditor_ = function() {
|
||||||
this.brightnessSlider_.render(div);
|
this.brightnessSlider_.render(div);
|
||||||
|
|
||||||
Blockly.FieldColourSlider.hueChangeEventKey_ = goog.events.listen(this.hueSlider_,
|
Blockly.FieldColourSlider.hueChangeEventKey_ = goog.events.listen(this.hueSlider_,
|
||||||
goog.ui.Component.EventType.CHANGE,
|
goog.ui.Component.EventType.CHANGE,
|
||||||
this.sliderCallbackFactory_('hue'));
|
this.sliderCallbackFactory_('hue'));
|
||||||
Blockly.FieldColourSlider.saturationChangeEventKey_ = goog.events.listen(this.saturationSlider_,
|
Blockly.FieldColourSlider.saturationChangeEventKey_ = goog.events.listen(this.saturationSlider_,
|
||||||
goog.ui.Component.EventType.CHANGE,
|
goog.ui.Component.EventType.CHANGE,
|
||||||
this.sliderCallbackFactory_('saturation'));
|
this.sliderCallbackFactory_('saturation'));
|
||||||
Blockly.FieldColourSlider.brightnessChangeEventKey_ = goog.events.listen(this.brightnessSlider_,
|
Blockly.FieldColourSlider.brightnessChangeEventKey_ = goog.events.listen(this.brightnessSlider_,
|
||||||
goog.ui.Component.EventType.CHANGE,
|
goog.ui.Component.EventType.CHANGE,
|
||||||
this.sliderCallbackFactory_('brightness'));
|
this.sliderCallbackFactory_('brightness'));
|
||||||
|
|
||||||
if (Blockly.FieldColourSlider.activateEyedropper_) {
|
if (Blockly.FieldColourSlider.activateEyedropper_) {
|
||||||
var button = document.createElement('button');
|
var button = document.createElement('button');
|
||||||
|
@ -343,11 +341,9 @@ Blockly.FieldColourSlider.prototype.showEditor_ = function() {
|
||||||
image.src = Blockly.mainWorkspace.options.pathToMedia + Blockly.FieldColourSlider.EYEDROPPER_PATH;
|
image.src = Blockly.mainWorkspace.options.pathToMedia + Blockly.FieldColourSlider.EYEDROPPER_PATH;
|
||||||
button.appendChild(image);
|
button.appendChild(image);
|
||||||
div.appendChild(button);
|
div.appendChild(button);
|
||||||
Blockly.FieldColourSlider.eyedropperEventData_ = Blockly.bindEventWithChecks_(button,
|
Blockly.FieldColourSlider.eyedropperEventData_ =
|
||||||
'mousedown',
|
Blockly.bindEventWithChecks_(button, 'mousedown', this,
|
||||||
this,
|
this.activateEyedropperInternal_);
|
||||||
this.activateEyedropperInternal_
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Blockly.DropDownDiv.setColour('#ffffff', '#dddddd');
|
Blockly.DropDownDiv.setColour('#ffffff', '#dddddd');
|
||||||
|
|
|
@ -221,10 +221,10 @@ Blockly.FieldDropdown.prototype.showEditor_ = function() {
|
||||||
// Activate the menu item.
|
// Activate the menu item.
|
||||||
control.performActionInternal(e);
|
control.performActionInternal(e);
|
||||||
}
|
}
|
||||||
menu.getHandler().listen(menu.getElement(), goog.events.EventType.TOUCHSTART,
|
menu.getHandler().listen(
|
||||||
callbackTouchStart);
|
menu.getElement(), goog.events.EventType.TOUCHSTART, callbackTouchStart);
|
||||||
menu.getHandler().listen(menu.getElement(), goog.events.EventType.TOUCHEND,
|
menu.getHandler().listen(
|
||||||
callbackTouchEnd);
|
menu.getElement(), goog.events.EventType.TOUCHEND, callbackTouchEnd);
|
||||||
|
|
||||||
// Record windowSize and scrollOffset before adding menu.
|
// Record windowSize and scrollOffset before adding menu.
|
||||||
menu.render(contentDiv);
|
menu.render(contentDiv);
|
||||||
|
@ -256,8 +256,8 @@ Blockly.FieldDropdown.prototype.showEditor_ = function() {
|
||||||
var secondaryY = position.top;
|
var secondaryY = position.top;
|
||||||
// Set bounds to workspace; show the drop-down.
|
// Set bounds to workspace; show the drop-down.
|
||||||
Blockly.DropDownDiv.setBoundsElement(this.sourceBlock_.workspace.getParentSvg().parentNode);
|
Blockly.DropDownDiv.setBoundsElement(this.sourceBlock_.workspace.getParentSvg().parentNode);
|
||||||
Blockly.DropDownDiv.show(this, primaryX, primaryY, secondaryX, secondaryY,
|
Blockly.DropDownDiv.show(
|
||||||
this.onHide.bind(this));
|
this, primaryX, primaryY, secondaryX, secondaryY, this.onHide.bind(this));
|
||||||
|
|
||||||
menu.setAllowAutoFocus(true);
|
menu.setAllowAutoFocus(true);
|
||||||
menuDom.focus();
|
menuDom.focus();
|
||||||
|
@ -267,7 +267,8 @@ Blockly.FieldDropdown.prototype.showEditor_ = function() {
|
||||||
if (this.sourceBlock_.isShadow()) {
|
if (this.sourceBlock_.isShadow()) {
|
||||||
this.savedPrimary_ = this.sourceBlock_.getColour();
|
this.savedPrimary_ = this.sourceBlock_.getColour();
|
||||||
this.sourceBlock_.setColour(this.sourceBlock_.getColourTertiary(),
|
this.sourceBlock_.setColour(this.sourceBlock_.getColourTertiary(),
|
||||||
this.sourceBlock_.getColourSecondary(), this.sourceBlock_.getColourTertiary());
|
this.sourceBlock_.getColourSecondary(),
|
||||||
|
this.sourceBlock_.getColourTertiary());
|
||||||
} else if (this.box_) {
|
} else if (this.box_) {
|
||||||
this.box_.setAttribute('fill', this.sourceBlock_.getColourTertiary());
|
this.box_.setAttribute('fill', this.sourceBlock_.getColourTertiary());
|
||||||
}
|
}
|
||||||
|
@ -283,7 +284,8 @@ Blockly.FieldDropdown.prototype.onHide = function() {
|
||||||
if (!this.disableColourChange_ && this.sourceBlock_) {
|
if (!this.disableColourChange_ && this.sourceBlock_) {
|
||||||
if (this.sourceBlock_.isShadow()) {
|
if (this.sourceBlock_.isShadow()) {
|
||||||
this.sourceBlock_.setColour(this.savedPrimary_,
|
this.sourceBlock_.setColour(this.savedPrimary_,
|
||||||
this.sourceBlock_.getColourSecondary(), this.sourceBlock_.getColourTertiary());
|
this.sourceBlock_.getColourSecondary(),
|
||||||
|
this.sourceBlock_.getColourTertiary());
|
||||||
} else if (this.box_) {
|
} else if (this.box_) {
|
||||||
this.box_.setAttribute('fill', this.sourceBlock_.getColour());
|
this.box_.setAttribute('fill', this.sourceBlock_.getColour());
|
||||||
}
|
}
|
||||||
|
@ -480,8 +482,7 @@ Blockly.FieldDropdown.prototype.positionArrow = function(x) {
|
||||||
this.arrowX_ += Blockly.BlockSvg.BOX_FIELD_PADDING;
|
this.arrowX_ += Blockly.BlockSvg.BOX_FIELD_PADDING;
|
||||||
}
|
}
|
||||||
this.arrow_.setAttribute('transform',
|
this.arrow_.setAttribute('transform',
|
||||||
'translate(' + this.arrowX_ + ',' + this.arrowY_ + ')'
|
'translate(' + this.arrowX_ + ',' + this.arrowY_ + ')');
|
||||||
);
|
|
||||||
return addedWidth;
|
return addedWidth;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -253,7 +253,8 @@ Blockly.FieldIconMenu.prototype.showEditor_ = function() {
|
||||||
// Update source block colour to look selected
|
// Update source block colour to look selected
|
||||||
this.savedPrimary_ = this.sourceBlock_.getColour();
|
this.savedPrimary_ = this.sourceBlock_.getColour();
|
||||||
this.sourceBlock_.setColour(this.sourceBlock_.getColourSecondary(),
|
this.sourceBlock_.setColour(this.sourceBlock_.getColourSecondary(),
|
||||||
this.sourceBlock_.getColourSecondary(), this.sourceBlock_.getColourTertiary());
|
this.sourceBlock_.getColourSecondary(),
|
||||||
|
this.sourceBlock_.getColourTertiary());
|
||||||
|
|
||||||
var scale = this.sourceBlock_.workspace.scale;
|
var scale = this.sourceBlock_.workspace.scale;
|
||||||
// Offset for icon-type horizontal blocks.
|
// Offset for icon-type horizontal blocks.
|
||||||
|
@ -268,8 +269,7 @@ Blockly.FieldIconMenu.prototype.showEditor_ = function() {
|
||||||
var arrowY = this.arrowY_ + Blockly.DropDownDiv.ARROW_SIZE / 1.5;
|
var arrowY = this.arrowY_ + Blockly.DropDownDiv.ARROW_SIZE / 1.5;
|
||||||
// Flip the arrow on the button
|
// Flip the arrow on the button
|
||||||
this.arrowIcon_.setAttribute('transform',
|
this.arrowIcon_.setAttribute('transform',
|
||||||
'translate(' + arrowX + ',' + arrowY + ') rotate(180)');
|
'translate(' + arrowX + ',' + arrowY + ') rotate(180)');}
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -294,7 +294,8 @@ Blockly.FieldIconMenu.prototype.onHide_ = function() {
|
||||||
// when a block is dragged from the flyout.
|
// when a block is dragged from the flyout.
|
||||||
if (this.sourceBlock_) {
|
if (this.sourceBlock_) {
|
||||||
this.sourceBlock_.setColour(this.savedPrimary_,
|
this.sourceBlock_.setColour(this.savedPrimary_,
|
||||||
this.sourceBlock_.getColourSecondary(), this.sourceBlock_.getColourTertiary());
|
this.sourceBlock_.getColourSecondary(),
|
||||||
|
this.sourceBlock_.getColourTertiary());
|
||||||
}
|
}
|
||||||
Blockly.DropDownDiv.content_.removeAttribute('role');
|
Blockly.DropDownDiv.content_.removeAttribute('role');
|
||||||
Blockly.DropDownDiv.content_.removeAttribute('aria-haspopup');
|
Blockly.DropDownDiv.content_.removeAttribute('aria-haspopup');
|
||||||
|
|
|
@ -187,7 +187,7 @@ Blockly.FieldImage.prototype.render_ = function() {
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
Blockly.FieldImage.prototype.updateWidth = function() {
|
Blockly.FieldImage.prototype.updateWidth = function() {
|
||||||
// NOP
|
// NOP
|
||||||
};
|
};
|
||||||
|
|
||||||
Blockly.Field.register('field_image', Blockly.FieldImage);
|
Blockly.Field.register('field_image', Blockly.FieldImage);
|
||||||
|
|
|
@ -85,12 +85,13 @@ Blockly.FieldLabel.prototype.init = function() {
|
||||||
}
|
}
|
||||||
// Build the DOM.
|
// Build the DOM.
|
||||||
this.textElement_ = Blockly.utils.createSvgElement('text',
|
this.textElement_ = Blockly.utils.createSvgElement('text',
|
||||||
{'class': 'blocklyText',
|
{
|
||||||
'y': Blockly.BlockSvg.FIELD_TOP_PADDING,
|
'class': 'blocklyText',
|
||||||
'text-anchor': 'middle',
|
'y': Blockly.BlockSvg.FIELD_TOP_PADDING,
|
||||||
'dominant-baseline': 'middle',
|
'text-anchor': 'middle',
|
||||||
'dy': goog.userAgent.EDGE_OR_IE ? Blockly.Field.IE_TEXT_OFFSET : '0'
|
'dominant-baseline': 'middle',
|
||||||
}, null);
|
'dy': goog.userAgent.EDGE_OR_IE ? Blockly.Field.IE_TEXT_OFFSET : '0'
|
||||||
|
}, null);
|
||||||
if (this.class_) {
|
if (this.class_) {
|
||||||
Blockly.utils.addClass(this.textElement_, this.class_);
|
Blockly.utils.addClass(this.textElement_, this.class_);
|
||||||
}
|
}
|
||||||
|
|
|
@ -95,7 +95,7 @@ Blockly.FieldNumber.DROPDOWN_Y_PADDING = 8;
|
||||||
* @type {Array.<string>}
|
* @type {Array.<string>}
|
||||||
* @const
|
* @const
|
||||||
*/
|
*/
|
||||||
// Calculator order
|
// Calculator order
|
||||||
Blockly.FieldNumber.NUMPAD_BUTTONS =
|
Blockly.FieldNumber.NUMPAD_BUTTONS =
|
||||||
['7', '8', '9', '4', '5', '6', '1', '2', '3', '.', '0', '-', ' '];
|
['7', '8', '9', '4', '5', '6', '1', '2', '3', '.', '0', '-', ' '];
|
||||||
|
|
||||||
|
|
|
@ -50,10 +50,10 @@ Blockly.FieldNumberDropdown = function(value, menuGenerator, opt_min, opt_max,
|
||||||
this.setConstraints_ = Blockly.FieldNumber.prototype.setConstraints_;
|
this.setConstraints_ = Blockly.FieldNumber.prototype.setConstraints_;
|
||||||
|
|
||||||
var numRestrictor = Blockly.FieldNumber.prototype.getNumRestrictor.call(
|
var numRestrictor = Blockly.FieldNumber.prototype.getNumRestrictor.call(
|
||||||
this, opt_min, opt_max, opt_precision
|
this, opt_min, opt_max, opt_precision
|
||||||
);
|
);
|
||||||
Blockly.FieldNumberDropdown.superClass_.constructor.call(
|
Blockly.FieldNumberDropdown.superClass_.constructor.call(
|
||||||
this, value, menuGenerator, opt_validator, numRestrictor
|
this, value, menuGenerator, opt_validator, numRestrictor
|
||||||
);
|
);
|
||||||
this.addArgType('numberdropdown');
|
this.addArgType('numberdropdown');
|
||||||
};
|
};
|
||||||
|
|
|
@ -90,17 +90,17 @@ Blockly.FieldTextDropdown.prototype.init = function() {
|
||||||
this.arrowX_ = 0;
|
this.arrowX_ = 0;
|
||||||
/** @type {Number} */
|
/** @type {Number} */
|
||||||
this.arrowY_ = 11;
|
this.arrowY_ = 11;
|
||||||
this.arrow_ = Blockly.utils.createSvgElement('image', {
|
this.arrow_ = Blockly.utils.createSvgElement('image',
|
||||||
'height': this.arrowSize_ + 'px',
|
{
|
||||||
'width': this.arrowSize_ + 'px'
|
'height': this.arrowSize_ + 'px',
|
||||||
});
|
'width': this.arrowSize_ + 'px'
|
||||||
|
});
|
||||||
this.arrow_.setAttributeNS('http://www.w3.org/1999/xlink',
|
this.arrow_.setAttributeNS('http://www.w3.org/1999/xlink',
|
||||||
'xlink:href', Blockly.mainWorkspace.options.pathToMedia + 'dropdown-arrow-dark.svg');
|
'xlink:href', Blockly.mainWorkspace.options.pathToMedia + 'dropdown-arrow-dark.svg');
|
||||||
this.arrow_.style.cursor = 'pointer';
|
this.arrow_.style.cursor = 'pointer';
|
||||||
this.fieldGroup_.appendChild(this.arrow_);
|
this.fieldGroup_.appendChild(this.arrow_);
|
||||||
this.mouseUpWrapper_ =
|
this.mouseUpWrapper_ =
|
||||||
Blockly.bindEvent_(this.arrow_, 'mouseup', this,
|
Blockly.bindEvent_(this.arrow_, 'mouseup', this, this.showDropdown_);
|
||||||
this.showDropdown_);
|
|
||||||
}
|
}
|
||||||
// Prevent the drop-down handler from changing the field colour on open.
|
// Prevent the drop-down handler from changing the field colour on open.
|
||||||
this.disableColourChange_ = true;
|
this.disableColourChange_ = true;
|
||||||
|
@ -124,12 +124,12 @@ Blockly.FieldTextDropdown.prototype.dispose = function() {
|
||||||
Blockly.FieldTextDropdown.prototype.showEditor_ = function() {
|
Blockly.FieldTextDropdown.prototype.showEditor_ = function() {
|
||||||
if (!this.dropDownOpen_) {
|
if (!this.dropDownOpen_) {
|
||||||
Blockly.FieldTextDropdown.superClass_.showEditor_.call(this, null, null,
|
Blockly.FieldTextDropdown.superClass_.showEditor_.call(this, null, null,
|
||||||
true, function() {
|
true, function() {
|
||||||
// When the drop-down arrow is clicked, hide text editor and show drop-down.
|
// When the drop-down arrow is clicked, hide text editor and show drop-down.
|
||||||
Blockly.WidgetDiv.hide();
|
Blockly.WidgetDiv.hide();
|
||||||
this.showDropdown_();
|
this.showDropdown_();
|
||||||
Blockly.Touch.clearTouchIdentifier();
|
Blockly.Touch.clearTouchIdentifier();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -248,7 +248,7 @@ Blockly.FieldTextInput.prototype.showEditor_ = function(
|
||||||
var dropDownArrow =
|
var dropDownArrow =
|
||||||
goog.dom.createDom(goog.dom.TagName.IMG, 'blocklyTextDropDownArrow');
|
goog.dom.createDom(goog.dom.TagName.IMG, 'blocklyTextDropDownArrow');
|
||||||
dropDownArrow.setAttribute('src',
|
dropDownArrow.setAttribute('src',
|
||||||
Blockly.mainWorkspace.options.pathToMedia + 'dropdown-arrow-dark.svg');
|
Blockly.mainWorkspace.options.pathToMedia + 'dropdown-arrow-dark.svg');
|
||||||
dropDownArrow.style.width = this.arrowSize_ + 'px';
|
dropDownArrow.style.width = this.arrowSize_ + 'px';
|
||||||
dropDownArrow.style.height = this.arrowSize_ + 'px';
|
dropDownArrow.style.height = this.arrowSize_ + 'px';
|
||||||
dropDownArrow.style.top = this.arrowY_ + 'px';
|
dropDownArrow.style.top = this.arrowY_ + 'px';
|
||||||
|
@ -262,7 +262,7 @@ Blockly.FieldTextInput.prototype.showEditor_ = function(
|
||||||
}
|
}
|
||||||
if (opt_arrowCallback) {
|
if (opt_arrowCallback) {
|
||||||
htmlInput.dropDownArrowMouseWrapper_ = Blockly.bindEvent_(dropDownArrow,
|
htmlInput.dropDownArrowMouseWrapper_ = Blockly.bindEvent_(dropDownArrow,
|
||||||
'mousedown', this, opt_arrowCallback);
|
'mousedown', this, opt_arrowCallback);
|
||||||
}
|
}
|
||||||
div.appendChild(dropDownArrow);
|
div.appendChild(dropDownArrow);
|
||||||
}
|
}
|
||||||
|
@ -305,15 +305,15 @@ Blockly.FieldTextInput.prototype.bindEvents_ = function(htmlInput) {
|
||||||
// Bind to keydown -- trap Enter without IME and Esc to hide.
|
// Bind to keydown -- trap Enter without IME and Esc to hide.
|
||||||
htmlInput.onKeyDownWrapper_ =
|
htmlInput.onKeyDownWrapper_ =
|
||||||
Blockly.bindEventWithChecks_(htmlInput, 'keydown', this,
|
Blockly.bindEventWithChecks_(htmlInput, 'keydown', this,
|
||||||
this.onHtmlInputKeyDown_);
|
this.onHtmlInputKeyDown_);
|
||||||
// Bind to keyup -- trap Enter; resize after every keystroke.
|
// Bind to keyup -- trap Enter; resize after every keystroke.
|
||||||
htmlInput.onKeyUpWrapper_ =
|
htmlInput.onKeyUpWrapper_ =
|
||||||
Blockly.bindEventWithChecks_(htmlInput, 'keyup', this,
|
Blockly.bindEventWithChecks_(htmlInput, 'keyup', this,
|
||||||
this.onHtmlInputChange_);
|
this.onHtmlInputChange_);
|
||||||
// Bind to keyPress -- repeatedly resize when holding down a key.
|
// Bind to keyPress -- repeatedly resize when holding down a key.
|
||||||
htmlInput.onKeyPressWrapper_ =
|
htmlInput.onKeyPressWrapper_ =
|
||||||
Blockly.bindEventWithChecks_(htmlInput, 'keypress', this,
|
Blockly.bindEventWithChecks_(htmlInput, 'keypress', this,
|
||||||
this.onHtmlInputChange_);
|
this.onHtmlInputChange_);
|
||||||
// For modern browsers (IE 9+, Chrome, Firefox, etc.) that support the
|
// For modern browsers (IE 9+, Chrome, Firefox, etc.) that support the
|
||||||
// DOM input event, also trigger onHtmlInputChange_ then. The input event
|
// DOM input event, also trigger onHtmlInputChange_ then. The input event
|
||||||
// is triggered on keypress but after the value of the text input
|
// is triggered on keypress but after the value of the text input
|
||||||
|
@ -460,10 +460,10 @@ Blockly.FieldTextInput.prototype.resizeEditor_ = function() {
|
||||||
if (Blockly.BlockSvg.FIELD_TEXTINPUT_EXPAND_PAST_TRUNCATION) {
|
if (Blockly.BlockSvg.FIELD_TEXTINPUT_EXPAND_PAST_TRUNCATION) {
|
||||||
// Resize the box based on the measured width of the text, pre-truncation
|
// Resize the box based on the measured width of the text, pre-truncation
|
||||||
var textWidth = Blockly.scratchBlocksUtils.measureText(
|
var textWidth = Blockly.scratchBlocksUtils.measureText(
|
||||||
Blockly.FieldTextInput.htmlInput_.style.fontSize,
|
Blockly.FieldTextInput.htmlInput_.style.fontSize,
|
||||||
Blockly.FieldTextInput.htmlInput_.style.fontFamily,
|
Blockly.FieldTextInput.htmlInput_.style.fontFamily,
|
||||||
Blockly.FieldTextInput.htmlInput_.style.fontWeight,
|
Blockly.FieldTextInput.htmlInput_.style.fontWeight,
|
||||||
Blockly.FieldTextInput.htmlInput_.value
|
Blockly.FieldTextInput.htmlInput_.value
|
||||||
);
|
);
|
||||||
// Size drawn in the canvas needs padding and scaling
|
// Size drawn in the canvas needs padding and scaling
|
||||||
textWidth += Blockly.FieldTextInput.TEXT_MEASURE_PADDING_MAGIC;
|
textWidth += Blockly.FieldTextInput.TEXT_MEASURE_PADDING_MAGIC;
|
||||||
|
|
|
@ -309,12 +309,16 @@ Blockly.FieldVariable.dropdownCreate = function() {
|
||||||
options[i] = [variableModelList[i].name, variableModelList[i].getId()];
|
options[i] = [variableModelList[i].name, variableModelList[i].getId()];
|
||||||
}
|
}
|
||||||
if (this.defaultType_ == Blockly.BROADCAST_MESSAGE_VARIABLE_TYPE) {
|
if (this.defaultType_ == Blockly.BROADCAST_MESSAGE_VARIABLE_TYPE) {
|
||||||
options.push([Blockly.Msg.NEW_BROADCAST_MESSAGE, Blockly.NEW_BROADCAST_MESSAGE_ID]);
|
options.push(
|
||||||
|
[Blockly.Msg.NEW_BROADCAST_MESSAGE, Blockly.NEW_BROADCAST_MESSAGE_ID]);
|
||||||
} else {
|
} else {
|
||||||
options.push([Blockly.Msg.RENAME_VARIABLE, Blockly.RENAME_VARIABLE_ID]);
|
options.push([Blockly.Msg.RENAME_VARIABLE, Blockly.RENAME_VARIABLE_ID]);
|
||||||
if (Blockly.Msg.DELETE_VARIABLE) {
|
if (Blockly.Msg.DELETE_VARIABLE) {
|
||||||
options.push([Blockly.Msg.DELETE_VARIABLE.replace('%1', name),
|
options.push(
|
||||||
Blockly.DELETE_VARIABLE_ID]);
|
[
|
||||||
|
Blockly.Msg.DELETE_VARIABLE.replace('%1', name),
|
||||||
|
Blockly.DELETE_VARIABLE_ID
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -77,14 +77,15 @@ Blockly.FieldVerticalSeparator.prototype.init = function() {
|
||||||
this.fieldGroup_.style.display = 'none';
|
this.fieldGroup_.style.display = 'none';
|
||||||
}
|
}
|
||||||
/** @type {SVGElement} */
|
/** @type {SVGElement} */
|
||||||
this.lineElement_ = Blockly.utils.createSvgElement('line', {
|
this.lineElement_ = Blockly.utils.createSvgElement('line',
|
||||||
'stroke': this.sourceBlock_.getColourSecondary(),
|
{
|
||||||
'stroke-linecap': 'round',
|
'stroke': this.sourceBlock_.getColourSecondary(),
|
||||||
'x1': 0,
|
'stroke-linecap': 'round',
|
||||||
'y1': 0,
|
'x1': 0,
|
||||||
'x2': 0,
|
'y1': 0,
|
||||||
'y2': this.height_
|
'x2': 0,
|
||||||
}, this.fieldGroup_);
|
'y2': this.height_
|
||||||
|
}, this.fieldGroup_);
|
||||||
|
|
||||||
this.sourceBlock_.getSvgRoot().appendChild(this.fieldGroup_);
|
this.sourceBlock_.getSvgRoot().appendChild(this.fieldGroup_);
|
||||||
};
|
};
|
||||||
|
@ -153,7 +154,7 @@ Blockly.FieldVerticalSeparator.prototype.render_ = function() {
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
Blockly.FieldVerticalSeparator.prototype.updateWidth = function() {
|
Blockly.FieldVerticalSeparator.prototype.updateWidth = function() {
|
||||||
// NOP
|
// NOP
|
||||||
};
|
};
|
||||||
|
|
||||||
Blockly.Field.register(
|
Blockly.Field.register(
|
||||||
|
|
|
@ -230,7 +230,7 @@ Blockly.HorizontalFlyout.prototype.setBackgroundPath_ = function(width, height)
|
||||||
path.push('a', this.CORNER_RADIUS, this.CORNER_RADIUS, 0, 0, 1,
|
path.push('a', this.CORNER_RADIUS, this.CORNER_RADIUS, 0, 0, 1,
|
||||||
this.CORNER_RADIUS, -this.CORNER_RADIUS);
|
this.CORNER_RADIUS, -this.CORNER_RADIUS);
|
||||||
path.push('h', width);
|
path.push('h', width);
|
||||||
// Right.
|
// Right.
|
||||||
path.push('a', this.CORNER_RADIUS, this.CORNER_RADIUS, 0, 0, 1,
|
path.push('a', this.CORNER_RADIUS, this.CORNER_RADIUS, 0, 0, 1,
|
||||||
this.CORNER_RADIUS, this.CORNER_RADIUS);
|
this.CORNER_RADIUS, this.CORNER_RADIUS);
|
||||||
path.push('v', height);
|
path.push('v', height);
|
||||||
|
@ -365,7 +365,7 @@ Blockly.HorizontalFlyout.prototype.layout_ = function(contents, gaps) {
|
||||||
// Clicking on a flyout button or label is a lot like clicking on the
|
// Clicking on a flyout button or label is a lot like clicking on the
|
||||||
// flyout background.
|
// flyout background.
|
||||||
this.listeners_.push(Blockly.bindEventWithChecks_(buttonSvg, 'mousedown',
|
this.listeners_.push(Blockly.bindEventWithChecks_(buttonSvg, 'mousedown',
|
||||||
this, this.onMouseDown_));
|
this, this.onMouseDown_));
|
||||||
|
|
||||||
|
|
||||||
this.buttons_.push(button);
|
this.buttons_.push(button);
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* @license
|
* @license
|
||||||
* Visual Blocks Editor
|
* Visual Blocks Editor
|
||||||
*
|
*
|
||||||
* Copyright 2011 Google Inc.
|
* Copyright 2017 Google Inc.
|
||||||
* https://developers.google.com/blockly/
|
* https://developers.google.com/blockly/
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
@ -39,6 +39,7 @@ goog.require('goog.events');
|
||||||
goog.require('goog.math.Rect');
|
goog.require('goog.math.Rect');
|
||||||
goog.require('goog.userAgent');
|
goog.require('goog.userAgent');
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class for a flyout.
|
* Class for a flyout.
|
||||||
* @param {!Object} workspaceOptions Dictionary of options for the workspace.
|
* @param {!Object} workspaceOptions Dictionary of options for the workspace.
|
||||||
|
@ -51,7 +52,7 @@ Blockly.VerticalFlyout = function(workspaceOptions) {
|
||||||
|
|
||||||
Blockly.VerticalFlyout.superClass_.constructor.call(this, workspaceOptions);
|
Blockly.VerticalFlyout.superClass_.constructor.call(this, workspaceOptions);
|
||||||
/**
|
/**
|
||||||
* Flyout should be laid out horizontally vs vertically.
|
* Flyout should be laid out vertically.
|
||||||
* @type {boolean}
|
* @type {boolean}
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
|
@ -154,15 +155,16 @@ Blockly.VerticalFlyout.prototype.createDom = function(tagName) {
|
||||||
var clipPath = Blockly.utils.createSvgElement('clipPath',
|
var clipPath = Blockly.utils.createSvgElement('clipPath',
|
||||||
{'id':'blocklyBlockMenuClipPath'}, this.defs_);
|
{'id':'blocklyBlockMenuClipPath'}, this.defs_);
|
||||||
this.clipRect_ = Blockly.utils.createSvgElement('rect',
|
this.clipRect_ = Blockly.utils.createSvgElement('rect',
|
||||||
{'id': 'blocklyBlockMenuClipRect',
|
{
|
||||||
|
'id': 'blocklyBlockMenuClipRect',
|
||||||
'height': '0',
|
'height': '0',
|
||||||
'width': '0',
|
'width': '0',
|
||||||
'y': '0',
|
'y': '0',
|
||||||
'x': '0'
|
'x': '0'
|
||||||
},
|
},
|
||||||
clipPath);
|
clipPath);
|
||||||
this.workspace_.svgGroup_.setAttribute('clip-path',
|
this.workspace_.svgGroup_.setAttribute(
|
||||||
'url(#blocklyBlockMenuClipPath)');
|
'clip-path', 'url(#blocklyBlockMenuClipPath)');
|
||||||
|
|
||||||
return this.svgGroup_;
|
return this.svgGroup_;
|
||||||
};
|
};
|
||||||
|
@ -477,8 +479,8 @@ Blockly.VerticalFlyout.prototype.layout_ = function(contents, gaps) {
|
||||||
button.show();
|
button.show();
|
||||||
// Clicking on a flyout button or label is a lot like clicking on the
|
// Clicking on a flyout button or label is a lot like clicking on the
|
||||||
// flyout background.
|
// flyout background.
|
||||||
this.listeners_.push(Blockly.bindEventWithChecks_(buttonSvg, 'mousedown',
|
this.listeners_.push(Blockly.bindEventWithChecks_(
|
||||||
this, this.onMouseDown_));
|
buttonSvg, 'mousedown', this, this.onMouseDown_));
|
||||||
|
|
||||||
this.buttons_.push(button);
|
this.buttons_.push(button);
|
||||||
cursorY += button.height + gaps[i];
|
cursorY += button.height + gaps[i];
|
||||||
|
@ -504,13 +506,13 @@ Blockly.VerticalFlyout.prototype.createRect_ = function(block, x, y,
|
||||||
// Create an invisible rectangle under the block to act as a button. Just
|
// Create an invisible rectangle under the block to act as a button. Just
|
||||||
// using the block as a button is poor, since blocks have holes in them.
|
// using the block as a button is poor, since blocks have holes in them.
|
||||||
var rect = Blockly.utils.createSvgElement('rect',
|
var rect = Blockly.utils.createSvgElement('rect',
|
||||||
{
|
{
|
||||||
'fill-opacity': 0,
|
'fill-opacity': 0,
|
||||||
'x': x,
|
'x': x,
|
||||||
'y': y,
|
'y': y,
|
||||||
'height': blockHW.height,
|
'height': blockHW.height,
|
||||||
'width': blockHW.width
|
'width': blockHW.width
|
||||||
}, null);
|
}, null);
|
||||||
rect.tooltip = block;
|
rect.tooltip = block;
|
||||||
Blockly.Tooltip.bindMouseEvents(rect);
|
Blockly.Tooltip.bindMouseEvents(rect);
|
||||||
// Add the rectangles under the blocks, so that the blocks' tooltips work.
|
// Add the rectangles under the blocks, so that the blocks' tooltips work.
|
||||||
|
@ -531,29 +533,29 @@ Blockly.VerticalFlyout.prototype.createRect_ = function(block, x, y,
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
Blockly.VerticalFlyout.prototype.createCheckbox_ = function(block, cursorX,
|
Blockly.VerticalFlyout.prototype.createCheckbox_ = function(block, cursorX,
|
||||||
cursorY, blockHW) {
|
cursorY, blockHW) {
|
||||||
var checkboxState = Blockly.VerticalFlyout.getCheckboxState(block.id);
|
var checkboxState = Blockly.VerticalFlyout.getCheckboxState(block.id);
|
||||||
var svgRoot = block.getSvgRoot();
|
var svgRoot = block.getSvgRoot();
|
||||||
var extraSpace = this.CHECKBOX_SIZE + this.CHECKBOX_MARGIN;
|
var extraSpace = this.CHECKBOX_SIZE + this.CHECKBOX_MARGIN;
|
||||||
var width = this.RTL ? this.getWidth() / this.workspace_.scale - extraSpace : cursorX;
|
var width = this.RTL ? this.getWidth() / this.workspace_.scale - extraSpace : cursorX;
|
||||||
var height = cursorY + blockHW.height / 2 - this.CHECKBOX_SIZE / 2;
|
var height = cursorY + blockHW.height / 2 - this.CHECKBOX_SIZE / 2;
|
||||||
var checkboxGroup = Blockly.utils.createSvgElement('g',
|
var checkboxGroup = Blockly.utils.createSvgElement('g',
|
||||||
{
|
{
|
||||||
'class': 'blocklyFlyoutCheckbox',
|
'class': 'blocklyFlyoutCheckbox',
|
||||||
'transform': 'translate(' + width + ', ' + height + ')'
|
'transform': 'translate(' + width + ', ' + height + ')'
|
||||||
}, null);
|
}, null);
|
||||||
Blockly.utils.createSvgElement('rect',
|
Blockly.utils.createSvgElement('rect',
|
||||||
{
|
{
|
||||||
'height': this.CHECKBOX_SIZE,
|
'height': this.CHECKBOX_SIZE,
|
||||||
'width': this.CHECKBOX_SIZE,
|
'width': this.CHECKBOX_SIZE,
|
||||||
'rx': this.CHECKBOX_CORNER_RADIUS,
|
'rx': this.CHECKBOX_CORNER_RADIUS,
|
||||||
'ry': this.CHECKBOX_CORNER_RADIUS
|
'ry': this.CHECKBOX_CORNER_RADIUS
|
||||||
}, checkboxGroup);
|
}, checkboxGroup);
|
||||||
Blockly.utils.createSvgElement('path',
|
Blockly.utils.createSvgElement('path',
|
||||||
{
|
{
|
||||||
'class': 'blocklyFlyoutCheckboxPath',
|
'class': 'blocklyFlyoutCheckboxPath',
|
||||||
'd': this.CHECKMARK_PATH
|
'd': this.CHECKMARK_PATH
|
||||||
}, checkboxGroup);
|
}, checkboxGroup);
|
||||||
var checkboxObj = {svgRoot: checkboxGroup, clicked: checkboxState, block: block};
|
var checkboxObj = {svgRoot: checkboxGroup, clicked: checkboxState, block: block};
|
||||||
|
|
||||||
if (checkboxState) {
|
if (checkboxState) {
|
||||||
|
|
|
@ -570,8 +570,8 @@ Blockly.Gesture.prototype.handleRightClick = function(e) {
|
||||||
*/
|
*/
|
||||||
Blockly.Gesture.prototype.handleWsStart = function(e, ws) {
|
Blockly.Gesture.prototype.handleWsStart = function(e, ws) {
|
||||||
goog.asserts.assert(!this.hasStarted_,
|
goog.asserts.assert(!this.hasStarted_,
|
||||||
'Tried to call gesture.handleWsStart, but the gesture had already been ' +
|
'Tried to call gesture.handleWsStart, but the gesture had already been ' +
|
||||||
'started.');
|
'started.');
|
||||||
this.setStartWorkspace_(ws);
|
this.setStartWorkspace_(ws);
|
||||||
this.mostRecentEvent_ = e;
|
this.mostRecentEvent_ = e;
|
||||||
this.doStart(e);
|
this.doStart(e);
|
||||||
|
@ -585,8 +585,8 @@ Blockly.Gesture.prototype.handleWsStart = function(e, ws) {
|
||||||
*/
|
*/
|
||||||
Blockly.Gesture.prototype.handleFlyoutStart = function(e, flyout) {
|
Blockly.Gesture.prototype.handleFlyoutStart = function(e, flyout) {
|
||||||
goog.asserts.assert(!this.hasStarted_,
|
goog.asserts.assert(!this.hasStarted_,
|
||||||
'Tried to call gesture.handleFlyoutStart, but the gesture had already been ' +
|
'Tried to call gesture.handleFlyoutStart, but the gesture had already ' +
|
||||||
'started.');
|
'been started.');
|
||||||
this.setStartFlyout_(flyout);
|
this.setStartFlyout_(flyout);
|
||||||
this.handleWsStart(e, flyout.getWorkspace());
|
this.handleWsStart(e, flyout.getWorkspace());
|
||||||
};
|
};
|
||||||
|
@ -599,8 +599,8 @@ Blockly.Gesture.prototype.handleFlyoutStart = function(e, flyout) {
|
||||||
*/
|
*/
|
||||||
Blockly.Gesture.prototype.handleBlockStart = function(e, block) {
|
Blockly.Gesture.prototype.handleBlockStart = function(e, block) {
|
||||||
goog.asserts.assert(!this.hasStarted_,
|
goog.asserts.assert(!this.hasStarted_,
|
||||||
'Tried to call gesture.handleBlockStart, but the gesture had already been ' +
|
'Tried to call gesture.handleBlockStart, but the gesture had already ' +
|
||||||
'started.');
|
'been started.');
|
||||||
this.setStartBlock(block);
|
this.setStartBlock(block);
|
||||||
this.mostRecentEvent_ = e;
|
this.mostRecentEvent_ = e;
|
||||||
};
|
};
|
||||||
|
@ -643,7 +643,7 @@ Blockly.Gesture.prototype.doBlockClick_ = function() {
|
||||||
// This is used to toggle the stack when any block in the stack is clicked.
|
// This is used to toggle the stack when any block in the stack is clicked.
|
||||||
var rootBlock = this.startBlock_.getRootBlock();
|
var rootBlock = this.startBlock_.getRootBlock();
|
||||||
Blockly.Events.fire(
|
Blockly.Events.fire(
|
||||||
new Blockly.Events.Ui(rootBlock, 'stackclick', undefined, undefined));
|
new Blockly.Events.Ui(rootBlock, 'stackclick', undefined, undefined));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.bringBlockToFront_();
|
this.bringBlockToFront_();
|
||||||
|
@ -684,8 +684,8 @@ Blockly.Gesture.prototype.bringBlockToFront_ = function() {
|
||||||
*/
|
*/
|
||||||
Blockly.Gesture.prototype.setStartField = function(field) {
|
Blockly.Gesture.prototype.setStartField = function(field) {
|
||||||
goog.asserts.assert(!this.hasStarted_,
|
goog.asserts.assert(!this.hasStarted_,
|
||||||
'Tried to call gesture.setStartField, but the gesture had already been ' +
|
'Tried to call gesture.setStartField, but the gesture had already been ' +
|
||||||
'started.');
|
'started.');
|
||||||
if (!this.startField_) {
|
if (!this.startField_) {
|
||||||
this.startField_ = field;
|
this.startField_ = field;
|
||||||
}
|
}
|
||||||
|
|
|
@ -443,13 +443,19 @@ Blockly.inject.bindDocumentEvents_ = function() {
|
||||||
Blockly.inject.loadSounds_ = function(pathToMedia, workspace) {
|
Blockly.inject.loadSounds_ = function(pathToMedia, workspace) {
|
||||||
var audioMgr = workspace.getAudioManager();
|
var audioMgr = workspace.getAudioManager();
|
||||||
audioMgr.load(
|
audioMgr.load(
|
||||||
[pathToMedia + 'click.mp3',
|
[
|
||||||
pathToMedia + 'click.wav',
|
pathToMedia + 'click.mp3',
|
||||||
pathToMedia + 'click.ogg'], 'click');
|
pathToMedia + 'click.wav',
|
||||||
|
pathToMedia + 'click.ogg'
|
||||||
|
],
|
||||||
|
'click');
|
||||||
audioMgr.load(
|
audioMgr.load(
|
||||||
[pathToMedia + 'delete.mp3',
|
[
|
||||||
pathToMedia + 'delete.ogg',
|
pathToMedia + 'delete.mp3',
|
||||||
pathToMedia + 'delete.wav'], 'delete');
|
pathToMedia + 'delete.ogg',
|
||||||
|
pathToMedia + 'delete.wav'
|
||||||
|
],
|
||||||
|
'delete');
|
||||||
|
|
||||||
// Bind temporary hooks that preload the sounds.
|
// Bind temporary hooks that preload the sounds.
|
||||||
var soundBinds = [];
|
var soundBinds = [];
|
||||||
|
|
|
@ -59,7 +59,7 @@ Blockly.scratchBlocksUtils.measureText = function(fontSize, fontFamily,
|
||||||
*/
|
*/
|
||||||
Blockly.scratchBlocksUtils.encodeEntities = function(rawStr) {
|
Blockly.scratchBlocksUtils.encodeEntities = function(rawStr) {
|
||||||
// CC-BY-SA https://stackoverflow.com/questions/18749591/encode-html-entities-in-javascript
|
// CC-BY-SA https://stackoverflow.com/questions/18749591/encode-html-entities-in-javascript
|
||||||
return rawStr.replace(/[\u00A0-\u9999<>\&]/gim, function(i) {
|
return rawStr.replace(/[\u00A0-\u9999<>&]/gim, function(i) {
|
||||||
return '&#' + i.charCodeAt(0) + ';';
|
return '&#' + i.charCodeAt(0) + ';';
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
@ -425,7 +425,7 @@ Blockly.WorkspaceSvg.prototype.createDom = function(opt_backgroundClass) {
|
||||||
bottom = this.addTrashcan_(bottom);
|
bottom = this.addTrashcan_(bottom);
|
||||||
}
|
}
|
||||||
if (this.options.zoomOptions && this.options.zoomOptions.controls) {
|
if (this.options.zoomOptions && this.options.zoomOptions.controls) {
|
||||||
bottom = this.addZoomControls_(bottom);
|
this.addZoomControls_(bottom);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.isFlyout) {
|
if (!this.isFlyout) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue