From d1243d98d2f517055437cc67e963528771aa4c4b Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Fri, 16 Mar 2012 15:41:26 -0700 Subject: fixing the components drag and drop. Signed-off-by: Valerio Virgillito --- js/mediators/drag-drop-mediator.js | 11 +++++++++++ .../ComponentsPanelBase.reel/ComponentsPanelBase.js | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) (limited to 'js') diff --git a/js/mediators/drag-drop-mediator.js b/js/mediators/drag-drop-mediator.js index 3a965be5..8663b06e 100755 --- a/js/mediators/drag-drop-mediator.js +++ b/js/mediators/drag-drop-mediator.js @@ -60,6 +60,17 @@ exports.DragDropMediator = Montage.create(Component, { var i, files = e.dataTransfer.files, position = {x: e.offsetX, y: e.offsetY}, rootUrl = this.application.ninja.coreIoApi.rootUrl+escape((this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1])), rootUri = this.application.ninja.documentController.documentHackReference.root; + + var xferString = e.dataTransfer.getData("text/plain"); + if(xferString) { + // 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(e.offsetX - this.application.ninja.stage.userContentLeft, e.offsetY - this.application.ninja.stage.userContentTop); + return; + } + } + } // for (i=0; files[i]; i++) { if (files[i].type.indexOf('image') !== -1) { diff --git a/js/panels/Components/ComponentsPanelBase.reel/ComponentsPanelBase.js b/js/panels/Components/ComponentsPanelBase.reel/ComponentsPanelBase.js index b6bee37d..b4eec771 100755 --- a/js/panels/Components/ComponentsPanelBase.reel/ComponentsPanelBase.js +++ b/js/panels/Components/ComponentsPanelBase.reel/ComponentsPanelBase.js @@ -118,7 +118,7 @@ var ComponentsPanelBase = exports.ComponentsPanelBase = Montage.create(Component didCreate: { value: function() { // Setup the drop delegate -// this.application.ninja.dragDropMediator.dropDelegate = this; + this.application.ninja.dragDropMediator.dropDelegate = this; // Loop through the component and load the JSON data for them this._loadComponents(); } -- cgit v1.2.3