diff options
Diffstat (limited to 'js/document/views/design.js')
-rwxr-xr-x | js/document/views/design.js | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/js/document/views/design.js b/js/document/views/design.js index dedfe8b6..05431d85 100755 --- a/js/document/views/design.js +++ b/js/document/views/design.js | |||
@@ -159,7 +159,7 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, { | |||
159 | this._observer.body = new WebKitMutationObserver(this.insertBannerContent.bind(this)); | 159 | this._observer.body = new WebKitMutationObserver(this.insertBannerContent.bind(this)); |
160 | this._observer.body.observe(this._bodyFragment, {childList: true}); | 160 | this._observer.body.observe(this._bodyFragment, {childList: true}); |
161 | //Inserting <body> HTML and parsing URLs via mediator method | 161 | //Inserting <body> HTML and parsing URLs via mediator method |
162 | 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)); | 162 | 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)); |
163 | } | 163 | } |
164 | } else { | 164 | } else { |
165 | //Creating temp code fragement to load head | 165 | //Creating temp code fragement to load head |
@@ -168,12 +168,12 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, { | |||
168 | this._observer.head = new WebKitMutationObserver(this.insertHeadContent.bind(this)); | 168 | this._observer.head = new WebKitMutationObserver(this.insertHeadContent.bind(this)); |
169 | this._observer.head.observe(this._headFragment, {childList: true}); | 169 | this._observer.head.observe(this._headFragment, {childList: true}); |
170 | //Inserting <head> HTML and parsing URLs via mediator method | 170 | //Inserting <head> HTML and parsing URLs via mediator method |
171 | 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)); | 171 | 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)); |
172 | //Adding event listener to know when the body is ready and make callback (using HTML5 new DOM Mutation Events) | 172 | //Adding event listener to know when the body is ready and make callback (using HTML5 new DOM Mutation Events) |
173 | this._observer.body = new WebKitMutationObserver(this.bodyContentLoaded.bind(this)); | 173 | this._observer.body = new WebKitMutationObserver(this.bodyContentLoaded.bind(this)); |
174 | this._observer.body.observe(this.document.body, {childList: true}); | 174 | this._observer.body.observe(this.document.body, {childList: true}); |
175 | //Inserting <body> HTML and parsing URLs via mediator method | 175 | //Inserting <body> HTML and parsing URLs via mediator method |
176 | 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)); | 176 | 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)); |
177 | //Copying attributes to maintain same properties as the <body> | 177 | //Copying attributes to maintain same properties as the <body> |
178 | for (var n in this.content.document.body.attributes) { | 178 | for (var n in this.content.document.body.attributes) { |
179 | if (this.content.document.body.attributes[n].value) { | 179 | if (this.content.document.body.attributes[n].value) { |
@@ -405,7 +405,13 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, { | |||
405 | //Initializing template with user's seriliazation | 405 | //Initializing template with user's seriliazation |
406 | var template = this.iframe.contentWindow.mjsTemplate.create(); | 406 | var template = this.iframe.contentWindow.mjsTemplate.create(); |
407 | template.initWithDocument(this.iframe.contentWindow.document); | 407 | template.initWithDocument(this.iframe.contentWindow.document); |
408 | template.instantiateWithOwnerAndDocument(null, this.iframe.contentWindow.document, function (e){/*Nothing just a required extra parameter*/}); | 408 | template.instantiateWithOwnerAndDocument(null, this.iframe.contentWindow.document, function (){ |
409 | //TODO: Verify this is properly done, seems like a hack | ||
410 | for (var c in template._deserializer._objects) { | ||
411 | //Forcing draw on components | ||
412 | template._deserializer._objects[c].needsDraw = true; | ||
413 | } | ||
414 | }); | ||
409 | }.bind(this), false); | 415 | }.bind(this), false); |
410 | } | 416 | } |
411 | }, | 417 | }, |