mirror of
https://github.com/google/blockly.git
synced 2026-01-22 00:07:12 +01:00
* chore(tests): update event assert functions to pass in types directly * refactor: move event types from prototypes to constructors * refactor: convert events/events_block_change.js to ES6 class * refactor: convert events/events_block_create.js to ES6 class * refactor: convert events/events_block_delete.js to ES6 class * refactor: convert events/events_block_drag.js to ES6 class * refactor: convert events/events_block_move.js to ES6 class * refactor: convert events/events_click.js to ES6 class * refactor: convert events/events_comment_change.js to ES6 class * refactor: convert events/events_comment_create.js to ES6 class * refactor: convert events/events_comment_delete.js to ES6 class * refactor: convert events/events_comment_move.js to ES6 class * refactor: convert events/events_marker_move.js to ES6 class * refactor: convert events/events_selected.js to ES6 class * refactor: convert events/events_theme_change.js to ES6 class * refactor: convert events/events_toolbox_item_select.js to ES6 class * refactor: convert events/events_trashcan_open.js to ES6 class * refactor: convert events/events_ui.js to ES6 class * refactor: convert events/events_var_create.js to ES6 class * refactor: convert events/events_var_delete.js to ES6 class * refactor: convert events/events_var_rename.js to ES6 class * refactor: convert events/events_viewport.js to ES6 class * chore: rebuild * chore: run clang-format
90 lines
2.4 KiB
JavaScript
90 lines
2.4 KiB
JavaScript
/**
|
|
* @license
|
|
* Copyright 2020 Google LLC
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
/**
|
|
* @fileoverview Events fired as a result of bubble open.
|
|
*/
|
|
'use strict';
|
|
|
|
/**
|
|
* Events fired as a result of bubble open.
|
|
* @class
|
|
*/
|
|
goog.module('Blockly.Events.BubbleOpen');
|
|
|
|
const eventUtils = goog.require('Blockly.Events.utils');
|
|
const object = goog.require('Blockly.utils.object');
|
|
const registry = goog.require('Blockly.registry');
|
|
/* eslint-disable-next-line no-unused-vars */
|
|
const {BlockSvg} = goog.requireType('Blockly.BlockSvg');
|
|
const {UiBase} = goog.require('Blockly.Events.UiBase');
|
|
|
|
|
|
/**
|
|
* Class for a bubble open event.
|
|
* @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'
|
|
* or 'warning'. Undefined for a blank event.
|
|
* @extends {UiBase}
|
|
* @constructor
|
|
* @alias Blockly.Events.BubbleOpen
|
|
*/
|
|
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;
|
|
|
|
/**
|
|
* Whether the bubble is opening (false if closing).
|
|
* @type {boolean|undefined}
|
|
*/
|
|
this.isOpen = opt_isOpen;
|
|
|
|
/**
|
|
* The type of bubble. One of 'mutator', 'comment', or 'warning'.
|
|
* @type {string|undefined}
|
|
*/
|
|
this.bubbleType = opt_bubbleType;
|
|
|
|
/**
|
|
* Type of this event.
|
|
* @type {string}
|
|
*/
|
|
this.type = eventUtils.BUBBLE_OPEN;
|
|
};
|
|
object.inherits(BubbleOpen, UiBase);
|
|
|
|
/**
|
|
* Encode the event as JSON.
|
|
* @return {!Object} JSON representation.
|
|
*/
|
|
BubbleOpen.prototype.toJson = function() {
|
|
const json = BubbleOpen.superClass_.toJson.call(this);
|
|
json['isOpen'] = this.isOpen;
|
|
json['bubbleType'] = this.bubbleType;
|
|
json['blockId'] = this.blockId;
|
|
return json;
|
|
};
|
|
|
|
/**
|
|
* Decode the JSON event.
|
|
* @param {!Object} json JSON representation.
|
|
*/
|
|
BubbleOpen.prototype.fromJson = function(json) {
|
|
BubbleOpen.superClass_.fromJson.call(this, json);
|
|
this.isOpen = json['isOpen'];
|
|
this.bubbleType = json['bubbleType'];
|
|
this.blockId = json['blockId'];
|
|
};
|
|
|
|
registry.register(registry.Type.EVENT, eventUtils.BUBBLE_OPEN, BubbleOpen);
|
|
|
|
exports.BubbleOpen = BubbleOpen;
|