diff options
author | Valerio Virgillito | 2012-05-22 14:42:43 -0700 |
---|---|---|
committer | Valerio Virgillito | 2012-05-22 14:42:43 -0700 |
commit | 9b6da637d9654727426c6d78f17e3804bbd84ce5 (patch) | |
tree | 84f2d0eeb8af2bbd7325d66114c9cec6397bebcd | |
parent | 58df45d43614b5364aa84832c7c0aa06a9d086fc (diff) | |
download | ninja-9b6da637d9654727426c6d78f17e3804bbd84ce5.tar.gz |
fixing a few document switching issues.
Signed-off-by: Valerio Virgillito <valerio@motorola.com>
-rwxr-xr-x | js/components/layout/document-entry.reel/document-entry.js | 2 | ||||
-rwxr-xr-x | js/controllers/document-controller.js | 90 | ||||
-rwxr-xr-x | js/document/document-html.js | 2 | ||||
-rwxr-xr-x | js/document/views/base.js | 2 |
4 files changed, 46 insertions, 50 deletions
diff --git a/js/components/layout/document-entry.reel/document-entry.js b/js/components/layout/document-entry.reel/document-entry.js index 24c7737c..50b3624c 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.documentController.activeDocument, this.application.ninja.documentController._findDocumentByUUID(this._uuid)); | 125 | this.application.ninja.documentController.switchDocuments(this.application.ninja.currentDocument, 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 b4aff2f0..d99fadbb 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js | |||
@@ -9,12 +9,8 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot | |||
9 | var Montage = require("montage/core/core").Montage, | 9 | var Montage = require("montage/core/core").Montage, |
10 | Component = require("montage/ui/component").Component, | 10 | Component = require("montage/ui/component").Component, |
11 | Uuid = require("montage/core/uuid").Uuid, | 11 | Uuid = require("montage/core/uuid").Uuid, |
12 | HTMLDocument = require("js/document/html-document").HTMLDocument, | 12 | HTMLDocument = require("js/document/document-html").HtmlDocument, |
13 | TextDocument = require("js/document/text-document").TextDocument; | 13 | TextDocument = require("js/document/document-text").TextDocument; |
14 | |||
15 | // New Document Objects | ||
16 | var Document_HTML = require("js/document/document-html").HtmlDocument; | ||
17 | var Document_Text = require("js/document/document-text").TextDocument; | ||
18 | //////////////////////////////////////////////////////////////////////// | 14 | //////////////////////////////////////////////////////////////////////// |
19 | // | 15 | // |
20 | var DocumentController = exports.DocumentController = Montage.create(Component, { | 16 | var DocumentController = exports.DocumentController = Montage.create(Component, { |
@@ -308,8 +304,8 @@ var DocumentController = exports.DocumentController = Montage.create(Component, | |||
308 | this.activeDocument.uri = fileUri; | 304 | this.activeDocument.uri = fileUri; |
309 | //save a new file | 305 | //save a new file |
310 | //use the ioMediator.fileSaveAll when implemented | 306 | //use the ioMediator.fileSaveAll when implemented |
311 | this.activeDocument.model.file.name=filename; | 307 | this.activeDocument.model.file.name = filename; |
312 | this.activeDocument.model.file.uri=fileUri; | 308 | this.activeDocument.model.file.uri = fileUri; |
313 | this.activeDocument.model.save(); | 309 | this.activeDocument.model.save(); |
314 | } | 310 | } |
315 | }, | 311 | }, |
@@ -334,11 +330,11 @@ var DocumentController = exports.DocumentController = Montage.create(Component, | |||
334 | 330 | ||
335 | //Open in designer view | 331 | //Open in designer view |
336 | this._hackRootFlag = false; | 332 | this._hackRootFlag = false; |
337 | Montage.create(Document_HTML).init(file, this, this._onOpenDocument, 'design', template); | 333 | Montage.create(HTMLDocument).init(file, this, this._onOpenDocument, 'design', template); |
338 | break; | 334 | break; |
339 | default: | 335 | default: |
340 | //Open in code view | 336 | //Open in code view |
341 | Montage.create(Document_Text).init(file, this, this._onOpenTextDocument, 'code'); | 337 | Montage.create(TextDocument).init(file, this, this._onOpenTextDocument, 'code'); |
342 | break; | 338 | break; |
343 | } | 339 | } |
344 | } | 340 | } |
@@ -404,17 +400,16 @@ var DocumentController = exports.DocumentController = Montage.create(Component, | |||
404 | 400 | ||
405 | this.application.ninja.stage.hideRulers(); | 401 | this.application.ninja.stage.hideRulers(); |
406 | 402 | ||
407 | // document.getElementById("iframeContainer").style.display="block"; | ||
408 | |||
409 | this.application.ninja.stage.hideCanvas(true); | 403 | this.application.ninja.stage.hideCanvas(true); |
410 | 404 | ||
405 | //TODO: Use references for those instead of calling getElementById | ||
411 | if(this._documents.length === 0){ | 406 | if(this._documents.length === 0){ |
412 | document.getElementById("iframeContainer").style.display="block"; | 407 | document.getElementById("iframeContainer").style.display="block"; |
413 | document.getElementById("codeViewContainer").style.display="block"; | 408 | document.getElementById("codeViewContainer").style.display="block"; |
414 | } | 409 | } |
415 | 410 | ||
416 | |||
417 | NJevent("closeDocument", doc.model.file.uri); | 411 | NJevent("closeDocument", doc.model.file.uri); |
412 | |||
418 | //TODO: Delete object here | 413 | //TODO: Delete object here |
419 | } | 414 | } |
420 | }, | 415 | }, |
@@ -458,8 +453,6 @@ var DocumentController = exports.DocumentController = Montage.create(Component, | |||
458 | if(this.activeDocument) { | 453 | if(this.activeDocument) { |
459 | // There is a document currently opened | 454 | // There is a document currently opened |
460 | currentDocument = this.activeDocument; | 455 | currentDocument = this.activeDocument; |
461 | |||
462 | //this.application.ninja.stage.stageView.restoreAllPanels(); | ||
463 | } else { | 456 | } else { |
464 | // There is no document opened | 457 | // There is no document opened |
465 | 458 | ||
@@ -486,16 +479,17 @@ var DocumentController = exports.DocumentController = Montage.create(Component, | |||
486 | 479 | ||
487 | _onOpenTextDocument: { | 480 | _onOpenTextDocument: { |
488 | value: function(doc) { | 481 | value: function(doc) { |
489 | var currentDocument=null; | 482 | var currentDocument = null; |
490 | if(this.activeDocument) { | 483 | if(this.activeDocument) { |
491 | // There is a document currently opened | 484 | // There is a document currently opened |
492 | currentDocument = this.activeDocument; | 485 | currentDocument = this.activeDocument; |
493 | } | 486 | } |
494 | 487 | ||
495 | this.application.ninja.stage._scrollFlag = false; // TODO HACK to prevent type error on Hide/Show Iframe | 488 | this.application.ninja.currentDocument = this.activeDocument = doc; |
496 | this.activeDocument = doc; | 489 | |
497 | document.getElementById("iframeContainer").style.display = "none"; | 490 | document.getElementById("iframeContainer").style.display = "none"; |
498 | this.application.ninja.codeEditorController.applySettings(); | 491 | this.application.ninja.codeEditorController.applySettings(); |
492 | |||
499 | this.switchDocuments(currentDocument, doc, true); | 493 | this.switchDocuments(currentDocument, doc, true); |
500 | } | 494 | } |
501 | }, | 495 | }, |
@@ -503,57 +497,57 @@ var DocumentController = exports.DocumentController = Montage.create(Component, | |||
503 | switchDocuments: { | 497 | switchDocuments: { |
504 | value: function(currentDocument, newDocument, didCreate) { | 498 | value: function(currentDocument, newDocument, didCreate) { |
505 | 499 | ||
506 | if(currentDocument && currentDocument.currentView === "design") { | ||
507 | currentDocument.serializeDocument(); | ||
508 | this.application.ninja.selectionController._selectionContainer = null; | ||
509 | currentDocument.model.views.design.propertiesPanel.clear(); | ||
510 | } | ||
511 | |||
512 | if(currentDocument) { | 500 | if(currentDocument) { |
513 | currentDocument.model.currentView.hide(); | 501 | if(currentDocument.currentView === "design") { |
502 | currentDocument.serializeDocument(); | ||
503 | this.application.ninja.selectionController._selectionContainer = null; | ||
504 | currentDocument.model.views.design.propertiesPanel.clear(); | ||
505 | } | ||
506 | |||
514 | currentDocument.model.isActive = false; | 507 | currentDocument.model.isActive = false; |
515 | } | ||
516 | if(currentDocument && newDocument && (currentDocument.model.parentContainer !== newDocument.model.parentContainer)){ | ||
517 | currentDocument.model.parentContainer.style["display"] = "none"; | ||
518 | } | ||
519 | 508 | ||
520 | if(newDocument && newDocument.currentView === "code"){ | 509 | currentDocument.model.currentView.hide(); |
521 | this.application.ninja.stage.showCodeViewBar(true); | ||
522 | this.application.ninja.stage.collapseAllPanels(); | ||
523 | this.application.ninja.stage.hideCanvas(true); | ||
524 | this.application.ninja.stage.hideRulers(); | ||
525 | 510 | ||
526 | newDocument.model.views.code.editor.focus(); | 511 | if(currentDocument.model.parentContainer !== newDocument.model.parentContainer) { |
512 | currentDocument.model.parentContainer.style["display"] = "none"; | ||
513 | newDocument.model.parentContainer.style["display"] = "block"; | ||
514 | } | ||
527 | 515 | ||
528 | }else if(currentDocument && newDocument && newDocument.currentView === "design"){ | 516 | if(currentDocument.currentView === "code" && newDocument.currentView === "design") { |
529 | this.application.ninja.stage.showCodeViewBar(false); | 517 | this.application.ninja.stage.showCodeViewBar(false); |
530 | this.application.ninja.stage.restoreAllPanels(); | 518 | this.application.ninja.stage.restoreAllPanels(); |
531 | this.application.ninja.stage.hideCanvas(false); | 519 | this.application.ninja.stage.hideCanvas(false); |
532 | this.application.ninja.stage.showRulers(); | 520 | this.application.ninja.stage.showRulers(); |
521 | } else if(currentDocument.currentView === "design" && newDocument.currentView === "code") { | ||
522 | this.application.ninja.stage.showCodeViewBar(true); | ||
523 | this.application.ninja.stage.collapseAllPanels(); | ||
524 | this.application.ninja.stage.hideCanvas(true); | ||
525 | this.application.ninja.stage.hideRulers(); | ||
526 | } | ||
533 | } | 527 | } |
534 | 528 | ||
535 | this.application.ninja.stage.clearAllCanvas(); | 529 | this.application.ninja.stage.clearAllCanvas(); |
536 | 530 | ||
537 | if(didCreate) { | 531 | if(didCreate) { |
538 | newDocument.model.currentView.show(); | 532 | newDocument.model.currentView.show(); |
539 | newDocument.model.parentContainer.style["display"] = "block"; | 533 | |
540 | if(newDocument.currentView === "design") { | 534 | if(newDocument.currentView === "design") { |
541 | newDocument.model.views.design.iframe.style.opacity = 1; | ||
542 | NJevent("onOpenDocument", newDocument); | 535 | NJevent("onOpenDocument", newDocument); |
536 | } else { | ||
537 | newDocument.model.parentContainer.style["display"] = "block"; | ||
543 | } | 538 | } |
544 | } | 539 | } else { |
545 | else { | ||
546 | this.activeDocument = newDocument; | 540 | this.activeDocument = newDocument; |
547 | 541 | ||
548 | newDocument.model.currentView.show(); | 542 | newDocument.model.currentView.show(); |
549 | if(currentDocument && newDocument && (currentDocument.model.parentContainer !== newDocument.model.parentContainer)){ | ||
550 | newDocument.model.par |