aboutsummaryrefslogtreecommitdiff
path: root/js/document/views
diff options
context:
space:
mode:
authorValerio Virgillito2012-06-05 13:49:59 -0700
committerValerio Virgillito2012-06-05 13:49:59 -0700
commit9a429f22a958fe372309e241c480923b7462d426 (patch)
tree56273e3769c18c5623f9e8671f73189a75ad372a /js/document/views
parent73a62c95b5635fee903457279f0f5b57f164e0b5 (diff)
parentfe376077b6e24bb01905cd83226912e25b043308 (diff)
downloadninja-9a429f22a958fe372309e241c480923b7462d426.tar.gz
Merge pull request #263 from joseeight/Components
Saving Google Components (reel components)
Diffstat (limited to 'js/document/views')
-rwxr-xr-xjs/document/views/design.js14
1 files changed, 10 insertions, 4 deletions
diff --git a/js/document/views/design.js b/js/document/views/design.js
index 9aeb370a..f7fbf3c5 100755
--- a/js/document/views/design.js
+++ b/js/document/views/design.js
@@ -154,7 +154,7 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, {
154 this._observer.body = new WebKitMutationObserver(this.insertBannerContent.bind(this)); 154 this._observer.body = new WebKitMutationObserver(this.insertBannerContent.bind(this));
155 this._observer.body.observe(this._bodyFragment, {childList: true}); 155 this._observer.body.observe(this._bodyFragment, {childList: true});
156 //Inserting <body> HTML and parsing URLs via mediator method 156 //Inserting <body> HTML and parsing URLs via mediator method
157 this._bodyFragment.innerHTML = '<ninjaloadinghack></ninjaloadinghack>'+(this.content.body.replace(/\b(href|src)\s*=\s*"([^"]*)"/g, this.application.ninja.ioMediator.getNinjaPropUrlRedirect.bind(this.application.ninja.ioMediator))).replace(/url\(([^"]*)(.+?)\1\)/g, this.application.ninja.ioMediator.getNinjaPropUrlRedirect.bind(this.application.ninja.ioMediator)); 157 this._bodyFragment.innerHTML = '<ninjaloadinghack></ninjaloadinghack>'+(this.content.body.replace(/\b(href|src)\s*=\s*"([^"]*)"/g, this.application.ninja.ioMediator.tmplt.getNinjaPropUrlRedirect.bind(this.application.ninja.ioMediator.tmplt))).replace(/url\(([^"]*)(.+?)\1\)/g, this.application.ninja.ioMediator.tmplt.getNinjaPropUrlRedirect.bind(this.application.ninja.ioMediator.tmplt));
158 } 158 }
159 } else { 159 } else {
160 //Creating temp code fragement to load head 160 //Creating temp code fragement to load head
@@ -163,12 +163,12 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, {
163 this._observer.head = new WebKitMutationObserver(this.insertHeadContent.bind(this)); 163 this._observer.head = new WebKitMutationObserver(this.insertHeadContent.bind(this));
164 this._observer.head.observe(this._headFragment, {childList: true}); 164 this._observer.head.observe(this._headFragment, {childList: true});
165 //Inserting <head> HTML and parsing URLs via mediator method 165 //Inserting <head> HTML and parsing URLs via mediator method
166 this._headFragment.innerHTML = (this.content.head.replace(/\b(href|src)\s*=\s*"([^"]*)"/g, this.application.ninja.ioMediator.getNinjaPropUrlRedirect.bind(this.application.ninja.ioMediator))).replace(/url\(([^"]*)(.+?)\1\)/g, this.application.ninja.ioMediator.getNinjaPropUrlRedirect.bind(this.application.ninja.ioMediator)); 166 this._headFragment.innerHTML = (this.content.head.replace(/\b(href|src)\s*=\s*"([^"]*)"/g, this.application.ninja.ioMediator.tmplt.getNinjaPropUrlRedirect.bind(this.application.ninja.ioMediator.tmplt))).replace(/url\(([^"]*)(.+?)\1\)/g, this.application.ninja.ioMediator.tmplt.getNinjaPropUrlRedirect.bind(this.application.ninja.ioMediator.tmplt));
167 //Adding event listener to know when the body is ready and make callback (using HTML5 new DOM Mutation Events) 167 //Adding event listener to know when the body is ready and make callback (using HTML5 new DOM Mutation Events)
168 this._observer.body = new WebKitMutationObserver(this.bodyContentLoaded.bind(this)); 168 this._observer.body = new WebKitMutationObserver(this.bodyContentLoaded.bind(this));
169 this._observer.body.observe(this.document.body, {childList: true}); 169 this._observer.body.observe(this.document.body, {childList: true});
170 //Inserting <body> HTML and parsing URLs via mediator method 170 //Inserting <body> HTML and parsing URLs via mediator method
171 this.document.body.innerHTML += '<ninjaloadinghack></ninjaloadinghack>'+(this.content.body.replace(/\b(href|src)\s*=\s*"([^"]*)"/g, this.application.ninja.ioMediator.getNinjaPropUrlRedirect.bind(this.application.ninja.ioMediator))).replace(/url\(([^"]*)(.+?)\1\)/g, this.application.ninja.ioMediator.getNinjaPropUrlRedirect.bind(this.application.ninja.ioMediator)); 171 this.document.body.innerHTML += '<ninjaloadinghack></ninjaloadinghack>'+(this.content.body.replace(/\b(href|src)\s*=\s*"([^"]*)"/g, this.application.ninja.ioMediator.tmplt.getNinjaPropUrlRedirect.bind(this.application.ninja.ioMediator.tmplt))).replace(/url\(([^"]*)(.+?)\1\)/g, this.application.ninja.ioMediator.tmplt.getNinjaPropUrlRedirect.bind(this.application.ninja.ioMediator.tmplt));
172 //Copying attributes to maintain same properties as the <body> 172 //Copying attributes to maintain same properties as the <body>
173 for (var n in this.content.document.body.attributes) { 173 for (var n in this.content.document.body.attributes) {
174 if (this.content.document.body.attributes[n].value) { 174 if (this.content.document.body.attributes[n].value) {
@@ -400,7 +400,13 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, {
400 //Initializing template with user's seriliazation 400 //Initializing template with user's seriliazation
401 var template = this.iframe.contentWindow.mjsTemplate.create(); 401 var template = this.iframe.contentWindow.mjsTemplate.create();
402 template.initWithDocument(this.iframe.contentWindow.document); 402 template.initWithDocument(this.iframe.contentWindow.document);
403 template.instantiateWithOwnerAndDocument(null, this.iframe.contentWindow.document, function (e){/*Nothing just a required extra parameter*/}); 403 template.instantiateWithOwnerAndDocument(null, this.iframe.contentWindow.document, function (){
404 //TODO: Verify this is properly done, seems like a hack
405 for (var c in template._deserializer._objects) {
406 //Forcing draw on components
407 template._deserializer._objects[c].needsDraw = true;
408 }
409 });
404 }.bind(this), false); 410 }.bind(this), false);
405 } 411 }
406 }, 412 },