diff options
Diffstat (limited to 'js')
-rwxr-xr-x | js/components/layout/document-entry.reel/document-entry.js | 2 | ||||
-rwxr-xr-x | js/controllers/document-controller.js | 105 | ||||
-rwxr-xr-x | js/document/models/text.js | 4 | ||||
-rwxr-xr-x | js/document/views/code.js | 54 | ||||
-rwxr-xr-x | js/stage/stage-view.reel/stage-view.js | 14 | ||||
-rwxr-xr-x | js/stage/stage.reel/stage.js | 44 |
6 files changed, 124 insertions, 99 deletions
diff --git a/js/components/layout/document-entry.reel/document-entry.js b/js/components/layout/document-entry.reel/document-entry.js index 50b3624c..24c7737c 100755 --- a/js/components/layout/document-entry.reel/document-entry.js +++ b/js/components/layout/document-entry.reel/document-entry.js | |||
@@ -122,7 +122,7 @@ exports.DocumentEntry = Montage.create(Component, { | |||
122 | this.application.ninja.documentController.closeFile(this.application.ninja.documentController._findDocumentByUUID(this._uuid)); | 122 | this.application.ninja.documentController.closeFile(this.application.ninja.documentController._findDocumentByUUID(this._uuid)); |
123 | } else { | 123 | } else { |
124 | if(!this.active) { | 124 | if(!this.active) { |
125 | this.application.ninja.documentController.switchDocuments(this.application.ninja.currentDocument, this.application.ninja.documentController._findDocumentByUUID(this._uuid)); | 125 | this.application.ninja.documentController.switchDocuments(this.application.ninja.documentController.activeDocument, this.application.ninja.documentController._findDocumentByUUID(this._uuid)); |
126 | } | 126 | } |
127 | } | 127 | } |
128 | } | 128 | } |
diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index 814a30e1..26c3ebaa 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js | |||
@@ -52,10 +52,6 @@ var DocumentController = exports.DocumentController = Montage.create(Component, | |||
52 | if(!!this._activeDocument){ | 52 | if(!!this._activeDocument){ |
53 | if(this._documents.indexOf(doc) === -1) this._documents.push(doc); | 53 | if(this._documents.indexOf(doc) === -1) this._documents.push(doc); |
54 | this._activeDocument.isActive = true; | 54 | this._activeDocument.isActive = true; |
55 | |||
56 | if(!!this._activeDocument.editor){ | ||
57 | this._activeDocument.editor.focus(); | ||
58 | } | ||
59 | } | 55 | } |
60 | } | 56 | } |
61 | }, | 57 | }, |
@@ -312,10 +308,9 @@ var DocumentController = exports.DocumentController = Montage.create(Component, | |||
312 | this.activeDocument.uri = fileUri; | 308 | this.activeDocument.uri = fileUri; |
313 | //save a new file | 309 | //save a new file |
314 | //use the ioMediator.fileSaveAll when implemented | 310 | //use the ioMediator.fileSaveAll when implemented |
315 | this.activeDocument._userDocument.name=filename; | 311 | this.activeDocument.model.file.name=filename; |
316 | this.activeDocument._userDocument.root=destination; | 312 | this.activeDocument.model.file.uri=fileUri; |
317 | this.activeDocument._userDocument.uri=fileUri; | 313 | this.activeDocument.model.save(); |
318 | this.application.ninja.ioMediator.fileSave(this.activeDocument.save(), this.fileSaveResult.bind(this)); | ||
319 | // | 314 | // |
320 | } | 315 | } |
321 | }, | 316 | }, |
@@ -408,7 +403,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component, | |||
408 | 403 | ||
409 | this._activeDocument = null; | 404 | this._activeDocument = null; |
410 | 405 | ||
411 | this.application.ninja.stage.stageView.hideRulers(); | 406 | this.application.ninja.stage.hideRulers(); |
412 | 407 | ||
413 | // document.getElementById("iframeContainer").style.display="block"; | 408 | // document.getElementById("iframeContainer").style.display="block"; |
414 | 409 | ||
@@ -471,7 +466,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component, | |||
471 | 466 | ||
472 | // Show the rulers | 467 | // Show the rulers |
473 | // TODO: Move this indo design view | 468 | // TODO: Move this indo design view |
474 | this.application.ninja.stage.stageView.showRulers(); | 469 | this.application.ninja.stage.showRulers(); |
475 | 470 | ||
476 | // Show the canvas | 471 | // Show the canvas |
477 | this.application.ninja.stage.hideCanvas(false); | 472 | this.application.ninja.stage.hideCanvas(false); |
@@ -489,53 +484,81 @@ var DocumentController = exports.DocumentController = Montage.create(Component, | |||
489 | } | 484 | } |
490 | }, | 485 | }, |
491 | 486 | ||
487 | |||
488 | _onOpenTextDocument: { | ||
489 | value: function(doc) { | ||
490 | var currentDocument=null; | ||
491 | if(this.activeDocument) { | ||
492 | // There is a document currently opened | ||
493 | currentDocument = this.activeDocument; | ||
494 | } | ||
495 | |||
496 | this.application.ninja.stage._scrollFlag = false; // TODO HACK to prevent type error on Hide/Show Iframe | ||
497 | this.activeDocument = doc; | ||
498 | document.getElementById("iframeContainer").style.display = "none"; | ||
499 | this.application.ninja.codeEditorController.applySettings(); | ||
500 | this.switchDocuments(currentDocument, doc, true); | ||
501 | } | ||
502 | }, | ||
503 | |||
492 | switchDocuments: { | 504 | switchDocuments: { |
493 | value: function(currentDocument, newDocument, didCreate) { | 505 | value: function(currentDocument, newDocument, didCreate) { |
494 | 506 | ||
495 | if(currentDocument) { | 507 | if(currentDocument && currentDocument.currentView === "design") { |
496 | currentDocument.serializeDocument(); | 508 | currentDocument.serializeDocument(); |
497 | |||
498 | this.application.ninja.selectionController._selectionContainer = null; | 509 | this.application.ninja.selectionController._selectionContainer = null; |
499 | currentDocument.model.views.design.propertiesPanel.clear(); | 510 | currentDocument.model.views.design.propertiesPanel.clear(); |
500 | currentDocument.model.views.design.hide(); | ||
501 | } | 511 | } |
502 | 512 | ||
503 | this.application.ninja.stage.clearAllCanvas(); | 513 | if(currentDocument) { |
514 | currentDocument.model.currentView.hide(); | ||
515 | currentDocument.model.isActive = false; | ||
516 | } | ||
517 | if(currentDocument && newDocument && (currentDocument.model.parentContainer !== newDocument.model.parentContainer)){ | ||
518 | currentDocument.model.parentContainer.style["display"] = "none"; | ||
519 | } | ||
504 | 520 | ||
505 | if(didCreate) { | 521 | if(newDocument && newDocument.currentView === "code"){ |
506 | newDocument.model.views.design.iframe.style.opacity = 1; | 522 | this.application.ninja.stage.showCodeViewBar(true); |
507 | NJevent("onOpenDocument", newDocument); | 523 | this.application.ninja.stage.collapseAllPanels(); |
508 | } else { | 524 | this.application.ninja.stage.hideCanvas(true); |
509 | this.activeDocument = newDocument; | 525 | this.application.ninja.stage.hideRulers(); |
510 | newDocument.model.views.design.show(); | 526 | |
511 | newDocument.deserializeDocument(); | 527 | newDocument.model.views.code.editor.focus(); |
512 | NJevent("onSwitchDocument"); | 528 | |
529 | }else if(currentDocument && newDocument && newDocument.currentView === "design"){ | ||
530 | this.application.ninja.stage.showCodeViewBar(false); | ||
531 | this.application.ninja.stage.restoreAllPanels(); | ||
532 | this.application.ninja.stage.hideCanvas(false); | ||
533 | this.application.ninja.stage.showRulers(); | ||
513 | } | 534 | } |
514 | } | ||
515 | }, | ||
516 | 535 | ||
536 | this.application.ninja.stage.clearAllCanvas(); | ||
517 | 537 | ||
518 | _onOpenTextDocument: { | 538 | if(didCreate) { |
519 | value: function(doc) { | 539 | newDocument.model.currentView.show(); |
520 | if(this.activeDocument) { | 540 | newDocument.model.parentContainer.style["display"] = "block"; |
541 | if(newDocument.currentView === "design") { | ||
542 | newDocument.model.views.design.iframe.style.opacity = 1; | ||
543 | NJevent("onOpenDocument", newDocument); | ||
544 | } | ||
545 | } | ||
546 | else { | ||
547 | this.activeDocument = newDocument; | ||
521 | 548 | ||
522 | if(this.activeDocument.currentView === "design"){ | 549 | newDocument.model.currentView.show(); |
523 | this.activeDocument.saveAppState(); | 550 | if(currentDocument && newDocument && (currentDocument.model.parentContainer !== newDocument.model.parentContainer)){ |
524 | this.activeDocument.parentContainer.style["display"] = "none"; | 551 | newDocument.model.parentContainer.style["display"] = "block"; |
525 | this.application.ninja.stage.hideCanvas(true); | ||
526 | this.application.ninja.stage.stageView.hideRulers(); | ||
527 | } | 552 | } |
528 | 553 | ||
529 | this.activeDocument.container.style["display"] = "none"; | 554 | if(newDocument.currentView === "design") { |
555 | newDocument.deserializeDocument(); | ||
556 | NJevent("onSwitchDocument"); | ||
557 | }else{ | ||
558 | newDocument.model.isActive = true; | ||
559 | this.application.ninja.codeEditorController.applySettings();//should be called after activeDocument is updated | ||
560 | } | ||
530 | } | 561 | } |
531 | |||
532 | this.application.ninja.stage._scrollFlag = false; // TODO HACK to prevent type error on Hide/Show Iframe | ||
533 | this.activeDocument = doc; | ||
534 | //hide the iframe when switching to code view | ||
535 | document.getElementById("iframeContainer").style.display = "none"; | ||
536 | doc.model.views.code.showCodeViewBar(true); | ||
537 | this.application.ninja.codeEditorController.applySettings(); | ||
538 | doc.model.views.code.collapseAllPanels(); | ||
539 | } | 562 | } |
540 | }, | 563 | }, |
541 | 564 | ||
diff --git a/js/document/models/text.js b/js/document/models/text.js index fe02953c..d1252b7d 100755 --- a/js/document/models/text.js +++ b/js/document/models/text.js | |||
@@ -60,8 +60,8 @@ exports.TextDocumentModel = Montage.create(BaseDocumentModel, { | |||
60 | } | 60 | } |
61 | // | 61 | // |
62 | this.parentContainer.removeChild(this.views.code.textViewContainer); | 62 | this.parentContainer.removeChild(this.views.code.textViewContainer); |
63 | this.views.code.restoreAllPanels(); | 63 | this.application.ninja.stage.showCodeViewBar(false); |
64 | this.views.code.showCodeViewBar(false); | 64 | this.application.ninja.stage.restoreAllPanels(); |
65 | this.views.code = null; | 65 | this.views.code = null; |
66 | 66 | ||
67 | // | 67 | // |
diff --git a/js/document/views/code.js b/js/document/views/code.js index 711479a8..66d1c702 100755 --- a/js/document/views/code.js +++ b/js/document/views/code.js | |||
@@ -140,56 +140,30 @@ var CodeDocumentView = exports.CodeDocumentView = Montage.create(BaseDocumentVie | |||
140 | }, | 140 | }, |
141 | //////////////////////////////////////////////////////////////////// | 141 | //////////////////////////////////////////////////////////////////// |
142 | // | 142 | // |
143 | 143 | show: { | |
144 | showRulers:{ | 144 | value: function (callback) { |
145 | value:function(){ | 145 | this.textViewContainer.style.display = "block"; |
146 | this.application.ninja.rulerTop.style.display = "block"; | 146 | // |