List Reorder (sortable) - modified
A modified and renewed version of "list reorder" plugin to provide support not only to "lis" but for all block-line elements and to support parents with position-relative.
unfinished
JavaScript
/*
List Reorder <http://www.utdallas.edu/~jrb048000/ListReorder/>
Enables drag-and-drop reordering of list items for any simple ordered <ol> or unordered <li> list.
Author: Jordan Bach
Version: 0.1
Created: January 1, 2009
License: MIT License
Constructor
$(expr).ListOrder(options)
Methods:
makeDefaultOrder - sets the current list order to [0, 1, 2, ...]
restoreOrder - returns the list to its original order
Events:
listorderchanged - Fired after a list item is dropped. The 2nd argument
is a jQuery object representing the list that fired the event.
The 3rd argument is an array where the values represent
the original index of each list item.
Options:
itemHoverClass : 'itemHover',
dragTargetClass : 'dragTarget',
dropTargetClass : 'dropTarget',
dragHandleClass : 'dragHandle'
*/
(function($){
$.fn.sortableDraggable = function (options) {
$.fn.sortableDraggable.defaults = {
itemHoverClass : 'itemHover',
dragTargetClass : 'dragTarget',
dropTargetClass : 'dropTarget',
dragHandleClass : 'dragHandle',
useDefaultDragHandle : false,
itemTag: 'li',
attacheFakeElementTo: 'body'
};
var opts = $.extend({}, $.fn.sortableDraggable.defaults, options);
return this.each(function() {
var theContainer = $(this), // The container
theItems = $(opts.itemTag, theContainer), // All elements in the container
dragActive = false, // Are we currently dragging an item?
dropTarget = null, // The list placeholder
dragTarget = null, // The element currently being dragged
dropIndex = -1, // The list index of the dropTarget
offset = {}, // Positions the mouse in the dragTarget
listOrder = [], // Keeps track of order relative to original order
ref = this;
...