From 8504b61aefb25fdab931f02c4568916d2bf8345c Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Thu, 2 Feb 2012 00:52:44 -0800 Subject: changes to open multiple code view tabs and switch between the code views, added nj-skinned css class for the buttons in file picker, new file dialog and save as dialog Signed-off-by: Ananya Sen --- js/io/document/base-document.js | 13 ++++++++++++- js/io/document/document-controller.js | 36 +++++++++++++++++++---------------- js/io/document/text-document.js | 4 ++-- 3 files changed, 34 insertions(+), 19 deletions(-) (limited to 'js/io/document') diff --git a/js/io/document/base-document.js b/js/io/document/base-document.js index 44f54f78..af96c851 100755 --- a/js/io/document/base-document.js +++ b/js/io/document/base-document.js @@ -12,6 +12,7 @@ var BaseDocument = exports.BaseDocument = Montage.create(Montage, { /** Private Members **/ _name: { value: null, enumerable: false }, _uri: { value: null, enumerable: false }, + _externalUri: {value: null, enumerable:false}, _documentType: { value: null, enumerable: false }, _container: {value: null, enumerable: false }, _uuid: { value: null, enumerable: false }, @@ -31,6 +32,11 @@ var BaseDocument = exports.BaseDocument = Montage.create(Montage, { set: function(value) { this._uri = value; } }, + externalUri: { + get: function() { return this._externalUri; }, + set: function(value) { this._externalUri = value; } + }, + documentType: { get: function() { return this._documentType; }, set: function(value) { this._documentType = value; } @@ -68,13 +74,18 @@ var BaseDocument = exports.BaseDocument = Montage.create(Montage, { /** Base Methods **/ init: { - value: function(name, uri, type, container, uuid, callback) { + value: function(name, uri, type, container, uuid, callback, externalUri) { this.name = name; this.uri = uri; this.documentType = type; this.container = container; this.uuid = uuid; this.callback = callback; + if(!!externalUri){ + this.externalUri = externalUri; + this.container.setAttribute("data-uri", externalUri); + } + } }, diff --git a/js/io/document/document-controller.js b/js/io/document/document-controller.js index bba7e0e7..7fe94c12 100755 --- a/js/io/document/document-controller.js +++ b/js/io/document/document-controller.js @@ -99,9 +99,8 @@ var DocumentController = exports.DocumentController = Montage.create(Component, if(!!uriArrayObj && !!uriArrayObj.uri && (uriArrayObj.uri.length > 0)){ uri = uriArrayObj.uri[0]; } - console.log("URI is: ", uri); + //console.log("URI is: ", uri); - // Get file from Jose Code with a callback to here if(!!uri){ response = this.application.ninja.coreIoApi.openFile({"uri":uri}); if((response.success === true) && ((response.status === 200) || (response.status === 304))){ @@ -113,7 +112,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component, if(uri.indexOf('.') != -1){ fileType = uri.substr(uri.lastIndexOf('.') + 1); } - this.openDocument({"type": ""+fileType, "name": ""+filename, "source": fileContent}); + this.openDocument({"type": ""+fileType, "name": ""+filename, "source": fileContent, "externalUri": uri}); } } @@ -124,7 +123,6 @@ var DocumentController = exports.DocumentController = Montage.create(Component, value: function(uri) { console.log("URI is: ", uri); - // Get project from Jose Code with a callback to here } }, @@ -158,18 +156,6 @@ var DocumentController = exports.DocumentController = Montage.create(Component, } }, - // Document has been loaded into the Iframe. Dispatch the event. - // Event Detail: Contains the current ActiveDocument - _onOpenDocument: { - value: function(doc){ - - DocumentController.activeDocument = doc; - - NJevent("onOpenDocument", doc); - - } - }, - textDocumentOpened: { value: function(doc) { @@ -209,13 +195,31 @@ var DocumentController = exports.DocumentController = Montage.create(Component, closeDocument: { value: function(id) { + + //if file dirty then save + var doc = this._findDocumentByUUID(id); this._removeDocumentView(doc.container); this._documents.splice(this._findIndexByUUID(id), 1); if(this.activeDocument.uuid === id && this._documents.length > 0) { + + var closeDocumentIndex = this._findIndexByUUID(id); + var nextDocumentIndex = -1 ; + if((this._documents.length > 0) && (closeDocumentIndex === 0)){ + nextDocumentIndex = 1; + }else if((this._documents.length > 0) && (closeDocumentIndex > 0)){ + nextDocumentIndex = closeDocumentIndex - 1; + } + + //remove the codemirror div if this is for a code view + /////test + + ////end- test + this.switchDocument(this._documents[0].uuid); + } } }, diff --git a/js/io/document/text-document.js b/js/io/document/text-document.js index 599d311c..a9081cb5 100755 --- a/js/io/document/text-document.js +++ b/js/io/document/text-document.js @@ -45,10 +45,10 @@ var TextDocument = exports.TextDocument = Montage.create(baseDocumentModule.Base // PUBLIC METHODS initialize: { value: function(doc, uuid, textArea, callback) { - this.init(doc.name, doc.uri, doc.type, textArea, uuid); - + this.init(doc.name, doc.uri, doc.type, textArea, uuid, null, doc.externalUri); this.currentView = "code"; this.textArea = textArea; + // this._loadContent(); } }, -- cgit v1.2.3