Skip to content

Commit 02160ec

Browse files
Merge pull request #57 from rachel-fenichel/feature/horizontal_config
Turn toolbox sideways in the horizontal playground.
2 parents 11c77cd + 803d0e7 commit 02160ec

File tree

6 files changed

+14
-4
lines changed

6 files changed

+14
-4
lines changed

core/flyout.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ Blockly.Flyout = function(workspaceOptions) {
6060
* Flyout should be laid out horizontally vs vertically.
6161
* @type {boolean}
6262
*/
63-
this.horizontalLayout_ = false;
63+
this.horizontalLayout_ = workspaceOptions.horizontalLayout;
6464

6565
/**
6666
* Opaque data that can be passed to Blockly.unbindEvent_.

core/inject.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,10 @@ Blockly.parseOptions_ = function(options) {
125125
if (hasSounds === undefined) {
126126
hasSounds = true;
127127
}
128+
var horizontalLayout = options['horizontalLayout'];
129+
if (horizontalLayout === undefined) {
130+
horizontalLayout = false;
131+
}
128132
}
129133
var hasScrollbars = options['scrollbars'];
130134
if (hasScrollbars === undefined) {
@@ -201,6 +205,7 @@ Blockly.parseOptions_ = function(options) {
201205
hasTrashcan: hasTrashcan,
202206
hasSounds: hasSounds,
203207
hasCss: hasCss,
208+
horizontalLayout: horizontalLayout,
204209
languageTree: languageTree,
205210
gridOptions: gridOptions,
206211
zoomOptions: zoomOptions,

core/toolbox.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ Blockly.Toolbox = function(workspace) {
6464
* @type {boolean}
6565
* @private
6666
*/
67-
this.horizontalLayout_ = false;
67+
this.horizontalLayout_ = workspace.options.horizontalLayout;
6868

6969
if (this.horizontalLayout_) {
7070
this.CONFIG_['cssTreeRow'] =
@@ -148,7 +148,8 @@ Blockly.Toolbox.prototype.init = function() {
148148
var workspaceOptions = {
149149
disabledPatternId: workspace.options.disabledPatternId,
150150
parentWorkspace: workspace,
151-
RTL: workspace.RTL
151+
RTL: workspace.RTL,
152+
horizontalLayout: workspace.horizontalLayout
152153
};
153154

154155
/**

core/workspace.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ Blockly.Workspace = function(opt_options) {
4343
this.options = opt_options || {};
4444
/** @type {boolean} */
4545
this.RTL = !!this.options.RTL;
46+
/** @type {boolean} */
47+
this.horizontalLayout = !!this.options.horizontalLayout;
4648
/** @type {!Array.<!Blockly.Block>} */
4749
this.topBlocks_ = [];
4850
};

core/workspace_svg.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,8 @@ Blockly.WorkspaceSvg.prototype.addFlyout_ = function() {
294294
var workspaceOptions = {
295295
disabledPatternId: this.options.disabledPatternId,
296296
parentWorkspace: this,
297-
RTL: this.RTL
297+
RTL: this.RTL,
298+
horizontalLayout: this.horizontalLayout
298299
};
299300
/** @type {Blockly.Flyout} */
300301
this.flyout_ = new Blockly.Flyout(workspaceOptions);

tests/horizontal_playground.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
scrollbars: true,
3434
toolbox: toolbox,
3535
trashcan: true,
36+
horizontalLayout: true,
3637
zoom: {
3738
controls: true,
3839
wheel: false,

0 commit comments

Comments
 (0)