aboutsummaryrefslogtreecommitdiff
path: root/js/io/document/document-controller.js
diff options
context:
space:
mode:
authorAnanya Sen2012-02-03 18:04:26 -0800
committerAnanya Sen2012-02-03 18:04:26 -0800
commit45cfffd9261ab1aa714554c584f0d0d8fe627c91 (patch)
tree74968ff98a59c6760cfb0a3854c8181877fdaff1 /js/io/document/document-controller.js
parent1daf146c849a0a8dbd2b61b14218c9a39bdee3a7 (diff)
downloadninja-45cfffd9261ab1aa714554c584f0d0d8fe627c91.tar.gz
allow to open html file in design view,
integrated file open with io mediator Signed-off-by: Ananya Sen <Ananya.Sen@motorola.com>
Diffstat (limited to 'js/io/document/document-controller.js')
-rwxr-xr-xjs/io/document/document-controller.js42
1 files changed, 17 insertions, 25 deletions
diff --git a/js/io/document/document-controller.js b/js/io/document/document-controller.js
index b900dee4..ca6b4533 100755
--- a/js/io/document/document-controller.js
+++ b/js/io/document/document-controller.js
@@ -105,7 +105,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
105 value:function(newFileObj){ 105 value:function(newFileObj){
106 //console.log(newFileObj);//contains the template uri and the new file uri 106 //console.log(newFileObj);//contains the template uri and the new file uri
107 if(!newFileObj) return; 107 if(!newFileObj) return;
108 this.application.ninja.ioMediator.fileNew(newFileObj.newFilePath, newFileObj.fileTemplateUri, this.openNewFile, this); 108 this.application.ninja.ioMediator.fileNew(newFileObj.newFilePath, newFileObj.fileTemplateUri, {"operation":this.openNewFileCallback, "thisScope":this});
109 109
110 if((newFileObj.fileExtension !== ".html") && (newFileObj.fileExtension !== ".htm")){//open code view 110 if((newFileObj.fileExtension !== ".html") && (newFileObj.fileExtension !== ".htm")){//open code view
111 111
@@ -123,7 +123,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
123 * source : file content 123 * source : file content
124 * uri : file uri 124 * uri : file uri
125 */ 125 */
126 openNewFile:{ 126 openNewFileCallback:{
127 value:function(doc){ 127 value:function(doc){
128 if(!doc){ 128 if(!doc){
129 doc = {"type": "js", "name": "filename", "source": "test file content", "uri": "/fs/fsd/"} ; 129 doc = {"type": "js", "name": "filename", "source": "test file content", "uri": "/fs/fsd/"} ;
@@ -140,20 +140,21 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
140 } 140 }
141 //console.log("URI is: ", uri); 141 //console.log("URI is: ", uri);
142 142
143 if(!!uri){ 143 this.application.ninja.ioMediator.fileOpen({"uri":uri}, {"operation":this.openFileCallback, "thisScope":this});
144 response = this.application.ninja.coreIoApi.openFile({"uri":uri}); 144 }
145 if((response.success === true) && ((response.status === 200) || (response.status === 304))){ 145 },
146 fileContent = response.content;
147 }
148
149 //console.log("$$$ "+uri+"\n content = \n\n\n"+ fileContent+"\n\n\n");
150 filename = this.getFileNameFromPath(uri);
151 if(uri.indexOf('.') != -1){
152 fileType = uri.substr(uri.lastIndexOf('.') + 1);
153 }
154 this.openDocument({"type": ""+fileType, "name": ""+filename, "source": fileContent, "uri": uri});
155 }
156 146
147 /**
148 * Public method
149 * doc contains:
150 * type : file type, like js, css, etc
151 * name : file name
152 * source : file content
153 * uri : file uri
154 */
155 openFileCallback:{
156 value:function(doc){
157 this.openDocument(doc);
157 } 158 }
158 }, 159 },
159 160
@@ -460,14 +461,5 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
460 value: function() { 461 value: function() {
461 return "userDocument_" + (this._iframeCounter++); 462 return "userDocument_" + (this._iframeCounter++);
462 } 463 }
463 }, 464 }
464
465 ///// Return the last part of a path (e.g. filename)
466 getFileNameFromPath : {
467 value: function(path) {
468 path = path.replace(/[/\\]$/g,"");
469 path = path.replace(/\\/g,"/");
470 return path.substr(path.lastIndexOf('/') + 1);
471 }
472 }
473}); \ No newline at end of file 465}); \ No newline at end of file