diff options
Diffstat (limited to 'js/document/views/design.js')
-rwxr-xr-x | js/document/views/design.js | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/js/document/views/design.js b/js/document/views/design.js index 30a74e9c..fa9d412e 100755 --- a/js/document/views/design.js +++ b/js/document/views/design.js | |||
@@ -88,18 +88,19 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, { | |||
88 | this.document.styleSheets[k].ownerNode.setAttribute('data-ninja-template', 'true'); | 88 | this.document.styleSheets[k].ownerNode.setAttribute('data-ninja-template', 'true'); |
89 | } | 89 | } |
90 | } | 90 | } |
91 | |||
91 | //Creating temp code fragement to load head | 92 | //Creating temp code fragement to load head |
92 | this._headFragment = this.document.createElement('head'); | 93 | this._headFragment = this.document.createElement('head'); |
93 | //Adding event listener to know when head is ready, event only dispatched once when using innerHTML | 94 | //Adding event listener to know when head is ready, event only dispatched once when using innerHTML |
94 | this._observer.head = new WebKitMutationObserver(this.insertHeadContent.bind(this)); | 95 | this._observer.head = new WebKitMutationObserver(this.insertHeadContent.bind(this)); |
95 | this._observer.head.observe(this._headFragment, {childList: true}); | 96 | this._observer.head.observe(this._headFragment, {childList: true}); |
96 | //Inserting <head> HTML and parsing URLs via mediator method | 97 | //Inserting <head> HTML and parsing URLs via mediator method |
97 | 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)); | 98 | 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)); |
98 | //Adding event listener to know when the body is ready and make callback (using HTML5 new DOM Mutation Events) | 99 | //Adding event listener to know when the body is ready and make callback (using HTML5 new DOM Mutation Events) |
99 | this._observer.body = new WebKitMutationObserver(this.bodyContentLoaded.bind(this)); | 100 | this._observer.body = new WebKitMutationObserver(this.bodyContentLoaded.bind(this)); |
100 | this._observer.body.observe(this.document.body, {childList: true}); | 101 | this._observer.body.observe(this.document.body, {childList: true}); |
101 | //Inserting <body> HTML and parsing URLs via mediator method | 102 | //Inserting <body> HTML and parsing URLs via mediator method |
102 | 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)); | 103 | 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)); |
103 | } | 104 | } |
104 | }, | 105 | }, |
105 | //////////////////////////////////////////////////////////////////// | 106 | //////////////////////////////////////////////////////////////////// |
@@ -108,6 +109,10 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, { | |||
108 | value: function (e) { | 109 | value: function (e) { |
109 | //Removing event, only needed on initial load | 110 | //Removing event, only needed on initial load |
110 | this._observer.body.disconnect(); | 111 | this._observer.body.disconnect(); |
112 | //Removing loading container | ||
113 | this.document.body.removeChild(this.document.getElementsByTagName('ninjaloadinghack')[0]); | ||
114 | |||
115 | |||
111 | 116 | ||
112 | 117 | ||
113 | 118 | ||
@@ -138,7 +143,7 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, { | |||
138 | // | 143 | // |
139 | if(this.document.styleSheets.length > 0) { | 144 | if(this.document.styleSheets.length > 0) { |
140 | for (var i = 0; i < this.document.styleSheets.length; i++) { | 145 | for (var i = 0; i < this.document.styleSheets.length; i++) { |
141 | console.log(i); | 146 | // |
142 | } | 147 | } |
143 | } | 148 | } |
144 | 149 | ||
@@ -147,6 +152,8 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, { | |||
147 | 152 | ||
148 | 153 | ||
149 | 154 | ||
155 | |||
156 | |||
150 | //Makign callback if specified | 157 | //Makign callback if specified |
151 | if (this._callback) this._callback(); | 158 | if (this._callback) this._callback(); |
152 | } | 159 | } |