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') 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 1b2af54128985c1b622e13ea740a8402e57527cc Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Fri, 4 May 2012 17:11:02 -0700 Subject: Temporarily skipping activeDocument.currentView check so keyboard shortcuts still work. Signed-off-by: Nivesh Rajbhandari --- js/mediators/keyboard-mediator.js | 31 +++---------------------------- 1 file changed, 3 insertions(+), 28 deletions(-) (limited to 'js/mediators') diff --git a/js/mediators/keyboard-mediator.js b/js/mediators/keyboard-mediator.js index f8934669..49960f58 100755 --- a/js/mediators/keyboard-mediator.js +++ b/js/mediators/keyboard-mediator.js @@ -87,7 +87,8 @@ exports.KeyboardMediator = Montage.create(Component, { value: function(evt) { //keyboard controls for html design view - if((!!this.application.ninja.documentController.activeDocument) && (this.application.ninja.documentController.activeDocument.currentView === "design")){ + // TODO - New template mode doesn't set currentView yet. + if((!!this.application.ninja.currentDocument)){// && (this.application.ninja.currentDocument.model.currentView === "design")){ // Don't do anything if an input or other control is focused if(document.activeElement.nodeName !== "BODY") { @@ -256,7 +257,7 @@ exports.KeyboardMediator = Montage.create(Component, { handleKeyup: { value: function(evt) { //keyboard controls for html design view - if((!!this.application.ninja.documentController.activeDocument) && (this.application.ninja.documentController.activeDocument.currentView === "design")){ + if((!!this.application.ninja.currentDocument)){// && (this.application.ninja.currentDocument.model.currentView === "design")){ if(document.activeElement.nodeName !== "BODY") { // Don't do anything if an input or other control is focused return; @@ -265,31 +266,5 @@ exports.KeyboardMediator = Montage.create(Component, { if(this.application.ninja.toolsData) this.application.ninja.toolsData.selectedToolInstance.HandleKeyUp(evt); } } - }, - - _handleKeydown: { - value: function(evt) { - - // Check if cmd-shift-+/ctrl-shift-+ for toggling snapping - if(evt.shiftKey && (evt.ctrlKey || evt.metaKey) && (evt.keyCode === 187)) - { - MainMenuModule.MenuActionManager.toggleSnapping("snap", !DocumentManagerModule.DocumentManager.activeDocument.snapping); - evt.preventDefault(); - return; - } - - if(evt.keyCode === Keyboard.PLUS && (evt.metaKey||evt.ctrlKey)) { - evt.preventDefault(); - this._toolsList.action("zoomIn", evt); - return; - } - - if(evt.keyCode === Keyboard.MINUS && (evt.metaKey || evt.ctrlKey)) { - evt.preventDefault(); - this._toolsList.action("zoomOut", evt); - return; - } - - } } }); -- cgit v1.2.3 From 29ad6355ef60cfb3b3fc7f780504f3ed30845883 Mon Sep 17 00:00:00 2001 From: John Mayhew Date: Mon, 7 May 2012 14:30:47 -0700 Subject: More implementation of moving color chips to the individual subtools. Removed the tool color bar Added new icons for inkbottle Removed Pencil tool Removed Inkbottle tool Added chips to the pen, brush and tag tools Aligned controls in several subtools --- js/mediators/keyboard-mediator.js | 7 ------- 1 file changed, 7 deletions(-) (limited to 'js/mediators') diff --git a/js/mediators/keyboard-mediator.js b/js/mediators/keyboard-mediator.js index f8934669..c647107f 100755 --- a/js/mediators/keyboard-mediator.js +++ b/js/mediators/keyboard-mediator.js @@ -179,13 +179,6 @@ exports.KeyboardMediator = Montage.create(Component, { return; } - // Shortcut for Eyedropper Tool is I - if(evt.keyCode === Keyboard.I && !(evt.ctrlKey || evt.metaKey)) { - evt.preventDefault(); - this.application.ninja.handleSelectTool({"detail": this.application.ninja.toolsData.defaultToolsData[12]}); - return; - } - // Rotate Stage Tool is M if(evt.keyCode === Keyboard.M ) { evt.preventDefault(); -- cgit v1.2.3 From dd663d8fe9191cc57c9cebe6d425562cb45982c2 Mon Sep 17 00:00:00 2001 From: John Mayhew Date: Tue, 8 May 2012 07:25:09 -0700 Subject: Removed unused SubSelect Tool --- js/mediators/keyboard-mediator.js | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'js/mediators') diff --git a/js/mediators/keyboard-mediator.js b/js/mediators/keyboard-mediator.js index c647107f..665e3ce7 100755 --- a/js/mediators/keyboard-mediator.js +++ b/js/mediators/keyboard-mediator.js @@ -110,35 +110,35 @@ exports.KeyboardMediator = Montage.create(Component, { // Shortcut for Selection Tool is V if(evt.keyCode === Keyboard.V) { evt.preventDefault(); - this.application.ninja.handleSelectTool({"detail": this.application.ninja.toolsData.defaultToolsData[0]}); + this.application.ninja.handleSelectTool({ "detail": this.application.ninja.toolsData.defaultToolsData[this.application.ninja.toolsData.selectionToolIndex] }); return; } // Shortcut for Tag Tool is D if(evt.keyCode === Keyboard.D){ evt.preventDefault(); - this.application.ninja.handleSelectTool({"detail": this.application.ninja.toolsData.defaultToolsData[4]}); + this.application.ninja.handleSelectTool({ "detail": this.application.ninja.toolsData.defaultToolsData[this.application.ninja.toolsData.tagToolIndex] }); return; } // Shortcut for Rotate Tool is W if(evt.keyCode === Keyboard.W){ evt.preventDefault(); - this.application.ninja.handleSelectTool({"detail": this.application.ninja.toolsData.defaultToolsData[2]}); + this.application.ninja.handleSelectTool({ "detail": this.application.ninja.toolsData.defaultToolsData[this.application.ninja.toolsData.rotate3DToolIndex] }); return; } // Shortcut for Translate Tool is G if(evt.keyCode === Keyboard.G){ evt.preventDefault(); - this.application.ninja.handleSelectTool({"detail": this.application.ninja.toolsData.defaultToolsData[3]}); + this.application.ninja.handleSelectTool({ "detail": this.application.ninja.toolsData.defaultToolsData[this.application.ninja.toolsData.translate3DToolIndex] }); return; } // shortcut for Pen tool is P if (evt.keyCode === Keyboard.P){ evt.preventDefault(); - this.application.ninja.handleSelectTool({"detail": this.application.ninja.toolsData.defaultToolsData[5]}); + this.application.ninja.handleSelectTool({ "detail": this.application.ninja.toolsData.defaultToolsData[this.application.ninja.toolsData.penToolIndex] }); return; } @@ -147,24 +147,24 @@ exports.KeyboardMediator = Montage.create(Component, { // If the user is pressing the command key, they want to refresh the browser. if((evt.keyCode === Keyboard.R) && !evt.metaKey) { evt.preventDefault(); - this.application.ninja.handleSelectTool({"detail": this.application.ninja.toolsData.defaultToolsData[7]}); - this.application.ninja.handleSelectSubTool({"detail": this.application.ninja.toolsData.defaultToolsData[7].subtools[1]}); + this.application.ninja.handleSelectTool({ "detail": this.application.ninja.toolsData.defaultToolsData[this.application.ninja.toolsData.shapeToolIndex] }); + this.application.ninja.handleSelectSubTool({ "detail": this.application.ninja.toolsData.defaultToolsData[this.application.ninja.toolsData.shapeToolIndex].subtools[1] }); return; } // Shortcut for Oval Tool is O if(evt.keyCode === Keyboard.O) { evt.preventDefault(); - this.application.ninja.handleSelectTool({"detail": this.application.ninja.toolsData.defaultToolsData[7]}); - this.application.ninja.handleSelectSubTool({"detail": this.application.ninja.toolsData.defaultToolsData[7].subtools[0]}); + this.application.ninja.handleSelectTool({ "detail": this.application.ninja.toolsData.defaultToolsData[this.application.ninja.toolsData.shapeToolIndex] }); + this.application.ninja.handleSelectSubTool({ "detail": this.application.ninja.toolsData.defaultToolsData[this.application.ninja.toolsData.shapeToolIndex].subtools[0] }); return; } // Shortcut for Line Tool is L if(evt.keyCode === Keyboard.L ) { evt.preventDefault(); - this.application.ninja.handleSelectTool({"detail": this.application.ninja.toolsData.defaultToolsData[7]}); - this.application.ninja.handleSelectSubTool({"detail": this.application.ninja.toolsData.defaultToolsData[7].subtools[2]}); + this.application.ninja.handleSelectTool({ "detail": this.application.ninja.toolsData.defaultToolsData[this.application.ninja.toolsData.shapeToolIndex] }); + this.application.ninja.handleSelectSubTool({ "detail": this.application.ninja.toolsData.defaultToolsData[this.application.ninja.toolsData.shapeToolIndex].subtools[2] }); return; } @@ -172,9 +172,9 @@ exports.KeyboardMediator = Montage.create(Component, { if(evt.keyCode === Keyboard.K ) { evt.preventDefault(); if(this.application.ninja.toolsData.selectedTool.id === "FillTool") { - this.application.ninja.handleSelectTool({"detail": this.application.ninja.toolsData.defaultToolsData[11]}); + this.application.ninja.handleSelectTool({ "detail": this.application.ninja.toolsData.defaultToolsData[this.application.ninja.toolsData.fillToolIndex] }); } else { - this.application.ninja.handleSelectTool({"detail": this.application.ninja.toolsData.defaultToolsData[10]}); + this.application.ninja.handleSelectTool({ "detail": this.application.ninja.toolsData.defaultToolsData[this.application.ninja.toolsData.inkBottleToolIndex] }); } return; } @@ -182,21 +182,21 @@ exports.KeyboardMediator = Montage.create(Component, { // Rotate Stage Tool is M if(evt.keyCode === Keyboard.M ) { evt.preventDefault(); - this.application.ninja.handleSelectTool({"detail": this.application.ninja.toolsData.defaultToolsData[13]}); + this.application.ninja.handleSelectTool({ "detail": this.application.ninja.toolsData.defaultToolsData[this.application.ninja.toolsData.rotateStage3DToolIndex] }); return; } // Hand tool if(evt.keyCode === Keyboard.H ) { evt.preventDefault(); - this.application.ninja.handleSelectTool({"detail": this.application.ninja.toolsData.defaultToolsData[14]}); + this.application.ninja.handleSelectTool({"detail": this.application.ninja.toolsData.defaultToolsData[this.application.ninja.toolsData.panToolIndex]}); return; } // Zoom tool if((evt.keyCode === Keyboard.Z) && !(evt.ctrlKey || evt.metaKey) && !evt.shiftKey) {//ctrl or shift key not press with Z evt.preventDefault(); - this.application.ninja.handleSelectTool({"detail": this.application.ninja.toolsData.defaultToolsData[15]}); + this.application.ninja.handleSelectTool({"detail": this.application.ninja.toolsData.defaultToolsData[this.application.ninja.toolsData.zoomToolIndex]}); return; } -- 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') 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') 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') 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 f6f722feecf88c8afe59327eaf8557ce4012abc7 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Thu, 10 May 2012 22:40:02 -0700 Subject: Fixing the dirty document flag. Disabling the stylesheets dirty flag because === true on document open. Signed-off-by: Valerio Virgillito --- js/mediators/element-mediator.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'js/mediators') diff --git a/js/mediators/element-mediator.js b/js/mediators/element-mediator.js index 06514076..483dacbc 100755 --- a/js/mediators/element-mediator.js +++ b/js/mediators/element-mediator.js @@ -48,7 +48,7 @@ exports.ElementMediator = Montage.create(Component, { document.application.undoManager.add(undoLabel, this.removeElements, this, elements, notify); - this.application.ninja.documentController.activeDocument.needsSave = true; + this.application.ninja.documentController.activeDocument.model.needsSave = true; if(notify || notify === undefined) { NJevent("elementAdded", elements); @@ -77,7 +77,7 @@ exports.ElementMediator = Montage.create(Component, { document.application.undoManager.add(undoLabel, this.addElements, this, elements, null, notify); - this.application.ninja.documentController.activeDocument.needsSave = true; + this.application.ninja.documentController.activeDocument.model.needsSave = true; NJevent("elementsRemoved", elements); } @@ -92,7 +92,7 @@ exports.ElementMediator = Montage.create(Component, { document.application.undoManager.add(undoLabel, this.replaceElement, this, oldChild, newChild); - this.application.ninja.documentController.activeDocument.needsSave = true; + this.application.ninja.documentController.activeDocument.model.needsSave = true; if(notify || notify === undefined) { NJevent("elementReplaced", {type : "replaceElement", data: {"newChild": newChild, "oldChild": oldChild}}); -- 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') 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') 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') 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') 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') 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') 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') 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') 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') 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 26c4d00b3e5d39c1c313d48433abebd06f386a85 Mon Sep 17 00:00:00 2001 From: John Mayhew Date: Wed, 16 May 2012 14:37:10 -0700 Subject: fixed bug with keyboard shortcut for fill/ink tool --- js/mediators/keyboard-mediator.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'js/mediators') diff --git a/js/mediators/keyboard-mediator.js b/js/mediators/keyboard-mediator.js index 665e3ce7..029c0916 100755 --- a/js/mediators/keyboard-mediator.js +++ b/js/mediators/keyboard-mediator.js @@ -172,11 +172,13 @@ exports.KeyboardMediator = Montage.create(Component, { if(evt.keyCode === Keyboard.K ) { evt.preventDefault(); if(this.application.ninja.toolsData.selectedTool.id === "FillTool") { + this.application.ninja.handleSelectTool({ "detail": this.application.ninja.toolsData.defaultToolsData[this.application.ninja.toolsData.inkBottleToolIndex] }); + } else if(this.application.ninja.toolsData.selectedTool.id === "InkBottleTool") { this.application.ninja.handleSelectTool({ "detail": this.application.ninja.toolsData.defaultToolsData[this.application.ninja.toolsData.fillToolIndex] }); } else { - this.application.ninja.handleSelectTool({ "detail": this.application.ninja.toolsData.defaultToolsData[this.application.ninja.toolsData.inkBottleToolIndex] }); + this.application.ninja.handleSelectTool({ "detail": this.application.ninja.toolsData.defaultToolsData[this.application.ninja.toolsData.fillToolIndex] }); } - return; + return; } // Rotate Stage Tool is M -- 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') 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') {