@blockdia/scratch-blocks 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.nvmrc +1 -0
- package/LICENSE +674 -0
- package/README.md +57 -0
- package/TRADEMARK +1 -0
- package/blockly_compressed_horizontal.js +2268 -0
- package/blockly_compressed_vertical.js +2296 -0
- package/blockly_uncompressed_horizontal.js +1212 -0
- package/blockly_uncompressed_vertical.js +1212 -0
- package/blocks_common/colour.js +61 -0
- package/blocks_common/math.js +159 -0
- package/blocks_common/matrix.js +54 -0
- package/blocks_common/note.js +58 -0
- package/blocks_common/text.js +57 -0
- package/blocks_compressed.js +37 -0
- package/blocks_compressed_horizontal.js +68 -0
- package/blocks_compressed_vertical.js +216 -0
- package/blocks_horizontal/control.js +212 -0
- package/blocks_horizontal/default_toolbox.js +139 -0
- package/blocks_horizontal/event.js +190 -0
- package/blocks_horizontal/wedo.js +325 -0
- package/blocks_vertical/control.js +532 -0
- package/blocks_vertical/data.js +666 -0
- package/blocks_vertical/default_toolbox.js +571 -0
- package/blocks_vertical/event.js +329 -0
- package/blocks_vertical/extensions.js +294 -0
- package/blocks_vertical/looks.js +591 -0
- package/blocks_vertical/motion.js +587 -0
- package/blocks_vertical/operators.js +470 -0
- package/blocks_vertical/procedures.js +1051 -0
- package/blocks_vertical/sensing.js +555 -0
- package/blocks_vertical/sound.js +246 -0
- package/blocks_vertical/vertical_extensions.js +289 -0
- package/build/gen_blocks.js +1 -0
- package/build/test_expect.js +1 -0
- package/build/test_input.js +1 -0
- package/build.py +647 -0
- package/cleanup.sh +101 -0
- package/core/block.js +1837 -0
- package/core/block_animations.js +107 -0
- package/core/block_drag_surface.js +299 -0
- package/core/block_dragger.js +424 -0
- package/core/block_events.js +531 -0
- package/core/block_render_svg_horizontal.js +892 -0
- package/core/block_render_svg_vertical.js +1734 -0
- package/core/block_svg.js +1355 -0
- package/core/blockly.js +620 -0
- package/core/blocks.js +37 -0
- package/core/bubble.js +664 -0
- package/core/bubble_dragger.js +285 -0
- package/core/colours.js +177 -0
- package/core/comment.js +293 -0
- package/core/comment_events.js +539 -0
- package/core/connection.js +776 -0
- package/core/connection_db.js +300 -0
- package/core/constants.js +408 -0
- package/core/contextmenu.js +534 -0
- package/core/css.js +1354 -0
- package/core/data_category.js +490 -0
- package/core/dragged_connection_manager.js +260 -0
- package/core/dropdowndiv.js +408 -0
- package/core/events.js +429 -0
- package/core/events_abstract.js +113 -0
- package/core/extensions.js +450 -0
- package/core/field.js +810 -0
- package/core/field_angle.js +410 -0
- package/core/field_checkbox.js +133 -0
- package/core/field_colour.js +253 -0
- package/core/field_colour_slider.js +387 -0
- package/core/field_date.js +353 -0
- package/core/field_dropdown.js +447 -0
- package/core/field_iconmenu.js +309 -0
- package/core/field_image.js +200 -0
- package/core/field_label.js +136 -0
- package/core/field_label_serializable.js +125 -0
- package/core/field_matrix.js +566 -0
- package/core/field_note.js +850 -0
- package/core/field_number.js +366 -0
- package/core/field_numberdropdown.js +77 -0
- package/core/field_textdropdown.js +164 -0
- package/core/field_textinput.js +675 -0
- package/core/field_textinput_removable.js +105 -0
- package/core/field_variable.js +385 -0
- package/core/field_variable_getter.js +185 -0
- package/core/field_vertical_separator.js +161 -0
- package/core/flyout_base.js +935 -0
- package/core/flyout_button.js +324 -0
- package/core/flyout_dragger.js +83 -0
- package/core/flyout_extension_category_header.js +159 -0
- package/core/flyout_horizontal.js +475 -0
- package/core/flyout_vertical.js +770 -0
- package/core/generator.js +426 -0
- package/core/gesture.js +1010 -0
- package/core/grid.js +227 -0
- package/core/icon.js +205 -0
- package/core/inject.js +496 -0
- package/core/input.js +285 -0
- package/core/insertion_marker_manager.js +678 -0
- package/core/intersection_observer.js +102 -0
- package/core/msg.js +62 -0
- package/core/mutator.js +426 -0
- package/core/names.js +198 -0
- package/core/options.js +244 -0
- package/core/procedures.js +739 -0
- package/core/rendered_connection.js +417 -0
- package/core/scratch_block_comment.js +646 -0
- package/core/scratch_blocks_utils.js +246 -0
- package/core/scratch_bubble.js +699 -0
- package/core/scratch_events.js +131 -0
- package/core/scratch_msgs.js +85 -0
- package/core/scrollbar.js +875 -0
- package/core/toolbox.js +803 -0
- package/core/tooltip.js +337 -0
- package/core/touch.js +226 -0
- package/core/trashcan.js +343 -0
- package/core/ui_events.js +91 -0
- package/core/ui_menu_utils.js +68 -0
- package/core/utils.js +825 -0
- package/core/variable_events.js +259 -0
- package/core/variable_map.js +415 -0
- package/core/variable_model.js +116 -0
- package/core/variables.js +674 -0
- package/core/warning.js +199 -0
- package/core/widgetdiv.js +344 -0
- package/core/workspace.js +673 -0
- package/core/workspace_audio.js +170 -0
- package/core/workspace_comment.js +426 -0
- package/core/workspace_comment_render_svg.js +706 -0
- package/core/workspace_comment_svg.js +609 -0
- package/core/workspace_drag_surface_svg.js +195 -0
- package/core/workspace_dragger.js +132 -0
- package/core/workspace_svg.js +2382 -0
- package/core/xml.js +930 -0
- package/core/zoom_controls.js +301 -0
- package/dist/horizontal.js +222 -0
- package/dist/vertical.js +222 -0
- package/dist/web/horizontal.js +232 -0
- package/dist/web/vertical.js +232 -0
- package/i18n/common.py +234 -0
- package/i18n/create_messages.py +162 -0
- package/i18n/create_scratch_msgs.js +69 -0
- package/i18n/dedup_json.py +73 -0
- package/i18n/js_to_json.js +46 -0
- package/i18n/js_to_json.py +136 -0
- package/i18n/json_to_js.js +52 -0
- package/i18n/json_to_js.py +185 -0
- package/i18n/sync_tx_translations.js +111 -0
- package/i18n/test_scratch_msgs.js +87 -0
- package/i18n/tests.py +47 -0
- package/i18n/xliff_to_json.py +232 -0
- package/local_build.sh +70 -0
- package/media/click.mp3 +0 -0
- package/media/click.ogg +0 -0
- package/media/click.wav +0 -0
- package/media/comment-arrow-down.svg +10 -0
- package/media/comment-arrow-up.svg +10 -0
- package/media/delete-x.svg +10 -0
- package/media/delete.mp3 +0 -0
- package/media/delete.ogg +0 -0
- package/media/delete.wav +0 -0
- package/media/dropdown-arrow-dark.svg +1 -0
- package/media/dropdown-arrow.svg +1 -0
- package/media/extensions/microbit-block-icon.svg +130 -0
- package/media/extensions/music-block-icon.svg +17 -0
- package/media/extensions/pen-block-icon.svg +19 -0
- package/media/extensions/wedo2-block-icon.svg +36 -0
- package/media/eyedropper.svg +22 -0
- package/media/green-flag.svg +17 -0
- package/media/handclosed.cur +0 -0
- package/media/handdelete.cur +0 -0
- package/media/handopen.cur +0 -0
- package/media/icons/arrow.svg +12 -0
- package/media/icons/arrow_button.svg +1 -0
- package/media/icons/control_forever.svg +1 -0
- package/media/icons/control_repeat.svg +1 -0
- package/media/icons/control_stop.svg +1 -0
- package/media/icons/control_wait.svg +1 -0
- package/media/icons/event_broadcast_blue.svg +1 -0
- package/media/icons/event_broadcast_coral.svg +1 -0
- package/media/icons/event_broadcast_green.svg +1 -0
- package/media/icons/event_broadcast_magenta.svg +1 -0
- package/media/icons/event_broadcast_orange.svg +1 -0
- package/media/icons/event_broadcast_purple.svg +1 -0
- package/media/icons/event_when-broadcast-received_blue.svg +1 -0
- package/media/icons/event_when-broadcast-received_coral.svg +1 -0
- package/media/icons/event_when-broadcast-received_green.svg +1 -0
- package/media/icons/event_when-broadcast-received_magenta.svg +1 -0
- package/media/icons/event_when-broadcast-received_orange.svg +1 -0
- package/media/icons/event_when-broadcast-received_purple.svg +1 -0
- package/media/icons/event_whenflagclicked.svg +1 -0
- package/media/icons/remove.svg +19 -0
- package/media/icons/set-led_blue.svg +1 -0
- package/media/icons/set-led_coral.svg +1 -0
- package/media/icons/set-led_green.svg +1 -0
- package/media/icons/set-led_magenta.svg +1 -0
- package/media/icons/set-led_mystery.svg +1 -0
- package/media/icons/set-led_orange.svg +1 -0
- package/media/icons/set-led_purple.svg +1 -0
- package/media/icons/set-led_white.svg +1 -0
- package/media/icons/set-led_yellow.svg +1 -0
- package/media/icons/wedo_motor-clockwise.svg +1 -0
- package/media/icons/wedo_motor-counterclockwise.svg +1 -0
- package/media/icons/wedo_motor-speed_fast.svg +1 -0
- package/media/icons/wedo_motor-speed_med.svg +1 -0
- package/media/icons/wedo_motor-speed_slow.svg +1 -0
- package/media/icons/wedo_when-distance_close.svg +1 -0
- package/media/icons/wedo_when-tilt-backward.svg +1 -0
- package/media/icons/wedo_when-tilt-forward.svg +1 -0
- package/media/icons/wedo_when-tilt-left.svg +1 -0
- package/media/icons/wedo_when-tilt-right.svg +1 -0
- package/media/icons/wedo_when-tilt.svg +1 -0
- package/media/repeat.svg +18 -0
- package/media/rotate-left.svg +1 -0
- package/media/rotate-right.svg +1 -0
- package/media/sprites.png +0 -0
- package/media/status-not-ready.svg +13 -0
- package/media/status-ready.svg +13 -0
- package/media/zoom-in.svg +1 -0
- package/media/zoom-out.svg +1 -0
- package/media/zoom-reset.svg +1 -0
- package/msg/js/en.js +290 -0
- package/msg/json/en.json +285 -0
- package/msg/messages.js +359 -0
- package/msg/scratch_msgs.js +22969 -0
- package/package.json +60 -0
- package/pull_from_blockly.sh +151 -0
- package/renovate.json5 +15 -0
- package/shim/blockly_compressed_horizontal-blocks_compressed.js +1 -0
- package/shim/blockly_compressed_horizontal.Blockly.js +1 -0
- package/shim/blockly_compressed_horizontal.goog.js +1 -0
- package/shim/blockly_compressed_horizontal.js +1 -0
- package/shim/blockly_compressed_vertical-blocks_compressed.js +1 -0
- package/shim/blockly_compressed_vertical.Blockly.js +1 -0
- package/shim/blockly_compressed_vertical.goog.js +1 -0
- package/shim/blockly_compressed_vertical.js +1 -0
- package/shim/blocks_compressed_horizontal-blockly_compressed_horizontal-messages.js +1 -0
- package/shim/blocks_compressed_horizontal.js +1 -0
- package/shim/blocks_compressed_vertical-blockly_compressed_vertical-messages.js +1 -0
- package/shim/blocks_compressed_vertical.js +1 -0
- package/shim/gh-pages.js +1 -0
- package/shim/horizontal.js +1 -0
- package/shim/index.js +17 -0
- package/shim/vertical.js +1 -0
- package/universal-python.js +82 -0
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Visual Blocks Editor
|
|
4
|
+
*
|
|
5
|
+
* Copyright 2017 Google Inc.
|
|
6
|
+
* https://developers.google.com/blockly/
|
|
7
|
+
*
|
|
8
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
9
|
+
* you may not use this file except in compliance with the License.
|
|
10
|
+
* You may obtain a copy of the License at
|
|
11
|
+
*
|
|
12
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
13
|
+
*
|
|
14
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
15
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
16
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
17
|
+
* See the License for the specific language governing permissions and
|
|
18
|
+
* limitations under the License.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @fileoverview Class that controls updates to connections during drags.
|
|
23
|
+
* @author fenichel@google.com (Rachel Fenichel)
|
|
24
|
+
*/
|
|
25
|
+
'use strict';
|
|
26
|
+
|
|
27
|
+
goog.provide('Blockly.DraggedConnectionManager');
|
|
28
|
+
|
|
29
|
+
goog.require('Blockly.BlockAnimations');
|
|
30
|
+
goog.require('Blockly.RenderedConnection');
|
|
31
|
+
|
|
32
|
+
goog.require('goog.math.Coordinate');
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Class that controls updates to connections during drags. It is primarily
|
|
37
|
+
* responsible for finding the closest eligible connection and highlighting or
|
|
38
|
+
* unhiglighting it as needed during a drag.
|
|
39
|
+
* @param {!Blockly.BlockSvg} block The top block in the stack being dragged.
|
|
40
|
+
* @constructor
|
|
41
|
+
*/
|
|
42
|
+
Blockly.DraggedConnectionManager = function(block) {
|
|
43
|
+
Blockly.selected = block;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* The top block in the stack being dragged.
|
|
47
|
+
* Does not change during a drag.
|
|
48
|
+
* @type {!Blockly.Block}
|
|
49
|
+
* @private
|
|
50
|
+
*/
|
|
51
|
+
this.topBlock_ = block;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* The workspace on which these connections are being dragged.
|
|
55
|
+
* Does not change during a drag.
|
|
56
|
+
* @type {!Blockly.WorkspaceSvg}
|
|
57
|
+
* @private
|
|
58
|
+
*/
|
|
59
|
+
this.workspace_ = block.workspace;
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* The connections on the dragging blocks that are available to connect to
|
|
63
|
+
* other blocks. This includes all open connections on the top block, as well
|
|
64
|
+
* as the last connection on the block stack.
|
|
65
|
+
* Does not change during a drag.
|
|
66
|
+
* @type {!Array.<!Blockly.RenderedConnection>}
|
|
67
|
+
* @private
|
|
68
|
+
*/
|
|
69
|
+
this.availableConnections_ = this.initAvailableConnections_();
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* The connection that this block would connect to if released immediately.
|
|
73
|
+
* Updated on every mouse move.
|
|
74
|
+
* @type {Blockly.RenderedConnection}
|
|
75
|
+
* @private
|
|
76
|
+
*/
|
|
77
|
+
this.closestConnection_ = null;
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* The connection that would connect to this.closestConnection_ if this block
|
|
81
|
+
* were released immediately.
|
|
82
|
+
* Updated on every mouse move.
|
|
83
|
+
* @type {Blockly.RenderedConnection}
|
|
84
|
+
* @private
|
|
85
|
+
*/
|
|
86
|
+
this.localConnection_ = null;
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* The distance between this.closestConnection_ and this.localConnection_,
|
|
90
|
+
* in workspace units.
|
|
91
|
+
* Updated on every mouse move.
|
|
92
|
+
* @type {number}
|
|
93
|
+
* @private
|
|
94
|
+
*/
|
|
95
|
+
this.radiusConnection_ = 0;
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Whether the block would be deleted if it were dropped immediately.
|
|
99
|
+
* Updated on every mouse move.
|
|
100
|
+
* @type {boolean}
|
|
101
|
+
* @private
|
|
102
|
+
*/
|
|
103
|
+
this.wouldDeleteBlock_ = false;
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Sever all links from this object.
|
|
108
|
+
* @package
|
|
109
|
+
*/
|
|
110
|
+
Blockly.DraggedConnectionManager.prototype.dispose = function() {
|
|
111
|
+
this.topBlock_ = null;
|
|
112
|
+
this.workspace_ = null;
|
|
113
|
+
this.availableConnections_.length = 0;
|
|
114
|
+
this.closestConnection_ = null;
|
|
115
|
+
this.localConnection_ = null;
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Return whether the block would be deleted if dropped immediately, based on
|
|
120
|
+
* information from the most recent move event.
|
|
121
|
+
* @return {boolean} true if the block would be deleted if dropped immediately.
|
|
122
|
+
* @package
|
|
123
|
+
*/
|
|
124
|
+
Blockly.DraggedConnectionManager.prototype.wouldDeleteBlock = function() {
|
|
125
|
+
return this.wouldDeleteBlock_;
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Return whether the block would be connected if dropped immediately, based on
|
|
130
|
+
* information from the most recent move event.
|
|
131
|
+
* @return {boolean} true if the block would be connected if dropped immediately.
|
|
132
|
+
* @package
|
|
133
|
+
*/
|
|
134
|
+
Blockly.DraggedConnectionManager.prototype.wouldConnectBlock = function() {
|
|
135
|
+
return !!this.closestConnection_;
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Connect to the closest connection and render the results.
|
|
140
|
+
* This should be called at the end of a drag.
|
|
141
|
+
* @package
|
|
142
|
+
*/
|
|
143
|
+
Blockly.DraggedConnectionManager.prototype.applyConnections = function() {
|
|
144
|
+
if (this.closestConnection_) {
|
|
145
|
+
// Connect two blocks together.
|
|
146
|
+
this.localConnection_.connect(this.closestConnection_);
|
|
147
|
+
if (this.topBlock_.rendered) {
|
|
148
|
+
// Trigger a connection animation.
|
|
149
|
+
// Determine which connection is inferior (lower in the source stack).
|
|
150
|
+
var inferiorConnection = this.localConnection_.isSuperior() ?
|
|
151
|
+
this.closestConnection_ : this.localConnection_;
|
|
152
|
+
Blockly.BlockAnimations.connectionUiEffect(
|
|
153
|
+
inferiorConnection.getSourceBlock());
|
|
154
|
+
// Bring the just-edited stack to the front.
|
|
155
|
+
var rootBlock = this.topBlock_.getRootBlock();
|
|
156
|
+
rootBlock.bringToFront();
|
|
157
|
+
}
|
|
158
|
+
this.removeHighlighting_();
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Update highlighted connections based on the most recent move location.
|
|
164
|
+
* @param {!goog.math.Coordinate} dxy Position relative to drag start,
|
|
165
|
+
* in workspace units.
|
|
166
|
+
* @param {?number} deleteArea One of {@link Blockly.DELETE_AREA_TRASH},
|
|
167
|
+
* {@link Blockly.DELETE_AREA_TOOLBOX}, or {@link Blockly.DELETE_AREA_NONE}.
|
|
168
|
+
* @param {?boolean} isOutside True if the drag is going outside the blocks workspace
|
|
169
|
+
* @package
|
|
170
|
+
*/
|
|
171
|
+
Blockly.DraggedConnectionManager.prototype.update = function(dxy, deleteArea, isOutside) {
|
|
172
|
+
var oldClosestConnection;
|
|
173
|
+
var closestConnectionChanged;
|
|
174
|
+
// If dragged outside, don't connect, since the connections aren't visible.
|
|
175
|
+
if (!isOutside) {
|
|
176
|
+
oldClosestConnection = this.closestConnection_;
|
|
177
|
+
closestConnectionChanged = this.updateClosest_(dxy);
|
|
178
|
+
if (closestConnectionChanged && oldClosestConnection) {
|
|
179
|
+
oldClosestConnection.unhighlight();
|
|
180
|
+
}
|
|
181
|
+
} else if (this.closestConnection_) {
|
|
182
|
+
this.closestConnection_.unhighlight();
|
|
183
|
+
this.closestConnection_ = null;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
// Prefer connecting over dropping into the trash can, but prefer dragging to
|
|
187
|
+
// the toolbox over connecting to other blocks.
|
|
188
|
+
var wouldConnect = !!this.closestConnection_ &&
|
|
189
|
+
deleteArea != Blockly.DELETE_AREA_TOOLBOX;
|
|
190
|
+
var wouldDelete = !!deleteArea && !this.topBlock_.getParent() &&
|
|
191
|
+
this.topBlock_.isDeletable();
|
|
192
|
+
this.wouldDeleteBlock_ = wouldDelete && !wouldConnect;
|
|
193
|
+
|
|
194
|
+
if (!this.wouldDeleteBlock_ && closestConnectionChanged &&
|
|
195
|
+
this.closestConnection_) {
|
|
196
|
+
this.addHighlighting_();
|
|
197
|
+
}
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Remove highlighting from the currently highlighted connection, if it exists.
|
|
202
|
+
* @private
|
|
203
|
+
*/
|
|
204
|
+
Blockly.DraggedConnectionManager.prototype.removeHighlighting_ = function() {
|
|
205
|
+
if (this.closestConnection_) {
|
|
206
|
+
this.closestConnection_.unhighlight();
|
|
207
|
+
}
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Add highlighting to the closest connection, if it exists.
|
|
212
|
+
* @private
|
|
213
|
+
*/
|
|
214
|
+
Blockly.DraggedConnectionManager.prototype.addHighlighting_ = function() {
|
|
215
|
+
if (this.closestConnection_) {
|
|
216
|
+
this.closestConnection_.highlight();
|
|
217
|
+
}
|
|
218
|
+
};
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Populate the list of available connections on this block stack. This should
|
|
222
|
+
* only be called once, at the beginning of a drag.
|
|
223
|
+
* @return {!Array.<!Blockly.RenderedConnection>} a list of available
|
|
224
|
+
* connections.
|
|
225
|
+
* @private
|
|
226
|
+
*/
|
|
227
|
+
Blockly.DraggedConnectionManager.prototype.initAvailableConnections_ = function() {
|
|
228
|
+
var available = this.topBlock_.getConnections_(false);
|
|
229
|
+
// Also check the last connection on this stack
|
|
230
|
+
var lastOnStack = this.topBlock_.lastConnectionInStack();
|
|
231
|
+
if (lastOnStack && lastOnStack != this.topBlock_.nextConnection) {
|
|
232
|
+
available.push(lastOnStack);
|
|
233
|
+
}
|
|
234
|
+
return available;
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* Find the new closest connection, and update internal state in response.
|
|
239
|
+
* @param {!goog.math.Coordinate} dxy Position relative to the drag start,
|
|
240
|
+
* in workspace units.
|
|
241
|
+
* @return {boolean} Whether the closest connection has changed.
|
|
242
|
+
* @private
|
|
243
|
+
*/
|
|
244
|
+
Blockly.DraggedConnectionManager.prototype.updateClosest_ = function(dxy) {
|
|
245
|
+
var oldClosestConnection = this.closestConnection_;
|
|
246
|
+
|
|
247
|
+
this.closestConnection_ = null;
|
|
248
|
+
this.localConnection_ = null;
|
|
249
|
+
this.radiusConnection_ = Blockly.SNAP_RADIUS;
|
|
250
|
+
for (var i = 0; i < this.availableConnections_.length; i++) {
|
|
251
|
+
var myConnection = this.availableConnections_[i];
|
|
252
|
+
var neighbour = myConnection.closest(this.radiusConnection_, dxy);
|
|
253
|
+
if (neighbour.connection) {
|
|
254
|
+
this.closestConnection_ = neighbour.connection;
|
|
255
|
+
this.localConnection_ = myConnection;
|
|
256
|
+
this.radiusConnection_ = neighbour.radius;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
return oldClosestConnection != this.closestConnection_;
|
|
260
|
+
};
|
|
@@ -0,0 +1,408 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Visual Blocks Editor
|
|
4
|
+
*
|
|
5
|
+
* Copyright 2016 Massachusetts Institute of Technology
|
|
6
|
+
* All rights reserved.
|
|
7
|
+
*
|
|
8
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
9
|
+
* you may not use this file except in compliance with the License.
|
|
10
|
+
* You may obtain a copy of the License at
|
|
11
|
+
*
|
|
12
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
13
|
+
*
|
|
14
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
15
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
16
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
17
|
+
* See the License for the specific language governing permissions and
|
|
18
|
+
* limitations under the License.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @fileoverview A div that floats on top of the workspace, for drop-down menus.
|
|
23
|
+
* The drop-down can be kept inside the workspace, animate in/out, etc.
|
|
24
|
+
* @author tmickel@mit.edu (Tim Mickel)
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
'use strict';
|
|
28
|
+
|
|
29
|
+
goog.provide('Blockly.DropDownDiv');
|
|
30
|
+
|
|
31
|
+
goog.require('goog.dom');
|
|
32
|
+
goog.require('goog.style');
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Class for drop-down div.
|
|
36
|
+
* @constructor
|
|
37
|
+
*/
|
|
38
|
+
Blockly.DropDownDiv = function() {
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* The div element. Set once by Blockly.DropDownDiv.createDom.
|
|
43
|
+
* @type {Element}
|
|
44
|
+
* @private
|
|
45
|
+
*/
|
|
46
|
+
Blockly.DropDownDiv.DIV_ = null;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Drop-downs will appear within the bounds of this element if possible.
|
|
50
|
+
* Set in Blockly.DropDownDiv.setBoundsElement.
|
|
51
|
+
* @type {Element}
|
|
52
|
+
* @private
|
|
53
|
+
*/
|
|
54
|
+
Blockly.DropDownDiv.boundsElement_ = null;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* The object currently using the drop-down.
|
|
58
|
+
* @type {Object}
|
|
59
|
+
* @private
|
|
60
|
+
*/
|
|
61
|
+
Blockly.DropDownDiv.owner_ = null;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Arrow size in px. Should match the value in CSS (need to position pre-render).
|
|
65
|
+
* @type {number}
|
|
66
|
+
* @const
|
|
67
|
+
*/
|
|
68
|
+
Blockly.DropDownDiv.ARROW_SIZE = 16;
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Drop-down border size in px. Should match the value in CSS (need to position the arrow).
|
|
72
|
+
* @type {number}
|
|
73
|
+
* @const
|
|
74
|
+
*/
|
|
75
|
+
Blockly.DropDownDiv.BORDER_SIZE = 1;
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Amount the arrow must be kept away from the edges of the main drop-down div, in px.
|
|
79
|
+
* @type {number}
|
|
80
|
+
* @const
|
|
81
|
+
*/
|
|
82
|
+
Blockly.DropDownDiv.ARROW_HORIZONTAL_PADDING = 12;
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Amount drop-downs should be padded away from the source, in px.
|
|
86
|
+
* @type {number}
|
|
87
|
+
* @const
|
|
88
|
+
*/
|
|
89
|
+
Blockly.DropDownDiv.PADDING_Y = 20;
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Length of animations in seconds.
|
|
93
|
+
* @type {number}
|
|
94
|
+
* @const
|
|
95
|
+
*/
|
|
96
|
+
Blockly.DropDownDiv.ANIMATION_TIME = 0.25;
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Timer for animation out, to be cleared if we need to immediately hide
|
|
100
|
+
* without disrupting new shows.
|
|
101
|
+
* @type {number}
|
|
102
|
+
*/
|
|
103
|
+
Blockly.DropDownDiv.animateOutTimer_ = null;
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Callback for when the drop-down is hidden.
|
|
107
|
+
* @type {Function}
|
|
108
|
+
*/
|
|
109
|
+
Blockly.DropDownDiv.onHide_ = 0;
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Create and insert the DOM element for this div.
|
|
113
|
+
* @param {Element} container Element that the div should be contained in.
|
|
114
|
+
*/
|
|
115
|
+
Blockly.DropDownDiv.createDom = function() {
|
|
116
|
+
if (Blockly.DropDownDiv.DIV_) {
|
|
117
|
+
return; // Already created.
|
|
118
|
+
}
|
|
119
|
+
Blockly.DropDownDiv.DIV_ = goog.dom.createDom('div', 'blocklyDropDownDiv');
|
|
120
|
+
document.body.appendChild(Blockly.DropDownDiv.DIV_);
|
|
121
|
+
Blockly.DropDownDiv.content_ = goog.dom.createDom('div', 'blocklyDropDownContent');
|
|
122
|
+
Blockly.DropDownDiv.DIV_.appendChild(Blockly.DropDownDiv.content_);
|
|
123
|
+
Blockly.DropDownDiv.arrow_ = goog.dom.createDom('div', 'blocklyDropDownArrow');
|
|
124
|
+
Blockly.DropDownDiv.DIV_.appendChild(Blockly.DropDownDiv.arrow_);
|
|
125
|
+
|
|
126
|
+
// Transition animation for transform: translate() and opacity.
|
|
127
|
+
Blockly.DropDownDiv.DIV_.style.transition = 'transform ' +
|
|
128
|
+
Blockly.DropDownDiv.ANIMATION_TIME + 's, ' +
|
|
129
|
+
'opacity ' + Blockly.DropDownDiv.ANIMATION_TIME + 's';
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Set an element to maintain bounds within. Drop-downs will appear
|
|
134
|
+
* within the box of this element if possible.
|
|
135
|
+
* @param {Element} boundsElement Element to bound drop-down to.
|
|
136
|
+
*/
|
|
137
|
+
Blockly.DropDownDiv.setBoundsElement = function(boundsElement) {
|
|
138
|
+
Blockly.DropDownDiv.boundsElement_ = boundsElement;
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Provide the div for inserting content into the drop-down.
|
|
143
|
+
* @return {Element} Div to populate with content
|
|
144
|
+
*/
|
|
145
|
+
Blockly.DropDownDiv.getContentDiv = function() {
|
|
146
|
+
return Blockly.DropDownDiv.content_;
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Clear the content of the drop-down.
|
|
151
|
+
*/
|
|
152
|
+
Blockly.DropDownDiv.clearContent = function() {
|
|
153
|
+
Blockly.DropDownDiv.content_.innerHTML = '';
|
|
154
|
+
Blockly.DropDownDiv.content_.style.width = '';
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Set the colour for the drop-down.
|
|
159
|
+
* @param {string} backgroundColour Any CSS color for the background
|
|
160
|
+
* @param {string} borderColour Any CSS color for the border
|
|
161
|
+
*/
|
|
162
|
+
Blockly.DropDownDiv.setColour = function(backgroundColour, borderColour) {
|
|
163
|
+
Blockly.DropDownDiv.DIV_.style.backgroundColor = backgroundColour;
|
|
164
|
+
Blockly.DropDownDiv.DIV_.style.borderColor = borderColour;
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Set the category for the drop-down.
|
|
169
|
+
* @param {string} category The new category for the drop-down.
|
|
170
|
+
*/
|
|
171
|
+
Blockly.DropDownDiv.setCategory = function(category) {
|
|
172
|
+
Blockly.DropDownDiv.DIV_.setAttribute('data-category', category);
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Shortcut to show and place the drop-down with positioning determined
|
|
177
|
+
* by a particular block. The primary position will be below the block,
|
|
178
|
+
* and the secondary position above the block. Drop-down will be
|
|
179
|
+
* constrained to the block's workspace.
|
|
180
|
+
* @param {Object} owner The object showing the drop-down
|
|
181
|
+
* @param {!Blockly.Block} block Block to position the drop-down around.
|
|
182
|
+
* @param {Function=} opt_onHide Optional callback for when the drop-down is hidden.
|
|
183
|
+
* @param {Number} opt_secondaryYOffset Optional Y offset for above-block positioning.
|
|
184
|
+
* @return {boolean} True if the menu rendered below block; false if above.
|
|
185
|
+
*/
|
|
186
|
+
Blockly.DropDownDiv.showPositionedByBlock = function(owner, block,
|
|
187
|
+
opt_onHide, opt_secondaryYOffset) {
|
|
188
|
+
var scale = block.workspace.scale;
|
|
189
|
+
var bBox = {width: block.width, height: block.height};
|
|
190
|
+
bBox.width *= scale;
|
|
191
|
+
bBox.height *= scale;
|
|
192
|
+
var position = block.getSvgRoot().getBoundingClientRect();
|
|
193
|
+
// If we can fit it, render below the block.
|
|
194
|
+
var primaryX = position.left + bBox.width / 2;
|
|
195
|
+
var primaryY = position.top + bBox.height;
|
|
196
|
+
// If we can't fit it, render above the entire parent block.
|
|
197
|
+
var secondaryX = primaryX;
|
|
198
|
+
var secondaryY = position.top;
|
|
199
|
+
if (opt_secondaryYOffset) {
|
|
200
|
+
secondaryY += opt_secondaryYOffset;
|
|
201
|
+
}
|
|
202
|
+
// Set bounds to workspace; show the drop-down.
|
|
203
|
+
Blockly.DropDownDiv.setBoundsElement(block.workspace.getParentSvg().parentNode);
|
|
204
|
+
return Blockly.DropDownDiv.show(this, primaryX, primaryY, secondaryX, secondaryY, opt_onHide);
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Show and place the drop-down.
|
|
209
|
+
* The drop-down is placed with an absolute "origin point" (x, y) - i.e.,
|
|
210
|
+
* the arrow will point at this origin and box will positioned below or above it.
|
|
211
|
+
* If we can maintain the container bounds at the primary point, the arrow will
|
|
212
|
+
* point there, and the container will be positioned below it.
|
|
213
|
+
* If we can't maintain the container bounds at the primary point, fall-back to the
|
|
214
|
+
* secondary point and position above.
|
|
215
|
+
* @param {Object} owner The object showing the drop-down
|
|
216
|
+
* @param {number} primaryX Desired origin point x, in absolute px
|
|
217
|
+
* @param {number} primaryY Desired origin point y, in absolute px
|
|
218
|
+
* @param {number} secondaryX Secondary/alternative origin point x, in absolute px
|
|
219
|
+
* @param {number} secondaryY Secondary/alternative origin point y, in absolute px
|
|
220
|
+
* @param {Function=} opt_onHide Optional callback for when the drop-down is hidden
|
|
221
|
+
* @return {boolean} True if the menu rendered at the primary origin point.
|
|
222
|
+
*/
|
|
223
|
+
Blockly.DropDownDiv.show = function(owner, primaryX, primaryY, secondaryX, secondaryY, opt_onHide) {
|
|
224
|
+
Blockly.DropDownDiv.owner_ = owner;
|
|
225
|
+
Blockly.DropDownDiv.onHide_ = opt_onHide;
|
|
226
|
+
var div = Blockly.DropDownDiv.DIV_;
|
|
227
|
+
var metrics = Blockly.DropDownDiv.getPositionMetrics(primaryX, primaryY, secondaryX, secondaryY);
|
|
228
|
+
// Update arrow CSS
|
|
229
|
+
Blockly.DropDownDiv.arrow_.style.transform = 'translate(' +
|
|
230
|
+
metrics.arrowX + 'px,' + metrics.arrowY + 'px) rotate(45deg)';
|
|
231
|
+
Blockly.DropDownDiv.arrow_.setAttribute('class',
|
|
232
|
+
metrics.arrowAtTop ? 'blocklyDropDownArrow arrowTop' : 'blocklyDropDownArrow arrowBottom');
|
|
233
|
+
// Set direction based on owner's rtl
|
|
234
|
+
div.style.direction = owner.sourceBlock_ && owner.sourceBlock_.RTL ? 'rtl' : 'ltr';
|
|
235
|
+
|
|
236
|
+
// When we change `translate` multiple times in close succession,
|
|
237
|
+
// Chrome may choose to wait and apply them all at once.
|
|
238
|
+
// Since we want the translation to initial X, Y to be immediate,
|
|
239
|
+
// and the translation to final X, Y to be animated,
|
|
240
|
+
// we saw problems where both would be applied after animation was turned on,
|
|
241
|
+
// making the dropdown appear to fly in from (0, 0).
|
|
242
|
+
// Using both `left`, `top` for the initial translation and then `translate`
|
|
243
|
+
// for the animated transition to final X, Y is a workaround.
|
|
244
|
+
|
|
245
|
+
// First apply initial translation.
|
|
246
|
+
div.style.left = metrics.initialX + 'px';
|
|
247
|
+
div.style.top = metrics.initialY + 'px';
|
|
248
|
+
// Show the div.
|
|
249
|
+
div.style.display = 'block';
|
|
250
|
+
div.style.opacity = 1;
|
|
251
|
+
// Add final translate, animated through `transition`.
|
|
252
|
+
// Coordinates are relative to (initialX, initialY),
|
|
253
|
+
// where the drop-down is absolutely positioned.
|
|
254
|
+
var dx = (metrics.finalX - metrics.initialX);
|
|
255
|
+
var dy = (metrics.finalY - metrics.initialY);
|
|
256
|
+
div.style.transform = 'translate(' + dx + 'px,' + dy + 'px)';
|
|
257
|
+
return metrics.arrowAtTop;
|
|
258
|
+
};
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* Helper to position the drop-down and the arrow, maintaining bounds.
|
|
262
|
+
* See explanation of origin points in Blockly.DropDownDiv.show.
|
|
263
|
+
* @param {number} primaryX Desired origin point x, in absolute px
|
|
264
|
+
* @param {number} primaryY Desired origin point y, in absolute px
|
|
265
|
+
* @param {number} secondaryX Secondary/alternative origin point x, in absolute px
|
|
266
|
+
* @param {number} secondaryY Secondary/alternative origin point y, in absolute px
|
|
267
|
+
* @returns {Object} Various final metrics, including rendered positions for drop-down and arrow.
|
|
268
|
+
*/
|
|
269
|
+
Blockly.DropDownDiv.getPositionMetrics = function(primaryX, primaryY, secondaryX, secondaryY) {
|
|
270
|
+
var div = Blockly.DropDownDiv.DIV_;
|
|
271
|
+
var boundPosition = Blockly.DropDownDiv.boundsElement_.getBoundingClientRect();
|
|
272
|
+
|
|
273
|
+
var boundSize = goog.style.getSize(Blockly.DropDownDiv.boundsElement_);
|
|
274
|
+
var divSize = goog.style.getSize(div);
|
|
275
|
+
|
|
276
|
+
// First decide if we will render at primary or secondary position
|
|
277
|
+
// i.e., above or below
|
|
278
|
+
// renderX, renderY will eventually be the final rendered position of the box.
|
|
279
|
+
var renderX, renderY, renderedSecondary;
|
|
280
|
+
// Can the div fit inside the bounds if we render below the primary point?
|
|
281
|
+
if (primaryY + divSize.height > boundPosition.top + boundSize.height) {
|
|
282
|
+
// We can't fit below in terms of y. Can we fit above?
|
|
283
|
+
if (secondaryY - divSize.height < boundPosition.top) {
|
|
284
|
+
// We also can't fit above, so just render below anyway.
|
|
285
|
+
renderX = primaryX;
|
|
286
|
+
renderY = primaryY + Blockly.DropDownDiv.PADDING_Y;
|
|
287
|
+
renderedSecondary = false;
|
|
288
|
+
} else {
|
|
289
|
+
// We can fit above, render secondary
|
|
290
|
+
renderX = secondaryX;
|
|
291
|
+
renderY = secondaryY - divSize.height - Blockly.DropDownDiv.PADDING_Y;
|
|
292
|
+
renderedSecondary = true;
|
|
293
|
+
}
|
|
294
|
+
} else {
|
|
295
|
+
// We can fit below, render primary
|
|
296
|
+
renderX = primaryX;
|
|
297
|
+
renderY = primaryY + Blockly.DropDownDiv.PADDING_Y;
|
|
298
|
+
renderedSecondary = false;
|
|
299
|
+
}
|
|
300
|
+
// First calculate the absolute arrow X
|
|
301
|
+
// This needs to be done before positioning the div, since the arrow
|
|
302
|
+
// wants to be as close to the origin point as possible.
|
|
303
|
+
var arrowX = renderX - Blockly.DropDownDiv.ARROW_SIZE / 2;
|
|
304
|
+
// Keep in overall bounds
|
|
305
|
+
arrowX = Math.max(boundPosition.left, Math.min(arrowX, boundPosition.left + boundSize.width));
|
|
306
|
+
|
|
307
|
+
// Adjust the x-position of the drop-down so that the div is centered and within bounds.
|
|
308
|
+
var centerX = divSize.width / 2;
|
|
309
|
+
renderX -= centerX;
|
|
310
|
+
// Fit horizontally in the bounds.
|
|
311
|
+
renderX = Math.max(
|
|
312
|
+
boundPosition.left,
|
|
313
|
+
Math.min(renderX, boundPosition.left + boundSize.width - divSize.width)
|
|
314
|
+
);
|
|
315
|
+
// After we've finished caclulating renderX, adjust the arrow to be relative to it.
|
|
316
|
+
arrowX -= renderX;
|
|
317
|
+
|
|
318
|
+
// Pad the arrow by some pixels, primarily so that it doesn't render on top of a rounded border.
|
|
319
|
+
arrowX = Math.max(
|
|
320
|
+
Blockly.DropDownDiv.ARROW_HORIZONTAL_PADDING,
|
|
321
|
+
Math.min(arrowX, divSize.width - Blockly.DropDownDiv.ARROW_HORIZONTAL_PADDING - Blockly.DropDownDiv.ARROW_SIZE)
|
|
322
|
+
);
|
|
323
|
+
|
|
324
|
+
// Calculate arrow Y. If we rendered secondary, add on bottom.
|
|
325
|
+
// Extra pixels are added so that it covers the border of the div.
|
|
326
|
+
var arrowY = (renderedSecondary) ? divSize.height - Blockly.DropDownDiv.BORDER_SIZE : 0;
|
|
327
|
+
arrowY -= (Blockly.DropDownDiv.ARROW_SIZE / 2) + Blockly.DropDownDiv.BORDER_SIZE;
|
|
328
|
+
|
|
329
|
+
// Initial position calculated without any padding to provide an animation point.
|
|
330
|
+
var initialX = renderX; // X position remains constant during animation.
|
|
331
|
+
var initialY;
|
|
332
|
+
if (renderedSecondary) {
|
|
333
|
+
initialY = secondaryY - divSize.height; // No padding on Y
|
|
334
|
+
} else {
|
|
335
|
+
initialY = primaryY; // No padding on Y
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
return {
|
|
339
|
+
initialX: initialX,
|
|
340
|
+
initialY : initialY,
|
|
341
|
+
finalX: renderX,
|
|
342
|
+
finalY: renderY,
|
|
343
|
+
arrowX: arrowX,
|
|
344
|
+
arrowY: arrowY,
|
|
345
|
+
arrowAtTop: !renderedSecondary
|
|
346
|
+
};
|
|
347
|
+
};
|
|
348
|
+
|
|
349
|
+
/**
|
|
350
|
+
* Is the container visible?
|
|
351
|
+
* @return {boolean} True if visible.
|
|
352
|
+
*/
|
|
353
|
+
Blockly.DropDownDiv.isVisible = function() {
|
|
354
|
+
return !!Blockly.DropDownDiv.owner_;
|
|
355
|
+
};
|
|
356
|
+
|
|
357
|
+
/**
|
|
358
|
+
* Hide the menu only if it is owned by the provided object.
|
|
359
|
+
* @param {Object} owner Object which must be owning the drop-down to hide
|
|
360
|
+
* @return {Boolean} True if hidden
|
|
361
|
+
*/
|
|
362
|
+
Blockly.DropDownDiv.hideIfOwner = function(owner) {
|
|
363
|
+
if (Blockly.DropDownDiv.owner_ === owner) {
|
|
364
|
+
Blockly.DropDownDiv.hide();
|
|
365
|
+
return true;
|
|
366
|
+
}
|
|
367
|
+
return false;
|
|
368
|
+
};
|
|
369
|
+
|
|
370
|
+
/**
|
|
371
|
+
* Hide the menu, triggering animation.
|
|
372
|
+
*/
|
|
373
|
+
Blockly.DropDownDiv.hide = function() {
|
|
374
|
+
// Start the animation by setting the translation and fading out.
|
|
375
|
+
var div = Blockly.DropDownDiv.DIV_;
|
|
376
|
+
// Reset to (initialX, initialY) - i.e., no translation.
|
|
377
|
+
div.style.transform = 'translate(0px, 0px)';
|
|
378
|
+
div.style.opacity = 0;
|
|
379
|
+
Blockly.DropDownDiv.animateOutTimer_ = setTimeout(function() {
|
|
380
|
+
// Finish animation - reset all values to default.
|
|
381
|
+
Blockly.DropDownDiv.hideWithoutAnimation();
|
|
382
|
+
}, Blockly.DropDownDiv.ANIMATION_TIME * 1000);
|
|
383
|
+
if (Blockly.DropDownDiv.onHide_) {
|
|
384
|
+
Blockly.DropDownDiv.onHide_();
|
|
385
|
+
Blockly.DropDownDiv.onHide_ = null;
|
|
386
|
+
}
|
|
387
|
+
};
|
|
388
|
+
|
|
389
|
+
/**
|
|
390
|
+
* Hide the menu, without animation.
|
|
391
|
+
*/
|
|
392
|
+
Blockly.DropDownDiv.hideWithoutAnimation = function() {
|
|
393
|
+
if (!Blockly.DropDownDiv.isVisible()) {
|
|
394
|
+
return;
|
|
395
|
+
}
|
|
396
|
+
var div = Blockly.DropDownDiv.DIV_;
|
|
397
|
+
Blockly.DropDownDiv.animateOutTimer_ && window.clearTimeout(Blockly.DropDownDiv.animateOutTimer_);
|
|
398
|
+
div.style.transform = '';
|
|
399
|
+
div.style.top = '';
|
|
400
|
+
div.style.left = '';
|
|
401
|
+
div.style.display = 'none';
|
|
402
|
+
Blockly.DropDownDiv.clearContent();
|
|
403
|
+
Blockly.DropDownDiv.owner_ = null;
|
|
404
|
+
if (Blockly.DropDownDiv.onHide_) {
|
|
405
|
+
Blockly.DropDownDiv.onHide_();
|
|
406
|
+
Blockly.DropDownDiv.onHide_ = null;
|
|
407
|
+
}
|
|
408
|
+
};
|