aboutsummaryrefslogtreecommitdiff
path: root/js/io
diff options
context:
space:
mode:
authorAnanya Sen2012-02-01 11:59:11 -0800
committerAnanya Sen2012-02-01 11:59:11 -0800
commit553fce7721cacfd13b6013fdcdd0243c90083b5e (patch)
treed0ef0c7fdf19053e2d78a3700e7234955eccb30c /js/io
parent61ff730a1897890f71403cbfac4d15269e2d271f (diff)
downloadninja-553fce7721cacfd13b6013fdcdd0243c90083b5e.tar.gz
fixed reference to coreioapi
cleaning up opening code view tabs Signed-off-by: Ananya Sen <Ananya.Sen@motorola.com>
Diffstat (limited to 'js/io')
-rwxr-xr-xjs/io/document/document-controller.js46
-rwxr-xr-xjs/io/system/coreioapi.js3
-rw-r--r--js/io/utils/file-utils.js4
3 files changed, 26 insertions, 27 deletions
diff --git a/js/io/document/document-controller.js b/js/io/document/document-controller.js
index 7cf7f409..bba7e0e7 100755
--- a/js/io/document/document-controller.js
+++ b/js/io/document/document-controller.js
@@ -15,10 +15,9 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot
15var Montage = require("montage/core/core").Montage, 15var Montage = require("montage/core/core").Montage,
16 Component = require("montage/ui/component").Component, 16 Component = require("montage/ui/component").Component,
17 Uuid = require("montage/core/uuid").Uuid, 17 Uuid = require("montage/core/uuid").Uuid,
18 fileSystem = require("js/io/system/coreioapi").CoreIoApi; 18 nj= require("js/lib/NJUtils.js").NJUtils,
19 19 HTMLDocument = require("js/io/document/html-document").HTMLDocument,
20var HTMLDocument = require("js/io/document/html-document").HTMLDocument; 20 TextDocument = require("js/io/document/text-document").TextDocument;
21var TextDocument = require("js/io/document/text-document").TextDocument;
22 21
23var DocumentController = exports.DocumentController = Montage.create(Component, { 22var DocumentController = exports.DocumentController = Montage.create(Component, {
24 hasTemplate: { 23 hasTemplate: {
@@ -96,7 +95,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
96 95
97 openFileWithURI: { 96 openFileWithURI: {
98 value: function(uriArrayObj) { 97 value: function(uriArrayObj) {
99 var uri = "", fileContent = "", response=null; 98 var uri = "", fileContent = "", response=null, filename="", fileType="js";
100 if(!!uriArrayObj && !!uriArrayObj.uri && (uriArrayObj.uri.length > 0)){ 99 if(!!uriArrayObj && !!uriArrayObj.uri && (uriArrayObj.uri.length > 0)){
101 uri = uriArrayObj.uri[0]; 100 uri = uriArrayObj.uri[0];
102 } 101 }
@@ -104,18 +103,23 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
104 103
105 // Get file from Jose Code with a callback to here 104 // Get file from Jose Code with a callback to here
106 if(!!uri){ 105 if(!!uri){
107 response = fileSystem.openFile({"uri":uri}); 106 response = this.application.ninja.coreIoApi.openFile({"uri":uri});
108 if((response.success === true) && ((response.status === 200) || (response.status === 304))){ 107 if((response.success === true) && ((response.status === 200) || (response.status === 304))){
109 fileContent = response.content; 108 fileContent = response.content;
110 } 109 }
111 110
112 console.log("$$$ "+uri+"\n content = \n\n\n"+ fileContent+"\n\n\n"); 111 //console.log("$$$ "+uri+"\n content = \n\n\n"+ fileContent+"\n\n\n");
113 this.openDocument({"type": "js", "name": "tmp.js", "source": fileContent}); 112 filename = nj.getFileNameFromPath(uri);
113 if(uri.indexOf('.') != -1){
114 fileType = uri.substr(uri.lastIndexOf('.') + 1);
115 }
116 this.openDocument({"type": ""+fileType, "name": ""+filename, "source": fileContent});
114 } 117 }
115 118
116 } 119 }
117 }, 120 },
118 121
122
119 openProjectWithURI: { 123 openProjectWithURI: {
120 value: function(uri) { 124 value: function(uri) {
121 console.log("URI is: ", uri); 125 console.log("URI is: ", uri);
@@ -211,7 +215,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
211 this._documents.splice(this._findIndexByUUID(id), 1); 215 this._documents.splice(this._findIndexByUUID(id), 1);
212 216
213 if(this.activeDocument.uuid === id && this._documents.length > 0) { 217 if(this.activeDocument.uuid === id && this._documents.length > 0) {
214 this.switchDocument(this._documents[0].uuid) 218 this.switchDocument(this._documents[0].uuid);
215 } 219 }
216 } 220 }
217 }, 221 },
@@ -254,11 +258,11 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
254 lineNumbers: true, 258 lineNumbers: true,
255 mode: "htmlmixed", 259 mode: "htmlmixed",
256 onCursorActivity: function() { 260 onCursorActivity: function() {
257 DocumentManager._codeEditor.editor.setLineClass(DocumentManager._codeEditor.hline, null); 261 DocumentController._codeEditor.editor.setLineClass(DocumentController._codeEditor.hline, null);
258 DocumentManager._codeEditor.hline = DocumentManager._codeEditor.editor.setLineClass(DocumentManager._codeEditor.editor.getCursor().line, "activeline"); 262 DocumentController._codeEditor.hline = DocumentController._codeEditor.editor.setLineClass(DocumentController._codeEditor.editor.getCursor().line, "activeline");
259 } 263 }
260 }); 264 });
261 this._codeEditor.hline = DocumentManager._codeEditor.editor.setLineClass(0, "activeline"); 265 this._codeEditor.hline = DocumentController._codeEditor.editor.setLineClass(0, "activeline");
262 } 266 }
263 } 267 }
264 }, 268 },
@@ -284,9 +288,9 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
284 288
285 _onOpenTextDocument: { 289 _onOpenTextDocument: {
286 value: function(doc) { 290 value: function(doc) {
287 DocumentManager._hideCurrentDocument(); 291 this._hideCurrentDocument();
288 this.application.ninja.stage._scrollFlag = false; // TODO HACK to prevent type error on Hide/Show Iframe 292 this.application.ninja.stage._scrollFlag = false; // TODO HACK to prevent type error on Hide/Show Iframe
289 DocumentManager.activeDocument = doc; 293 this.activeDocument = doc;
290 294
291 var type; 295 var type;
292 296
@@ -299,15 +303,15 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
299 break; 303 break;
300 } 304 }
301 305
302 DocumentManager._codeEditor.editor = CodeMirror.fromTextArea(doc.textArea, { 306 DocumentController._codeEditor.editor = CodeMirror.fromTextArea(doc.textArea, {
303 lineNumbers: true, 307 lineNumbers: true,
304 mode: type, 308 mode: type,
305 onCursorActivity: function() { 309 onCursorActivity: function() {
306 DocumentManager._codeEditor.editor.setLineClass(DocumentManager._codeEditor.hline, null); 310 DocumentController._codeEditor.editor.setLineClass(DocumentController._codeEditor.hline, null);
307 DocumentManager._codeEditor.hline = DocumentManager._codeEditor.editor.setLineClass(DocumentManager._codeEditor.editor.getCursor().line, "activeline"); 311 DocumentController._codeEditor.hline = DocumentController._codeEditor.editor.setLineClass(DocumentController._codeEditor.editor.getCursor().line, "activeline");
308 } 312 }
309 }); 313 });
310 DocumentManager._codeEditor.hline = DocumentManager._codeEditor.editor.setLineClass(0, "activeline"); 314 DocumentController._codeEditor.hline = DocumentController._codeEditor.editor.setLineClass(0, "activeline");
311 315
312 } 316 }
313 }, 317 },
@@ -349,7 +353,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
349 value: function() { 353 value: function() {
350 if(this.activeDocument) { 354 if(this.activeDocument) {
351 this.activeDocument.container.style["display"] = "none"; 355 this.activeDocument.container.style["display"] = "none";
352 if(this.activeDocument.documentType === "htm" || this.activeDocument.documentType === "html") this.application.ninja.stage.toggleCanvas(); 356 //if(this.activeDocument.documentType === "htm" || this.activeDocument.documentType === "html") this.application.ninja.stage.toggleCanvas();
353 } 357 }
354 } 358 }
355 }, 359 },
@@ -358,7 +362,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
358 value: function() { 362 value: function() {
359 if(this.activeDocument) { 363 if(this.activeDocument) {
360 this.activeDocument.container.style["display"] = "block"; 364 this.activeDocument.container.style["display"] = "block";
361 if(this.activeDocument.documentType === "htm" || this.activeDocument.documentType === "html") this.application.ninja.stage.toggleCanvas(); 365 //if(this.activeDocument.documentType === "htm" || this.activeDocument.documentType === "html") this.application.ninja.stage.toggleCanvas();
362 } 366 }
363 } 367 }
364 }, 368 },
@@ -415,7 +419,7 @@ _createTextAreaElement: {
415 textArea.id = "code"; 419 textArea.id = "code";
416 textArea.name = "code"; 420 textArea.name = "code";
417 421
418 codeMirrorDiv.appendChild(textArea); 422 //codeMirrorDiv.appendChild(textArea);
419 423
420// if(!this._textHolder) this._textHolder = document.getElementById("codeViewContainer"); 424// if(!this._textHolder) this._textHolder = document.getElementById("codeViewContainer");
421// this._textHolder.appendChild(codeMirrorDiv); 425// this._textHolder.appendChild(codeMirrorDiv);
diff --git a/js/io/system/coreioapi.js b/js/io/system/coreioapi.js
index 5deeae73..43812b3c 100755
--- a/js/io/system/coreioapi.js
+++ b/js/io/system/coreioapi.js
@@ -134,9 +134,6 @@ exports.CoreIoApi = Montage.create(Component, {
134 directoryServiceURL: { 134 directoryServiceURL: {
135 enumerable: false, 135 enumerable: false,
136 get: function() { 136 get: function() {
137 if(!this.rootUrl){
138 this.rootUrl = 'http://localhost:16380';
139 }
140 return String(this.rootUrl+this._directoryServiceURL); 137 return String(this.rootUrl+this._directoryServiceURL);
141 }, 138 },
142 set: function(value) { 139 set: function(value) {
diff --git a/js/io/utils/file-utils.js b/js/io/utils/file-utils.js
index 0afdffc6..0a4d9687 100644
--- a/js/io/utils/file-utils.js
+++ b/js/io/utils/file-utils.js
@@ -4,8 +4,6 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot
4(c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. 4(c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved.
5</copyright> */ 5</copyright> */
6 6
7var fileSystem = require("js/io/system/coreioapi").CoreIoApi;
8
9var FileUtils = exports.FileUtils = Object.create(Object.prototype, { 7var FileUtils = exports.FileUtils = Object.create(Object.prototype, {
10 8
11 /*** 9 /***
@@ -61,7 +59,7 @@ var FileUtils = exports.FileUtils = Object.create(Object.prototype, {
61 59
62 uri = ""+folderUri+fileUri; 60 uri = ""+folderUri+fileUri;
63 61
64 response = fileSystem.fileExists({"uri":uri}); 62 response = this.application.ninja.coreIoApi.fileExists({"uri":uri});
65 if(!!response && response.success && (response.status === 204)){ 63 if(!!response && response.success && (response.status === 204)){
66 status = true; 64 status = true;
67 }else if(!!response && response.success && (response.status === 404)){ 65 }else if(!!response && response.success && (response.status === 404)){