diff options
-rwxr-xr-x | js/io/document/document-controller.js | 42 | ||||
-rwxr-xr-x | js/io/document/html-document.js | 5 | ||||
-rw-r--r-- | js/mediators/io-mediator.js | 32 | ||||
-rwxr-xr-x | js/stage/stage-view.reel/stage-view.css | 1 |
4 files changed, 49 insertions, 31 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('\\'); |
diff --git a/js/mediators/io-mediator.js b/js/mediators/io-mediator.js index 3d75771f..76f78a7d 100644 --- a/js/mediators/io-mediator.js +++ b/js/mediators/io-mediator.js | |||
@@ -16,12 +16,12 @@ exports.IoMediator = Montage.create(require("montage/ui/component").Component, { | |||
16 | // | 16 | // |
17 | fileNew: { | 17 | fileNew: { |
18 | enumerable: false, | 18 | enumerable: false, |
19 | value: function (file, template, callback, callbackScope) { | 19 | value: function (file, template, callback) { |
20 | // | 20 | // |
21 | 21 | ||
22 | 22 | ||
23 | var returnObj = null; //like {"type": "js", "name": "filename", "source": "test file content", "uri": "/fs/fsd/"} | 23 | var returnObj = null; //like {"type": "js", "name": "filename", "source": "test file content", "uri": "/fs/fsd/"} |
24 | callback.call(callbackScope, returnObj); | 24 | callback.operation.call(callback.thisScope, returnObj); |
25 | } | 25 | } |
26 | }, | 26 | }, |
27 | //////////////////////////////////////////////////////////////////// | 27 | //////////////////////////////////////////////////////////////////// |
@@ -29,7 +29,23 @@ exports.IoMediator = Montage.create(require("montage/ui/component").Component, { | |||
29 | fileOpen: { | 29 | fileOpen: { |
30 | enumerable: false, | 30 | enumerable: false, |
31 | value: function (file, callback) { | 31 | value: function (file, callback) { |
32 | // | 32 | var response = "", fileContent="", filename="", fileType="js", returnObj=null; |
33 | |||
34 | response = this.application.ninja.coreIoApi.openFile({"uri":file.uri}); | ||
35 | if((response.success === true) && ((response.status === 200) || (response.status === 304))){ | ||
36 | fileContent = response.content; | ||
37 | } | ||
38 | |||
39 | |||
40 | //TODO : format html content to render in design view | ||
41 | |||
42 | |||
43 | filename = this.getFileNameFromPath(file.uri); | ||
44 | if(file.uri.indexOf('.') != -1){ | ||
45 | fileType = file.uri.substr(file.uri.lastIndexOf('.') + 1); | ||
46 | } | ||
47 | returnObj = {"type": ""+fileType, "name": ""+filename, "source": fileContent, "uri": file.uri}; | ||
48 | callback.operation.call(callback.thisScope, returnObj); | ||
33 | } | 49 | } |
34 | }, | 50 | }, |
35 | //////////////////////////////////////////////////////////////////// | 51 | //////////////////////////////////////////////////////////////////// |
@@ -47,8 +63,16 @@ exports.IoMediator = Montage.create(require("montage/ui/component").Component, { | |||
47 | value: function (file, copy, callback) { | 63 | value: function (file, copy, callback) { |
48 | // | 64 | // |
49 | } | 65 | } |
50 | } | 66 | }, |
51 | //////////////////////////////////////////////////////////////////// | 67 | //////////////////////////////////////////////////////////////////// |
68 | ///// Return the last part of a path (e.g. filename) | ||
69 | getFileNameFromPath : { | ||
70 | value: function(path) { | ||
71 | path = path.replace(/[/\\]$/g,""); | ||
72 | path = path.replace(/\\/g,"/"); | ||
73 | return path.substr(path.lastIndexOf('/') + 1); | ||
74 | } | ||
75 | } | ||
52 | //////////////////////////////////////////////////////////////////// | 76 | //////////////////////////////////////////////////////////////////// |
53 | }); | 77 | }); |
54 | //////////////////////////////////////////////////////////////////////// | 78 | //////////////////////////////////////////////////////////////////////// |
diff --git a/js/stage/stage-view.reel/stage-view.css b/js/stage/stage-view.reel/stage-view.css index f00a5f8a..ce7072c7 100755 --- a/js/stage/stage-view.reel/stage-view.css +++ b/js/stage/stage-view.reel/stage-view.css | |||
@@ -13,6 +13,7 @@ | |||
13 | background-color: #ffffff; | 13 | background-color: #ffffff; |
14 | width: 100%; | 14 | width: 100%; |
15 | height: 100%; | 15 | height: 100%; |
16 | overflow:auto; | ||
16 | /*display: none;*/ | 17 | /*display: none;*/ |
17 | } | 18 | } |
18 | 19 | ||