mirror of
https://github.com/scratchfoundation/scratch-blocks.git
synced 2025-06-15 22:33:38 -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);
|
||||
} else {
|
||||
this.colourSecondary_ = goog.color.rgbArrayToHex(
|
||||
goog.color.darken(goog.color.hexToRgb(this.colour_),
|
||||
0.1));
|
||||
goog.color.darken(goog.color.hexToRgb(this.colour_), 0.1));
|
||||
}
|
||||
if (colourTertiary !== undefined) {
|
||||
this.colourTertiary_ = this.makeColour_(colourTertiary);
|
||||
} else {
|
||||
this.colourTertiary_ = goog.color.rgbArrayToHex(
|
||||
goog.color.darken(goog.color.hexToRgb(this.colour_),
|
||||
0.2));
|
||||
goog.color.darken(goog.color.hexToRgb(this.colour_), 0.2));
|
||||
}
|
||||
if (this.rendered) {
|
||||
this.updateColour();
|
||||
|
|
|
@ -112,13 +112,14 @@ Blockly.BlockDragSurfaceSvg.prototype.createDom = function() {
|
|||
if (this.SVG_) {
|
||||
return; // Already created.
|
||||
}
|
||||
this.SVG_ = Blockly.utils.createSvgElement('svg', {
|
||||
'xmlns': Blockly.SVG_NS,
|
||||
'xmlns:html': Blockly.HTML_NS,
|
||||
'xmlns:xlink': 'http://www.w3.org/1999/xlink',
|
||||
'version': '1.1',
|
||||
'class': 'blocklyBlockDragSurface'
|
||||
}, this.container_);
|
||||
this.SVG_ = Blockly.utils.createSvgElement('svg',
|
||||
{
|
||||
'xmlns': Blockly.SVG_NS,
|
||||
'xmlns:html': Blockly.HTML_NS,
|
||||
'xmlns:xlink': 'http://www.w3.org/1999/xlink',
|
||||
'version': '1.1',
|
||||
'class': 'blocklyBlockDragSurface'
|
||||
}, this.container_);
|
||||
this.dragGroup_ = Blockly.utils.createSvgElement('g', {}, this.SVG_);
|
||||
// Belongs in Scratch Blocks, but not Blockly.
|
||||
var defs = Blockly.utils.createSvgElement('defs', {}, this.SVG_);
|
||||
|
@ -152,7 +153,7 @@ Blockly.BlockDragSurfaceSvg.prototype.createDropShadowDom_ = function(defs) {
|
|||
},
|
||||
dragShadowFilter);
|
||||
var componentTransfer = Blockly.utils.createSvgElement(
|
||||
'feComponentTransfer', {'result': 'offsetBlur'}, dragShadowFilter);
|
||||
'feComponentTransfer', {'result': 'offsetBlur'}, dragShadowFilter);
|
||||
// Shadow opacity is specified in the adjustable colour library,
|
||||
// since the darkness of the shadow largely depends on the workspace colour.
|
||||
Blockly.utils.createSvgElement('feFuncA',
|
||||
|
|
|
@ -679,10 +679,10 @@ Blockly.BlockSvg.prototype.renderDrawLeft_ = function(steps, connectionsXY, metr
|
|||
steps.push('m', metrics.fieldRadius + ',0');
|
||||
// Top-left rounded corner.
|
||||
steps.push(
|
||||
'A', metrics.fieldRadius + ',' + metrics.fieldRadius,
|
||||
'0', '0,0', '0,' + metrics.fieldRadius);
|
||||
'A', metrics.fieldRadius + ',' + metrics.fieldRadius,
|
||||
'0', '0,0', '0,' + metrics.fieldRadius);
|
||||
steps.push(
|
||||
'V', metrics.height - metrics.fieldRadius);
|
||||
'V', metrics.height - metrics.fieldRadius);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -710,8 +710,8 @@ Blockly.BlockSvg.prototype.renderDrawBottom_ = function(steps,
|
|||
} else {
|
||||
// Input
|
||||
steps.push(
|
||||
'a', metrics.fieldRadius + ',' + metrics.fieldRadius,
|
||||
'0', '0,0', metrics.fieldRadius + ',' + metrics.fieldRadius);
|
||||
'a', metrics.fieldRadius + ',' + metrics.fieldRadius,
|
||||
'0', '0,0', metrics.fieldRadius + ',' + metrics.fieldRadius);
|
||||
}
|
||||
|
||||
// Has statement
|
||||
|
@ -787,8 +787,8 @@ Blockly.BlockSvg.prototype.renderDrawRight_ = function(steps, connectionsXY, met
|
|||
} else {
|
||||
// Input
|
||||
steps.push(
|
||||
'a', metrics.fieldRadius + ',' + metrics.fieldRadius,
|
||||
'0', '0,0', metrics.fieldRadius + ',' + -1 * metrics.fieldRadius);
|
||||
'a', metrics.fieldRadius + ',' + metrics.fieldRadius,
|
||||
'0', '0,0', metrics.fieldRadius + ',' + -1 * metrics.fieldRadius);
|
||||
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);
|
||||
} else {
|
||||
steps.push(
|
||||
'a', metrics.fieldRadius + ',' + metrics.fieldRadius,
|
||||
'0', '0,0', '-' + metrics.fieldRadius + ',-' + metrics.fieldRadius);
|
||||
'a', metrics.fieldRadius + ',' + metrics.fieldRadius,
|
||||
'0', '0,0', '-' + metrics.fieldRadius + ',-' + metrics.fieldRadius);
|
||||
}
|
||||
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).
|
||||
* @private
|
||||
*/
|
||||
Blockly.BlockSvg.prototype.renderFields_ =
|
||||
function(fieldList, cursorX, cursorY) {
|
||||
/* eslint-disable indent */
|
||||
Blockly.BlockSvg.prototype.renderFields_ = function(fieldList, cursorX,
|
||||
cursorY) {
|
||||
if (this.RTL) {
|
||||
cursorX = -cursorX;
|
||||
}
|
||||
|
@ -738,8 +737,7 @@ Blockly.BlockSvg.prototype.renderFields_ =
|
|||
translateX += field.renderWidth;
|
||||
}
|
||||
root.setAttribute('transform',
|
||||
'translate(' + translateX + ', ' + translateY + ') ' + scale
|
||||
);
|
||||
'translate(' + translateX + ', ' + translateY + ') ' + scale);
|
||||
|
||||
// Fields are invisible on insertion marker.
|
||||
if (this.isInsertionMarker()) {
|
||||
|
@ -747,7 +745,7 @@ Blockly.BlockSvg.prototype.renderFields_ =
|
|||
}
|
||||
}
|
||||
return this.RTL ? -cursorX : cursorX;
|
||||
}; /* eslint-enable indent */
|
||||
};
|
||||
|
||||
/**
|
||||
* Computes the height and widths for each row and field.
|
||||
|
@ -1198,7 +1196,6 @@ Blockly.BlockSvg.prototype.renderClassify_ = function() {
|
|||
* @private
|
||||
*/
|
||||
Blockly.BlockSvg.prototype.renderDrawTop_ = function(steps, rightEdge) {
|
||||
/* eslint-disable indent */
|
||||
if (this.type == Blockly.PROCEDURES_DEFINITION_BLOCK_TYPE) {
|
||||
steps.push('m 0, 0');
|
||||
steps.push(Blockly.BlockSvg.TOP_LEFT_CORNER_DEFINE_HAT);
|
||||
|
@ -1231,7 +1228,7 @@ Blockly.BlockSvg.prototype.renderDrawTop_ = function(steps, rightEdge) {
|
|||
}
|
||||
}
|
||||
this.width = rightEdge;
|
||||
}; /* eslint-enable indent */
|
||||
};
|
||||
|
||||
/**
|
||||
* 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);
|
||||
inputShape.setAttribute('d', inputShapeInfo.path);
|
||||
inputShape.setAttribute('transform',
|
||||
'translate(' + inputShapeX + ',' + inputShapeY + ')'
|
||||
);
|
||||
'translate(' + inputShapeX + ',' + inputShapeY + ')');
|
||||
inputShape.setAttribute('data-argument-type', inputShapeInfo.argType);
|
||||
inputShape.setAttribute('style', 'visibility: visible');
|
||||
}
|
||||
|
@ -1481,9 +1477,8 @@ Blockly.BlockSvg.prototype.drawEdgeShapeRight_ = function(steps) {
|
|||
* @param {!Blockly.Connection} existingConnection The connection on the
|
||||
* existing block, which newBlock should line up with.
|
||||
*/
|
||||
Blockly.BlockSvg.prototype.positionNewBlock =
|
||||
function(newBlock, newConnection, existingConnection) {
|
||||
/* eslint-disable indent */
|
||||
Blockly.BlockSvg.prototype.positionNewBlock = function(newBlock, newConnection,
|
||||
existingConnection) {
|
||||
// We only need to position the new block if it's before the existing one,
|
||||
// otherwise its position is set by the previous block.
|
||||
if (newConnection.type == Blockly.NEXT_STATEMENT) {
|
||||
|
@ -1492,7 +1487,7 @@ Blockly.BlockSvg.prototype.positionNewBlock =
|
|||
|
||||
newBlock.moveBy(dx, dy);
|
||||
}
|
||||
}; /* eslint-enable indent */
|
||||
};
|
||||
|
||||
/**
|
||||
* 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 (this.isShadow()) {
|
||||
this.setColour(this.getColour(), this.getColourSecondary(),
|
||||
newParent.getColourTertiary());
|
||||
newParent.getColourTertiary());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -444,10 +444,9 @@ Blockly.bindEventWithChecks_ = function(node, name, thisObject, func,
|
|||
e.preventDefault();
|
||||
}
|
||||
};
|
||||
for (var i = 0, eventName;
|
||||
eventName = Blockly.Touch.TOUCH_MAP[name][i]; i++) {
|
||||
node.addEventListener(eventName, touchWrapFunc, false);
|
||||
bindData.push([node, eventName, touchWrapFunc]);
|
||||
for (var i = 0, type; type = Blockly.Touch.TOUCH_MAP[name][i]; i++) {
|
||||
node.addEventListener(type, touchWrapFunc, false);
|
||||
bindData.push([node, type, touchWrapFunc]);
|
||||
}
|
||||
}
|
||||
return bindData;
|
||||
|
@ -494,10 +493,9 @@ Blockly.bindEvent_ = function(node, name, thisObject, func) {
|
|||
// Stop the browser from scrolling/zooming the page.
|
||||
e.preventDefault();
|
||||
};
|
||||
for (var i = 0, eventName;
|
||||
eventName = Blockly.Touch.TOUCH_MAP[name][i]; i++) {
|
||||
node.addEventListener(eventName, touchWrapFunc, false);
|
||||
bindData.push([node, eventName, touchWrapFunc]);
|
||||
for (var i = 0, type; type = Blockly.Touch.TOUCH_MAP[name][i]; i++) {
|
||||
node.addEventListener(type, touchWrapFunc, false);
|
||||
bindData.push([node, type, touchWrapFunc]);
|
||||
}
|
||||
}
|
||||
return bindData;
|
||||
|
|
|
@ -455,10 +455,10 @@ Blockly.Connection.prototype.isConnectionAllowed = function(candidate) {
|
|||
break;
|
||||
}
|
||||
case Blockly.NEXT_STATEMENT: {
|
||||
// Scratch-specific behaviour:
|
||||
// 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
|
||||
// block on a stack or there's already a block connected inside the c.
|
||||
// Scratch-specific behaviour:
|
||||
// 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
|
||||
// block on a stack or there's already a block connected inside the c.
|
||||
if (firstStatementConnection &&
|
||||
this == this.sourceBlock_.previousConnection &&
|
||||
candidate.isConnectedToNonInsertionMarker() &&
|
||||
|
|
|
@ -120,7 +120,7 @@ Blockly.DataCategory.addSetVariableTo = function(xmlList, variable) {
|
|||
// </value>
|
||||
// </block>
|
||||
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>
|
||||
// </block>
|
||||
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>
|
||||
// </block>
|
||||
Blockly.DataCategory.addBlock(xmlList, variable, 'data_showvariable',
|
||||
'VARIABLE');
|
||||
'VARIABLE');
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -170,7 +170,7 @@ Blockly.DataCategory.addHideVariable = function(xmlList, variable) {
|
|||
// </value>
|
||||
// </block>
|
||||
Blockly.DataCategory.addBlock(xmlList, variable, 'data_hidevariable',
|
||||
'VARIABLE');
|
||||
'VARIABLE');
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -202,7 +202,7 @@ Blockly.DataCategory.addAddToList = function(xmlList, variable) {
|
|||
// </value>
|
||||
// </block>
|
||||
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>
|
||||
// </block>
|
||||
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>
|
||||
// </block>
|
||||
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>
|
||||
// </block>
|
||||
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>
|
||||
// </block>
|
||||
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>
|
||||
// </block>
|
||||
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';
|
||||
callback = function(button) {
|
||||
Blockly.Variables.createVariable(button.getTargetWorkspace(), null,
|
||||
Blockly.LIST_VARIABLE_TYPE);};
|
||||
Blockly.LIST_VARIABLE_TYPE);};
|
||||
}
|
||||
button.setAttribute('text', msg);
|
||||
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
|
||||
* name and shadow type of a second pair of value tags.
|
||||
*/
|
||||
Blockly.DataCategory.addBlock = function(xmlList,
|
||||
variable, blockType, fieldName, opt_value, opt_secondValue) {
|
||||
Blockly.DataCategory.addBlock = function(xmlList, variable, blockType,
|
||||
fieldName, opt_value, opt_secondValue) {
|
||||
if (Blockly.Blocks[blockType]) {
|
||||
var firstValueField;
|
||||
var secondValueField;
|
||||
if (opt_value) {
|
||||
firstValueField = Blockly.DataCategory.createValue(opt_value[0],
|
||||
opt_value[1], opt_value[2]);
|
||||
opt_value[1], opt_value[2]);
|
||||
}
|
||||
if (opt_secondValue) {
|
||||
secondValueField = Blockly.DataCategory.createValue(opt_secondValue[0],
|
||||
opt_secondValue[1], opt_value[2]);
|
||||
opt_secondValue[1], opt_value[2]);
|
||||
}
|
||||
|
||||
var gap = 8;
|
||||
|
|
|
@ -173,8 +173,8 @@ Blockly.DraggedConnectionManager.prototype.update = function(dxy, deleteArea, is
|
|||
this.closestConnection_ = null;
|
||||
}
|
||||
|
||||
// Prefer connecting over dropping into the trash can, but prefer dragging to
|
||||
// the toolbox over connecting to other blocks.
|
||||
// Prefer connecting over dropping into the trash can, but prefer dragging to
|
||||
// the toolbox over connecting to other blocks.
|
||||
var wouldConnect = !!this.closestConnection_ &&
|
||||
deleteArea != Blockly.DELETE_AREA_TOOLBOX;
|
||||
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.
|
||||
*/
|
||||
Blockly.DropDownDiv.showPositionedByBlock = function(owner, block,
|
||||
opt_onHide, opt_secondaryYOffset) {
|
||||
opt_onHide, opt_secondaryYOffset) {
|
||||
var scale = block.workspace.scale;
|
||||
var bBox = {width: block.width, height: block.height};
|
||||
bBox.width *= scale;
|
||||
|
@ -306,16 +306,16 @@ Blockly.DropDownDiv.getPositionMetrics = function(primaryX, primaryY, secondaryX
|
|||
renderX -= centerX;
|
||||
// Fit horizontally in the bounds.
|
||||
renderX = Math.max(
|
||||
boundPosition.left,
|
||||
Math.min(renderX, boundPosition.left + boundSize.width - divSize.width)
|
||||
boundPosition.left,
|
||||
Math.min(renderX, boundPosition.left + boundSize.width - divSize.width)
|
||||
);
|
||||
// After we've finished caclulating renderX, adjust the arrow to be relative to it.
|
||||
arrowX -= renderX;
|
||||
|
||||
// Pad the arrow by some pixels, primarily so that it doesn't render on top of a rounded border.
|
||||
arrowX = Math.max(
|
||||
Blockly.DropDownDiv.ARROW_HORIZONTAL_PADDING,
|
||||
Math.min(arrowX, divSize.width - Blockly.DropDownDiv.ARROW_HORIZONTAL_PADDING - Blockly.DropDownDiv.ARROW_SIZE)
|
||||
Blockly.DropDownDiv.ARROW_HORIZONTAL_PADDING,
|
||||
Math.min(arrowX, divSize.width - Blockly.DropDownDiv.ARROW_HORIZONTAL_PADDING - Blockly.DropDownDiv.ARROW_SIZE)
|
||||
);
|
||||
|
||||
// Calculate arrow Y. If we rendered secondary, add on bottom.
|
||||
|
|
|
@ -48,8 +48,8 @@ goog.require('goog.userAgent');
|
|||
*/
|
||||
Blockly.Field = function(text, opt_validator) {
|
||||
this.size_ = new goog.math.Size(
|
||||
Blockly.BlockSvg.FIELD_WIDTH,
|
||||
Blockly.BlockSvg.FIELD_HEIGHT);
|
||||
Blockly.BlockSvg.FIELD_WIDTH,
|
||||
Blockly.BlockSvg.FIELD_HEIGHT);
|
||||
this.setValue(text);
|
||||
this.setValidator(opt_validator);
|
||||
|
||||
|
@ -236,22 +236,22 @@ Blockly.Field.prototype.init = function() {
|
|||
var fieldX = (this.sourceBlock_.RTL) ? -size.width / 2 : size.width / 2;
|
||||
/** @type {!Element} */
|
||||
this.textElement_ = Blockly.utils.createSvgElement('text',
|
||||
{'class': this.className_,
|
||||
'x': fieldX,
|
||||
'y': size.height / 2 + Blockly.BlockSvg.FIELD_TOP_PADDING,
|
||||
'dominant-baseline': 'middle',
|
||||
'dy': goog.userAgent.EDGE_OR_IE ? Blockly.Field.IE_TEXT_OFFSET : '0',
|
||||
'text-anchor': 'middle'},
|
||||
this.fieldGroup_);
|
||||
{
|
||||
'class': this.className_,
|
||||
'x': fieldX,
|
||||
'y': size.height / 2 + Blockly.BlockSvg.FIELD_TOP_PADDING,
|
||||
'dominant-baseline': 'middle',
|
||||
'dy': goog.userAgent.EDGE_OR_IE ? Blockly.Field.IE_TEXT_OFFSET : '0',
|
||||
'text-anchor': 'middle'
|
||||
}, this.fieldGroup_);
|
||||
|
||||
this.updateEditable();
|
||||
this.sourceBlock_.getSvgRoot().appendChild(this.fieldGroup_);
|
||||
// Force a render.
|
||||
this.render_();
|
||||
this.size_.width = 0;
|
||||
this.mouseDownWrapper_ =
|
||||
Blockly.bindEventWithChecks_(this.getClickTarget_(), 'mousedown', this,
|
||||
this.onMouseDown_);
|
||||
this.mouseDownWrapper_ = Blockly.bindEventWithChecks_(
|
||||
this.getClickTarget_(), 'mousedown', this, this.onMouseDown_);
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -224,20 +224,18 @@ Blockly.FieldAngle.prototype.showEditor_ = function() {
|
|||
'r': Blockly.FieldAngle.HANDLE_RADIUS,
|
||||
'class': 'blocklyAngleDragHandle'
|
||||
}, this.handle_);
|
||||
this.arrowSvg_ = Blockly.utils.createSvgElement(
|
||||
'image',
|
||||
{
|
||||
'width': Blockly.FieldAngle.ARROW_WIDTH,
|
||||
'height': Blockly.FieldAngle.ARROW_WIDTH,
|
||||
'x': -Blockly.FieldAngle.ARROW_WIDTH / 2,
|
||||
'y': -Blockly.FieldAngle.ARROW_WIDTH / 2
|
||||
},
|
||||
this.handle_
|
||||
);
|
||||
this.arrowSvg_ = Blockly.utils.createSvgElement('image',
|
||||
{
|
||||
'width': Blockly.FieldAngle.ARROW_WIDTH,
|
||||
'height': Blockly.FieldAngle.ARROW_WIDTH,
|
||||
'x': -Blockly.FieldAngle.ARROW_WIDTH / 2,
|
||||
'y': -Blockly.FieldAngle.ARROW_WIDTH / 2
|
||||
},
|
||||
this.handle_);
|
||||
this.arrowSvg_.setAttributeNS(
|
||||
'http://www.w3.org/1999/xlink',
|
||||
'xlink:href',
|
||||
Blockly.mainWorkspace.options.pathToMedia + Blockly.FieldAngle.ARROW_SVG_PATH
|
||||
'http://www.w3.org/1999/xlink',
|
||||
'xlink:href',
|
||||
Blockly.mainWorkspace.options.pathToMedia + Blockly.FieldAngle.ARROW_SVG_PATH
|
||||
);
|
||||
|
||||
Blockly.DropDownDiv.setColour(this.sourceBlock_.parentBlock_.getColour(),
|
||||
|
|
|
@ -152,15 +152,15 @@ Blockly.FieldColourSlider.prototype.createColourStops_ = function(channel) {
|
|||
Blockly.FieldColourSlider.prototype.setGradient_ = function(node, channel) {
|
||||
var gradient = this.createColourStops_(channel).join(',');
|
||||
goog.style.setStyle(node, 'background',
|
||||
'-moz-linear-gradient(left, ' + gradient + ')');
|
||||
'-moz-linear-gradient(left, ' + gradient + ')');
|
||||
goog.style.setStyle(node, 'background',
|
||||
'-webkit-linear-gradient(left, ' + gradient + ')');
|
||||
'-webkit-linear-gradient(left, ' + gradient + ')');
|
||||
goog.style.setStyle(node, 'background',
|
||||
'-o-linear-gradient(left, ' + gradient + ')');
|
||||
'-o-linear-gradient(left, ' + gradient + ')');
|
||||
goog.style.setStyle(node, 'background',
|
||||
'-ms-linear-gradient(left, ' + gradient + ')');
|
||||
'-ms-linear-gradient(left, ' + gradient + ')');
|
||||
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]);
|
||||
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);
|
||||
}
|
||||
if (colour !== null) {
|
||||
|
@ -301,9 +301,8 @@ Blockly.FieldColourSlider.prototype.showEditor_ = function() {
|
|||
this.hueSlider_.setMoveToPointEnabled(true);
|
||||
this.hueSlider_.render(div);
|
||||
|
||||
var saturationElements = this.createLabelDom_(
|
||||
Blockly.Msg.COLOUR_SATURATION_LABEL
|
||||
);
|
||||
var saturationElements =
|
||||
this.createLabelDom_(Blockly.Msg.COLOUR_SATURATION_LABEL);
|
||||
div.appendChild(saturationElements[0]);
|
||||
this.saturationReadout_ = saturationElements[1];
|
||||
this.saturationSlider_ = new goog.ui.Slider();
|
||||
|
@ -314,9 +313,8 @@ Blockly.FieldColourSlider.prototype.showEditor_ = function() {
|
|||
this.saturationSlider_.setMaximum(1.0);
|
||||
this.saturationSlider_.render(div);
|
||||
|
||||
var brightnessElements = this.createLabelDom_(
|
||||
Blockly.Msg.COLOUR_BRIGHTNESS_LABEL
|
||||
);
|
||||
var brightnessElements =
|
||||
this.createLabelDom_(Blockly.Msg.COLOUR_BRIGHTNESS_LABEL);
|
||||
div.appendChild(brightnessElements[0]);
|
||||
this.brightnessReadout_ = brightnessElements[1];
|
||||
this.brightnessSlider_ = new goog.ui.Slider();
|
||||
|
@ -327,14 +325,14 @@ Blockly.FieldColourSlider.prototype.showEditor_ = function() {
|
|||
this.brightnessSlider_.render(div);
|
||||
|
||||
Blockly.FieldColourSlider.hueChangeEventKey_ = goog.events.listen(this.hueSlider_,
|
||||
goog.ui.Component.EventType.CHANGE,
|
||||
this.sliderCallbackFactory_('hue'));
|
||||
goog.ui.Component.EventType.CHANGE,
|
||||
this.sliderCallbackFactory_('hue'));
|
||||
Blockly.FieldColourSlider.saturationChangeEventKey_ = goog.events.listen(this.saturationSlider_,
|
||||
goog.ui.Component.EventType.CHANGE,
|
||||
this.sliderCallbackFactory_('saturation'));
|
||||
goog.ui.Component.EventType.CHANGE,
|
||||
this.sliderCallbackFactory_('saturation'));
|
||||
Blockly.FieldColourSlider.brightnessChangeEventKey_ = goog.events.listen(this.brightnessSlider_,
|
||||
goog.ui.Component.EventType.CHANGE,
|
||||
this.sliderCallbackFactory_('brightness'));
|
||||
goog.ui.Component.EventType.CHANGE,
|
||||
this.sliderCallbackFactory_('brightness'));
|
||||
|
||||
if (Blockly.FieldColourSlider.activateEyedropper_) {
|
||||
var button = document.createElement('button');
|
||||
|
@ -343,11 +341,9 @@ Blockly.FieldColourSlider.prototype.showEditor_ = function() {
|
|||
image.src = Blockly.mainWorkspace.options.pathToMedia + Blockly.FieldColourSlider.EYEDROPPER_PATH;
|
||||
button.appendChild(image);
|
||||
div.appendChild(button);
|
||||
Blockly.FieldColourSlider.eyedropperEventData_ = Blockly.bindEventWithChecks_(button,
|
||||
'mousedown',
|
||||
this,
|
||||
this.activateEyedropperInternal_
|
||||
);
|
||||
Blockly.FieldColourSlider.eyedropperEventData_ =
|
||||
Blockly.bindEventWithChecks_(button, 'mousedown', this,
|
||||
this.activateEyedropperInternal_);
|
||||
}
|
||||
|
||||
Blockly.DropDownDiv.setColour('#ffffff', '#dddddd');
|
||||
|
|
|
@ -221,10 +221,10 @@ Blockly.FieldDropdown.prototype.showEditor_ = function() {
|
|||
// Activate the menu item.
|
||||
control.performActionInternal(e);
|
||||
}
|
||||
menu.getHandler().listen(menu.getElement(), goog.events.EventType.TOUCHSTART,
|
||||
callbackTouchStart);
|
||||
menu.getHandler().listen(menu.getElement(), goog.events.EventType.TOUCHEND,
|
||||
callbackTouchEnd);
|
||||
menu.getHandler().listen(
|
||||
menu.getElement(), goog.events.EventType.TOUCHSTART, callbackTouchStart);
|
||||
menu.getHandler().listen(
|
||||
menu.getElement(), goog.events.EventType.TOUCHEND, callbackTouchEnd);
|
||||
|
||||
// Record windowSize and scrollOffset before adding menu.
|
||||
menu.render(contentDiv);
|
||||
|
@ -256,8 +256,8 @@ Blockly.FieldDropdown.prototype.showEditor_ = function() {
|
|||
var secondaryY = position.top;
|
||||
// Set bounds to workspace; show the drop-down.
|
||||
Blockly.DropDownDiv.setBoundsElement(this.sourceBlock_.workspace.getParentSvg().parentNode);
|
||||
Blockly.DropDownDiv.show(this, primaryX, primaryY, secondaryX, secondaryY,
|
||||
this.onHide.bind(this));
|
||||
Blockly.DropDownDiv.show(
|
||||
this, primaryX, primaryY, secondaryX, secondaryY, this.onHide.bind(this));
|
||||
|
||||
menu.setAllowAutoFocus(true);
|
||||
menuDom.focus();
|
||||
|
@ -267,7 +267,8 @@ Blockly.FieldDropdown.prototype.showEditor_ = function() {
|
|||
if (this.sourceBlock_.isShadow()) {
|
||||
this.savedPrimary_ = this.sourceBlock_.getColour();
|
||||
this.sourceBlock_.setColour(this.sourceBlock_.getColourTertiary(),
|
||||
this.sourceBlock_.getColourSecondary(), this.sourceBlock_.getColourTertiary());
|
||||
this.sourceBlock_.getColourSecondary(),
|
||||
this.sourceBlock_.getColourTertiary());
|
||||
} else if (this.box_) {
|
||||
this.box_.setAttribute('fill', this.sourceBlock_.getColourTertiary());
|
||||
}
|
||||
|
@ -283,7 +284,8 @@ Blockly.FieldDropdown.prototype.onHide = function() {
|
|||
if (!this.disableColourChange_ && this.sourceBlock_) {
|
||||
if (this.sourceBlock_.isShadow()) {
|
||||
this.sourceBlock_.setColour(this.savedPrimary_,
|
||||
this.sourceBlock_.getColourSecondary(), this.sourceBlock_.getColourTertiary());
|
||||
this.sourceBlock_.getColourSecondary(),
|
||||
this.sourceBlock_.getColourTertiary());
|
||||
} else if (this.box_) {
|
||||
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.arrow_.setAttribute('transform',
|
||||
'translate(' + this.arrowX_ + ',' + this.arrowY_ + ')'
|
||||
);
|
||||
'translate(' + this.arrowX_ + ',' + this.arrowY_ + ')');
|
||||
return addedWidth;
|
||||
};
|
||||
|
||||
|
|
|
@ -253,7 +253,8 @@ Blockly.FieldIconMenu.prototype.showEditor_ = function() {
|
|||
// Update source block colour to look selected
|
||||
this.savedPrimary_ = this.sourceBlock_.getColour();
|
||||
this.sourceBlock_.setColour(this.sourceBlock_.getColourSecondary(),
|
||||
this.sourceBlock_.getColourSecondary(), this.sourceBlock_.getColourTertiary());
|
||||
this.sourceBlock_.getColourSecondary(),
|
||||
this.sourceBlock_.getColourTertiary());
|
||||
|
||||
var scale = this.sourceBlock_.workspace.scale;
|
||||
// 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;
|
||||
// Flip the arrow on the button
|
||||
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.
|
||||
if (this.sourceBlock_) {
|
||||
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('aria-haspopup');
|
||||
|
|
|
@ -187,7 +187,7 @@ Blockly.FieldImage.prototype.render_ = function() {
|
|||
* @private
|
||||
*/
|
||||
Blockly.FieldImage.prototype.updateWidth = function() {
|
||||
// NOP
|
||||
// NOP
|
||||
};
|
||||
|
||||
Blockly.Field.register('field_image', Blockly.FieldImage);
|
||||
|
|
|
@ -85,12 +85,13 @@ Blockly.FieldLabel.prototype.init = function() {
|
|||
}
|
||||
// Build the DOM.
|
||||
this.textElement_ = Blockly.utils.createSvgElement('text',
|
||||
{'class': 'blocklyText',
|
||||
'y': Blockly.BlockSvg.FIELD_TOP_PADDING,
|
||||
'text-anchor': 'middle',
|
||||
'dominant-baseline': 'middle',
|
||||
'dy': goog.userAgent.EDGE_OR_IE ? Blockly.Field.IE_TEXT_OFFSET : '0'
|
||||
}, null);
|
||||
{
|
||||
'class': 'blocklyText',
|
||||
'y': Blockly.BlockSvg.FIELD_TOP_PADDING,
|
||||
'text-anchor': 'middle',
|
||||
'dominant-baseline': 'middle',
|
||||
'dy': goog.userAgent.EDGE_OR_IE ? Blockly.Field.IE_TEXT_OFFSET : '0'
|
||||
}, null);
|
||||
if (this.class_) {
|
||||
Blockly.utils.addClass(this.textElement_, this.class_);
|
||||
}
|
||||
|
|
|
@ -95,7 +95,7 @@ Blockly.FieldNumber.DROPDOWN_Y_PADDING = 8;
|
|||
* @type {Array.<string>}
|
||||
* @const
|
||||
*/
|
||||
// Calculator order
|
||||
// Calculator order
|
||||
Blockly.FieldNumber.NUMPAD_BUTTONS =
|
||||
['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_;
|
||||
|
||||
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(
|
||||
this, value, menuGenerator, opt_validator, numRestrictor
|
||||
this, value, menuGenerator, opt_validator, numRestrictor
|
||||
);
|
||||
this.addArgType('numberdropdown');
|
||||
};
|
||||
|
|
|
@ -90,17 +90,17 @@ Blockly.FieldTextDropdown.prototype.init = function() {
|
|||
this.arrowX_ = 0;
|
||||
/** @type {Number} */
|
||||
this.arrowY_ = 11;
|
||||
this.arrow_ = Blockly.utils.createSvgElement('image', {
|
||||
'height': this.arrowSize_ + 'px',
|
||||
'width': this.arrowSize_ + 'px'
|
||||
});
|
||||
this.arrow_ = Blockly.utils.createSvgElement('image',
|
||||
{
|
||||
'height': this.arrowSize_ + 'px',
|
||||
'width': this.arrowSize_ + 'px'
|
||||
});
|
||||
this.arrow_.setAttributeNS('http://www.w3.org/1999/xlink',
|
||||
'xlink:href', Blockly.mainWorkspace.options.pathToMedia + 'dropdown-arrow-dark.svg');
|
||||
this.arrow_.style.cursor = 'pointer';
|
||||
this.fieldGroup_.appendChild(this.arrow_);
|
||||
this.mouseUpWrapper_ =
|
||||
Blockly.bindEvent_(this.arrow_, 'mouseup', this,
|
||||
this.showDropdown_);
|
||||
Blockly.bindEvent_(this.arrow_, 'mouseup', this, this.showDropdown_);
|
||||
}
|
||||
// Prevent the drop-down handler from changing the field colour on open.
|
||||
this.disableColourChange_ = true;
|
||||
|
@ -124,12 +124,12 @@ Blockly.FieldTextDropdown.prototype.dispose = function() {
|
|||
Blockly.FieldTextDropdown.prototype.showEditor_ = function() {
|
||||
if (!this.dropDownOpen_) {
|
||||
Blockly.FieldTextDropdown.superClass_.showEditor_.call(this, null, null,
|
||||
true, function() {
|
||||
// When the drop-down arrow is clicked, hide text editor and show drop-down.
|
||||
Blockly.WidgetDiv.hide();
|
||||
this.showDropdown_();
|
||||
Blockly.Touch.clearTouchIdentifier();
|
||||
});
|
||||
true, function() {
|
||||
// When the drop-down arrow is clicked, hide text editor and show drop-down.
|
||||
Blockly.WidgetDiv.hide();
|
||||
this.showDropdown_();
|
||||
Blockly.Touch.clearTouchIdentifier();
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -248,7 +248,7 @@ Blockly.FieldTextInput.prototype.showEditor_ = function(
|
|||
var dropDownArrow =
|
||||
goog.dom.createDom(goog.dom.TagName.IMG, 'blocklyTextDropDownArrow');
|
||||
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.height = this.arrowSize_ + 'px';
|
||||
dropDownArrow.style.top = this.arrowY_ + 'px';
|
||||
|
@ -262,7 +262,7 @@ Blockly.FieldTextInput.prototype.showEditor_ = function(
|
|||
}
|
||||
if (opt_arrowCallback) {
|
||||
htmlInput.dropDownArrowMouseWrapper_ = Blockly.bindEvent_(dropDownArrow,
|
||||
'mousedown', this, opt_arrowCallback);
|
||||
'mousedown', this, opt_arrowCallback);
|
||||
}
|
||||
div.appendChild(dropDownArrow);
|
||||
}
|
||||
|
@ -305,15 +305,15 @@ Blockly.FieldTextInput.prototype.bindEvents_ = function(htmlInput) {
|
|||
// Bind to keydown -- trap Enter without IME and Esc to hide.
|
||||
htmlInput.onKeyDownWrapper_ =
|
||||
Blockly.bindEventWithChecks_(htmlInput, 'keydown', this,
|
||||
this.onHtmlInputKeyDown_);
|
||||
this.onHtmlInputKeyDown_);
|
||||
// Bind to keyup -- trap Enter; resize after every keystroke.
|
||||
htmlInput.onKeyUpWrapper_ =
|
||||
Blockly.bindEventWithChecks_(htmlInput, 'keyup', this,
|
||||
this.onHtmlInputChange_);
|
||||
this.onHtmlInputChange_);
|
||||
// Bind to keyPress -- repeatedly resize when holding down a key.
|
||||
htmlInput.onKeyPressWrapper_ =
|
||||
Blockly.bindEventWithChecks_(htmlInput, 'keypress', this,
|
||||
this.onHtmlInputChange_);
|
||||
this.onHtmlInputChange_);
|
||||
// For modern browsers (IE 9+, Chrome, Firefox, etc.) that support the
|
||||
// DOM input event, also trigger onHtmlInputChange_ then. The input event
|
||||
// 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) {
|
||||
// Resize the box based on the measured width of the text, pre-truncation
|
||||
var textWidth = Blockly.scratchBlocksUtils.measureText(
|
||||
Blockly.FieldTextInput.htmlInput_.style.fontSize,
|
||||
Blockly.FieldTextInput.htmlInput_.style.fontFamily,
|
||||
Blockly.FieldTextInput.htmlInput_.style.fontWeight,
|
||||
Blockly.FieldTextInput.htmlInput_.value
|
||||
Blockly.FieldTextInput.htmlInput_.style.fontSize,
|
||||
Blockly.FieldTextInput.htmlInput_.style.fontFamily,
|
||||
Blockly.FieldTextInput.htmlInput_.style.fontWeight,
|
||||
Blockly.FieldTextInput.htmlInput_.value
|
||||
);
|
||||
// Size drawn in the canvas needs padding and scaling
|
||||
textWidth += Blockly.FieldTextInput.TEXT_MEASURE_PADDING_MAGIC;
|
||||
|
|
|
@ -309,12 +309,16 @@ Blockly.FieldVariable.dropdownCreate = function() {
|
|||
options[i] = [variableModelList[i].name, variableModelList[i].getId()];
|
||||
}
|
||||
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 {
|
||||
options.push([Blockly.Msg.RENAME_VARIABLE, Blockly.RENAME_VARIABLE_ID]);
|
||||
if (Blockly.Msg.DELETE_VARIABLE) {
|
||||
options.push([Blockly.Msg.DELETE_VARIABLE.replace('%1', name),
|
||||
Blockly.DELETE_VARIABLE_ID]);
|
||||
options.push(
|
||||
[
|
||||
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';
|
||||
}
|
||||
/** @type {SVGElement} */
|
||||
this.lineElement_ = Blockly.utils.createSvgElement('line', {
|
||||
'stroke': this.sourceBlock_.getColourSecondary(),
|
||||
'stroke-linecap': 'round',
|
||||
'x1': 0,
|
||||
'y1': 0,
|
||||
'x2': 0,
|
||||
'y2': this.height_
|
||||
}, this.fieldGroup_);
|
||||
this.lineElement_ = Blockly.utils.createSvgElement('line',
|
||||
{
|
||||
'stroke': this.sourceBlock_.getColourSecondary(),
|
||||
'stroke-linecap': 'round',
|
||||
'x1': 0,
|
||||
'y1': 0,
|
||||
'x2': 0,
|
||||
'y2': this.height_
|
||||
}, this.fieldGroup_);
|
||||
|
||||
this.sourceBlock_.getSvgRoot().appendChild(this.fieldGroup_);
|
||||
};
|
||||
|
@ -153,7 +154,7 @@ Blockly.FieldVerticalSeparator.prototype.render_ = function() {
|
|||
* @private
|
||||
*/
|
||||
Blockly.FieldVerticalSeparator.prototype.updateWidth = function() {
|
||||
// NOP
|
||||
// NOP
|
||||
};
|
||||
|
||||
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,
|
||||
this.CORNER_RADIUS, -this.CORNER_RADIUS);
|
||||
path.push('h', width);
|
||||
// Right.
|
||||
// Right.
|
||||
path.push('a', this.CORNER_RADIUS, this.CORNER_RADIUS, 0, 0, 1,
|
||||
this.CORNER_RADIUS, this.CORNER_RADIUS);
|
||||
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
|
||||
// flyout background.
|
||||
this.listeners_.push(Blockly.bindEventWithChecks_(buttonSvg, 'mousedown',
|
||||
this, this.onMouseDown_));
|
||||
this, this.onMouseDown_));
|
||||
|
||||
|
||||
this.buttons_.push(button);
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* @license
|
||||
* Visual Blocks Editor
|
||||
*
|
||||
* Copyright 2011 Google Inc.
|
||||
* Copyright 2017 Google Inc.
|
||||
* https://developers.google.com/blockly/
|
||||
*
|
||||
* 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.userAgent');
|
||||
|
||||
|
||||
/**
|
||||
* Class for a flyout.
|
||||
* @param {!Object} workspaceOptions Dictionary of options for the workspace.
|
||||
|
@ -51,7 +52,7 @@ Blockly.VerticalFlyout = function(workspaceOptions) {
|
|||
|
||||
Blockly.VerticalFlyout.superClass_.constructor.call(this, workspaceOptions);
|
||||
/**
|
||||
* Flyout should be laid out horizontally vs vertically.
|
||||
* Flyout should be laid out vertically.
|
||||
* @type {boolean}
|
||||
* @private
|
||||
*/
|
||||
|
@ -154,15 +155,16 @@ Blockly.VerticalFlyout.prototype.createDom = function(tagName) {
|
|||
var clipPath = Blockly.utils.createSvgElement('clipPath',
|
||||
{'id':'blocklyBlockMenuClipPath'}, this.defs_);
|
||||
this.clipRect_ = Blockly.utils.createSvgElement('rect',
|
||||
{'id': 'blocklyBlockMenuClipRect',
|
||||
{
|
||||
'id': 'blocklyBlockMenuClipRect',
|
||||
'height': '0',
|
||||
'width': '0',
|
||||
'y': '0',
|
||||
'x': '0'
|
||||
},
|
||||
clipPath);
|
||||
this.workspace_.svgGroup_.setAttribute('clip-path',
|
||||
'url(#blocklyBlockMenuClipPath)');
|
||||
this.workspace_.svgGroup_.setAttribute(
|
||||
'clip-path', 'url(#blocklyBlockMenuClipPath)');
|
||||
|
||||
return this.svgGroup_;
|
||||
};
|
||||
|
@ -477,8 +479,8 @@ Blockly.VerticalFlyout.prototype.layout_ = function(contents, gaps) {
|
|||
button.show();
|
||||
// Clicking on a flyout button or label is a lot like clicking on the
|
||||
// flyout background.
|
||||
this.listeners_.push(Blockly.bindEventWithChecks_(buttonSvg, 'mousedown',
|
||||
this, this.onMouseDown_));
|
||||
this.listeners_.push(Blockly.bindEventWithChecks_(
|
||||
buttonSvg, 'mousedown', this, this.onMouseDown_));
|
||||
|
||||
this.buttons_.push(button);
|
||||
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
|
||||
// using the block as a button is poor, since blocks have holes in them.
|
||||
var rect = Blockly.utils.createSvgElement('rect',
|
||||
{
|
||||
'fill-opacity': 0,
|
||||
'x': x,
|
||||
'y': y,
|
||||
'height': blockHW.height,
|
||||
'width': blockHW.width
|
||||
}, null);
|
||||
{
|
||||
'fill-opacity': 0,
|
||||
'x': x,
|
||||
'y': y,
|
||||
'height': blockHW.height,
|
||||
'width': blockHW.width
|
||||
}, null);
|
||||
rect.tooltip = block;
|
||||
Blockly.Tooltip.bindMouseEvents(rect);
|
||||
// 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
|
||||
*/
|
||||
Blockly.VerticalFlyout.prototype.createCheckbox_ = function(block, cursorX,
|
||||
cursorY, blockHW) {
|
||||
cursorY, blockHW) {
|
||||
var checkboxState = Blockly.VerticalFlyout.getCheckboxState(block.id);
|
||||
var svgRoot = block.getSvgRoot();
|
||||
var extraSpace = this.CHECKBOX_SIZE + this.CHECKBOX_MARGIN;
|
||||
var width = this.RTL ? this.getWidth() / this.workspace_.scale - extraSpace : cursorX;
|
||||
var height = cursorY + blockHW.height / 2 - this.CHECKBOX_SIZE / 2;
|
||||
var checkboxGroup = Blockly.utils.createSvgElement('g',
|
||||
{
|
||||
'class': 'blocklyFlyoutCheckbox',
|
||||
'transform': 'translate(' + width + ', ' + height + ')'
|
||||
}, null);
|
||||
{
|
||||
'class': 'blocklyFlyoutCheckbox',
|
||||
'transform': 'translate(' + width + ', ' + height + ')'
|
||||
}, null);
|
||||
Blockly.utils.createSvgElement('rect',
|
||||
{
|
||||
'height': this.CHECKBOX_SIZE,
|
||||
'width': this.CHECKBOX_SIZE,
|
||||
'rx': this.CHECKBOX_CORNER_RADIUS,
|
||||
'ry': this.CHECKBOX_CORNER_RADIUS
|
||||
}, checkboxGroup);
|
||||
{
|
||||
'height': this.CHECKBOX_SIZE,
|
||||
'width': this.CHECKBOX_SIZE,
|
||||
'rx': this.CHECKBOX_CORNER_RADIUS,
|
||||
'ry': this.CHECKBOX_CORNER_RADIUS
|
||||
}, checkboxGroup);
|
||||
Blockly.utils.createSvgElement('path',
|
||||
{
|
||||
'class': 'blocklyFlyoutCheckboxPath',
|
||||
'd': this.CHECKMARK_PATH
|
||||
}, checkboxGroup);
|
||||
{
|
||||
'class': 'blocklyFlyoutCheckboxPath',
|
||||
'd': this.CHECKMARK_PATH
|
||||
}, checkboxGroup);
|
||||
var checkboxObj = {svgRoot: checkboxGroup, clicked: checkboxState, block: block};
|
||||
|
||||
if (checkboxState) {
|
||||
|
|
|
@ -570,8 +570,8 @@ Blockly.Gesture.prototype.handleRightClick = function(e) {
|
|||
*/
|
||||
Blockly.Gesture.prototype.handleWsStart = function(e, ws) {
|
||||
goog.asserts.assert(!this.hasStarted_,
|
||||
'Tried to call gesture.handleWsStart, but the gesture had already been ' +
|
||||
'started.');
|
||||
'Tried to call gesture.handleWsStart, but the gesture had already been ' +
|
||||
'started.');
|
||||
this.setStartWorkspace_(ws);
|
||||
this.mostRecentEvent_ = e;
|
||||
this.doStart(e);
|
||||
|
@ -585,8 +585,8 @@ Blockly.Gesture.prototype.handleWsStart = function(e, ws) {
|
|||
*/
|
||||
Blockly.Gesture.prototype.handleFlyoutStart = function(e, flyout) {
|
||||
goog.asserts.assert(!this.hasStarted_,
|
||||
'Tried to call gesture.handleFlyoutStart, but the gesture had already been ' +
|
||||
'started.');
|
||||
'Tried to call gesture.handleFlyoutStart, but the gesture had already ' +
|
||||
'been started.');
|
||||
this.setStartFlyout_(flyout);
|
||||
this.handleWsStart(e, flyout.getWorkspace());
|
||||
};
|
||||
|
@ -599,8 +599,8 @@ Blockly.Gesture.prototype.handleFlyoutStart = function(e, flyout) {
|
|||
*/
|
||||
Blockly.Gesture.prototype.handleBlockStart = function(e, block) {
|
||||
goog.asserts.assert(!this.hasStarted_,
|
||||
'Tried to call gesture.handleBlockStart, but the gesture had already been ' +
|
||||
'started.');
|
||||
'Tried to call gesture.handleBlockStart, but the gesture had already ' +
|
||||
'been started.');
|
||||
this.setStartBlock(block);
|
||||
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.
|
||||
var rootBlock = this.startBlock_.getRootBlock();
|
||||
Blockly.Events.fire(
|
||||
new Blockly.Events.Ui(rootBlock, 'stackclick', undefined, undefined));
|
||||
new Blockly.Events.Ui(rootBlock, 'stackclick', undefined, undefined));
|
||||
}
|
||||
}
|
||||
this.bringBlockToFront_();
|
||||
|
@ -684,8 +684,8 @@ Blockly.Gesture.prototype.bringBlockToFront_ = function() {
|
|||
*/
|
||||
Blockly.Gesture.prototype.setStartField = function(field) {
|
||||
goog.asserts.assert(!this.hasStarted_,
|
||||
'Tried to call gesture.setStartField, but the gesture had already been ' +
|
||||
'started.');
|
||||
'Tried to call gesture.setStartField, but the gesture had already been ' +
|
||||
'started.');
|
||||
if (!this.startField_) {
|
||||
this.startField_ = field;
|
||||
}
|
||||
|
|
|
@ -443,13 +443,19 @@ Blockly.inject.bindDocumentEvents_ = function() {
|
|||
Blockly.inject.loadSounds_ = function(pathToMedia, workspace) {
|
||||
var audioMgr = workspace.getAudioManager();
|
||||
audioMgr.load(
|
||||
[pathToMedia + 'click.mp3',
|
||||
pathToMedia + 'click.wav',
|
||||
pathToMedia + 'click.ogg'], 'click');
|
||||
[
|
||||
pathToMedia + 'click.mp3',
|
||||
pathToMedia + 'click.wav',
|
||||
pathToMedia + 'click.ogg'
|
||||
],
|
||||
'click');
|
||||
audioMgr.load(
|
||||
[pathToMedia + 'delete.mp3',
|
||||
pathToMedia + 'delete.ogg',
|
||||
pathToMedia + 'delete.wav'], 'delete');
|
||||
[
|
||||
pathToMedia + 'delete.mp3',
|
||||
pathToMedia + 'delete.ogg',
|
||||
pathToMedia + 'delete.wav'
|
||||
],
|
||||
'delete');
|
||||
|
||||
// Bind temporary hooks that preload the sounds.
|
||||
var soundBinds = [];
|
||||
|
|
|
@ -59,7 +59,7 @@ Blockly.scratchBlocksUtils.measureText = function(fontSize, fontFamily,
|
|||
*/
|
||||
Blockly.scratchBlocksUtils.encodeEntities = function(rawStr) {
|
||||
// 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) + ';';
|
||||
});
|
||||
};
|
||||
|
|
|
@ -425,7 +425,7 @@ Blockly.WorkspaceSvg.prototype.createDom = function(opt_backgroundClass) {
|
|||
bottom = this.addTrashcan_(bottom);
|
||||
}
|
||||
if (this.options.zoomOptions && this.options.zoomOptions.controls) {
|
||||
bottom = this.addZoomControls_(bottom);
|
||||
this.addZoomControls_(bottom);
|
||||
}
|
||||
|
||||
if (!this.isFlyout) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue