Skip to content

Commit

Permalink
Removed modal patch for Blockly and used native version from google/b…
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkusBordihn committed Feb 4, 2017
1 parent 1552113 commit 83a6811
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 207 deletions.
2 changes: 1 addition & 1 deletion app/manifest.json
Expand Up @@ -9,7 +9,7 @@
"short_name": "Coding with Chrome",
"description": "Learn, improve, or teach coding skills within a Chrome browser.",
"key": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAgSWdCJSwkgFTY9d993Quot277oCS2PCM2H/F6U28NE8D3Z21GXS/7qW8XCGShB054Wboq62pP679f9tB9F+GRHzOh/an4zIu+Uhb3ZKVzZLJbHsP8N+E5wk3wgwOBgE+UXCy9I8i1RpfzutJ4aha+YEzvCsVpo6UwsuWiXORB9yRU5NuooYX+fhVpWZmrZJo4vqzQhuoJ/uWiQujABXXo4qdrclwSw8+JlpWLMqHHQ6HE8Sf7VWDdGvRdYP6LRZobWqovb659qEumJ0bxhwXtHkWgPHQWtW35T/r/oH8uuke35pH+YtBtaOqN5U3bYGPinP0bYrI33OSLUJx/DrC1wIDAQAB",
"version": "4.1.5",
"version": "4.2.4",
"oauth2": {
"client_id": "418162477970-2qmsb2sp3m522hf292154favsjgpsj9n.apps.googleusercontent.com",
"scopes": [
Expand Down
1 change: 0 additions & 1 deletion build/external/extra_files.js
Expand Up @@ -129,7 +129,6 @@ closureBuilder.build({
BlocklyPath + 'blocks_compressed.js',
BlocklyPath + 'javascript_compressed.js',
'patches/blockly/audio_preload_patch.js',
'patches/blockly/modal_support_patch.js'
],
out: 'genfiles/external/blockly/'
});
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,7 +1,7 @@
{
"name": "coding-with-chrome",
"description": "Coding with Chrome",
"version": "4.1.5",
"version": "4.2.4",
"author": "Markus Bordihn (mbordihn@google.com)",
"license": "Apache-2.0",
"private": true,
Expand Down
180 changes: 0 additions & 180 deletions patches/blockly/modal_support_patch.js

This file was deleted.

29 changes: 6 additions & 23 deletions src/ui/blockly/blockly.js
Expand Up @@ -81,15 +81,6 @@ cwc.ui.Blockly = function(helper) {
/** @type {cwc.ui.BlocklyToolbar} */
this.toolbar = null;

/** @type {Function} */
this.modalAlert = null;

/** @type {Function} */
this.modalConfirm = null;

/** @type {Function} */
this.modalPrompt = null;

/** @type {Blockly.Workspace} */
this.workspace = null;

Expand Down Expand Up @@ -135,16 +126,15 @@ cwc.ui.Blockly.prototype.decorate = function(node, opt_toolbox, opt_prefix,
// Modal window
var dialogInstance = this.helper.getInstance('dialog');
if (dialogInstance) {
this.modalAlert = function(promptText, opt_title) {
dialogInstance.showContent(opt_title || 'Blockly', promptText);
Blockly['alert'] = function(message, callback) {
dialogInstance.showAlert('Blockly alert', message).then(callback);
};
this.modalConfirm = function(promptText, callback, opt_title) {
dialogInstance.showYesNo(
opt_title || 'Blockly', promptText).then(callback);
Blockly['confirm'] = function(message, callback) {
dialogInstance.showYesNo('Blockly confirm', message).then(callback);
};
this.modalPrompt = function(promptText, defaultText, callback, opt_title) {
Blockly['prompt'] = function(message, default_value, callback) {
dialogInstance.showPrompt(
opt_title || 'Blockly', promptText, defaultText).then(callback);
'Blockly prompt', message, default_value).then(callback);
};
}

Expand Down Expand Up @@ -175,13 +165,6 @@ cwc.ui.Blockly.prototype.decorate = function(node, opt_toolbox, opt_prefix,
this.log.info('Decorating Blockly node', this.nodeEditor, 'with', options);
this.workspace = Blockly.inject(this.nodeEditor, options);

// Adding Modal support
this.setWorkspaceOption('modalOptions', {
'alert': this.modalAlert,
'confirm': this.modalConfirm,
'prompt': this.modalPrompt
});

// Monitor changes
var viewportMonitor = new goog.dom.ViewportSizeMonitor();
if (viewportMonitor) {
Expand Down
25 changes: 25 additions & 0 deletions src/utils/dialog/dialog.js
Expand Up @@ -220,6 +220,31 @@ cwc.utils.Dialog.prototype.setButtonText = function(id, text) {
};


/**
* @param {!string} title
* @param {!string} content
* @export
*/
cwc.utils.Dialog.prototype.showAlert = function(title, content) {
return new Promise((resolve, reject) => {
if (this.getDialog_()) {
this.render(title, content, cwc.soy.Dialog.alertTemplate);
var okButton = goog.dom.getElement(this.prefix + 'ok');
okButton.addEventListener('click', this.close.bind(this));
if (this.defaultCloseHandler_) {
okButton.addEventListener('click', this.defaultCloseHandler_);
}
okButton.addEventListener('click', function() {
resolve(true);
});
this.showModal();
} else {
reject();
}
});
};


/**
* @param {!string} title
* @param {!string} content
Expand Down
23 changes: 23 additions & 0 deletions src/utils/dialog/dialog.soy
Expand Up @@ -51,6 +51,29 @@
</div>
{/template}


/**
* Alert template.
*/
{template .alertTemplate}
{@param prefix: string}
{@param title: string}
{@param content: string}

<h3 class="mdl-dialog__title">
{msg desc=""}{$title}{/msg}
</h3>
<div class="mdl-dialog__content">
{$content}
</div>
<div class="mdl-dialog__actions">
<button id="{$prefix}ok" type="button" class="mdl-button">
{msg desc=""}OK{/msg}
</button>
</div>
{/template}


/**
* Yes / no template.
*/
Expand Down
2 changes: 1 addition & 1 deletion third_party/blockly
Submodule blockly updated 211 files

0 comments on commit 83a6811

Please sign in to comment.