From 86837d69186bc4d1d6f54fc893c523de0972a0b9 Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Fri, 1 Jun 2012 11:53:57 -0700 Subject: Creating template mediator class This is to simplify code, more to be changed and added. --- js/document/views/design.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'js/document/views/design.js') diff --git a/js/document/views/design.js b/js/document/views/design.js index dedfe8b6..02e78e6e 100755 --- a/js/document/views/design.js +++ b/js/document/views/design.js @@ -159,7 +159,7 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, { this._observer.body = new WebKitMutationObserver(this.insertBannerContent.bind(this)); this._observer.body.observe(this._bodyFragment, {childList: true}); //Inserting HTML and parsing URLs via mediator method - this._bodyFragment.innerHTML = ''+(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)); + this._bodyFragment.innerHTML = ''+(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)); } } else { //Creating temp code fragement to load head @@ -168,12 +168,12 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, { this._observer.head = new WebKitMutationObserver(this.insertHeadContent.bind(this)); this._observer.head.observe(this._headFragment, {childList: true}); //Inserting HTML and parsing URLs via mediator method - 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)); + 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)); //Adding event listener to know when the body is ready and make callback (using HTML5 new DOM Mutation Events) this._observer.body = new WebKitMutationObserver(this.bodyContentLoaded.bind(this)); this._observer.body.observe(this.document.body, {childList: true}); //Inserting HTML and parsing URLs via mediator method - this.document.body.innerHTML += ''+(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)); + this.document.body.innerHTML += ''+(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)); //Copying attributes to maintain same properties as the for (var n in this.content.document.body.attributes) { if (this.content.document.body.attributes[n].value) { -- cgit v1.2.3 From 54c53c326ebde0631fe5720dc912c39341966f1f Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Fri, 1 Jun 2012 16:55:31 -0700 Subject: Adding open draw to reel components --- js/document/views/design.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'js/document/views/design.js') diff --git a/js/document/views/design.js b/js/document/views/design.js index 02e78e6e..05431d85 100755 --- a/js/document/views/design.js +++ b/js/document/views/design.js @@ -405,7 +405,13 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, { //Initializing template with user's seriliazation var template = this.iframe.contentWindow.mjsTemplate.create(); template.initWithDocument(this.iframe.contentWindow.document); - template.instantiateWithOwnerAndDocument(null, this.iframe.contentWindow.document, function (e){/*Nothing just a required extra parameter*/}); + template.instantiateWithOwnerAndDocument(null, this.iframe.contentWindow.document, function (){ + //TODO: Verify this is properly done, seems like a hack + for (var c in template._deserializer._objects) { + //Forcing draw on components + template._deserializer._objects[c].needsDraw = true; + } + }); }.bind(this), false); } }, -- cgit v1.2.3