diff --git a/examples/js/jquery.orgchart.js b/examples/js/jquery.orgchart.js
index 525848ee..dee4e818 100755
--- a/examples/js/jquery.orgchart.js
+++ b/examples/js/jquery.orgchart.js
@@ -524,7 +524,8 @@
}
});
if (opts.draggable) {
- $nodeDiv.on('dragstart', function() {
+ $nodeDiv.on('dragstart', function(event) {
+ event.originalEvent.dataTransfer.setData('text/html', 'hack for firefox');
var $dragged = $(this);
var $draggedZone = $dragged.closest('table').find('.node');
$dragged.closest('.orgchart')
@@ -549,8 +550,9 @@
.on('drop', function(event) {
var $dropZone = $(this);
var $orgchart = $dropZone.closest('.orgchart');
+ var $dragged = $orgchart.data('dragged');
$orgchart.find('.allowedDrop').removeClass('allowedDrop');
- var $dragZone = $orgchart.data('dragged').closest('.nodes').siblings().eq(0).children();
+ var $dragZone = $dragged.closest('.nodes').siblings().eq(0).children();
// firstly, deal with the hierarchy of drop zone
if (!$dropZone.closest('tr').siblings().length) { // if the drop zone is a leaf node
$dropZone.append('')
@@ -558,14 +560,17 @@
.parent().after('
|
'
+ ' | |
'
+ '
')
- .siblings(':last').append($orgchart.data('dragged').find('.horizontalEdge').remove().end().closest('table').parent());
+ .siblings(':last').append($dragged.find('.horizontalEdge').remove().end().closest('table').parent());
} else {
var dropColspan = parseInt($dropZone.parent().attr('colspan')) + 2;
var horizontalEdges = '';
$dropZone.closest('tr').next().addBack().children().attr('colspan', dropColspan);
+ if (!$dragged.find('.horizontalEdge').length) {
+ $dragged.append(horizontalEdges);
+ }
$dropZone.closest('tr').siblings().eq(1).children(':last').before(' | | ')
- .end().next().append($orgchart.data('dragged').append(horizontalEdges).closest('table').parent());
- var $dropSibs = $orgchart.data('dragged').closest('table').parent().siblings().find('.node:first');
+ .end().next().append($dragged.closest('table').parent());
+ var $dropSibs = $dragged.closest('table').parent().siblings().find('.node:first');
if ($dropSibs.length === 1) {
$dropSibs.append(horizontalEdges);
}
diff --git a/jquery.orgchart.js b/jquery.orgchart.js
index 525848ee..dee4e818 100755
--- a/jquery.orgchart.js
+++ b/jquery.orgchart.js
@@ -524,7 +524,8 @@
}
});
if (opts.draggable) {
- $nodeDiv.on('dragstart', function() {
+ $nodeDiv.on('dragstart', function(event) {
+ event.originalEvent.dataTransfer.setData('text/html', 'hack for firefox');
var $dragged = $(this);
var $draggedZone = $dragged.closest('table').find('.node');
$dragged.closest('.orgchart')
@@ -549,8 +550,9 @@
.on('drop', function(event) {
var $dropZone = $(this);
var $orgchart = $dropZone.closest('.orgchart');
+ var $dragged = $orgchart.data('dragged');
$orgchart.find('.allowedDrop').removeClass('allowedDrop');
- var $dragZone = $orgchart.data('dragged').closest('.nodes').siblings().eq(0).children();
+ var $dragZone = $dragged.closest('.nodes').siblings().eq(0).children();
// firstly, deal with the hierarchy of drop zone
if (!$dropZone.closest('tr').siblings().length) { // if the drop zone is a leaf node
$dropZone.append('')
@@ -558,14 +560,17 @@
.parent().after(' |
'
+ ' | |
'
+ '
')
- .siblings(':last').append($orgchart.data('dragged').find('.horizontalEdge').remove().end().closest('table').parent());
+ .siblings(':last').append($dragged.find('.horizontalEdge').remove().end().closest('table').parent());
} else {
var dropColspan = parseInt($dropZone.parent().attr('colspan')) + 2;
var horizontalEdges = '';
$dropZone.closest('tr').next().addBack().children().attr('colspan', dropColspan);
+ if (!$dragged.find('.horizontalEdge').length) {
+ $dragged.append(horizontalEdges);
+ }
$dropZone.closest('tr').siblings().eq(1).children(':last').before(' | | ')
- .end().next().append($orgchart.data('dragged').append(horizontalEdges).closest('table').parent());
- var $dropSibs = $orgchart.data('dragged').closest('table').parent().siblings().find('.node:first');
+ .end().next().append($dragged.closest('table').parent());
+ var $dropSibs = $dragged.closest('table').parent().siblings().find('.node:first');
if ($dropSibs.length === 1) {
$dropSibs.append(horizontalEdges);
}