Migrate core/events/events_ui.js and core/events/events_ui_base.js to goog.module

This commit is contained in:
kozbial
2021-08-03 16:26:34 -07:00
committed by Monica Kozbial
parent aa83199a55
commit e16a0a4bce
3 changed files with 22 additions and 20 deletions

View File

@@ -11,7 +11,8 @@
*/
'use strict';
goog.provide('Blockly.Events.Ui');
goog.module('Blockly.Events.Ui');
goog.module.declareLegacyNamespace();
goog.require('Blockly.Events');
goog.require('Blockly.Events.UiBase');
@@ -33,30 +34,30 @@ goog.requireType('Blockly.Block');
* @deprecated December 2020. Instead use a more specific UI event.
* @constructor
*/
Blockly.Events.Ui = function(opt_block, opt_element, opt_oldValue,
const Ui = function(opt_block, opt_element, opt_oldValue,
opt_newValue) {
const workspaceId = opt_block ? opt_block.workspace.id : undefined;
Blockly.Events.Ui.superClass_.constructor.call(this, workspaceId);
Ui.superClass_.constructor.call(this, workspaceId);
this.blockId = opt_block ? opt_block.id : null;
this.element = typeof opt_element == 'undefined' ? '' : opt_element;
this.oldValue = typeof opt_oldValue == 'undefined' ? '' : opt_oldValue;
this.newValue = typeof opt_newValue == 'undefined' ? '' : opt_newValue;
};
Blockly.utils.object.inherits(Blockly.Events.Ui, Blockly.Events.UiBase);
Blockly.utils.object.inherits(Ui, Blockly.Events.UiBase);
/**
* Type of this event.
* @type {string}
*/
Blockly.Events.Ui.prototype.type = Blockly.Events.UI;
Ui.prototype.type = Blockly.Events.UI;
/**
* Encode the event as JSON.
* @return {!Object} JSON representation.
*/
Blockly.Events.Ui.prototype.toJson = function() {
const json = Blockly.Events.Ui.superClass_.toJson.call(this);
Ui.prototype.toJson = function() {
const json = Ui.superClass_.toJson.call(this);
json['element'] = this.element;
if (this.newValue !== undefined) {
json['newValue'] = this.newValue;
@@ -71,12 +72,13 @@ Blockly.Events.Ui.prototype.toJson = function() {
* Decode the JSON event.
* @param {!Object} json JSON representation.
*/
Blockly.Events.Ui.prototype.fromJson = function(json) {
Blockly.Events.Ui.superClass_.fromJson.call(this, json);
Ui.prototype.fromJson = function(json) {
Ui.superClass_.fromJson.call(this, json);
this.element = json['element'];
this.newValue = json['newValue'];
this.blockId = json['blockId'];
};
Blockly.registry.register(Blockly.registry.Type.EVENT, Blockly.Events.UI,
Blockly.Events.Ui);
Ui);
exports = Ui;

View File

@@ -11,14 +11,12 @@
*/
'use strict';
goog.provide('Blockly.Events.UiBase');
goog.module('Blockly.Events.UiBase');
goog.module.declareLegacyNamespace();
goog.require('Blockly.Events');
goog.require('Blockly.Events.Abstract');
goog.require('Blockly.utils.object');
goog.requireType('Blockly.Block');
/**
* Base class for a UI event.
@@ -31,8 +29,8 @@ goog.requireType('Blockly.Block');
* @extends {Blockly.Events.Abstract}
* @constructor
*/
Blockly.Events.UiBase = function(opt_workspaceId) {
Blockly.Events.UiBase.superClass_.constructor.call(this);
const UiBase = function(opt_workspaceId) {
UiBase.superClass_.constructor.call(this);
/**
* Whether or not the event is blank (to be populated by fromJson).
@@ -49,10 +47,12 @@ Blockly.Events.UiBase = function(opt_workspaceId) {
// UI events do not undo or redo.
this.recordUndo = false;
};
Blockly.utils.object.inherits(Blockly.Events.UiBase, Blockly.Events.Abstract);
Blockly.utils.object.inherits(UiBase, Blockly.Events.Abstract);
/**
* Whether or not the event is a UI event.
* @type {boolean}
*/
Blockly.Events.UiBase.prototype.isUiEvent = true;
UiBase.prototype.isUiEvent = true;
exports = UiBase;

View File

@@ -49,8 +49,8 @@ goog.addDependency('../../core/events/events_selected.js', ['Blockly.Events.Sele
goog.addDependency('../../core/events/events_theme_change.js', ['Blockly.Events.ThemeChange'], ['Blockly.Events', 'Blockly.Events.UiBase', 'Blockly.registry', 'Blockly.utils.object'], {'lang': 'es6', 'module': 'goog'});
goog.addDependency('../../core/events/events_toolbox_item_select.js', ['Blockly.Events.ToolboxItemSelect'], ['Blockly.Events', 'Blockly.Events.UiBase', 'Blockly.registry', 'Blockly.utils.object'], {'lang': 'es6', 'module': 'goog'});
goog.addDependency('../../core/events/events_trashcan_open.js', ['Blockly.Events.TrashcanOpen'], ['Blockly.Events', 'Blockly.Events.UiBase', 'Blockly.registry', 'Blockly.utils.object'], {'lang': 'es6', 'module': 'goog'});
goog.addDependency('../../core/events/events_ui.js', ['Blockly.Events.Ui'], ['Blockly.Events', 'Blockly.Events.UiBase', 'Blockly.registry', 'Blockly.utils.object']);
goog.addDependency('../../core/events/events_ui_base.js', ['Blockly.Events.UiBase'], ['Blockly.Events', 'Blockly.Events.Abstract', 'Blockly.utils.object']);
goog.addDependency('../../core/events/events_ui.js', ['Blockly.Events.Ui'], ['Blockly.Events', 'Blockly.Events.UiBase', 'Blockly.registry', 'Blockly.utils.object'], {'lang': 'es6', 'module': 'goog'});
goog.addDependency('../../core/events/events_ui_base.js', ['Blockly.Events.UiBase'], ['Blockly.Events.Abstract', 'Blockly.utils.object'], {'lang': 'es6', 'module': 'goog'});
goog.addDependency('../../core/events/events_var_base.js', ['Blockly.Events.VarBase'], ['Blockly.Events.Abstract', 'Blockly.utils.object'], {'lang': 'es6', 'module': 'goog'});
goog.addDependency('../../core/events/events_var_create.js', ['Blockly.Events.VarCreate'], ['Blockly.Events', 'Blockly.Events.VarBase', 'Blockly.registry', 'Blockly.utils.object'], {'lang': 'es6', 'module': 'goog'});
goog.addDependency('../../core/events/events_var_delete.js', ['Blockly.Events.VarDelete'], ['Blockly.Events', 'Blockly.Events.VarBase', 'Blockly.registry', 'Blockly.utils.object'], {'lang': 'es6', 'module': 'goog'});