diff options
Diffstat (limited to 'js/document/views')
-rwxr-xr-x | js/document/views/code.js | 6 | ||||
-rwxr-xr-x | js/document/views/design.js | 29 |
2 files changed, 18 insertions, 17 deletions
diff --git a/js/document/views/code.js b/js/document/views/code.js index 0a0ff5c1..c8b2a23e 100755 --- a/js/document/views/code.js +++ b/js/document/views/code.js | |||
@@ -82,12 +82,6 @@ exports.CodeDocumentView = Montage.create(BaseDocumentView, { | |||
82 | // | 82 | // |
83 | var type; | 83 | var type; |
84 | // | 84 | // |
85 | if(this.activeDocument) { | ||
86 | //need to hide only if another document was open before | ||
87 | //this.application.ninja.documentController._hideCurrentDocument(); | ||
88 | //this.hideOtherDocuments(doc.uuid); | ||
89 | } | ||
90 | // | ||
91 | switch(file.extension) { | 85 | switch(file.extension) { |
92 | case "css" : | 86 | case "css" : |
93 | type = "css"; | 87 | type = "css"; |
diff --git a/js/document/views/design.js b/js/document/views/design.js index c7313708..f7fbf3c5 100755 --- a/js/document/views/design.js +++ b/js/document/views/design.js | |||
@@ -63,11 +63,6 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, { | |||
63 | set: function(value) {this._document = value;} | 63 | set: function(value) {this._document = value;} |
64 | }, | 64 | }, |
65 | //////////////////////////////////////////////////////////////////// | 65 | //////////////////////////////////////////////////////////////////// |
66 | // | ||
67 | propertiesPanel: { | ||
68 | value: null | ||
69 | }, | ||
70 | //////////////////////////////////////////////////////////////////// | ||
71 | // | 66 | // |
72 | _liveNodeList: { | 67 | _liveNodeList: { |
73 | value: null | 68 | value: null |
@@ -129,7 +124,7 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, { | |||
129 | // | 124 | // |
130 | onTemplateLoad: { | 125 | onTemplateLoad: { |
131 | value: function (e) { | 126 | value: function (e) { |
132 | //console.log(this.iframe.contentWindow); | 127 | //TODO: Remove, this is a temp patch for webRequest API gate |
133 | this.application.ninja.documentController.redirectRequests = true; | 128 | this.application.ninja.documentController.redirectRequests = true; |
134 | //TODO: Add support to constructing URL with a base HREF | 129 | //TODO: Add support to constructing URL with a base HREF |
135 | var basetag = this.content.document.getElementsByTagName('base'); | 130 | var basetag = this.content.document.getElementsByTagName('base'); |
@@ -159,7 +154,7 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, { | |||
159 | this._observer.body = new WebKitMutationObserver(this.insertBannerContent.bind(this)); | 154 | this._observer.body = new WebKitMutationObserver(this.insertBannerContent.bind(this)); |
160 | this._observer.body.observe(this._bodyFragment, {childList: true}); | 155 | this._observer.body.observe(this._bodyFragment, {childList: true}); |
161 | //Inserting <body> HTML and parsing URLs via mediator method | 156 | //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)); | 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)); |
163 | } | 158 | } |
164 | } else { | 159 | } else { |
165 | //Creating temp code fragement to load head | 160 | //Creating temp code fragement to load head |
@@ -168,12 +163,12 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, { | |||
168 | this._observer.head = new WebKitMutationObserver(this.insertHeadContent.bind(this)); | 163 | this._observer.head = new WebKitMutationObserver(this.insertHeadContent.bind(this)); |
169 | this._observer.head.observe(this._headFragment, {childList: true}); | 164 | this._observer.head.observe(this._headFragment, {childList: true}); |
170 | //Inserting <head> HTML and parsing URLs via mediator method | 165 | //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)); | 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)); |
172 | //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) |
173 | this._observer.body = new WebKitMutationObserver(this.bodyContentLoaded.bind(this)); | 168 | this._observer.body = new WebKitMutationObserver(this.bodyContentLoaded.bind(this)); |
174 | this._observer.body.observe(this.document.body, {childList: true}); | 169 | this._observer.body.observe(this.document.body, {childList: true}); |
175 | //Inserting <body> HTML and parsing URLs via mediator method | 170 | //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)); | 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)); |
177 | //Copying attributes to maintain same properties as the <body> | 172 | //Copying attributes to maintain same properties as the <body> |
178 | for (var n in this.content.document.body.attributes) { | 173 | for (var n in this.content.document.body.attributes) { |
179 | if (this.content.document.body.attributes[n].value) { | 174 | if (this.content.document.body.attributes[n].value) { |
@@ -245,7 +240,7 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, { | |||
245 | this.document.body.removeChild(this.document.getElementsByTagName('ninjaloadinghack')[0]); | 240 | this.document.body.removeChild(this.document.getElementsByTagName('ninjaloadinghack')[0]); |
246 | //Getting style and link tags in document | 241 | //Getting style and link tags in document |
247 | var stags = this.document.getElementsByTagName('style'), | 242 | var stags = this.document.getElementsByTagName('style'), |
248 | ltags = this.document.getElementsByTagName('link'), i, | 243 | ltags = this.document.getElementsByTagName('link'), i, orgNodes, |
249 | scripttags = this.document.getElementsByTagName('script'); | 244 | scripttags = this.document.getElementsByTagName('script'); |
250 | //Temporarily checking for disabled special case (we must enabled for Ninja to access styles) | 245 | //Temporarily checking for disabled special case (we must enabled for Ninja to access styles) |
251 | this.ninjaDisableAttribute(stags); | 246 | this.ninjaDisableAttribute(stags); |
@@ -286,6 +281,12 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, { | |||
286 | } | 281 | } |
287 | //Storing node list for reference (might need to store in the model) | 282 | //Storing node list for reference (might need to store in the model) |
288 | this._liveNodeList = this.model.documentRoot.getElementsByTagName('*'); | 283 | this._liveNodeList = this.model.documentRoot.getElementsByTagName('*'); |
284 | //Getting list of original nodes | ||
285 | orgNodes = this.document.getElementsByTagName('*'); | ||
286 | //TODO: Figure out if this is ideal for identifying nodes created by Ninja | ||
287 | for (var n in orgNodes) { | ||
288 | if (orgNodes[n].getAttribute) orgNodes[n].setAttribute('data-ninja-node', 'true'); | ||
289 | } | ||
289 | //Initiliazing document model | 290 | //Initiliazing document model |
290 | document.application.njUtils.makeElementModel(this.model.documentRoot, "Body", "body"); | 291 | document.application.njUtils.makeElementModel(this.model.documentRoot, "Body", "body"); |
291 | //Makign callback if specified | 292 | //Makign callback if specified |
@@ -399,7 +400,13 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, { | |||
399 | //Initializing template with user's seriliazation | 400 | //Initializing template with user's seriliazation |
400 | var template = this.iframe.contentWindow.mjsTemplate.create(); | 401 | var template = this.iframe.contentWindow.mjsTemplate.create(); |
401 | template.initWithDocument(this.iframe.contentWindow.document); | 402 | template.initWithDocument(this.iframe.contentWindow.document); |
402 | 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 | }); | ||
403 | }.bind(this), false); | 410 | }.bind(this), false); |
404 | } | 411 | } |
405 | }, | 412 | }, |