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.js37
1 files changed, 12 insertions, 25 deletions
diff --git a/js/document/document-html.js b/js/document/document-html.js
index c60a12a2..04565753 100755
--- a/js/document/document-html.js
+++ b/js/document/document-html.js
@@ -62,10 +62,14 @@ exports.HtmlDocument = Montage.create(Component, {
62 parentContainer: {value: document.getElementById("iframeContainer")}, //Saving reference to parent container of all views (should be changed to buckets approach 62 parentContainer: {value: document.getElementById("iframeContainer")}, //Saving reference to parent container of all views (should be changed to buckets approach
63 views: {value: {'design': DesignDocumentView.create(), 'code': null}} //TODO: Add code view logic 63 views: {value: {'design': DesignDocumentView.create(), 'code': null}} //TODO: Add code view logic
64 }); 64 });
65 //Calling the any init routines in the model
66 this.model.init();
65 //Initiliazing views and hiding 67 //Initiliazing views and hiding
66 if (this.model.views.design.initialize(this.model.parentContainer)) { 68 if (this.model.views.design.initialize(this.model.parentContainer)) {
67 //Hiding iFrame, just initiliazing 69 //Hiding iFrame, just initiliazing
68 this.model.views.design.hide(); 70 this.model.views.design.hide();
71 //Setting the iFrame property for reference in helper class
72 this.model.webGlHelper.iframe = this.model.views.design.iframe;
69 } else { 73 } else {
70 //ERROR: Design View not initialized 74 //ERROR: Design View not initialized
71 } 75 }
@@ -80,13 +84,13 @@ exports.HtmlDocument = Montage.create(Component, {
80 this.model.views.design.iframe.style.opacity = 0; 84 this.model.views.design.iframe.style.opacity = 0;
81 this.model.views.design.content = this.model.file.content; 85 this.model.views.design.content = this.model.file.content;
82 //TODO: Improve reference (probably through binding values) 86 //TODO: Improve reference (probably through binding values)
83 this.model.views.design.model = this.model; 87 this.model.views.design._webGlHelper = this.model.webGlHelper;
84 //Rendering design view, using observers to know when template is ready 88 //Rendering design view, using observers to know when template is ready
85 this.model.views.design.render(function () { 89 this.model.views.design.render(function () {
86 //Adding observer to know when template is ready 90 //Adding observer to know when template is ready
87 this._observer = new WebKitMutationObserver(this.handleTemplateReady.bind(this)); 91 this._observer = new WebKitMutationObserver(this.handleTemplateReady.bind(this));
88 this._observer.observe(this.model.views.design.document.head, {childList: true}); 92 this._observer.observe(this.model.views.design.document.head, {childList: true});
89 }.bind(this), template); 93 }.bind(this), template, {viewCallback: this.handleViewReady, context: this});
90 } else { 94 } else {
91 //TODO: Identify default view (probably code) 95 //TODO: Identify default view (probably code)
92 } 96 }
@@ -99,10 +103,14 @@ exports.HtmlDocument = Montage.create(Component, {
99 //Removing observer, only needed on initial load 103 //Removing observer, only needed on initial load
100 this._observer.disconnect(); 104 this._observer.disconnect();
101 this._observer = null; 105 this._observer = null;
102 //Making callback after view is loaded
103 this.loaded.callback.call(this.loaded.context, this);
104 } 106 }
105 }, 107 },
108 handleViewReady: {
109 value: function() {
110 //Making callback after view is loaded
111 this.loaded.callback.call(this.loaded.context, this);
112 }
113 },
106 //////////////////////////////////////////////////////////////////// 114 ////////////////////////////////////////////////////////////////////
107 // 115 //
108 closeDocument: { 116 closeDocument: {
@@ -117,10 +125,6 @@ exports.HtmlDocument = Montage.create(Component, {
117 // 125 //
118 serializeDocument: { 126 serializeDocument: {
119 value: function () { 127 value: function () {
120 // There are not needed for now since we cannot change them
121 //this.gridHorizontalSpacing = this.application.ninja.stage.drawUtils.gridHorizontalSpacing;
122 //this.gridVerticalSpacing = this.application.ninja.stage.drawUtils.gridVerticalSpacing;
123
124 // Serialize the current scroll position 128 // Serialize the current scroll position
125 //TODO: Move these properties to the design view class 129 //TODO: Move these properties to the design view class
126 this.model.scrollLeft = this.application.ninja.stage._scrollLeft; 130 this.model.scrollLeft = this.application.ninja.stage._scrollLeft;
@@ -132,11 +136,6 @@ exports.HtmlDocument = Montage.create(Component, {
132 // Serialize the selection, the container and grid 136 // Serialize the selection, the container and grid
133 //TODO: Move this property to the design view class 137 //TODO: Move this property to the design view class
134 this.model.selection = this.application.ninja.selectedElements.slice(0); 138 this.model.selection = this.application.ninja.selectedElements.slice(0);
135 this.model.selectionContainer = this.application.ninja.currentSelectedContainer;
136 this.draw3DGrid = this.application.ninja.appModel.show3dGrid;
137
138 // Serialize the undo
139 // TODO: Save the montage undo queue
140 139
141 // Pause the videos 140 // Pause the videos
142 //TODO: Move these to be handled on the show/hide methods in the view 141 //TODO: Move these to be handled on the show/hide methods in the view
@@ -147,27 +146,15 @@ exports.HtmlDocument = Montage.create(Component, {
147 // 146 //
148 deserializeDocument: { 147 deserializeDocument: {
149 value: function () { 148 value: function () {
150 // There are not needed for now since we cannot change them
151 //this.application.ninja.stage.drawUtils.gridHorizontalSpacing = this.gridHorizontalSpacing;
152 //this.application.ninja.stage.drawUtils.gridVerticalSpacing = this.gridVerticalSpacing;
153
154 // Deserialize the current scroll position 149 // Deserialize the current scroll position
155 //TODO: Move these properties to the design view class 150 //TODO: Move these properties to the design view class
156 this.application.ninja.stage._scrollLeft = this.model.scrollLeft; 151 this.application.ninja.stage._scrollLeft = this.model.scrollLeft;
157 this.application.ninja.stage._scrollTop = this.model.scrollTop; 152 this.application.ninja.stage._scrollTop = this.model.scrollTop;
158 this.application.ninja.stage._userContentLeft = this.model.userContentLeft; 153 this.application.ninja.stage._userContentLeft = this.model.userContentLeft;
159 this.application.ninja.stage._userContentTop = this.model.userContentTop; 154 this.application.ninja.stage._userContentTop = this.model.userContentTop;
160
161 //TODO: Move this property to the design view class
162 this.application.ninja.selectedElements = this.model.selection.slice(0);
163// this.application.ninja.currentSelectedContainer = this.model.selectionContainer;
164 this.application.ninja.appModel.show3dGrid = this.draw3DGrid;
165 155
166 // Serialize the undo 156 // Serialize the undo
167 // TODO: Save the montage undo queue 157 // TODO: Save the montage undo queue
168
169 //TODO: Move this to the document controller
170 this.model.isActive = true;
171 } 158 }
172 } 159 }
173 //////////////////////////////////////////////////////////////////// 160 ////////////////////////////////////////////////////////////////////