diff options
Diffstat (limited to 'js/document')
-rwxr-xr-x | js/document/_toDelete/html-document.js (renamed from js/document/html-document.js) | 0 | ||||
-rwxr-xr-x | js/document/_toDelete/text-document.js (renamed from js/document/text-document.js) | 0 | ||||
-rwxr-xr-x | js/document/document-html.js | 34 | ||||
-rwxr-xr-x | js/document/document-text.js | 59 | ||||
-rwxr-xr-x | js/document/models/html.js | 5 | ||||
-rwxr-xr-x | js/document/views/base.js | 2 | ||||
-rwxr-xr-x | js/document/views/code.js | 56 | ||||
-rwxr-xr-x | js/document/views/design.js | 42 |
8 files changed, 103 insertions, 95 deletions
diff --git a/js/document/html-document.js b/js/document/_toDelete/html-document.js index 447d90e3..447d90e3 100755 --- a/js/document/html-document.js +++ b/js/document/_toDelete/html-document.js | |||
diff --git a/js/document/text-document.js b/js/document/_toDelete/text-document.js index 2574b67c..2574b67c 100755 --- a/js/document/text-document.js +++ b/js/document/_toDelete/text-document.js | |||
diff --git a/js/document/document-html.js b/js/document/document-html.js index f92a425c..c60a12a2 100755 --- a/js/document/document-html.js +++ b/js/document/document-html.js | |||
@@ -6,10 +6,10 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot | |||
6 | 6 | ||
7 | //////////////////////////////////////////////////////////////////////// | 7 | //////////////////////////////////////////////////////////////////////// |
8 | // | 8 | // |
9 | var Montage = require("montage/core/core").Montage, | 9 | var Montage = require("montage/core/core").Montage, |
10 | Component = require("montage/ui/component").Component, | 10 | Component = require("montage/ui/component").Component, |
11 | HtmlDocumentModel = require("js/document/models/html").HtmlDocumentModel, | 11 | HtmlDocumentModel = require("js/document/models/html").HtmlDocumentModel, |
12 | DesignDocumentView = require("js/document/views/design").DesignDocumentView; | 12 | DesignDocumentView = require("js/document/views/design").DesignDocumentView; |
13 | //////////////////////////////////////////////////////////////////////// | 13 | //////////////////////////////////////////////////////////////////////// |
14 | // | 14 | // |
15 | exports.HtmlDocument = Montage.create(Component, { | 15 | exports.HtmlDocument = Montage.create(Component, { |
@@ -33,15 +33,10 @@ exports.HtmlDocument = Montage.create(Component, { | |||
33 | _observer: { | 33 | _observer: { |
34 | value: null | 34 | value: null |
35 | }, | 35 | }, |
36 | //////////////////////////////////////////////////////////////////// | ||
37 | // | ||
38 | _document: { | ||
39 | value: null //TODO: Figure out if this will be needed, probably not | ||
40 | }, | ||
41 | //////////////////////////////////////////////////////////////////// | 36 | //////////////////////////////////////////////////////////////////// |
42 | // | 37 | // |
43 | exclusionList: { | 38 | exclusionList: { |
44 | value: ["HTML", "BODY", "NINJA-CONTENT"] //TODO: Update to correct list | 39 | value: ["HTML", "BODY", "NINJA-CONTENT"] |
45 | }, | 40 | }, |
46 | //////////////////////////////////////////////////////////////////// | 41 | //////////////////////////////////////////////////////////////////// |
47 | // | 42 | // |
@@ -72,7 +67,7 @@ exports.HtmlDocument = Montage.create(Component, { | |||
72 | //Hiding iFrame, just initiliazing | 67 | //Hiding iFrame, just initiliazing |
73 | this.model.views.design.hide(); | 68 | this.model.views.design.hide(); |
74 | } else { | 69 | } else { |
75 | //ERROR: Design View not initilized | 70 | //ERROR: Design View not initialized |
76 | } | 71 | } |
77 | // | 72 | // |
78 | if (view === 'design') { | 73 | if (view === 'design') { |
@@ -84,23 +79,10 @@ exports.HtmlDocument = Montage.create(Component, { | |||
84 | this.model.views.design.show(); | 79 | this.model.views.design.show(); |
85 | this.model.views.design.iframe.style.opacity = 0; | 80 | this.model.views.design.iframe.style.opacity = 0; |
86 | this.model.views.design.content = this.model.file.content; | 81 | this.model.views.design.content = this.model.file.content; |
87 | //TODO: Improve reference | 82 | //TODO: Improve reference (probably through binding values) |
88 | this.model.views.design.model = this.model; | 83 | this.model.views.design.model = this.model; |
89 | // | 84 | //Rendering design view, using observers to know when template is ready |
90 | //TODO: Clean up | ||
91 | this.model.views.design.render(function () { | 85 | this.model.views.design.render(function () { |
92 | //TODO: Identify and remove usage of '_document' | ||
93 | this._document = this.model.views.design.document; | ||
94 | //TODO: Remove usage, seems as not needed | ||
95 | if (template && template.type === 'banner') { | ||
96 | this.documentRoot = this.model.views.design.document.body.getElementsByTagName('ninja-content')[0]; | ||
97 | } else { | ||
98 | this.documentRoot = this.model.views.design.document.body; | ||
99 | } | ||
100 | //TODO: Why is this needed? | ||
101 | this._liveNodeList = this.documentRoot.getElementsByTagName('*'); | ||
102 | //Initiliazing document model | ||
103 | document.application.njUtils.makeElementModel(this.documentRoot, "Body", "body"); | ||
104 | //Adding observer to know when template is ready | 86 | //Adding observer to know when template is ready |
105 | this._observer = new WebKitMutationObserver(this.handleTemplateReady.bind(this)); | 87 | this._observer = new WebKitMutationObserver(this.handleTemplateReady.bind(this)); |
106 | this._observer.observe(this.model.views.design.document.head, {childList: true}); | 88 | this._observer.observe(this.model.views.design.document.head, {childList: true}); |
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 | // |
9 | var Montage = require("montage/core/core").Montage, | 9 | var 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 | // |
15 | exports.TextDocument = Montage.create(Component, { | 15 | exports.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 |
diff --git a/js/document/models/html.js b/js/document/models/html.js index 9cc8ce92..fd42d4de 100755 --- a/js/document/models/html.js +++ b/js/document/models/html.js | |||
@@ -64,6 +64,11 @@ exports.HtmlDocumentModel = Montage.create(BaseDocumentModel, { | |||
64 | userComponents: { | 64 | userComponents: { |
65 | value: {} | 65 | value: {} |
66 | }, | 66 | }, |
67 | //////////////////////////////////////////////////////////////////// | ||
68 | // | ||
69 | documentRoot: { | ||
70 | value: null | ||
71 | }, | ||
67 | //////////////////////////////////////////////////////////////////// | 72 | //////////////////////////////////////////////////////////////////// |
68 | //Add a reference to a component instance to the userComponents hash using the element UUID | 73 | //Add a reference to a component instance to the userComponents hash using the element UUID |
69 | setComponentInstance: { | 74 | setComponentInstance: { |
diff --git a/js/document/views/base.js b/js/document/views/base.js index db72cc60..d13dce1a 100755 --- a/js/document/views/base.js +++ b/js/document/views/base.js | |||
@@ -28,7 +28,7 @@ exports.BaseDocumentView = Montage.create(Component, { | |||
28 | value: null | 28 | value: null |
29 | }, | 29 | }, |
30 | //////////////////////////////////////////////////////////////////// | 30 | //////////////////////////////////////////////////////////////////// |
31 | // | 31 | //TODO: This should be renamed to better illustrate it's a container (iframe for design, div for code view) |
32 | iframe: { | 32 | iframe: { |
33 | get: function() {return this._iframe;}, | 33 | get: function() {return this._iframe;}, |
34 | set: function(value) {this._iframe= value;} | 34 | set: function(value) {this._iframe= value;} |
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, | |||