aboutsummaryrefslogtreecommitdiff
path: root/js/document/document-text.js
diff options
context:
space:
mode:
authorEric Guzman2012-05-31 10:57:09 -0700
committerEric Guzman2012-05-31 10:57:09 -0700
commit4e28e2d2a695d487b1bc127dce0a874691539ca8 (patch)
treeb00dd9e992d1d9cb7bc9076464de76c4a627954e /js/document/document-text.js
parente09efe3212e86ac794de3fc8ecfc6cdef7b15181 (diff)
parentb7e33c16bab26f8ee0daa61f920cfdbcb7abc6e3 (diff)
downloadninja-4e28e2d2a695d487b1bc127dce0a874691539ca8.tar.gz
Merge branch 'binding' of github.com:dhg637/ninja-internal into binding
Diffstat (limited to 'js/document/document-text.js')
-rwxr-xr-xjs/document/document-text.js59
1 files changed, 30 insertions, 29 deletions
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
6 6
7//////////////////////////////////////////////////////////////////////// 7////////////////////////////////////////////////////////////////////////
8// 8//
9var Montage = require("montage/core/core").Montage, 9var Montage = require("montage/core/core").Montage,
10 Component = require("montage/ui/component").Component, 10 Component = require("montage/ui/component").Component,
11 TextDocumentModel = require("js/document/models/text").TextDocumentModel, 11 TextDocumentModel = require("js/document/models/text").TextDocumentModel,
12 CodeDocumentView = require("js/document/views/code").CodeDocumentView; 12 CodeDocumentView = require("js/document/views/code").CodeDocumentView;
13//////////////////////////////////////////////////////////////////////// 13////////////////////////////////////////////////////////////////////////
14// 14//
15exports.TextDocument = Montage.create(Component, { 15exports.TextDocument = Montage.create(Component, {
16 //////////////////////////////////////////////////////////////////// 16 ////////////////////////////////////////////////////////////////////
17 // 17 //
18 hasTemplate: { 18 hasTemplate: {
19 enumerable: false,
20 value: false 19 value: false
21 }, 20 },
22 //////////////////////////////////////////////////////////////////// 21 ////////////////////////////////////////////////////////////////////
@@ -26,45 +25,47 @@ exports.TextDocument = Montage.create(Component, {
26 }, 25 },
27 //////////////////////////////////////////////////////////////////// 26 ////////////////////////////////////////////////////////////////////
28 // 27 //
29
30 init:{ 28 init:{
31 enumerable: false, 29 value: function(file, context, callback, view){
32 value : function(file, context, callback, view){ 30 //
33 var codeDocumentView = CodeDocumentView.create(), container = null; 31 var codeDocumentView = CodeDocumentView.create(), container = null; //TODO: Why is this initilzied to null?
34
35 //Creating instance of Text Document Model 32 //Creating instance of Text Document Model
36 this.model = Montage.create(TextDocumentModel,{ 33 this.model = Montage.create(TextDocumentModel,{
37 file: {value: file}, 34 file: {value: file},
38 parentContainer: {value: document.getElementById("codeViewContainer")}, 35 parentContainer: {value: document.getElementById("codeViewContainer")}, //TODO: Remove reference to this element, should be dynamic
39 views: {value: {'code': codeDocumentView, 'design': null}} 36 views: {value: {'code': codeDocumentView, 'design': null}} //TODO: Add check if file might have design view, if so, then create it
40 }); 37 });
41 38 //TODO: Add design view logic
39 //Initilizing view(s)
42 codeDocumentView.initialize(this.model.parentContainer); 40 codeDocumentView.initialize(this.model.parentContainer);
43 41 //Checking for view specified
44 codeDocumentView.textArea.value = file.content;
45 codeDocumentView.initializeTextView(file, this);
46
47 if (view === 'code') { 42 if (view === 'code') {
48 //TODO: Remove reference and use as part of model 43 //TODO: Remove reference and use as part of model
49 this.currentView = 'code'; 44 this.currentView = 'code';
50 //Setting current view object to design 45 //Setting current view object to design
51 this.model.currentView = this.model.views.code; 46 this.model.currentView = this.model.views.code;
47 //Rendering view
48 codeDocumentView.textArea.value = file.content;
49 codeDocumentView.initializeTextView(file, this);
50 } else {
51 //Other view(s) logic goes here
52 } 52 }
53 53 //Checking if callback is needed
54 54 if (callback) callback.call(context, this);
55 callback.call(context, this);
56 } 55 }
57 }, 56 },
58//////////////////////////////////////////////////////////////////// 57 ////////////////////////////////////////////////////////////////////
59 // 58 //
60 closeDocument: { 59 closeDocument: {
61 value: function (context, callback) { 60 value: function (context, callback) {
62 var closed = this.model.close(null); 61 //Closing document and getting outcome
63 62 var closed = this.model.close(null);
64 callback.call(context, this); 63 //Making callback if specified
65 } 64 if (callback) callback.call(context, this);
66 } 65 }
67//////////////////////////////////////////////////////////////////// 66 }
67 ////////////////////////////////////////////////////////////////////
68 ////////////////////////////////////////////////////////////////////
68}); 69});
69//////////////////////////////////////////////////////////////////////// 70////////////////////////////////////////////////////////////////////////
70//////////////////////////////////////////////////////////////////////// \ No newline at end of file 71//////////////////////////////////////////////////////////////////////// \ No newline at end of file