This commit is contained in:
Rachel Fenichel 2016-11-02 13:56:27 -07:00
parent 38a672ebea
commit 41fc324aee
6 changed files with 17 additions and 18 deletions

View file

@ -66,7 +66,7 @@ Blockly.ContextMenu.show = function(e, options, rtl) {
if (option.enabled) {
goog.events.listen(menuItem, goog.ui.Component.EventType.ACTION,
option.callback);
menuItem.handleContextMenu = function(e) {
menuItem.handleContextMenu = function(/* e */) {
// Right-clicking on menu option should count as a click.
goog.events.dispatchEvent(this, goog.ui.Component.EventType.ACTION);
};

View file

@ -260,7 +260,7 @@ Blockly.FieldDropdown.prototype.onItemSelected = function(menu, menuItem) {
if (value !== null) {
this.setValue(value);
}
}
};
/**
* Factor out common words in statically defined options.

View file

@ -152,7 +152,6 @@ Blockly.FieldVariable.dropdownCreate = function() {
* @param {goog.ui.MenuItem} menuItem The MenuItem selected within menu.
*/
Blockly.FieldVariable.prototype.onItemSelected = function(menu, menuItem) {
var menuLength = menu.getChildCount();
var itemText = menuItem.getValue();
if (this.sourceBlock_) {
var workspace = this.sourceBlock_.workspace;

View file

@ -366,7 +366,7 @@ Blockly.Generator.prototype.provideFunction_ = function(desiredName, code) {
var oldCodeText;
while (oldCodeText != codeText) {
oldCodeText = codeText;
codeText = codeText.replace(/^(( )*) /gm, '$1\0');
codeText = codeText.replace(/^(( {2})*) {2}/gm, '$1\0');
}
codeText = codeText.replace(/\0/g, this.INDENT);
this.definitions_[desiredName] = codeText;

View file

@ -329,9 +329,9 @@ Blockly.Variables.generateUniqueName = function(workspace) {
* Create a new variable on the given workspace.
* @param {!Blockly.Workspace} workspace The workspace on which to create the
* variable.
* @param {function(null|undefined|string)=} opt_callback A callback. It will
* return an acceptable new variable name, or null if change is to be
* aborted (cancel button), or undefined if an existing variable was chosen.
* @param {function(?string)=} opt_callback A callback. It
* will be passed a new variable name, or null if the change is to be
* aborted (cancel button).
*/
Blockly.Variables.createVariable = function(workspace, opt_callback) {
var promptAndCheckWithAlert = function(defaultName) {
@ -365,7 +365,7 @@ Blockly.Variables.createVariable = function(workspace, opt_callback) {
* Prompt the user for a new variable name.
* @param {string} promptText The string of the prompt.
* @param {string} defaultText The default value to show in the prompt's field.
* @param {function(?string)} callback A callback. It will return the new
* @param {function(?string)} callback A callback. It will be passed the new
* variable name, or null if the user picked something illegal.
*/
Blockly.Variables.promptName = function(promptText, defaultText, callback) {

View file

@ -314,6 +314,14 @@ Blockly.Workspace.prototype.getVariableUses = function(name) {
*/
Blockly.Workspace.prototype.deleteVariable = function(name) {
var workspace = this;
function doDeletion(variableUses, index) {
Blockly.Events.setGroup(true);
for (var i = 0; i < variableUses.length; i++) {
variableUses[i].dispose(true, false);
}
Blockly.Events.setGroup(false);
workspace.variableList.splice(index, 1);
}
var variableIndex = this.variableIndexOf(name);
if (variableIndex != -1) {
// Check whether this variable is a function parameter before deleting.
@ -329,15 +337,7 @@ Blockly.Workspace.prototype.deleteVariable = function(name) {
return;
}
}
function doDeletion() {
Blockly.Events.setGroup(true);
for (var i = 0; i < uses.length; i++) {
uses[i].dispose(true, false);
}
Blockly.Events.setGroup(false);
workspace.variableList.splice(variableIndex, 1);
}
if (uses.length > 1) {
// Confirm before deleting multiple blocks.
Blockly.confirm(
@ -345,7 +345,7 @@ Blockly.Workspace.prototype.deleteVariable = function(name) {
replace('%2', name),
function(ok) {
if (ok) {
doDeletion();
doDeletion(uses, variableIndex);
}
});
} else {