From 36d50b6599ab98559c76e1fe57b1bb131c4433da Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Thu, 19 Apr 2012 15:53:18 -0700 Subject: Clean up --- js/mediators/io-mediator.js | 4 ---- 1 file changed, 4 deletions(-) (limited to 'js/mediators/io-mediator.js') diff --git a/js/mediators/io-mediator.js b/js/mediators/io-mediator.js index 057a849d..c20ae8f7 100644 --- a/js/mediators/io-mediator.js +++ b/js/mediators/io-mediator.js @@ -153,10 +153,6 @@ exports.IoMediator = Montage.create(Component, { // switch (file.mode) { case 'html': - - - //TODO: Add check for Monatage library to copy - //Getting content from function to properly handle saving assets (as in external if flagged) contents = this.parseNinjaTemplateToHtml(file); break; -- cgit v1.2.3 From a1e8540f5656e62db6a89f3af7829be6b259b7ed Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Tue, 8 May 2012 17:33:13 -0700 Subject: Adding SAVE for I/O Adding save functionality to new template. Need to implement user UI for prompts and also clean up... --- js/mediators/io-mediator.js | 89 ++++++++++++++++++++++++++------------------- 1 file changed, 52 insertions(+), 37 deletions(-) (limited to 'js/mediators/io-mediator.js') diff --git a/js/mediators/io-mediator.js b/js/mediators/io-mediator.js index c20ae8f7..6d146c97 100644 --- a/js/mediators/io-mediator.js +++ b/js/mediators/io-mediator.js @@ -147,21 +147,21 @@ exports.IoMediator = Montage.create(Component, { // fileSave: { enumerable: false, - value: function (file, callback) { + value: function (doc, callback) { // var contents, save; // - switch (file.mode) { + switch (doc.mode) { case 'html': //Getting content from function to properly handle saving assets (as in external if flagged) - contents = this.parseNinjaTemplateToHtml(file); + contents = this.parseNinjaTemplateToHtml(doc); break; default: - contents = file.content; + contents = doc.content; break; } //Making call to save file - save = this.fio.saveFile({ uri: file.document.uri, contents: contents }); + save = this.fio.saveFile({ uri: doc.file.uri, contents: contents }); //Checking for callback if (callback) callback(save); } @@ -192,7 +192,7 @@ exports.IoMediator = Montage.create(Component, { //Setting content to temp doc.getElementsByTagName('html')[0].innerHTML = html; //Creating return object - return { head: doc.head.innerHTML, body: doc.body.innerHTML, document: doc }; + return {head: doc.head.innerHTML, body: doc.body.innerHTML, document: doc}; } }, //////////////////////////////////////////////////////////////////// @@ -203,12 +203,26 @@ exports.IoMediator = Montage.create(Component, { var regexRootUrl, rootUrl = this.application.ninja.coreIoApi.rootUrl + escape((this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1])); regexRootUrl = new RegExp(rootUrl.replace(/\//gi, '\\\/'), 'gi'); //Injecting head and body into old document - template.document.content.document.head.innerHTML = template.head.replace(regexRootUrl, ''); - template.document.content.document.body.innerHTML = template.body.replace(regexRootUrl, ''); + template.file.content.document.head.innerHTML = template.head.innerHTML.replace(regexRootUrl, ''); + template.file.content.document.body.innerHTML = template.body.innerHTML.replace(regexRootUrl, ''); //Getting all CSS (style or link) tags - var styletags = template.document.content.document.getElementsByTagName('style'), - linktags = template.document.content.document.getElementsByTagName('link'), - toremovetags = []; + var styletags = template.file.content.document.getElementsByTagName('style'), + linktags = template.file.content.document.getElementsByTagName('link'), + toremovetags = [], + njtemplatetags = template.file.content.document.querySelectorAll('[data-ninja-template]'), + basetags = template.file.content.document.getElementsByTagName('base'); + + ////////////////////////////////////////////////// + //TODO: Remove, temp hack to avoid montage + for (var g in basetags) { + if (basetags[g].getAttribute) toremovetags.push(basetags[g]); + } + ////////////////////////////////////////////////// + + // + for (var f in njtemplatetags) { + if (njtemplatetags[f].getAttribute) toremovetags.push(njtemplatetags[f]); + } //Getting styles tags to be removed from document if (styletags.length) { for (var j = 0; j < styletags.length; j++) { @@ -225,15 +239,16 @@ exports.IoMediator = Montage.create(Component, { for (var h = 0; toremovetags[h]; h++) { try { //Checking head first - template.document.content.document.head.removeChild(toremovetags[h]); + template.file.content.document.head.removeChild(toremovetags[h]); } catch (e) { - try { + + } + try { //Checking body if not in head - template.document.content.document.body.removeChild(toremovetags[h]); + template.file.content.document.body.removeChild(toremovetags[h]); } catch (e) { //Error, not found! } - } } //Removing disabled tags from tags that were not originally disabled by user (Ninja enables all) for (var l in linktags) { @@ -251,13 +266,13 @@ exports.IoMediator = Montage.create(Component, { if (template.styles) { //Getting all style tags var styleCounter = 0, - docStyles = template.document.content.document.getElementsByTagName('style'); + docStyles = template.file.content.document.getElementsByTagName('style'); //Looping through all style tags for (var i in template.styles) { if (template.styles[i].ownerNode) { if (template.styles[i].ownerNode.getAttribute) { //Checking for node not to be loaded from file - if (template.styles[i].ownerNode.getAttribute('data-ninja-uri') === null && !template.styles[i].ownerNode.getAttribute('data-ninja-template')) { + if (template.styles[i].ownerNode.getAttribute('data-ninja-uri') === null && !template.styles[i].ownerNode.getAttribute('data-ninja-template') && !template.styles[i].ownerNode.getAttribute('data-ninja-external-url')) { if (docStyles[styleCounter]) { //Inseting data from rules array into tag as string docStyles[styleCounter].innerHTML = this.getCssFromRules(template.styles[i].cssRules); @@ -271,8 +286,8 @@ exports.IoMediator = Montage.create(Component, { } else if (template.css) { //Getting all style and link tags var styleCounter = 0, - docStyles = template.document.content.document.getElementsByTagName('style'), - docLinks = template.document.content.document.getElementsByTagName('link'); + docStyles = template.file.content.document.getElementsByTagName('style'), + docLinks = template.file.content.document.getElementsByTagName('link'); //Removing Ninja Data Attributes for (var n in docLinks) { if (docLinks[n].attributes) { @@ -352,13 +367,13 @@ exports.IoMediator = Montage.create(Component, { if (this.application.ninja.coreIoApi.ninjaLibrary.libs[i].name === 'RDGE') { rdgeDirName = (this.application.ninja.coreIoApi.ninjaLibrary.libs[i].name + this.application.ninja.coreIoApi.ninjaLibrary.libs[i].version).toLowerCase(); rdgeVersion = this.application.ninja.coreIoApi.ninjaLibrary.libs[i].version; - this.application.ninja.coreIoApi.ninjaLibrary.copyLibToCloud(template.document.root, rdgeDirName); + this.application.ninja.coreIoApi.ninjaLibrary.copyLibToCloud(template.file.root, rdgeDirName); } else { //TODO: Error handle no available library to copy } } // - var json, matchingtags = [], webgltag, scripts = template.document.content.document.getElementsByTagName('script'), webgljstag, webgllibtag, webglrdgetag, mjstag, mjslibtag; + var json, matchingtags = [], webgltag, scripts = template.file.content.document.getElementsByTagName('script'), webgljstag, webgllibtag, webglrdgetag, mjstag, mjslibtag; // for (var i in scripts) { if (scripts[i].getAttribute) { @@ -393,32 +408,32 @@ exports.IoMediator = Montage.create(Component, { } // if (!webglrdgetag) { - webglrdgetag = template.document.content.document.createElement('script'); + webglrdgetag = template.file.content.document.createElement('script'); webglrdgetag.setAttribute('type', 'text/javascript'); webglrdgetag.setAttribute('src', rdgeDirName + '/rdge-compiled.js'); webglrdgetag.setAttribute('data-ninja-webgl-rdge', 'true'); - template.document.content.document.head.appendChild(webglrdgetag); + template.file.content.document.head.appendChild(webglrdgetag); } // if (!webgllibtag) { - webgllibtag = template.document.content.document.createElement('script'); + webgllibtag = template.file.content.document.createElement('script'); webgllibtag.setAttribute('type', 'text/javascript'); webgllibtag.setAttribute('src', rdgeDirName + '/canvas-runtime.js'); webgllibtag.setAttribute('data-ninja-webgl-lib', 'true'); - template.document.content.document.head.appendChild(webgllibtag); + template.file.content.document.head.appendChild(webgllibtag); } // if (!webgltag) { - webgltag = template.document.content.document.createElement('script'); + webgltag = template.file.content.document.createElement('script'); webgltag.setAttribute('data-ninja-webgl', 'true'); - template.document.content.document.head.appendChild(webgltag); + template.file.content.document.head.appendChild(webgltag); } //TODO: Remove this tag and place inside JS file if (!webgljstag) { - webgljstag = template.document.content.document.createElement('script'); + webgljstag = template.file.content.document.createElement('script'); webgljstag.setAttribute('type', 'text/javascript'); webgljstag.setAttribute('data-ninja-webgl-js', 'true'); - template.document.content.document.head.appendChild(webgljstag); + template.file.content.document.head.appendChild(webgljstag); } //TODO: Decide if this should be over-writter or only written on creation var rootElement = 'document.body'; //TODO: Set actual root element @@ -463,33 +478,33 @@ function loadWebGL (e) {\n\ // if (template.mjs && mjsCounter > 0) { var mjsDirName, mjsVersion, - mjscode = temp.initWithHeadAndBodyElements(template.document.content.document.documentElement.head, template.document.content.document.documentElement.body, mjsComponents)._ownerSerialization; + mjscode = temp.initWithHeadAndBodyElements(template.file.content.document.documentElement.head, template.file.content.document.documentElement.body, mjsComponents)._ownerSerialization; //Copy Montage library if needed for (var i in this.application.ninja.coreIoApi.ninjaLibrary.libs) { //Checking for Montage library to be available if (this.application.ninja.coreIoApi.ninjaLibrary.libs[i].name === 'Montage') { mjsDirName = (this.application.ninja.coreIoApi.ninjaLibrary.libs[i].name + this.application.ninja.coreIoApi.ninjaLibrary.libs[i].version).toLowerCase(); mjsVersion = this.application.ninja.coreIoApi.ninjaLibrary.libs[i].version; - this.application.ninja.coreIoApi.ninjaLibrary.copyLibToCloud(template.document.root, mjsDirName); + this.application.ninja.coreIoApi.ninjaLibrary.copyLibToCloud(template.file.root, mjsDirName); //TODO: Fix to allow no overwrite and nested locations - var packjson = this.application.ninja.coreIoApi.createFile({ uri: template.document.root + 'package.json', contents: '{"mappings": {"montage": "' + mjsDirName + '/"}}' }); + var packjson = this.application.ninja.coreIoApi.createFile({ uri: template.file.root + 'package.json', contents: '{"mappings": {"montage": "' + mjsDirName + '/"}}' }); } else { //TODO: Error handle no available library to copy } } // if (!mjslibtag) { - mjslibtag = template.document.content.document.createElement('script'); + mjslibtag = template.file.content.document.createElement('script'); mjslibtag.setAttribute('type', 'text/javascript'); mjslibtag.setAttribute('src', mjsDirName + '/montage.js'); mjslibtag.setAttribute('data-mjs-lib', 'true'); - template.document.content.document.head.appendChild(mjslibtag); + template.file.content.document.head.appendChild(mjslibtag); } // if (!mjstag) { - mjstag = template.document.content.document.createElement('script'); + mjstag = template.file.content.document.createElement('script'); mjstag.setAttribute('type', 'text/montage-serialization'); - template.document.content.document.head.appendChild(mjstag); + template.file.content.document.head.appendChild(mjstag); } // mjstag.innerHTML = mjscode; @@ -502,7 +517,7 @@ function loadWebGL (e) {\n\ //Cleaning URLs from HTML - var cleanHTML = template.document.content.document.documentElement.outerHTML.replace(/(\b(?:(?:https?|ftp|file|[A-Za-z]+):\/\/|www\.|ftp\.)(?:\([-A-Z0-9+&@#\/%=~_|$?!:,.]*\)|[-A-Z0-9+&@#\/%=~_|$?!:,.])*(?:\([-A-Z0-9+&@#\/%=~_|$?!:,.]*\)|[A-Z0-9+&@#\/%=~_|$]))/gi, parseNinjaRootUrl.bind(this)); + var cleanHTML = template.file.content.document.documentElement.outerHTML.replace(/(\b(?:(?:https?|ftp|file|[A-Za-z]+):\/\/|www\.|ftp\.)(?:\([-A-Z0-9+&@#\/%=~_|$?!:,.]*\)|[-A-Z0-9+&@#\/%=~_|$?!:,.])*(?:\([-A-Z0-9+&@#\/%=~_|$?!:,.]*\)|[A-Z0-9+&@#\/%=~_|$]))/gi, parseNinjaRootUrl.bind(this)); // function parseNinjaRootUrl(url) { if (url.indexOf(this.application.ninja.coreIoApi.rootUrl) !== -1) { -- cgit v1.2.3 From 3811f72f8cd8caaa2d13fa695b918f25facb85c5 Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Wed, 9 May 2012 16:28:13 -0700 Subject: Preliminary Montage Template Cleanup The template creator is currently not returning serializing code, but does clean the document. Need to investigate reason why, currently all components are removed on save. --- js/mediators/io-mediator.js | 40 ++++++++++++++++++++++++++++++---------- 1 file changed, 30 insertions(+), 10 deletions(-) (limited to 'js/mediators/io-mediator.js') diff --git a/js/mediators/io-mediator.js b/js/mediators/io-mediator.js index 6d146c97..cf44ab9d 100644 --- a/js/mediators/io-mediator.js +++ b/js/mediators/io-mediator.js @@ -10,7 +10,7 @@ var Montage = require("montage/core/core").Montage, Component = require("montage/ui/component").Component, FileIo = require("js/io/system/fileio").FileIo, ProjectIo = require("js/io/system/projectio").ProjectIo, - TemplateCreator = require("node_modules/tools/template-creator").TemplateCreator; + TemplateCreator = require("node_modules/tools/template/template-creator").TemplateCreator; //////////////////////////////////////////////////////////////////////// // exports.IoMediator = Montage.create(Component, { @@ -203,20 +203,38 @@ exports.IoMediator = Montage.create(Component, { var regexRootUrl, rootUrl = this.application.ninja.coreIoApi.rootUrl + escape((this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1])); regexRootUrl = new RegExp(rootUrl.replace(/\//gi, '\\\/'), 'gi'); //Injecting head and body into old document - template.file.content.document.head.innerHTML = template.head.innerHTML.replace(regexRootUrl, ''); - template.file.content.document.body.innerHTML = template.body.innerHTML.replace(regexRootUrl, ''); + //template.file.content.document.head.innerHTML = template.head.innerHTML.replace(regexRootUrl, ''); + //template.file.content.document.body.innerHTML = template.body.innerHTML.replace(regexRootUrl, ''); + + + + //Testing using montage clean up method + var mjscode, mjsTemp = TemplateCreator.create(); + + //mjscode = mjsTemp.initWithHeadAndBodyElements(template.head, template.body); + mjscode = mjsTemp.initWithDocument(template.file.content.document); + + console.log(template.head, mjscode._document.head); + template.file.content.document.head.innerHTML = mjscode._document.head.innerHTML.replace(regexRootUrl, ''); + template.file.content.document.body.innerHTML = mjscode._document.body.innerHTML.replace(regexRootUrl, ''); + + + + //Getting all CSS (style or link) tags var styletags = template.file.content.document.getElementsByTagName('style'), linktags = template.file.content.document.getElementsByTagName('link'), toremovetags = [], - njtemplatetags = template.file.content.document.querySelectorAll('[data-ninja-template]'), - basetags = template.file.content.document.getElementsByTagName('base'); + njtemplatetags = template.file.content.document.querySelectorAll('[data-ninja-template]'); ////////////////////////////////////////////////// - //TODO: Remove, temp hack to avoid montage + //TODO: Remove, temp hack, this is to be fixed by Montage + /* +var basetags = template.file.content.document.getElementsByTagName('base'); for (var g in basetags) { if (basetags[g].getAttribute) toremovetags.push(basetags[g]); } +*/ ////////////////////////////////////////////////// // @@ -469,9 +487,9 @@ function loadWebGL (e) {\n\ // - var mjsCounter = 0, mjsComponents = [], temp = TemplateCreator.create(); - // - for (var m in template.mjs) { + + /* +for (var m in template.mjs) { mjsComponents.push(template.mjs[m]); mjsCounter++; } @@ -509,6 +527,7 @@ function loadWebGL (e) {\n\ // mjstag.innerHTML = mjscode; } +*/ @@ -570,7 +589,8 @@ function loadWebGL (e) {\n\ // getDocRootUrl: { value: function () { - return this.application.ninja.coreIoApi.rootUrl + escape((this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1]).replace(/\/\//gi, '/')); + //TODO: Add support for model.baseHref (base tag) + return this.application.ninja.coreIoApi.rootUrl + escape((this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1]).replace(/\/\//gi, '/')); } }, //////////////////////////////////////////////////////////////////// -- cgit v1.2.3 From ec68c665dee1936312842c546e1c7347f05dc555 Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Wed, 9 May 2012 16:56:08 -0700 Subject: Temp removing montage clean up --- js/mediators/io-mediator.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'js/mediators/io-mediator.js') diff --git a/js/mediators/io-mediator.js b/js/mediators/io-mediator.js index cf44ab9d..dae0f359 100644 --- a/js/mediators/io-mediator.js +++ b/js/mediators/io-mediator.js @@ -203,20 +203,23 @@ exports.IoMediator = Montage.create(Component, { var regexRootUrl, rootUrl = this.application.ninja.coreIoApi.rootUrl + escape((this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1])); regexRootUrl = new RegExp(rootUrl.replace(/\//gi, '\\\/'), 'gi'); //Injecting head and body into old document - //template.file.content.document.head.innerHTML = template.head.innerHTML.replace(regexRootUrl, ''); - //template.file.content.document.body.innerHTML = template.body.innerHTML.replace(regexRootUrl, ''); + template.file.content.document.head.innerHTML = template.head.innerHTML.replace(regexRootUrl, ''); + template.file.content.document.body.innerHTML = template.body.innerHTML.replace(regexRootUrl, ''); - //Testing using montage clean up method + /* +//Testing using montage clean up method var mjscode, mjsTemp = TemplateCreator.create(); //mjscode = mjsTemp.initWithHeadAndBodyElements(template.head, template.body); - mjscode = mjsTemp.initWithDocument(template.file.content.document); + //mjscode = mjsTemp.initWithDocument(template.file.content.document); + mjscode = mjsTemp.initWithDocument(template.document); console.log(template.head, mjscode._document.head); template.file.content.document.head.innerHTML = mjscode._document.head.innerHTML.replace(regexRootUrl, ''); template.file.content.document.body.innerHTML = mjscode._document.body.innerHTML.replace(regexRootUrl, ''); +*/ @@ -229,12 +232,10 @@ exports.IoMediator = Montage.create(Component, { ////////////////////////////////////////////////// //TODO: Remove, temp hack, this is to be fixed by Montage - /* -var basetags = template.file.content.document.getElementsByTagName('base'); + var basetags = template.file.content.document.getElementsByTagName('base'); for (var g in basetags) { if (basetags[g].getAttribute) toremovetags.push(basetags[g]); } -*/ ////////////////////////////////////////////////// // -- cgit v1.2.3 From c87e538fdc337639bc4d54bb087dbf2b4f20297f Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Fri, 11 May 2012 14:41:20 -0700 Subject: Adding support for new templates This is supported for NEW and OPEN, SAVE is not supported yet by I/O. Saving works, but it will not be a banner template. --- js/mediators/io-mediator.js | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'js/mediators/io-mediator.js') diff --git a/js/mediators/io-mediator.js b/js/mediators/io-mediator.js index dae0f359..0bff1f3b 100644 --- a/js/mediators/io-mediator.js +++ b/js/mediators/io-mediator.js @@ -53,14 +53,14 @@ exports.IoMediator = Montage.create(Component, { // fileNew: { enumerable: false, - value: function (file, template, callback) { + value: function (file, url, callback, template) { //Loading template from template URL var xhr = new XMLHttpRequest(), result; - xhr.open("GET", template, false); + xhr.open("GET", url, false); xhr.send(); if (xhr.readyState === 4) { //Making call to create file, checking for return code - switch (this.fio.newFile({ uri: file, contents: xhr.response })) { + switch (this.fio.newFile({ uri: file, contents: parseTemplate(xhr.response, template) })) { case 201: result = { status: 201, success: true, uri: file }; break; @@ -74,6 +74,20 @@ exports.IoMediator = Montage.create(Component, { result = { status: 500, success: false, uri: file }; break; } + //TODO: Improve template data injection + function parseTemplate (content, template) { + // + if (template.name.toLowerCase() === 'banner') { + //Getting dimensions of banner + var dimensions = template.id.split('x'); + dimensions = {width: String(dimensions[0])+'px', height: String(dimensions[1])+'px'}; + // + content = content.replace(/Dimensions@@@/gi, "Dimensions@@@"+template.id); + content = content.replace(/ninja-banner {}/gi, "ninja-banner {width: "+dimensions.width+"; height: "+dimensions.height+"}"); + } + // + return content; + } } else { result = { status: 500, success: false, uri: file }; } -- cgit v1.2.3 From d114f222cb48a101ffdb1b88d43823ca16f2c7df Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Fri, 11 May 2012 15:15:33 -0700 Subject: Fixing overflow bug for banner templates Ensuring overflow is visible but saved as hidden. --- js/mediators/io-mediator.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/mediators/io-mediator.js') diff --git a/js/mediators/io-mediator.js b/js/mediators/io-mediator.js index 0bff1f3b..c9c7203f 100644 --- a/js/mediators/io-mediator.js +++ b/js/mediators/io-mediator.js @@ -83,7 +83,7 @@ exports.IoMediator = Montage.create(Component, { dimensions = {width: String(dimensions[0])+'px', height: String(dimensions[1])+'px'}; // content = content.replace(/Dimensions@@@/gi, "Dimensions@@@"+template.id); - content = content.replace(/ninja-banner {}/gi, "ninja-banner {width: "+dimensions.width+"; height: "+dimensions.height+"}"); + content = content.replace(/ninja-banner {}/gi, "ninja-banner {overflow: hidden; width: "+dimensions.width+"; height: "+dimensions.height+"}"); } // return content; -- cgit v1.2.3 From 734b6ad96d25bb67d0db4a0a75c331468e194809 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Mon, 14 May 2012 12:05:41 -0700 Subject: Fixing 3d to work in banner templates. Signed-off-by: Nivesh Rajbhandari --- js/mediators/io-mediator.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/mediators/io-mediator.js') diff --git a/js/mediators/io-mediator.js b/js/mediators/io-mediator.js index c9c7203f..7d55b20f 100644 --- a/js/mediators/io-mediator.js +++ b/js/mediators/io-mediator.js @@ -83,7 +83,7 @@ exports.IoMediator = Montage.create(Component, { dimensions = {width: String(dimensions[0])+'px', height: String(dimensions[1])+'px'}; // content = content.replace(/Dimensions@@@/gi, "Dimensions@@@"+template.id); - content = content.replace(/ninja-banner {}/gi, "ninja-banner {overflow: hidden; width: "+dimensions.width+"; height: "+dimensions.height+"}"); + content = content.replace(/ninja-banner {}/gi, "ninja-banner {overflow: visible; width: "+dimensions.width+"; height: "+dimensions.height+"}"); } // return content; -- cgit v1.2.3 From 150b6eb2be526627d588a0cf7226ddad7a399b8f Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Mon, 14 May 2012 16:35:09 -0700 Subject: Fixing banner template Need to implement save, but this cover open and new. --- js/mediators/io-mediator.js | 1 + 1 file changed, 1 insertion(+) (limited to 'js/mediators/io-mediator.js') diff --git a/js/mediators/io-mediator.js b/js/mediators/io-mediator.js index 7d55b20f..7a905fc6 100644 --- a/js/mediators/io-mediator.js +++ b/js/mediators/io-mediator.js @@ -84,6 +84,7 @@ exports.IoMediator = Montage.create(Component, { // content = content.replace(/Dimensions@@@/gi, "Dimensions@@@"+template.id); content = content.replace(/ninja-banner {}/gi, "ninja-banner {overflow: visible; width: "+dimensions.width+"; height: "+dimensions.height+"}"); + content = content.replace(/ninja-content-wrapper {}/gi, "ninja-content-wrapper {overflow: hidden; width: "+dimensions.width+"; height: "+dimensions.height+"}"); } // return content; -- cgit v1.2.3 From 3ce003c8d99f0043d460b5833c9e5e6bf6a9f0a7 Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Tue, 15 May 2012 11:24:05 -0700 Subject: Adding animation sub-category to new file Adding animation sub-category to template in new file. --- js/mediators/io-mediator.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/mediators/io-mediator.js') diff --git a/js/mediators/io-mediator.js b/js/mediators/io-mediator.js index 7a905fc6..696a69dc 100644 --- a/js/mediators/io-mediator.js +++ b/js/mediators/io-mediator.js @@ -77,7 +77,7 @@ exports.IoMediator = Montage.create(Component, { //TODO: Improve template data injection function parseTemplate (content, template) { // - if (template.name.toLowerCase() === 'banner') { + if (template.name.toLowerCase() === 'banner' || template.name.toLowerCase() === 'animation') { //Getting dimensions of banner var dimensions = template.id.split('x'); dimensions = {width: String(dimensions[0])+'px', height: String(dimensions[1])+'px'}; -- cgit v1.2.3 From bffc9b2a4bd3480a6e369a36660ce402f7e16aba Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Tue, 15 May 2012 12:01:37 -0700 Subject: File save for banner template Adding file save for templates, completing I/O. --- js/mediators/io-mediator.js | 47 +++++++++++++++++++++++++++++++++++++-------- 1 file changed, 39 insertions(+), 8 deletions(-) (limited to 'js/mediators/io-mediator.js') diff --git a/js/mediators/io-mediator.js b/js/mediators/io-mediator.js index 696a69dc..aa2165c7 100644 --- a/js/mediators/io-mediator.js +++ b/js/mediators/io-mediator.js @@ -169,7 +169,11 @@ exports.IoMediator = Montage.create(Component, { switch (doc.mode) { case 'html': //Getting content from function to properly handle saving assets (as in external if flagged) - contents = this.parseNinjaTemplateToHtml(doc); + if (doc.template && (doc.template.type === 'banner' || doc.template.type === 'animation')) { + contents = this.parseNinjaTemplateToHtml(doc, true); + } else { + contents = this.parseNinjaTemplateToHtml(doc); + } break; default: contents = doc.content; @@ -214,7 +218,7 @@ exports.IoMediator = Montage.create(Component, { //TODO: Expand to allow more templates, clean up variables parseNinjaTemplateToHtml: { enumerable: false, - value: function (template) { + value: function (template, ninjaWrapper) { var regexRootUrl, rootUrl = this.application.ninja.coreIoApi.rootUrl + escape((this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1])); regexRootUrl = new RegExp(rootUrl.replace(/\//gi, '\\\/'), 'gi'); //Injecting head and body into old document @@ -446,7 +450,11 @@ exports.IoMediator = Montage.create(Component, { webglrdgetag.setAttribute('type', 'text/javascript'); webglrdgetag.setAttribute('src', rdgeDirName + '/rdge-compiled.js'); webglrdgetag.setAttribute('data-ninja-webgl-rdge', 'true'); - template.file.content.document.head.appendChild(webglrdgetag); + if (ninjaWrapper) { + template.file.content.document.body.getElementsByTagName('ninja-content')[0].appendChild(webglrdgetag); + } else { + template.file.content.document.head.appendChild(webglrdgetag); + } } // if (!webgllibtag) { @@ -454,20 +462,32 @@ exports.IoMediator = Montage.create(Component, { webgllibtag.setAttribute('type', 'text/javascript'); webgllibtag.setAttribute('src', rdgeDirName + '/canvas-runtime.js'); webgllibtag.setAttribute('data-ninja-webgl-lib', 'true'); - template.file.content.document.head.appendChild(webgllibtag); + if (ninjaWrapper) { + template.file.content.document.body.getElementsByTagName('ninja-content')[0].appendChild(webgllibtag); + } else { + template.file.content.document.head.appendChild(webgllibtag); + } } // if (!webgltag) { webgltag = template.file.content.document.createElement('script'); webgltag.setAttribute('data-ninja-webgl', 'true'); - template.file.content.document.head.appendChild(webgltag); + if (ninjaWrapper) { + template.file.content.document.body.getElementsByTagName('ninja-content')[0].appendChild(webgltag); + } else { + template.file.content.document.head.appendChild(webgltag); + } } //TODO: Remove this tag and place inside JS file if (!webgljstag) { webgljstag = template.file.content.document.createElement('script'); webgljstag.setAttribute('type', 'text/javascript'); webgljstag.setAttribute('data-ninja-webgl-js', 'true'); - template.file.content.document.head.appendChild(webgljstag); + if (ninjaWrapper) { + template.file.content.document.body.getElementsByTagName('ninja-content')[0].appendChild(webgljstag); + } else { + template.file.content.document.head.appendChild(webgljstag); + } } //TODO: Decide if this should be over-writter or only written on creation var rootElement = 'document.body'; //TODO: Set actual root element @@ -549,10 +569,15 @@ for (var m in template.mjs) { - + //Cleaning URLs from HTML - var cleanHTML = template.file.content.document.documentElement.outerHTML.replace(/(\b(?:(?:https?|ftp|file|[A-Za-z]+):\/\/|www\.|ftp\.)(?:\([-A-Z0-9+&@#\/%=~_|$?!:,.]*\)|[-A-Z0-9+&@#\/%=~_|$?!:,.])*(?:\([-A-Z0-9+&@#\/%=~_|$?!:,.]*\)|[A-Z0-9+&@#\/%=~_|$]))/gi, parseNinjaRootUrl.bind(this)); + var cleanHTML; + if (ninjaWrapper) { + cleanHTML = template.file.content.document.body.innerHTML.replace(/(\b(?:(?:https?|ftp|file|[A-Za-z]+):\/\/|www\.|ftp\.)(?:\([-A-Z0-9+&@#\/%=~_|$?!:,.]*\)|[-A-Z0-9+&@#\/%=~_|$?!:,.])*(?:\([-A-Z0-9+&@#\/%=~_|$?!:,.]*\)|[A-Z0-9+&@#\/%=~_|$]))/gi, parseNinjaRootUrl.bind(this)); + } else { + cleanHTML = template.file.content.document.documentElement.outerHTML.replace(/(\b(?:(?:https?|ftp|file|[A-Za-z]+):\/\/|www\.|ftp\.)(?:\([-A-Z0-9+&@#\/%=~_|$?!:,.]*\)|[-A-Z0-9+&@#\/%=~_|$?!:,.])*(?:\([-A-Z0-9+&@#\/%=~_|$?!:,.]*\)|[A-Z0-9+&@#\/%=~_|$]))/gi, parseNinjaRootUrl.bind(this)); + } // function parseNinjaRootUrl(url) { if (url.indexOf(this.application.ninja.coreIoApi.rootUrl) !== -1) { @@ -561,6 +586,12 @@ for (var m in template.mjs) { return url; } } + // + if (ninjaWrapper) { + cleanHTML = cleanHTML.replace(/ninja-viewport/gi, 'div'); + cleanHTML = cleanHTML.replace(/ninja-content/gi, 'div'); + } + // return this.getPrettyHtml(cleanHTML.replace(this.getAppTemplatesUrlRegEx(), '')); } -- cgit v1.2.3 From 374ab6d8980b810a1c943b14a1aea07cb85389ad Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Tue, 15 May 2012 13:26:07 -0700 Subject: Saving body attributes --- js/mediators/io-mediator.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'js/mediators/io-mediator.js') diff --git a/js/mediators/io-mediator.js b/js/mediators/io-mediator.js index aa2165c7..8346c75e 100644 --- a/js/mediators/io-mediator.js +++ b/js/mediators/io-mediator.js @@ -224,8 +224,14 @@ exports.IoMediator = Montage.create(Component, { //Injecting head and body into old document template.file.content.document.head.innerHTML = template.head.innerHTML.replace(regexRootUrl, ''); template.file.content.document.body.innerHTML = template.body.innerHTML.replace(regexRootUrl, ''); - - + //Copying attributes to maintain same properties as the + for (var n in template.body.attributes) { + if (template.body.attributes[n].value) { + // + template.file.content.document.body.setAttribute(template.body.attributes[n].name, template.body.attributes[n].value); + } + } + //TODO: Add attribute copying for and /* //Testing using montage clean up method -- cgit v1.2.3 From 5de553a1b3bdd8783ab6ce017ae70369ad92a890 Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Wed, 16 May 2012 11:37:05 -0700 Subject: Fixing preview bug Also setting up for Montage component serialization. --- js/mediators/io-mediator.js | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'js/mediators/io-mediator.js') diff --git a/js/mediators/io-mediator.js b/js/mediators/io-mediator.js index 8346c75e..e6f2cc2d 100644 --- a/js/mediators/io-mediator.js +++ b/js/mediators/io-mediator.js @@ -234,17 +234,13 @@ exports.IoMediator = Montage.create(Component, { //TODO: Add attribute copying for and /* -//Testing using montage clean up method - var mjscode, mjsTemp = TemplateCreator.create(); - - //mjscode = mjsTemp.initWithHeadAndBodyElements(template.head, template.body); - //mjscode = mjsTemp.initWithDocument(template.file.content.document); - mjscode = mjsTemp.initWithDocument(template.document); + var tc = this.application.ninja.documentController.activeDocument.model.views.design.iframe.contentWindow.mjsTemplateCreator, code; + code = tc.initWithDocument(this.application.ninja.documentController.activeDocument.model.views.design.iframe.contentWindow.document); + console.log(code._ownerSerialization, code._document.getElementsByTagName('html')[0].innerHTML); - console.log(template.head, mjscode._document.head); template.file.content.document.head.innerHTML = mjscode._document.head.innerHTML.replace(regexRootUrl, ''); template.file.content.document.body.innerHTML = mjscode._document.body.innerHTML.replace(regexRootUrl, ''); -*/ + */ -- cgit v1.2.3 From ac750fd9b9c311dcd48c6ee309607edc6fa048e1 Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Wed, 16 May 2012 14:22:18 -0700 Subject: Adding basic montage components I/O Only for saving basic components without a reel. --- js/mediators/io-mediator.js | 72 +++++++++++++++++++++++++++++++++++++-------- 1 file changed, 59 insertions(+), 13 deletions(-) (limited to 'js/mediators/io-mediator.js') diff --git a/js/mediators/io-mediator.js b/js/mediators/io-mediator.js index e6f2cc2d..6cdf70fe 100644 --- a/js/mediators/io-mediator.js +++ b/js/mediators/io-mediator.js @@ -219,11 +219,24 @@ exports.IoMediator = Montage.create(Component, { parseNinjaTemplateToHtml: { enumerable: false, value: function (template, ninjaWrapper) { - var regexRootUrl, rootUrl = this.application.ninja.coreIoApi.rootUrl + escape((this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1])); + //TODO: Improve reference for rootUrl + var regexRootUrl, + rootUrl = this.application.ninja.coreIoApi.rootUrl + escape((this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1])), + montageTemplate = template.mjsTemplateCreator.initWithDocument(template.document), + mJsSerialization; + //Setting up expression for parsing URLs regexRootUrl = new RegExp(rootUrl.replace(/\//gi, '\\\/'), 'gi'); //Injecting head and body into old document - template.file.content.document.head.innerHTML = template.head.innerHTML.replace(regexRootUrl, ''); - template.file.content.document.body.innerHTML = template.body.innerHTML.replace(regexRootUrl, ''); + if (montageTemplate._ownerSerialization.length > 0) { + template.file.content.document.head.innerHTML = montageTemplate._document.head.innerHTML.replace(regexRootUrl, ''); + template.file.content.document.body.innerHTML = montageTemplate._document.body.innerHTML.replace(regexRootUrl, ''); + // + mJsSerialization = montageTemplate._ownerSerialization; + } else { + template.file.content.document.head.innerHTML = template.head.innerHTML.replace(regexRootUrl, ''); + template.file.content.document.body.innerHTML = template.body.innerHTML.replace(regexRootUrl, ''); + } + //Copying attributes to maintain same properties as the for (var n in template.body.attributes) { if (template.body.attributes[n].value) { @@ -233,15 +246,6 @@ exports.IoMediator = Montage.create(Component, { } //TODO: Add attribute copying for and - /* - var tc = this.application.ninja.documentController.activeDocument.model.views.design.iframe.contentWindow.mjsTemplateCreator, code; - code = tc.initWithDocument(this.application.ninja.documentController.activeDocument.model.views.design.iframe.contentWindow.document); - console.log(code._ownerSerialization, code._document.getElementsByTagName('html')[0].innerHTML); - - template.file.content.document.head.innerHTML = mjscode._document.head.innerHTML.replace(regexRootUrl, ''); - template.file.content.document.body.innerHTML = mjscode._document.body.innerHTML.replace(regexRootUrl, ''); - */ - @@ -521,7 +525,49 @@ function loadWebGL (e) {\n\ - + + //Checking for Montage + if (mJsSerialization) { + //Copy Montage library if needed + for (var i in this.application.ninja.coreIoApi.ninjaLibrary.libs) { + //Checking for Montage library to be available + if (this.application.ninja.coreIoApi.ninjaLibrary.libs[i].name === 'Montage') { + mjsDirName = (this.application.ninja.coreIoApi.ninjaLibrary.libs[i].name + this.application.ninja.coreIoApi.ninjaLibrary.libs[i].version).toLowerCase(); + mjsVersion = this.application.ninja.coreIoApi.ninjaLibrary.libs[i].version; + this.application.ninja.coreIoApi.ninjaLibrary.copyLibToCloud(template.file.root, mjsDirName); + //TODO: Fix to allow no overwrite and nested locations + var packjson = this.application.ninja.coreIoApi.createFile({ uri: template.file.root + 'package.json', contents: '{"mappings": {"montage": "' + mjsDirName + '/montage/"}}' }); + } else { + //TODO: Error handle no available library to copy + } + } + // + if (!mjslibtag) { + mjslibtag = template.file.content.document.createElement('script'); + mjslibtag.setAttribute('type', 'text/javascript'); + mjslibtag.setAttribute('src', mjsDirName + '/montage/montage.js'); + mjslibtag.setAttribute('data-mjs-lib', 'true'); + if (ninjaWrapper) { + template.file.content.document.body.getElementsByTagName('ninja-content')[0].appendChild(mjslibtag); + } else { + template.file.content.document.head.appendChild(mjslibtag); + } + + } + // + if (!mjstag) { + mjstag = template.file.content.document.createElement('script'); + mjstag.setAttribute('type', 'text/montage-serialization'); + if (ninjaWrapper) { + template.file.content.document.body.getElementsByTagName('ninja-content')[0].appendChild(mjstag); + } else { + template.file.content.document.head.appendChild(mjstag); + } + + } + // + mjstag.innerHTML = mJsSerialization; + } // -- cgit v1.2.3 From a2afa558aba65b81f8b1b58687629def14ea471d Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Wed, 16 May 2012 14:37:32 -0700 Subject: Fixing reference to serialization tag --- js/mediators/io-mediator.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/mediators/io-mediator.js') diff --git a/js/mediators/io-mediator.js b/js/mediators/io-mediator.js index 6cdf70fe..7f7bd72a 100644 --- a/js/mediators/io-mediator.js +++ b/js/mediators/io-mediator.js @@ -433,7 +433,7 @@ exports.IoMediator = Montage.create(Component, { if (scripts[i].getAttribute('data-ninja-webgl-rdge') !== null) { webglrdgetag = scripts[i]; // TODO: Add logic to delete unneccesary tags } - if (scripts[i].getAttribute('type') !== 'text/montage-serialization') { + if (scripts[i].getAttribute('type') === 'text/montage-serialization') { mjstag = scripts[i]; // TODO: Add logic to delete unneccesary tags } if (scripts[i].getAttribute('data-mjs-lib') !== null) { -- cgit v1.2.3 From 5cc5d29736d8bf253e3a168cdd6443e839ffb23c Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Wed, 16 May 2012 15:42:09 -0700 Subject: Fixing serialization referencing (new object per save) --- js/mediators/io-mediator.js | 60 +++++---------------------------------------- 1 file changed, 6 insertions(+), 54 deletions(-) (limited to 'js/mediators/io-mediator.js') diff --git a/js/mediators/io-mediator.js b/js/mediators/io-mediator.js index 7f7bd72a..b1916446 100644 --- a/js/mediators/io-mediator.js +++ b/js/mediators/io-mediator.js @@ -222,8 +222,11 @@ exports.IoMediator = Montage.create(Component, { //TODO: Improve reference for rootUrl var regexRootUrl, rootUrl = this.application.ninja.coreIoApi.rootUrl + escape((this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1])), - montageTemplate = template.mjsTemplateCreator.initWithDocument(template.document), - mJsSerialization; + mjsCreator = template.mjsTemplateCreator.create(), + mJsSerialization, + montageTemplate; + // + montageTemplate = mjsCreator.initWithDocument(template.document); //Setting up expression for parsing URLs regexRootUrl = new RegExp(rootUrl.replace(/\//gi, '\\\/'), 'gi'); //Injecting head and body into old document @@ -567,58 +570,8 @@ function loadWebGL (e) {\n\ } // mjstag.innerHTML = mJsSerialization; + mjsCreator = null; } - - - // - - /* -for (var m in template.mjs) { - mjsComponents.push(template.mjs[m]); - mjsCounter++; - } - // - if (template.mjs && mjsCounter > 0) { - var mjsDirName, mjsVersion, - mjscode = temp.initWithHeadAndBodyElements(template.file.content.document.documentElement.head, template.file.content.document.documentElement.body, mjsComponents)._ownerSerialization; - //Copy Montage library if needed - for (var i in this.application.ninja.coreIoApi.ninjaLibrary.libs) { - //Checking for Montage library to be available - if (this.application.ninja.coreIoApi.ninjaLibrary.libs[i].name === 'Montage') { - mjsDirName = (this.application.ninja.coreIoApi.ninjaLibrary.libs[i].name + this.application.ninja.coreIoApi.ninjaLibrary.libs[i].version).toLowerCase(); - mjsVersion = this.application.ninja.coreIoApi.ninjaLibrary.libs[i].version; - this.application.ninja.coreIoApi.ninjaLibrary.copyLibToCloud(template.file.root, mjsDirName); - //TODO: Fix to allow no overwrite and nested locations - var packjson = this.application.ninja.coreIoApi.createFile({ uri: template.file.root + 'package.json', contents: '{"mappings": {"montage": "' + mjsDirName + '/"}}' }); - } else { - //TODO: Error handle no available library to copy - } - } - // - if (!mjslibtag) { - mjslibtag = template.file.content.document.createElement('script'); - mjslibtag.setAttribute('type', 'text/javascript'); - mjslibtag.setAttribute('src', mjsDirName + '/montage.js'); - mjslibtag.setAttribute('data-mjs-lib', 'true'); - template.file.content.document.head.appendChild(mjslibtag); - } - // - if (!mjstag) { - mjstag = template.file.content.document.createElement('script'); - mjstag.setAttribute('type', 'text/montage-serialization'); - template.file.content.document.head.appendChild(mjstag); - } - // - mjstag.innerHTML = mjscode; - } -*/ - - - - - - - //Cleaning URLs from HTML var cleanHTML; if (ninjaWrapper) { @@ -639,7 +592,6 @@ for (var m in template.mjs) { cleanHTML = cleanHTML.replace(/ninja-viewport/gi, 'div'); cleanHTML = cleanHTML.replace(/ninja-content/gi, 'div'); } - // return this.getPrettyHtml(cleanHTML.replace(this.getAppTemplatesUrlRegEx(), '')); } -- cgit v1.2.3 From 792c83a0fe8f7f22d139684ed6d711a2c334c098 Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Thu, 17 May 2012 16:55:19 -0700 Subject: Adding component initialization on open This is for opening components, selection is still not reflecting component data. --- js/mediators/io-mediator.js | 78 +++++++++++++++++++++++++-------------------- 1 file changed, 43 insertions(+), 35 deletions(-) (limited to 'js/mediators/io-mediator.js') diff --git a/js/mediators/io-mediator.js b/js/mediators/io-mediator.js index b1916446..c506e186 100644 --- a/js/mediators/io-mediator.js +++ b/js/mediators/io-mediator.js @@ -225,7 +225,7 @@ exports.IoMediator = Montage.create(Component, { mjsCreator = template.mjsTemplateCreator.create(), mJsSerialization, montageTemplate; - // + //Creating instance of template creator montageTemplate = mjsCreator.initWithDocument(template.document); //Setting up expression for parsing URLs regexRootUrl = new RegExp(rootUrl.replace(/\//gi, '\\\/'), 'gi'); @@ -239,7 +239,6 @@ exports.IoMediator = Montage.create(Component, { template.file.content.document.head.innerHTML = template.head.innerHTML.replace(regexRootUrl, ''); template.file.content.document.body.innerHTML = template.body.innerHTML.replace(regexRootUrl, ''); } - //Copying attributes to maintain same properties as the for (var n in template.body.attributes) { if (template.body.attributes[n].value) { @@ -250,6 +249,7 @@ exports.IoMediator = Montage.create(Component, { //TODO: Add attribute copying for and + //console.log(template.file.content.document.getElementsByTagName('html')[0].innerHTML); //Getting all CSS (style or link) tags @@ -266,7 +266,7 @@ exports.IoMediator = Montage.create(Component, { } ////////////////////////////////////////////////// - // + //Adding to tags to be removed form template for (var f in njtemplatetags) { if (njtemplatetags[f].getAttribute) toremovetags.push(njtemplatetags[f]); } @@ -405,6 +405,31 @@ exports.IoMediator = Montage.create(Component, { } } } + // + var matchingtags = [], scripts = template.file.content.document.getElementsByTagName('script'), webgltag, webgljstag, webgllibtag, webglrdgetag, mjstag, mjslibtag; + // + for (var i in scripts) { + if (scripts[i].getAttribute) { + if (scripts[i].getAttribute('data-ninja-webgl') !== null) {//TODO: Use querySelectorAll + matchingtags.push(scripts[i]); + } + if (scripts[i].getAttribute('data-ninja-webgl-js') !== null) { + webgljstag = scripts[i]; // TODO: Add logic to delete unneccesary tags + } + if (scripts[i].getAttribute('data-ninja-webgl-lib') !== null) { + webgllibtag = scripts[i]; // TODO: Add logic to delete unneccesary tags + } + if (scripts[i].getAttribute('data-ninja-webgl-rdge') !== null) { + webglrdgetag = scripts[i]; // TODO: Add logic to delete unneccesary tags + } + if (scripts[i].getAttribute('type') === 'text/montage-serialization') { + mjstag = scripts[i]; // TODO: Add logic to delete unneccesary tags + } + if (scripts[i].getAttribute('data-mjs-lib') !== null) { + mjslibtag = scripts[i]; // TODO: Add logic to delete unneccesary tags + } + } + } //Checking for webGL elements in document if (template.webgl && template.webgl.length > 1) {//TODO: Should be length 0, hack for a temp fix var rdgeDirName, rdgeVersion; @@ -420,31 +445,6 @@ exports.IoMediator = Montage.create(Component, { } } // - var json, matchingtags = [], webgltag, scripts = template.file.content.document.getElementsByTagName('script'), webgljstag, webgllibtag, webglrdgetag, mjstag, mjslibtag; - // - for (var i in scripts) { - if (scripts[i].getAttribute) { - if (scripts[i].getAttribute('data-ninja-webgl') !== null) {//TODO: Use querySelectorAll - matchingtags.push(scripts[i]); - } - if (scripts[i].getAttribute('data-ninja-webgl-js') !== null) { - webgljstag = scripts[i]; // TODO: Add logic to delete unneccesary tags - } - if (scripts[i].getAttribute('data-ninja-webgl-lib') !== null) { - webgllibtag = scripts[i]; // TODO: Add logic to delete unneccesary tags - } - if (scripts[i].getAttribute('data-ninja-webgl-rdge') !== null) { - webglrdgetag = scripts[i]; // TODO: Add logic to delete unneccesary tags - } - if (scripts[i].getAttribute('type') === 'text/montage-serialization') { - mjstag = scripts[i]; // TODO: Add logic to delete unneccesary tags - } - if (scripts[i].getAttribute('data-mjs-lib') !== null) { - mjslibtag = scripts[i]; // TODO: Add logic to delete unneccesary tags - } - } - } - // if (matchingtags.length) { if (matchingtags.length === 1) { webgltag = matchingtags[0]; @@ -510,7 +510,7 @@ function loadWebGL (e) {\n\ }\ "; //TODO: This data should be saved to a JSON file eventually - json = '\n({\n\t"version": "' + rdgeVersion + '",\n\t"directory": "' + rdgeDirName + '/",\n\t"data": ['; + var json = '\n({\n\t"version": "' + rdgeVersion + '",\n\t"directory": "' + rdgeDirName + '/",\n\t"data": ['; //Looping through data to create escaped array for (var j = 0; template.webgl[j]; j++) { if (j === 0) { @@ -524,11 +524,6 @@ function loadWebGL (e) {\n\ //Setting string in tag webgltag.innerHTML = json; } - - - - - //Checking for Montage if (mJsSerialization) { //Copy Montage library if needed @@ -538,8 +533,21 @@ function loadWebGL (e) {\n\ mjsDirName = (this.application.ninja.coreIoApi.ninjaLibrary.libs[i].name + this.application.ninja.coreIoApi.ninjaLibrary.libs[i].version).toLowerCase(); mjsVersion = this.application.ninja.coreIoApi.ninjaLibrary.libs[i].version; this.application.ninja.coreIoApi.ninjaLibrary.copyLibToCloud(template.file.root, mjsDirName); + + + //TODO: Fix to allow no overwrite and nested locations - var packjson = this.application.ninja.coreIoApi.createFile({ uri: template.file.root + 'package.json', contents: '{"mappings": {"montage": "' + mjsDirName + '/montage/"}}' }); + var mjsCheck, mjsPath = template.file.root + 'package.json'; + mjsCheck = this.application.ninja.coreIoApi.fileExists({uri: mjsPath}); + // + if (!mjsCheck || mjsCheck.status !== 204) { + var packjson = this.application.ninja.coreIoApi.createFile({ uri: mjsPath, contents: '{"mappings": {"montage": "' + mjsDirName + '/montage/"}}' }); + } else { + //Already exists + } + + + } else { //TODO: Error handle no available library to copy } -- cgit v1.2.3 From d878aa470074d5698a316512b513949fa22073f2 Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Fri, 18 May 2012 15:23:15 -0700 Subject: Fixing save logic Moved dirty marker clearing code to model. --- js/mediators/io-mediator.js | 1 + 1 file changed, 1 insertion(+) (limited to 'js/mediators/io-mediator.js') diff --git a/js/mediators/io-mediator.js b/js/mediators/io-mediator.js index c506e186..ade27728 100644 --- a/js/mediators/io-mediator.js +++ b/js/mediators/io-mediator.js @@ -557,6 +557,7 @@ function loadWebGL (e) {\n\ mjslibtag = template.file.content.document.createElement('script'); mjslibtag.setAttribute('type', 'text/javascript'); mjslibtag.setAttribute('src', mjsDirName + '/montage/montage.js'); + mjslibtag.setAttribute('data-package', '.'); mjslibtag.setAttribute('data-mjs-lib', 'true'); if (ninjaWrapper) { template.file.content.document.body.getElementsByTagName('ninja-content')[0].appendChild(mjslibtag); -- cgit v1.2.3 From 2994a18010dec4023d904ddc28ca19101f206d6b Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Mon, 21 May 2012 12:19:58 -0700 Subject: Adding mappings to Google Components This is just to add correct mappings to Google Montage components in the package.json file generated. --- js/mediators/io-mediator.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/mediators/io-mediator.js') diff --git a/js/mediators/io-mediator.js b/js/mediators/io-mediator.js index ade27728..8fe88ee6 100644 --- a/js/mediators/io-mediator.js +++ b/js/mediators/io-mediator.js @@ -541,7 +541,7 @@ function loadWebGL (e) {\n\ mjsCheck = this.application.ninja.coreIoApi.fileExists({uri: mjsPath}); // if (!mjsCheck || mjsCheck.status !== 204) { - var packjson = this.application.ninja.coreIoApi.createFile({ uri: mjsPath, contents: '{"mappings": {"montage": "' + mjsDirName + '/montage/"}}' }); + var packjson = this.application.ninja.coreIoApi.createFile({ uri: mjsPath, contents: '{"mappings": {\n\t\t"montage": "' + mjsDirName + '/montage/",\n\t\t"montage-google": "' + mjsDirName + '/montage-google/"\n\t}\n}' }); } else { //Already exists } -- cgit v1.2.3 From 11a5be59ff80e0672e9ecf36679be28effb7696c Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Mon, 21 May 2012 18:28:38 -0700 Subject: Modifying Canvas Data I/O Changing methods to save all data to external files, this will be optional for the user. Currently save will only save to external files, but UI will allow user to save in file. Need to implement loading data on file open for external file, only works for in file currently. Modified the Runtime file to load all data itself to not bulk up the user document. --- js/mediators/io-mediator.js | 147 +++++++++++++++++++++++++++++++++----------- 1 file changed, 111 insertions(+), 36 deletions(-) (limited to 'js/mediators/io-mediator.js') diff --git a/js/mediators/io-mediator.js b/js/mediators/io-mediator