Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 18 additions & 17 deletions core/events/events_selected.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@
*/
'use strict';

goog.provide('Blockly.Events.Selected');
goog.module('Blockly.Events.Selected');
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');


/**
Expand All @@ -26,12 +27,11 @@ goog.require('Blockly.utils.object');
* element currently selected (deselect). Undefined for a blank event.
* @param {string=} opt_workspaceId The workspace identifier for this event.
* Null if no element previously selected. Undefined for a blank event.
* @extends {Blockly.Events.UiBase}
* @extends {UiBase}
* @constructor
*/
Blockly.Events.Selected = function(opt_oldElementId, opt_newElementId,
opt_workspaceId) {
Blockly.Events.Selected.superClass_.constructor.call(this, opt_workspaceId);
const Selected = function(opt_oldElementId, opt_newElementId, opt_workspaceId) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't have to do it right now, but I think this falls under the category of classes that could use a rename. I think SelectedEvent makes a lot more sense.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1, that would definitely make it clearer. Added a note to #5073 so we don't forget to revisit this.

Selected.superClass_.constructor.call(this, opt_workspaceId);

/**
* The id of the last selected element.
Expand All @@ -45,20 +45,20 @@ Blockly.Events.Selected = function(opt_oldElementId, opt_newElementId,
*/
this.newElementId = opt_newElementId;
};
Blockly.utils.object.inherits(Blockly.Events.Selected, Blockly.Events.UiBase);
object.inherits(Selected, UiBase);

/**
* Type of this event.
* @type {string}
*/
Blockly.Events.Selected.prototype.type = Blockly.Events.SELECTED;
Selected.prototype.type = Events.SELECTED;

/**
* Encode the event as JSON.
* @return {!Object} JSON representation.
*/
Blockly.Events.Selected.prototype.toJson = function() {
var json = Blockly.Events.Selected.superClass_.toJson.call(this);
Selected.prototype.toJson = function() {
const json = Selected.superClass_.toJson.call(this);
json['oldElementId'] = this.oldElementId;
json['newElementId'] = this.newElementId;
return json;
Expand All @@ -68,11 +68,12 @@ Blockly.Events.Selected.prototype.toJson = function() {
* Decode the JSON event.
* @param {!Object} json JSON representation.
*/
Blockly.Events.Selected.prototype.fromJson = function(json) {
Blockly.Events.Selected.superClass_.fromJson.call(this, json);
Selected.prototype.fromJson = function(json) {
Selected.superClass_.fromJson.call(this, json);
this.oldElementId = json['oldElementId'];
this.newElementId = json['newElementId'];
};

Blockly.registry.register(Blockly.registry.Type.EVENT, Blockly.Events.SELECTED,
Blockly.Events.Selected);
registry.register(registry.Type.EVENT, Events.SELECTED, Selected);

exports = Selected;
2 changes: 1 addition & 1 deletion tests/deps.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.