All remaining lint in core

This commit is contained in:
Rachel Fenichel 2018-05-02 15:32:28 -07:00
parent 49eca4eee0
commit fc0da3e070
29 changed files with 225 additions and 223 deletions

View file

@ -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();

View file

@ -112,7 +112,8 @@ Blockly.BlockDragSurfaceSvg.prototype.createDom = function() {
if (this.SVG_) {
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:xlink': 'http://www.w3.org/1999/xlink',

View file

@ -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.

View file

@ -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;

View file

@ -383,8 +383,8 @@ 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;

View file

@ -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_,
{
'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_);
'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_);
};
/**

View file

@ -224,16 +224,14 @@ Blockly.FieldAngle.prototype.showEditor_ = function() {
'r': Blockly.FieldAngle.HANDLE_RADIUS,
'class': 'blocklyAngleDragHandle'
}, this.handle_);
this.arrowSvg_ = Blockly.utils.createSvgElement(
'image',
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.handle_);
this.arrowSvg_.setAttributeNS(
'http://www.w3.org/1999/xlink',
'xlink:href',

View file

@ -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();
@ -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');

View file

@ -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;
};

View file

@ -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');

View file

@ -85,7 +85,8 @@ Blockly.FieldLabel.prototype.init = function() {
}
// Build the DOM.
this.textElement_ = Blockly.utils.createSvgElement('text',
{'class': 'blocklyText',
{
'class': 'blocklyText',
'y': Blockly.BlockSvg.FIELD_TOP_PADDING,
'text-anchor': 'middle',
'dominant-baseline': 'middle',

View file

@ -90,7 +90,8 @@ Blockly.FieldTextDropdown.prototype.init = function() {
this.arrowX_ = 0;
/** @type {Number} */
this.arrowY_ = 11;
this.arrow_ = Blockly.utils.createSvgElement('image', {
this.arrow_ = Blockly.utils.createSvgElement('image',
{
'height': this.arrowSize_ + 'px',
'width': this.arrowSize_ + 'px'
});
@ -99,8 +100,7 @@ Blockly.FieldTextDropdown.prototype.init = function() {
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;

View file

@ -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
]);
}
}

View file

@ -77,7 +77,8 @@ Blockly.FieldVerticalSeparator.prototype.init = function() {
this.fieldGroup_.style.display = 'none';
}
/** @type {SVGElement} */
this.lineElement_ = Blockly.utils.createSvgElement('line', {
this.lineElement_ = Blockly.utils.createSvgElement('line',
{
'stroke': this.sourceBlock_.getColourSecondary(),
'stroke-linecap': 'round',
'x1': 0,

View file

@ -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];

View file

@ -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;
};

View file

@ -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.mp3',
pathToMedia + 'click.wav',
pathToMedia + 'click.ogg'], 'click');
pathToMedia + 'click.ogg'
],
'click');
audioMgr.load(
[pathToMedia + 'delete.mp3',
[
pathToMedia + 'delete.mp3',
pathToMedia + 'delete.ogg',
pathToMedia + 'delete.wav'], 'delete');
pathToMedia + 'delete.wav'
],
'delete');
// Bind temporary hooks that preload the sounds.
var soundBinds = [];

View file

@ -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) + ';';
});
};

View file

@ -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) {