Commit 9701ad76 authored by Evan W. Patton's avatar Evan W. Patton Committed by Jeffrey Schiller

Use DomHelper to show Do It error dialog (#1664)

* Use DomHelper to show Do It error dialog
* Disable Do It when companion not connected
parent c0193fea
......@@ -49,7 +49,6 @@ Blockly.BlocklyEditor.render = function() {
*/
Blockly.Block.prototype.customContextMenu = function(options) {
var myBlock = this;
var doitOption = { enabled: !this.disabled};
if (window.parent.BlocklyPanel_checkIsAdmin()) {
var yailOption = {enabled: !this.disabled};
yailOption.text = Blockly.Msg.GENERATE_YAIL;
......@@ -67,6 +66,8 @@ Blockly.Block.prototype.customContextMenu = function(options) {
};
options.push(yailOption);
}
var connectedToRepl = top.ReplState.state === Blockly.ReplMgr.rsState.CONNECTED;
var doitOption = { enabled: !this.disabled && connectedToRepl};
doitOption.text = Blockly.Msg.DO_IT;
doitOption.callback = function() {
var yailText;
......@@ -74,8 +75,8 @@ Blockly.Block.prototype.customContextMenu = function(options) {
//and an array if the block is a value
var yailTextOrArray = Blockly.Yail.blockToCode1(myBlock);
var dialog;
if (window.parent.ReplState.state != Blockly.ReplMgr.rsState.CONNECTED) {
dialog = new goog.ui.Dialog(null, true);
if (!connectedToRepl) {
dialog = new goog.ui.Dialog(null, true, new goog.dom.DomHelper(top.document));
dialog.setTitle(Blockly.Msg.CAN_NOT_DO_IT);
dialog.setTextContent(Blockly.Msg.CONNECT_TO_DO_IT);
dialog.setButtonSet(new goog.ui.Dialog.ButtonSet().
......
......@@ -1434,6 +1434,7 @@ Blockly.Msg.en.switch_language_to_english = {
// Blocklyeditor.js
Blockly.Msg.GENERATE_YAIL = "Generate Yail";
Blockly.Msg.DO_IT = "Do It";
Blockly.Msg.DO_IT_DISCONNECTED = 'Do It (Companion not connected)';
Blockly.Msg.CLEAR_DO_IT_ERROR = "Clear Error";
Blockly.Msg.CAN_NOT_DO_IT = "Cannot Do it";
Blockly.Msg.CONNECT_TO_DO_IT = 'You must be connected to the companion or emulator to use "Do It"';
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment