From b978bf7f76195bea9caa370ea18b1444d0b1bf18 Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Sun, 27 May 2012 16:32:32 -0700 Subject: Cleaning up --- js/document/document-text.js | 59 ++++++++++++++++++++++---------------------- js/document/views/code.js | 56 +++++++++++++++++------------------------ 2 files changed, 52 insertions(+), 63 deletions(-) (limited to 'js/document') diff --git a/js/document/document-text.js b/js/document/document-text.js index bb63f5f8..811cc8ce 100755 --- a/js/document/document-text.js +++ b/js/document/document-text.js @@ -6,17 +6,16 @@ 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, +var Montage = require("montage/core/core").Montage, + Component = require("montage/ui/component").Component, TextDocumentModel = require("js/document/models/text").TextDocumentModel, - CodeDocumentView = require("js/document/views/code").CodeDocumentView; + CodeDocumentView = require("js/document/views/code").CodeDocumentView; //////////////////////////////////////////////////////////////////////// // exports.TextDocument = Montage.create(Component, { //////////////////////////////////////////////////////////////////// // hasTemplate: { - enumerable: false, value: false }, //////////////////////////////////////////////////////////////////// @@ -26,45 +25,47 @@ exports.TextDocument = Montage.create(Component, { }, //////////////////////////////////////////////////////////////////// // - init:{ - enumerable: false, - value : function(file, context, callback, view){ - var codeDocumentView = CodeDocumentView.create(), container = null; - + value: function(file, context, callback, view){ + // + var codeDocumentView = CodeDocumentView.create(), container = null; //TODO: Why is this initilzied to null? //Creating instance of Text Document Model this.model = Montage.create(TextDocumentModel,{ file: {value: file}, - parentContainer: {value: document.getElementById("codeViewContainer")}, - views: {value: {'code': codeDocumentView, 'design': null}} + parentContainer: {value: document.getElementById("codeViewContainer")}, //TODO: Remove reference to this element, should be dynamic + views: {value: {'code': codeDocumentView, 'design': null}} //TODO: Add check if file might have design view, if so, then create it }); - + //TODO: Add design view logic + //Initilizing view(s) codeDocumentView.initialize(this.model.parentContainer); - - codeDocumentView.textArea.value = file.content; - codeDocumentView.initializeTextView(file, this); - + //Checking for view specified if (view === 'code') { //TODO: Remove reference and use as part of model this.currentView = 'code'; //Setting current view object to design this.model.currentView = this.model.views.code; + //Rendering view + codeDocumentView.textArea.value = file.content; + codeDocumentView.initializeTextView(file, this); + } else { + //Other view(s) logic goes here } - - - callback.call(context, this); + //Checking if callback is needed + if (callback) callback.call(context, this); } }, -//////////////////////////////////////////////////////////////////// - // - closeDocument: { - value: function (context, callback) { - var closed = this.model.close(null); - - callback.call(context, this); - } - } -//////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////// + // + closeDocument: { + value: function (context, callback) { + //Closing document and getting outcome + var closed = this.model.close(null); + //Making callback if specified + if (callback) callback.call(context, this); + } + } + //////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////// }); //////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// \ No newline at end of file diff --git a/js/document/views/code.js b/js/document/views/code.js index 66d1c702..0a0ff5c1 100755 --- a/js/document/views/code.js +++ b/js/document/views/code.js @@ -10,15 +10,13 @@ var Montage = require("montage/core/core").Montage, Component = require("montage/ui/component").Component, BaseDocumentView = require("js/document/views/base").BaseDocumentView; //////////////////////////////////////////////////////////////////////// -// -var CodeDocumentView = exports.CodeDocumentView = Montage.create(BaseDocumentView, { +// +exports.CodeDocumentView = Montage.create(BaseDocumentView, { //////////////////////////////////////////////////////////////////// // hasTemplate: { - enumerable: false, value: false }, - //////////////////////////////////////////////////////////////////// // _editor: { @@ -28,7 +26,7 @@ var CodeDocumentView = exports.CodeDocumentView = Montage.create(BaseDocumentVie // editor: { get: function() {return this._editor;}, - set: function(value) {this._editor= value;} + set: function(value) {this._editor = value;} }, //////////////////////////////////////////////////////////////////// // @@ -39,7 +37,7 @@ var CodeDocumentView = exports.CodeDocumentView = Montage.create(BaseDocumentVie // textArea: { get: function() {return this._textArea;}, - set: function(value) {this._textArea= value;} + set: function(value) {this._textArea = value;} }, //////////////////////////////////////////////////////////////////// // @@ -50,14 +48,10 @@ var CodeDocumentView = exports.CodeDocumentView = Montage.create(BaseDocumentVie // textViewContainer: { get: function() {return this._textViewContainer;}, - set: function(value) {this._textViewContainer= value;} + set: function(value) {this._textViewContainer = value;} }, //////////////////////////////////////////////////////////////////// // - - /** - * Public method - */ initialize:{ value: function(parentContainer){ //create contianer @@ -65,42 +59,35 @@ var CodeDocumentView = exports.CodeDocumentView = Montage.create(BaseDocumentVie //this.textViewContainer.id = "codemirror_" + uuid; this.textViewContainer.style.display = "block"; parentContainer.appendChild(this.textViewContainer); - //create text area this.textArea = this.createTextAreaElement(); } }, - - /** - * Public method - * Creates a textarea element which will contain the content of the opened text document. - */ + //////////////////////////////////////////////////////////////////// + //Creates a textarea element which will contain the content of the opened text document createTextAreaElement: { value: function() { var textArea = document.createElement("textarea"); -// textArea.id = "code"; -// textArea.name = "code"; + //textArea.id = "code"; + //textArea.name = "code"; this.textViewContainer.appendChild(textArea); - + //Returns textarea element return textArea; } }, //////////////////////////////////////////////////////////////////// - // - /** - * Public method - * Creates a new instance of a code editor - */ + //Creates a new instance of a code editor initializeTextView: { value: function(file, textDocument) { + // var type; - + // if(this.activeDocument) { //need to hide only if another document was open before -// this.application.ninja.documentController._hideCurrentDocument(); -// this.hideOtherDocuments(doc.uuid); + //this.application.ninja.documentController._hideCurrentDocument(); + //this.hideOtherDocuments(doc.uuid); } - + // switch(file.extension) { case "css" : type = "css"; @@ -130,18 +117,18 @@ var CodeDocumentView = exports.CodeDocumentView = Montage.create(BaseDocumentVie type = "xml"; break; } + // this.textViewContainer.style.display="block"; - + // this.editor = this.application.ninja.codeEditorController.createEditor(this, type, file.extension, textDocument); this.editor.hline = this.editor.setLineClass(0, "activeline"); - - } }, //////////////////////////////////////////////////////////////////// // show: { value: function (callback) { + // this.textViewContainer.style.display = "block"; // if (callback) callback(); @@ -151,6 +138,7 @@ var CodeDocumentView = exports.CodeDocumentView = Montage.create(BaseDocumentVie // hide: { value: function (callback) { + // this.textViewContainer.style.display = "none"; // if (callback) callback(); @@ -164,8 +152,8 @@ var CodeDocumentView = exports.CodeDocumentView = Montage.create(BaseDocumentVie this.textViewContainer.className = "codeViewContainer "+themeClass; } } -//////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////// }); //////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// \ No newline at end of file -- cgit v1.2.3 From 6ca89e7233614b93c49a4feadb8a0a82e5800b8f Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Sun, 27 May 2012 17:32:41 -0700 Subject: Cleaning up --- js/document/views/design.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'js/document') diff --git a/js/document/views/design.js b/js/document/views/design.js index d772aa86..c7313708 100755 --- a/js/document/views/design.js +++ b/js/document/views/design.js @@ -67,13 +67,13 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, { propertiesPanel: { value: null }, - //////////////////////////////////////////////////////////////////// // _liveNodeList: { value: null }, - + //////////////////////////////////////////////////////////////////// + // getLiveNodeList: { value: function(useFilter) { if(useFilter) { @@ -92,8 +92,6 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, { } }, //////////////////////////////////////////////////////////////////// - // - // initialize: { value: function (parent) { -- cgit v1.2.3