aboutsummaryrefslogtreecommitdiff
path: root/js/io/document
diff options
context:
space:
mode:
Diffstat (limited to 'js/io/document')
-rwxr-xr-xjs/io/document/base-document.js5
-rwxr-xr-xjs/io/document/document-controller.js34
-rwxr-xr-xjs/io/document/html-document.js23
-rwxr-xr-xjs/io/document/text-document.js1
4 files changed, 23 insertions, 40 deletions
diff --git a/js/io/document/base-document.js b/js/io/document/base-document.js
index ecc92447..918b51ad 100755
--- a/js/io/document/base-document.js
+++ b/js/io/document/base-document.js
@@ -31,11 +31,6 @@ var BaseDocument = exports.BaseDocument = Montage.create(Montage, {
31 set: function(value) { this._uri = value; } 31 set: function(value) { this._uri = value; }
32 }, 32 },
33 33
34 externalUri: {
35 get: function() { return this._externalUri; },
36 set: function(value) { this._externalUri = value; }
37 },
38
39 documentType: { 34 documentType: {
40 get: function() { return this._documentType; }, 35 get: function() { return this._documentType; },
41 set: function(value) { this._documentType = value; } 36 set: function(value) { this._documentType = value; }
diff --git a/js/io/document/document-controller.js b/js/io/document/document-controller.js
index ca6b4533..51575a24 100755
--- a/js/io/document/document-controller.js
+++ b/js/io/document/document-controller.js
@@ -239,45 +239,25 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
239 value: function(id) { 239 value: function(id) {
240 240
241 //if file dirty then save 241 //if file dirty then save
242 if(this.activeDocument.dirtyFlag === true){
243 this.activeDocument.save(true);
244 this.activeDocument.dirtyFlag=false;
245 }
242 246
243 var doc = this._findDocumentByUUID(id); 247 var doc = this._findDocumentByUUID(id);
244 this._removeDocumentView(doc.container); 248 this._removeDocumentView(doc.container);
245 249
250 var closeDocumentIndex = this._findIndexByUUID(id);
246 this._documents.splice(this._findIndexByUUID(id), 1); 251 this._documents.splice(this._findIndexByUUID(id), 1);
247 252
248 if(this.activeDocument.uuid === id && this._documents.length > 0) { 253 if(this.activeDocument.uuid === id && this._documents.length > 0) {
249
250 var closeDocumentIndex = this._findIndexByUUID(id);
251 var nextDocumentIndex = -1 ; 254 var nextDocumentIndex = -1 ;
252 if((this._documents.length > 0) && (closeDocumentIndex === 0)){ 255 if((this._documents.length > 0) && (closeDocumentIndex === 0)){
253 nextDocumentIndex = 1; 256 nextDocumentIndex = 1;
254 }else if((this._documents.length > 0) && (closeDocumentIndex > 0)){ 257 }else if((this._documents.length > 0) && (closeDocumentIndex > 0)){
255 nextDocumentIndex = closeDocumentIndex - 1; 258 nextDocumentIndex = closeDocumentIndex - 1;
256 } 259 }
257 260 this.application.ninja.stage.stageView.switchDocument(this._documents[nextDocumentIndex]);
258 //remove the codemirror div if this is for a code view
259 /////test
260
261 ////end- test
262
263 this.switchDocument(this._documents[0].uuid);
264
265 }
266 }
267 },
268
269 switchDocument: {
270 value: function(id) {
271 this._hideCurrentDocument();
272 this.activeDocument = this._findDocumentByUUID(id);
273
274 this.application.ninja.stage._scrollFlag = false; // TODO HACK to prevent type error on Hide/Show Iframe
275 this._showCurrentDocument();
276
277 if(this.activeDocument.documentType === "htm" || this.activeDocument.documentType === "html") {
278 this.application.ninja.stage._scrollFlag = true; // TODO HACK to prevent type error on Hide/Show Iframe
279 // TODO dispatch event here
280// appDelegateModule.MyAppDelegate.onSetActiveDocument();
281 } 261 }
282 } 262 }
283 }, 263 },
@@ -406,6 +386,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
406 if(this.activeDocument.currentView === "design" || this.activeDocument.currentView === "design"){ 386 if(this.activeDocument.currentView === "design" || this.activeDocument.currentView === "design"){
407 this.activeDocument.container.parentNode.style["display"] = "none"; 387 this.activeDocument.container.parentNode.style["display"] = "none";
408 this.application.ninja.stage.hideCanvas(true); 388 this.application.ninja.stage.hideCanvas(true);
389 this.application.ninja.stage.stageView.hideRulers();
409 } 390 }
410 } 391 }
411 } 392 }
@@ -418,6 +399,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
418 if(this.activeDocument.currentView === "design" || this.activeDocument.currentView === "design"){ 399 if(this.activeDocument.currentView === "design" || this.activeDocument.currentView === "design"){
419 this.activeDocument.container.parentNode.style["display"] = "block"; 400 this.activeDocument.container.parentNode.style["display"] = "block";
420 this.application.ninja.stage.hideCanvas(false); 401 this.application.ninja.stage.hideCanvas(false);
402 this.application.ninja.stage.stageView.showRulers();
421 } 403 }
422 } 404 }
423 } 405 }
diff --git a/js/io/document/html-document.js b/js/io/document/html-document.js
index da1bbe4a..8e1eb614 100755
--- a/js/io/document/html-document.js
+++ b/js/io/document/html-document.js
@@ -449,17 +449,22 @@ var HTMLDocument = exports.HTMLDocument = Montage.create(baseDocumentModule.Base
449 */ 449 */
450 save:{ 450 save:{
451 value:function(removeCodeMirrorDivFlag){ 451 value:function(removeCodeMirrorDivFlag){
452 if(this.currentView === "design"){ 452 try{
453 //generate html and save 453 if(this.currentView === "design"){
454 }else if((this.currentView === "code") && (this.codeViewDocument !== null)){ 454 //generate html and save
455 if(removeCodeMirrorDivFlag === true){ 455 }else if((this.currentView === "code") && (this.codeViewDocument !== null)){
456 this.codeViewDocument.save(true); 456 if(removeCodeMirrorDivFlag === true){
457 }else{ 457 this.codeViewDocument.save(true);
458 this.codeViewDocument.save(); 458 }else{
459 this.codeViewDocument.save();
460 }
461 //persist to filesystem
459 } 462 }
460 //persist to filesystem 463 this.dirtyFlag=false;
464 }catch(e){
465 console.log("Error while saving "+this.uri);
466 console.log(e.stack);
461 } 467 }
462
463 } 468 }
464 } 469 }
465}); \ No newline at end of file 470}); \ No newline at end of file
diff --git a/js/io/document/text-document.js b/js/io/document/text-document.js
index a768779f..683c513c 100755
--- a/js/io/document/text-document.js
+++ b/js/io/document/text-document.js
@@ -95,6 +95,7 @@ var TextDocument = exports.TextDocument = Montage.create(baseDocumentModule.Base
95 save:{ 95 save:{
96 value:function(removeCodeMirrorDivFlag){ 96 value:function(removeCodeMirrorDivFlag){
97 this.editor.save(); 97 this.editor.save();
98 this.dirtyFlag=false;
98 if(removeCodeMirrorDivFlag === true){ 99 if(removeCodeMirrorDivFlag === true){
99 var codemirrorDiv = this.textArea.parentNode.querySelector(".CodeMirror"); 100 var codemirrorDiv = this.textArea.parentNode.querySelector(".CodeMirror");
100 if(!!codemirrorDiv){codemirrorDiv.parentNode.removeChild(codemirrorDiv);} 101 if(!!codemirrorDiv){codemirrorDiv.parentNode.removeChild(codemirrorDiv);}