diff --git a/core/warning.js b/core/warning.js index e596f0328..c39e7cad9 100644 --- a/core/warning.js +++ b/core/warning.js @@ -10,7 +10,8 @@ */ 'use strict'; -goog.provide('Blockly.Warning'); +goog.module('Blockly.Warning'); +goog.module.declareLegacyNamespace(); goog.require('Blockly.Bubble'); goog.require('Blockly.Events'); @@ -32,25 +33,25 @@ goog.requireType('Blockly.utils.Coordinate'); * @extends {Blockly.Icon} * @constructor */ -Blockly.Warning = function(block) { - Blockly.Warning.superClass_.constructor.call(this, block); +const Warning = function(block) { + Warning.superClass_.constructor.call(this, block); this.createIcon(); // The text_ object can contain multiple warnings. this.text_ = Object.create(null); }; -Blockly.utils.object.inherits(Blockly.Warning, Blockly.Icon); +Blockly.utils.object.inherits(Warning, Blockly.Icon); /** * Does this icon get hidden when the block is collapsed. */ -Blockly.Warning.prototype.collapseHidden = false; +Warning.prototype.collapseHidden = false; /** * Draw the warning icon. * @param {!Element} group The icon group. * @protected */ -Blockly.Warning.prototype.drawIcon_ = function(group) { +Warning.prototype.drawIcon_ = function(group) { // Triangle with rounded corners. Blockly.utils.dom.createSvgElement( Blockly.utils.Svg.PATH, @@ -83,7 +84,7 @@ Blockly.Warning.prototype.drawIcon_ = function(group) { * Show or hide the warning bubble. * @param {boolean} visible True if the bubble should be visible. */ -Blockly.Warning.prototype.setVisible = function(visible) { +Warning.prototype.setVisible = function(visible) { if (visible == this.isVisible()) { return; } @@ -100,7 +101,7 @@ Blockly.Warning.prototype.setVisible = function(visible) { * Show the bubble. * @private */ -Blockly.Warning.prototype.createBubble_ = function() { +Warning.prototype.createBubble_ = function() { this.paragraphElement_ = Blockly.Bubble.textToDom(this.getText()); this.bubble_ = Blockly.Bubble.createNonEditableBubble( this.paragraphElement_, /** @type {!Blockly.BlockSvg} */ (this.block_), @@ -112,7 +113,7 @@ Blockly.Warning.prototype.createBubble_ = function() { * Dispose of the bubble and references to it. * @private */ -Blockly.Warning.prototype.disposeBubble_ = function() { +Warning.prototype.disposeBubble_ = function() { this.bubble_.dispose(); this.bubble_ = null; this.paragraphElement_ = null; @@ -125,7 +126,7 @@ Blockly.Warning.prototype.disposeBubble_ = function() { * @param {string} id An ID for this text entry to be able to maintain * multiple warnings. */ -Blockly.Warning.prototype.setText = function(text, id) { +Warning.prototype.setText = function(text, id) { if (this.text_[id] == text) { return; } @@ -144,7 +145,7 @@ Blockly.Warning.prototype.setText = function(text, id) { * Get this warning's texts. * @return {string} All texts concatenated into one string. */ -Blockly.Warning.prototype.getText = function() { +Warning.prototype.getText = function() { const allWarnings = []; for (let id in this.text_) { allWarnings.push(this.text_[id]); @@ -155,7 +156,9 @@ Blockly.Warning.prototype.getText = function() { /** * Dispose of this warning. */ -Blockly.Warning.prototype.dispose = function() { +Warning.prototype.dispose = function() { this.block_.warning = null; Blockly.Icon.prototype.dispose.call(this); }; + +exports = Warning; diff --git a/tests/deps.js b/tests/deps.js index 84c1c2b48..c6ccc9bb8 100644 --- a/tests/deps.js +++ b/tests/deps.js @@ -199,7 +199,7 @@ goog.addDependency('../../core/variable_map.js', ['Blockly.VariableMap'], ['Bloc goog.addDependency('../../core/variable_model.js', ['Blockly.VariableModel'], ['Blockly.Events', 'Blockly.Events.VarCreate', 'Blockly.utils']); goog.addDependency('../../core/variables.js', ['Blockly.Variables'], ['Blockly.Blocks', 'Blockly.Msg', 'Blockly.VariableModel', 'Blockly.Xml', 'Blockly.internalConstants', 'Blockly.utils', 'Blockly.utils.xml']); goog.addDependency('../../core/variables_dynamic.js', ['Blockly.VariablesDynamic'], ['Blockly.Blocks', 'Blockly.Msg', 'Blockly.VariableModel', 'Blockly.Variables', 'Blockly.utils.xml']); -goog.addDependency('../../core/warning.js', ['Blockly.Warning'], ['Blockly.Bubble', 'Blockly.Events', 'Blockly.Events.BubbleOpen', 'Blockly.Icon', 'Blockly.utils.Svg', 'Blockly.utils.dom', 'Blockly.utils.object']); +goog.addDependency('../../core/warning.js', ['Blockly.Warning'], ['Blockly.Bubble', 'Blockly.Events', 'Blockly.Events.BubbleOpen', 'Blockly.Icon', 'Blockly.utils.Svg', 'Blockly.utils.dom', 'Blockly.utils.object'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../core/widgetdiv.js', ['Blockly.WidgetDiv'], ['Blockly.utils.dom']); goog.addDependency('../../core/workspace.js', ['Blockly.Workspace'], ['Blockly.ConnectionChecker', 'Blockly.Events', 'Blockly.IASTNodeLocation', 'Blockly.Options', 'Blockly.VariableMap', 'Blockly.registry', 'Blockly.utils', 'Blockly.utils.math']); goog.addDependency('../../core/workspace_audio.js', ['Blockly.WorkspaceAudio'], ['Blockly.internalConstants', 'Blockly.utils', 'Blockly.utils.global', 'Blockly.utils.userAgent'], {'lang': 'es5'});