@@ -65,49 +65,12 @@ blocklyApp.VariableModalComponent = ng.core.Component({
this.currentVariableName = "";
var that = this;
- this.variableModalService.registerPreShowHook(
+ this.variableModalService.registerPreRenameShowHook(
function(oldName) {
that.currentVariableName = oldName;
that.modalIsVisible = true;
- that.keyboardInputService.setOverride({
- // Tab key: navigates to the previous or next item in the list.
- '9': function(evt) {
- evt.preventDefault();
- evt.stopPropagation();
-
- if (evt.shiftKey) {
- // Move to the previous item in the list.
- if (that.activeButtonIndex <= 0) {
- that.activeActionButtonIndex = 0;
- that.audioService.playOopsSound();
- } else {
- that.activeButtonIndex--;
- }
- } else {
- // Move to the next item in the list.
- if (that.activeButtonIndex == that.numInteractiveElements() - 1) {
- that.audioService.playOopsSound();
- } else {
- that.activeButtonIndex++;
- }
- }
-
- that.focusOnOption(that.activeButtonIndex);
- },
- // Escape key: closes the modal.
- '27': function() {
- that.dismissModal();
- },
- // Up key: no-op.
- '38': function(evt) {
- evt.preventDefault();
- },
- // Down key: no-op.
- '40': function(evt) {
- evt.preventDefault();
- }
- });
+ Blockly.CommonModal.setupKeyboardOverrides(that);
setTimeout(function() {
document.getElementById('mainFieldId').focus();
@@ -121,36 +84,16 @@ blocklyApp.VariableModalComponent = ng.core.Component({
this.variableName = newValue;
},
// Closes the modal (on both success and failure).
- hideModal_: function() {
- this.modalIsVisible = false;
- this.keyboardInputService.clearOverride();
- },
+ hideModal_: Blockly.CommonModal.hideModal,
// Focuses on the button represented by the given index.
- focusOnOption: function(index) {
- var elements = this.getInteractiveElements();
- var button = elements[index];
- button.focus();
- },
+ focusOnOption: Blockly.CommonModal.focusOnOption,
// Counts the number of interactive elements for the modal.
- numInteractiveElements: function() {
- var elements = this.getInteractiveElements();
- return elements.length;
- },
+ numInteractiveElements: Blockly.CommonModal.numInteractiveElements,
// Gets all the interactive elements for the modal.
- getInteractiveElements: function() {
- return Array.prototype.filter.call(
- document.getElementById("varForm").elements, function(element) {
- if (element.type === 'hidden') {
- return false;
- }
- if (element.disabled) {
- return false;
- }
- if (element.tabIndex < 0) {
- return false;
- }
- return true;
- });
+ getInteractiveElements: Blockly.CommonModal.getInteractiveElements,
+ // Gets the container with interactive elements.
+ getInteractiveContainer: function() {
+ return document.getElementById("varForm");
},
// Submits the name change for the variable.
submit: function() {
diff --git a/blockly_compressed.js b/blockly_compressed.js
index 21d1e2473..0ed3d3880 100644
--- a/blockly_compressed.js
+++ b/blockly_compressed.js
@@ -1,7 +1,7 @@
// Do not edit this file; automatically generated by build.py.
'use strict';
-var COMPILED=!0,goog=goog||{};goog.global=this;goog.isDef=function(a){return void 0!==a};goog.exportPath_=function(a,b,c){a=a.split(".");c=c||goog.global;a[0]in c||!c.execScript||c.execScript("var "+a[0]);for(var d;a.length&&(d=a.shift());)!a.length&&goog.isDef(b)?c[d]=b:c=c[d]&&Object.prototype.hasOwnProperty.call(c,d)?c[d]:c[d]={}};
+var COMPILED=!0,goog=goog||{};goog.global=this;goog.isDef=function(a){return void 0!==a};goog.exportPath_=function(a,b,c){a=a.split(".");c=c||goog.global;a[0]in c||!c.execScript||c.execScript("var "+a[0]);for(var d;a.length&&(d=a.shift());)!a.length&&goog.isDef(b)?c[d]=b:c=c[d]&&c[d]!==Object.prototype[d]?c[d]:c[d]={}};
goog.define=function(a,b){var c=b;COMPILED||(goog.global.CLOSURE_UNCOMPILED_DEFINES&&Object.prototype.hasOwnProperty.call(goog.global.CLOSURE_UNCOMPILED_DEFINES,a)?c=goog.global.CLOSURE_UNCOMPILED_DEFINES[a]:goog.global.CLOSURE_DEFINES&&Object.prototype.hasOwnProperty.call(goog.global.CLOSURE_DEFINES,a)&&(c=goog.global.CLOSURE_DEFINES[a]));goog.exportPath_(a,c)};goog.DEBUG=!1;goog.LOCALE="en";goog.TRUSTED_SITE=!0;goog.STRICT_MODE_COMPATIBLE=!1;goog.DISALLOW_TEST_ONLY_CODE=COMPILED&&!goog.DEBUG;
goog.ENABLE_CHROME_APP_SAFE_SCRIPT_LOADING=!1;goog.provide=function(a){if(goog.isInModuleLoader_())throw Error("goog.provide can not be used within a goog.module.");if(!COMPILED&&goog.isProvided_(a))throw Error('Namespace "'+a+'" already declared.');goog.constructNamespace_(a)};goog.constructNamespace_=function(a,b){if(!COMPILED){delete goog.implicitNamespaces_[a];for(var c=a;(c=c.substring(0,c.lastIndexOf(".")))&&!goog.getObjectByName(c);)goog.implicitNamespaces_[c]=!0}goog.exportPath_(a,b)};
goog.VALID_MODULE_RE_=/^[a-zA-Z_$][a-zA-Z0-9._$]*$/;
@@ -15,19 +15,20 @@ goog.require=function(a){if(!COMPILED){goog.ENABLE_DEBUG_LOADER&&goog.IS_OLD_IE_
goog.abstractMethod=function(){throw Error("unimplemented abstract method");};goog.addSingletonGetter=function(a){a.instance_=void 0;a.getInstance=function(){if(a.instance_)return a.instance_;goog.DEBUG&&(goog.instantiatedSingletons_[goog.instantiatedSingletons_.length]=a);return a.instance_=new a}};goog.instantiatedSingletons_=[];goog.LOAD_MODULE_USING_EVAL=!0;goog.SEAL_MODULE_EXPORTS=goog.DEBUG;goog.loadedModules_={};goog.DEPENDENCIES_ENABLED=!COMPILED&&goog.ENABLE_DEBUG_LOADER;goog.TRANSPILE="detect";
goog.TRANSPILER="transpile.js";
goog.DEPENDENCIES_ENABLED&&(goog.dependencies_={loadFlags:{},nameToPath:{},requires:{},visited:{},written:{},deferred:{}},goog.inHtmlDocument_=function(){var a=goog.global.document;return null!=a&&"write"in a},goog.findBasePath_=function(){if(goog.isDef(goog.global.CLOSURE_BASE_PATH))goog.basePath=goog.global.CLOSURE_BASE_PATH;else if(goog.inHtmlDocument_())for(var a=goog.global.document.getElementsByTagName("SCRIPT"),b=a.length-1;0<=b;--b){var c=a[b].src,d=c.lastIndexOf("?"),d=-1==d?c.length:d;if("base.js"==
-c.substr(d-7,7)){goog.basePath=c.substr(0,d-7);break}}},goog.importScript_=function(a,b){(goog.global.CLOSURE_IMPORT_SCRIPT||goog.writeScriptTag_)(a,b)&&(goog.dependencies_.written[a]=!0)},goog.IS_OLD_IE_=!(goog.global.atob||!goog.global.document||!goog.global.document.all),goog.importProcessedScript_=function(a,b,c){goog.importScript_("",'goog.retrieveAndExec_("'+a+'", '+b+", "+c+");")},goog.queuedModules_=[],goog.wrapModule_=function(a,b){return goog.LOAD_MODULE_USING_EVAL&&goog.isDef(goog.global.JSON)?
-"goog.loadModule("+goog.global.JSON.stringify(b+"\n//# sourceURL="+a+"\n")+");":'goog.loadModule(function(exports) {"use strict";'+b+"\n;return exports});\n//# sourceURL="+a+"\n"},goog.loadQueuedModules_=function(){var a=goog.queuedModules_.length;if(0
\x3c/script>')},goog.appendScriptSrcNode_=function(a){var b=goog.global.document,c=b.createElement("script");c.type="text/javascript";c.src=a;c.defer=!1;c.async=!1;b.head.appendChild(c)},goog.writeScriptTag_=
-function(a,b){if(goog.inHtmlDocument_()){var c=goog.global.document;if(!goog.ENABLE_CHROME_APP_SAFE_SCRIPT_LOADING&&"complete"==c.readyState){if(/\bdeps.js$/.test(a))return!1;throw Error('Cannot write "'+a+'" after document load');}if(void 0===b)if(goog.IS_OLD_IE_){var d=" onreadystatechange='goog.onScriptLoad_(this, "+ ++goog.lastNonModuleScriptIndex_+")' ";c.write('
+
-
+
+
+
@@ -350,6 +353,7 @@
+