aboutsummaryrefslogtreecommitdiff
path: root/js/document/views
diff options
context:
space:
mode:
authorValerio Virgillito2012-05-16 00:54:40 -0700
committerValerio Virgillito2012-05-16 00:54:40 -0700
commita9672abd32c2e03b8607c1af4903c90f7ff9531c (patch)
tree30da60ed624d3d60b09fc04672c502bbed3b11f8 /js/document/views
parent6dfe2e62b1d7a71daf097aac3a31213d564e6122 (diff)
parent2b21e91a3343229bb87179e08be1e532fcf9b8f9 (diff)
downloadninja-a9672abd32c2e03b8607c1af4903c90f7ff9531c.tar.gz
Merge branch 'dom-architecture' of github.com:Motorola-Mobility/ninja-internal into dom-architecture
Diffstat (limited to 'js/document/views')
-rwxr-xr-xjs/document/views/design.js27
1 files changed, 20 insertions, 7 deletions
diff --git a/js/document/views/design.js b/js/document/views/design.js
index 16d1ac06..c7aab1d7 100755
--- a/js/document/views/design.js
+++ b/js/document/views/design.js
@@ -159,16 +159,25 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, {
159 insertBannerContent: { 159 insertBannerContent: {
160 value: function (e) { 160 value: function (e) {
161 //Getting first element in DOM (assumes it's root) 161 //Getting first element in DOM (assumes it's root)
162 var banner = this._bodyFragment.getElementsByTagName('*')[1], 162 //TODO: Ensure wrapper logic is proper
163 ninjaBanner = this.document.body.getElementsByTagName('ninja-banner')[0]; 163 var wrapper = this._bodyFragment.getElementsByTagName('*')[1],
164 //Copying attributes to maintain same properties as the banner root 164 banner = this._bodyFragment.getElementsByTagName('*')[2],
165 ninjaBanner = this.document.body.getElementsByTagName('ninja-content')[0],
166 ninjaWrapper = this.document.body.getElementsByTagName('ninja-viewport')[0];
167 //Copying attributes to maintain same properties as the banner wrapper
168 for (var n in wrapper.attributes) {
169 if (wrapper.attributes[n].value) {
170 ninjaWrapper.setAttribute(wrapper.attributes[n].name, wrapper.attributes[n].value);
171 }
172 }
173 //Copying attributes to maintain same properties as the banner content
165 for (var n in banner.attributes) { 174 for (var n in banner.attributes) {
166 if (banner.attributes[n].value) { 175 if (banner.attributes[n].value) {
167 ninjaBanner.setAttribute(banner.attributes[n].name, banner.attributes[n].value); 176 ninjaBanner.setAttribute(banner.attributes[n].name, banner.attributes[n].value);
168 } 177 }
169 } 178 }
170 //Adjusting margin per size of document 179 //Adjusting margin per size of document
171 this.document.head.getElementsByTagName('style')[0].innerHTML += '\n ninja-banner {overflow: visible !important; margin-top: -'+Math.floor(this._template.size.height/2)+'px; margin-left: -'+Math.floor(this._template.size.width/2)+'px}'; 180 this.document.head.getElementsByTagName('style')[0].innerHTML += '\n ninja-viewport {overflow: visible !important;} ninja-content, ninja-viewport {width: ' + this._template.size.width + 'px; height: ' + this._template.size.height + 'px;}';
172 //Setting content in template 181 //Setting content in template
173 ninjaBanner.innerHTML = banner.innerHTML; 182 ninjaBanner.innerHTML = banner.innerHTML;
174 //Garbage collection 183 //Garbage collection
@@ -202,7 +211,7 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, {
202 //Removing event, only needed on initial load 211 //Removing event, only needed on initial load
203 this._observer.body.disconnect(); 212 this._observer.body.disconnect();
204 this._observer.body = null; 213 this._observer.body = null;
205 //Removing loading container 214 //Removing loading container (should be removed)
206 this.document.body.removeChild(this.document.getElementsByTagName('ninjaloadinghack')[0]); 215 this.document.body.removeChild(this.document.getElementsByTagName('ninjaloadinghack')[0]);
207 //Getting style and link tags in document 216 //Getting style and link tags in document
208 var stags = this.document.getElementsByTagName('style'), 217 var stags = this.document.getElementsByTagName('style'),
@@ -216,8 +225,12 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, {
216 for (i = 0; i < ltags.length; i++) { 225 for (i = 0; i < ltags.length; i++) {
217 // 226 //
218 if (ltags[i].href) { 227 if (ltags[i].href) {
219 //TODO: Verify this works for tags in body as well (working in head) 228 //Inseting <style> right above of <link> to maintain hierarchy
220 this.document.head.insertBefore(this.getStyleTagFromCssFile(ltags[i]), ltags[i]) || this.document.body.insertBefore(this.getStyleTagFromCssFile(ltags[i]), ltags[i]); 229 try {
230 this.document.head.insertBefore(this.getStyleTagFromCssFile(ltags[i]), ltags[i])
231 } catch (e) {
232 this.document.body.insertBefore(this.getStyleTagFromCssFile(ltags[i]), ltags[i]);
233 }
221 //Disabling tag once it has been reloaded 234 //Disabling tag once it has been reloaded
222 ltags[i].setAttribute('disabled', 'true'); 235 ltags[i].setAttribute('disabled', 'true');
223 } else { 236 } else {