aboutsummaryrefslogtreecommitdiff
path: root/js/document
diff options
context:
space:
mode:
authorJose Antonio Marquez2012-05-02 16:00:15 -0700
committerJose Antonio Marquez2012-05-02 16:00:15 -0700
commit0e59bc28a205292e2efd3ce1fb9a5e539086366d (patch)
tree9c5ca2e832678303600bfc729e6b224b43c46d69 /js/document
parentca6c4961649836ca175b235cbb0b261b5f9fb307 (diff)
downloadninja-0e59bc28a205292e2efd3ce1fb9a5e539086366d.tar.gz
Adding hack to allow for blank documents to open
Diffstat (limited to 'js/document')
-rwxr-xr-xjs/document/templates/montage-web/index.html4
-rwxr-xr-xjs/document/views/design.js13
2 files changed, 14 insertions, 3 deletions
diff --git a/js/document/templates/montage-web/index.html b/js/document/templates/montage-web/index.html
index 67cfec86..1c6b6287 100755
--- a/js/document/templates/montage-web/index.html
+++ b/js/document/templates/montage-web/index.html
@@ -25,6 +25,10 @@
25 -webkit-transform-style: preserve-3d; 25 -webkit-transform-style: preserve-3d;
26 -webkit-perspective: 1400px; 26 -webkit-perspective: 1400px;
27 } 27 }
28
29 ninjaloadinghack {
30 display: none;
31 }
28 32
29 .active-element-outline { 33 .active-element-outline {
30 outline: #adff2f solid 2px; 34 outline: #adff2f solid 2px;
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 }