mirror of
https://github.com/google/blockly.git
synced 2026-01-10 02:17:09 +01:00
Merge pull request #5284 from gonfunko/events_click
Migrate core/events/events_click.js to goog.module syntax
This commit is contained in:
@@ -10,31 +10,31 @@
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
goog.provide('Blockly.Events.Click');
|
||||
|
||||
goog.require('Blockly.Events');
|
||||
goog.require('Blockly.Events.UiBase');
|
||||
goog.require('Blockly.registry');
|
||||
goog.require('Blockly.utils.object');
|
||||
|
||||
goog.requireType('Blockly.Block');
|
||||
goog.module('Blockly.Events.Click');
|
||||
goog.module.declareLegacyNamespace();
|
||||
|
||||
/* 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 click event.
|
||||
* @param {?Blockly.Block=} opt_block The affected block. Null for click events
|
||||
* @param {?Block=} opt_block The affected block. Null for click events
|
||||
* that do not have an associated block (i.e. workspace click). Undefined
|
||||
* for a blank event.
|
||||
* @param {?string=} opt_workspaceId The workspace identifier for this event.
|
||||
* Not used if block is passed. Undefined for a blank event.
|
||||
* @param {string=} opt_targetType The type of element targeted by this click
|
||||
* event. Undefined for a blank event.
|
||||
* @extends {Blockly.Events.UiBase}
|
||||
* @extends {UiBase}
|
||||
* @constructor
|
||||
*/
|
||||
Blockly.Events.Click = function(opt_block, opt_workspaceId, opt_targetType) {
|
||||
var workspaceId = opt_block ? opt_block.workspace.id : opt_workspaceId;
|
||||
Blockly.Events.Click.superClass_.constructor.call(this, workspaceId);
|
||||
const Click = function(opt_block, opt_workspaceId, opt_targetType) {
|
||||
const workspaceId = opt_block ? opt_block.workspace.id : opt_workspaceId;
|
||||
Click.superClass_.constructor.call(this, workspaceId);
|
||||
this.blockId = opt_block ? opt_block.id : null;
|
||||
|
||||
/**
|
||||
@@ -43,20 +43,20 @@ Blockly.Events.Click = function(opt_block, opt_workspaceId, opt_targetType) {
|
||||
*/
|
||||
this.targetType = opt_targetType;
|
||||
};
|
||||
Blockly.utils.object.inherits(Blockly.Events.Click, Blockly.Events.UiBase);
|
||||
object.inherits(Click, UiBase);
|
||||
|
||||
/**
|
||||
* Type of this event.
|
||||
* @type {string}
|
||||
*/
|
||||
Blockly.Events.Click.prototype.type = Blockly.Events.CLICK;
|
||||
Click.prototype.type = Events.CLICK;
|
||||
|
||||
/**
|
||||
* Encode the event as JSON.
|
||||
* @return {!Object} JSON representation.
|
||||
*/
|
||||
Blockly.Events.Click.prototype.toJson = function() {
|
||||
var json = Blockly.Events.Click.superClass_.toJson.call(this);
|
||||
Click.prototype.toJson = function() {
|
||||
const json = Click.superClass_.toJson.call(this);
|
||||
json['targetType'] = this.targetType;
|
||||
if (this.blockId) {
|
||||
json['blockId'] = this.blockId;
|
||||
@@ -68,11 +68,12 @@ Blockly.Events.Click.prototype.toJson = function() {
|
||||
* Decode the JSON event.
|
||||
* @param {!Object} json JSON representation.
|
||||
*/
|
||||
Blockly.Events.Click.prototype.fromJson = function(json) {
|
||||
Blockly.Events.Click.superClass_.fromJson.call(this, json);
|
||||
Click.prototype.fromJson = function(json) {
|
||||
Click.superClass_.fromJson.call(this, json);
|
||||
this.targetType = json['targetType'];
|
||||
this.blockId = json['blockId'];
|
||||
};
|
||||
|
||||
Blockly.registry.register(Blockly.registry.Type.EVENT, Blockly.Events.CLICK,
|
||||
Blockly.Events.Click);
|
||||
registry.register(registry.Type.EVENT, Events.CLICK, Click);
|
||||
|
||||
exports = Click;
|
||||
|
||||
@@ -38,7 +38,7 @@ goog.addDependency('../../core/events/events.js', ['Blockly.Events'], ['Blockly.
|
||||
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_click.js', ['Blockly.Events.Click'], ['Blockly.Events', 'Blockly.Events.UiBase', 'Blockly.registry', 'Blockly.utils.object']);
|
||||
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']);
|
||||
goog.addDependency('../../core/events/events_theme_change.js', ['Blockly.Events.ThemeChange'], ['Blockly.Events', 'Blockly.Events.UiBase', 'Blockly.registry', 'Blockly.utils.object']);
|
||||
|
||||
Reference in New Issue
Block a user