-
{{modalHeaderHtml}}
+
Block Options
@@ -84,27 +84,23 @@ blocklyApp.BlockOptionsModalComponent = ng.core.Component({
})
.Class({
constructor: [
- blocklyApp.ModalService, blocklyApp.KeyboardInputService,
+ blocklyApp.BlockOptionsModalService, blocklyApp.KeyboardInputService,
blocklyApp.AudioService,
- function(modalService_, keyboardInputService_, audioService_) {
- this.modalService = modalService_;
+ function(blockOptionsModalService_, keyboardInputService_, audioService_) {
+ this.blockOptionsModalService = blockOptionsModalService_;
this.keyboardInputService = keyboardInputService_;
this.audioService = audioService_;
this.modalIsVisible = false;
- this.modalHeaderHtml = '';
this.actionButtonsInfo = [];
this.activeActionButtonIndex = 0;
- this.onHideCallback = null;
var that = this;
- this.modalService.registerPreShowHook(
- function(newModalHeaderHtml, newActionButtonsInfo, onHideCallback) {
+ this.blockOptionsModalService.registerPreShowHook(
+ function(newActionButtonsInfo) {
that.modalIsVisible = true;
- that.modalHeaderHtml = newModalHeaderHtml;
that.actionButtonsInfo = newActionButtonsInfo;
that.activeActionButtonIndex = 0;
- that.onHideCallback = onHideCallback;
that.keyboardInputService.setOverride({
// Tab key: no-op.
'9': function(evt) {
@@ -156,7 +152,7 @@ blocklyApp.BlockOptionsModalComponent = ng.core.Component({
});
setTimeout(function() {
- document.getElementById('modalId').focus();
+ document.getElementById('blockOptionsModal').focus();
}, 150);
}
);
@@ -184,6 +180,6 @@ blocklyApp.BlockOptionsModalComponent = ng.core.Component({
hideModal: function() {
this.modalIsVisible = false;
this.keyboardInputService.clearOverride();
- this.modalService.hideModal();
+ this.blockOptionsModalService.hideModal();
}
});
diff --git a/accessible/modal.service.js b/accessible/block-options-modal.service.js
similarity index 76%
rename from accessible/modal.service.js
rename to accessible/block-options-modal.service.js
index 2136ea51c..b064766a8 100644
--- a/accessible/modal.service.js
+++ b/accessible/block-options-modal.service.js
@@ -18,30 +18,27 @@
*/
/**
- * @fileoverview Angular2 Service that stores the content for custom modals.
- * This is a singleton service.
+ * @fileoverview Angular2 Service for the block options modal.
*
* @author sll@google.com (Sean Lip)
*/
-blocklyApp.ModalService = ng.core.Class({
+blocklyApp.BlockOptionsModalService = ng.core.Class({
constructor: [function() {
- this.modalHeaderHtml = '';
this.actionButtonsInfo = [];
- this.preShowHookHtml = null;
+ this.preShowHook = null;
this.modalIsShown = false;
this.onHideCallback = null;
}],
registerPreShowHook: function(preShowHook) {
this.preShowHook = function() {
- preShowHook(this.modalHeaderHtml, this.actionButtonsInfo);
+ preShowHook(this.actionButtonsInfo);
};
},
isModalShown: function() {
return this.modalIsShown;
},
- showModal: function(modalHeaderHtml, actionButtonsInfo, onHideCallback) {
- this.modalHeaderHtml = modalHeaderHtml;
+ showModal: function(actionButtonsInfo, onHideCallback) {
this.actionButtonsInfo = actionButtonsInfo;
this.onHideCallback = onHideCallback;
diff --git a/accessible/toolbox.component.js b/accessible/toolbox.component.js
index a08d77662..0a72cb99e 100644
--- a/accessible/toolbox.component.js
+++ b/accessible/toolbox.component.js
@@ -73,12 +73,11 @@ blocklyApp.ToolboxComponent = ng.core.Component({
})
.Class({
constructor: [
- blocklyApp.TreeService, blocklyApp.UtilsService, blocklyApp.ModalService,
- function(_treeService, _utilsService, _modalService) {
+ blocklyApp.TreeService, blocklyApp.UtilsService,
+ function(_treeService, _utilsService) {
this.toolboxCategories = [];
this.treeService = _treeService;
this.utilsService = _utilsService;
- this.modalService = _modalService;
this.xmlHasCategories = false;
}
@@ -120,9 +119,6 @@ blocklyApp.ToolboxComponent = ng.core.Component({
});
}
},
- isModalShown: function() {
- return this.modalService.isModalShown();
- },
getActiveDescId: function() {
return this.treeService.getActiveDescId('blockly-toolbox-tree');
},
diff --git a/accessible/tree.service.js b/accessible/tree.service.js
index a213aa6ce..39df6948a 100644
--- a/accessible/tree.service.js
+++ b/accessible/tree.service.js
@@ -27,17 +27,17 @@
blocklyApp.TreeService = ng.core.Class({
constructor: [
blocklyApp.NotificationsService, blocklyApp.UtilsService,
- blocklyApp.ClipboardService, blocklyApp.ModalService,
+ blocklyApp.ClipboardService, blocklyApp.BlockOptionsModalService,
blocklyApp.AudioService,
function(
_notificationsService, _utilsService, _clipboardService,
- _modalService, _audioService) {
+ _blockOptionsModalService, _audioService) {
// Stores active descendant ids for each tree in the page.
this.activeDescendantIds_ = {};
this.notificationsService = _notificationsService;
this.utilsService = _utilsService;
this.clipboardService = _clipboardService;
- this.modalService = _modalService;
+ this.blockOptionsModalService = _blockOptionsModalService;
this.audioService = _audioService;
this.toolboxWorkspaces = {};
}
@@ -357,7 +357,7 @@ blocklyApp.TreeService = ng.core.Class({
},
showBlockOptionsModal: function(block, blockRootNode) {
var that = this;
- this.modalService.showModal('Block options', [{
+ var actionButtonsInfo = [{
translationIdForText: 'MARK_SPOT_BEFORE',
action: function() {
that.clipboardService.markConnection(block.previousConnection);
@@ -436,7 +436,9 @@ blocklyApp.TreeService = ng.core.Class({
isDisabled: function() {
return false;
}
- }], function() {
+ }];
+
+ this.blockOptionsModalService.showModal(actionButtonsInfo, function() {
// TODO(sll): If there are no blocks in the workspace, focus on the
// entire workspace instead.
that.focusOnBlock(block.id);
@@ -464,7 +466,9 @@ blocklyApp.TreeService = ng.core.Class({
this.utilsService.getBlockById(blockId);
},
onKeypress: function(e, tree) {
- if (this.modalService.isModalShown()) {
+ // TODO(sll): Instead of this, have a common ActiveContextService which
+ // returns true if at least one modal is shown, and false otherwise.
+ if (this.blockOptionsModalService.isModalShown()) {
return;
}
diff --git a/accessible/workspace-tree.component.js b/accessible/workspace-tree.component.js
index da04b7f52..76d040281 100644
--- a/accessible/workspace-tree.component.js
+++ b/accessible/workspace-tree.component.js
@@ -79,17 +79,15 @@ blocklyApp.WorkspaceTreeComponent = ng.core.Component({
.Class({
constructor: [
blocklyApp.ClipboardService, blocklyApp.NotificationsService,
- blocklyApp.TreeService, blocklyApp.UtilsService,
- blocklyApp.AudioService, blocklyApp.ModalService,
+ blocklyApp.TreeService, blocklyApp.UtilsService, blocklyApp.AudioService,
function(
_clipboardService, _notificationsService, _treeService,
- _utilsService, _audioService, _modalService) {
+ _utilsService, _audioService) {
this.clipboardService = _clipboardService;
this.notificationsService = _notificationsService;
this.treeService = _treeService;
this.utilsService = _utilsService;
this.audioService = _audioService;
- this.modalService = _modalService;
}],
ngOnInit: function() {
var SUPPORTED_FIELDS = [
diff --git a/demos/accessible/index.html b/demos/accessible/index.html
index a4436fa52..1b6e7f9d3 100644
--- a/demos/accessible/index.html
+++ b/demos/accessible/index.html
@@ -20,7 +20,7 @@
-
+