Skip to content

Commit b5822e2

Browse files
Revert "Revert "Rebuild nov 3 16""
This reverts commit c8ca24a.
1 parent d04d828 commit b5822e2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

118 files changed

+1335
-649
lines changed

blockly_compressed.js

+174-152
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

blockly_uncompressed.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

blocks/logic.js

+36
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,42 @@ Blockly.Blocks['controls_if_else'] = {
265265
}
266266
};
267267

268+
Blockly.Blocks['controls_ifelse'] = {
269+
/**
270+
* If/else block that does not use a mutator.
271+
*/
272+
init: function() {
273+
this.jsonInit({
274+
"message0": Blockly.Msg.CONTROLS_IFELSE_TITLE,
275+
"args0": [
276+
{
277+
"type": "input_value",
278+
"name": "IF0",
279+
"check": "Boolean",
280+
"align": "RIGHT"
281+
},
282+
{
283+
"type": "input_statement",
284+
"name": "DO0",
285+
"check": "Boolean",
286+
"align": "RIGHT"
287+
},
288+
{
289+
"type": "input_statement",
290+
"name": "ELSE",
291+
"check": "Boolean",
292+
"align": "RIGHT"
293+
}
294+
],
295+
"previousStatement": null,
296+
"nextStatement": null,
297+
"colour": Blockly.Blocks.logic.HUE,
298+
"tooltip": Blockly.Msg.CONTROLS_IF_TOOLTIP_2,
299+
"helpUrl": Blockly.Msg.CONTROLS_IF_HELPURL
300+
});
301+
}
302+
};
303+
268304
Blockly.Blocks['logic_compare'] = {
269305
/**
270306
* Block for comparison operator.

blocks/loops.js

+9
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,9 @@ Blockly.Blocks['controls_flow_statements'] = {
257257
* @this Blockly.Block
258258
*/
259259
onchange: function(e) {
260+
if (this.workspace.isDragging()) {
261+
return; // Don't change state at the start of a drag.
262+
}
260263
var legal = false;
261264
// Is the block nested in a loop?
262265
var block = this;
@@ -269,8 +272,14 @@ Blockly.Blocks['controls_flow_statements'] = {
269272
} while (block);
270273
if (legal) {
271274
this.setWarningText(null);
275+
if (!this.isInFlyout) {
276+
this.setDisabled(false);
277+
}
272278
} else {
273279
this.setWarningText(Blockly.Msg.CONTROLS_FLOW_STATEMENTS_WARNING);
280+
if (!this.isInFlyout && !this.getInheritedDisabled()) {
281+
this.setDisabled(true);
282+
}
274283
}
275284
},
276285
/**

blocks/procedures.js

+9
Original file line numberDiff line numberDiff line change
@@ -843,6 +843,9 @@ Blockly.Blocks['procedures_ifreturn'] = {
843843
* @this Blockly.Block
844844
*/
845845
onchange: function(e) {
846+
if (this.workspace.isDragging()) {
847+
return; // Don't change state at the start of a drag.
848+
}
846849
var legal = false;
847850
// Is the block nested in a procedure?
848851
var block = this;
@@ -868,8 +871,14 @@ Blockly.Blocks['procedures_ifreturn'] = {
868871
this.hasReturnValue_ = true;
869872
}
870873
this.setWarningText(null);
874+
if (!this.isInFlyout) {
875+
this.setDisabled(false);
876+
}
871877
} else {
872878
this.setWarningText(Blockly.Msg.PROCEDURES_IFRETURN_WARNING);
879+
if (!this.isInFlyout && !this.getInheritedDisabled()) {
880+
this.setDisabled(true);
881+
}
873882
}
874883
},
875884
/**

blocks_compressed.js

+11-8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

core/block_svg.js

+23-23
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ Blockly.BlockSvg.prototype.initSvg = function() {
130130
Blockly.bindEventWithChecks_(this.getSvgRoot(), 'mousedown', this,
131131
this.onMouseDown_);
132132
var thisBlock = this;
133-
Blockly.bindEventWithChecks_(this.getSvgRoot(), 'touchstart', null,
133+
Blockly.bindEvent_(this.getSvgRoot(), 'touchstart', null,
134134
function(e) {Blockly.longStart_(e, thisBlock);});
135135
}
136136
this.eventsInit_ = true;
@@ -264,7 +264,8 @@ Blockly.BlockSvg.terminateDrag = function() {
264264
delete selected.draggedBubbles_;
265265
selected.setDragging_(false);
266266
selected.render();
267-
// Ensure that any stap and bump are part of this move's event group.
267+
selected.workspace.setResizesEnabled(true);
268+
// Ensure that any snap and bump are part of this move's event group.
268269
var group = Blockly.Events.getGroup();
269270
setTimeout(function() {
270271
Blockly.Events.setGroup(group);
@@ -276,8 +277,6 @@ Blockly.BlockSvg.terminateDrag = function() {
276277
selected.bumpNeighbours_();
277278
Blockly.Events.setGroup(false);
278279
}, Blockly.BUMP_DELAY);
279-
// Fire an event to allow scrollbars to resize.
280-
selected.workspace.resizeContents();
281280
}
282281
}
283282
Blockly.dragMode_ = Blockly.DRAG_NONE;
@@ -830,12 +829,14 @@ Blockly.BlockSvg.prototype.setDragging_ = function(adding) {
830829
var group = this.getSvgRoot();
831830
group.translate_ = '';
832831
group.skew_ = '';
833-
this.addDragging();
834832
Blockly.draggingConnections_ =
835833
Blockly.draggingConnections_.concat(this.getConnections_(true));
834+
Blockly.addClass_(/** @type {!Element} */ (this.svgGroup_),
835+
'blocklyDragging');
836836
} else {
837-
this.removeDragging();
838837
Blockly.draggingConnections_ = [];
838+
Blockly.removeClass_(/** @type {!Element} */ (this.svgGroup_),
839+
'blocklyDragging');
839840
}
840841
// Recurse through all blocks attached under this one.
841842
for (var i = 0; i < this.childBlocks_.length; i++) {
@@ -870,6 +871,7 @@ Blockly.BlockSvg.prototype.onMouseMove_ = function(e) {
870871
// Switch to unrestricted dragging.
871872
Blockly.dragMode_ = Blockly.DRAG_FREE;
872873
Blockly.longStop_();
874+
this.workspace.setResizesEnabled(false);
873875
if (this.parentBlock_) {
874876
// Push this block to the very top of the stack.
875877
this.unplug();
@@ -1430,6 +1432,21 @@ Blockly.BlockSvg.prototype.setDisabled = function(disabled) {
14301432
}
14311433
};
14321434

1435+
/**
1436+
* Set whether the block is highlighted or not.
1437+
* @param {boolean} highlighted True if highlighted.
1438+
*/
1439+
Blockly.BlockSvg.prototype.setHighlighted = function(highlighted) {
1440+
if (highlighted) {
1441+
this.svgPath_.setAttribute('filter',
1442+
'url(#' + this.workspace.options.embossFilterId + ')');
1443+
this.svgPathLight_.style.display = 'none';
1444+
} else {
1445+
this.svgPath_.removeAttribute('filter');
1446+
this.svgPathLight_.style.display = 'block';
1447+
}
1448+
};
1449+
14331450
/**
14341451
* Select this block. Highlight it visually.
14351452
*/
@@ -1453,23 +1470,6 @@ Blockly.BlockSvg.prototype.removeSelect = function() {
14531470
'blocklySelected');
14541471
};
14551472

1456-
/**
1457-
* Adds the dragging class to this block.
1458-
* Also disables the highlights/shadows to improve performance.
1459-
*/
1460-
Blockly.BlockSvg.prototype.addDragging = function() {
1461-
Blockly.addClass_(/** @type {!Element} */ (this.svgGroup_),
1462-
'blocklyDragging');
1463-
};
1464-
1465-
/**
1466-
* Removes the dragging class from this block.
1467-
*/
1468-
Blockly.BlockSvg.prototype.removeDragging = function() {
1469-
Blockly.removeClass_(/** @type {!Element} */ (this.svgGroup_),
1470-
'blocklyDragging');
1471-
};
1472-
14731473
// Overrides of functions on Blockly.Block that take into account whether the
14741474
// block has been rendered.
14751475

core/blockly.js

+22-3
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,28 @@ Blockly.clipboardSource_ = null;
117117
*/
118118
Blockly.dragMode_ = Blockly.DRAG_NONE;
119119

120+
/**
121+
* Map from function names to callbacks, for deciding what to do when a button
122+
* is clicked.
123+
* @type {!Object<string, function(!Blockly.FlyoutButton)>}
124+
*/
125+
Blockly.flyoutButtonCallbacks_ = {};
126+
127+
/**
128+
* Register a callback function associated with a given key, for clicks on
129+
* buttons and labels in the flyout.
130+
* For instance, a button specified by the XML
131+
* <button text="create variable" callbackKey="CREATE_VARIABLE"></button>
132+
* should be matched by a call to
133+
* registerButtonCallback("CREATE_VARIABLE", yourCallbackFunction).
134+
* @param {string} key The name to use to look up this function.
135+
* @param {function(!Blockly.FlyoutButton)} func The function to call when the
136+
* given button is clicked.
137+
*/
138+
Blockly.registerButtonCallback = function(key, func) {
139+
Blockly.flyoutButtonCallbacks_[key] = func;
140+
};
141+
120142
/**
121143
* Convert a hue (HSV model) into an RGB hex triplet.
122144
* @param {number} hue Hue on a colour wheel (0-360).
@@ -341,7 +363,6 @@ Blockly.getMainWorkspace = function() {
341363
return Blockly.mainWorkspace;
342364
};
343365

344-
<<<<<<< HEAD
345366
/**
346367
* Wrapper to window.alert() that app developers may override to
347368
* provide alternatives to the modal browser window.
@@ -405,8 +426,6 @@ Blockly.defineBlocksWithJsonArray = function(jsonArray) {
405426
}
406427
};
407428

408-
=======
409-
>>>>>>> master
410429
// IE9 does not have a console. Create a stub to stop errors.
411430
if (!goog.global['console']) {
412431
goog.global['console'] = {

core/contextmenu.js

+4
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ Blockly.ContextMenu.show = function(e, options, rtl) {
6666
if (option.enabled) {
6767
goog.events.listen(menuItem, goog.ui.Component.EventType.ACTION,
6868
option.callback);
69+
menuItem.handleContextMenu = function(e) {
70+
// Right-clicking on menu option should count as a click.
71+
goog.events.dispatchEvent(this, goog.ui.Component.EventType.ACTION);
72+
};
6973
}
7074
}
7175
goog.events.listen(menu, goog.ui.Component.EventType.ACTION,

core/css.js

+16
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,22 @@ Blockly.Css.CONTENT = [
271271
'fill: #aaa;',
272272
'}',
273273

274+
'.blocklyFlyoutLabel {',
275+
'cursor: default;',
276+
'}',
277+
278+
'.blocklyFlyoutLabelBackground {',
279+
'opacity: 0;',
280+
'}',
281+
282+
'.blocklyFlyoutLabelText {',
283+
'fill: #000;',
284+
'}',
285+
286+
'.blocklyFlyoutLabelText:hover {',
287+
'fill: #aaa;',
288+
'}',
289+
274290
/*
275291
Don't allow users to select text. It gets annoying when trying to
276292
drag a block and selected text moves instead.

core/field.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -403,8 +403,6 @@ Blockly.Field.prototype.updateTextNode_ = function() {
403403
// Truncate displayed string and add an ellipsis ('...').
404404
text = text.substring(0, this.maxDisplayLength - 2) + '\u2026';
405405
}
406-
// Empty the text element.
407-
goog.dom.removeChildren(/** @type {!Element} */ (this.textElement_));
408406
// Replace whitespace with non-breaking spaces so the text doesn't collapse.
409407
text = text.replace(/\s/g, Blockly.Field.NBSP);
410408
if (this.sourceBlock_.RTL && text) {
@@ -415,6 +413,9 @@ Blockly.Field.prototype.updateTextNode_ = function() {
415413
// Prevent the field from disappearing if empty.
416414
text = Blockly.Field.NBSP;
417415
}
416+
417+
// Replace the text.
418+
goog.dom.removeChildren(/** @type {!Element} */ (this.textElement_));
418419
var textNode = document.createTextNode(text);
419420
this.textElement_.appendChild(textNode);
420421

core/field_angle.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ Blockly.FieldAngle.prototype.showEditor_ = function() {
130130
Blockly.FieldAngle.superClass_.showEditor_.call(this, noFocus);
131131
var div = Blockly.WidgetDiv.DIV;
132132
if (!div.firstChild) {
133-
// Mobile interface uses window.prompt.
133+
// Mobile interface uses Blockly.prompt.
134134
return;
135135
}
136136
// Build the SVG DOM.

core/field_dropdown.js

+28-11
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,13 @@ Blockly.FieldDropdown.ARROW_CHAR = goog.userAgent.ANDROID ? '\u25BC' : '\u25BE';
7575
*/
7676
Blockly.FieldDropdown.prototype.CURSOR = 'default';
7777

78+
/**
79+
* Language-neutral currently selected string.
80+
* @type {string}
81+
* @private
82+
*/
83+
Blockly.FieldDropdown.prototype.value_ = '';
84+
7885
/**
7986
* Install this dropdown on a block.
8087
*/
@@ -85,9 +92,9 @@ Blockly.FieldDropdown.prototype.init = function() {
8592
}
8693
// Add dropdown arrow: "option ▾" (LTR) or "▾ אופציה" (RTL)
8794
this.arrow_ = Blockly.createSvgElement('tspan', {}, null);
88-
this.arrow_.appendChild(document.createTextNode(
89-
this.sourceBlock_.RTL ? Blockly.FieldDropdown.ARROW_CHAR + ' ' :
90-
' ' + Blockly.FieldDropdown.ARROW_CHAR));
95+
this.arrow_.appendChild(document.createTextNode(this.sourceBlock_.RTL ?
96+
Blockly.FieldDropdown.ARROW_CHAR + ' ' :
97+
' ' + Blockly.FieldDropdown.ARROW_CHAR));
9198

9299
Blockly.FieldDropdown.superClass_.init.call(this);
93100
// Force a reset of the text to add the arrow.
@@ -105,16 +112,10 @@ Blockly.FieldDropdown.prototype.showEditor_ = function() {
105112
var thisField = this;
106113

107114
function callback(e) {
115+
var menu = this;
108116
var menuItem = e.target;
109117
if (menuItem) {
110-
var value = menuItem.getValue();
111-
if (thisField.sourceBlock_) {
112-
// Call any validation function, and allow it to override.
113-
value = thisField.callValidator(value);
114-
}
115-
if (value !== null) {
116-
thisField.setValue(value);
117-
}
118+
thisField.onItemSelected(menu, menuItem);
118119
}
119120
Blockly.WidgetDiv.hideIfOwner(thisField);
120121
}
@@ -192,6 +193,22 @@ Blockly.FieldDropdown.prototype.showEditor_ = function() {
192193
menuDom.focus();
193194
};
194195

196+
/**
197+
* Handle the selection of an item in the dropdown menu.
198+
* @param {!goog.ui.Menu} menu The Menu component clicked.
199+
* @param {!goog.ui.MenuItem} menuItem The MenuItem selected within menu.
200+
*/
201+
Blockly.FieldDropdown.prototype.onItemSelected = function(menu, menuItem) {
202+
var value = menuItem.getValue();
203+
if (this.sourceBlock_) {
204+
// Call any validation function, and allow it to override.
205+
value = this.callValidator(value);
206+
}
207+
if (value !== null) {
208+
this.setValue(value);
209+
}
210+
}
211+
195212
/**
196213
* Factor out common words in statically defined options.
197214
* Create prefix and/or suffix labels.

core/field_textinput.js

+8-5
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,14 @@ Blockly.FieldTextInput.prototype.showEditor_ = function(opt_quietInput) {
114114
if (!quietInput && (goog.userAgent.MOBILE || goog.userAgent.ANDROID ||
115115
goog.userAgent.IPAD)) {
116116
// Mobile browsers have issues with in-line textareas (focus & keyboards).
117-
var newValue = window.prompt(Blockly.Msg.CHANGE_VALUE_TITLE, this.text_);
118-
if (this.sourceBlock_) {
119-
newValue = this.callValidator(newValue);
120-
}
121-
this.setValue(newValue);
117+
var fieldText = this;
118+
Blockly.prompt(Blockly.Msg.CHANGE_VALUE_TITLE, this.text_,
119+
function(newValue) {
120+
if (fieldText.sourceBlock_) {
121+
newValue = fieldText.callValidator(newValue);
122+
}
123+
fieldText.setValue(newValue);
124+
});
122125
return;
123126
}
124127

0 commit comments

Comments
 (0)