Skip to content

Commit 53e2bb3

Browse files
author
Ke, Mingze
committed
Bumped blockly version
1 parent 99e400b commit 53e2bb3

92 files changed

Lines changed: 635 additions & 569 deletions

Some content is hidden

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

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "webduino-blockly",
33
"dependencies": {
4-
"blockly": "google/blockly#1ca2fdc8445001981cfcf483181f24ae49325452"
4+
"blockly": "google/blockly#8d87f73f45d4adb85555cced89b3c8bd7f274312"
55
}
66
}

components/blockly/.bower.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{
22
"name": "blockly",
33
"homepage": "https://github.com/google/blockly",
4-
"_release": "1ca2fdc844",
4+
"_release": "8d87f73f45",
55
"_resolution": {
66
"type": "commit",
7-
"commit": "1ca2fdc8445001981cfcf483181f24ae49325452"
7+
"commit": "8d87f73f45d4adb85555cced89b3c8bd7f274312"
88
},
99
"_source": "git://github.com/google/blockly.git",
10-
"_target": "1ca2fdc8445001981cfcf483181f24ae49325452",
10+
"_target": "8d87f73f45d4adb85555cced89b3c8bd7f274312",
1111
"_originalSource": "google/blockly"
1212
}

components/blockly/blockly_compressed.js

Lines changed: 49 additions & 47 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

components/blockly/blockly_uncompressed.js

Lines changed: 17 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

components/blockly/blocks/lists.js

Lines changed: 36 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ Blockly.Blocks['lists_create_with'] = {
6565
},
6666
/**
6767
* Create XML to represent list inputs.
68-
* @return {Element} XML storage element.
68+
* @return {!Element} XML storage element.
6969
* @this Blockly.Block
7070
*/
7171
mutationToDom: function() {
@@ -649,14 +649,8 @@ Blockly.Blocks['lists_split'] = {
649649
var dropdown = new Blockly.FieldDropdown(
650650
[[Blockly.Msg.LISTS_SPLIT_LIST_FROM_TEXT, 'SPLIT'],
651651
[Blockly.Msg.LISTS_SPLIT_TEXT_FROM_LIST, 'JOIN']],
652-
function(newOp) {
653-
if (newOp == 'SPLIT') {
654-
thisBlock.outputConnection.setCheck('Array');
655-
thisBlock.getInput('INPUT').setCheck('String');
656-
} else {
657-
thisBlock.outputConnection.setCheck('String');
658-
thisBlock.getInput('INPUT').setCheck('Array');
659-
}
652+
function(newMode) {
653+
thisBlock.updateType_(newMode);
660654
});
661655
this.setHelpUrl(Blockly.Msg.LISTS_SPLIT_HELPURL);
662656
this.setColour(Blockly.Blocks.lists.HUE);
@@ -677,5 +671,38 @@ Blockly.Blocks['lists_split'] = {
677671
}
678672
throw 'Unknown mode: ' + mode;
679673
});
674+
},
675+
/**
676+
* Modify this block to have the correct input and output types.
677+
* @param {string} newMode Either 'SPLIT' or 'JOIN'.
678+
* @private
679+
* @this Blockly.Block
680+
*/
681+
updateType_: function(newMode) {
682+
if (newMode == 'SPLIT') {
683+
this.outputConnection.setCheck('Array');
684+
this.getInput('INPUT').setCheck('String');
685+
} else {
686+
this.outputConnection.setCheck('String');
687+
this.getInput('INPUT').setCheck('Array');
688+
}
689+
},
690+
/**
691+
* Create XML to represent the input and output types.
692+
* @return {!Element} XML storage element.
693+
* @this Blockly.Block
694+
*/
695+
mutationToDom: function() {
696+
var container = document.createElement('mutation');
697+
container.setAttribute('mode', this.getFieldValue('MODE'));
698+
return container;
699+
},
700+
/**
701+
* Parse XML to restore the input and output types.
702+
* @param {!Element} xmlElement XML storage element.
703+
* @this Blockly.Block
704+
*/
705+
domToMutation: function(xmlElement) {
706+
this.updateType_(xmlElement.getAttribute('mode'));
680707
}
681708
};

components/blockly/blocks/loops.js

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,19 +34,19 @@ goog.require('Blockly.Blocks');
3434
*/
3535
Blockly.Blocks.loops.HUE = 120;
3636

37-
Blockly.Blocks['controls_repeat'] = {
37+
Blockly.Blocks['controls_repeat_ext'] = {
3838
/**
39-
* Block for repeat n times (internal number).
39+
* Block for repeat n times (external number).
4040
* @this Blockly.Block
4141
*/
4242
init: function() {
4343
this.jsonInit({
4444
"message0": Blockly.Msg.CONTROLS_REPEAT_TITLE,
4545
"args0": [
4646
{
47-
"type": "field_input",
47+
"type": "input_value",
4848
"name": "TIMES",
49-
"text": "10"
49+
"check": "Number"
5050
}
5151
],
5252
"previousStatement": null,
@@ -57,24 +57,23 @@ Blockly.Blocks['controls_repeat'] = {
5757
});
5858
this.appendStatementInput('DO')
5959
.appendField(Blockly.Msg.CONTROLS_REPEAT_INPUT_DO);
60-
this.getField('TIMES').setChangeHandler(
61-
Blockly.FieldTextInput.nonnegativeIntegerValidator);
6260
}
6361
};
6462

65-
Blockly.Blocks['controls_repeat_ext'] = {
63+
Blockly.Blocks['controls_repeat'] = {
6664
/**
67-
* Block for repeat n times (external number).
65+
* Block for repeat n times (internal number).
66+
* The 'controls_repeat_ext' block is preferred as it is more flexible.
6867
* @this Blockly.Block
6968
*/
7069
init: function() {
7170
this.jsonInit({
7271
"message0": Blockly.Msg.CONTROLS_REPEAT_TITLE,
7372
"args0": [
7473
{
75-
"type": "input_value",
74+
"type": "field_input",
7675
"name": "TIMES",
77-
"check": "Number"
76+
"text": "10"
7877
}
7978
],
8079
"previousStatement": null,
@@ -85,6 +84,8 @@ Blockly.Blocks['controls_repeat_ext'] = {
8584
});
8685
this.appendStatementInput('DO')
8786
.appendField(Blockly.Msg.CONTROLS_REPEAT_INPUT_DO);
87+
this.getField('TIMES').setChangeHandler(
88+
Blockly.FieldTextInput.nonnegativeIntegerValidator);
8889
}
8990
};
9091

components/blockly/blocks/math.js

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -347,11 +347,7 @@ Blockly.Blocks['math_on_list'] = {
347347
this.setColour(Blockly.Blocks.math.HUE);
348348
this.setOutput(true, 'Number');
349349
var dropdown = new Blockly.FieldDropdown(OPERATORS, function(newOp) {
350-
if (newOp == 'MODE') {
351-
thisBlock.outputConnection.setCheck('Array');
352-
} else {
353-
thisBlock.outputConnection.setCheck('Number');
354-
}
350+
thisBlock.updateType_(newOp);
355351
});
356352
this.appendValueInput('LIST')
357353
.setCheck('Array')
@@ -370,6 +366,37 @@ Blockly.Blocks['math_on_list'] = {
370366
};
371367
return TOOLTIPS[mode];
372368
});
369+
},
370+
/**
371+
* Modify this block to have the correct output type.
372+
* @param {string} newOp Either 'MODE' or some op than returns a number.
373+
* @private
374+
* @this Blockly.Block
375+
*/
376+
updateType_: function(newOp) {
377+
if (newOp == 'MODE') {
378+
this.outputConnection.setCheck('Array');
379+
} else {
380+
this.outputConnection.setCheck('Number');
381+
}
382+
},
383+
/**
384+
* Create XML to represent the output type.
385+
* @return {Element} XML storage element.
386+
* @this Blockly.Block
387+
*/
388+
mutationToDom: function() {
389+
var container = document.createElement('mutation');
390+
container.setAttribute('op', this.getFieldValue('OP'));
391+
return container;
392+
},
393+
/**
394+
* Parse XML to restore the output type.
395+
* @param {!Element} xmlElement XML storage element.
396+
* @this Blockly.Block
397+
*/
398+
domToMutation: function(xmlElement) {
399+
this.updateType_(xmlElement.getAttribute('op'));
373400
}
374401
};
375402

components/blockly/blocks/procedures.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ Blockly.Blocks['procedures_defnoreturn'] = {
109109
},
110110
/**
111111
* Create XML to represent the argument inputs.
112-
* @return {Element} XML storage element.
112+
* @return {!Element} XML storage element.
113113
* @this Blockly.Block
114114
*/
115115
mutationToDom: function() {
@@ -583,7 +583,7 @@ Blockly.Blocks['procedures_callnoreturn'] = {
583583
},
584584
/**
585585
* Create XML to represent the (non-editable) name and arguments.
586-
* @return {Element} XML storage element.
586+
* @return {!Element} XML storage element.
587587
* @this Blockly.Block
588588
*/
589589
mutationToDom: function() {
@@ -705,7 +705,7 @@ Blockly.Blocks['procedures_ifreturn'] = {
705705
},
706706
/**
707707
* Create XML to represent whether this block has a return value.
708-
* @return {Element} XML storage element.
708+
* @return {!Element} XML storage element.
709709
* @this Blockly.Block
710710
*/
711711
mutationToDom: function() {

components/blockly/blocks/text.js

Lines changed: 55 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ Blockly.Blocks['text_join'] = {
8282
},
8383
/**
8484
* Create XML to represent number of text inputs.
85-
* @return {Element} XML storage element.
85+
* @return {!Element} XML storage element.
8686
* @this Blockly.Block
8787
*/
8888
mutationToDom: function() {
@@ -364,7 +364,7 @@ Blockly.Blocks['text_charAt'] = {
364364
},
365365
/**
366366
* Create XML to represent whether there is an 'AT' input.
367-
* @return {Element} XML storage element.
367+
* @return {!Element} XML storage element.
368368
* @this Blockly.Block
369369
*/
370370
mutationToDom: function() {
@@ -458,7 +458,7 @@ Blockly.Blocks['text_getSubstring'] = {
458458
},
459459
/**
460460
* Create XML to represent whether there are 'AT' inputs.
461-
* @return {Element} XML storage element.
461+
* @return {!Element} XML storage element.
462462
* @this Blockly.Block
463463
*/
464464
mutationToDom: function() {
@@ -593,46 +593,68 @@ Blockly.Blocks['text_print'] = {
593593
}
594594
};
595595

596-
Blockly.Blocks['text_prompt'] = {
596+
Blockly.Blocks['text_prompt_ext'] = {
597597
/**
598-
* Block for prompt function (internal message).
598+
* Block for prompt function (external message).
599599
* @this Blockly.Block
600600
*/
601601
init: function() {
602602
var TYPES =
603603
[[Blockly.Msg.TEXT_PROMPT_TYPE_TEXT, 'TEXT'],
604604
[Blockly.Msg.TEXT_PROMPT_TYPE_NUMBER, 'NUMBER']];
605-
// Assign 'this' to a variable for use in the closure below.
606-
var thisBlock = this;
607605
this.setHelpUrl(Blockly.Msg.TEXT_PROMPT_HELPURL);
608606
this.setColour(Blockly.Blocks.texts.HUE);
607+
// Assign 'this' to a variable for use in the closures below.
608+
var thisBlock = this;
609609
var dropdown = new Blockly.FieldDropdown(TYPES, function(newOp) {
610-
if (newOp == 'NUMBER') {
611-
thisBlock.changeOutput('Number');
612-
} else {
613-
thisBlock.changeOutput('String');
614-
}
610+
thisBlock.updateType_(newOp);
615611
});
616-
this.appendDummyInput()
617-
.appendField(dropdown, 'TYPE')
618-
.appendField(this.newQuote_(true))
619-
.appendField(new Blockly.FieldTextInput(''), 'TEXT')
620-
.appendField(this.newQuote_(false));
612+
this.appendValueInput('TEXT')
613+
.appendField(dropdown, 'TYPE');
621614
this.setOutput(true, 'String');
622-
// Assign 'this' to a variable for use in the tooltip closure below.
623-
var thisBlock = this;
624615
this.setTooltip(function() {
625616
return (thisBlock.getFieldValue('TYPE') == 'TEXT') ?
626617
Blockly.Msg.TEXT_PROMPT_TOOLTIP_TEXT :
627618
Blockly.Msg.TEXT_PROMPT_TOOLTIP_NUMBER;
628619
});
629620
},
630-
newQuote_: Blockly.Blocks['text'].newQuote_
621+
/**
622+
* Modify this block to have the correct output type.
623+
* @param {string} newOp Either 'TEXT' or 'NUMBER'.
624+
* @private
625+
* @this Blockly.Block
626+
*/
627+
updateType_: function(newOp) {
628+
if (newOp == 'NUMBER') {
629+
this.outputConnection.setCheck('Number');
630+
} else {
631+
this.outputConnection.setCheck('String');
632+
}
633+
},
634+
/**
635+
* Create XML to represent the output type.
636+
* @return {!Element} XML storage element.
637+
* @this Blockly.Block
638+
*/
639+
mutationToDom: function() {
640+
var container = document.createElement('mutation');
641+
container.setAttribute('type', this.getFieldValue('TYPE'));
642+
return container;
643+
},
644+
/**
645+
* Parse XML to restore the output type.
646+
* @param {!Element} xmlElement XML storage element.
647+
* @this Blockly.Block
648+
*/
649+
domToMutation: function(xmlElement) {
650+
this.updateType_(xmlElement.getAttribute('type'));
651+
}
631652
};
632653

633-
Blockly.Blocks['text_prompt_ext'] = {
654+
Blockly.Blocks['text_prompt'] = {
634655
/**
635-
* Block for prompt function (external message).
656+
* Block for prompt function (internal message).
657+
* The 'text_prompt_ext' block is preferred as it is more flexible.
636658
* @this Blockly.Block
637659
*/
638660
init: function() {
@@ -644,14 +666,13 @@ Blockly.Blocks['text_prompt_ext'] = {
644666
this.setHelpUrl(Blockly.Msg.TEXT_PROMPT_HELPURL);
645667
this.setColour(Blockly.Blocks.texts.HUE);
646668
var dropdown = new Blockly.FieldDropdown(TYPES, function(newOp) {
647-
if (newOp == 'NUMBER') {
648-
thisBlock.changeOutput('Number');
649-
} else {
650-
thisBlock.changeOutput('String');
651-
}
669+
thisBlock.updateType_(newOp);
652670
});
653-
this.appendValueInput('TEXT')
654-
.appendField(dropdown, 'TYPE');
671+
this.appendDummyInput()
672+
.appendField(dropdown, 'TYPE')
673+
.appendField(this.newQuote_(true))
674+
.appendField(new Blockly.FieldTextInput(''), 'TEXT')
675+
.appendField(this.newQuote_(false));
655676
this.setOutput(true, 'String');
656677
// Assign 'this' to a variable for use in the tooltip closure below.
657678
var thisBlock = this;
@@ -660,5 +681,9 @@ Blockly.Blocks['text_prompt_ext'] = {
660681
Blockly.Msg.TEXT_PROMPT_TOOLTIP_TEXT :
661682
Blockly.Msg.TEXT_PROMPT_TOOLTIP_NUMBER;
662683
});
663-
}
684+
},
685+
newQuote_: Blockly.Blocks['text'].newQuote_,
686+
updateType_: Blockly.Blocks['text_prompt_ext'].updateType_,
687+
mutationToDom: Blockly.Blocks['text_prompt_ext'].mutationToDom,
688+
domToMutation: Blockly.Blocks['text_prompt_ext'].domToMutation
664689
};

0 commit comments

Comments
 (0)