Blockly.dialog.setAlert(function(message, callback)
{
Swal.fire
({
position: 'top',
title: 'Alert!',
text: message,
width: 500,
confirmButtonColor: '#008cf0',
confirmButtonText: 'Close',
showClass:
{
backdrop: 'swal2-noanimation',
popup: '',
icon: ''
},
hideClass:
{
popup: '',
},
}).then((result) =>
{
if (result.isConfirmed)
{
callback;
}
else if (result.isDismissed)
{
callback;
}
});
});
Blockly.dialog.setConfirm(function(message, callback)
{
Swal.fire
({
position: 'top',
title: 'Confirm',
text: message,
width: 500,
confirmButtonColor: '#008cf0',
confirmButtonText: 'Close',
showClass:
{
backdrop: 'swal2-noanimation',
popup: '',
icon: ''
},
hideClass:
{
popup: '',
},
}).then((result) =>
{
if (result.isConfirmed)
{
callback(true);
}
else if (result.isDismissed)
{
callback(false);
}
});
});
Blockly.dialog.setPrompt(function(message, callback)
{
Swal.fire
({
position: 'top',
title: message,
input: 'text',
inputAttributes:
{
autocapitalize: 'off'
},
showCancelButton: true,
confirmButtonColor: '#008cf0',
confirmButtonText: 'Confirm',
cancelButtonColor: '#545454',
width: 500,
showClass:
{
backdrop: 'swal2-noanimation',
popup: '',
icon: ''
},
hideClass:
{
popup: '',
},
inputValidator: (value) =>
{
if (!value)
{
return 'You need to write something!'
}
}
}).then((result) =>
{
if (result.isConfirmed)
{
callback(result.value)
}
else if (result.isDismissed)
{
callback(null);
}
})
});