diff --git a/core/grid.js b/core/grid.js index b01d59dbd..48189fe69 100644 --- a/core/grid.js +++ b/core/grid.js @@ -11,7 +11,8 @@ */ 'use strict'; -goog.provide('Blockly.Grid'); +goog.module('Blockly.Grid'); +goog.module.declareLegacyNamespace(); goog.require('Blockly.utils.dom'); goog.require('Blockly.utils.Svg'); @@ -27,7 +28,7 @@ goog.require('Blockly.utils.userAgent'); * https://developers.google.com/blockly/guides/configure/web/grid * @constructor */ -Blockly.Grid = function(pattern, options) { +const Grid = function(pattern, options) { /** * The grid's SVG pattern, created during injection. * @type {!SVGElement} @@ -78,14 +79,14 @@ Blockly.Grid = function(pattern, options) { * @type {number} * @private */ -Blockly.Grid.prototype.scale_ = 1; +Grid.prototype.scale_ = 1; /** * Dispose of this grid and unlink from the DOM. * @package * @suppress {checkTypes} */ -Blockly.Grid.prototype.dispose = function() { +Grid.prototype.dispose = function() { this.gridPattern_ = null; }; @@ -94,7 +95,7 @@ Blockly.Grid.prototype.dispose = function() { * @return {boolean} True if blocks should snap, false otherwise. * @package */ -Blockly.Grid.prototype.shouldSnap = function() { +Grid.prototype.shouldSnap = function() { return this.snapToGrid_; }; @@ -103,7 +104,7 @@ Blockly.Grid.prototype.shouldSnap = function() { * @return {number} The spacing of the grid points. * @package */ -Blockly.Grid.prototype.getSpacing = function() { +Grid.prototype.getSpacing = function() { return this.spacing_; }; @@ -113,7 +114,7 @@ Blockly.Grid.prototype.getSpacing = function() { * @return {string} The pattern ID. * @package */ -Blockly.Grid.prototype.getPatternId = function() { +Grid.prototype.getPatternId = function() { return this.gridPattern_.id; }; @@ -122,7 +123,7 @@ Blockly.Grid.prototype.getPatternId = function() { * @param {number} scale The new workspace scale. * @package */ -Blockly.Grid.prototype.update = function(scale) { +Grid.prototype.update = function(scale) { this.scale_ = scale; // MSIE freaks if it sees a 0x0 pattern, so set empty patterns to 100x100. const safeSpacing = (this.spacing_ * scale) || 100; @@ -153,7 +154,7 @@ Blockly.Grid.prototype.update = function(scale) { * @param {number} y2 The new y end position of the line (in px). * @private */ -Blockly.Grid.prototype.setLineAttributes_ = function(line, width, +Grid.prototype.setLineAttributes_ = function(line, width, x1, x2, y1, y2) { if (line) { line.setAttribute('stroke-width', width); @@ -171,7 +172,7 @@ Blockly.Grid.prototype.setLineAttributes_ = function(line, width, * @param {number} y The new y position of the grid (in px). * @package */ -Blockly.Grid.prototype.moveTo = function(x, y) { +Grid.prototype.moveTo = function(x, y) { this.gridPattern_.setAttribute('x', x); this.gridPattern_.setAttribute('y', y); @@ -190,7 +191,7 @@ Blockly.Grid.prototype.moveTo = function(x, y) { * @return {!SVGElement} The SVG element for the grid pattern. * @package */ -Blockly.Grid.createDom = function(rnd, gridOptions, defs) { +Grid.createDom = function(rnd, gridOptions, defs) { /* @@ -220,3 +221,5 @@ Blockly.Grid.createDom = function(rnd, gridOptions, defs) { } return gridPattern; }; + +exports = Grid; diff --git a/tests/deps.js b/tests/deps.js index 25dd37c2e..f6a0972e2 100644 --- a/tests/deps.js +++ b/tests/deps.js @@ -67,7 +67,7 @@ goog.addDependency('../../core/flyout_horizontal.js', ['Blockly.HorizontalFlyout goog.addDependency('../../core/flyout_vertical.js', ['Blockly.VerticalFlyout'], ['Blockly.Block', 'Blockly.DropDownDiv', 'Blockly.Flyout', 'Blockly.Scrollbar', 'Blockly.WidgetDiv', 'Blockly.constants', 'Blockly.registry', 'Blockly.utils', 'Blockly.utils.Rect', 'Blockly.utils.object', 'Blockly.utils.toolbox']); goog.addDependency('../../core/generator.js', ['Blockly.Generator'], ['Blockly.Block', 'Blockly.internalConstants', 'Blockly.utils.deprecation']); goog.addDependency('../../core/gesture.js', ['Blockly.Gesture'], ['Blockly.BlockDragger', 'Blockly.BubbleDragger', 'Blockly.Events', 'Blockly.Events.Click', 'Blockly.Tooltip', 'Blockly.Touch', 'Blockly.Workspace', 'Blockly.WorkspaceDragger', 'Blockly.blockAnimations', 'Blockly.browserEvents', 'Blockly.internalConstants', 'Blockly.utils', 'Blockly.utils.Coordinate']); -goog.addDependency('../../core/grid.js', ['Blockly.Grid'], ['Blockly.utils.Svg', 'Blockly.utils.dom', 'Blockly.utils.userAgent'], {'lang': 'es6'}); +goog.addDependency('../../core/grid.js', ['Blockly.Grid'], ['Blockly.utils.Svg', 'Blockly.utils.dom', 'Blockly.utils.userAgent'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../core/icon.js', ['Blockly.Icon'], ['Blockly.browserEvents', 'Blockly.utils', 'Blockly.utils.Coordinate', 'Blockly.utils.Size', 'Blockly.utils.Svg', 'Blockly.utils.dom']); goog.addDependency('../../core/inject.js', ['Blockly.inject'], ['Blockly.BlockDragSurfaceSvg', 'Blockly.Css', 'Blockly.DropDownDiv', 'Blockly.Events', 'Blockly.Grid', 'Blockly.Msg', 'Blockly.Options', 'Blockly.ScrollbarPair', 'Blockly.Tooltip', 'Blockly.WidgetDiv', 'Blockly.Workspace', 'Blockly.WorkspaceDragSurfaceSvg', 'Blockly.WorkspaceSvg', 'Blockly.browserEvents', 'Blockly.utils', 'Blockly.utils.Svg', 'Blockly.utils.aria', 'Blockly.utils.dom', 'Blockly.utils.math', 'Blockly.utils.userAgent']); goog.addDependency('../../core/input.js', ['Blockly.Input'], ['Blockly.Connection', 'Blockly.FieldLabel', 'Blockly.fieldRegistry', 'Blockly.inputTypes'], {'lang': 'es5'});