aboutsummaryrefslogtreecommitdiff
path: root/js/document/views
diff options
context:
space:
mode:
authorValerio Virgillito2012-05-15 16:05:41 -0700
committerValerio Virgillito2012-05-15 16:05:41 -0700
commit17bbf73c73eadf018b03bb21a7da571901b5a389 (patch)
treebd478adcc531685d874ec186cbb20ea277f55c61 /js/document/views
parent3be58f9391cc2ef7f1d27ec69c98ea600cb93a22 (diff)
parent1c91748d8517656c0982c6fc194cd0010d02fb63 (diff)
downloadninja-17bbf73c73eadf018b03bb21a7da571901b5a389.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, 19 insertions, 8 deletions
diff --git a/js/document/views/design.js b/js/document/views/design.js
index 4c91ff39..c7aab1d7 100755
--- a/js/document/views/design.js
+++ b/js/document/views/design.js
@@ -160,17 +160,24 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, {
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 //TODO: Ensure wrapper logic is proper 162 //TODO: Ensure wrapper logic is proper
163 var banner = this._bodyFragment.getElementsByTagName('*')[2], 163 var wrapper = this._bodyFragment.getElementsByTagName('*')[1],
164 ninjaBanner = this.document.body.getElementsByTagName('ninja-content')[0]; 164 banner = this._bodyFragment.getElementsByTagName('*')[2],
165 //Copying attributes to maintain same properties as the banner root 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
166 for (var n in banner.attributes) { 174 for (var n in banner.attributes) {
167 if (banner.attributes[n].value) { 175 if (banner.attributes[n].value) {
168 ninjaBanner.setAttribute(banner.attributes[n].name, banner.attributes[n].value); 176 ninjaBanner.setAttribute(banner.attributes[n].name, banner.attributes[n].value);
169 } 177 }
170 } 178 }
171 //Adjusting margin per size of document 179 //Adjusting margin per size of document
172 //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;}';
173 this.document.head.getElementsByTagName('style')[0].innerHTML += '\n ninja-content {overflow: visible !important;} ninja-content, ninja-viewport {width: ' + this._template.size.width + 'px; height: ' + this._template.size.height + 'px;}';
174 //Setting content in template 181 //Setting content in template
175 ninjaBanner.innerHTML = banner.innerHTML; 182 ninjaBanner.innerHTML = banner.innerHTML;
176 //Garbage collection 183 //Garbage collection
@@ -204,7 +211,7 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, {
204 //Removing event, only needed on initial load 211 //Removing event, only needed on initial load
205 this._observer.body.disconnect(); 212 this._observer.body.disconnect();
206 this._observer.body = null; 213 this._observer.body = null;
207 //Removing loading container 214 //Removing loading container (should be removed)
208 this.document.body.removeChild(this.document.getElementsByTagName('ninjaloadinghack')[0]); 215 this.document.body.removeChild(this.document.getElementsByTagName('ninjaloadinghack')[0]);
209 //Getting style and link tags in document 216 //Getting style and link tags in document
210 var stags = this.document.getElementsByTagName('style'), 217 var stags = this.document.getElementsByTagName('style'),
@@ -218,8 +225,12 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, {
218 for (i = 0; i < ltags.length; i++) { 225 for (i = 0; i < ltags.length; i++) {
219 // 226 //
220 if (ltags[i].href) { 227 if (ltags[i].href) {
221 //TODO: Verify this works for tags in body as well (working in head) 228 //Inseting <style> right above of <link> to maintain hierarchy
222 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 }
223 //Disabling tag once it has been reloaded 234 //Disabling tag once it has been reloaded
224 ltags[i].setAttribute('disabled', 'true'); 235 ltags[i].setAttribute('disabled', 'true');
225 } else { 236 } else {