diff options
Diffstat (limited to 'js')
-rwxr-xr-x | js/controllers/document-controller.js | 16 | ||||
-rwxr-xr-x | js/io/document/html-document.js | 24 | ||||
-rwxr-xr-x | js/io/system/coreioapi.js | 2 | ||||
-rwxr-xr-x | js/io/system/fileio.js | 28 | ||||
-rw-r--r-- | js/mediators/io-mediator.js | 14 |
5 files changed, 75 insertions, 9 deletions
diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index 7f4feff9..227b5462 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js | |||
@@ -97,13 +97,19 @@ DocumentController = exports.DocumentController = Montage.create(Component, { | |||
97 | this.application.ninja.newFileController.showNewFileDialog(newFileSettings); | 97 | this.application.ninja.newFileController.showNewFileDialog(newFileSettings); |
98 | } | 98 | } |
99 | }, | 99 | }, |
100 | 100 | ||
101 | |||
102 | //////////////////////////////////////////////////////////////////// | ||
103 | //TODO: Improve logic and make functions | ||
101 | handleExecuteSave: { | 104 | handleExecuteSave: { |
102 | value: function(event) { | 105 | value: function(event) { |
103 | this.activeDocument.save(); | 106 | // |
104 | } | 107 | this.application.ninja.ioMediator.fileSave(this.activeDocument.save()); |
108 | } | ||
105 | }, | 109 | }, |
106 | 110 | //////////////////////////////////////////////////////////////////// | |
111 | |||
112 | |||
107 | createNewFile:{ | 113 | createNewFile:{ |
108 | value:function(newFileObj){ | 114 | value:function(newFileObj){ |
109 | //console.log(newFileObj);//contains the template uri and the new file uri | 115 | //console.log(newFileObj);//contains the template uri and the new file uri |
diff --git a/js/io/document/html-document.js b/js/io/document/html-document.js index fbb34a1d..2ece76c5 100755 --- a/js/io/document/html-document.js +++ b/js/io/document/html-document.js | |||
@@ -14,6 +14,7 @@ var HTMLDocument = exports.HTMLDocument = Montage.create(baseDocumentModule.Base | |||
14 | _htmlTemplateUrl: { value: "user-document-templates/montage-application-cloud/index.html", enumerable: false}, | 14 | _htmlTemplateUrl: { value: "user-document-templates/montage-application-cloud/index.html", enumerable: false}, |
15 | _iframe: { value: null, enumerable: false }, | 15 | _iframe: { value: null, enumerable: false }, |
16 | _server: { value: null, enumerable: false }, | 16 | _server: { value: null, enumerable: false }, |
17 | _templateDocument: { value: null, enumerable: false }, | ||
17 | _selectionModel: { value: [], enumerable: false }, | 18 | _selectionModel: { value: [], enumerable: false }, |
18 | _undoModel: { value: { "queue" : [], "position" : 0 }, enumerable: false}, | 19 | _undoModel: { value: { "queue" : [], "position" : 0 }, enumerable: false}, |
19 | 20 | ||
@@ -359,6 +360,10 @@ var HTMLDocument = exports.HTMLDocument = Montage.create(baseDocumentModule.Base | |||
359 | // | 360 | // |
360 | handleEvent: { | 361 | handleEvent: { |
361 | value: function(event){ | 362 | value: function(event){ |
363 | //TODO: Clean up, using for prototyping save | ||
364 | this._templateDocument = {}; | ||
365 | this._templateDocument.head = this.iframe.contentWindow.document.getElementById("userHead");; | ||
366 | this._templateDocument.body = this.iframe.contentWindow.document.getElementById("UserContent");; | ||
362 | // | 367 | // |
363 | this.documentRoot = this.iframe.contentWindow.document.getElementById("UserContent"); | 368 | this.documentRoot = this.iframe.contentWindow.document.getElementById("UserContent"); |
364 | this.stageBG = this.iframe.contentWindow.document.getElementById("stageBG"); | 369 | this.stageBG = this.iframe.contentWindow.document.getElementById("stageBG"); |
@@ -373,7 +378,7 @@ var HTMLDocument = exports.HTMLDocument = Montage.create(baseDocumentModule.Base | |||
373 | this.iframe.contentWindow.document.getElementById("userHead").innerHTML = this._userDocument.content.head; | 378 | this.iframe.contentWindow.document.getElementById("userHead").innerHTML = this._userDocument.content.head; |
374 | 379 | ||
375 | 380 | ||
376 | 381 | //TODO: Look at code below and clean up | |
377 | 382 | ||
378 | 383 | ||
379 | 384 | ||
@@ -461,7 +466,21 @@ var HTMLDocument = exports.HTMLDocument = Montage.create(baseDocumentModule.Base | |||
461 | * public method | 466 | * public method |
462 | * | 467 | * |
463 | */ | 468 | */ |
464 | save:{ | 469 | //////////////////////////////////////////////////////////////////// |
470 | // | ||
471 | save: { | ||
472 | enumerable: false, | ||
473 | value: function () { | ||
474 | //TODO: Add code view logic | ||
475 | return {mode: 'html', document: this._userDocument, head: this._templateDocument.head.innerHTML, body: this._templateDocument.body.innerHTML}; | ||
476 | } | ||
477 | } | ||
478 | //////////////////////////////////////////////////////////////////// | ||
479 | //////////////////////////////////////////////////////////////////// | ||
480 | |||
481 | |||
482 | /* | ||
483 | save:{ | ||
465 | value:function(){ | 484 | value:function(){ |
466 | try{ | 485 | try{ |
467 | if(this.currentView === "design"){ | 486 | if(this.currentView === "design"){ |
@@ -477,5 +496,6 @@ var HTMLDocument = exports.HTMLDocument = Montage.create(baseDocumentModule.Base | |||
477 | } | 496 | } |
478 | } | 497 | } |
479 | } | 498 | } |
499 | */ | ||
480 | 500 | ||
481 | }); \ No newline at end of file | 501 | }); \ No newline at end of file |
diff --git a/js/io/system/coreioapi.js b/js/io/system/coreioapi.js index b19f1e70..614b0850 100755 --- a/js/io/system/coreioapi.js +++ b/js/io/system/coreioapi.js | |||
@@ -450,7 +450,7 @@ window.hack = function (name, type) { | |||
450 | enumerable: false, | 450 | enumerable: false, |
451 | value: function(file) { | 451 | value: function(file) { |
452 | var retValue = { success:null, status:null }; | 452 | var retValue = { success:null, status:null }; |
453 | if(file && file.uri && file.uri.length && file.contents && file.contents.length) { | 453 | if(file && file.uri && file.uri.length && file.contents) { |
454 | try { | 454 | try { |
455 | var serviceURL = this._prepareServiceURL(this.fileServiceURL, file.uri), | 455 | var serviceURL = this._prepareServiceURL(this.fileServiceURL, file.uri), |
456 | xhr = new XMLHttpRequest(); | 456 | xhr = new XMLHttpRequest(); |
diff --git a/js/io/system/fileio.js b/js/io/system/fileio.js index 045fa2fd..f363ef9f 100755 --- a/js/io/system/fileio.js +++ b/js/io/system/fileio.js | |||
@@ -104,13 +104,39 @@ exports.FileIo = Montage.create(Component, { | |||
104 | // | 104 | // |
105 | saveFile: { | 105 | saveFile: { |
106 | enumerable: true, | 106 | enumerable: true, |
107 | value: function() { | 107 | value: function(file) { |
108 | //Checking for API to be available | 108 | //Checking for API to be available |
109 | if (!this.application.ninja.coreIoApi.cloudAvailable()) { | 109 | if (!this.application.ninja.coreIoApi.cloudAvailable()) { |
110 | //API not available, no IO action taken | 110 | //API not available, no IO action taken |
111 | return null; | 111 | return null; |
112 | } | 112 | } |
113 | //Peforming check for file to exist | ||
114 | var check = this.application.ninja.coreIoApi.fileExists({uri: file.uri}), status, result; | ||
115 | //Upon successful check, handling results | ||
116 | if (check.success) { | ||
117 | //Handling status of check | ||
118 | switch (check.status) { | ||
119 | case 204: | ||
120 | //File exists | ||
121 | result = this.application.ninja.coreIoApi.updateFile(file); | ||
122 | status = 204; | ||
123 | break; | ||
124 | case 404://createFile | ||
125 | //File does not exists, ready to be created | ||
126 | result = this.application.ninja.coreIoApi.createFile(file); | ||
127 | status = 404; | ||
128 | break; | ||
129 | default: | ||
130 | //Unknown Error | ||
131 | status = 500; | ||
132 | break; | ||
133 | } | ||
134 | } else { | ||
135 | //Unknown Error | ||
136 | status = 500; | ||
137 | } | ||
113 | // | 138 | // |
139 | return {status: status, result: result}; | ||
114 | } | 140 | } |
115 | }, | 141 | }, |
116 | //////////////////////////////////////////////////////////////////// | 142 | //////////////////////////////////////////////////////////////////// |
diff --git a/js/mediators/io-mediator.js b/js/mediators/io-mediator.js index 2f286e5e..deb748c7 100644 --- a/js/mediators/io-mediator.js +++ b/js/mediators/io-mediator.js | |||
@@ -138,6 +138,20 @@ exports.IoMediator = Montage.create(Component, { | |||
138 | enumerable: false, | 138 | enumerable: false, |
139 | value: function (file, callback) { | 139 | value: function (file, callback) { |
140 | // | 140 | // |
141 | var contents, save; | ||
142 | // | ||
143 | switch (file.mode) { | ||
144 | case 'html': | ||
145 | file.document.content.document.body.innerHTML = file.body; | ||
146 | file.document.content.document.head.innerHTML = file.head; | ||
147 | contents = file.document.content.document.documentElement.outerHTML; | ||
148 | break; | ||
149 | default: | ||
150 | break; | ||
151 | } | ||
152 | // | ||
153 | save = this.fio.saveFile({uri: file.document.uri, contents: contents}) | ||
154 | console.log(save); | ||
141 | } | 155 | } |
142 | }, | 156 | }, |
143 | //////////////////////////////////////////////////////////////////// | 157 | //////////////////////////////////////////////////////////////////// |