diff --git a/core/delete_area.js b/core/delete_area.js index 384136a05..55eb61a34 100644 --- a/core/delete_area.js +++ b/core/delete_area.js @@ -12,23 +12,26 @@ 'use strict'; -goog.provide('Blockly.DeleteArea'); +goog.module('Blockly.DeleteArea'); +goog.module.declareLegacyNamespace(); -goog.require('Blockly.BlockSvg'); -goog.require('Blockly.DragTarget'); -goog.require('Blockly.IDeleteArea'); - -goog.requireType('Blockly.IDraggable'); +const BlockSvg = goog.require('Blockly.BlockSvg'); +const DragTarget = goog.require('Blockly.DragTarget'); +/* eslint-disable-next-line no-unused-vars */ +const IDeleteArea = goog.require('Blockly.IDeleteArea'); +/* eslint-disable-next-line no-unused-vars */ +const IDraggable = goog.requireType('Blockly.IDraggable'); +const {inherits} = goog.require('Blockly.utils.object'); /** * Abstract class for a component that can delete a block or bubble that is * dropped on top of it. - * @extends {Blockly.DragTarget} - * @implements {Blockly.IDeleteArea} + * @extends {DragTarget} + * @implements {IDeleteArea} * @constructor */ -Blockly.DeleteArea = function() { - Blockly.DeleteArea.superClass_.constructor.call(this); +const DeleteArea = function() { + DeleteArea.superClass_.constructor.call(this); /** * Whether the last block or bubble dragged over this delete area would be @@ -39,24 +42,24 @@ Blockly.DeleteArea = function() { */ this.wouldDelete_ = false; }; -Blockly.utils.object.inherits(Blockly.DeleteArea, Blockly.DragTarget); +inherits(DeleteArea, DragTarget); /** * Returns whether the provided block or bubble would be deleted if dropped on * this area. * This method should check if the element is deletable and is always called * before onDragEnter/onDragOver/onDragExit. - * @param {!Blockly.IDraggable} element The block or bubble currently being + * @param {!IDraggable} element The block or bubble currently being * dragged. * @param {boolean} couldConnect Whether the element could could connect to * another. * @return {boolean} Whether the element provided would be deleted if dropped on * this area. */ -Blockly.DeleteArea.prototype.wouldDelete = function(element, couldConnect) { - if (element instanceof Blockly.BlockSvg) { - var block = /** @type {Blockly.BlockSvg} */ (element); - var couldDeleteBlock = !block.getParent() && block.isDeletable(); +DeleteArea.prototype.wouldDelete = function(element, couldConnect) { + if (element instanceof BlockSvg) { + const block = /** @type {BlockSvg} */ (element); + const couldDeleteBlock = !block.getParent() && block.isDeletable(); this.updateWouldDelete_(couldDeleteBlock && !couldConnect); } else { this.updateWouldDelete_(element.isDeletable()); @@ -69,6 +72,8 @@ Blockly.DeleteArea.prototype.wouldDelete = function(element, couldConnect) { * @param {boolean} wouldDelete The new value for the wouldDelete state. * @protected */ -Blockly.DeleteArea.prototype.updateWouldDelete_ = function(wouldDelete) { +DeleteArea.prototype.updateWouldDelete_ = function(wouldDelete) { this.wouldDelete_ = wouldDelete; }; + +exports = DeleteArea; diff --git a/tests/deps.js b/tests/deps.js index da56c39f2..234771c13 100644 --- a/tests/deps.js +++ b/tests/deps.js @@ -28,7 +28,7 @@ goog.addDependency('../../core/contextmenu.js', ['Blockly.ContextMenu'], ['Block goog.addDependency('../../core/contextmenu_items.js', ['Blockly.ContextMenuItems'], ['Blockly.ContextMenuRegistry', 'Blockly.Events', 'Blockly.constants', 'Blockly.inputTypes'], {'lang': 'es5'}); goog.addDependency('../../core/contextmenu_registry.js', ['Blockly.ContextMenuRegistry'], [], {'lang': 'es5'}); goog.addDependency('../../core/css.js', ['Blockly.Css'], [], {'lang': 'es6', 'module': 'goog'}); -goog.addDependency('../../core/delete_area.js', ['Blockly.DeleteArea'], ['Blockly.BlockSvg', 'Blockly.DragTarget', 'Blockly.IDeleteArea']); +goog.addDependency('../../core/delete_area.js', ['Blockly.DeleteArea'], ['Blockly.BlockSvg', 'Blockly.DragTarget', 'Blockly.IDeleteArea', 'Blockly.utils.object'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../core/drag_target.js', ['Blockly.DragTarget'], ['Blockly.IDragTarget'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../core/dropdowndiv.js', ['Blockly.DropDownDiv'], ['Blockly.utils.Rect', 'Blockly.utils.dom', 'Blockly.utils.math', 'Blockly.utils.style']); goog.addDependency('../../core/events/block_events.js', ['Blockly.Events.BlockBase', 'Blockly.Events.BlockChange', 'Blockly.Events.BlockCreate', 'Blockly.Events.BlockDelete', 'Blockly.Events.BlockMove', 'Blockly.Events.Change', 'Blockly.Events.Create', 'Blockly.Events.Delete', 'Blockly.Events.Move'], ['Blockly.Events', 'Blockly.Events.Abstract', 'Blockly.Xml', 'Blockly.connectionTypes', 'Blockly.registry', 'Blockly.utils.Coordinate', 'Blockly.utils.object', 'Blockly.utils.xml']);