mirror of
https://github.com/google/blockly.git
synced 2026-01-12 19:37:08 +01:00
Make flyouts be optional modules.
No Blockly instances need both Horizontal and Vertical flyouts. Dropping one of these saves 2 KB. Some don’t need flyouts at all (e.g. Blockly Games Puzzle or readonly documentation blocks).
This commit is contained in:
@@ -34,12 +34,10 @@ goog.require('Blockly.BlockSvg.render');
|
||||
goog.require('Blockly.Events');
|
||||
goog.require('Blockly.Events.Ui');
|
||||
goog.require('Blockly.Generator');
|
||||
goog.require('Blockly.HorizontalFlyout');
|
||||
goog.require('Blockly.navigation');
|
||||
goog.require('Blockly.Procedures');
|
||||
goog.require('Blockly.Tooltip');
|
||||
goog.require('Blockly.Touch');
|
||||
goog.require('Blockly.VerticalFlyout');
|
||||
goog.require('Blockly.WidgetDiv');
|
||||
goog.require('Blockly.WorkspaceSvg');
|
||||
goog.require('Blockly.constants');
|
||||
|
||||
@@ -35,6 +35,9 @@ goog.require('Blockly');
|
||||
// configuration must be false, and no blocks may be loaded from XML which
|
||||
// define comments.
|
||||
goog.require('Blockly.Comment');
|
||||
// One of these two will almost certainly be needed (usually VerticalFlyout).
|
||||
goog.require('Blockly.HorizontalFlyout');
|
||||
goog.require('Blockly.VerticalFlyout');
|
||||
// If the toolbox does not have categories and only has a simple flyout, then
|
||||
// 'Blockly.Toolbox' is not needed.
|
||||
goog.require('Blockly.Toolbox');
|
||||
|
||||
@@ -28,8 +28,6 @@ goog.provide('Blockly.Toolbox');
|
||||
|
||||
goog.require('Blockly.Events');
|
||||
goog.require('Blockly.Events.Ui');
|
||||
goog.require('Blockly.Flyout');
|
||||
goog.require('Blockly.HorizontalFlyout');
|
||||
goog.require('Blockly.navigation');
|
||||
goog.require('Blockly.Touch');
|
||||
goog.require('Blockly.tree.TreeControl');
|
||||
@@ -40,7 +38,6 @@ goog.require('Blockly.utils.colour');
|
||||
goog.require('Blockly.utils.dom');
|
||||
goog.require('Blockly.utils.object');
|
||||
goog.require('Blockly.utils.Rect');
|
||||
goog.require('Blockly.VerticalFlyout');
|
||||
|
||||
|
||||
/**
|
||||
@@ -186,8 +183,14 @@ Blockly.Toolbox.prototype.init = function() {
|
||||
*/
|
||||
this.flyout_ = null;
|
||||
if (workspace.horizontalLayout) {
|
||||
if (!Blockly.HorizontalFlyout) {
|
||||
throw Error('Missing require for Blockly.HorizontalFlyout');
|
||||
}
|
||||
this.flyout_ = new Blockly.HorizontalFlyout(workspaceOptions);
|
||||
} else {
|
||||
if (!Blockly.VerticalFlyout) {
|
||||
throw Error('Missing require for Blockly.VerticalFlyout');
|
||||
}
|
||||
this.flyout_ = new Blockly.VerticalFlyout(workspaceOptions);
|
||||
}
|
||||
// Insert the flyout after the workspace.
|
||||
|
||||
@@ -78,11 +78,17 @@ Blockly.Trashcan = function(workspace) {
|
||||
flyoutWorkspaceOptions.toolboxPosition =
|
||||
this.workspace_.toolboxPosition == Blockly.TOOLBOX_AT_TOP ?
|
||||
Blockly.TOOLBOX_AT_BOTTOM : Blockly.TOOLBOX_AT_TOP;
|
||||
if (!Blockly.HorizontalFlyout) {
|
||||
throw Error('Missing require for Blockly.HorizontalFlyout');
|
||||
}
|
||||
this.flyout_ = new Blockly.HorizontalFlyout(flyoutWorkspaceOptions);
|
||||
} else {
|
||||
flyoutWorkspaceOptions.toolboxPosition =
|
||||
this.workspace_.toolboxPosition == Blockly.TOOLBOX_AT_RIGHT ?
|
||||
Blockly.TOOLBOX_AT_LEFT : Blockly.TOOLBOX_AT_RIGHT;
|
||||
if (!Blockly.VerticalFlyout) {
|
||||
throw Error('Missing require for Blockly.VerticalFlyout');
|
||||
}
|
||||
this.flyout_ = new Blockly.VerticalFlyout(flyoutWorkspaceOptions);
|
||||
}
|
||||
this.workspace_.addChangeListener(this.onDelete_());
|
||||
|
||||
@@ -810,8 +810,14 @@ Blockly.WorkspaceSvg.prototype.addFlyout_ = function(tagName) {
|
||||
renderer: this.options.renderer
|
||||
};
|
||||
if (this.horizontalLayout) {
|
||||
if (!Blockly.HorizontalFlyout) {
|
||||
throw Error('Missing require for Blockly.HorizontalFlyout');
|
||||
}
|
||||
this.flyout_ = new Blockly.HorizontalFlyout(workspaceOptions);
|
||||
} else {
|
||||
if (!Blockly.VerticalFlyout) {
|
||||
throw Error('Missing require for Blockly.VerticalFlyout');
|
||||
}
|
||||
this.flyout_ = new Blockly.VerticalFlyout(workspaceOptions);
|
||||
}
|
||||
this.flyout_.autoClose = false;
|
||||
|
||||
@@ -3,6 +3,7 @@ goog.provide('Main');
|
||||
// Either require 'Blockly.requires', or just the components you use:
|
||||
goog.require('Blockly');
|
||||
goog.require('Blockly.geras.Renderer');
|
||||
goog.require('Blockly.VerticalFlyout');
|
||||
// Blocks
|
||||
goog.require('Blockly.Constants.Logic');
|
||||
goog.require('Blockly.Constants.Loops');
|
||||
|
||||
Reference in New Issue
Block a user