Code style

This commit is contained in:
Neil Fraser
2018-01-05 15:39:55 -08:00
committed by Neil Fraser
parent eb61152ac2
commit 7413db1089
4 changed files with 25 additions and 26 deletions

View File

@@ -128,4 +128,4 @@ Blockly.Constants.Variables.CUSTOM_CONTEXT_MENU_VARIABLE_GETTER_SETTER_MIXIN = {
};
Blockly.Extensions.registerMixin('contextMenu_variableSetterGetter',
Blockly.Constants.Variables.CUSTOM_CONTEXT_MENU_VARIABLE_GETTER_SETTER_MIXIN);
Blockly.Constants.Variables.CUSTOM_CONTEXT_MENU_VARIABLE_GETTER_SETTER_MIXIN);

View File

@@ -92,17 +92,17 @@ Blockly.defineBlocksWithJsonArray([ // BEGIN JSON EXTRACT
*/
Blockly.Constants.VariablesDynamic.CUSTOM_CONTEXT_MENU_VARIABLE_GETTER_SETTER_MIXIN = {
/**
* Add menu option to create getter/setter block for this setter/getter.
* @param {!Array} options List of menu options to add to.
* @this Blockly.Block
*/
* Add menu option to create getter/setter block for this setter/getter.
* @param {!Array} options List of menu options to add to.
* @this Blockly.Block
*/
customContextMenu: function(options) {
// Getter blocks have the option to create a setter block, and vice versa.
if(this.isInFlyout){
if (this.isInFlyout) {
return;
}
var opposite_type ;
var contextMenuMsg ;
var opposite_type;
var contextMenuMsg;
if (this.type == 'variables_get_dynamic') {
opposite_type = 'variables_set_dynamic';
contextMenuMsg = Blockly.Msg.VARIABLES_GET_CREATE_SET;
@@ -135,4 +135,4 @@ Blockly.Constants.VariablesDynamic.CUSTOM_CONTEXT_MENU_VARIABLE_GETTER_SETTER_MI
};
Blockly.Extensions.registerMixin('contextMenu_variableDynamicSetterGetter',
Blockly.Constants.VariablesDynamic.CUSTOM_CONTEXT_MENU_VARIABLE_GETTER_SETTER_MIXIN);
Blockly.Constants.VariablesDynamic.CUSTOM_CONTEXT_MENU_VARIABLE_GETTER_SETTER_MIXIN);

View File

@@ -48,7 +48,7 @@ Blockly.VariablesDynamic.onCreateVariableButtonClick_Colour = function(button) {
/**
* Construct the elements (blocks and button) required by the flyout for the
* variable category.
* @param {!Blockly.Workspace} workspace The workspace contianing variables.
* @param {!Blockly.Workspace} workspace The workspace containing variables.
* @return {!Array.<!Element>} Array of XML elements.
*/
Blockly.VariablesDynamic.flyoutCategory = function(workspace) {
@@ -66,11 +66,11 @@ Blockly.VariablesDynamic.flyoutCategory = function(workspace) {
xmlList.push(button);
workspace.registerButtonCallback('CREATE_VARIABLE_STRING',
Blockly.VariablesDynamic.onCreateVariableButtonClick_String);
Blockly.VariablesDynamic.onCreateVariableButtonClick_String);
workspace.registerButtonCallback('CREATE_VARIABLE_NUMBER',
Blockly.VariablesDynamic.onCreateVariableButtonClick_Number);
Blockly.VariablesDynamic.onCreateVariableButtonClick_Number);
workspace.registerButtonCallback('CREATE_VARIABLE_COLOUR',
Blockly.VariablesDynamic.onCreateVariableButtonClick_Colour);
Blockly.VariablesDynamic.onCreateVariableButtonClick_Colour);
var blockList = Blockly.VariablesDynamic.flyoutCategoryBlocks(workspace);
@@ -80,7 +80,7 @@ Blockly.VariablesDynamic.flyoutCategory = function(workspace) {
/**
* Construct the blocks required by the flyout for the variable category.
* @param {!Blockly.Workspace} workspace The workspace contianing variables.
* @param {!Blockly.Workspace} workspace The workspace containing variables.
* @return {!Array.<!Element>} Array of XML block elements.
*/
Blockly.VariablesDynamic.flyoutCategoryBlocks = function(workspace) {
@@ -89,25 +89,24 @@ Blockly.VariablesDynamic.flyoutCategoryBlocks = function(workspace) {
var xmlList = [];
if (variableModelList.length > 0) {
if (Blockly.Blocks['variables_set_dynamic']) {
var firstVariable = variableModelList[0];
var gap = 24;
var blockText = '<xml>' +
'<block type="variables_set_dynamic" gap="' + gap + '">' +
Blockly.Variables.generateVariableFieldXml_(firstVariable) +
'</block>' +
'</xml>';
'<block type="variables_set_dynamic" gap="' + gap + '">' +
Blockly.Variables.generateVariableFieldXml_(firstVariable) +
'</block>' +
'</xml>';
var block = Blockly.Xml.textToDom(blockText).firstChild;
xmlList.push(block);
}
for (var i = 0, variable; variable = variableModelList[i]; i++) {
if (Blockly.Blocks['variables_get_dynamic']) {
if (Blockly.Blocks['variables_get_dynamic']) {
for (var i = 0, variable; variable = variableModelList[i]; i++) {
var blockText = '<xml>' +
'<block type="variables_get_dynamic" gap="8">' +
Blockly.Variables.generateVariableFieldXml_(variable) +
'</block>' +
'</xml>';
'<block type="variables_get_dynamic" gap="8">' +
Blockly.Variables.generateVariableFieldXml_(variable) +
'</block>' +
'</xml>';
var block = Blockly.Xml.textToDom(blockText).firstChild;
xmlList.push(block);
}

View File

@@ -1041,7 +1041,7 @@ Blockly.Msg.LISTS_GET_SUBLIST_TAIL = '';
/// [[File:Blockly-get-sublist.png]]
Blockly.Msg.LISTS_GET_SUBLIST_TOOLTIP = 'Creates a copy of the specified portion of a list.';
/// {{optional}}\nurl - Information describing sorting a list.
/// {{Optional}} url - Information describing sorting a list.
Blockly.Msg.LISTS_SORT_HELPURL = 'https://github.com/google/blockly/wiki/Lists#sorting-a-list';
/// Sort as type %1 (numeric or alphabetic) in order %2 (ascending or descending) a list of items %3.\n{{Identical|Sort}}
Blockly.Msg.LISTS_SORT_TITLE = 'sort %1 %2 %3';