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.js27
1 files changed, 24 insertions, 3 deletions
diff --git a/js/document/document-html.js b/js/document/document-html.js
index b7dacf6a..76157a07 100755
--- a/js/document/document-html.js
+++ b/js/document/document-html.js
@@ -34,7 +34,8 @@ POSSIBILITY OF SUCH DAMAGE.
34var Montage = require("montage/core/core").Montage, 34var Montage = require("montage/core/core").Montage,
35 Component = require("montage/ui/component").Component, 35 Component = require("montage/ui/component").Component,
36 HtmlDocumentModel = require("js/document/models/html").HtmlDocumentModel, 36 HtmlDocumentModel = require("js/document/models/html").HtmlDocumentModel,
37 DesignDocumentView = require("js/document/views/design").DesignDocumentView; 37 DesignDocumentView = require("js/document/views/design").DesignDocumentView,
38 DesignCodeView = require("js/document/views/design-code").DesignCodeView;
38//////////////////////////////////////////////////////////////////////// 39////////////////////////////////////////////////////////////////////////
39// 40//
40exports.HtmlDocument = Montage.create(Component, { 41exports.HtmlDocument = Montage.create(Component, {
@@ -77,6 +78,7 @@ exports.HtmlDocument = Montage.create(Component, {
77 // 78 //
78 init: { 79 init: {
79 value: function(file, context, callback, view, template) { 80 value: function(file, context, callback, view, template) {
81 var designCodeView = DesignCodeView.create();
80 //Storing callback data for loaded dispatch 82 //Storing callback data for loaded dispatch
81 this.loaded.callback = callback; 83 this.loaded.callback = callback;
82 this.loaded.context = context; 84 this.loaded.context = context;
@@ -85,7 +87,7 @@ exports.HtmlDocument = Montage.create(Component, {
85 file: {value: file}, 87 file: {value: file},
86 fileTemplate: {value: template}, 88 fileTemplate: {value: template},
87 parentContainer: {value: document.getElementById("iframeContainer")}, //Saving reference to parent container of all views (should be changed to buckets approach 89 parentContainer: {value: document.getElementById("iframeContainer")}, //Saving reference to parent container of all views (should be changed to buckets approach
88 views: {value: {'design': DesignDocumentView.create(), 'code': null}} //TODO: Add code view logic 90 views: {value: {'design': DesignDocumentView.create(), 'code': designCodeView}} //TODO: Add code view logic
89 }); 91 });
90 //Calling the any init routines in the model 92 //Calling the any init routines in the model
91 this.model.init(); 93 this.model.init();
@@ -98,6 +100,14 @@ exports.HtmlDocument = Montage.create(Component, {
98 } else { 100 } else {
99 //ERROR: Design View not initialized 101 //ERROR: Design View not initialized
100 } 102 }
103
104
105 //initialize the code view for the html document and hide it since design is the default view
106 this.model.views.code.initialize(this.model.parentContainer);
107
108 this.model.views.code.hide();
109
110
101 // 111 //
102 if (view === 'design') { 112 if (view === 'design') {
103 //TODO: Remove reference and use as part of model 113 //TODO: Remove reference and use as part of model
@@ -125,6 +135,7 @@ exports.HtmlDocument = Montage.create(Component, {
125 //TODO: Make into one method to use here and one init 135 //TODO: Make into one method to use here and one init
126 reloadView: { 136 reloadView: {
127 value: function (view, template) { 137 value: function (view, template) {
138 var content;
128 // 139 //
129 this.model.parentContainer.removeChild(this.model.views.design.iframe); 140 this.model.parentContainer.removeChild(this.model.views.design.iframe);
130 //Initiliazing views and hiding 141 //Initiliazing views and hiding
@@ -154,8 +165,18 @@ exports.HtmlDocument = Montage.create(Component, {
154 this._observer = new WebKitMutationObserver(this.handleTemplateReady.bind(this)); 165 this._observer = new WebKitMutationObserver(this.handleTemplateReady.bind(this));
155 this._observer.observe(this.model.views.design.document.head, {childList: true}); 166 this._observer.observe(this.model.views.design.document.head, {childList: true});
156 }.bind(this), template, {viewCallback: this.handleViewReady, context: this}); 167 }.bind(this), template, {viewCallback: this.handleViewReady, context: this});
157 } else { 168 } else if(view === 'code'){
158 //TODO: Identify default view (probably code) 169 //TODO: Identify default view (probably code)
170
171 //TODO:get the html content from the document
172 content = '<html><head>'+this.model.file.content.head+'</head><body>'+this.model.file.content.body+'</body></html>';//dummy
173
174 this.model.views.code.load(content);
175
176 //Setting current view object to code
177 this.currentView = 'code';
178 this.model.currentView = this.model.views.code;
179
159 } 180 }
160 } 181 }
161 }, 182 },