Replaces calls to window.alert(), window.confirm(), and window.prompt() with Blockly.alert(), Blockly.confirm(), and Blockly.prompt(). These are designed to allow app developers to replace the dialogs with versions that match their own open app, possibly avoiding modal browser dialogs. They each take a callback, so the developer has the opportunity to implement non-modal behavior.

This commit is contained in:
Andrew n marshall
2016-10-20 09:30:45 -07:00
parent 13c5d9b3dd
commit 8f3b4bcb5e
8 changed files with 567 additions and 56 deletions

View File

@@ -316,26 +316,29 @@ Blockly.Workspace.prototype.deleteVariable = function(name) {
if (block.type == 'procedures_defnoreturn' ||
block.type == 'procedures_defreturn') {
var procedureName = block.getFieldValue('NAME');
window.alert(
Blockly.alert(
Blockly.Msg.CANNOT_DELETE_VARIABLE_PROCEDURE.replace('%1', name).
replace('%2', procedureName));
replace('%2', procedureName));
return;
}
}
var ok = window.confirm(
var workspace = this;
Blockly.confirm(
Blockly.Msg.DELETE_VARIABLE_CONFIRMATION.replace('%1', uses.length).
replace('%2', name));
if (!ok) {
return;
}
}
replace('%2', name),
function(ok) {
if (!ok) {
return;
}
Blockly.Events.setGroup(true);
for (var i = 0; i < uses.length; i++) {
uses[i].dispose(true, false);
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);
});
}
Blockly.Events.setGroup(false);
this.variableList.splice(variableIndex, 1);
}
};