Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions blockly_compressed_horizontal.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions blockly_compressed_vertical.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions core/blockly.js
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,7 @@ Blockly.prompt = function(message, defaultValue, callback, _opt_title,
_opt_varType) {
// opt_title and opt_varType are unused because we only need them to pass
// information to the scratch-gui, which overwrites this function

callback(window.prompt(message, defaultValue));
};

Expand Down
3 changes: 2 additions & 1 deletion core/data_category.js
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,8 @@ Blockly.DataCategory.addCreateButton = function(xmlList, workspace, type) {
var msg = Blockly.Msg.NEW_VARIABLE;
var callbackKey = 'CREATE_VARIABLE';
var callback = function(button) {
Blockly.Variables.createVariable(button.getTargetWorkspace(), null, '');};
Blockly.Variables.createVariable(button.getTargetWorkspace(), null, '');
};

if (type === 'LIST') {
msg = Blockly.Msg.NEW_LIST;
Expand Down
47 changes: 46 additions & 1 deletion core/variables.js
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,6 @@ Blockly.Variables.createVariable = function(workspace, opt_callback, opt_type) {
if (flyout.setCheckboxState) {
flyout.setCheckboxState(variableBlockId, true);
}

if (opt_callback) {
opt_callback(variableBlockId);
}
Expand Down Expand Up @@ -367,6 +366,52 @@ Blockly.Variables.createVariable = function(workspace, opt_callback, opt_type) {
* proceed with creating or renaming the variable.
* @private
*/
/*
* xigua
*/
Blockly.Variables.createCloudVarialbe = function(text, additionalVars, variableOptions, workspace) {
var scope = variableOptions.scope;
var isLocal = (scope === 'local') || false;
var isCloud = variableOptions.isCloud || false;
// Default to [] if additionalVars is not provided
additionalVars = additionalVars || [];
// Only use additionalVars for global variable creation.
var additionalVarNames = isLocal ? [] : additionalVars;
var validate = Blockly.Variables.nameValidator_.bind(null, '');
var validatedText = validate(text, workspace, additionalVarNames, isCloud, null);
if (validatedText) {
// The name is valid according to the type, create the variable
var potentialVarMap = workspace.getPotentialVariableMap();
var variable;
// This check ensures that if a new variable is being created from a
// workspace that already has a variable of the same name and type as
// a potential variable, that potential variable gets turned into a
// real variable and thus there aren't duplicate options in the field_variable
// dropdown.
if (potentialVarMap) {
variable = Blockly.Variables.realizePotentialVar(validatedText,
'', workspace, false);
}
if (!variable) {
variable = workspace.createVariable(validatedText, '', null, isLocal, isCloud);
}

var flyout = workspace.isFlyout ? workspace : workspace.getFlyout();
var variableBlockId = variable.getId();
if (flyout.setCheckboxState) {
flyout.setCheckboxState(variableBlockId, true);
}
// if (opt_callback) {
// opt_callback(variableBlockId);
// }
} else {
// User canceled prompt without a value.
// if (opt_callback) {
// opt_callback(null);
// }
}
}

Blockly.Variables.nameValidator_ = function(type, text, workspace, additionalVars,
isCloud, opt_callback) {
// The validators for the different variable types require slightly different arguments.
Expand Down