diff options
Diffstat (limited to 'js')
-rwxr-xr-x | js/controllers/document-controller.js | 22 | ||||
-rwxr-xr-x | js/io/system/coreioapi.js | 10 | ||||
-rwxr-xr-x | js/io/ui/cloudpopup.reel/cloudpopup.js | 11 | ||||
-rwxr-xr-x | js/mediators/keyboard-mediator.js | 220 |
4 files changed, 148 insertions, 115 deletions
diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index c31ffbac..3cd2c254 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js | |||
@@ -100,18 +100,26 @@ var DocumentController = exports.DocumentController = Montage.create(Component, | |||
100 | handleExecuteFileOpen: { | 100 | handleExecuteFileOpen: { |
101 | value: function(event) { | 101 | value: function(event) { |
102 | var pickerSettings = event._event.settings || {}; | 102 | var pickerSettings = event._event.settings || {}; |
103 | pickerSettings.callback = this.openFileWithURI.bind(this); | 103 | //adding callback so that file picker can be opened after checking cloud status |
104 | pickerSettings.pickerMode = "read"; | 104 | this.application.ninja.coreIoApi.cloudAvailable(function(){ |
105 | pickerSettings.inFileMode = true; | 105 | pickerSettings.callback = this.openFileWithURI.bind(this); |
106 | this.application.ninja.filePickerController.showFilePicker(pickerSettings); | 106 | pickerSettings.pickerMode = "read"; |
107 | pickerSettings.inFileMode = true; | ||
108 | this.application.ninja.filePickerController.showFilePicker(pickerSettings); | ||
109 | }.bind(this)); | ||
110 | |||
107 | } | 111 | } |
108 | }, | 112 | }, |
109 | 113 | ||
110 | handleExecuteNewFile: { | 114 | handleExecuteNewFile: { |
111 | value: function(event) { | 115 | value: function(event) { |
112 | var newFileSettings = event._event.settings || {}; | 116 | var newFileSettings = event._event.settings || {}; |
113 | newFileSettings.callback = this.createNewFile.bind(this); | 117 | //adding callback so that new file dialog can be opened after checking cloud status |
114 | this.application.ninja.newFileController.showNewFileDialog(newFileSettings); | 118 | this.application.ninja.coreIoApi.cloudAvailable(function(){ |
119 | newFileSettings.callback = this.createNewFile.bind(this); | ||
120 | this.application.ninja.newFileController.showNewFileDialog(newFileSettings); | ||
121 | }.bind(this)); | ||
122 | |||
115 | } | 123 | } |
116 | }, | 124 | }, |
117 | 125 | ||
@@ -305,6 +313,8 @@ var DocumentController = exports.DocumentController = Montage.create(Component, | |||
305 | this._removeDocumentView(doc.container); | 313 | this._removeDocumentView(doc.container); |
306 | this.application.ninja.stage.stageView.hideRulers(); | 314 | this.application.ninja.stage.stageView.hideRulers(); |
307 | document.getElementById("iframeContainer").style.display="block"; | 315 | document.getElementById("iframeContainer").style.display="block"; |
316 | |||
317 | this.application.ninja.stage.hideCanvas(true); | ||
308 | } | 318 | } |
309 | } | 319 | } |
310 | }, | 320 | }, |
diff --git a/js/io/system/coreioapi.js b/js/io/system/coreioapi.js index 2051da43..1bc66532 100755 --- a/js/io/system/coreioapi.js +++ b/js/io/system/coreioapi.js | |||
@@ -234,18 +234,19 @@ exports.CoreIoApi = Montage.create(Component, { | |||
234 | //Method to check status of I/O API, will return false if not active | 234 | //Method to check status of I/O API, will return false if not active |
235 | cloudAvailable: { | 235 | cloudAvailable: { |
236 | enumerable: false, | 236 | enumerable: false, |
237 | value: function () { | 237 | value: function (callback) { |
238 | var cloud = this.getCloudStatus(); | 238 | var cloud = this.getCloudStatus(); |
239 | // | 239 | // |
240 | if (this.rootUrl && cloud.status === 200) { | 240 | if (this.rootUrl && cloud.status === 200) { |
241 | //Active | 241 | //Active |
242 | this.cloudData.name = cloud.response['name']; | 242 | this.cloudData.name = cloud.response['name']; |
243 | this.cloudData.root = cloud.response['server-root']; | 243 | this.cloudData.root = cloud.response['server-root']; |
244 | return true; | 244 | if(!!callback){callback();} |
245 | else{return true}; | ||
245 | } else { | 246 | } else { |
246 | //Inactive | 247 | //Inactive |
247 | if (!this._cloudDialogOpen && this.application.ninja) { | 248 | if (!this._cloudDialogOpen && this.application.ninja) { |
248 | this.showCloudDialog(); | 249 | this.showCloudDialog(callback); |
249 | } | 250 | } |
250 | return false; | 251 | return false; |
251 | } | 252 | } |
@@ -273,7 +274,7 @@ exports.CoreIoApi = Montage.create(Component, { | |||
273 | // | 274 | // |
274 | showCloudDialog: { | 275 | showCloudDialog: { |
275 | enumerable: false, | 276 | enumerable: false, |
276 | value: function () { | 277 | value: function (callback) { |
277 | // | 278 | // |
278 | this._cloudDialogOpen = true; | 279 | this._cloudDialogOpen = true; |
279 | // | 280 | // |
@@ -294,6 +295,7 @@ exports.CoreIoApi = Montage.create(Component, { | |||
294 | this._cloudDialogComponents.dialog.element = popup; | 295 | this._cloudDialogComponents.dialog.element = popup; |
295 | this._cloudDialogComponents.dialog.needsDraw = true; | 296 | this._cloudDialogComponents.dialog.needsDraw = true; |
296 | this._cloudDialogComponents.dialog.element.style.opacity = 0; | 297 | this._cloudDialogComponents.dialog.element.style.opacity = 0; |
298 | this._cloudDialogComponents.dialog.callback = callback; | ||
297 | // | 299 | // |
298 | this._cloudDialogComponents.dialog.addEventListener('firstDraw', this, false); | 300 | this._cloudDialogComponents.dialog.addEventListener('firstDraw', this, false); |
299 | } | 301 | } |
diff --git a/js/io/ui/cloudpopup.reel/cloudpopup.js b/js/io/ui/cloudpopup.reel/cloudpopup.js index d2e82662..34393db5 100755 --- a/js/io/ui/cloudpopup.reel/cloudpopup.js +++ b/js/io/ui/cloudpopup.reel/cloudpopup.js | |||
@@ -23,6 +23,12 @@ exports.CloudPopup = Montage.create(Component, { | |||
23 | }, | 23 | }, |
24 | //////////////////////////////////////////////////////////////////// | 24 | //////////////////////////////////////////////////////////////////// |
25 | // | 25 | // |
26 | callback:{ | ||
27 | writable:true, | ||
28 | enumerable:true, | ||
29 | value:null | ||
30 | }, | ||
31 | // | ||
26 | components: { | 32 | components: { |
27 | enumerable: false, | 33 | enumerable: false, |
28 | value: {test_btn: null, ok_btn: null, cancel_btn: null, download_btn: null, status: null, url: null} | 34 | value: {test_btn: null, ok_btn: null, cancel_btn: null, download_btn: null, status: null, url: null} |
@@ -125,6 +131,10 @@ exports.CloudPopup = Montage.create(Component, { | |||
125 | value: function() { | 131 | value: function() { |
126 | // | 132 | // |
127 | this.application.ninja.coreIoApi.hideCloudDialog(); | 133 | this.application.ninja.coreIoApi.hideCloudDialog(); |
134 | this.application.ninja.coreIoApi._cloudDialogOpen=false; | ||
135 | if(!!this.callback){ | ||
136 | this.callback(); | ||
137 | } | ||
128 | } | 138 | } |
129 | }, | 139 | }, |
130 | //////////////////////////////////////////////////////////////////// | 140 | //////////////////////////////////////////////////////////////////// |
@@ -135,6 +145,7 @@ exports.CloudPopup = Montage.create(Component, { | |||
135 | // | 145 | // |
136 | this.application.ninja.coreIoApi.rootUrl = null; | 146 | this.application.ninja.coreIoApi.rootUrl = null; |
137 | this.application.ninja.coreIoApi.hideCloudDialog(); | 147 | this.application.ninja.coreIoApi.hideCloudDialog(); |
148 | this.application.ninja.coreIoApi._cloudDialogOpen=false; | ||
138 | } | 149 | } |
139 | } | 150 | } |
140 | //////////////////////////////////////////////////////////////////// | 151 | //////////////////////////////////////////////////////////////////// |
diff --git a/js/mediators/keyboard-mediator.js b/js/mediators/keyboard-mediator.js index 40b26582..0282060f 100755 --- a/js/mediators/keyboard-mediator.js +++ b/js/mediators/keyboard-mediator.js | |||
@@ -85,23 +85,115 @@ 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") && (!!this.application.ninja.documentController.activeDocument) | ||
89 | && (this.application.ninja.documentController.activeDocument.currentView === "design")) { | ||
90 | // Don't do anything if an input or other control is focused | ||
91 | return; | ||
92 | } | ||
93 | 88 | ||
94 | // Disable defaults for the Arrow Keys | 89 | //keyboard controls for html design view |
95 | if((evt.keyCode == Keyboard.LEFT) || (evt.keyCode == Keyboard.RIGHT) || (evt.keyCode == Keyboard.UP) || (evt.keyCode == Keyboard.DOWN)) { | 90 | if((!!this.application.ninja.documentController.activeDocument) && (this.application.ninja.documentController.activeDocument.currentView === "design")){ |
96 | evt.preventDefault(); | 91 | |
97 | } | 92 | // Don't do anything if an input or other control is focused |
93 | if(document.activeElement.nodeName !== "BODY") { | ||
94 | return; | ||
95 | } | ||
96 | |||
97 | // Disable defaults for the Arrow Keys | ||
98 | if((evt.keyCode == Keyboard.LEFT) || (evt.keyCode == Keyboard.RIGHT) || (evt.keyCode == Keyboard.UP) || (evt.keyCode == Keyboard.DOWN)) { | ||
99 | evt.preventDefault(); | ||
100 | } | ||
101 | |||
102 | // Check DELETE OR BACKSPACE | ||
103 | if((evt.keyCode == Keyboard.BACKSPACE) || (evt.keyCode == Keyboard.DELETE)) { | ||
104 | evt.stopImmediatePropagation(); | ||
105 | evt.preventDefault(); | ||
106 | NJevent("deleting"); | ||
107 | return; | ||
108 | } | ||
109 | |||
110 | |||
111 | // Shortcut for Selection Tool is V | ||
112 | if(evt.keyCode === Keyboard.V) { | ||
113 | evt.preventDefault(); | ||
114 | this.application.ninja.handleSelectTool({"detail": this.application.ninja.toolsData.defaultToolsData[0]}); | ||
115 | return; | ||
116 | } | ||
117 | |||
118 | // Shortcut for Tag Tool is D | ||
119 | if(evt.keyCode === Keyboard.D){ | ||
120 | evt.preventDefault(); | ||
121 | this.application.ninja.handleSelectTool({"detail": this.application.ninja.toolsData.defaultToolsData[4]}); | ||
122 | return; | ||
123 | } | ||
124 | |||
125 | // Shortcut for Rotate Tool is W | ||
126 | if(evt.keyCode === Keyboard.W){ | ||
127 | evt.preventDefault(); | ||
128 | this.application.ninja.handleSelectTool({"detail": this.application.ninja.toolsData.defaultToolsData[2]}); | ||
129 | return; | ||
130 | } | ||
131 | |||
132 | // Shortcut for Translate Tool is G | ||
133 | if(evt.keyCode === Keyboard.G){ | ||
134 | evt.preventDefault(); | ||
135 | this.application.ninja.handleSelectTool({"detail": this.application.ninja.toolsData.defaultToolsData[3]}); | ||
136 | return; | ||
137 | } | ||
138 | |||
139 | // Shortcut for Rectangle Tool is R | ||
140 | // unless the user is pressing the command key. | ||
141 | // If the user is pressing the command key, they want to refresh the browser. | ||
142 | if((evt.keyCode === Keyboard.R) && !evt.metaKey) { | ||
143 | evt.preventDefault(); | ||
144 | this.application.ninja.handleSelectTool({"detail": this.application.ninja.toolsData.defaultToolsData[7]}); | ||
145 | this.application.ninja.handleSelectSubTool({"detail": this.application.ninja.toolsData.defaultToolsData[7].subtools[1]}); | ||
146 |