aboutsummaryrefslogtreecommitdiff
path: root/js/document/document-html.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/document/document-html.js')
-rwxr-xr-xjs/document/document-html.js54
1 files changed, 47 insertions, 7 deletions
diff --git a/js/document/document-html.js b/js/document/document-html.js
index 567e4455..9bbea4c9 100755
--- a/js/document/document-html.js
+++ b/js/document/document-html.js
@@ -63,17 +63,19 @@ exports.HtmlDocument = Montage.create(Component, {
63 //////////////////////////////////////////////////////////////////// 63 ////////////////////////////////////////////////////////////////////
64 // 64 //
65 init: { 65 init: {
66 value:function(file, context, callback, view, template) { //TODO: Add template support logic 66 value:function(file, context, callback, view, template) {
67 //Storing callback data for loaded dispatch 67 //Storing callback data for loaded dispatch
68 this.loaded.callback = callback; 68 this.loaded.callback = callback;
69 this.loaded.context = context; 69 this.loaded.context = context;
70 //Creating instance of HTML Document Model 70 //Creating instance of HTML Document Model
71 this.model = Montage.create(HtmlDocumentModel,{ 71 this.model = Montage.create(HtmlDocumentModel,{
72 file: {value: file}, 72 file: {value: file},
73 fileTemplate: {value: template},
74 parentContainer: {value: document.getElementById("iframeContainer")}, //Saving reference to parent container of all views (should be changed to buckets approach
73 views: {value: {'design': DesignDocumentView.create(), 'code': null}} //TODO: Add code view logic 75 views: {value: {'design': DesignDocumentView.create(), 'code': null}} //TODO: Add code view logic
74 }); 76 });
75 //Initiliazing views and hiding 77 //Initiliazing views and hiding
76 if (this.model.views.design.initialize(document.getElementById("iframeContainer"))) { 78 if (this.model.views.design.initialize(this.model.parentContainer)) {
77 //Hiding iFrame, just initiliazing 79 //Hiding iFrame, just initiliazing
78 this.model.views.design.hide(); 80 this.model.views.design.hide();
79 } else { 81 } else {
@@ -96,16 +98,20 @@ exports.HtmlDocument = Montage.create(Component, {
96 this.model.views.design.render(function () { 98 this.model.views.design.render(function () {
97 //TODO: Identify and remove usage of '_document' 99 //TODO: Identify and remove usage of '_document'
98 this._document = this.model.views.design.document; 100 this._document = this.model.views.design.document;
99 //TODO: Remove usage, seems as not needed 101 //TODO: Remove usage, seems as not needed
100 this.documentRoot = this.model.views.design.document.body; 102 if (template && template.type === 'banner') {
103 this.documentRoot = this.model.views.design.document.body.getElementsByTagName('ninja-content')[0];
104 } else {
105 this.documentRoot = this.model.views.design.document.body;
106 }
101 //TODO: Why is this needed? 107 //TODO: Why is this needed?
102 this._liveNodeList = this.model.views.design.document.body.getElementsByTagName('*'); 108 this._liveNodeList = this.documentRoot.getElementsByTagName('*');
103 //Initiliazing document model 109 //Initiliazing document model
104 document.application.njUtils.makeElementModel(this.model.views.design.document.body, "Body", "body"); 110 document.application.njUtils.makeElementModel(this.documentRoot, "Body", "body");
105 //Adding observer to know when template is ready 111 //Adding observer to know when template is ready
106 this._observer = new WebKitMutationObserver(this.handleTemplateReady.bind(this)); 112 this._observer = new WebKitMutationObserver(this.handleTemplateReady.bind(this));
107 this._observer.observe(this.model.views.design.document.head, {childList: true}); 113 this._observer.observe(this.model.views.design.document.head, {childList: true});
108 }.bind(this)); 114 }.bind(this), template);
109 } else { 115 } else {
110 //TODO: Identify default view (probably code) 116 //TODO: Identify default view (probably code)
111 } 117 }
@@ -123,6 +129,40 @@ exports.HtmlDocument = Montage.create(Component, {
123 //Setting opacity to be viewable after load 129 //Setting opacity to be viewable after load
124 this.model.views.design.iframe.style.opacity = 1; 130 this.model.views.design.iframe.style.opacity = 1;
125 } 131 }
132 },
133 ////////////////////////////////////////////////////////////////////
134 //
135 closeDocument: {
136 value: function () {
137 //
138 this.model.close(null, this.handleCloseDocument.bind(this));
139 }
140 },
141 ////////////////////////////////////////////////////////////////////
142 //
143 handleCloseDocument: {
144 value: function (success) {
145 //TODO: Add logic for handling success or failure
146 //
147 this.application.ninja.documentController._documents.splice(this.uuid, 1);
148 //
149 NJevent("closeDocument", this.model.file.uri);
150 //TODO: Delete object here
151 }
152 },
153 ////////////////////////////////////////////////////////////////////
154 //
155 saveAppState: {
156 value: function () {
157 //TODO: Import functionality
158 }
159 },
160 ////////////////////////////////////////////////////////////////////
161 //
162 restoreAppState: {
163 value: function () {
164 //TODO: Import functionality
165 }
126 } 166 }
127 //////////////////////////////////////////////////////////////////// 167 ////////////////////////////////////////////////////////////////////
128 //////////////////////////////////////////////////////////////////// 168 ////////////////////////////////////////////////////////////////////