From 646b269da2387582531258d14a3f2ff550617323 Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Tue, 14 Feb 2012 11:45:57 -0800 Subject: Cleaning up mediator --- js/controllers/document-controller.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'js/controllers/document-controller.js') diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index 84b994ce..7d38c600 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js @@ -104,16 +104,26 @@ DocumentController = exports.DocumentController = Montage.create(Component, { handleExecuteSave: { value: function(event) { //Text and HTML document classes should return the same save object for fileSave - this.application.ninja.ioMediator.fileSave(this.activeDocument.save(), this.clearDocumentDirtyFlag.bind(this)); + this.application.ninja.ioMediator.fileSave(this.activeDocument.save(), this.fileSaveResult.bind(this)); } }, - + //////////////////////////////////////////////////////////////////// + // + fileSaveResult: { + value: function (result) { + if(result.status === 204){ + this.clearDocumentDirtyFlag(); + } + } + }, + //////////////////////////////////////////////////////////////////// + + clearDocumentDirtyFlag:{ value: function(){ this.activeDocument.dirtyFlag = false; } }, - //////////////////////////////////////////////////////////////////// createNewFile:{ -- cgit v1.2.3 From a7952c5a16e2cae3fd1a459b03b9f16bba1004da Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Tue, 14 Feb 2012 13:23:20 -0800 Subject: Cleaning up Setting up a 'document' folder to handle all document related classes that in relation to IO --- js/controllers/document-controller.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'js/controllers/document-controller.js') diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index 7d38c600..9b412576 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js @@ -9,8 +9,8 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot var Montage = require("montage/core/core").Montage, Component = require("montage/ui/component").Component, Uuid = require("montage/core/uuid").Uuid, - HTMLDocument = require("js/io/document/html-document").HTMLDocument, - TextDocument = require("js/io/document/text-document").TextDocument, + HTMLDocument = require("js/document/models/html-document").HTMLDocument, + TextDocument = require("js/document/models/text-document").TextDocument, DocumentController; //////////////////////////////////////////////////////////////////////// // -- cgit v1.2.3 From 93c8f327d662a7693d1d6ca050a0efd15ebc18ed Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Tue, 14 Feb 2012 14:00:48 -0800 Subject: Merging TextDocument into BaseDocument Merged the text-document class with base-document, didn't make sense to have two classes for basic model of documents, the html-document class remain extending base-document to incorporate design view. These two classes might be renamed. --- js/controllers/document-controller.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'js/controllers/document-controller.js') diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index 9b412576..25f60cc5 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js @@ -10,7 +10,7 @@ var Montage = require("montage/core/core").Montage, Component = require("montage/ui/component").Component, Uuid = require("montage/core/uuid").Uuid, HTMLDocument = require("js/document/models/html-document").HTMLDocument, - TextDocument = require("js/document/models/text-document").TextDocument, + BaseDocument = require("js/document/models/base-document").BaseDocument, DocumentController; //////////////////////////////////////////////////////////////////////// // @@ -203,7 +203,7 @@ DocumentController = exports.DocumentController = Montage.create(Component, { break; default: //Open in code view - var code = Montage.create(TextDocument, {"source": {value: doc.content}}), docuuid = Uuid.generate(), textArea; + var code = Montage.create(BaseDocument, {"source": {value: doc.content}}), docuuid = Uuid.generate(), textArea; textArea = this.application.ninja.stage.stageView.createTextAreaElement(docuuid); code.initialize(doc, docuuid, textArea, textArea.parentNode); //code.init(doc.name, doc.uri, doc.extension, null, docuuid); -- cgit v1.2.3 From 68ce64a5a2f4a71b54d33916aaf1d57161302425 Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Tue, 14 Feb 2012 20:48:40 -0800 Subject: Reverting text/html document classes and setting up MVC folder structure Setting up the folder structure for the proposed set up for documents in Ninja. Reverted to have a temp HTML/Text document class. Tweak some UI for file pickers. --- js/controllers/document-controller.js | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-) (limited to 'js/controllers/document-controller.js') diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index 25f60cc5..f397ace7 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js @@ -9,8 +9,8 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot var Montage = require("montage/core/core").Montage, Component = require("montage/ui/component").Component, Uuid = require("montage/core/uuid").Uuid, - HTMLDocument = require("js/document/models/html-document").HTMLDocument, - BaseDocument = require("js/document/models/base-document").BaseDocument, + HTMLDocument = require("js/document/html-document").HTMLDocument, + TextDocument = require("js/document/text-document").TextDocument, DocumentController; //////////////////////////////////////////////////////////////////////// // @@ -28,13 +28,7 @@ DocumentController = exports.DocumentController = Montage.create(Component, { _iframeHolder: { value: null, enumerable: false }, _textHolder: { value: null, enumerable: false }, _codeMirrorCounter: {value: 1, enumerable: false}, - - tmpSourceForTesting: { - value: "function CodeMirror(place, givenOptions) {" + - "// Determine effective options based on given values and defaults." + - "var options = {}, defaults = CodeMirror.defaults; }" - }, - + activeDocument: { get: function() { return this._activeDocument; @@ -62,21 +56,12 @@ DocumentController = exports.DocumentController = Montage.create(Component, { this.eventManager.addEventListener("executeSave", this, false); this.eventManager.addEventListener("recordStyleChanged", this, false); - - // Temporary testing opening a new file after Ninja has loaded - this.eventManager.addEventListener("executeNewProject", this, false); } }, handleAppLoaded: { value: function() { - //this.openDocument({"type": "html"}); - } - }, - - handleExecuteNewProject: { - value: function() { - this.openDocument({"type": "html"}); + // } }, @@ -203,7 +188,7 @@ DocumentController = exports.DocumentController = Montage.create(Component, { break; default: //Open in code view - var code = Montage.create(BaseDocument, {"source": {value: doc.content}}), docuuid = Uuid.generate(), textArea; + var code = Montage.create(TextDocument, {"source": {value: doc.content}}), docuuid = Uuid.generate(), textArea; textArea = this.application.ninja.stage.stageView.createTextAreaElement(docuuid); code.initialize(doc, docuuid, textArea, textArea.parentNode); //code.init(doc.name, doc.uri, doc.extension, null, docuuid); -- cgit v1.2.3 From 729e32ee70b0dd30a3b498ed7d1636b1b5b56a43 Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Thu, 16 Feb 2012 11:18:21 -0800 Subject: Squashed commit of the following: commit 302ae3c1812086d976eb67c9cf693c43205f3904 Author: Ananya Sen Date: Thu Feb 16 11:13:05 2012 -0800 hide the rulers when no document is open Signed-off-by: Ananya Sen commit 2e766c9eaa98fa20f311b3eb2f892a1a240e90cf Author: Ananya Sen Date: Thu Feb 16 06:43:33 2012 -0800 file picker: Enable ok if user double clicks folder and enter it. Validate path if user enter it manually in addressbar. Signed-off-by: Ananya Sen commit 4937b39fb0cf542f57cdadc7d1e2ed9798f7ef87 Author: Ananya Sen Date: Wed Feb 15 16:09:14 2012 -0800 fixes to document tabbing Signed-off-by: Ananya Sen commit 56d2a8d11a73cd04c7f1bc20d1ded52b9c1242f2 Author: Ananya Sen Date: Wed Feb 15 10:54:38 2012 -0800 Revert "Revert "Creating NinjaTemplate to HTML function"" This reverts commit 2e308be9bec5e06d81b2905b65005a232f0a190d. Signed-off-by: Ananya Sen commit e2b97c951a9a5a0c4ff831d44fdd82177cbd82ad Author: Ananya Sen Date: Wed Feb 15 10:54:14 2012 -0800 Revert "Revert "Reverting text/html document classes and setting up MVC folder structure"" This reverts commit 9048cd50bf5e0a418d1d95498bb593961f72db36. Signed-off-by: Ananya Sen commit aead95ce4b2571356701229567bfde73d54bed93 Author: Ananya Sen Date: Wed Feb 15 10:53:55 2012 -0800 Revert "Revert "Cleaning up"" This reverts commit a90e3be8850b64e8e370aa8ff8cadaa448dd0c82. Signed-off-by: Ananya Sen commit a8d1a2e1f4f4ab7b9298bfbd1b49731785c79c3a Author: Ananya Sen Date: Wed Feb 15 10:52:56 2012 -0800 Revert "Revert "Merging TextDocument into BaseDocument"" This reverts commit b8782f2e3dd106accbb0160a98e6b498f26752ea. Signed-off-by: Ananya Sen commit e864dc319805e259b7ae39a9d4d96fac552a1f87 Author: Ananya Sen Date: Wed Feb 15 10:52:38 2012 -0800 Revert "merging from github.com/joseeight/ninja-internal/tree/FileIO is breaking opening html files… to trying to fix local build" This reverts commit 3cf1d19c5cdc9534d9c87cbc7d1fcf48e68daa42. Signed-off-by: Ananya Sen commit 3cf1d19c5cdc9534d9c87cbc7d1fcf48e68daa42 Author: Ananya Sen Date: Wed Feb 15 10:06:42 2012 -0800 merging from github.com/joseeight/ninja-internal/tree/FileIO is breaking opening html files… to trying to fix local build Signed-off-by: Ananya Sen commit b8782f2e3dd106accbb0160a98e6b498f26752ea Author: Ananya Sen Date: Wed Feb 15 10:01:59 2012 -0800 Revert "Merging TextDocument into BaseDocument" This reverts commit 93c8f327d662a7693d1d6ca050a0efd15ebc18ed. Conflicts: js/controllers/document-controller.js Signed-off-by: Ananya Sen commit a90e3be8850b64e8e370aa8ff8cadaa448dd0c82 Author: Ananya Sen Date: Wed Feb 15 09:58:37 2012 -0800 Revert "Cleaning up" This reverts commit a7952c5a16e2cae3fd1a459b03b9f16bba1004da. Conflicts: js/controllers/document-controller.js js/io/document/text-document.js Signed-off-by: Ananya Sen commit 9048cd50bf5e0a418d1d95498bb593961f72db36 Author: Ananya Sen Date: Wed Feb 15 09:51:12 2012 -0800 Revert "Reverting text/html document classes and setting up MVC folder structure" This reverts commit 68ce64a5a2f4a71b54d33916aaf1d57161302425. Signed-off-by: Ananya Sen commit 2e308be9bec5e06d81b2905b65005a232f0a190d Author: Ananya Sen Date: Wed Feb 15 09:50:20 2012 -0800 Revert "Creating NinjaTemplate to HTML function" This reverts commit e327eccb93e2bc513fcbb7ab302783d6bce83884. Signed-off-by: Ananya Sen --- js/controllers/document-controller.js | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) (limited to 'js/controllers/document-controller.js') diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index f397ace7..b1a22c1b 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js @@ -34,17 +34,17 @@ DocumentController = exports.DocumentController = Montage.create(Component, { return this._activeDocument; }, set: function(doc) { - if(this._activeDocument) this._activeDocument.isActive = false; - - if(this._documents.indexOf(doc) === -1) this._documents.push(doc); + if(!!this._activeDocument) this._activeDocument.isActive = false; this._activeDocument = doc; - this._activeDocument.isActive = true; + if(!!this._activeDocument){ - if(!!this._activeDocument.editor){ - this._activeDocument.editor.focus(); + if(this._documents.indexOf(doc) === -1) this._documents.push(doc); + this._activeDocument.isActive = true; + if(!!this._activeDocument.editor){ + this._activeDocument.editor.focus(); + } } - } }, @@ -184,7 +184,7 @@ DocumentController = exports.DocumentController = Montage.create(Component, { switch (doc.extension) { case 'html': case 'html': //Open in designer view - Montage.create(HTMLDocument).initialize(doc, Uuid.generate(), this._createIframeElement(), this._onOpenDocument); + Montage.create(HTMLDocument).initialize(doc, Uuid.generate(), this._createIframeElement(), this._onOpenDocument.bind(this)); break; default: //Open in code view @@ -250,7 +250,6 @@ DocumentController = exports.DocumentController = Montage.create(Component, { } var doc = this._findDocumentByUUID(id); - this._removeDocumentView(doc.container); var closeDocumentIndex = this._findIndexByUUID(id); this._documents.splice(this._findIndexByUUID(id), 1); @@ -263,8 +262,11 @@ DocumentController = exports.DocumentController = Montage.create(Component, { nextDocumentIndex = closeDocumentIndex - 1; } this.application.ninja.stage.stageView.switchDocument(this._documents[nextDocumentIndex]); + this._removeDocumentView(doc.container); }else if(this._documents.length === 0){ - //if there are no documents to switch to then just show the iframeContainer + this.activeDocument = null; + this._removeDocumentView(doc.container); + this.application.ninja.stage.stageView.hideRulers(); document.getElementById("iframeContainer").style.display="block"; } } @@ -275,11 +277,15 @@ DocumentController = exports.DocumentController = Montage.create(Component, { _onOpenDocument: { value: function(doc){ //var data = DocumentManager.activeDocument; - //DocumentManager._hideCurrentDocument(); - //stageManagerModule.stageManager.toggleCanvas(); + this._hideCurrentDocument(); + this.application.ninja.stage.stageView.hideOtherDocuments(doc.uuid); + + this.application.ninja.stage.hideCanvas(false); + + this.activeDocument = doc; - DocumentController.activeDocument = doc; + this._showCurrentDocument(); NJevent("onOpenDocument", doc); // appDelegateModule.MyAppDelegate.onSetActiveDocument(); -- cgit v1.2.3