mirror of
https://github.com/google/blockly.git
synced 2026-01-08 01:20:12 +01:00
Code style
This commit is contained in:
@@ -128,4 +128,4 @@ Blockly.Constants.Variables.CUSTOM_CONTEXT_MENU_VARIABLE_GETTER_SETTER_MIXIN = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
Blockly.Extensions.registerMixin('contextMenu_variableSetterGetter',
|
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);
|
||||||
|
|||||||
@@ -92,17 +92,17 @@ Blockly.defineBlocksWithJsonArray([ // BEGIN JSON EXTRACT
|
|||||||
*/
|
*/
|
||||||
Blockly.Constants.VariablesDynamic.CUSTOM_CONTEXT_MENU_VARIABLE_GETTER_SETTER_MIXIN = {
|
Blockly.Constants.VariablesDynamic.CUSTOM_CONTEXT_MENU_VARIABLE_GETTER_SETTER_MIXIN = {
|
||||||
/**
|
/**
|
||||||
* Add menu option to create getter/setter block for this setter/getter.
|
* Add menu option to create getter/setter block for this setter/getter.
|
||||||
* @param {!Array} options List of menu options to add to.
|
* @param {!Array} options List of menu options to add to.
|
||||||
* @this Blockly.Block
|
* @this Blockly.Block
|
||||||
*/
|
*/
|
||||||
customContextMenu: function(options) {
|
customContextMenu: function(options) {
|
||||||
// Getter blocks have the option to create a setter block, and vice versa.
|
// Getter blocks have the option to create a setter block, and vice versa.
|
||||||
if(this.isInFlyout){
|
if (this.isInFlyout) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var opposite_type ;
|
var opposite_type;
|
||||||
var contextMenuMsg ;
|
var contextMenuMsg;
|
||||||
if (this.type == 'variables_get_dynamic') {
|
if (this.type == 'variables_get_dynamic') {
|
||||||
opposite_type = 'variables_set_dynamic';
|
opposite_type = 'variables_set_dynamic';
|
||||||
contextMenuMsg = Blockly.Msg.VARIABLES_GET_CREATE_SET;
|
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.Extensions.registerMixin('contextMenu_variableDynamicSetterGetter',
|
||||||
Blockly.Constants.VariablesDynamic.CUSTOM_CONTEXT_MENU_VARIABLE_GETTER_SETTER_MIXIN);
|
Blockly.Constants.VariablesDynamic.CUSTOM_CONTEXT_MENU_VARIABLE_GETTER_SETTER_MIXIN);
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ Blockly.VariablesDynamic.onCreateVariableButtonClick_Colour = function(button) {
|
|||||||
/**
|
/**
|
||||||
* Construct the elements (blocks and button) required by the flyout for the
|
* Construct the elements (blocks and button) required by the flyout for the
|
||||||
* variable category.
|
* 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.
|
* @return {!Array.<!Element>} Array of XML elements.
|
||||||
*/
|
*/
|
||||||
Blockly.VariablesDynamic.flyoutCategory = function(workspace) {
|
Blockly.VariablesDynamic.flyoutCategory = function(workspace) {
|
||||||
@@ -66,11 +66,11 @@ Blockly.VariablesDynamic.flyoutCategory = function(workspace) {
|
|||||||
xmlList.push(button);
|
xmlList.push(button);
|
||||||
|
|
||||||
workspace.registerButtonCallback('CREATE_VARIABLE_STRING',
|
workspace.registerButtonCallback('CREATE_VARIABLE_STRING',
|
||||||
Blockly.VariablesDynamic.onCreateVariableButtonClick_String);
|
Blockly.VariablesDynamic.onCreateVariableButtonClick_String);
|
||||||
workspace.registerButtonCallback('CREATE_VARIABLE_NUMBER',
|
workspace.registerButtonCallback('CREATE_VARIABLE_NUMBER',
|
||||||
Blockly.VariablesDynamic.onCreateVariableButtonClick_Number);
|
Blockly.VariablesDynamic.onCreateVariableButtonClick_Number);
|
||||||
workspace.registerButtonCallback('CREATE_VARIABLE_COLOUR',
|
workspace.registerButtonCallback('CREATE_VARIABLE_COLOUR',
|
||||||
Blockly.VariablesDynamic.onCreateVariableButtonClick_Colour);
|
Blockly.VariablesDynamic.onCreateVariableButtonClick_Colour);
|
||||||
|
|
||||||
|
|
||||||
var blockList = Blockly.VariablesDynamic.flyoutCategoryBlocks(workspace);
|
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.
|
* 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.
|
* @return {!Array.<!Element>} Array of XML block elements.
|
||||||
*/
|
*/
|
||||||
Blockly.VariablesDynamic.flyoutCategoryBlocks = function(workspace) {
|
Blockly.VariablesDynamic.flyoutCategoryBlocks = function(workspace) {
|
||||||
@@ -89,25 +89,24 @@ Blockly.VariablesDynamic.flyoutCategoryBlocks = function(workspace) {
|
|||||||
|
|
||||||
var xmlList = [];
|
var xmlList = [];
|
||||||
if (variableModelList.length > 0) {
|
if (variableModelList.length > 0) {
|
||||||
|
|
||||||
if (Blockly.Blocks['variables_set_dynamic']) {
|
if (Blockly.Blocks['variables_set_dynamic']) {
|
||||||
var firstVariable = variableModelList[0];
|
var firstVariable = variableModelList[0];
|
||||||
var gap = 24;
|
var gap = 24;
|
||||||
var blockText = '<xml>' +
|
var blockText = '<xml>' +
|
||||||
'<block type="variables_set_dynamic" gap="' + gap + '">' +
|
'<block type="variables_set_dynamic" gap="' + gap + '">' +
|
||||||
Blockly.Variables.generateVariableFieldXml_(firstVariable) +
|
Blockly.Variables.generateVariableFieldXml_(firstVariable) +
|
||||||
'</block>' +
|
'</block>' +
|
||||||
'</xml>';
|
'</xml>';
|
||||||
var block = Blockly.Xml.textToDom(blockText).firstChild;
|
var block = Blockly.Xml.textToDom(blockText).firstChild;
|
||||||
xmlList.push(block);
|
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>' +
|
var blockText = '<xml>' +
|
||||||
'<block type="variables_get_dynamic" gap="8">' +
|
'<block type="variables_get_dynamic" gap="8">' +
|
||||||
Blockly.Variables.generateVariableFieldXml_(variable) +
|
Blockly.Variables.generateVariableFieldXml_(variable) +
|
||||||
'</block>' +
|
'</block>' +
|
||||||
'</xml>';
|
'</xml>';
|
||||||
var block = Blockly.Xml.textToDom(blockText).firstChild;
|
var block = Blockly.Xml.textToDom(blockText).firstChild;
|
||||||
xmlList.push(block);
|
xmlList.push(block);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1041,7 +1041,7 @@ Blockly.Msg.LISTS_GET_SUBLIST_TAIL = '';
|
|||||||
/// [[File:Blockly-get-sublist.png]]
|
/// [[File:Blockly-get-sublist.png]]
|
||||||
Blockly.Msg.LISTS_GET_SUBLIST_TOOLTIP = 'Creates a copy of the specified portion of a list.';
|
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';
|
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}}
|
/// 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';
|
Blockly.Msg.LISTS_SORT_TITLE = 'sort %1 %2 %3';
|
||||||
|
|||||||
Reference in New Issue
Block a user