diff --git a/core/interfaces/i_collapsible_toolbox_item.js b/core/interfaces/i_collapsible_toolbox_item.js new file mode 100644 index 000000000..c92008358 --- /dev/null +++ b/core/interfaces/i_collapsible_toolbox_item.js @@ -0,0 +1,45 @@ +/** + * @license + * Copyright 2020 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */ + +/** + * @fileoverview The interface for a collapsible toolbox item. + * @author kozbial@google.com (Monica Kozbial) + */ + +'use strict'; + +goog.provide('Blockly.ICollapsibleToolboxItem'); + +goog.require('Blockly.IToolboxItem'); +goog.requireType('Blockly.utils.toolbox'); + + +/** + * Interface for an item in the toolbox that can be collapsed. + * @extends {Blockly.ISelectableToolboxItem} + * @interface + */ +Blockly.ICollapsibleToolboxItem = function() {}; + +/** + * Gets any children toolbox items. (ex. Gets the subcategories) + * @return {!Array} The child toolbox items. + */ +Blockly.ICollapsibleToolboxItem.prototype.getChildToolboxItems; + +/** + * Whether the toolbox item is expanded to show its child subcategories. + * @return {boolean} True if the toolbox item shows its children, false if it + * is collapsed. + * @public + */ +Blockly.ICollapsibleToolboxItem.prototype.isExpanded; + +/** + * Toggles whether or not the toolbox item is expanded. + * @public + */ +Blockly.ICollapsibleToolboxItem.prototype.toggleExpanded; diff --git a/core/interfaces/i_selectable_toolbox_item.js b/core/interfaces/i_selectable_toolbox_item.js new file mode 100644 index 000000000..fb7b8558f --- /dev/null +++ b/core/interfaces/i_selectable_toolbox_item.js @@ -0,0 +1,65 @@ +/** + * @license + * Copyright 2020 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */ + +/** + * @fileoverview The interface for a selectable toolbox item. + * @author aschmiedt@google.com (Abby Schmiedt) + */ + +'use strict'; + +goog.provide('Blockly.ISelectableToolboxItem'); + +goog.require('Blockly.IToolboxItem'); +goog.requireType('Blockly.utils.toolbox'); + + +/** + * Interface for an item in the toolbox that can be selected. + * @extends {Blockly.IToolboxItem} + * @interface + */ +Blockly.ISelectableToolboxItem = function() {}; + +/** + * Gets the name of the toolbox item. Used for emitting events. + * @return {string} The name of the toolbox item. + * @public + */ +Blockly.ISelectableToolboxItem.prototype.getName; + +/** + * Gets the contents of the toolbox item. These are items that are meant to be + * displayed in the flyout. + * @return {!Blockly.utils.toolbox.FlyoutItemInfoArray|string} The definition + * of items to be displayed in the flyout. + * @public + */ +Blockly.ISelectableToolboxItem.prototype.getContents; + +/** + * Sets the current toolbox item as selected. + * @param {boolean} _isSelected True if this category is selected, false + * otherwise. + * @public + */ +Blockly.ISelectableToolboxItem.prototype.setSelected; + +/** + * Gets the HTML element that is clickable. + * The parent toolbox element receives clicks. The parent toolbox will add an ID + * to this element so it can pass the onClick event to the correct toolboxItem. + * @return {!Element} The HTML element that receives clicks. + * @public + */ +Blockly.ISelectableToolboxItem.prototype.getClickTarget; + +/** + * Handles when the toolbox item is clicked. + * @param {!Event} _e Click event to handle. + * @public + */ +Blockly.ISelectableToolboxItem.prototype.onClick; diff --git a/core/interfaces/i_toolbox_item.js b/core/interfaces/i_toolbox_item.js index afd6191f7..ce646d376 100644 --- a/core/interfaces/i_toolbox_item.js +++ b/core/interfaces/i_toolbox_item.js @@ -11,8 +11,6 @@ 'use strict'; -goog.provide('Blockly.ICollapsibleToolboxItem'); -goog.provide('Blockly.ISelectableToolboxItem'); goog.provide('Blockly.IToolboxItem'); goog.requireType('Blockly.utils.toolbox'); @@ -81,77 +79,3 @@ Blockly.IToolboxItem.prototype.isCollapsible; * @public */ Blockly.IToolboxItem.prototype.dispose; - -/** - * Interface for an item in the toolbox that can be selected. - * @extends {Blockly.IToolboxItem} - * @interface - */ -Blockly.ISelectableToolboxItem = function() {}; - -/** - * Gets the name of the toolbox item. Used for emitting events. - * @return {string} The name of the toolbox item. - * @public - */ -Blockly.ISelectableToolboxItem.prototype.getName; - -/** - * Gets the contents of the toolbox item. These are items that are meant to be - * displayed in the flyout. - * @return {!Blockly.utils.toolbox.FlyoutItemInfoArray|string} The definition - * of items to be displayed in the flyout. - * @public - */ -Blockly.ISelectableToolboxItem.prototype.getContents; - -/** - * Sets the current toolbox item as selected. - * @param {boolean} _isSelected True if this category is selected, false - * otherwise. - * @public - */ -Blockly.ISelectableToolboxItem.prototype.setSelected; - -/** - * Gets the HTML element that is clickable. - * The parent toolbox element receives clicks. The parent toolbox will add an ID - * to this element so it can pass the onClick event to the correct toolboxItem. - * @return {!Element} The HTML element that receives clicks. - * @public - */ -Blockly.ISelectableToolboxItem.prototype.getClickTarget; - -/** - * Handles when the toolbox item is clicked. - * @param {!Event} _e Click event to handle. - * @public - */ -Blockly.ISelectableToolboxItem.prototype.onClick; - -/** - * Interface for an item in the toolbox that can be collapsed. - * @extends {Blockly.ISelectableToolboxItem} - * @interface - */ -Blockly.ICollapsibleToolboxItem = function() {}; - -/** - * Gets any children toolbox items. (ex. Gets the subcategories) - * @return {!Array} The child toolbox items. - */ -Blockly.ICollapsibleToolboxItem.prototype.getChildToolboxItems; - -/** - * Whether the toolbox item is expanded to show its child subcategories. - * @return {boolean} True if the toolbox item shows its children, false if it - * is collapsed. - * @public - */ -Blockly.ICollapsibleToolboxItem.prototype.isExpanded; - -/** - * Toggles whether or not the toolbox item is expanded. - * @public - */ -Blockly.ICollapsibleToolboxItem.prototype.toggleExpanded;