aboutsummaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorAnanya Sen2012-02-03 17:22:48 -0800
committerAnanya Sen2012-02-03 17:22:48 -0800
commit1daf146c849a0a8dbd2b61b14218c9a39bdee3a7 (patch)
treeaf5568f4adac1371ee8b533c34198fb72545e778 /js
parent7618cabe1945acc6392c48f3b57820f67f7973b0 (diff)
downloadninja-1daf146c849a0a8dbd2b61b14218c9a39bdee3a7.tar.gz
added editor tab save while switching code view tabs,
integrated new file dialog with io mediator to open the new file in a new tab Signed-off-by: Ananya Sen <Ananya.Sen@motorola.com>
Diffstat (limited to 'js')
-rwxr-xr-xjs/components/layout/document-entry.reel/document-entry.js2
-rwxr-xr-xjs/io/document/base-document.js7
-rwxr-xr-xjs/io/document/document-controller.js41
-rwxr-xr-xjs/io/document/html-document.js28
-rwxr-xr-xjs/io/document/text-document.js16
-rwxr-xr-xjs/io/system/coreioapi.js1
-rwxr-xr-xjs/io/system/projectio.js2
-rw-r--r--js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js5
-rw-r--r--js/mediators/io-mediator.js9
-rwxr-xr-xjs/ninja.reel/ninja.html8
-rwxr-xr-xjs/stage/stage-view.reel/stage-view.css2
-rwxr-xr-xjs/stage/stage-view.reel/stage-view.js96
12 files changed, 147 insertions, 70 deletions
diff --git a/js/components/layout/document-entry.reel/document-entry.js b/js/components/layout/document-entry.reel/document-entry.js
index 1431e76f..2a33548a 100755
--- a/js/components/layout/document-entry.reel/document-entry.js
+++ b/js/components/layout/document-entry.reel/document-entry.js
@@ -101,7 +101,7 @@ exports.DocumentEntry = Montage.create(Component, {
101 this.application.ninja.documentController.closeDocument(this._uuid); 101 this.application.ninja.documentController.closeDocument(this._uuid);
102 } else { 102 } else {
103 if(!this._document.isActive) { 103 if(!this._document.isActive) {
104 this.application.ninja.stage.stageView.switchCodeView(this.application.ninja.documentController._findDocumentByUUID(this._uuid)); 104 this.application.ninja.stage.stageView.switchDocument(this.application.ninja.documentController._findDocumentByUUID(this._uuid));
105 } 105 }
106 } 106 }
107 } 107 }
diff --git a/js/io/document/base-document.js b/js/io/document/base-document.js
index d3601de5..ecc92447 100755
--- a/js/io/document/base-document.js
+++ b/js/io/document/base-document.js
@@ -87,7 +87,12 @@ var BaseDocument = exports.BaseDocument = Montage.create(Montage, {
87 value: function() { 87 value: function() {
88 // Have the XHR here? 88 // Have the XHR here?
89 } 89 }
90 } 90 },
91 91
92 save:{
93 value:function(){
94 //base function - to be overridden
95 }
96 }
92 97
93}); \ No newline at end of file 98}); \ No newline at end of file
diff --git a/js/io/document/document-controller.js b/js/io/document/document-controller.js
index 7cc0eeeb..b900dee4 100755
--- a/js/io/document/document-controller.js
+++ b/js/io/document/document-controller.js
@@ -103,7 +103,32 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
103 103
104 createNewFile:{ 104 createNewFile:{
105 value:function(newFileObj){ 105 value:function(newFileObj){
106 //console.log(newFileObj); 106 //console.log(newFileObj);//contains the template uri and the new file uri
107 if(!newFileObj) return;
108 this.application.ninja.ioMediator.fileNew(newFileObj.newFilePath, newFileObj.fileTemplateUri, this.openNewFile, this);
109
110 if((newFileObj.fileExtension !== ".html") && (newFileObj.fileExtension !== ".htm")){//open code view
111
112 }else{
113 //open design view
114 }
115 }
116 },
117
118 /**
119 * Public method
120 * doc contains:
121 * type : file type, like js, css, etc
122 * name : file name
123 * source : file content
124 * uri : file uri
125 */
126 openNewFile:{
127 value:function(doc){
128 if(!doc){
129 doc = {"type": "js", "name": "filename", "source": "test file content", "uri": "/fs/fsd/"} ;
130 }
131 this.openDocument(doc);
107 } 132 }
108 }, 133 },
109 134
@@ -160,7 +185,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
160 newDoc.initialize(doc, docUuid, textArea, textArea.parentNode); 185 newDoc.initialize(doc, docUuid, textArea, textArea.parentNode);
161 186
162 // Tmp this will be filled with the real content 187 // Tmp this will be filled with the real content
163 newDoc.textArea.innerHTML = doc.source; //this.tmpSourceForTesting; 188 newDoc.textArea.value = doc.source; //this.tmpSourceForTesting;
164 189
165 this.textDocumentOpened(newDoc); 190 this.textDocumentOpened(newDoc);
166 191
@@ -175,7 +200,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
175 textDocumentOpened: { 200 textDocumentOpened: {
176 value: function(doc) { 201 value: function(doc) {
177 202
178 this.activeDocument = doc; 203
179 204
180 this.application.ninja.stage.stageView.createTextView(doc); 205 this.application.ninja.stage.stageView.createTextView(doc);
181 206
@@ -377,7 +402,10 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
377 value: function() { 402 value: function() {
378 if(this.activeDocument) { 403 if(this.activeDocument) {
379 this.activeDocument.container.style["display"] = "none"; 404 this.activeDocument.container.style["display"] = "none";
380 //if(this.activeDocument.documentType === "htm" || this.activeDocument.documentType === "html") this.application.ninja.stage.toggleCanvas(); 405 if(this.activeDocument.currentView === "design" || this.activeDocument.currentView === "design"){
406 this.activeDocument.container.parentNode.style["display"] = "none";
407 this.application.ninja.stage.hideCanvas(true);
408 }
381 } 409 }
382 } 410 }
383 }, 411 },
@@ -386,7 +414,10 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
386 value: function() { 414 value: function() {
387 if(this.activeDocument) { 415 if(this.activeDocument) {
388 this.activeDocument.container.style["display"] = "block"; 416 this.activeDocument.container.style["display"] = "block";
389 //if(this.activeDocument.documentType === "htm" || this.activeDocument.documentType === "html") this.application.ninja.stage.toggleCanvas(); 417 if(this.activeDocument.currentView === "design" || this.activeDocument.currentView === "design"){
418 this.activeDocument.container.parentNode.style["display"] = "block";
419 this.application.ninja.stage.hideCanvas(false);
420 }
390 } 421 }
391 } 422 }
392 }, 423 },
diff --git a/js/io/document/html-document.js b/js/io/document/html-document.js
index fc7dd05b..24d4e7e4 100755
--- a/js/io/document/html-document.js
+++ b/js/io/document/html-document.js
@@ -43,9 +43,16 @@ var HTMLDocument = exports.HTMLDocument = Montage.create(baseDocumentModule.Base
43 } 43 }
44 }, 44 },
45 45
46
46 // PUBLIC MEMBERS 47 // PUBLIC MEMBERS
47 cssLoadInterval: { value: null, enumerable: false }, 48 cssLoadInterval: { value: null, enumerable: false },
48 49
50 codeViewDocument:{
51 writable: true,
52 enumerable: true,
53 value:null
54 },
55
49 /* 56 /*
50 * PUBLIC API 57 * PUBLIC API
51 */ 58 */
@@ -432,5 +439,26 @@ var HTMLDocument = exports.HTMLDocument = Montage.create(baseDocumentModule.Base
432 */ 439 */
433 } 440 }
434 } 441 }
442 },
443
444 /**
445 * public method
446 * parameter:
447 * removeCodeMirrorDivFlag - for code view, tell to remove the codemirror div after saving
448 */
449 save:{
450 value:function(removeCodeMirrorDivFlag){
451 if(this.currentView === "design"){
452 //generate html and save
453 }else if((this.currentView === "code") && (this.codeViewDocument !== null)){
454 if(removeCodeMirrorDivFlag === true){
455 this.codeViewDocument.save(true);
456 }else{
457 this.codeViewDocument.save();
458 }
459 //persist to filesystem
460 }
461
462 }
435 } 463 }
436}); \ No newline at end of file 464}); \ No newline at end of file
diff --git a/js/io/document/text-document.js b/js/io/document/text-document.js
index 156aaacb..a768779f 100755
--- a/js/io/document/text-document.js
+++ b/js/io/document/text-document.js
@@ -85,6 +85,22 @@ var TextDocument = exports.TextDocument = Montage.create(baseDocumentModule.Base
85 85
86 xhr.send(''); 86 xhr.send('');
87 } 87 }
88 },
89
90 /**
91 * public method
92 * parameter:
93 * removeCodeMirrorDivFlag - for code view, tell to remove the codemirror div after saving
94 */
95 save:{
96 value:function(removeCodeMirrorDivFlag){
97 this.editor.save();
98 if(removeCodeMirrorDivFlag === true){
99 var codemirrorDiv = this.textArea.parentNode.querySelector(".CodeMirror");
100 if(!!codemirrorDiv){codemirrorDiv.parentNode.removeChild(codemirrorDiv);}
101 }
102 //persist to filesystem
103 }
88 } 104 }
89 105
90}); \ No newline at end of file 106}); \ No newline at end of file
diff --git a/js/io/system/coreioapi.js b/js/io/system/coreioapi.js
index 5379cbfc..115fbf64 100755
--- a/js/io/system/coreioapi.js
+++ b/js/io/system/coreioapi.js
@@ -1064,6 +1064,7 @@ exports.CoreIoApi = Montage.create(Component, {
1064 /*** 1064 /***
1065 * checks for valid uri pattern 1065 * checks for valid uri pattern
1066 * also flags if Windows uri pattern and Unix uri patterns are mixed 1066 * also flags if Windows uri pattern and Unix uri patterns are mixed
1067 * Todo: need to augment when files can be accessed via other protocols like http, ftp, ssh, etc.
1067 */ 1068 */
1068 isValidUri:{ 1069 isValidUri:{
1069 value: function(uri){ 1070 value: function(uri){