Skip to content

Commit

Permalink
Merge pull request #228 from google/2016
Browse files Browse the repository at this point in the history
Update from 2016 dev branch.
  • Loading branch information
NeilFraser committed Jan 8, 2016
2 parents a77788d + 80f36f0 commit b1b96e4
Show file tree
Hide file tree
Showing 160 changed files with 1,788 additions and 2,897 deletions.
391 changes: 197 additions & 194 deletions blockly_compressed.js

Large diffs are not rendered by default.

91 changes: 44 additions & 47 deletions blockly_uncompressed.js

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions blocks/lists.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,11 @@ Blockly.Blocks['lists_create_with'] = {
* @this Blockly.Block
*/
decompose: function(workspace) {
var containerBlock =
Blockly.Block.obtain(workspace, 'lists_create_with_container');
var containerBlock = workspace.newBlock('lists_create_with_container');
containerBlock.initSvg();
var connection = containerBlock.getInput('STACK').connection;
for (var i = 0; i < this.itemCount_; i++) {
var itemBlock = Blockly.Block.obtain(workspace, 'lists_create_with_item');
var itemBlock = workspace.newBlock('lists_create_with_item');
itemBlock.initSvg();
connection.connect(itemBlock.previousConnection);
connection = itemBlock.nextConnection;
Expand Down
14 changes: 7 additions & 7 deletions blocks/logic.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,17 +113,17 @@ Blockly.Blocks['controls_if'] = {
* @this Blockly.Block
*/
decompose: function(workspace) {
var containerBlock = Blockly.Block.obtain(workspace, 'controls_if_if');
var containerBlock = workspace.newBlock('controls_if_if');
containerBlock.initSvg();
var connection = containerBlock.getInput('STACK').connection;
var connection = containerBlock.nextConnection;
for (var i = 1; i <= this.elseifCount_; i++) {
var elseifBlock = Blockly.Block.obtain(workspace, 'controls_if_elseif');
var elseifBlock = workspace.newBlock('controls_if_elseif');
elseifBlock.initSvg();
connection.connect(elseifBlock.previousConnection);
connection = elseifBlock.nextConnection;
}
if (this.elseCount_) {
var elseBlock = Blockly.Block.obtain(workspace, 'controls_if_else');
var elseBlock = workspace.newBlock('controls_if_else');
elseBlock.initSvg();
connection.connect(elseBlock.previousConnection);
}
Expand All @@ -147,7 +147,7 @@ Blockly.Blocks['controls_if'] = {
}
this.elseifCount_ = 0;
// Rebuild the block's optional inputs.
var clauseBlock = containerBlock.getInputTargetBlock('STACK');
var clauseBlock = containerBlock.nextConnection.targetBlock();
while (clauseBlock) {
switch (clauseBlock.type) {
case 'controls_if_elseif':
Expand Down Expand Up @@ -187,7 +187,7 @@ Blockly.Blocks['controls_if'] = {
* @this Blockly.Block
*/
saveConnections: function(containerBlock) {
var clauseBlock = containerBlock.getInputTargetBlock('STACK');
var clauseBlock = containerBlock.nextConnection.targetBlock();
var i = 1;
while (clauseBlock) {
switch (clauseBlock.type) {
Expand Down Expand Up @@ -223,7 +223,7 @@ Blockly.Blocks['controls_if_if'] = {
this.setColour(Blockly.Blocks.logic.HUE);
this.appendDummyInput()
.appendField(Blockly.Msg.CONTROLS_IF_IF_TITLE_IF);
this.appendStatementInput('STACK');
this.setNextStatement(true);
this.setTooltip(Blockly.Msg.CONTROLS_IF_IF_TOOLTIP);
this.contextMenu = false;
}
Expand Down
37 changes: 20 additions & 17 deletions blocks/procedures.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ Blockly.Blocks['procedures_defnoreturn'] = {
* @this Blockly.Block
*/
init: function() {
this.setHelpUrl(Blockly.Msg.PROCEDURES_DEFNORETURN_HELPURL);
this.setColour(Blockly.Blocks.procedures.HUE);
var nameField = new Blockly.FieldTextInput(
Blockly.Msg.PROCEDURES_DEFNORETURN_PROCEDURE,
Blockly.Procedures.rename);
Expand All @@ -51,7 +49,12 @@ Blockly.Blocks['procedures_defnoreturn'] = {
.appendField(nameField, 'NAME')
.appendField('', 'PARAMS');
this.setMutator(new Blockly.Mutator(['procedures_mutatorarg']));
if (Blockly.Msg.PROCEDURES_DEFNORETURN_COMMENT) {
this.setCommentText(Blockly.Msg.PROCEDURES_DEFNORETURN_COMMENT);
}
this.setColour(Blockly.Blocks.procedures.HUE);
this.setTooltip(Blockly.Msg.PROCEDURES_DEFNORETURN_TOOLTIP);
this.setHelpUrl(Blockly.Msg.PROCEDURES_DEFNORETURN_HELPURL);
this.arguments_ = [];
this.setStatements_(true);
this.statementConnection_ = null;
Expand Down Expand Up @@ -159,8 +162,7 @@ Blockly.Blocks['procedures_defnoreturn'] = {
* @this Blockly.Block
*/
decompose: function(workspace) {
var containerBlock = Blockly.Block.obtain(workspace,
'procedures_mutatorcontainer');
var containerBlock = workspace.newBlock('procedures_mutatorcontainer');
containerBlock.initSvg();

// Check/uncheck the allow statement box.
Expand All @@ -174,7 +176,7 @@ Blockly.Blocks['procedures_defnoreturn'] = {
// Parameter list.
var connection = containerBlock.getInput('STACK').connection;
for (var i = 0; i < this.arguments_.length; i++) {
var paramBlock = Blockly.Block.obtain(workspace, 'procedures_mutatorarg');
var paramBlock = workspace.newBlock('procedures_mutatorarg');
paramBlock.initSvg();
paramBlock.setFieldValue(this.arguments_[i], 'NAME');
// Store the old location.
Expand Down Expand Up @@ -344,8 +346,6 @@ Blockly.Blocks['procedures_defreturn'] = {
* @this Blockly.Block
*/
init: function() {
this.setHelpUrl(Blockly.Msg.PROCEDURES_DEFRETURN_HELPURL);
this.setColour(Blockly.Blocks.procedures.HUE);
var nameField = new Blockly.FieldTextInput(
Blockly.Msg.PROCEDURES_DEFRETURN_PROCEDURE,
Blockly.Procedures.rename);
Expand All @@ -358,7 +358,12 @@ Blockly.Blocks['procedures_defreturn'] = {
.setAlign(Blockly.ALIGN_RIGHT)
.appendField(Blockly.Msg.PROCEDURES_DEFRETURN_RETURN);
this.setMutator(new Blockly.Mutator(['procedures_mutatorarg']));
if (Blockly.Msg.PROCEDURES_DEFRETURN_COMMENT) {
this.setCommentText(Blockly.Msg.PROCEDURES_DEFRETURN_COMMENT);
}
this.setColour(Blockly.Blocks.procedures.HUE);
this.setTooltip(Blockly.Msg.PROCEDURES_DEFRETURN_TOOLTIP);
this.setHelpUrl(Blockly.Msg.PROCEDURES_DEFRETURN_HELPURL);
this.arguments_ = [];
this.setStatements_(true);
this.statementConnection_ = null;
Expand Down Expand Up @@ -394,13 +399,13 @@ Blockly.Blocks['procedures_mutatorcontainer'] = {
* @this Blockly.Block
*/
init: function() {
this.setColour(Blockly.Blocks.procedures.HUE);
this.appendDummyInput()
.appendField(Blockly.Msg.PROCEDURES_MUTATORCONTAINER_TITLE);
this.appendStatementInput('STACK');
this.appendDummyInput('STATEMENT_INPUT')
.appendField(Blockly.Msg.PROCEDURES_ALLOW_STATEMENTS)
.appendField(new Blockly.FieldCheckbox('TRUE'), 'STATEMENTS');
this.setColour(Blockly.Blocks.procedures.HUE);
this.setTooltip(Blockly.Msg.PROCEDURES_MUTATORCONTAINER_TOOLTIP);
this.contextMenu = false;
}
Expand All @@ -412,12 +417,12 @@ Blockly.Blocks['procedures_mutatorarg'] = {
* @this Blockly.Block
*/
init: function() {
this.setColour(Blockly.Blocks.procedures.HUE);
this.appendDummyInput()
.appendField(Blockly.Msg.PROCEDURES_MUTATORARG_TITLE)
.appendField(new Blockly.FieldTextInput('x', this.validator_), 'NAME');
this.setPreviousStatement(true);
this.setNextStatement(true);
this.setColour(Blockly.Blocks.procedures.HUE);
this.setTooltip(Blockly.Msg.PROCEDURES_MUTATORARG_TOOLTIP);
this.contextMenu = false;
},
Expand All @@ -442,14 +447,13 @@ Blockly.Blocks['procedures_callnoreturn'] = {
* @this Blockly.Block
*/
init: function() {
this.setHelpUrl(Blockly.Msg.PROCEDURES_CALLNORETURN_HELPURL);
this.setColour(Blockly.Blocks.procedures.HUE);
this.appendDummyInput('TOPROW')
.appendField(Blockly.Msg.PROCEDURES_CALLNORETURN_CALL)
.appendField('', 'NAME');
this.setPreviousStatement(true);
this.setNextStatement(true);
this.setColour(Blockly.Blocks.procedures.HUE);
// Tooltip is set in domToMutation.
this.setHelpUrl(Blockly.Msg.PROCEDURES_CALLNORETURN_HELPURL);
this.arguments_ = [];
this.quarkConnections_ = {};
this.quarkArguments_ = null;
Expand Down Expand Up @@ -671,13 +675,12 @@ Blockly.Blocks['procedures_callreturn'] = {
* @this Blockly.Block
*/
init: function() {
this.setHelpUrl(Blockly.Msg.PROCEDURES_CALLRETURN_HELPURL);
this.setColour(Blockly.Blocks.procedures.HUE);
this.appendDummyInput('TOPROW')
.appendField(Blockly.Msg.PROCEDURES_CALLRETURN_CALL)
.appendField('', 'NAME');
this.setOutput(true);
this.setColour(Blockly.Blocks.procedures.HUE);
// Tooltip is set in domToMutation.
this.setHelpUrl(Blockly.Msg.PROCEDURES_CALLRETURN_HELPURL);
this.arguments_ = [];
this.quarkConnections_ = {};
this.quarkArguments_ = null;
Expand All @@ -699,8 +702,6 @@ Blockly.Blocks['procedures_ifreturn'] = {
* @this Blockly.Block
*/
init: function() {
this.setHelpUrl('http://c2.com/cgi/wiki?GuardClause');
this.setColour(Blockly.Blocks.procedures.HUE);
this.appendValueInput('CONDITION')
.setCheck('Boolean')
.appendField(Blockly.Msg.CONTROLS_IF_MSG_IF);
Expand All @@ -709,7 +710,9 @@ Blockly.Blocks['procedures_ifreturn'] = {
this.setInputsInline(true);
this.setPreviousStatement(true);
this.setNextStatement(true);
this.setColour(Blockly.Blocks.procedures.HUE);
this.setTooltip(Blockly.Msg.PROCEDURES_IFRETURN_TOOLTIP);
this.setHelpUrl(Blockly.Msg.PROCEDURES_IFRETURN_HELPURL);
this.hasReturnValue_ = true;
},
/**
Expand Down
5 changes: 2 additions & 3 deletions blocks/text.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,11 @@ Blockly.Blocks['text_join'] = {
* @this Blockly.Block
*/
decompose: function(workspace) {
var containerBlock = Blockly.Block.obtain(workspace,
'text_create_join_container');
var containerBlock = workspace.newBlock('text_create_join_container');
containerBlock.initSvg();
var connection = containerBlock.getInput('STACK').connection;
for (var i = 0; i < this.itemCount_; i++) {
var itemBlock = Blockly.Block.obtain(workspace, 'text_create_join_item');
var itemBlock = workspace.newBlock('text_create_join_item');
itemBlock.initSvg();
connection.connect(itemBlock.previousConnection);
connection = itemBlock.nextConnection;
Expand Down
Loading

0 comments on commit b1b96e4

Please sign in to comment.