From af3f04b508dc7ad2e0434269312222aa2ea55ab3 Mon Sep 17 00:00:00 2001 From: kozbial Date: Thu, 29 Jul 2021 11:06:55 -0700 Subject: [PATCH] Migrate core/toolbox/toolbox_item.js to goog.module --- core/toolbox/toolbox_item.js | 24 ++++++++++++++---------- tests/deps.js | 2 +- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/core/toolbox/toolbox_item.js b/core/toolbox/toolbox_item.js index febc0a068..e34290eb6 100644 --- a/core/toolbox/toolbox_item.js +++ b/core/toolbox/toolbox_item.js @@ -10,12 +10,14 @@ */ 'use strict'; -goog.provide('Blockly.ToolboxItem'); +goog.module('Blockly.ToolboxItem'); +goog.module.declareLegacyNamespace(); goog.require('Blockly.IToolboxItem'); goog.requireType('Blockly.ICollapsibleToolboxItem'); goog.requireType('Blockly.IToolbox'); +goog.require('Blockly.utils.IdGenerator'); goog.requireType('Blockly.utils.toolbox'); goog.requireType('Blockly.WorkspaceSvg'); @@ -30,7 +32,7 @@ goog.requireType('Blockly.WorkspaceSvg'); * @constructor * @implements {Blockly.IToolboxItem} */ -Blockly.ToolboxItem = function(toolboxItemDef, toolbox, opt_parent) { +const ToolboxItem = function(toolboxItemDef, toolbox, opt_parent) { /** * The id for the category. @@ -81,7 +83,7 @@ Blockly.ToolboxItem = function(toolboxItemDef, toolbox, opt_parent) { * on the info object. * @public */ -Blockly.ToolboxItem.prototype.init = function() { +ToolboxItem.prototype.init = function() { // No-op by default. }; @@ -90,7 +92,7 @@ Blockly.ToolboxItem.prototype.init = function() { * @return {?Element} The div for the toolbox item. * @public */ -Blockly.ToolboxItem.prototype.getDiv = function() { +ToolboxItem.prototype.getDiv = function() { return null; }; @@ -99,7 +101,7 @@ Blockly.ToolboxItem.prototype.getDiv = function() { * @return {string} The ID for the toolbox item. * @public */ -Blockly.ToolboxItem.prototype.getId = function() { +ToolboxItem.prototype.getId = function() { return this.id_; }; @@ -109,7 +111,7 @@ Blockly.ToolboxItem.prototype.getId = function() { * this toolbox item is not nested. * @public */ -Blockly.ToolboxItem.prototype.getParent = function() { +ToolboxItem.prototype.getParent = function() { return null; }; @@ -118,7 +120,7 @@ Blockly.ToolboxItem.prototype.getParent = function() { * @return {number} The nested level of the category. * @package */ -Blockly.ToolboxItem.prototype.getLevel = function() { +ToolboxItem.prototype.getLevel = function() { return this.level_; }; @@ -127,7 +129,7 @@ Blockly.ToolboxItem.prototype.getLevel = function() { * @return {boolean} True if the toolbox item can be selected. * @public */ -Blockly.ToolboxItem.prototype.isSelectable = function() { +ToolboxItem.prototype.isSelectable = function() { return false; }; @@ -136,7 +138,7 @@ Blockly.ToolboxItem.prototype.isSelectable = function() { * @return {boolean} True if the toolbox item is collapsible. * @public */ -Blockly.ToolboxItem.prototype.isCollapsible = function() { +ToolboxItem.prototype.isCollapsible = function() { return false; }; @@ -144,5 +146,7 @@ Blockly.ToolboxItem.prototype.isCollapsible = function() { * Dispose of this toolbox item. No-op by default. * @public */ -Blockly.ToolboxItem.prototype.dispose = function() { +ToolboxItem.prototype.dispose = function() { }; + +exports = ToolboxItem; diff --git a/tests/deps.js b/tests/deps.js index d4eac1200..1e9ef54f4 100644 --- a/tests/deps.js +++ b/tests/deps.js @@ -172,7 +172,7 @@ goog.addDependency('../../core/toolbox/category.js', ['Blockly.ToolboxCategory'] goog.addDependency('../../core/toolbox/collapsible_category.js', ['Blockly.CollapsibleToolboxCategory'], ['Blockly.ICollapsibleToolboxItem', 'Blockly.ToolboxCategory', 'Blockly.ToolboxSeparator', 'Blockly.registry', 'Blockly.utils.aria', 'Blockly.utils.dom', 'Blockly.utils.object', 'Blockly.utils.toolbox'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../core/toolbox/separator.js', ['Blockly.ToolboxSeparator'], ['Blockly.IToolboxItem', 'Blockly.ToolboxItem', 'Blockly.registry', 'Blockly.utils.dom'], {'lang': 'es5'}); goog.addDependency('../../core/toolbox/toolbox.js', ['Blockly.Toolbox'], ['Blockly.BlockSvg', 'Blockly.CollapsibleToolboxCategory', 'Blockly.ComponentManager', 'Blockly.Css', 'Blockly.DeleteArea', 'Blockly.Events', 'Blockly.Events.ToolboxItemSelect', 'Blockly.IAutoHideable', 'Blockly.IKeyboardAccessible', 'Blockly.IStyleable', 'Blockly.IToolbox', 'Blockly.Options', 'Blockly.Touch', 'Blockly.browserEvents', 'Blockly.constants', 'Blockly.registry', 'Blockly.utils', 'Blockly.utils.Rect', 'Blockly.utils.aria', 'Blockly.utils.dom', 'Blockly.utils.toolbox'], {'lang': 'es5'}); -goog.addDependency('../../core/toolbox/toolbox_item.js', ['Blockly.ToolboxItem'], ['Blockly.IToolboxItem']); +goog.addDependency('../../core/toolbox/toolbox_item.js', ['Blockly.ToolboxItem'], ['Blockly.IToolboxItem', 'Blockly.utils.IdGenerator'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../core/tooltip.js', ['Blockly.Tooltip'], ['Blockly.browserEvents', 'Blockly.utils.string']); goog.addDependency('../../core/touch.js', ['Blockly.Touch'], ['Blockly.internalConstants', 'Blockly.utils', 'Blockly.utils.global', 'Blockly.utils.string']); goog.addDependency('../../core/touch_gesture.js', ['Blockly.TouchGesture'], ['Blockly.Gesture', 'Blockly.browserEvents', 'Blockly.utils', 'Blockly.utils.Coordinate', 'Blockly.utils.object']);