mirror of
https://github.com/google/blockly.git
synced 2026-01-09 10:00:09 +01:00
Migrate core/events/events_block_drag.js to goog.module syntax (#5286)
* Migrate core/events/events_block_drag.js to ES6 const/let * Migrate core/events/events_block_drag.js to goog.module * Migrate core/events/events_block_drag.js to named requires * clang-format core/events/events_block_drag.js
This commit is contained in:
@@ -10,30 +10,31 @@
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
goog.provide('Blockly.Events.BlockDrag');
|
||||
goog.module('Blockly.Events.BlockDrag');
|
||||
goog.module.declareLegacyNamespace();
|
||||
|
||||
goog.require('Blockly.Events');
|
||||
goog.require('Blockly.Events.UiBase');
|
||||
goog.require('Blockly.registry');
|
||||
goog.require('Blockly.utils.object');
|
||||
|
||||
goog.requireType('Blockly.Block');
|
||||
/* eslint-disable-next-line no-unused-vars */
|
||||
const Block = goog.requireType('Blockly.Block');
|
||||
const Events = goog.require('Blockly.Events');
|
||||
const UiBase = goog.require('Blockly.Events.UiBase');
|
||||
const object = goog.require('Blockly.utils.object');
|
||||
const registry = goog.require('Blockly.registry');
|
||||
|
||||
|
||||
/**
|
||||
* Class for a block drag event.
|
||||
* @param {!Blockly.Block=} opt_block The top block in the stack that is being
|
||||
* @param {!Block=} opt_block The top block in the stack that is being
|
||||
* dragged. Undefined for a blank event.
|
||||
* @param {boolean=} opt_isStart Whether this is the start of a block drag.
|
||||
* Undefined for a blank event.
|
||||
* @param {!Array<!Blockly.Block>=} opt_blocks The blocks affected by this
|
||||
* @param {!Array<!Block>=} opt_blocks The blocks affected by this
|
||||
* drag. Undefined for a blank event.
|
||||
* @extends {Blockly.Events.UiBase}
|
||||
* @extends {UiBase}
|
||||
* @constructor
|
||||
*/
|
||||
Blockly.Events.BlockDrag = function(opt_block, opt_isStart, opt_blocks) {
|
||||
var workspaceId = opt_block ? opt_block.workspace.id : undefined;
|
||||
Blockly.Events.BlockDrag.superClass_.constructor.call(this, workspaceId);
|
||||
const BlockDrag = function(opt_block, opt_isStart, opt_blocks) {
|
||||
const workspaceId = opt_block ? opt_block.workspace.id : undefined;
|
||||
BlockDrag.superClass_.constructor.call(this, workspaceId);
|
||||
this.blockId = opt_block ? opt_block.id : null;
|
||||
|
||||
/**
|
||||
@@ -44,24 +45,24 @@ Blockly.Events.BlockDrag = function(opt_block, opt_isStart, opt_blocks) {
|
||||
|
||||
/**
|
||||
* The blocks affected by this drag event.
|
||||
* @type {!Array<!Blockly.Block>|undefined}
|
||||
* @type {!Array<!Block>|undefined}
|
||||
*/
|
||||
this.blocks = opt_blocks;
|
||||
};
|
||||
Blockly.utils.object.inherits(Blockly.Events.BlockDrag, Blockly.Events.UiBase);
|
||||
object.inherits(BlockDrag, UiBase);
|
||||
|
||||
/**
|
||||
* Type of this event.
|
||||
* @type {string}
|
||||
*/
|
||||
Blockly.Events.BlockDrag.prototype.type = Blockly.Events.BLOCK_DRAG;
|
||||
BlockDrag.prototype.type = Events.BLOCK_DRAG;
|
||||
|
||||
/**
|
||||
* Encode the event as JSON.
|
||||
* @return {!Object} JSON representation.
|
||||
*/
|
||||
Blockly.Events.BlockDrag.prototype.toJson = function() {
|
||||
var json = Blockly.Events.BlockDrag.superClass_.toJson.call(this);
|
||||
BlockDrag.prototype.toJson = function() {
|
||||
const json = BlockDrag.superClass_.toJson.call(this);
|
||||
json['isStart'] = this.isStart;
|
||||
json['blockId'] = this.blockId;
|
||||
json['blocks'] = this.blocks;
|
||||
@@ -72,12 +73,13 @@ Blockly.Events.BlockDrag.prototype.toJson = function() {
|
||||
* Decode the JSON event.
|
||||
* @param {!Object} json JSON representation.
|
||||
*/
|
||||
Blockly.Events.BlockDrag.prototype.fromJson = function(json) {
|
||||
Blockly.Events.BlockDrag.superClass_.fromJson.call(this, json);
|
||||
BlockDrag.prototype.fromJson = function(json) {
|
||||
BlockDrag.superClass_.fromJson.call(this, json);
|
||||
this.isStart = json['isStart'];
|
||||
this.blockId = json['blockId'];
|
||||
this.blocks = json['blocks'];
|
||||
};
|
||||
|
||||
Blockly.registry.register(Blockly.registry.Type.EVENT,
|
||||
Blockly.Events.BLOCK_DRAG, Blockly.Events.BlockDrag);
|
||||
registry.register(registry.Type.EVENT, Events.BLOCK_DRAG, BlockDrag);
|
||||
|
||||
exports = BlockDrag;
|
||||
|
||||
@@ -40,7 +40,7 @@ goog.addDependency('../../core/events/events_block_base.js', ['Blockly.Events.Bl
|
||||
goog.addDependency('../../core/events/events_block_change.js', ['Blockly.Events.BlockChange'], ['Blockly.Events', 'Blockly.Xml', 'Blockly.registry', 'Blockly.utils.object'], {'lang': 'es6', 'module': 'goog'});
|
||||
goog.addDependency('../../core/events/events_block_create.js', ['Blockly.Events.BlockCreate'], ['Blockly.Events', 'Blockly.Events.BlockBase', 'Blockly.Xml', 'Blockly.registry', 'Blockly.utils.object', 'Blockly.utils.xml'], {'lang': 'es6', 'module': 'goog'});
|
||||
goog.addDependency('../../core/events/events_block_delete.js', ['Blockly.Events.BlockDelete'], ['Blockly.Events', 'Blockly.Events.BlockBase', 'Blockly.Xml', 'Blockly.registry', 'Blockly.utils.object', 'Blockly.utils.xml'], {'lang': 'es6', 'module': 'goog'});
|
||||
goog.addDependency('../../core/events/events_block_drag.js', ['Blockly.Events.BlockDrag'], ['Blockly.Events', 'Blockly.Events.UiBase', 'Blockly.registry', 'Blockly.utils.object']);
|
||||
goog.addDependency('../../core/events/events_block_drag.js', ['Blockly.Events.BlockDrag'], ['Blockly.Events', 'Blockly.Events.UiBase', 'Blockly.registry', 'Blockly.utils.object'], {'lang': 'es6', 'module': 'goog'});
|
||||
goog.addDependency('../../core/events/events_block_move.js', ['Blockly.Events.BlockMove'], ['Blockly.Events', 'Blockly.Events.BlockBase', 'Blockly.connectionTypes', 'Blockly.registry', 'Blockly.utils.Coordinate', 'Blockly.utils.object'], {'lang': 'es6', 'module': 'goog'});
|
||||
goog.addDependency('../../core/events/events_bubble_open.js', ['Blockly.Events.BubbleOpen'], ['Blockly.Events', 'Blockly.Events.UiBase', 'Blockly.registry', 'Blockly.utils.object'], {'lang': 'es6', 'module': 'goog'});
|
||||
goog.addDependency('../../core/events/events_click.js', ['Blockly.Events.Click'], ['Blockly.Events', 'Blockly.Events.UiBase', 'Blockly.registry', 'Blockly.utils.object'], {'lang': 'es6', 'module': 'goog'});
|
||||
|
||||
Reference in New Issue
Block a user