From 0eb739ab722ea768ab0fa1c5de0ee09ed1a576ea Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Tue, 14 Feb 2012 00:25:45 -0800 Subject: Add support for drag and drop for the components. Signed-off-by: Valerio Virgillito --- js/mediators/drag-drop-mediator.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'js/mediators') diff --git a/js/mediators/drag-drop-mediator.js b/js/mediators/drag-drop-mediator.js index ede71383..bf22aed2 100644 --- a/js/mediators/drag-drop-mediator.js +++ b/js/mediators/drag-drop-mediator.js @@ -24,6 +24,10 @@ exports.DragDropMediator = Montage.create(Component, { writable: true }, + dropDelegate: { + value: null + }, + deserializedFromTemplate: { value: function() { this.eventManager.addEventListener("appLoaded", this, false); @@ -69,13 +73,14 @@ exports.DragDropMediator = Montage.create(Component, { xferString = evt.dataTransfer.getData("text/plain"); if(xferString) { - - if(xferString.lastIndexOf("-Component") !== -1) { - component = xferString.substring(0, xferString.lastIndexOf("-Component")); - NJevent( "executeAddComponent", { "component": component, "dropX": this.baseX, "dropY": this.baseY }); -// ComponentPanelModule.ComponentsPanelBase.addComponentToStage(componentStr.substring(0, compInd), this.baseX, this.baseY); + // If the drop is a component, call the delegate with the top,left coordinates + if(xferString.indexOf("componentDrop") > -1) { + if(this.dropDelegate && typeof this.dropDelegate === 'object') { + this.dropDelegate.handleComponentDrop(this.baseX, this.baseY); + return; + } } - return; + } // Verify that browser supports FileReader API. -- cgit v1.2.3 From 075252ad893452df446566f01d0b26eeab08be3d Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Wed, 15 Feb 2012 23:07:00 -0800 Subject: Setting up webGL library copy on save --- js/mediators/io-mediator.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'js/mediators') diff --git a/js/mediators/io-mediator.js b/js/mediators/io-mediator.js index 2008e40f..e9958ec3 100644 --- a/js/mediators/io-mediator.js +++ b/js/mediators/io-mediator.js @@ -86,6 +86,7 @@ exports.IoMediator = Montage.create(Component, { case 204: //Creating and formatting result object for callbak result = read.file.details; + result.root = read.file.details.uri.replace(read.file.details.name, ""); //Checking for type of content to returns if (result.extension !== 'html' && result.extension !== 'htm') { //Simple string @@ -191,6 +192,17 @@ exports.IoMediator = Montage.create(Component, { // template.document.content.document.body.innerHTML = template.body; template.document.content.document.head.innerHTML = template.head; + // + if (template.webgl.length > 0) { + for (var i in this.application.ninja.coreIoApi.ninjaLibrary.libs) { + if (this.application.ninja.coreIoApi.ninjaLibrary.libs[i].name === 'Assets' || this.application.ninja.coreIoApi.ninjaLibrary.libs[i].name === 'RDGE') { + this.application.ninja.coreIoApi.ninjaLibrary.copyLibToCloud(template.document.root, (this.application.ninja.coreIoApi.ninjaLibrary.libs[i].name+this.application.ninja.coreIoApi.ninjaLibrary.libs[i].version).toLowerCase()); + } + } + + //this.application.ninja.coreIoApi.ninjaLibrary.copyLibToCloud(path, libname); + //console.log(this.application.ninja.coreIoApi.ninjaLibrary.libs); + } //TODO: Remove temp fix for styles if (template.style) { template.document.content.document.head.getElementsByTagName('style')[0].innerHTML = this.getCssFromRules(template.style.cssRules); -- cgit v1.2.3 From 6bc07657c8ef58e6efddd383748ecf84d1c789ad Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Thu, 16 Feb 2012 15:58:26 -0800 Subject: Adding new RDGE library data --- js/mediators/io-mediator.js | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'js/mediators') diff --git a/js/mediators/io-mediator.js b/js/mediators/io-mediator.js index e9958ec3..56869839 100644 --- a/js/mediators/io-mediator.js +++ b/js/mediators/io-mediator.js @@ -143,6 +143,16 @@ exports.IoMediator = Montage.create(Component, { // switch (file.mode) { case 'html': + //Copy webGL library if needed + if (file.webgl.length > 0) { + for (var i in this.application.ninja.coreIoApi.ninjaLibrary.libs) { + //if (this.application.ninja.coreIoApi.ninjaLibrary.libs[i].name === 'Assets' || this.application.ninja.coreIoApi.ninjaLibrary.libs[i].name === 'RDGE') { + if (this.application.ninja.coreIoApi.ninjaLibrary.libs[i].name === 'RDGE') { + this.application.ninja.coreIoApi.ninjaLibrary.copyLibToCloud(file.document.root, (this.application.ninja.coreIoApi.ninjaLibrary.libs[i].name+this.application.ninja.coreIoApi.ninjaLibrary.libs[i].version).toLowerCase()); + } + } + } + // contents = this.parseNinjaTemplateToHtml(file); break; default: @@ -192,17 +202,6 @@ exports.IoMediator = Montage.create(Component, { // template.document.content.document.body.innerHTML = template.body; template.document.content.document.head.innerHTML = template.head; - // - if (template.webgl.length > 0) { - for (var i in this.application.ninja.coreIoApi.ninjaLibrary.libs) { - if (this.application.ninja.coreIoApi.ninjaLibrary.libs[i].name === 'Assets' || this.application.ninja.coreIoApi.ninjaLibrary.libs[i].name === 'RDGE') { - this.application.ninja.coreIoApi.ninjaLibrary.copyLibToCloud(template.document.root, (this.application.ninja.coreIoApi.ninjaLibrary.libs[i].name+this.application.ninja.coreIoApi.ninjaLibrary.libs[i].version).toLowerCase()); - } - } - - //this.application.ninja.coreIoApi.ninjaLibrary.copyLibToCloud(path, libname); - //console.log(this.application.ninja.coreIoApi.ninjaLibrary.libs); - } //TODO: Remove temp fix for styles if (template.style) { template.document.content.document.head.getElementsByTagName('style')[0].innerHTML = this.getCssFromRules(template.style.cssRules); -- cgit v1.2.3