Lint issues found while debugging.

This commit is contained in:
Neil Fraser
2019-03-27 15:25:15 -07:00
committed by Neil Fraser
parent dbafdcf1ff
commit 405b1e4e78
19 changed files with 97 additions and 113 deletions

View File

@@ -494,8 +494,8 @@ Blockly.Block.prototype.lastConnectionInStack = function() {
* @protected
*/
Blockly.Block.prototype.bumpNeighbours_ = function() {
console.warn('Not expected to reach this bumpNeighbours_ function. The ' +
'BlockSvg function for bumpNeighbours_ was expected to be called instead.');
console.warn('Not expected to reach Block.bumpNeighbours_ function. ' +
'BlockSvg.bumpNeighbours_ was expected to be called instead.');
};
/**
@@ -912,7 +912,7 @@ Blockly.Block.prototype.setColour = function(colour) {
if (colour != dereferenced) {
errorMsg += ' (from "' + colour + '")';
}
throw errorMsg;
throw Error(errorMsg);
}
};
@@ -925,7 +925,7 @@ Blockly.Block.prototype.setStyle = function(blockStyleName) {
var theme = Blockly.getTheme();
if (!theme) {
throw Error('Trying to set block style to ' + blockStyleName +
' before theme was defined via Blockly.setTheme().');
' before theme was defined via Blockly.setTheme().');
}
var blockStyle = theme.getBlockStyle(blockStyleName);
this.styleName_ = blockStyleName;
@@ -936,8 +936,7 @@ Blockly.Block.prototype.setStyle = function(blockStyleName) {
this.hat = blockStyle.hat;
// Set colour will trigger an updateColour() on a block_svg
this.setColour(blockStyle['colourPrimary']);
}
else {
} else {
throw Error('Invalid style name: ' + blockStyleName);
}
};
@@ -1428,13 +1427,13 @@ Blockly.Block.prototype.jsonInit = function(json) {
Blockly.Block.prototype.jsonInitColour_ = function(json, warningPrefix) {
if ('colour' in json) {
if (json['colour'] === undefined) {
console.warn(warningPrefix + 'Undefined color value.');
console.warn(warningPrefix + 'Undefined colour value.');
} else {
var rawValue = json['colour'];
try {
this.setColour(rawValue);
} catch (colorError) {
console.warn(warningPrefix + 'Illegal color value: ', rawValue);
} catch (e) {
console.warn(warningPrefix + 'Illegal colour value: ', rawValue);
}
}
}
@@ -1477,7 +1476,7 @@ Blockly.Block.prototype.mixin = function(mixinObj, opt_disableCheck) {
}
if (overwrites.length) {
throw Error('Mixin will overwrite block members: ' +
JSON.stringify(overwrites));
JSON.stringify(overwrites));
}
}
goog.mixin(this, mixinObj);
@@ -1488,8 +1487,8 @@ Blockly.Block.prototype.mixin = function(mixinObj, opt_disableCheck) {
* @param {string} message Text contains interpolation tokens (%1, %2, ...)
* that match with fields or inputs defined in the args array.
* @param {!Array} args Array of arguments to be interpolated.
* @param {string=} lastDummyAlign If a dummy input is added at the end,
* how should it be aligned?
* @param {string|undefined} lastDummyAlign If a dummy input is added at the
* end, how should it be aligned?
* @private
*/
Blockly.Block.prototype.interpolate_ = function(message, args, lastDummyAlign) {

View File

@@ -192,8 +192,8 @@ Blockly.svgResize = function(workspace) {
// are multiple workspaces and non-main workspaces are able to accept input.
Blockly.onKeyDown_ = function(e) {
var workspace = Blockly.mainWorkspace;
if (workspace.options.readOnly || Blockly.utils.isTargetInput(e)
|| (workspace.rendered && !workspace.isVisible())) {
if (workspace.options.readOnly || Blockly.utils.isTargetInput(e) ||
(workspace.rendered && !workspace.isVisible())) {
// No key actions on readonly workspaces.
// When focused on an HTML text input widget, don't trap any keys.
// Ignore keypresses on rendered workspaces that have been explicitly
@@ -467,7 +467,7 @@ Blockly.defineBlocksWithJsonArray = function(jsonArray) {
* @param {!Function} func Function to call when event is triggered.
* @param {boolean=} opt_noCaptureIdentifier True if triggering on this event
* should not block execution of other event handlers on this touch or
* other simultaneous touches.
* other simultaneous touches. False by default.
* @param {boolean=} opt_noPreventDefault True if triggering on this event
* should prevent the default handler. False by default. If
* opt_noPreventDefault is provided, opt_noCaptureIdentifier must also be
@@ -683,8 +683,9 @@ Blockly.checkBlockColourConstant_ = function(
/**
* Sets the theme for blockly and refreshes all blocks in the toolbox and workspace.
* @param {Blockly.Theme} theme Theme for blockly.
* Sets the theme for Blockly and refreshes all blocks in the toolbox and
* workspace.
* @param {!Blockly.Theme} theme Theme for Blockly.
*/
Blockly.setTheme = function(theme) {
this.theme_ = theme;
@@ -697,25 +698,25 @@ Blockly.setTheme = function(theme) {
/**
* Refresh the theme for all items on the workspace.
* @param {Blockly.Workspace} ws Blockly workspace to refresh theme on.
* @param {!Blockly.Workspace} ws Blockly workspace to refresh theme on.
* @private
*/
Blockly.refreshTheme_ = function(ws) {
//update all blocks in workspace that have a style name
// Update all blocks in workspace that have a style name.
this.updateBlockStyles_(ws.getAllBlocks().filter(
function(block){
return block.getStyleName() !== undefined;
}
));
//update blocks in the flyout
// Update blocks in the flyout.
if (!ws.toolbox_ && ws.flyout_ && ws.flyout_.workspace_) {
this.updateBlockStyles_(ws.flyout_.workspace_.getAllBlocks());
} else {
ws.refreshToolboxSelection();
}
//update colours on the categories
// Update colours on the categories.
if (ws.toolbox_) {
ws.toolbox_.updateColourFromTheme();
}
@@ -727,12 +728,12 @@ Blockly.refreshTheme_ = function(ws) {
/**
* Updates all the blocks with new style.
* @param {!Array.<Blockly.Block>} blocks List of blocks to update the style on.
* @param {!Array.<!Blockly.Block>} blocks List of blocks to update the style
* on.
* @private
*/
Blockly.updateBlockStyles_ = function(blocks) {
for (var i = 0; i < blocks.length; i++) {
var block = blocks[i];
for (var i = 0, block; block = blocks[i]; i++) {
var blockStyleName = block.getStyleName();
block.setStyle(blockStyleName);
@@ -744,20 +745,12 @@ Blockly.updateBlockStyles_ = function(blocks) {
/**
* Gets the theme.
* @return {?Blockly.Theme} theme Theme for blockly.
* @return {?Blockly.Theme} theme Theme for Blockly.
*/
Blockly.getTheme = function() {
return this.theme_;
};
// IE9 does not have a console. Create a stub to stop errors.
if (!goog.global['console']) {
goog.global['console'] = {
'log': function() {},
'warn': function() {}
};
}
// Export symbols that would otherwise be renamed by Closure compiler.
if (!goog.global['Blockly']) {
goog.global['Blockly'] = {};

View File

@@ -542,7 +542,7 @@ Blockly.Bubble.prototype.getOptimalRelativeLeft_ = function(metrics) {
if (this.workspace_.RTL) {
if (bubbleLeft < workspaceLeft) {
// Slide the bubble right until it is onscreen.
relativeLeft = -(workspaceLeft - this.anchorXY_.x + this.width_);
relativeLeft = -(workspaceLeft - this.anchorXY_.x + this.width_);
} else if (bubbleRight > workspaceRight) {
// Slide the bubble left until it is onscreen.
relativeLeft = -(workspaceRight - this.anchorXY_.x);

View File

@@ -187,7 +187,7 @@ Blockly.Comment.prototype.setVisible = function(visible) {
if ((!this.block_.isEditable() && !this.textarea_) || goog.userAgent.IE) {
// Steal the code from warnings to make an uneditable text bubble.
// MSIE does not support foreignobject; textareas are impossible.
// http://msdn.microsoft.com/en-us/library/hh834675%28v=vs.85%29.aspx
// https://docs.microsoft.com/en-us/openspecs/ie_standards/ms-svg/56e6e04c-7c8c-44dd-8100-bd745ee42034
// Always treat comments in IE as uneditable.
Blockly.Warning.prototype.setVisible.call(this, visible);
return;

View File

@@ -325,7 +325,7 @@ Blockly.Connection.prototype.checkConnection_ = function(target) {
throw Error('Target connection is null.');
case Blockly.Connection.REASON_CHECKS_FAILED:
var msg = 'Connection checks failed. ';
msg += this + ' expected ' + this.check_ + ', found ' + target.check_;
msg += this + ' expected ' + this.check_ + ', found ' + target.check_;
throw Error(msg);
case Blockly.Connection.REASON_SHADOW_PARENT:
throw Error('Connecting non-shadow to shadow block.');

View File

@@ -153,7 +153,7 @@ Blockly.ConnectionDB.prototype.removeConnection_ = function(connection) {
* @param {!Blockly.Connection} connection The connection whose neighbours
* should be returned.
* @param {number} maxRadius The maximum radius to another connection.
* @return {!Array.<Blockly.Connection>} List of connections.
* @return {!Array.<!Blockly.Connection>} List of connections.
*/
Blockly.ConnectionDB.prototype.getNeighbours = function(connection, maxRadius) {
var db = this.connections_;

View File

@@ -270,14 +270,14 @@ Blockly.DELETE_AREA_TRASH = 1;
Blockly.DELETE_AREA_TOOLBOX = 2;
/**
* String for use in the "custom" attribute of a category in toolbox xml.
* String for use in the "custom" attribute of a category in toolbox XML.
* This string indicates that the category should be dynamically populated with
* variable blocks.
* @const {string}
*/
Blockly.VARIABLE_CATEGORY_NAME = 'VARIABLE';
/**
* String for use in the "custom" attribute of a category in toolbox xml.
* String for use in the "custom" attribute of a category in toolbox XML.
* This string indicates that the category should be dynamically populated with
* variable blocks.
* @const {string}
@@ -285,7 +285,7 @@ Blockly.VARIABLE_CATEGORY_NAME = 'VARIABLE';
Blockly.VARIABLE_DYNAMIC_CATEGORY_NAME = 'VARIABLE_DYNAMIC';
/**
* String for use in the "custom" attribute of a category in toolbox xml.
* String for use in the "custom" attribute of a category in toolbox XML.
* This string indicates that the category should be dynamically populated with
* procedure blocks.
* @const {string}

View File

@@ -104,8 +104,8 @@ Blockly.Css.inject = function(hasCss, pathToMedia) {
* @deprecated April 2017.
*/
Blockly.Css.setCursor = function(cursor) {
console.warn('Deprecated call to Blockly.Css.setCursor.' +
'See https://github.com/google/blockly/issues/981 for context');
console.warn('Deprecated call to Blockly.Css.setCursor. ' +
'See https://github.com/google/blockly/issues/981 for context');
};
/**

View File

@@ -252,7 +252,7 @@ Blockly.Extensions.checkBlockHasMutatorProperties_ = function(errorPrefix,
/**
* Get a list of values of mutator properties on the given block.
* @param {!Blockly.Block} block The block to inspect.
* @return {!Array.<Object>} a list with all of the defined properties, which
* @return {!Array.<Object>} A list with all of the defined properties, which
* should be functions, but may be anything other than undefined.
* @private
*/
@@ -385,7 +385,7 @@ Blockly.Extensions.checkDropdownOptionsInTable_ = function(block, dropdownName,
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);
' of field ' + dropdownName + ' of block type ' + block.type);
}
}
}

View File

@@ -398,7 +398,7 @@ Blockly.init_ = function(mainWorkspace) {
mainWorkspace.scrollbar = new Blockly.ScrollbarPair(mainWorkspace);
mainWorkspace.scrollbar.resize();
} else {
mainWorkspace.setMetrics({x: .5, y: .5});
mainWorkspace.setMetrics({x: 0.5, y: 0.5});
}
// Load the sounds.

View File

@@ -116,10 +116,7 @@ Blockly.Options = function(options) {
} else {
var oneBasedIndex = !!options['oneBasedIndex'];
}
var theme = options['theme'];
if (theme === undefined) {
theme = Blockly.Themes.Classic;
}
var theme = options['theme'] || Blockly.Themes.Classic;
this.RTL = rtl;
this.oneBasedIndex = oneBasedIndex;
@@ -165,7 +162,7 @@ Blockly.Options.prototype.getMetrics = null;
/**
* Parse the user-specified move options, using reasonable defaults where
* behavior is unspecified.
* behaviour is unspecified.
* @param {!Object} options Dictionary of options.
* @param {!boolean} hasCategories Whether the workspace has categories or not.
* @return {!Object} A dictionary of normalized options.
@@ -174,8 +171,7 @@ Blockly.Options.prototype.getMetrics = null;
Blockly.Options.parseMoveOptions = function(options, hasCategories) {
var move = options['move'] || {};
var moveOptions = {};
if (move['scrollbars'] === undefined
&& options['scrollbars'] === undefined) {
if (move['scrollbars'] === undefined && options['scrollbars'] === undefined) {
moveOptions.scrollbars = hasCategories;
} else {
moveOptions.scrollbars = !!move['scrollbars'] || !!options['scrollbars'];

View File

@@ -339,12 +339,10 @@ Blockly.Toolbox.prototype.syncTrees_ = function(treeIn, treeOut, pathToMedia) {
if (colour && styleName) {
childOut.hexColour = '';
console.warn('Toolbox category "' + categoryName +
'" can not have both a style and a colour');
}
else if (styleName) {
'" can not have both a style and a colour');
} else if (styleName) {
this.setColourFromStyle_(styleName, childOut, categoryName);
}
else {
} else {
this.setColour_(colour, childOut, categoryName);
}
@@ -435,8 +433,7 @@ Blockly.Toolbox.prototype.setColourFromStyle_ = function(
var style = Blockly.getTheme().getCategoryStyle(styleName);
if (style && style.colour) {
this.setColour_(style.colour, childOut, categoryName);
}
else {
} else {
console.warn('Style "' + styleName + '" must exist and contain a colour value');
}
}
@@ -644,8 +641,7 @@ Blockly.Toolbox.TreeControl.prototype.handleTouchEvent_ = function(e) {
Blockly.Toolbox.TreeControl.prototype.createNode = function(opt_html) {
var html = opt_html ?
goog.html.SafeHtml.htmlEscape(opt_html) : goog.html.SafeHtml.EMPTY;
return new Blockly.Toolbox.TreeNode(this.toolbox_, html,
this.getConfig(), this.getDomHelper());
return new Blockly.Toolbox.TreeNode(this.toolbox_, html, this.getConfig());
};
/**
@@ -695,15 +691,14 @@ Blockly.Toolbox.TreeControl.prototype.setSelectedItem = function(node) {
* A single node in the tree, customized for Blockly's UI.
* @param {Blockly.Toolbox} toolbox The parent toolbox for this tree.
* @param {!goog.html.SafeHtml} html The HTML content of the node label.
* @param {Object=} opt_config The configuration for the tree. See
* goog.ui.tree.TreeControl.DefaultConfig. If not specified, a default config
* will be used.
* @param {goog.dom.DomHelper=} opt_domHelper Optional DOM helper.
* @param {Object|undefined} config The configuration for the tree.
* See goog.ui.tree.TreeControl.DefaultConfig.
* If not specified, a default config will be used.
* @constructor
* @extends {goog.ui.tree.TreeNode}
*/
Blockly.Toolbox.TreeNode = function(toolbox, html, opt_config, opt_domHelper) {
goog.ui.tree.TreeNode.call(this, html, opt_config, opt_domHelper);
Blockly.Toolbox.TreeNode = function(toolbox, html, config) {
goog.ui.tree.TreeNode.call(this, html, config);
if (toolbox) {
var resize = function() {
// Even though the div hasn't changed size, the visible workspace
@@ -792,9 +787,9 @@ Blockly.Toolbox.TreeNode.prototype.onKeyDown = function(e) {
/**
* A blank separator node in the tree.
* @param {Object=} config The configuration for the tree. See
* goog.ui.tree.TreeControl.DefaultConfig. If not specified, a default config
* will be used.
* @param {Object|undefined} config The configuration for the tree.
* See goog.ui.tree.TreeControl.DefaultConfig
* If not specified, a default config will be used.
* @constructor
* @extends {Blockly.Toolbox.TreeNode}
*/

View File

@@ -330,11 +330,11 @@ Blockly.Trashcan.prototype.position = function() {
// There are no metrics available (workspace is probably not visible).
return;
}
if (metrics.toolboxPosition == Blockly.TOOLBOX_AT_LEFT
|| (this.workspace_.horizontalLayout && !this.workspace_.RTL)) {
if (metrics.toolboxPosition == Blockly.TOOLBOX_AT_LEFT ||
(this.workspace_.horizontalLayout && !this.workspace_.RTL)) {
// Toolbox starts in the left corner.
this.left_ = metrics.viewWidth + metrics.absoluteLeft -
this.WIDTH_ - this.MARGIN_SIDE_ - Blockly.Scrollbar.scrollbarThickness;
this.WIDTH_ - this.MARGIN_SIDE_ - Blockly.Scrollbar.scrollbarThickness;
} else {
// Toolbox starts in the right corner.
this.left_ = this.MARGIN_SIDE_ + Blockly.Scrollbar.scrollbarThickness;
@@ -406,11 +406,11 @@ Blockly.Trashcan.prototype.animateLid_ = function() {
*/
Blockly.Trashcan.prototype.setLidAngle_ = function(lidAngle) {
var openAtRight = this.workspace_.toolboxPosition == Blockly.TOOLBOX_AT_RIGHT
|| (this.workspace_.horizontalLayout && this.workspace_.RTL);
|| (this.workspace_.horizontalLayout && this.workspace_.RTL);
this.svgLid_.setAttribute('transform', 'rotate(' +
(openAtRight ? -lidAngle : lidAngle) + ',' +
(openAtRight ? 4 : this.WIDTH_ - 4) + ',' +
(this.LID_HEIGHT_ - 2) + ')');
(openAtRight ? -lidAngle : lidAngle) + ',' +
(openAtRight ? 4 : this.WIDTH_ - 4) + ',' +
(this.LID_HEIGHT_ - 2) + ')');
};
/**
@@ -491,7 +491,7 @@ Blockly.Trashcan.prototype.onDelete_ = function() {
};
/**
* Converts xml representing a block into text that can be stored in the
* Converts XML representing a block into text that can be stored in the
* content array.
* @param {!Element} xml An XML tree defining the block and any
* connected child blocks.

View File

@@ -194,9 +194,9 @@ Blockly.utils.getRelativeXY = function(element) {
/**
* Return the coordinates of the top-left corner of this element relative to
* the div blockly was injected into.
* the div Blockly was injected into.
* @param {!Element} element SVG element to find the coordinates of. If this is
* not a child of the div blockly was injected into, the behaviour is
* not a child of the div Blockly was injected into, the behaviour is
* undefined.
* @return {!goog.math.Coordinate} Object with .x and .y properties.
*/
@@ -847,10 +847,10 @@ Blockly.utils.is3dSupported = function() {
el.style[t] = 'translate3d(1px,1px,1px)';
var computedStyle = goog.global.getComputedStyle(el);
if (!computedStyle) {
// getComputedStyle in Firefox returns null when blockly is loaded
// getComputedStyle in Firefox returns null when Blockly is loaded
// inside an iframe with display: none. Returning false and not
// caching is3dSupported means we try again later. This is most likely
// when users are interacting with blocks which should mean blockly is
// when users are interacting with blocks which should mean Blockly is
// visible again.
// See https://bugzilla.mozilla.org/show_bug.cgi?id=548397
document.body.removeChild(el);
@@ -909,7 +909,7 @@ Blockly.utils.runAfterPageLoad = function(fn) {
/**
* Sets the CSS transform property on an element. This function sets the
* non-vendor-prefixed and vendor-prefixed versions for backwards compatibility
* with older browsers. See http://caniuse.com/#feat=transforms2d
* with older browsers. See https://caniuse.com/#feat=transforms2d
* @param {!Element} node The node which the CSS transform should be applied.
* @param {string} transform The value of the CSS `transform` property.
*/

View File

@@ -120,7 +120,7 @@ Blockly.Variables.allDeveloperVariables = function(workspace) {
if (!Blockly.Variables.ALL_DEVELOPER_VARS_WARNINGS_BY_BLOCK_TYPE_[
block.type]) {
console.warn('Function getDeveloperVars() deprecated. Use ' +
'getDeveloperVariables() (block type \'' + block.type + '\')');
'getDeveloperVariables() (block type \'' + block.type + '\')');
Blockly.Variables.ALL_DEVELOPER_VARS_WARNINGS_BY_BLOCK_TYPE_[
block.type] = true;
}

View File

@@ -188,8 +188,7 @@ Blockly.WidgetDiv.positionWithAnchor = function(viewportBBox, anchorBBox,
if (y < 0) {
Blockly.WidgetDiv.positionInternal_(x, 0, widgetSize.height + y);
}
else {
} else {
Blockly.WidgetDiv.positionInternal_(x, y, widgetSize.height);
}
};

View File

@@ -148,7 +148,7 @@ Blockly.Workspace.prototype.dispose = function() {
* Angle away from the horizontal to sweep for blocks. Order of execution is
* generally top to bottom, but a small angle changes the scan to give a bit of
* a left to right bias (reversed in RTL). Units are in degrees.
* See: http://tvtropes.org/pmwiki/pmwiki.php/Main/DiagonalBilling.
* See: https://tvtropes.org/pmwiki/pmwiki.php/Main/DiagonalBilling
*/
Blockly.Workspace.SCAN_ANGLE = 3;
@@ -481,7 +481,7 @@ Blockly.Workspace.prototype.getVariableTypes = function() {
/**
* Return all variables of all types.
* @return {!Array.<Blockly.VariableModel>} List of variable models.
* @return {!Array.<!Blockly.VariableModel>} List of variable models.
*/
Blockly.Workspace.prototype.getAllVariables = function() {
return this.variableMap_.getAllVariables();

View File

@@ -771,7 +771,7 @@ Blockly.WorkspaceSvg.prototype.updateScreenCalculationsIfScrolled =
/* eslint-disable indent */
var currScroll = goog.dom.getDocumentScroll();
if (!goog.math.Coordinate.equals(this.lastRecordedPageScroll_,
currScroll)) {
currScroll)) {
this.lastRecordedPageScroll_ = currScroll;
this.updateScreenCalculations_();
}
@@ -815,9 +815,9 @@ Blockly.WorkspaceSvg.prototype.getParentSvg = function() {
/**
* Translate this workspace to new coordinates.
* @param {number} x Horizontal translation, in pixel units relative to the
* top left of the blockly div.
* top left of the Blockly div.
* @param {number} y Vertical translation, in pixel units relative to the
* top left of the blockly div.
* top left of the Blockly div.
*/
Blockly.WorkspaceSvg.prototype.translate = function(x, y) {
if (this.useWorkspaceDragSurface_ && this.isDragSurfaceActive_) {
@@ -1273,11 +1273,11 @@ Blockly.WorkspaceSvg.prototype.isDraggable = function() {
* @package
*/
Blockly.WorkspaceSvg.prototype.isContentBounded = function() {
return (this.options.moveOptions && this.options.moveOptions.scrollbars)
|| (this.options.moveOptions && this.options.moveOptions.wheel)
|| (this.options.moveOptions && this.options.moveOptions.drag)
|| (this.options.zoomOptions && this.options.zoomOptions.controls)
|| (this.options.zoomOptions && this.options.zoomOptions.wheel);
return (this.options.moveOptions && this.options.moveOptions.scrollbars) ||
(this.options.moveOptions && this.options.moveOptions.wheel) ||
(this.options.moveOptions && this.options.moveOptions.drag) ||
(this.options.zoomOptions && this.options.zoomOptions.controls) ||
(this.options.zoomOptions && this.options.zoomOptions.wheel);
};
/**
@@ -1292,10 +1292,10 @@ Blockly.WorkspaceSvg.prototype.isContentBounded = function() {
* @package
*/
Blockly.WorkspaceSvg.prototype.isMovable = function() {
return (this.options.moveOptions && this.options.moveOptions.scrollbars)
|| (this.options.moveOptions && this.options.moveOptions.wheel)
|| (this.options.moveOptions && this.options.moveOptions.drag)
|| (this.options.zoomOptions && this.options.zoomOptions.wheel);
return (this.options.moveOptions && this.options.moveOptions.scrollbars) ||
(this.options.moveOptions && this.options.moveOptions.wheel) ||
(this.options.moveOptions && this.options.moveOptions.drag) ||
(this.options.zoomOptions && this.options.zoomOptions.wheel);
};
/**
@@ -1318,18 +1318,21 @@ Blockly.WorkspaceSvg.prototype.onMouseWheel_ = function(e) {
var scrollDelta = Blockly.utils.getScrollDeltaPixels(e);
if (canWheelZoom && (e.ctrlKey || !canWheelMove)) {
// The vertical scroll distance that corresponds to a click of a zoom button.
// Zoom.
// The vertical scroll distance that corresponds to a click of a zoom
// button.
var PIXELS_PER_ZOOM_STEP = 50;
var delta = -scrollDelta.y / PIXELS_PER_ZOOM_STEP;
var position = Blockly.utils.mouseToSvg(e, this.getParentSvg(),
this.getInverseScreenCTM());
this.zoom(position.x, position.y, delta);
} else {
// Scroll.
var x = this.scrollX - scrollDelta.x;
var y = this.scrollY - scrollDelta.y;
if (e.shiftKey && !scrollDelta.x) {
// Scroll horizontally (based on vertical scroll delta)
// Scroll horizontally (based on vertical scroll delta).
// This is needed as for some browser/system combinations which do not
// set deltaX.
x = this.scrollX - scrollDelta.y;
@@ -1710,7 +1713,7 @@ Blockly.WorkspaceSvg.prototype.zoomCenter = function(type) {
Blockly.WorkspaceSvg.prototype.zoomToFit = function() {
if (!this.isMovable()) {
console.warn('Tried to move a non-movable workspace. This could result' +
' in blocks becoming inaccessible.');
' in blocks becoming inaccessible.');
return;
}
@@ -1779,7 +1782,7 @@ Blockly.WorkspaceSvg.prototype.endCanvasTransition = function() {
Blockly.WorkspaceSvg.prototype.scrollCenter = function() {
if (!this.isMovable()) {
console.warn('Tried to move a non-movable workspace. This could result' +
' in blocks becoming inaccessible.');
' in blocks becoming inaccessible.');
return;
}
@@ -1801,7 +1804,7 @@ Blockly.WorkspaceSvg.prototype.scrollCenter = function() {
Blockly.WorkspaceSvg.prototype.centerOnBlock = function(id) {
if (!this.isMovable()) {
console.warn('Tried to move a non-movable workspace. This could result' +
' in blocks becoming inaccessible.');
' in blocks becoming inaccessible.');
return;
}
@@ -2072,9 +2075,9 @@ Blockly.WorkspaceSvg.getContentDimensionsBounded_ = function(ws, svgSize) {
* .viewWidth: Width of the visible portion of the workspace.
* .contentHeight: Height of the content.
* .contentWidth: Width of the content.
* .svgHeight: Height of the blockly div (the view + the toolbox,
* .svgHeight: Height of the Blockly div (the view + the toolbox,
* simple or otherwise),
* .svgWidth: Width of the blockly div (the view + the toolbox,
* .svgWidth: Width of the Blockly div (the view + the toolbox,
* simple or otherwise),
* .viewTop: Top-edge of the visible portion of the workspace, relative to
* the workspace origin.
@@ -2283,8 +2286,7 @@ Blockly.WorkspaceSvg.prototype.registerToolboxCategoryCallback = function(key,
* is registered.
*/
Blockly.WorkspaceSvg.prototype.getToolboxCategoryCallback = function(key) {
var result = this.toolboxCategoryCallbacks_[key];
return result ? result : null;
return this.toolboxCategoryCallbacks_[key] || null;
};
/**
@@ -2310,7 +2312,7 @@ Blockly.WorkspaceSvg.prototype.getGesture = function(e) {
var gesture = this.currentGesture_;
if (gesture) {
if (isStart && gesture.hasStarted()) {
console.warn('tried to start the same gesture twice');
console.warn('Tried to start the same gesture twice.');
// That's funny. We must have missed a mouse up.
// Cancel it, rather than try to retrieve all of the state we need.
gesture.cancel();

View File

@@ -149,11 +149,11 @@ Blockly.ZoomControls.prototype.position = function() {
// There are no metrics available (workspace is probably not visible).
return;
}
if (metrics.toolboxPosition == Blockly.TOOLBOX_AT_LEFT
|| (this.workspace_.horizontalLayout && !this.workspace_.RTL)) {
if (metrics.toolboxPosition == Blockly.TOOLBOX_AT_LEFT ||
(this.workspace_.horizontalLayout && !this.workspace_.RTL)) {
// Toolbox starts in the left corner.
this.left_ = metrics.viewWidth + metrics.absoluteLeft -
this.WIDTH_ - this.MARGIN_SIDE_ - Blockly.Scrollbar.scrollbarThickness;
this.WIDTH_ - this.MARGIN_SIDE_ - Blockly.Scrollbar.scrollbarThickness;
} else {
// Toolbox starts in the right corner.
this.left_ = this.MARGIN_SIDE_ + Blockly.Scrollbar.scrollbarThickness;