Merge pull request #5275 from gonfunko/events_viewport

Migrate core/events/events_viewport.js to goog.module syntax
This commit is contained in:
Aaron Dodson
2021-08-03 08:03:08 -07:00
committed by GitHub
2 changed files with 20 additions and 19 deletions

View File

@@ -10,12 +10,13 @@
*/
'use strict';
goog.provide('Blockly.Events.ViewportChange');
goog.module('Blockly.Events.ViewportChange');
goog.module.declareLegacyNamespace();
goog.require('Blockly.Events');
goog.require('Blockly.Events.UiBase');
goog.require('Blockly.registry');
goog.require('Blockly.utils.object');
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');
/**
@@ -30,12 +31,12 @@ goog.require('Blockly.utils.object');
* Undefined for a blank event.
* @param {number=} opt_oldScale The old scale of the workspace. Undefined for a
* blank event.
* @extends {Blockly.Events.UiBase}
* @extends {UiBase}
* @constructor
*/
Blockly.Events.ViewportChange = function(opt_top, opt_left, opt_scale,
opt_workspaceId, opt_oldScale) {
Blockly.Events.ViewportChange.superClass_.constructor.call(this, opt_workspaceId);
const ViewportChange = function(
opt_top, opt_left, opt_scale, opt_workspaceId, opt_oldScale) {
ViewportChange.superClass_.constructor.call(this, opt_workspaceId);
/**
* Top-edge of the visible portion of the workspace, relative to the workspace
@@ -63,21 +64,20 @@ Blockly.Events.ViewportChange = function(opt_top, opt_left, opt_scale,
*/
this.oldScale = opt_oldScale;
};
Blockly.utils.object.inherits(Blockly.Events.ViewportChange,
Blockly.Events.UiBase);
object.inherits(ViewportChange, UiBase);
/**
* Type of this event.
* @type {string}
*/
Blockly.Events.ViewportChange.prototype.type = Blockly.Events.VIEWPORT_CHANGE;
ViewportChange.prototype.type = Events.VIEWPORT_CHANGE;
/**
* Encode the event as JSON.
* @return {!Object} JSON representation.
*/
Blockly.Events.ViewportChange.prototype.toJson = function() {
var json = Blockly.Events.ViewportChange.superClass_.toJson.call(this);
ViewportChange.prototype.toJson = function() {
const json = ViewportChange.superClass_.toJson.call(this);
json['viewTop'] = this.viewTop;
json['viewLeft'] = this.viewLeft;
json['scale'] = this.scale;
@@ -89,13 +89,14 @@ Blockly.Events.ViewportChange.prototype.toJson = function() {
* Decode the JSON event.
* @param {!Object} json JSON representation.
*/
Blockly.Events.ViewportChange.prototype.fromJson = function(json) {
Blockly.Events.ViewportChange.superClass_.fromJson.call(this, json);
ViewportChange.prototype.fromJson = function(json) {
ViewportChange.superClass_.fromJson.call(this, json);
this.viewTop = json['viewTop'];
this.viewLeft = json['viewLeft'];
this.scale = json['scale'];
this.oldScale = json['oldScale'];
};
Blockly.registry.register(Blockly.registry.Type.EVENT,
Blockly.Events.VIEWPORT_CHANGE, Blockly.Events.ViewportChange);
registry.register(registry.Type.EVENT, Events.VIEWPORT_CHANGE, ViewportChange);
exports = ViewportChange;

View File

@@ -44,7 +44,7 @@ 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']);
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']);
goog.addDependency('../../core/events/events_viewport.js', ['Blockly.Events.ViewportChange'], ['Blockly.Events', 'Blockly.Events.UiBase', 'Blockly.registry', 'Blockly.utils.object']);
goog.addDependency('../../core/events/events_viewport.js', ['Blockly.Events.ViewportChange'], ['Blockly.Events', 'Blockly.Events.UiBase', 'Blockly.registry', 'Blockly.utils.object'], {'lang': 'es6', 'module': 'goog'});
goog.addDependency('../../core/events/ui_events.js', ['Blockly.Events.Ui', 'Blockly.Events.UiBase'], ['Blockly.Events', 'Blockly.Events.Abstract', 'Blockly.registry', 'Blockly.utils.object']);
goog.addDependency('../../core/events/variable_events.js', ['Blockly.Events.VarBase', 'Blockly.Events.VarCreate', 'Blockly.Events.VarDelete', 'Blockly.Events.VarRename'], ['Blockly.Events', 'Blockly.Events.Abstract', 'Blockly.registry', 'Blockly.utils.object']);
goog.addDependency('../../core/events/workspace_events.js', ['Blockly.Events.FinishedLoading'], ['Blockly.Events', 'Blockly.Events.Abstract', 'Blockly.registry', 'Blockly.utils.object'], {'lang': 'es5'});