aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xjs/controllers/elements/element-controller.js3
-rwxr-xr-xjs/document/views/design.js10
-rw-r--r--js/mediators/io-mediator.js21
-rwxr-xr-xnode_modules/tools/template/template-creator.js1
4 files changed, 29 insertions, 6 deletions
diff --git a/js/controllers/elements/element-controller.js b/js/controllers/elements/element-controller.js
index 20225c61..8447c3d3 100755
--- a/js/controllers/elements/element-controller.js
+++ b/js/controllers/elements/element-controller.js
@@ -11,6 +11,9 @@ exports.ElementController = Montage.create(Component, {
11 11
12 addElement: { 12 addElement: {
13 value: function(el, styles) { 13 value: function(el, styles) {
14
15 if (el.getAttribute) el.setAttribute('data-ninja-node', 'true');
16
14 if(this.application.ninja.timeline.currentLayerSelected) { 17 if(this.application.ninja.timeline.currentLayerSelected) {
15 var selectedLayerIndex = this.application.ninja.timeline.getLayerIndexByID(this.application.ninja.timeline.currentLayerSelected.layerData.layerID); 18 var selectedLayerIndex = this.application.ninja.timeline.getLayerIndexByID(this.application.ninja.timeline.currentLayerSelected.layerData.layerID);
16 19
diff --git a/js/document/views/design.js b/js/document/views/design.js
index c7313708..dedfe8b6 100755
--- a/js/document/views/design.js
+++ b/js/document/views/design.js
@@ -129,7 +129,7 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, {
129 // 129 //
130 onTemplateLoad: { 130 onTemplateLoad: {
131 value: function (e) { 131 value: function (e) {
132 //console.log(this.iframe.contentWindow); 132 //TODO: Remove, this is a temp patch for webRequest API gate
133 this.application.ninja.documentController.redirectRequests = true; 133 this.application.ninja.documentController.redirectRequests = true;
134 //TODO: Add support to constructing URL with a base HREF 134 //TODO: Add support to constructing URL with a base HREF
135 var basetag = this.content.document.getElementsByTagName('base'); 135 var basetag = this.content.document.getElementsByTagName('base');
@@ -245,7 +245,7 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, {
245 this.document.body.removeChild(this.document.getElementsByTagName('ninjaloadinghack')[0]); 245 this.document.body.removeChild(this.document.getElementsByTagName('ninjaloadinghack')[0]);
246 //Getting style and link tags in document 246 //Getting style and link tags in document
247 var stags = this.document.getElementsByTagName('style'), 247 var stags = this.document.getElementsByTagName('style'),
248 ltags = this.document.getElementsByTagName('link'), i, 248 ltags = this.document.getElementsByTagName('link'), i, orgNodes,
249 scripttags = this.document.getElementsByTagName('script'); 249 scripttags = this.document.getElementsByTagName('script');
250 //Temporarily checking for disabled special case (we must enabled for Ninja to access styles) 250 //Temporarily checking for disabled special case (we must enabled for Ninja to access styles)
251 this.ninjaDisableAttribute(stags); 251 this.ninjaDisableAttribute(stags);
@@ -286,6 +286,12 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, {
286 } 286 }
287 //Storing node list for reference (might need to store in the model) 287 //Storing node list for reference (might need to store in the model)
288 this._liveNodeList = this.model.documentRoot.getElementsByTagName('*'); 288 this._liveNodeList = this.model.documentRoot.getElementsByTagName('*');
289 //Getting list of original nodes
290 orgNodes = this.document.getElementsByTagName('*');
291 //TODO: Figure out if this is ideal for identifying nodes created by Ninja
292 for (var n in orgNodes) {
293 if (orgNodes[n].getAttribute) orgNodes[n].setAttribute('data-ninja-node', 'true');
294 }
289 //Initiliazing document model 295 //Initiliazing document model
290 document.application.njUtils.makeElementModel(this.model.documentRoot, "Body", "body"); 296 document.application.njUtils.makeElementModel(this.model.documentRoot, "Body", "body");
291 //Makign callback if specified 297 //Makign callback if specified
diff --git a/js/mediators/io-mediator.js b/js/mediators/io-mediator.js
index e9ed86d7..1edcc06c 100644
--- a/js/mediators/io-mediator.js
+++ b/js/mediators/io-mediator.js
@@ -277,6 +277,8 @@ exports.IoMediator = Montage.create(Component, {
277 rootUrl = this.application.ninja.coreIoApi.rootUrl + escape((this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1])), 277 rootUrl = this.application.ninja.coreIoApi.rootUrl + escape((this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1])),
278 mjsCreator = template.mjsTemplateCreator.create(), 278 mjsCreator = template.mjsTemplateCreator.create(),
279 mJsSerialization, 279 mJsSerialization,
280 toremovetags = [],
281 presentNodes,
280 montageTemplate; 282 montageTemplate;
281 //Creating instance of template creator 283 //Creating instance of template creator
282 montageTemplate = mjsCreator.initWithDocument(template.document); 284 montageTemplate = mjsCreator.initWithDocument(template.document);
@@ -299,23 +301,34 @@ exports.IoMediator = Montage.create(Component, {
299 template.file.content.document.body.setAttribute(template.body.attributes[n].name, template.body.attributes[n].value); 301 template.file.content.document.body.setAttribute(template.body.attributes[n].name, template.body.attributes[n].value);
300 } 302 }
301 } 303 }
302 //TODO: Add attribute copying for <HEAD> and <HTML>
303 304
304 305
305 //console.log(template.file.content.document.getElementsByTagName('html')[0].innerHTML); 306
307 //TODO: Add attribute copying for <HEAD> and <HTML>
306 308
307 309
310
311 //Getting list of current nodes (Ninja DOM)
312 presentNodes = template.file.content.document.getElementsByTagName('*');
313 //Looping through nodes to determine origin and removing if not inserted by Ninja
314 for (var n in presentNodes) {
315 if (presentNodes[n].getAttribute && presentNodes[n].getAttribute('data-ninja-node') === null) {
316 toremovetags.push(presentNodes[n]);
317 } else if (presentNodes[n].getAttribute && presentNodes[n].getAttribute('data-ninja-node') !== null) {
318 //Removing attribute
319 presentNodes[n].removeAttribute('data-ninja-node');
320 }
321 }
308 //Getting all CSS (style or link) tags 322 //Getting all CSS (style or link) tags
309 var styletags = template.file.content.document.getElementsByTagName('style'), 323 var styletags = template.file.content.document.getElementsByTagName('style'),
310 linktags = template.file.content.document.getElementsByTagName('link'), 324 linktags = template.file.content.document.getElementsByTagName('link'),
311 toremovetags = [],
312 njtemplatetags = template.file.content.document.querySelectorAll('[data-ninja-template]'); 325 njtemplatetags = template.file.content.document.querySelectorAll('[data-ninja-template]');
313 326
314 ////////////////////////////////////////////////// 327 //////////////////////////////////////////////////
315 //TODO: Remove, temp hack, this is to be fixed by Montage 328 //TODO: Remove, temp hack, this is to be fixed by Montage
316 var basetags = template.file.content.document.getElementsByTagName('base'); 329 var basetags = template.file.content.document.getElementsByTagName('base');
317 for (var g in basetags) { 330 for (var g in basetags) {
318 if (basetags[g].getAttribute) toremovetags.push(basetags[g]); 331 if (basetags[g].getAttribute && basetags[g].href && basetags[g].href.indexOf('chrome-extension://') !== -1) toremovetags.push(basetags[g]);
319 } 332 }
320 ////////////////////////////////////////////////// 333 //////////////////////////////////////////////////
321 334
diff --git a/node_modules/tools/template/template-creator.js b/node_modules/tools/template/template-creator.js
index c5d3cffd..646c4171 100755
--- a/node_modules/tools/template/template-creator.js
+++ b/node_modules/tools/template/template-creator.js
@@ -57,6 +57,7 @@ var TemplateCreator = exports.TemplateCreator = Montage.create(Template, /** @le
57 component._element = targetNode; 57 component._element = targetNode;
58 components[label] = component; 58 components[label] = component;
59 componentsChildComponents[label] = component.childComponents; 59 componentsChildComponents[label] = component.childComponents;
60 component._element.setAttribute('data-ninja-node', 'true');
60 delete component.childComponents; 61 delete component.childComponents;
61 } else { 62 } else {
62 for (var i = 0; (childNode = childNodes[i]); i++) { 63 for (var i = 0; (childNode = childNodes[i]); i++) {