diff options
author | Jose Antonio Marquez Russo | 2012-07-23 19:07:11 -0700 |
---|---|---|
committer | Jose Antonio Marquez Russo | 2012-07-23 19:07:11 -0700 |
commit | 5946ec8651547f846520add097850470a09df635 (patch) | |
tree | 0278eeb16b60df94c35d1374796f92204b7be4ed | |
parent | 9c74db91b9f0c755eb8e8c36d5270b7db90c8ff7 (diff) | |
download | ninja-5946ec8651547f846520add097850470a09df635.tar.gz |
In Progress: Cleaning up merge
Cleaned up new updates. Still pending is adding functionality to parse the document when toggling views and fix Timeline errors. Code view also has some rending issues that will be fixed, this is just a clean up.
-rwxr-xr-x | js/components/layout/document-bar.reel/document-bar.js | 63 | ||||
-rwxr-xr-x | js/document/document-html.js | 27 |
2 files changed, 41 insertions, 49 deletions
diff --git a/js/components/layout/document-bar.reel/document-bar.js b/js/components/layout/document-bar.reel/document-bar.js index 803d2c3a..f5e61a18 100755 --- a/js/components/layout/document-bar.reel/document-bar.js +++ b/js/components/layout/document-bar.reel/document-bar.js | |||
@@ -73,12 +73,12 @@ exports.DocumentBar = Montage.create(Component, { | |||
73 | _codeEditorWrapper:{ | 73 | _codeEditorWrapper:{ |
74 | value: null | 74 | value: null |
75 | }, | 75 | }, |
76 | 76 | //////////////////////////////////////////////////////////////////// | |
77 | // | ||
77 | codeEditorWrapper:{ | 78 | codeEditorWrapper:{ |
78 | get : function() { | 79 | get: function() {return this._codeEditorWrapper;}, |
79 | return this._codeEditorWrapper; | 80 | set: function(value) { |
80 | }, | 81 | // |
81 | set : function(value) { | ||
82 | if(this._codeEditorWrapper !== value){ | 82 | if(this._codeEditorWrapper !== value){ |
83 | this._codeEditorWrapper = value; | 83 | this._codeEditorWrapper = value; |
84 | } | 84 | } |
@@ -89,9 +89,13 @@ exports.DocumentBar = Montage.create(Component, { | |||
89 | btnCode: { | 89 | btnCode: { |
90 | value: null | 90 | value: null |
91 | }, | 91 | }, |
92 | //////////////////////////////////////////////////////////////////// | ||
93 | // | ||
92 | btnDesign: { | 94 | btnDesign: { |
93 | value: null | 95 | value: null |
94 | }, | 96 | }, |
97 | //////////////////////////////////////////////////////////////////// | ||
98 | // | ||
95 | btnPreview: { | 99 | btnPreview: { |
96 | value: null | 100 | value: null |
97 | }, | 101 | }, |
@@ -209,52 +213,37 @@ exports.DocumentBar = Montage.create(Component, { | |||
209 | }, | 213 | }, |
210 | //////////////////////////////////////////////////////////////////// | 214 | //////////////////////////////////////////////////////////////////// |
211 | // | 215 | // |
212 | renderDesignView: { | 216 | showViewDesign: { |
213 | value: function () { | 217 | value: function () { |
214 | //Reloading in design view (with updates from other view) | 218 | // |
215 | this.reloadView('design', this.fileTemplate); | 219 | this.showView('design', this.renderDesignView, this.btnDesign, this.btnCode); |
216 | } | 220 | } |
217 | }, | 221 | }, |
218 | //////////////////////////////////////////////////////////////////// | 222 | //////////////////////////////////////////////////////////////////// |
219 | // | 223 | // |
220 | renderCodeView: { | 224 | showViewCode: { |
221 | value: function () { | 225 | value: function () { |
222 | //Reloading in code view (with updates from other view) | 226 | // |
223 | this.reloadView('code', this.fileTemplate); | 227 | this.showView('code', this.renderCodeView, this.btnCode, this.btnDesign); |
224 | } | 228 | } |
225 | }, | 229 | }, |
226 | //////////////////////////////////////////////////////////////////// | 230 | //////////////////////////////////////////////////////////////////// |
227 | // | 231 | // |
228 | showViewDesign: { | 232 | showView: { |
229 | value: function () { | 233 | value: function (view, render, aBtn, iBtn) { |
230 | // | 234 | //TODO: Remove reference to string view |
231 | if (this._currentDocument.model.currentView !== 'design') { | 235 | if (this._currentDocument.model.currentView !== view) { |
232 | // | 236 | // |
233 | this._currentDocument.model.switchViewTo('design'); | 237 | this._currentDocument.model.switchViewTo(view); |
234 | this.btnCode.setAttribute('class', 'inactive'); | 238 | iBtn.setAttribute('class', 'inactive'); |
235 | this.btnDesign.removeAttribute('class'); | 239 | aBtn.removeAttribute('class'); |
236 | //this._currentDocument.model.file.content.body = '<div class="test">hello</div><div class="test">hello</div>'; | 240 | //TODO: Add document parsing to reload view |
237 | var render = this.renderDesignView.bind(this._currentDocument); | 241 | this._currentDocument.reloadView(view, this.fileTemplate); |
238 | render(); | ||
239 | } | 242 | } |
240 | } | 243 | } |
241 | }, | 244 | }, |
242 | //////////////////////////////////////////////////////////////////// | 245 | //////////////////////////////////////////////////////////////////// |
243 | //TODO: Implement code with that updates the file template through the ninja document parser | 246 | // |
244 | showViewCode: { | ||
245 | value: function () { | ||
246 | // | ||
247 | if (this._currentDocument.model.currentView !== 'code') { | ||
248 | // | ||
249 | this._currentDocument.model.switchViewTo('code'); | ||
250 | this.btnDesign.setAttribute('class', 'inactive'); | ||
251 | this.btnCode.removeAttribute('class'); | ||
252 | var render = this.renderCodeView.bind(this._currentDocument); | ||
253 | render(); | ||
254 | } | ||
255 | } | ||
256 | }, | ||
257 | |||
258 | handleClick: { | 247 | handleClick: { |
259 | value: function(evt) { | 248 | value: function(evt) { |
260 | NJevent("executePreview"); | 249 | NJevent("executePreview"); |
diff --git a/js/document/document-html.js b/js/document/document-html.js index 76157a07..569b6d8b 100755 --- a/js/document/document-html.js +++ b/js/document/document-html.js | |||
@@ -35,7 +35,7 @@ var 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 | CodeDocumentView = require("js/document/views/design-code").DesignCodeView; |
39 | //////////////////////////////////////////////////////////////////////// | 39 | //////////////////////////////////////////////////////////////////////// |
40 | // | 40 | // |
41 | exports.HtmlDocument = Montage.create(Component, { | 41 | exports.HtmlDocument = Montage.create(Component, { |
@@ -78,7 +78,6 @@ exports.HtmlDocument = Montage.create(Component, { | |||
78 | // | 78 | // |
79 | init: { | 79 | init: { |
80 | value: function(file, context, callback, view, template) { | 80 | value: function(file, context, callback, view, template) { |
81 | var designCodeView = DesignCodeView.create(); | ||
82 | //Storing callback data for loaded dispatch | 81 | //Storing callback data for loaded dispatch |
83 | this.loaded.callback = callback; | 82 | this.loaded.callback = callback; |
84 | this.loaded.context = context; | 83 | this.loaded.context = context; |
@@ -87,7 +86,7 @@ exports.HtmlDocument = Montage.create(Component, { | |||
87 | file: {value: file}, | 86 | file: {value: file}, |
88 | fileTemplate: {value: template}, | 87 | fileTemplate: {value: template}, |
89 | parentContainer: {value: document.getElementById("iframeContainer")}, //Saving reference to parent container of all views (should be changed to buckets approach | 88 | parentContainer: {value: document.getElementById("iframeContainer")}, //Saving reference to parent container of all views (should be changed to buckets approach |
90 | views: {value: {'design': DesignDocumentView.create(), 'code': designCodeView}} //TODO: Add code view logic | 89 | views: {value: {'design': DesignDocumentView.create(), 'code': CodeDocumentView.create()}} //TODO: Add code view logic |
91 | }); | 90 | }); |
92 | //Calling the any init routines in the model | 91 | //Calling the any init routines in the model |
93 | this.model.init(); | 92 | this.model.init(); |
@@ -101,10 +100,10 @@ exports.HtmlDocument = Montage.create(Component, { | |||
101 | //ERROR: Design View not initialized | 100 | //ERROR: Design View not initialized |
102 | } | 101 | } |
103 | 102 | ||
104 | 103 | ||
104 | //TODO: Make sure you have a boolean to indicate if view was initilize and handle errors (just like design view above) | ||
105 | //initialize the code view for the html document and hide it since design is the default view | 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); | 106 | this.model.views.code.initialize(this.model.parentContainer); |
107 | |||
108 | this.model.views.code.hide(); | 107 | this.model.views.code.hide(); |
109 | 108 | ||
110 | 109 | ||
@@ -126,8 +125,10 @@ exports.HtmlDocument = Montage.create(Component, { | |||
126 | this._observer = new WebKitMutationObserver(this.handleTemplateReady.bind(this)); | 125 | this._observer = new WebKitMutationObserver(this.handleTemplateReady.bind(this)); |
127 | this._observer.observe(this.model.views.design.document.head, {childList: true}); | 126 | this._observer.observe(this.model.views.design.document.head, {childList: true}); |
128 | }.bind(this), template, {viewCallback: this.handleViewReady, context: this}); | 127 | }.bind(this), template, {viewCallback: this.handleViewReady, context: this}); |
128 | } else if (view === 'code'){ | ||
129 | //TODO: Add logic to open document in code view since it's now available | ||
129 | } else { | 130 | } else { |
130 | //TODO: Identify default view (probably code) | 131 | //TODO: Add error handling |
131 | } | 132 | } |
132 | } | 133 | } |
133 | }, | 134 | }, |
@@ -166,17 +167,19 @@ exports.HtmlDocument = Montage.create(Component, { | |||
166 | this._observer.observe(this.model.views.design.document.head, {childList: true}); | 167 | this._observer.observe(this.model.views.design.document.head, {childList: true}); |
167 | }.bind(this), template, {viewCallback: this.handleViewReady, context: this}); | 168 | }.bind(this), template, {viewCallback: this.handleViewReady, context: this}); |
168 | } else if(view === 'code'){ | 169 | } else if(view === 'code'){ |
169 | //TODO: Identify default view (probably code) | 170 | |
170 | 171 | ||
171 | //TODO:get the html content from the document | 172 | //TODO: Parse in memory document through template to get current document |
172 | content = '<html><head>'+this.model.file.content.head+'</head><body>'+this.model.file.content.body+'</body></html>';//dummy | 173 | content = '<html><head>'+this.model.file.content.head+'</head><body>'+this.model.file.content.body+'</body></html>';//dummy |
173 | 174 | ||
175 | |||
176 | // | ||
174 | this.model.views.code.load(content); | 177 | this.model.views.code.load(content); |
175 | |||
176 | //Setting current view object to code | 178 | //Setting current view object to code |
177 | this.currentView = 'code'; | 179 | this.currentView = 'code'; |
178 | this.model.currentView = this.model.views.code; | 180 | this.model.currentView = this.model.views.code; |
179 | 181 | } else { | |
182 | //TODO: Identify default view (probably code) - Error handling | ||
180 | } | 183 | } |
181 | } | 184 | } |