sortable.js revision 79768504cfa253883b609dc616353cf9baa014e8
/**
* Sortable List.
* @module sortable
*/
/**
* Sortable Lists.
* @class Sortable
* @extends Base
* @constructor
*/
var S = function(o) {
},
CURRENT_NODE = 'currentNode',
OPACITY_NODE = 'opacityNode',
ID = 'id',
OPACITY = 'opacity',
PARENT_NODE = 'parentNode',
NODE = 'node';
S.NAME = 'sortable';
S.ATTRS = {
/**
* @attribute cont
* @description A selector query to get the container to listen for mousedown events on. All "nodes" should be a child of this container.
* @type String
*/
cont: {
value: 'body'
},
/**
* @attribute nodes
* @description A selector query to get the children of the "container" to make draggable elements from.
* @type String
*/
nodes: {
value: '.dd-draggable'
},
/**
* @attribute opacity
* @description The ocpacity to test the proxy item to when dragging.
* @type String
*/
opacity: {
value: '.75'
},
/**
* @attribute opacityNode
* @description The node to set opacity on when dragging (dragNode or currentNode). Default: currentNode.
* @type String
*/
opacityNode: {
value: 'currentNode'
},
/**
* @attribute id
* @description The id of this sortable, used to get a reference to this sortable list from another list.
* @type String
*/
id: {
value: null
},
/**
* @attribute moveType
* @description How should an item move to another list: swap, move, copy. Default: swap
* @type String
*/
moveType: {
value: 'swap'
},
/**
* @attribute invalid
* @description A selector string to test if a list item is invalid and not sortable
* @type String
*/
invalid: {
value: ''
}
};
/**
* @static
* @property _sortables
* @private
* @type Array
* @description Hash map of all Sortables on the page.
*/
S._sortables = [];
/**
* @static
* @method getSortable
* @param {String|Node} node The node instance or selector string to use to find a Sortable instance.
* @description Get a sortable instance back from a node reference or a selector string.
*/
S.getSortable = function(node) {
var s = null;
Y.each(S._sortables, function(v) {
s = v;
}
});
return s;
};
/**
* @static
* @method regSortable
* @param Sortable s A Sortable instance.
* @description Register a Sortable instance with the singleton to allow lookups later.
*/
S.regSortable = function(s) {
S._sortables.push(s);
};
/**
* @static
* @method unregSortable
* @param Sortable s A Sortable instance.
* @description Unregister a Sortable instance with the singleton.
*/
S.unregSortable = function(s) {
Y.each(S._sortables, function(v, k) {
if (v === s) {
S._sortables[k] = null;
delete S._sortables[k];
}
});
};
/**
* @property delegate
* @type DD.Delegate
* @description A reference to the DD.Delegate instance.
*/
delegate: null,
initializer: function() {
self = this,
target: true,
dragConfig: {
}
});
moveOnEnd: false,
cloneNode: true
});
S.regSortable(self);
},
/**
* @private
* @method _handleDropOver
* @param Event e The Event Object
* @description Handles the DropOver event to append a drop node to an empty target
*/
_handleDropOver: function(e) {
}
}
},
/**
* @private
* @method _handleDragOver
* @param Event e The Event Object
* @description Handles the DragOver event that moves the object in the list or to another list.
*/
_handleDragOver: function(e) {
return;
}
return;
}
switch (this.get('moveType')) {
case 'swap':
break;
case 'move':
case 'copy':
//Same List
} else {
//New List
top: '',
left: ''
});
}
}
break;
}
},
/**
* @private
* @method _handleDragStart
* @param Event e The Event Object
* @description Handles the DragStart event and initializes some settings.
*/
_handleDragStart: function(e) {
},
/**
* @private
* @method _handleDragEnd
* @param Event e The Event Object
* @description Handles the DragEnd event that cleans up the settings in the drag:start event.
*/
_handleDragEnd: function(e) {
top: '',
left: ''
});
},
/**
* @method plug
* @param Class cls The class to plug
* @param Object config The class config
* @description Passthrough to the DD.Delegate.ddplug method
* @chainable
*/
return this;
},
/**
* @method plug
* @description Passthrough to the DD.Delegate syncTargets method.
* @chainable
*/
sync: function() {
return this;
},
destructor: function() {
S.unregSortable(this);
},
/**
* @method join
* @param Sortable sel The sortable list to join with
* @param String type The type of join to do: full, inner, outer. Default: full
* @description Join this Sortable with another Sortable instance.
* <ul>
* <li>Full: Exchange nodes with both lists.</li>
* <li>Inner: Items can go into this list from the joined list.</li>
* <li>Outer: Items can go out of the joined list into this list.</li>
* </ul>
* @chainable
*/
Y.error('Sortable: join needs a Sortable Instance');
return this;
}
if (!type) {
type = 'full';
}
switch (type.toLowerCase()) {
case 'none':
break;
case 'out':
case 'outside':
case 'outter':
case 'outer':
break;
case 'in':
case 'inside':
case 'inner':
break;
default: //full
break;
}
return this;
}
});
Y.Sortable = S;