aboutsummaryrefslogtreecommitdiff
path: root/js/document/document-html.js
diff options
context:
space:
mode:
authorEric Guzman2012-06-11 13:28:42 -0700
committerEric Guzman2012-06-11 13:28:42 -0700
commit3a4727ffc350216a434a7c6977b6a23653b77780 (patch)
treec5dff306f8803c36a16163ba5df1e7f492e762b5 /js/document/document-html.js
parentd6b46ba496c9c8974ae39bb476aea35bcd1ddaf1 (diff)
parent337efc667372326ae2f9984d89a47bb151016774 (diff)
downloadninja-3a4727ffc350216a434a7c6977b6a23653b77780.tar.gz
Merge branch 'binding' of github.com:dhg637/ninja-internal into binding
Diffstat (limited to 'js/document/document-html.js')
-rwxr-xr-xjs/document/document-html.js38
1 files changed, 13 insertions, 25 deletions
diff --git a/js/document/document-html.js b/js/document/document-html.js
index c60a12a2..8b82c40f 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,15 @@ 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(mObjects) {
110 this.model.mObjects = mObjects;
111 //Making callback after view is loaded
112 this.loaded.callback.call(this.loaded.context, this);
113 }
114 },
106 //////////////////////////////////////////////////////////////////// 115 ////////////////////////////////////////////////////////////////////
107 // 116 //
108 closeDocument: { 117 closeDocument: {
@@ -117,10 +126,6 @@ exports.HtmlDocument = Montage.create(Component, {
117 // 126 //
118 serializeDocument: { 127 serializeDocument: {
119 value: function () { 128 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 129 // Serialize the current scroll position
125 //TODO: Move these properties to the design view class 130 //TODO: Move these properties to the design view class
126 this.model.scrollLeft = this.application.ninja.stage._scrollLeft; 131 this.model.scrollLeft = this.application.ninja.stage._scrollLeft;
@@ -132,11 +137,6 @@ exports.HtmlDocument = Montage.create(Component, {
132 // Serialize the selection, the container and grid 137 // Serialize the selection, the container and grid
133 //TODO: Move this property to the design view class 138 //TODO: Move this property to the design view class
134 this.model.selection = this.application.ninja.selectedElements.slice(0); 139 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 140
141 // Pause the videos 141 // Pause the videos
142 //TODO: Move these to be handled on the show/hide methods in the view 142 //TODO: Move these to be handled on the show/hide methods in the view
@@ -147,27 +147,15 @@ exports.HtmlDocument = Montage.create(Component, {
147 // 147 //
148 deserializeDocument: { 148 deserializeDocument: {
149 value: function () { 149 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 150 // Deserialize the current scroll position
155 //TODO: Move these properties to the design view class 151 //TODO: Move these properties to the design view class
156 this.application.ninja.stage._scrollLeft = this.model.scrollLeft; 152 this.application.ninja.stage._scrollLeft = this.model.scrollLeft;
157 this.application.ninja.stage._scrollTop = this.model.scrollTop; 153 this.application.ninja.stage._scrollTop = this.model.scrollTop;
158 this.application.ninja.stage._userContentLeft = this.model.userContentLeft; 154 this.application.ninja.stage._userContentLeft = this.model.userContentLeft;
159 this.application.ninja.stage._userContentTop = this.model.userContentTop; 155 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 156
166 // Serialize the undo 157 // Serialize the undo
167 // TODO: Save the montage undo queue 158 // TODO: Save the montage undo queue
168
169 //TODO: Move this to the document controller
170 this.model.isActive = true;
171 } 159 }
172 } 160 }
173 //////////////////////////////////////////////////////////////////// 161 ////////////////////////////////////////////////////////////////////