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 From 6f5ffa17c72dd0aef7a02e3496154514750143c2 Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Fri, 18 May 2012 18:38:09 -0700 Subject: save for code view documents in the new dom architecture Signed-off-by: Ananya Sen --- js/document/document-text.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'js/document/document-text.js') diff --git a/js/document/document-text.js b/js/document/document-text.js index 533b32c9..09525f4e 100755 --- a/js/document/document-text.js +++ b/js/document/document-text.js @@ -53,8 +53,16 @@ exports.TextDocument = Montage.create(Component, { callback.call(context, this); } - } + }, //////////////////////////////////////////////////////////////////// + // + closeDocument: { + value: function (context, callback) { + var closed = this.model.close(null); + + callback.call(context, this); + } + } //////////////////////////////////////////////////////////////////// }); //////////////////////////////////////////////////////////////////////// -- cgit v1.2.3 From c3c2ffc8d057660b7c42b45442885cd0d2d598bc Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Sun, 20 May 2012 15:16:06 -0700 Subject: use documents parent container property Signed-off-by: Ananya Sen --- js/document/document-text.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'js/document/document-text.js') diff --git a/js/document/document-text.js b/js/document/document-text.js index 09525f4e..bb63f5f8 100755 --- a/js/document/document-text.js +++ b/js/document/document-text.js @@ -31,7 +31,6 @@ exports.TextDocument = Montage.create(Component, { 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,{ @@ -40,6 +39,8 @@ exports.TextDocument = Montage.create(Component, { views: {value: {'code': codeDocumentView, 'design': null}} }); + codeDocumentView.initialize(this.model.parentContainer); + codeDocumentView.textArea.value = file.content; codeDocumentView.initializeTextView(file, this); -- cgit v1.2.3 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 ++++++++++++++++++++++---------------------- 1 file changed, 30 insertions(+), 29 deletions(-) (limited to 'js/document/document-text.js') 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 -- cgit v1.2.3