From 7a22f7b368ef549a5b30c58a0f3900685b764bdb Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Fri, 18 May 2012 16:56:16 -0700 Subject: integrated open code view document in new dom architecture Signed-off-by: Ananya Sen --- js/document/document-text.js | 43 ++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 40 insertions(+), 3 deletions(-) (limited to 'js/document/document-text.js') diff --git a/js/document/document-text.js b/js/document/document-text.js index 2a469144..533b32c9 100755 --- a/js/document/document-text.js +++ b/js/document/document-text.js @@ -7,7 +7,9 @@ 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; + Component = require("montage/ui/component").Component, + TextDocumentModel = require("js/document/models/text").TextDocumentModel, + CodeDocumentView = require("js/document/views/code").CodeDocumentView; //////////////////////////////////////////////////////////////////////// // exports.TextDocument = Montage.create(Component, { @@ -16,9 +18,44 @@ exports.TextDocument = Montage.create(Component, { hasTemplate: { enumerable: false, value: false - } - //////////////////////////////////////////////////////////////////// + }, //////////////////////////////////////////////////////////////////// + // + model: { + value: null + }, + //////////////////////////////////////////////////////////////////// + // + + init:{ + enumerable: false, + value : function(file, context, callback, view){ + var codeDocumentView = CodeDocumentView.create(), container = null; + codeDocumentView.initialize(); + + //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}} + }); + + codeDocumentView.textArea.value = file.content; + codeDocumentView.initializeTextView(file, this); + + 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; + } + + + callback.call(context, this); + } + } +//////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////// }); //////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// \ No newline at end of file -- cgit v1.2.3