From d4c3835a5eb92c8a0e4005a07d0207e8f2829803 Mon Sep 17 00:00:00 2001 From: Rachel Fenichel Date: Wed, 14 Mar 2018 17:37:32 -0700 Subject: [PATCH] Fix more compiler warnings --- core/block_dragger.js | 12 +++++++----- core/icon.js | 6 +++--- core/workspace_svg.js | 13 +++++++++++-- 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/core/block_dragger.js b/core/block_dragger.js index d8238cb0a..051b2a6d8 100644 --- a/core/block_dragger.js +++ b/core/block_dragger.js @@ -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 */ @@ -168,10 +168,11 @@ Blockly.BlockDragger.prototype.startBlockDrag = function(currentDragDeltaXY) { // surface. this.draggingBlock_.moveToDragSurface_(); - if (this.workspace_.toolbox_) { + var toolbox = this.workspace_.getToolbox(); + if (toolbox) { var style = this.draggingBlock_.isDeletable() ? 'blocklyToolboxDelete' : 'blocklyToolboxGrab'; - this.workspace_.toolbox_.addStyle(style); + toolbox.addStyle(style); } }; @@ -226,10 +227,11 @@ Blockly.BlockDragger.prototype.endBlockDrag = function(e, currentDragDeltaXY) { } this.workspace_.setResizesEnabled(true); - if (this.workspace_.toolbox_) { + var toolbox = this.workspace_.getToolbox(); + if (toolbox) { var style = this.draggingBlock_.isDeletable() ? 'blocklyToolboxDelete' : 'blocklyToolboxGrab'; - this.workspace_.toolbox_.removeStyle(style); + toolbox.removeStyle(style); } Blockly.Events.setGroup(false); }; diff --git a/core/icon.js b/core/icon.js index 88b7fb689..b51d90efd 100644 --- a/core/icon.js +++ b/core/icon.js @@ -52,14 +52,14 @@ Blockly.Icon.prototype.SIZE = 17; /** * Bubble UI (if visible). * @type {Blockly.Bubble} - * @private + * @protected */ Blockly.Icon.prototype.bubble_ = null; /** * Absolute coordinate of icon's center. * @type {goog.math.Coordinate} - * @private + * @protected */ Blockly.Icon.prototype.iconXY_ = null; @@ -119,7 +119,7 @@ Blockly.Icon.prototype.isVisible = function() { /** * Clicking on the icon toggles if the bubble is visible. * @param {!Event} e Mouse click event. - * @private + * @protected */ Blockly.Icon.prototype.iconClick_ = function(e) { if (this.block_.workspace.isDragging()) { diff --git a/core/workspace_svg.js b/core/workspace_svg.js index 901ed4ca2..4a3adb510 100644 --- a/core/workspace_svg.js +++ b/core/workspace_svg.js @@ -581,6 +581,15 @@ Blockly.WorkspaceSvg.prototype.getFlyout_ = function() { return null; }; +/** + * Getter for the toolbox associated with this workspace, if one exists. + * @return {Blockly.Toolbox} The toolbox on this workspace. + * @package + */ +Blockly.WorkspaceSvg.prototype.getToolbox = function() { + return this.toolbox_; +}; + /** * Update items that use screen coordinate calculations * because something has changed (e.g. scroll position, window size). @@ -755,8 +764,8 @@ Blockly.WorkspaceSvg.prototype.setupDragSurface = function() { // Figure out where we want to put the canvas back. The order // in the is important because things are layered. var previousElement = this.svgBlockCanvas_.previousSibling; - var width = this.getParentSvg().getAttribute('width'); - var height = this.getParentSvg().getAttribute('height'); + var width = parseInt(this.getParentSvg().getAttribute('width'), 10); + var height = parseInt(this.getParentSvg().getAttribute('height'), 10); var coord = Blockly.utils.getRelativeXY(this.svgBlockCanvas_); this.workspaceDragSurface_.setContentsAndShow(this.svgBlockCanvas_, this.svgBubbleCanvas_, previousElement, width, height, this.scale);