diff options
author | Ananya Sen | 2012-02-03 18:04:26 -0800 |
---|---|---|
committer | Ananya Sen | 2012-02-03 18:04:26 -0800 |
commit | 45cfffd9261ab1aa714554c584f0d0d8fe627c91 (patch) | |
tree | 74968ff98a59c6760cfb0a3854c8181877fdaff1 /js/io | |
parent | 1daf146c849a0a8dbd2b61b14218c9a39bdee3a7 (diff) | |
download | ninja-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')
-rwxr-xr-x | js/io/document/document-controller.js | 42 | ||||
-rwxr-xr-x | js/io/document/html-document.js | 5 |
2 files changed, 20 insertions, 27 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 |
diff --git a/js/io/document/html-document.js b/js/io/document/html-document.js index 24d4e7e4..da1bbe4a 100755 --- a/js/io/document/html-document.js +++ b/js/io/document/html-document.js | |||
@@ -216,8 +216,9 @@ var HTMLDocument = exports.HTMLDocument = Montage.create(baseDocumentModule.Base | |||
216 | value: function(doc, uuid, iframe, callback) { | 216 | value: function(doc, uuid, iframe, callback) { |
217 | // Shell mode is not used anymore | 217 | // Shell mode is not used anymore |
218 | //if(!window.IsInShellMode()) { | 218 | //if(!window.IsInShellMode()) { |
219 | 219 | if(!doc.name){doc.name = "index-cloud"}; | |
220 | this.init("index-cloud", this._cloudTemplateUri, doc.type, iframe, uuid, callback); | 220 | if(!doc.uri){doc.uri = this._cloudTemplateUri}; |
221 | this.init(doc.name, doc.uri, doc.type, iframe, uuid, callback); | ||
221 | /* | 222 | /* |
222 | } else { | 223 | } else { |
223 | var tmpurl = doc.uri.split('\\'); | 224 | var tmpurl = doc.uri.split('\\'); |