mirror of
https://github.com/google/blockly.git
synced 2026-01-25 09:40:10 +01:00
* Migrate core/events/events_theme_change.js to ES6 const/let * Migrate core/events/events_theme_change.js to goog.module * Migrate core/events/events_theme_change.js to named requires * clang-format core/events/events_theme_change.js
69 lines
1.7 KiB
JavaScript
69 lines
1.7 KiB
JavaScript
/**
|
|
* @license
|
|
* Copyright 2020 Google LLC
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
/**
|
|
* @fileoverview Events fired as a result of a theme update.
|
|
* @author kozbial@google.com (Monica Kozbial)
|
|
*/
|
|
'use strict';
|
|
|
|
goog.module('Blockly.Events.ThemeChange');
|
|
goog.module.declareLegacyNamespace();
|
|
|
|
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 theme change event.
|
|
* @param {string=} opt_themeName The theme name. Undefined for a blank event.
|
|
* @param {string=} opt_workspaceId The workspace identifier for this event.
|
|
* event. Undefined for a blank event.
|
|
* @extends {UiBase}
|
|
* @constructor
|
|
*/
|
|
const ThemeChange = function(opt_themeName, opt_workspaceId) {
|
|
ThemeChange.superClass_.constructor.call(this, opt_workspaceId);
|
|
|
|
/**
|
|
* The theme name.
|
|
* @type {string|undefined}
|
|
*/
|
|
this.themeName = opt_themeName;
|
|
};
|
|
object.inherits(ThemeChange, UiBase);
|
|
|
|
/**
|
|
* Type of this event.
|
|
* @type {string}
|
|
*/
|
|
ThemeChange.prototype.type = Events.THEME_CHANGE;
|
|
|
|
/**
|
|
* Encode the event as JSON.
|
|
* @return {!Object} JSON representation.
|
|
*/
|
|
ThemeChange.prototype.toJson = function() {
|
|
const json = ThemeChange.superClass_.toJson.call(this);
|
|
json['themeName'] = this.themeName;
|
|
return json;
|
|
};
|
|
|
|
/**
|
|
* Decode the JSON event.
|
|
* @param {!Object} json JSON representation.
|
|
*/
|
|
ThemeChange.prototype.fromJson = function(json) {
|
|
ThemeChange.superClass_.fromJson.call(this, json);
|
|
this.themeName = json['themeName'];
|
|
};
|
|
|
|
registry.register(registry.Type.EVENT, Events.THEME_CHANGE, ThemeChange);
|
|
|
|
exports = ThemeChange;
|