aboutsummaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorAnanya Sen2012-02-17 11:07:42 -0800
committerAnanya Sen2012-02-17 11:07:42 -0800
commitf3b6a62f110be31a9438a6172694b111ffd4d507 (patch)
tree56b30ce23149e7c778a04c59977b35a5fd258571 /js
parent4641dbefb6e8cb41f1f3d7f4d070d50bcaed94be (diff)
downloadninja-f3b6a62f110be31a9438a6172694b111ffd4d507.tar.gz
-added keyboard control for saving documents
-mark html design view when element is added or deleted Signed-off-by: Ananya Sen <Ananya.Sen@motorola.com>
Diffstat (limited to 'js')
-rwxr-xr-xjs/controllers/document-controller.js21
-rwxr-xr-xjs/mediators/keyboard-mediator.js9
2 files changed, 27 insertions, 3 deletions
diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js
index b1a22c1b..6f31e24d 100755
--- a/js/controllers/document-controller.js
+++ b/js/controllers/document-controller.js
@@ -50,12 +50,21 @@ DocumentController = exports.DocumentController = Montage.create(Component, {
50 50
51 deserializedFromTemplate: { 51 deserializedFromTemplate: {
52 value: function() { 52 value: function() {
53 var self = this;
54
53 this.eventManager.addEventListener("appLoaded", this, false); 55 this.eventManager.addEventListener("appLoaded", this, false);
54 this.eventManager.addEventListener("executeFileOpen", this, false); 56 this.eventManager.addEventListener("executeFileOpen", this, false);
55 this.eventManager.addEventListener("executeNewFile", this, false); 57 this.eventManager.addEventListener("executeNewFile", this, false);
56 this.eventManager.addEventListener("executeSave", this, false); 58 this.eventManager.addEventListener("executeSave", this, false);
57 59
58 this.eventManager.addEventListener("recordStyleChanged", this, false); 60 this.eventManager.addEventListener("recordStyleChanged", this, false);
61
62 //event listener to detect a change in the html design view
63 this.eventManager.addEventListener("elementAdded", function(evt){self.markCurrentDocumentChanged()}, false);
64 this.eventManager.addEventListener("elementDeleted", function(evt){self.markCurrentDocumentChanged()}, false);
65 //todo: add all applicable event listeners
66 //end-event listener to detect a change in the html design view
67
59 } 68 }
60 }, 69 },
61 70
@@ -88,8 +97,10 @@ DocumentController = exports.DocumentController = Montage.create(Component, {
88 //TODO: Check for appropiate structures 97 //TODO: Check for appropiate structures
89 handleExecuteSave: { 98 handleExecuteSave: {
90 value: function(event) { 99 value: function(event) {
91 //Text and HTML document classes should return the same save object for fileSave 100 if(!!this.activeDocument){
92 this.application.ninja.ioMediator.fileSave(this.activeDocument.save(), this.fileSaveResult.bind(this)); 101 //Text and HTML document classes should return the same save object for fileSave
102 this.application.ninja.ioMediator.fileSave(this.activeDocument.save(), this.fileSaveResult.bind(this));
103 }
93 } 104 }
94 }, 105 },
95 //////////////////////////////////////////////////////////////////// 106 ////////////////////////////////////////////////////////////////////
@@ -427,5 +438,11 @@ DocumentController = exports.DocumentController = Montage.create(Component, {
427 value: function() { 438 value: function() {
428 return "userDocument_" + (this._iframeCounter++); 439 return "userDocument_" + (this._iframeCounter++);
429 } 440 }
441 },
442
443 markCurrentDocumentChanged:{
444 value: function(){
445 this.activeDocument.dirtyFlag = true;
430 } 446 }
447 }
431}); 448});
diff --git a/js/mediators/keyboard-mediator.js b/js/mediators/keyboard-mediator.js
index a1fdead3..e348a09b 100755
--- a/js/mediators/keyboard-mediator.js
+++ b/js/mediators/keyboard-mediator.js
@@ -85,7 +85,7 @@ exports.KeyboardMediator = Montage.create(Component, {
85 85
86 handleKeydown: { 86 handleKeydown: {
87 value: function(evt) { 87 value: function(evt) {
88 if(document.activeElement.nodeName !== "BODY") { 88 if((document.activeElement.nodeName !== "BODY") && (this.application.ninja.documentController.activeDocument.currentView === "design")) {
89 // Don't do anything if an input or other control is focused 89 // Don't do anything if an input or other control is focused
90 return; 90 return;
91 } 91 }
@@ -110,6 +110,13 @@ exports.KeyboardMediator = Montage.create(Component, {
110 return; 110 return;
111 } 111 }
112 112
113 // Check if cmd+s/ctrl+s for Save (Windows/Mac)
114 if ((evt.keyCode == Keyboard.S) && (evt.ctrlKey || evt.metaKey) && !evt.shiftKey) {
115 NJevent("executeSave");
116 evt.preventDefault();
117 return;
118 }
119
113 // Check if cmd+shift+z for Redo (Mac) 120 // Check if cmd+shift+z for Redo (Mac)
114 if ((evt.keyCode == Keyboard.Z) && evt.metaKey && evt.shiftKey) { 121 if ((evt.keyCode == Keyboard.Z) && evt.metaKey && evt.shiftKey) {
115 NJevent("executeRedo"); 122 NJevent("executeRedo");