From 54bb23a33688ef5a1065c95253556b3f2e6d0b50 Mon Sep 17 00:00:00 2001 From: Oscar Godson Date: Fri, 6 Jul 2012 13:36:31 -0700 Subject: [PATCH 01/14] Fix to make placeholder spot exactly the same height. height() only works if there's no padding or borders on the placeholder item. --- jquery.sortable.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jquery.sortable.js b/jquery.sortable.js index 9ba705c..e331e01 100644 --- a/jquery.sortable.js +++ b/jquery.sortable.js @@ -65,7 +65,7 @@ $.fn.sortable = function(options) { e.originalEvent.dataTransfer.dropEffect = 'move'; if (items.is(this)) { if (options.forcePlaceholderSize) { - placeholder.height(dragging.height()); + placeholder.height(dragging.outerHeight()); } dragging.hide(); $(this)[placeholder.index() < $(this).index() ? 'after' : 'before'](placeholder); From b2e32484c05131046d9ef75d56297e8794298cbb Mon Sep 17 00:00:00 2001 From: Ali Farhadi Date: Fri, 27 Jul 2012 08:52:16 +0430 Subject: [PATCH 02/14] Use only `div` or `li` elements as placeholder. --- jquery.sortable.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jquery.sortable.js b/jquery.sortable.js index e331e01..c489948 100644 --- a/jquery.sortable.js +++ b/jquery.sortable.js @@ -22,7 +22,7 @@ $.fn.sortable = function(options) { return; } var isHandle, index, items = $(this).children(options.items); - var placeholder = $('<' + items[0].tagName + ' class="sortable-placeholder">'); + var placeholder = $('<' + (/^ul|ol$/i.test(this.tagName) ? 'li' : 'div') + ' class="sortable-placeholder">'); items.find(options.handle).mousedown(function() { isHandle = true; }).mouseup(function() { From 0e7640d45b7eeea298356158e3d4ef518e7891fd Mon Sep 17 00:00:00 2001 From: Ali Farhadi Date: Fri, 27 Jul 2012 09:21:17 +0430 Subject: [PATCH 03/14] Removing fade effect. --- jquery.sortable.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jquery.sortable.js b/jquery.sortable.js index c489948..b7768cd 100644 --- a/jquery.sortable.js +++ b/jquery.sortable.js @@ -43,7 +43,7 @@ $.fn.sortable = function(options) { dt.setData('Text', 'dummy'); index = (dragging = $(this)).addClass('sortable-dragging').index(); }).on('dragend.h5s', function() { - dragging.removeClass('sortable-dragging').fadeIn(); + dragging.removeClass('sortable-dragging').show(); placeholders.detach(); if (index != dragging.index()) { items.parent().trigger('sortupdate', {item: dragging}); From 1af14253dbe8e489dd85ffa51ce1f0a47b197f13 Mon Sep 17 00:00:00 2001 From: Ali Farhadi Date: Fri, 27 Jul 2012 22:52:28 +0430 Subject: [PATCH 04/14] Fixing bug in dropping items into empty connected lists. Closes #15. --- jquery.sortable.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/jquery.sortable.js b/jquery.sortable.js index b7768cd..5ac3161 100644 --- a/jquery.sortable.js +++ b/jquery.sortable.js @@ -70,6 +70,9 @@ $.fn.sortable = function(options) { dragging.hide(); $(this)[placeholder.index() < $(this).index() ? 'after' : 'before'](placeholder); placeholders.not(placeholder).detach(); + } else if (!placeholders.is(this) && !$(this).children(options.items).length) { + placeholders.detach(); + $(this).append(placeholder); } return false; }); From 040fa49bcaef5a8334b0774367d23d05b2cb8629 Mon Sep 17 00:00:00 2001 From: Ali Farhadi Date: Sun, 29 Jul 2012 12:51:34 +0430 Subject: [PATCH 05/14] In Opera `dragend` isn't triggred after `drop` event, so we trigger it manually. Closes #16. --- jquery.sortable.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/jquery.sortable.js b/jquery.sortable.js index 5ac3161..350d172 100644 --- a/jquery.sortable.js +++ b/jquery.sortable.js @@ -43,10 +43,13 @@ $.fn.sortable = function(options) { dt.setData('Text', 'dummy'); index = (dragging = $(this)).addClass('sortable-dragging').index(); }).on('dragend.h5s', function() { + if (!dragging) { + return; + } dragging.removeClass('sortable-dragging').show(); placeholders.detach(); if (index != dragging.index()) { - items.parent().trigger('sortupdate', {item: dragging}); + dragging.parent().trigger('sortupdate', {item: dragging}); } dragging = null; }).not('a[href], img').on('selectstart.h5s', function() { @@ -59,6 +62,7 @@ $.fn.sortable = function(options) { if (e.type == 'drop') { e.stopPropagation(); placeholders.filter(':visible').after(dragging); + dragging.trigger('dragend.h5s'); return false; } e.preventDefault(); From b90b6baac95cdc0df1ec1682b7181ff94b1f7820 Mon Sep 17 00:00:00 2001 From: adamedoe Date: Fri, 3 Aug 2012 11:13:47 -0700 Subject: [PATCH 06/14] Update index.html --- index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.html b/index.html index 41301f0..0b650db 100644 --- a/index.html +++ b/index.html @@ -156,7 +156,7 @@

Connected Sortable Lists

Fork me on GitHub - +