diff options
author | Jose Antonio Marquez | 2012-07-17 11:25:41 -0700 |
---|---|---|
committer | Jose Antonio Marquez | 2012-07-17 11:25:41 -0700 |
commit | 17d464e5bd224cdd8940855409359b411325f1df (patch) | |
tree | 1ebdc306a8e88a6738fbece21cb1943fc9fa19e6 /js | |
parent | 928cc57730d1938c03013d3512c324677f5b8d2c (diff) | |
download | ninja-17d464e5bd224cdd8940855409359b411325f1df.tar.gz |
New: Adding re-render method to switching view
This now re-renders the design view when switching from code view. There are many outstanding issues, the Time-Line completely breaks and blocks Ninja, it is unknown why, there are too many dependencies. To make it work, we disabled that feature, although this check in does not include that, so it can be fixed proper. Also, the document controller creates a new tab per switch as it does not check that it is the same document. That bug must also be fixed. Finally, we need to hook up a new code view to the document, the current code view will not work as desired, so a new code view must be built and implemented.
Diffstat (limited to 'js')
-rwxr-xr-x | js/components/layout/document-bar.reel/document-bar.js | 13 | ||||
-rwxr-xr-x | js/document/document-html.js | 41 |
2 files changed, 51 insertions, 3 deletions
diff --git a/js/components/layout/document-bar.reel/document-bar.js b/js/components/layout/document-bar.reel/document-bar.js index 1a580284..dbb4fcad 100755 --- a/js/components/layout/document-bar.reel/document-bar.js +++ b/js/components/layout/document-bar.reel/document-bar.js | |||
@@ -171,6 +171,14 @@ exports.DocumentBar = Montage.create(Component, { | |||
171 | }, | 171 | }, |
172 | //////////////////////////////////////////////////////////////////// | 172 | //////////////////////////////////////////////////////////////////// |
173 | // | 173 | // |
174 | renderDesignView: { | ||
175 | value: function () { | ||
176 | //Reloading in design view (with updates from other view) | ||
177 | this.reloadView('design', this.fileTemplate); | ||
178 | } | ||
179 | }, | ||
180 | //////////////////////////////////////////////////////////////////// | ||
181 | // | ||
174 | showViewDesign: { | 182 | showViewDesign: { |
175 | value: function () { | 183 | value: function () { |
176 | // | 184 | // |
@@ -179,11 +187,14 @@ exports.DocumentBar = Montage.create(Component, { | |||
179 | this._currentDocument.model.switchViewTo('design'); | 187 | this._currentDocument.model.switchViewTo('design'); |
180 | this.btnCode.setAttribute('class', 'inactive'); | 188 | this.btnCode.setAttribute('class', 'inactive'); |
181 | this.btnDesign.removeAttribute('class'); | 189 | this.btnDesign.removeAttribute('class'); |
190 | //this._currentDocument.model.file.content.body = '<div class="test">hello</div><div class="test">hello</div>'; | ||
191 | var render = this.renderDesignView.bind(this._currentDocument); | ||
192 | render(); | ||
182 | } | 193 | } |
183 | } | 194 | } |
184 | }, | 195 | }, |
185 | //////////////////////////////////////////////////////////////////// | 196 | //////////////////////////////////////////////////////////////////// |
186 | // | 197 | //TODO: Implement code with that updates the file template through the ninja document parser |
187 | showViewCode: { | 198 | showViewCode: { |
188 | value: function () { | 199 | value: function () { |
189 | // | 200 | // |
diff --git a/js/document/document-html.js b/js/document/document-html.js index 5079cfca..b7dacf6a 100755 --- a/js/document/document-html.js +++ b/js/document/document-html.js | |||
@@ -76,7 +76,7 @@ exports.HtmlDocument = Montage.create(Component, { | |||
76 | //////////////////////////////////////////////////////////////////// | 76 | //////////////////////////////////////////////////////////////////// |
77 | // | 77 | // |
78 | init: { | 78 | init: { |
79 | value:function(file, context, callback, view, template) { | 79 | value: function(file, context, callback, view, template) { |
80 | //Storing callback data for loaded dispatch | 80 | //Storing callback data for loaded dispatch |
81 | this.loaded.callback = callback; | 81 | this.loaded.callback = callback; |
82 | this.loaded.context = context; | 82 | this.loaded.context = context; |
@@ -122,6 +122,44 @@ exports.HtmlDocument = Montage.create(Component, { | |||
122 | } | 122 | } |
123 | }, | 123 | }, |
124 | //////////////////////////////////////////////////////////////////// | 124 | //////////////////////////////////////////////////////////////////// |
125 | //TODO: Make into one method to use here and one init | ||
126 | reloadView: { | ||
127 | value: function (view, template) { | ||
128 | // | ||
129 | this.model.parentContainer.removeChild(this.model.views.design.iframe); | ||
130 | //Initiliazing views and hiding | ||
131 | if (this.model.views.design.initialize(this.model.parentContainer)) { | ||
132 | //Hiding iFrame, just initiliazing | ||
133 | this.model.views.design.hide(); | ||
134 | //Setting the iFrame property for reference in helper class | ||
135 | this.model.webGlHelper.iframe = this.model.views.design.iframe; | ||
136 | } else { | ||
137 | //ERROR: Design View not initialized | ||
138 | } | ||
139 | // | ||
140 | if (view === 'design') { | ||
141 | //TODO: Remove reference and use as part of model | ||
142 | this.currentView = 'design'; | ||
143 | //Setting current view object to design | ||
144 | this.model.currentView = this.model.views.design; | ||
145 | //Showing design iFrame | ||
146 | this.model.views.design.show(); | ||
147 | this.model.views.design.iframe.style.opacity = 0; | ||
148 | this.model.views.design.content = this.model.file.content; | ||
149 | //TODO: Improve reference (probably through binding values) | ||
150 | this.model.views.design._webGlHelper = this.model.webGlHelper; | ||
151 | //Rendering design view, using observers to know when template is ready | ||
152 | this.model.views.design.render(function () { | ||
153 | //Adding observer to know when template is ready | ||
154 | this._observer = new WebKitMutationObserver(this.handleTemplateReady.bind(this)); | ||
155 | this._observer.observe(this.model.views.design.document.head, {childList: true}); | ||
156 | }.bind(this), template, {viewCallback: this.handleViewReady, context: this}); | ||
157 | } else { | ||
158 | //TODO: Identify default view (probably code) | ||
159 | } | ||
160 | } | ||
161 | }, | ||
162 | //////////////////////////////////////////////////////////////////// | ||
125 | // | 163 | // |
126 | handleTemplateReady: { | 164 | handleTemplateReady: { |
127 | value: function (e) { | 165 | value: function (e) { |
@@ -140,7 +178,6 @@ exports.HtmlDocument = Montage.create(Component, { | |||
140 | if(typeof this.model.domContainer !== "undefined") { | 178 | if(typeof this.model.domContainer !== "undefined") { |
141 | this.model.domContainer = this.model.documentRoot; | 179 | this.model.domContainer = this.model.documentRoot; |
142 | } | 180 | } |
143 | |||
144 | //Making callback after view is loaded | 181 | //Making callback after view is loaded |
145 | this.loaded.callback.call(this.loaded.context, this); | 182 | this.loaded.callback.call(this.loaded.context, this); |
146 | } | 183 | } |