Migrate core/events/events_bubble_open.js to goog.module syntax (#5285)

* Migrate core/events/events_bubble_open.js to ES6 const/let

* Migrate core/events/events_bubble_open.js to goog.module

* Migrate core/events/events_bubble_open.js to named requires
This commit is contained in:
Aaron Dodson
2021-08-04 08:25:07 -07:00
committed by GitHub
parent 623e901b1c
commit 18efccc2f6
2 changed files with 25 additions and 22 deletions

View File

@@ -10,30 +10,32 @@
*/
'use strict';
goog.provide('Blockly.Events.BubbleOpen');
goog.module('Blockly.Events.BubbleOpen');
goog.module.declareLegacyNamespace();
goog.require('Blockly.Events');
goog.require('Blockly.Events.UiBase');
goog.require('Blockly.registry');
goog.require('Blockly.utils.object');
goog.requireType('Blockly.BlockSvg');
/* eslint-disable-next-line no-unused-vars */
const BlockSvg = goog.requireType('Blockly.BlockSvg');
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 bubble open event.
* @param {Blockly.BlockSvg} opt_block The associated block. Undefined for a
* @param {BlockSvg} opt_block The associated block. Undefined for a
* blank event.
* @param {boolean=} opt_isOpen Whether the bubble is opening (false if
* closing). Undefined for a blank event.
* @param {string=} opt_bubbleType The type of bubble. One of 'mutator', 'comment'
* @param {string=} opt_bubbleType The type of bubble. One of 'mutator',
* 'comment'
* or 'warning'. Undefined for a blank event.
* @extends {Blockly.Events.UiBase}
* @extends {UiBase}
* @constructor
*/
Blockly.Events.BubbleOpen = function(opt_block, opt_isOpen, opt_bubbleType) {
var workspaceId = opt_block ? opt_block.workspace.id : undefined;
Blockly.Events.BubbleOpen.superClass_.constructor.call(this, workspaceId);
const BubbleOpen = function(opt_block, opt_isOpen, opt_bubbleType) {
const workspaceId = opt_block ? opt_block.workspace.id : undefined;
BubbleOpen.superClass_.constructor.call(this, workspaceId);
this.blockId = opt_block ? opt_block.id : null;
/**
@@ -48,20 +50,20 @@ Blockly.Events.BubbleOpen = function(opt_block, opt_isOpen, opt_bubbleType) {
*/
this.bubbleType = opt_bubbleType;
};
Blockly.utils.object.inherits(Blockly.Events.BubbleOpen, Blockly.Events.UiBase);
object.inherits(BubbleOpen, UiBase);
/**
* Type of this event.
* @type {string}
*/
Blockly.Events.BubbleOpen.prototype.type = Blockly.Events.BUBBLE_OPEN;
BubbleOpen.prototype.type = Events.BUBBLE_OPEN;
/**
* Encode the event as JSON.
* @return {!Object} JSON representation.
*/
Blockly.Events.BubbleOpen.prototype.toJson = function() {
var json = Blockly.Events.BubbleOpen.superClass_.toJson.call(this);
BubbleOpen.prototype.toJson = function() {
const json = BubbleOpen.superClass_.toJson.call(this);
json['isOpen'] = this.isOpen;
json['bubbleType'] = this.bubbleType;
json['blockId'] = this.blockId;
@@ -72,12 +74,13 @@ Blockly.Events.BubbleOpen.prototype.toJson = function() {
* Decode the JSON event.
* @param {!Object} json JSON representation.
*/
Blockly.Events.BubbleOpen.prototype.fromJson = function(json) {
Blockly.Events.BubbleOpen.superClass_.fromJson.call(this, json);
BubbleOpen.prototype.fromJson = function(json) {
BubbleOpen.superClass_.fromJson.call(this, json);
this.isOpen = json['isOpen'];
this.bubbleType = json['bubbleType'];
this.blockId = json['blockId'];
};
Blockly.registry.register(Blockly.registry.Type.EVENT,
Blockly.Events.BUBBLE_OPEN, Blockly.Events.BubbleOpen);
registry.register(registry.Type.EVENT, Events.BUBBLE_OPEN, BubbleOpen);
exports = BubbleOpen;

View File

@@ -37,7 +37,7 @@ goog.addDependency('../../core/events/block_events.js', ['Blockly.Events.BlockBa
goog.addDependency('../../core/events/events.js', ['Blockly.Events'], ['Blockly.registry', 'Blockly.utils']);
goog.addDependency('../../core/events/events_abstract.js', ['Blockly.Events.Abstract'], ['Blockly.Events']);
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_bubble_open.js', ['Blockly.Events.BubbleOpen'], ['Blockly.Events', 'Blockly.Events.UiBase', 'Blockly.registry', 'Blockly.utils.object']);
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'});
goog.addDependency('../../core/events/events_marker_move.js', ['Blockly.Events.MarkerMove'], ['Blockly.ASTNode', 'Blockly.Events', 'Blockly.Events.UiBase', 'Blockly.registry', 'Blockly.utils.object'], {'lang': 'es6', 'module': 'goog'});
goog.addDependency('../../core/events/events_selected.js', ['Blockly.Events.Selected'], ['Blockly.Events', 'Blockly.Events.UiBase', 'Blockly.registry', 'Blockly.utils.object'], {'lang': 'es6', 'module': 'goog'});