mirror of
https://github.com/scratchfoundation/scratch-blocks.git
synced 2025-06-15 22:33:38 -04:00
More lint and small changes from Blockly
This commit is contained in:
parent
f0b6e72888
commit
3c992dee6a
19 changed files with 174 additions and 123 deletions
|
@ -51,7 +51,7 @@ goog.require('goog.string');
|
|||
* @param {?string} prototypeName Name of the language object containing
|
||||
* type-specific functions for this block.
|
||||
* @param {string=} opt_id Optional ID. Use this ID if provided, otherwise
|
||||
* create a new id.
|
||||
* create a new ID.
|
||||
* @constructor
|
||||
*/
|
||||
Blockly.Block = function(workspace, prototypeName, opt_id) {
|
||||
|
@ -1188,11 +1188,12 @@ Blockly.Block.prototype.appendDummyInput = function(opt_name) {
|
|||
* @param {!Object} json Structured data describing the block.
|
||||
*/
|
||||
Blockly.Block.prototype.jsonInit = function(json) {
|
||||
var warningPrefix = json['type'] ? 'Block "' + json['type'] + '": ' : '';
|
||||
|
||||
// Validate inputs.
|
||||
goog.asserts.assert(json['output'] == undefined ||
|
||||
json['previousStatement'] == undefined,
|
||||
'Must not have both an output and a previousStatement.');
|
||||
goog.asserts.assert(
|
||||
json['output'] == undefined || json['previousStatement'] == undefined,
|
||||
warningPrefix + 'Must not have both an output and a previousStatement.');
|
||||
|
||||
// Set basic properties of block.
|
||||
if (json['colour'] !== undefined) {
|
||||
|
@ -1343,11 +1344,11 @@ Blockly.Block.prototype.interpolate_ = function(message, args, lastDummyAlign) {
|
|||
var token = tokens[i];
|
||||
if (typeof token == 'number') {
|
||||
if (token <= 0 || token > args.length) {
|
||||
throw new Error('Block \"' + this.type + '\": ' +
|
||||
throw new Error('Block "' + this.type + '": ' +
|
||||
'Message index %' + token + ' out of range.');
|
||||
}
|
||||
if (indexDup[token]) {
|
||||
throw new Error('Block \"' + this.type + '\": ' +
|
||||
throw new Error('Block "' + this.type + '": ' +
|
||||
'Message index %' + token + ' duplicated.');
|
||||
}
|
||||
indexDup[token] = true;
|
||||
|
@ -1360,14 +1361,14 @@ Blockly.Block.prototype.interpolate_ = function(message, args, lastDummyAlign) {
|
|||
}
|
||||
}
|
||||
}
|
||||
if(indexCount != args.length) {
|
||||
throw new Error('Block \"' + this.type + '\": ' +
|
||||
if (indexCount != args.length) {
|
||||
throw new Error('Block "' + this.type + '": ' +
|
||||
'Message does not reference all ' + args.length + ' arg(s).');
|
||||
}
|
||||
// Add last dummy input if needed.
|
||||
if (elements.length && (typeof elements[elements.length - 1] == 'string' ||
|
||||
goog.string.startsWith(elements[elements.length - 1]['type'],
|
||||
'field_'))) {
|
||||
goog.string.startsWith(
|
||||
elements[elements.length - 1]['type'], 'field_'))) {
|
||||
var dummyInput = {type: 'input_dummy'};
|
||||
if (lastDummyAlign) {
|
||||
dummyInput['align'] = lastDummyAlign;
|
||||
|
@ -1487,8 +1488,8 @@ Blockly.Block.prototype.moveInputBefore = function(name, refName) {
|
|||
}
|
||||
}
|
||||
goog.asserts.assert(inputIndex != -1, 'Named input "%s" not found.', name);
|
||||
goog.asserts.assert(refIndex != -1, 'Reference input "%s" not found.',
|
||||
refName);
|
||||
goog.asserts.assert(
|
||||
refIndex != -1, 'Reference input "%s" not found.', refName);
|
||||
this.moveNumberedInputBefore(inputIndex, refIndex);
|
||||
};
|
||||
|
||||
|
@ -1502,9 +1503,9 @@ Blockly.Block.prototype.moveNumberedInputBefore = function(
|
|||
// Validate arguments.
|
||||
goog.asserts.assert(inputIndex != refIndex, 'Can\'t move input to itself.');
|
||||
goog.asserts.assert(inputIndex < this.inputList.length,
|
||||
'Input index ' + inputIndex + ' out of bounds.');
|
||||
'Input index ' + inputIndex + ' out of bounds.');
|
||||
goog.asserts.assert(refIndex <= this.inputList.length,
|
||||
'Reference input ' + refIndex + ' out of bounds.');
|
||||
'Reference input ' + refIndex + ' out of bounds.');
|
||||
// Remove input.
|
||||
var input = this.inputList[inputIndex];
|
||||
this.inputList.splice(inputIndex, 1);
|
||||
|
|
|
@ -36,7 +36,7 @@ goog.require('goog.asserts');
|
|||
/**
|
||||
* Class for a block dragger. It moves blocks around the workspace when they
|
||||
* are being dragged by a mouse or touch.
|
||||
* @param {!Blockly.Block} block The block to drag.
|
||||
* @param {!Blockly.BlockSvg} block The block to drag.
|
||||
* @param {!Blockly.WorkspaceSvg} workspace The workspace to drag on.
|
||||
* @constructor
|
||||
*/
|
||||
|
|
|
@ -1037,7 +1037,7 @@ Blockly.BlockSvg.prototype.setWarningText = function(text, opt_id) {
|
|||
}
|
||||
this.warning.setText(/** @type {string} */ (text), id);
|
||||
} else {
|
||||
// Dispose all warnings if no id is given.
|
||||
// Dispose all warnings if no ID is given.
|
||||
if (this.warning && !id) {
|
||||
this.warning.dispose();
|
||||
changedState = true;
|
||||
|
@ -1113,11 +1113,11 @@ Blockly.BlockSvg.prototype.setMouseThroughStyle = function(letMouseThrough) {
|
|||
*/
|
||||
Blockly.BlockSvg.prototype.setDeleteStyle = function(enable) {
|
||||
if (enable) {
|
||||
Blockly.utils.addClass(
|
||||
/** @type {!Element} */ (this.svgGroup_), 'blocklyDraggingDelete');
|
||||
Blockly.utils.addClass(/** @type {!Element} */ (this.svgGroup_),
|
||||
'blocklyDraggingDelete');
|
||||
} else {
|
||||
Blockly.utils.removeClass(
|
||||
/** @type {!Element} */ (this.svgGroup_), 'blocklyDraggingDelete');
|
||||
Blockly.utils.removeClass(/** @type {!Element} */ (this.svgGroup_),
|
||||
'blocklyDraggingDelete');
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -1164,9 +1164,8 @@ Blockly.BlockSvg.prototype.bringToFront = function() {
|
|||
* @param {(string|Array.<string>|null)=} opt_check Statement type or
|
||||
* list of statement types. Null/undefined if any type could be connected.
|
||||
*/
|
||||
Blockly.BlockSvg.prototype.setPreviousStatement =
|
||||
function(newBoolean, opt_check) {
|
||||
/* eslint-disable indent */
|
||||
Blockly.BlockSvg.prototype.setPreviousStatement = function(newBoolean,
|
||||
opt_check) {
|
||||
Blockly.BlockSvg.superClass_.setPreviousStatement.call(this, newBoolean,
|
||||
opt_check);
|
||||
|
||||
|
@ -1174,7 +1173,7 @@ Blockly.BlockSvg.prototype.setPreviousStatement =
|
|||
this.render();
|
||||
this.bumpNeighbours_();
|
||||
}
|
||||
}; /* eslint-enable indent */
|
||||
};
|
||||
|
||||
/**
|
||||
* Set whether another block can chain onto the bottom of this block.
|
||||
|
|
|
@ -126,8 +126,10 @@ Blockly.hueToRgb = function(hue) {
|
|||
* @return {!Object} Contains width and height properties.
|
||||
*/
|
||||
Blockly.svgSize = function(svg) {
|
||||
return {width: svg.cachedWidth_,
|
||||
height: svg.cachedHeight_};
|
||||
return {
|
||||
width: svg.cachedWidth_,
|
||||
height: svg.cachedHeight_
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -324,7 +326,6 @@ Blockly.confirm = function(message, callback) {
|
|||
callback(window.confirm(message));
|
||||
};
|
||||
|
||||
/* eslint-disable no-unused-vars */
|
||||
/**
|
||||
* Wrapper to window.prompt() that app developers may override to provide
|
||||
* alternatives to the modal browser window. Built-in browser prompts are
|
||||
|
@ -333,17 +334,16 @@ Blockly.confirm = function(message, callback) {
|
|||
* @param {string} message The message to display to the user.
|
||||
* @param {string} defaultValue The value to initialize the prompt with.
|
||||
* @param {!function(string)} callback The callback for handling user response.
|
||||
* @param {?string} opt_title An optional title for the prompt.
|
||||
* @param {?string} opt_varType An optional variable type for variable specific
|
||||
* @param {?string} _opt_title An optional title for the prompt.
|
||||
* @param {?string} _opt_varType An optional variable type for variable specific
|
||||
* prompt behavior.
|
||||
*/
|
||||
Blockly.prompt = function(message, defaultValue, callback, opt_title,
|
||||
opt_varType) {
|
||||
Blockly.prompt = function(message, defaultValue, callback, _opt_title,
|
||||
_opt_varType) {
|
||||
// opt_title and opt_varType are unused because we only need them to pass
|
||||
// information to the scratch-gui, which overwrites this function
|
||||
callback(window.prompt(message, defaultValue));
|
||||
};
|
||||
/* eslint-enable no-unused-vars */
|
||||
|
||||
/**
|
||||
* Helper function for defining a block from JSON. The resulting function has
|
||||
|
@ -365,19 +365,28 @@ Blockly.jsonInitFactory_ = function(jsonDef) {
|
|||
* @param {!Array.<!Object>} jsonArray An array of JSON block definitions.
|
||||
*/
|
||||
Blockly.defineBlocksWithJsonArray = function(jsonArray) {
|
||||
for (var i = 0, elem; elem = jsonArray[i]; i++) {
|
||||
var typename = elem.type;
|
||||
if (typename == null || typename === '') {
|
||||
console.warn('Block definition #' + i +
|
||||
' in JSON array is missing a type attribute. Skipping.');
|
||||
for (var i = 0; i < jsonArray.length; i++) {
|
||||
var elem = jsonArray[i];
|
||||
if (!elem) {
|
||||
console.warn(
|
||||
'Block definition #' + i + ' in JSON array is ' + elem + '. ' +
|
||||
'Skipping.');
|
||||
} else {
|
||||
if (Blockly.Blocks[typename]) {
|
||||
console.warn('Block definition #' + i +
|
||||
' in JSON array overwrites prior definition of "' + typename + '".');
|
||||
var typename = elem.type;
|
||||
if (typename == null || typename === '') {
|
||||
console.warn(
|
||||
'Block definition #' + i +
|
||||
' in JSON array is missing a type attribute. Skipping.');
|
||||
} else {
|
||||
if (Blockly.Blocks[typename]) {
|
||||
console.warn(
|
||||
'Block definition #' + i + ' in JSON array' +
|
||||
' overwrites prior definition of "' + typename + '".');
|
||||
}
|
||||
Blockly.Blocks[typename] = {
|
||||
init: Blockly.jsonInitFactory_(elem)
|
||||
};
|
||||
}
|
||||
Blockly.Blocks[typename] = {
|
||||
init: Blockly.jsonInitFactory_(elem)
|
||||
};
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -162,7 +162,7 @@ Blockly.Bubble.bubbleMouseUp_ = function(/*e*/) {
|
|||
Blockly.Bubble.prototype.rendered_ = false;
|
||||
|
||||
/**
|
||||
* Absolute coordinate of anchor point, in workspace coordinates
|
||||
* Absolute coordinate of anchor point, in workspace coordinates.
|
||||
* @type {goog.math.Coordinate}
|
||||
* @private
|
||||
*/
|
||||
|
@ -256,10 +256,8 @@ Blockly.Bubble.prototype.createDom_ = function(content, hasResize) {
|
|||
Blockly.utils.createSvgElement('line',
|
||||
{
|
||||
'class': 'blocklyResizeLine',
|
||||
'x1': resizeSize / 3,
|
||||
'y1': resizeSize - 1,
|
||||
'x2': resizeSize - 1,
|
||||
'y2': resizeSize / 3
|
||||
'x1': resizeSize / 3, 'y1': resizeSize - 1,
|
||||
'x2': resizeSize - 1, 'y2': resizeSize / 3
|
||||
}, this.resizeGroup_);
|
||||
Blockly.utils.createSvgElement('line',
|
||||
{
|
||||
|
@ -371,11 +369,16 @@ Blockly.Bubble.prototype.registerResizeEvent = function(callback) {
|
|||
|
||||
/**
|
||||
* Move this bubble to the top of the stack.
|
||||
* @return {!boolean} Whether or not the bubble has been moved.
|
||||
* @private
|
||||
*/
|
||||
Blockly.Bubble.prototype.promote_ = function() {
|
||||
var svgGroup = this.bubbleGroup_.parentNode;
|
||||
svgGroup.appendChild(this.bubbleGroup_);
|
||||
if (svgGroup.lastChild !== this.bubbleGroup_) {
|
||||
svgGroup.appendChild(this.bubbleGroup_);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -448,8 +451,17 @@ Blockly.Bubble.prototype.positionBubble_ = function() {
|
|||
left += this.relativeLeft_;
|
||||
}
|
||||
var top = this.relativeTop_ + this.anchorXY_.y;
|
||||
this.bubbleGroup_.setAttribute('transform',
|
||||
'translate(' + left + ',' + top + ')');
|
||||
this.moveTo(left, top);
|
||||
};
|
||||
|
||||
/**
|
||||
* Move the bubble group to the specified location in workspace coordinates.
|
||||
* @param {number} x The x position to move to.
|
||||
* @param {number} y The y position to move to.
|
||||
* @package
|
||||
*/
|
||||
Blockly.Bubble.prototype.moveTo = function(x, y) {
|
||||
this.bubbleGroup_.setAttribute('transform', 'translate(' + x + ',' + y + ')');
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -126,10 +126,10 @@ Blockly.Comment.prototype.createEditor_ = function() {
|
|||
Blockly.bindEventWithChecks_(textarea, 'wheel', this, function(e) {
|
||||
e.stopPropagation();
|
||||
});
|
||||
Blockly.bindEventWithChecks_(textarea, 'change', this, function(/* e */) {
|
||||
Blockly.bindEventWithChecks_(textarea, 'change', this, function(_e) {
|
||||
if (this.text_ != textarea.value) {
|
||||
Blockly.Events.fire(new Blockly.Events.BlockChange(
|
||||
this.block_, 'comment', null, this.text_, textarea.value));
|
||||
this.block_, 'comment', null, this.text_, textarea.value));
|
||||
this.text_ = textarea.value;
|
||||
}
|
||||
});
|
||||
|
@ -213,17 +213,18 @@ Blockly.Comment.prototype.setVisible = function(visible) {
|
|||
|
||||
/**
|
||||
* Bring the comment to the top of the stack when clicked on.
|
||||
* @param {!Event} e Mouse up event.
|
||||
* @param {!Event} _e Mouse up event.
|
||||
* @private
|
||||
*/
|
||||
Blockly.Comment.prototype.textareaFocus_ = function(/*e*/) {
|
||||
Blockly.Comment.prototype.textareaFocus_ = function(_e) {
|
||||
// Ideally this would be hooked to the focus event for the comment.
|
||||
// However doing so in Firefox swallows the cursor for unknown reasons.
|
||||
// So this is hooked to mouseup instead. No big deal.
|
||||
this.bubble_.promote_();
|
||||
// Since the act of moving this node within the DOM causes a loss of focus,
|
||||
// we need to reapply the focus.
|
||||
this.textarea_.focus();
|
||||
if (this.bubble_.promote_()) {
|
||||
// Since the act of moving this node within the DOM causes a loss of focus,
|
||||
// we need to reapply the focus.
|
||||
this.textarea_.focus();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -76,6 +76,9 @@ Blockly.Extensions.register = function(name, initFn) {
|
|||
* registered.
|
||||
*/
|
||||
Blockly.Extensions.registerMixin = function(name, mixinObj) {
|
||||
if (!goog.isObject(mixinObj)){
|
||||
throw new Error('Error: Mixin "' + name + '" must be a object');
|
||||
}
|
||||
Blockly.Extensions.register(name, function() {
|
||||
this.mixin(mixinObj);
|
||||
});
|
||||
|
@ -373,24 +376,24 @@ Blockly.Extensions.buildTooltipForDropdown = function(dropdownName,
|
|||
* Emits console warnings when they are not.
|
||||
* @param {!Blockly.Block} block The block containing the dropdown
|
||||
* @param {string} dropdownName The name of the dropdown
|
||||
* @param {!Object<string, string>} lookupTable The string lookup table
|
||||
* @param {!Object.<string, string>} lookupTable The string lookup table
|
||||
* @private
|
||||
*/
|
||||
Blockly.Extensions.checkDropdownOptionsInTable_ =
|
||||
function(block, dropdownName, lookupTable) {
|
||||
// Validate all dropdown options have values.
|
||||
var dropdown = block.getField(dropdownName);
|
||||
if (!dropdown.isOptionListDynamic()) {
|
||||
var options = dropdown.getOptions();
|
||||
for (var i = 0; i < options.length; ++i) {
|
||||
var optionKey = options[i][1]; // label, then value
|
||||
if (lookupTable[optionKey] == null) {
|
||||
console.warn('No tooltip mapping for value ' + optionKey +
|
||||
' of field ' + dropdownName + ' of block type ' + block.type);
|
||||
}
|
||||
Blockly.Extensions.checkDropdownOptionsInTable_ = function(block, dropdownName,
|
||||
lookupTable) {
|
||||
// Validate all dropdown options have values.
|
||||
var dropdown = block.getField(dropdownName);
|
||||
if (!dropdown.isOptionListDynamic()) {
|
||||
var options = dropdown.getOptions();
|
||||
for (var i = 0; i < options.length; ++i) {
|
||||
var optionKey = options[i][1]; // label, then value
|
||||
if (lookupTable[optionKey] == null) {
|
||||
console.warn('No tooltip mapping for value ' + optionKey +
|
||||
' of field ' + dropdownName + ' of block type ' + block.type);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Builds an extension function that will install a dynamic tooltip. The
|
||||
|
|
|
@ -733,14 +733,13 @@ Blockly.Field.prototype.onMouseDown_ = function(e) {
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Change the tooltip text for this field.
|
||||
* @param {string|!Element} newTip Text for tooltip or a parent element to
|
||||
* @param {string|!Element} _newTip Text for tooltip or a parent element to
|
||||
* link to for its tooltip.
|
||||
* @abstract
|
||||
*/
|
||||
Blockly.Field.prototype.setTooltip = function(/*newTip*/) {
|
||||
Blockly.Field.prototype.setTooltip = function(_newTip) {
|
||||
// Non-abstract sub-classes may wish to implement this. See FieldLabel.
|
||||
};
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@ goog.require('goog.events');
|
|||
goog.require('goog.style');
|
||||
goog.require('goog.ui.ColorPicker');
|
||||
|
||||
|
||||
/**
|
||||
* Class for a colour input field.
|
||||
* @param {string} colour The initial colour in '#rrggbb' format.
|
||||
|
|
|
@ -30,6 +30,7 @@ goog.require('Blockly.Field');
|
|||
goog.require('Blockly.utils');
|
||||
|
||||
goog.require('goog.date');
|
||||
goog.require('goog.date.DateTime');
|
||||
goog.require('goog.dom');
|
||||
goog.require('goog.events');
|
||||
goog.require('goog.i18n.DateTimeSymbols');
|
||||
|
@ -156,7 +157,7 @@ Blockly.FieldDate.prototype.createWidget_ = function() {
|
|||
picker.setShowWeekNum(false);
|
||||
var div = Blockly.WidgetDiv.DIV;
|
||||
picker.render(div);
|
||||
picker.setDate(goog.date.fromIsoString(this.getValue()));
|
||||
picker.setDate(goog.date.DateTime.fromIsoString(this.getValue()));
|
||||
return picker;
|
||||
};
|
||||
|
||||
|
|
|
@ -367,7 +367,8 @@ Blockly.FieldDropdown.prototype.trimOptions_ = function() {
|
|||
};
|
||||
|
||||
/**
|
||||
* @return {boolean} True if the option list is generated by a function. Otherwise false.
|
||||
* @return {boolean} True if the option list is generated by a function.
|
||||
* Otherwise false.
|
||||
*/
|
||||
Blockly.FieldDropdown.prototype.isOptionListDynamic = function() {
|
||||
return goog.isFunction(this.menuGenerator_);
|
||||
|
|
|
@ -95,12 +95,12 @@ Blockly.FieldImage.prototype.init = function() {
|
|||
}
|
||||
/** @type {SVGElement} */
|
||||
this.imageElement_ = Blockly.utils.createSvgElement(
|
||||
'image',
|
||||
{
|
||||
'height': this.height_ + 'px',
|
||||
'width': this.width_ + 'px'
|
||||
},
|
||||
this.fieldGroup_);
|
||||
'image',
|
||||
{
|
||||
'height': this.height_ + 'px',
|
||||
'width': this.width_ + 'px'
|
||||
},
|
||||
this.fieldGroup_);
|
||||
this.setValue(this.src_);
|
||||
this.sourceBlock_.getSvgRoot().appendChild(this.fieldGroup_);
|
||||
|
||||
|
|
|
@ -359,11 +359,10 @@ Blockly.FieldVariable.prototype.onItemSelected = function(menu, menuItem) {
|
|||
};
|
||||
|
||||
/**
|
||||
* Whether this field references any Blockly variables. If true it may need to
|
||||
* be handled differently during serialization and deserialization. Subclasses
|
||||
* may override this.
|
||||
* @return {boolean} True if this field has any variable references.
|
||||
* Overrides referencesVariables(), indicating this field refers to a variable.
|
||||
* @return {boolean} True.
|
||||
* @package
|
||||
* @override
|
||||
*/
|
||||
Blockly.FieldVariable.prototype.referencesVariables = function() {
|
||||
return true;
|
||||
|
|
|
@ -50,7 +50,7 @@ Blockly.Flyout = function(workspaceOptions) {
|
|||
|
||||
/**
|
||||
* @type {!Blockly.Workspace}
|
||||
* @private
|
||||
* @protected
|
||||
*/
|
||||
this.workspace_ = new Blockly.WorkspaceSvg(workspaceOptions);
|
||||
this.workspace_.isFlyout = true;
|
||||
|
@ -352,7 +352,7 @@ Blockly.Flyout.prototype.getHeight = function() {
|
|||
};
|
||||
|
||||
/**
|
||||
* Get the flyout's workspace.
|
||||
* Get the workspace inside the flyout.
|
||||
* @return {!Blockly.WorkspaceSvg} The workspace inside the flyout.
|
||||
* @package
|
||||
*/
|
||||
|
@ -724,7 +724,7 @@ Blockly.Flyout.prototype.createBlock = function(originalBlock) {
|
|||
Blockly.Events.setGroup(true);
|
||||
Blockly.Events.fire(new Blockly.Events.Create(newBlock));
|
||||
// Fire a VarCreate event for each (if any) new variable created.
|
||||
for(var i = 0; i < newVariables.length; i++) {
|
||||
for (var i = 0; i < newVariables.length; i++) {
|
||||
var thisVariable = newVariables[i];
|
||||
Blockly.Events.fire(new Blockly.Events.VarCreate(thisVariable));
|
||||
}
|
||||
|
|
|
@ -145,20 +145,31 @@ Blockly.FlyoutButton.prototype.createDom = function() {
|
|||
if (!this.isLabel_) {
|
||||
// Shadow rectangle (light source does not mirror in RTL).
|
||||
var shadow = Blockly.utils.createSvgElement('rect',
|
||||
{'class': 'blocklyFlyoutButtonShadow',
|
||||
'rx': 4, 'ry': 4, 'x': 1, 'y': 1},
|
||||
this.svgGroup_);
|
||||
{
|
||||
'class': 'blocklyFlyoutButtonShadow',
|
||||
'rx': 4,
|
||||
'ry': 4,
|
||||
'x': 1,
|
||||
'y': 1
|
||||
},
|
||||
this.svgGroup_);
|
||||
}
|
||||
// Background rectangle.
|
||||
var rect = Blockly.utils.createSvgElement('rect',
|
||||
{'class': this.isLabel_ ?
|
||||
'blocklyFlyoutLabelBackground' : 'blocklyFlyoutButtonBackground',
|
||||
'rx': 4, 'ry': 4},
|
||||
{
|
||||
'class': this.isLabel_ ?
|
||||
'blocklyFlyoutLabelBackground' : 'blocklyFlyoutButtonBackground',
|
||||
'rx': 4, 'ry': 4
|
||||
},
|
||||
this.svgGroup_);
|
||||
|
||||
var svgText = Blockly.utils.createSvgElement('text',
|
||||
{'class': this.isLabel_ ? 'blocklyFlyoutLabelText' : 'blocklyText',
|
||||
'x': 0, 'y': 0, 'text-anchor': 'middle'},
|
||||
{
|
||||
'class': this.isLabel_ ? 'blocklyFlyoutLabelText' : 'blocklyText',
|
||||
'x': 0,
|
||||
'y': 0,
|
||||
'text-anchor': 'middle'
|
||||
},
|
||||
this.svgGroup_);
|
||||
svgText.textContent = this.text_;
|
||||
|
||||
|
|
|
@ -65,25 +65,37 @@ Blockly.Mutator.prototype.workspaceHeight_ = 0;
|
|||
Blockly.Mutator.prototype.drawIcon_ = function(group) {
|
||||
// Square with rounded corners.
|
||||
Blockly.utils.createSvgElement('rect',
|
||||
{'class': 'blocklyIconShape',
|
||||
'rx': '4', 'ry': '4',
|
||||
'height': '16', 'width': '16'},
|
||||
group);
|
||||
{
|
||||
'class': 'blocklyIconShape',
|
||||
'rx': '4',
|
||||
'ry': '4',
|
||||
'height': '16',
|
||||
'width': '16'
|
||||
},
|
||||
group);
|
||||
// Gear teeth.
|
||||
Blockly.utils.createSvgElement('path',
|
||||
{'class': 'blocklyIconSymbol',
|
||||
'd': 'm4.203,7.296 0,1.368 -0.92,0.677 -0.11,0.41 0.9,1.559 ' +
|
||||
'0.41,0.11 1.043,-0.457 1.187,0.683 0.127,1.134 0.3,0.3 ' +
|
||||
'1.8,0 0.3,-0.299 0.127,-1.138 1.185,-0.682 1.046,0.458 0.409,-0.11 ' +
|
||||
'0.9,-1.559 -0.11,-0.41 -0.92,-0.677 0,-1.366 0.92,-0.677 0.11,-0.41 ' +
|
||||
'-0.9,-1.559 -0.409,-0.109 -1.046,0.458 -1.185,-0.682 -0.127,-1.138 ' +
|
||||
'-0.3,-0.299 -1.8,0 -0.3,0.3 -0.126,1.135 -1.187,0.682 -1.043,-0.457 ' +
|
||||
'-0.41,0.11 -0.899,1.559 0.108,0.409z'},
|
||||
group);
|
||||
{
|
||||
'class': 'blocklyIconSymbol',
|
||||
'd': 'm4.203,7.296 0,1.368 -0.92,0.677 -0.11,0.41 0.9,1.559 0.41,' +
|
||||
'0.11 1.043,-0.457 1.187,0.683 0.127,1.134 0.3,0.3 1.8,0 0.3,' +
|
||||
'-0.299 0.127,-1.138 1.185,-0.682 1.046,0.458 0.409,-0.11 0.9,' +
|
||||
'-1.559 -0.11,-0.41 -0.92,-0.677 0,-1.366 0.92,-0.677 0.11,' +
|
||||
'-0.41 -0.9,-1.559 -0.409,-0.109 -1.046,0.458 -1.185,-0.682 ' +
|
||||
'-0.127,-1.138 -0.3,-0.299 -1.8,0 -0.3,0.3 -0.126,1.135 -1.187,' +
|
||||
'0.682 -1.043,-0.457 -0.41,0.11 -0.899,1.559 0.108,0.409z'
|
||||
},
|
||||
group);
|
||||
// Axle hole.
|
||||
Blockly.utils.createSvgElement('circle',
|
||||
{'class': 'blocklyIconShape', 'r': '2.7', 'cx': '8', 'cy': '8'},
|
||||
group);
|
||||
Blockly.utils.createSvgElement(
|
||||
'circle',
|
||||
{
|
||||
'class': 'blocklyIconShape',
|
||||
'r': '2.7',
|
||||
'cx': '8',
|
||||
'cy': '8'
|
||||
},
|
||||
group);
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -258,8 +258,8 @@ Blockly.Scrollbar.prototype.origin_ = new goog.math.Coordinate(0, 0);
|
|||
Blockly.Scrollbar.prototype.originHasChanged_ = true;
|
||||
|
||||
/**
|
||||
* The size of the area within which the scrollbar handle can move.
|
||||
* Coordinate system: pixel coordinates.
|
||||
* The size of the area within which the scrollbar handle can move, in CSS
|
||||
* pixels.
|
||||
* @type {number}
|
||||
* @private
|
||||
*/
|
||||
|
|
|
@ -34,6 +34,7 @@ goog.require('goog.events');
|
|||
goog.require('goog.events.BrowserFeature');
|
||||
goog.require('goog.string');
|
||||
|
||||
|
||||
/**
|
||||
* Which touch events are we currently paying attention to?
|
||||
* @type {DOMString}
|
||||
|
@ -63,7 +64,7 @@ Blockly.longPid_ = 0;
|
|||
|
||||
/**
|
||||
* Context menus on touch devices are activated using a long-press.
|
||||
* Unfortunately the contextmenu touch event is currently (2015) only suported
|
||||
* Unfortunately the contextmenu touch event is currently (2015) only supported
|
||||
* by Chrome. This function is fired on any touchstart event, queues a task,
|
||||
* which after about a second opens the context menu. The tasks is killed
|
||||
* if the touch event terminates early.
|
||||
|
@ -153,7 +154,7 @@ Blockly.Touch.getTouchIdentifierFromEvent = function(e) {
|
|||
Blockly.Touch.checkTouchIdentifier = function(e) {
|
||||
var identifier = Blockly.Touch.getTouchIdentifierFromEvent(e);
|
||||
|
||||
// if (Blockly.touchIdentifier_ )is insufficient because android touch
|
||||
// if (Blockly.touchIdentifier_ )is insufficient because Android touch
|
||||
// identifiers may be zero.
|
||||
if (Blockly.Touch.touchIdentifier_ != undefined &&
|
||||
Blockly.Touch.touchIdentifier_ != null) {
|
||||
|
|
|
@ -269,7 +269,7 @@ Blockly.utils.getScale_REGEXP_ = /scale\(\s*([-+\d.e]+)\s*\)/;
|
|||
* @private
|
||||
*/
|
||||
Blockly.utils.getRelativeXY.XY_3D_REGEX_ =
|
||||
/transform:\s*translate3d\(\s*([-+\d.e]+)px([ ,]\s*([-+\d.e]+)\s*)px([ ,]\s*([-+\d.e]+)\s*)px\)?/;
|
||||
/transform:\s*translate3d\(\s*([-+\d.e]+)px([ ,]\s*([-+\d.e]+)\s*)px([ ,]\s*([-+\d.e]+)\s*)px\)?/;
|
||||
|
||||
/**
|
||||
* Static regex to pull the x,y,z values out of a translate3d() style property.
|
||||
|
@ -278,7 +278,7 @@ Blockly.utils.getRelativeXY.XY_3D_REGEX_ =
|
|||
* @private
|
||||
*/
|
||||
Blockly.utils.getRelativeXY.XY_2D_REGEX_ =
|
||||
/transform:\s*translate\(\s*([-+\d.e]+)px([ ,]\s*([-+\d.e]+)\s*)px\)?/;
|
||||
/transform:\s*translate\(\s*([-+\d.e]+)px([ ,]\s*([-+\d.e]+)\s*)px\)?/;
|
||||
|
||||
/**
|
||||
* Helper method for creating SVG elements.
|
||||
|
@ -491,7 +491,8 @@ Blockly.utils.checkMessageReferences = function(message) {
|
|||
* @return {!Array.<string|number>} Array of strings and numbers.
|
||||
* @private
|
||||
*/
|
||||
Blockly.utils.tokenizeInterpolation_ = function(message, parseInterpolationTokens) {
|
||||
Blockly.utils.tokenizeInterpolation_ = function(message,
|
||||
parseInterpolationTokens) {
|
||||
var tokens = [];
|
||||
var chars = message.split('');
|
||||
chars.push(''); // End marker.
|
||||
|
@ -499,7 +500,7 @@ Blockly.utils.tokenizeInterpolation_ = function(message, parseInterpolationToken
|
|||
// 0 - Base case.
|
||||
// 1 - % found.
|
||||
// 2 - Digit found.
|
||||
// 3 - Message ref found
|
||||
// 3 - Message ref found.
|
||||
var state = 0;
|
||||
var buffer = [];
|
||||
var number = null;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue