Skip to content

Merge latest google/develop Blockly #111

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 30 commits into from
Mar 3, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
4d88254
Merge branch 'master' into 2016
NeilFraser Feb 17, 2016
3e0709c
Merge branch 'master' into 2016
NeilFraser Feb 17, 2016
9b6b090
Localisation updates from https://translatewiki.net.
siebrand Feb 19, 2016
217c7d7
Localisation updates from https://translatewiki.net.
Nikerabbit Feb 22, 2016
f0d04ba
Fix RTL flyout events.
NeilFraser Feb 25, 2016
e6db687
Fix startScale on workspaces without a fixed flyout.
NeilFraser Feb 25, 2016
515a61e
Localisation updates from https://translatewiki.net.
Nikerabbit Feb 25, 2016
4d4521b
Fix scaled RTL coordinates.
NeilFraser Feb 25, 2016
9f3824b
Merge branch 'master' into develop
NeilFraser Feb 25, 2016
67aa5ef
Minor refactor of connection code
rachel-fenichel Feb 25, 2016
9de5722
Refactor: pull rendering code out of block_svg
rachel-fenichel Feb 25, 2016
c2f879a
Merge pull request #262 from rachel-fenichel/feature/connection_refactor
rachel-fenichel Feb 25, 2016
9263e28
Add tests for connection logic
rachel-fenichel Feb 25, 2016
5cb6cf5
Fix js style
rachel-fenichel Feb 25, 2016
924047c
Merge pull request #264 from rachel-fenichel/feature/connection_refac…
NeilFraser Feb 26, 2016
ea6d875
Merge pull request #263 from rachel-fenichel/feature/rendering_refactor
NeilFraser Feb 26, 2016
b567d6b
Allow shadow blocks to be edited.
NeilFraser Feb 26, 2016
a22b936
Fix invalid colours in Block Factory.
NeilFraser Feb 27, 2016
4c54224
Provide default getVars and renameVar functions. Issue 265.
NeilFraser Feb 27, 2016
73fc630
Localisation updates from https://translatewiki.net.
Nikerabbit Feb 29, 2016
39653b6
Rearrange code in ScrollbarPair set so that all the getAttribute
picklesrus Feb 29, 2016
1ae7b8e
Merge pull request #270 from picklesrus/scroll-master
NeilFraser Feb 29, 2016
6eb652c
Fix persistence of logging in playground.
NeilFraser Feb 29, 2016
3fe9ca6
Merge branch 'master' into develop
NeilFraser Feb 29, 2016
fee94ae
Allow injection based on CSS selector (based on PR 249).
NeilFraser Feb 29, 2016
5097963
Reduce code duplication in 'if' block.
NeilFraser Mar 2, 2016
016d2e7
IE does not have sessionStorage on file:// URLs.
NeilFraser Mar 3, 2016
5bdc307
Merge branch 'upstream' into feature/upstream-merge
tmickel Mar 3, 2016
4ba1f81
Remove block_render_svg
tmickel Mar 3, 2016
4611347
Compilation update
tmickel Mar 3, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 46 additions & 46 deletions blockly_compressed_horizontal.js

Large diffs are not rendered by default.

72 changes: 37 additions & 35 deletions blockly_compressed_vertical.js

Large diffs are not rendered by default.

93 changes: 52 additions & 41 deletions blocks/logic.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,17 +94,7 @@ Blockly.Blocks['controls_if'] = {
domToMutation: function(xmlElement) {
this.elseifCount_ = parseInt(xmlElement.getAttribute('elseif'), 10) || 0;
this.elseCount_ = parseInt(xmlElement.getAttribute('else'), 10) || 0;
for (var i = 1; i <= this.elseifCount_; i++) {
this.appendValueInput('IF' + i)
.setCheck('Boolean')
.appendField(Blockly.Msg.CONTROLS_IF_MSG_ELSEIF);
this.appendStatementInput('DO' + i)
.appendField(Blockly.Msg.CONTROLS_IF_MSG_THEN);
}
if (this.elseCount_) {
this.appendStatementInput('ELSE')
.appendField(Blockly.Msg.CONTROLS_IF_MSG_ELSE);
}
this.updateShape_();
},
/**
* Populate the mutator's dialog with this block's components.
Expand Down Expand Up @@ -135,51 +125,43 @@ Blockly.Blocks['controls_if'] = {
* @this Blockly.Block
*/
compose: function(containerBlock) {
// Disconnect the else input blocks and remove the inputs.
if (this.elseCount_) {
this.removeInput('ELSE');
}
this.elseCount_ = 0;
// Disconnect all the elseif input blocks and remove the inputs.
for (var i = this.elseifCount_; i > 0; i--) {
this.removeInput('IF' + i);
this.removeInput('DO' + i);
}
this.elseifCount_ = 0;
// Rebuild the block's optional inputs.
var clauseBlock = containerBlock.nextConnection.targetBlock();
// Count number of inputs.
this.elseifCount_ = 0;
this.elseCount_ = 0;
var valueConnections = [null];
var statementConnections = [null];
var elseStatementConnection = null;
while (clauseBlock) {
switch (clauseBlock.type) {
case 'controls_if_elseif':
this.elseifCount_++;
var ifInput = this.appendValueInput('IF' + this.elseifCount_)
.setCheck('Boolean')
.appendField(Blockly.Msg.CONTROLS_IF_MSG_ELSEIF);
var doInput = this.appendStatementInput('DO' + this.elseifCount_);
doInput.appendField(Blockly.Msg.CONTROLS_IF_MSG_THEN);
// Reconnect any child blocks.
if (clauseBlock.valueConnection_) {
ifInput.connection.connect(clauseBlock.valueConnection_);
}
if (clauseBlock.statementConnection_) {
doInput.connection.connect(clauseBlock.statementConnection_);
}
valueConnections.push(clauseBlock.valueConnection_);
statementConnections.push(clauseBlock.statementConnection_);
break;
case 'controls_if_else':
this.elseCount_++;
var elseInput = this.appendStatementInput('ELSE');
elseInput.appendField(Blockly.Msg.CONTROLS_IF_MSG_ELSE);
// Reconnect any child blocks.
if (clauseBlock.statementConnection_) {
elseInput.connection.connect(clauseBlock.statementConnection_);
}
elseStatementConnection = clauseBlock.statementConnection_;
break;
default:
throw 'Unknown block type.';
}
clauseBlock = clauseBlock.nextConnection &&
clauseBlock.nextConnection.targetBlock();
}
this.updateShape_();
// Reconnect any child blocks.
for (var i = 1; i <= this.elseifCount_; i++) {
if (valueConnections[i]) {
this.getInput('IF' + i).connection.connect(valueConnections[i]);
}
if (statementConnections[i]) {
this.getInput('DO' + i).connection.connect(statementConnections[i]);
}
}
if (elseStatementConnection) {
this.getInput('ELSE').connection.connect(elseStatementConnection);
}
},
/**
* Store pointers to any connected child blocks.
Expand Down Expand Up @@ -211,6 +193,35 @@ Blockly.Blocks['controls_if'] = {
clauseBlock = clauseBlock.nextConnection &&
clauseBlock.nextConnection.targetBlock();
}
},
/**
* Modify this block to have the correct number of inputs.
* @private
* @this Blockly.Block
*/
updateShape_: function() {
// Delete everything.
if (this.getInput('ELSE')) {
this.removeInput('ELSE');
}
var i = 1;
while (this.getInput('IF' + i)) {
this.removeInput('IF' + i);
this.removeInput('DO' + i);
i++;
}
// Rebuild block.
for (var i = 1; i <= this.elseifCount_; i++) {
this.appendValueInput('IF' + i)
.setCheck('Boolean')
.appendField(Blockly.Msg.CONTROLS_IF_MSG_ELSEIF);
this.appendStatementInput('DO' + i)
.appendField(Blockly.Msg.CONTROLS_IF_MSG_THEN);
}
if (this.elseCount_) {
this.appendStatementInput('ELSE')
.appendField(Blockly.Msg.CONTROLS_IF_MSG_ELSE);
}
}
};

Expand Down
40 changes: 0 additions & 40 deletions blocks/loops.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,26 +168,6 @@ Blockly.Blocks['controls_for'] = {
thisBlock.getFieldValue('VAR'));
});
},
/**
* Return all variables referenced by this block.
* @return {!Array.<string>} List of variable names.
* @this Blockly.Block
*/
getVars: function() {
return [this.getFieldValue('VAR')];
},
/**
* Notification that a variable is renaming.
* If the name matches one of this block's variables, rename it.
* @param {string} oldName Previous name of variable.
* @param {string} newName Renamed variable.
* @this Blockly.Block
*/
renameVar: function(oldName, newName) {
if (Blockly.Names.equals(oldName, this.getFieldValue('VAR'))) {
this.setFieldValue(newName, 'VAR');
}
},
/**
* Add menu option to create getter block for loop variable.
* @param {!Array} options List of menu options to add to.
Expand Down Expand Up @@ -242,26 +222,6 @@ Blockly.Blocks['controls_forEach'] = {
thisBlock.getFieldValue('VAR'));
});
},
/**
* Return all variables referenced by this block.
* @return {!Array.<string>} List of variable names.
* @this Blockly.Block
*/
getVars: function() {
return [this.getFieldValue('VAR')];
},
/**
* Notification that a variable is renaming.
* If the name matches one of this block's variables, rename it.
* @param {string} oldName Previous name of variable.
* @param {string} newName Renamed variable.
* @this Blockly.Block
*/
renameVar: function(oldName, newName) {
if (Blockly.Names.equals(oldName, this.getFieldValue('VAR'))) {
this.setFieldValue(newName, 'VAR');
}
},
customContextMenu: Blockly.Blocks['controls_for'].customContextMenu
};

Expand Down
20 changes: 0 additions & 20 deletions blocks/math.js
Original file line number Diff line number Diff line change
Expand Up @@ -290,26 +290,6 @@ Blockly.Blocks['math_change'] = {
return Blockly.Msg.MATH_CHANGE_TOOLTIP.replace('%1',
thisBlock.getFieldValue('VAR'));
});
},
/**
* Return all variables referenced by this block.
* @return {!Array.<string>} List of variable names.
* @this Blockly.Block
*/
getVars: function() {
return [this.getFieldValue('VAR')];
},
/**
* Notification that a variable is renaming.
* If the name matches one of this block's variables, rename it.
* @param {string} oldName Previous name of variable.
* @param {string} newName Renamed variable.
* @this Blockly.Block
*/
renameVar: function(oldName, newName) {
if (Blockly.Names.equals(oldName, this.getFieldValue('VAR'))) {
this.setFieldValue(newName, 'VAR');
}
}
};

Expand Down
20 changes: 0 additions & 20 deletions blocks/text.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,26 +244,6 @@ Blockly.Blocks['text_append'] = {
return Blockly.Msg.TEXT_APPEND_TOOLTIP.replace('%1',
thisBlock.getFieldValue('VAR'));
});
},
/**
* Return all variables referenced by this block.
* @return {!Array.<string>} List of variable names.
* @this Blockly.Block
*/
getVars: function() {
return [this.getFieldValue('VAR')];
},
/**
* Notification that a variable is renaming.
* If the name matches one of this block's variables, rename it.
* @param {string} oldName Previous name of variable.
* @param {string} newName Renamed variable.
* @this Blockly.Block
*/
renameVar: function(oldName, newName) {
if (Blockly.Names.equals(oldName, this.getFieldValue('VAR'))) {
this.setFieldValue(newName, 'VAR');
}
}
};

Expand Down
40 changes: 0 additions & 40 deletions blocks/variables.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,26 +49,6 @@ Blockly.Blocks['variables_get'] = {
this.setTooltip(Blockly.Msg.VARIABLES_GET_TOOLTIP);
this.contextMenuMsg_ = Blockly.Msg.VARIABLES_GET_CREATE_SET;
},
/**
* Return all variables referenced by this block.
* @return {!Array.<string>} List of variable names.
* @this Blockly.Block
*/
getVars: function() {
return [this.getFieldValue('VAR')];
},
/**
* Notification that a variable is renaming.
* If the name matches one of this block's variables, rename it.
* @param {string} oldName Previous name of variable.
* @param {string} newName Renamed variable.
* @this Blockly.Block
*/
renameVar: function(oldName, newName) {
if (Blockly.Names.equals(oldName, this.getFieldValue('VAR'))) {
this.setFieldValue(newName, 'VAR');
}
},
contextMenuType_: 'variables_set',
/**
* Add menu option to create getter/setter block for this setter/getter.
Expand Down Expand Up @@ -115,26 +95,6 @@ Blockly.Blocks['variables_set'] = {
});
this.contextMenuMsg_ = Blockly.Msg.VARIABLES_SET_CREATE_GET;
},
/**
* Return all variables referenced by this block.
* @return {!Array.<string>} List of variable names.
* @this Blockly.Block
*/
getVars: function() {
return [this.getFieldValue('VAR')];
},
/**
* Notification that a variable is renaming.
* If the name matches one of this block's variables, rename it.
* @param {string} oldName Previous name of variable.
* @param {string} newName Renamed variable.
* @this Blockly.Block
*/
renameVar: function(oldName, newName) {
if (Blockly.Names.equals(oldName, this.getFieldValue('VAR'))) {
this.setFieldValue(newName, 'VAR');
}
},
contextMenuType_: 'variables_get',
customContextMenu: Blockly.Blocks['variables_get'].customContextMenu
};
Loading