aboutsummaryrefslogtreecommitdiff
path: root/js/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'js/controllers')
-rwxr-xr-xjs/controllers/document-controller.js33
1 files changed, 24 insertions, 9 deletions
diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js
index 9a063280..505daaba 100755
--- a/js/controllers/document-controller.js
+++ b/js/controllers/document-controller.js
@@ -58,6 +58,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
58 this.eventManager.addEventListener("executeFileOpen", this, false); 58 this.eventManager.addEventListener("executeFileOpen", this, false);
59 this.eventManager.addEventListener("executeNewFile", this, false); 59 this.eventManager.addEventListener("executeNewFile", this, false);
60 this.eventManager.addEventListener("executeSave", this, false); 60 this.eventManager.addEventListener("executeSave", this, false);
61 this.eventManager.addEventListener("executeSaveAs", this, false);
61 62
62 this.eventManager.addEventListener("recordStyleChanged", this, false); 63 this.eventManager.addEventListener("recordStyleChanged", this, false);
63 64
@@ -100,33 +101,47 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
100 handleExecuteFileOpen: { 101 handleExecuteFileOpen: {
101 value: function(event) { 102 value: function(event) {
102 var pickerSettings = event._event.settings || {}; 103 var pickerSettings = event._event.settings || {};
103 pickerSettings.callback = this.openFileWithURI.bind(this); 104 if (this.application.ninja.coreIoApi.cloudAvailable()) {
104 pickerSettings.pickerMode = "read"; 105 pickerSettings.callback = this.openFileWithURI.bind(this);
105 pickerSettings.inFileMode = true; 106 pickerSettings.pickerMode = "read";
106 this.application.ninja.filePickerController.showFilePicker(pickerSettings); 107 pickerSettings.inFileMode = true;
108 this.application.ninja.filePickerController.showFilePicker(pickerSettings);
109 }
107 } 110 }
108 }, 111 },
109 112
110 handleExecuteNewFile: { 113 handleExecuteNewFile: {
111 value: function(event) { 114 value: function(event) {
112 var newFileSettings = event._event.settings || {}; 115 var newFileSettings = event._event.settings || {};
113 newFileSettings.callback = this.createNewFile.bind(this); 116 if (this.application.ninja.coreIoApi.cloudAvailable()) {
114 this.application.ninja.newFileController.showNewFileDialog(newFileSettings); 117 newFileSettings.callback = this.createNewFile.bind(this);
118 this.application.ninja.newFileController.showNewFileDialog(newFileSettings);
119 }
115 } 120 }
116 }, 121 },
117
118
119 //////////////////////////////////////////////////////////////////// 122 ////////////////////////////////////////////////////////////////////
120 //TODO: Check for appropiate structures 123 //TODO: Check for appropiate structures
121 handleExecuteSave: { 124 handleExecuteSave: {
122 value: function(event) { 125 value: function(event) {
123 if(!!this.activeDocument){ 126 if((typeof this.activeDocument !== "undefined") && this.application.ninja.coreIoApi.cloudAvailable()){
124 //Text and HTML document classes should return the same save object for fileSave 127 //Text and HTML document classes should return the same save object for fileSave
125 this.application.ninja.ioMediator.fileSave(this.activeDocument.save(), this.fileSaveResult.bind(this)); 128 this.application.ninja.ioMediator.fileSave(this.activeDocument.save(), this.fileSaveResult.bind(this));
126 } 129 }
127 } 130 }
128 }, 131 },
129 //////////////////////////////////////////////////////////////////// 132 ////////////////////////////////////////////////////////////////////
133 handleExecuteSaveAs: {
134 value: function(event) {
135 var saveAsSettings = event._event.settings || {};
136 if((typeof this.activeDocument !== "undefined") && this.application.ninja.coreIoApi.cloudAvailable()){
137 saveAsSettings.fileName = this.activeDocument.name;
138 saveAsSettings.folderUri = this.activeDocument.uri.substring(0, this.activeDocument.uri.lastIndexOf("/"));
139 //add callback
140 this.application.ninja.newFileController.showSaveAsDialog(saveAsSettings);
141 }
142 }
143 },
144
130 // 145 //
131 fileSaveResult: { 146 fileSaveResult: {
132 value: function (result) { 147 value: function (result) {