mirror of
https://github.com/google/blockly.git
synced 2026-01-10 18:37:09 +01:00
Use registry to instantiate flyout from trashcan (#4706)
* Instantiate flyouts using registry in trashcan
This commit is contained in:
@@ -19,6 +19,7 @@ goog.require('Blockly.Events');
|
||||
/** @suppress {extraRequire} */
|
||||
goog.require('Blockly.Events.TrashcanOpen');
|
||||
goog.require('Blockly.IPositionable');
|
||||
goog.require('Blockly.registry');
|
||||
goog.require('Blockly.Scrollbar');
|
||||
goog.require('Blockly.utils.dom');
|
||||
goog.require('Blockly.utils.math');
|
||||
@@ -84,18 +85,18 @@ Blockly.Trashcan = function(workspace) {
|
||||
flyoutWorkspaceOptions.toolboxPosition =
|
||||
this.workspace_.toolboxPosition == Blockly.utils.toolbox.Position.TOP ?
|
||||
Blockly.utils.toolbox.Position.BOTTOM : Blockly.utils.toolbox.Position.TOP;
|
||||
if (!Blockly.HorizontalFlyout) {
|
||||
throw Error('Missing require for Blockly.HorizontalFlyout');
|
||||
}
|
||||
this.flyout = new Blockly.HorizontalFlyout(flyoutWorkspaceOptions);
|
||||
var HorizontalFlyout = Blockly.registry.getClassFromOptions(
|
||||
Blockly.registry.Type.FLYOUTS_HORIZONTAL_TOOLBOX,
|
||||
this.workspace_.options, true);
|
||||
this.flyout = new HorizontalFlyout(flyoutWorkspaceOptions);
|
||||
} else {
|
||||
flyoutWorkspaceOptions.toolboxPosition =
|
||||
this.workspace_.toolboxPosition == Blockly.utils.toolbox.Position.RIGHT ?
|
||||
Blockly.utils.toolbox.Position.LEFT : Blockly.utils.toolbox.Position.RIGHT;
|
||||
if (!Blockly.VerticalFlyout) {
|
||||
throw Error('Missing require for Blockly.VerticalFlyout');
|
||||
}
|
||||
this.flyout = new Blockly.VerticalFlyout(flyoutWorkspaceOptions);
|
||||
var VerticalFlyout = Blockly.registry.getClassFromOptions(
|
||||
Blockly.registry.Type.FLYOUTS_VERTICAL_TOOLBOX,
|
||||
this.workspace_.options, true);
|
||||
this.flyout = new VerticalFlyout(flyoutWorkspaceOptions);
|
||||
}
|
||||
this.workspace_.addChangeListener(this.onDelete_.bind(this));
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user