From b39c76533248fa9cda77a60988c458e2a99d3120 Mon Sep 17 00:00:00 2001 From: Wes Date: Fri, 2 Dec 2011 13:41:02 +0000 Subject: [PATCH] changed the way drag and drop events are binding to nodes to fix an issue in recent versions of FF. Also cleaned out some dead code --- example/example.html | 4 ++-- example/jquery.jOrgChart.js | 26 ++++++++++---------------- jquery.jOrgChart.js | 28 +++++++++++----------------- 3 files changed, 23 insertions(+), 35 deletions(-) diff --git a/example/example.html b/example/example.html index b5bf5a4..08404f3 100644 --- a/example/example.html +++ b/example/example.html @@ -9,8 +9,8 @@ - - + + diff --git a/example/jquery.jOrgChart.js b/example/jquery.jOrgChart.js index ebb5873..1b97c02 100644 --- a/example/jquery.jOrgChart.js +++ b/example/jquery.jOrgChart.js @@ -35,44 +35,41 @@ $('div.node').draggable({ cursor : 'move', distance : 40, - helper : 'clone', + helper : 'clone', opacity : 0.8, - revert : true, + revert : true, revertDuration : 100, snap : 'div.node.expanded', snapMode : 'inner', - stack : 'div.node', - start : handleDragStart, - stop : handleDragStop + stack : 'div.node' }); $('div.node').droppable({ - accept : '.node', + accept : '.node', activeClass : 'drag-active', - drop : handleDropEvent, hoverClass : 'drop-hover' }); // Drag start event handler for nodes - function handleDragStart( event, ui ){ + $('div.node').bind("dragstart", function handleDragStart( event, ui ){ var sourceNode = $(this); sourceNode.parentsUntil('.node-container') .find('*') .filter('.node') .droppable('disable'); - } + }); // Drag stop event handler for nodes - function handleDragStop( event, ui ){ + $('div.node').bind("dragstop", function handleDragStop( event, ui ){ /* reload the plugin */ $(opts.chartElement).children().remove(); $this.jOrgChart(opts); - } + }); // Drop event handler for nodes - function handleDropEvent( event, ui ) { + $('div.node').bind("drop", function handleDropEvent( event, ui ) { var sourceNode = ui.draggable; var targetNode = $(this); @@ -113,7 +110,7 @@ targetLi.append(''); } - } // handleDropEvent + }); // handleDropEvent } // Drag and drop }; @@ -148,10 +145,7 @@ .end() .html(); - //var $heading = $("

").text(nodeContent); $nodeDiv = $("
").addClass("node").append($nodeContent); -// $nodeDiv.data('markup',$node.html()); - // Expand and contract nodes $nodeDiv.click(function() { diff --git a/jquery.jOrgChart.js b/jquery.jOrgChart.js index ebb5873..da4ec0f 100644 --- a/jquery.jOrgChart.js +++ b/jquery.jOrgChart.js @@ -17,7 +17,7 @@ $.fn.jOrgChart = function(options) { var opts = $.extend({}, $.fn.jOrgChart.defaults, options); - var $appendTo = $(opts.chartElement); + var $appendTo = $(opts.chartElement); // build the tree $this = $(this); @@ -35,44 +35,41 @@ $('div.node').draggable({ cursor : 'move', distance : 40, - helper : 'clone', + helper : 'clone', opacity : 0.8, - revert : true, + revert : true, revertDuration : 100, snap : 'div.node.expanded', snapMode : 'inner', - stack : 'div.node', - start : handleDragStart, - stop : handleDragStop + stack : 'div.node' }); $('div.node').droppable({ - accept : '.node', + accept : '.node', activeClass : 'drag-active', - drop : handleDropEvent, hoverClass : 'drop-hover' }); // Drag start event handler for nodes - function handleDragStart( event, ui ){ + $('div.node').bind("dragstart", function handleDragStart( event, ui ){ var sourceNode = $(this); sourceNode.parentsUntil('.node-container') .find('*') .filter('.node') .droppable('disable'); - } + }); // Drag stop event handler for nodes - function handleDragStop( event, ui ){ + $('div.node').bind("dragstop", function handleDragStop( event, ui ){ /* reload the plugin */ $(opts.chartElement).children().remove(); $this.jOrgChart(opts); - } + }); // Drop event handler for nodes - function handleDropEvent( event, ui ) { + $('div.node').bind("drop", function handleDropEvent( event, ui ) { var sourceNode = ui.draggable; var targetNode = $(this); @@ -113,7 +110,7 @@ targetLi.append('
  • '+sourceliClone.html()+'
'); } - } // handleDropEvent + }); // handleDropEvent } // Drag and drop }; @@ -148,10 +145,7 @@ .end() .html(); - //var $heading = $("

").text(nodeContent); $nodeDiv = $("
").addClass("node").append($nodeContent); -// $nodeDiv.data('markup',$node.html()); - // Expand and contract nodes $nodeDiv.click(function() {