ad598bab533c3f4f0bdb0f536bcf5e0ac0769d15Dav Glass * Provides the ability to drag multiple nodes under a container element using only one Y.DD.Drag instance as a delegate.
4d589fe0c1bf5d088a90cdf29f3bc777942006cbDav Glass * @module dd
4d589fe0c1bf5d088a90cdf29f3bc777942006cbDav Glass * @submodule dd-delegate
ad598bab533c3f4f0bdb0f536bcf5e0ac0769d15Dav Glass * Provides the ability to drag multiple nodes under a container element using only one Y.DD.Drag instance as a delegate.
4d589fe0c1bf5d088a90cdf29f3bc777942006cbDav Glass * @class Delegate
4d589fe0c1bf5d088a90cdf29f3bc777942006cbDav Glass * @extends Base
4d589fe0c1bf5d088a90cdf29f3bc777942006cbDav Glass * @constructor
4d589fe0c1bf5d088a90cdf29f3bc777942006cbDav Glass * @namespace DD
482da2d388e0f999f372383039af944e21bc717bDav Glass Delegate.superclass.constructor.apply(this, arguments);
f05c0eb9de3e3021b733c24fb7d17ba9ae093272Dav Glass * @property _bubbleTargets
f05c0eb9de3e3021b733c24fb7d17ba9ae093272Dav Glass * @description The default bubbleTarget for this object. Default: Y.DD.DDM
3b3bd34996b581ab171be1465201869cb009dbadDav Glass * @property dd
4d589fe0c1bf5d088a90cdf29f3bc777942006cbDav Glass * @description A reference to the temporary dd instance used under the hood.
4d589fe0c1bf5d088a90cdf29f3bc777942006cbDav Glass * @property _shimState
4d589fe0c1bf5d088a90cdf29f3bc777942006cbDav Glass * @description The state of the Y.DD.DDM._noShim property to it can be reset.
5b99a6835685fac17a0dad8b3b3a8e3d76e59c94Dav Glass * @property _handles
5b99a6835685fac17a0dad8b3b3a8e3d76e59c94Dav Glass * @description Array of event handles to be destroyed
482da2d388e0f999f372383039af944e21bc717bDav Glass * @method _onNodeChange
3b3bd34996b581ab171be1465201869cb009dbadDav Glass * @description Listens to the nodeChange event and sets the dragNode on the temp dd instance.
3b3bd34996b581ab171be1465201869cb009dbadDav Glass * @param {Event} e The Event.
482da2d388e0f999f372383039af944e21bc717bDav Glass _onNodeChange: function(e) {
482da2d388e0f999f372383039af944e21bc717bDav Glass * @method _afterDragEnd
3b3bd34996b581ab171be1465201869cb009dbadDav Glass * @description Listens for the drag:end event and updates the temp dd instance.
3b3bd34996b581ab171be1465201869cb009dbadDav Glass * @param {Event} e The Event.
482da2d388e0f999f372383039af944e21bc717bDav Glass _afterDragEnd: function(e) {
eba99cf5219728ad7993f0b1ed3b75f7fdb78193Dav Glass this.get('lastNode').removeClass(Y.DD.DDM.CSS_PREFIX + '-dragging');
eba99cf5219728ad7993f0b1ed3b75f7fdb78193Dav Glass * @method _delMouseDown
3b3bd34996b581ab171be1465201869cb009dbadDav Glass * @description The callback for the Y.DD.Delegate instance used
3b3bd34996b581ab171be1465201869cb009dbadDav Glass * @param {Event} e The MouseDown Event.
eba99cf5219728ad7993f0b1ed3b75f7fdb78193Dav Glass _delMouseDown: function(e) {
eba99cf5219728ad7993f0b1ed3b75f7fdb78193Dav Glass if (tar.test(this.get(NODES)) && !tar.test(this.get('invalid'))) {
482da2d388e0f999f372383039af944e21bc717bDav Glass * @method _onMouseEnter
3b3bd34996b581ab171be1465201869cb009dbadDav Glass * @description Sets the target shim state
3b3bd34996b581ab171be1465201869cb009dbadDav Glass * @param {Event} e The MouseEnter Event
482da2d388e0f999f372383039af944e21bc717bDav Glass _onMouseEnter: function(e) {
482da2d388e0f999f372383039af944e21bc717bDav Glass * @method _onMouseLeave
3b3bd34996b581ab171be1465201869cb009dbadDav Glass * @description Resets the target shim state
3b3bd34996b581ab171be1465201869cb009dbadDav Glass * @param {Event} e The MouseLeave Event
482da2d388e0f999f372383039af944e21bc717bDav Glass _onMouseLeave: function(e) {
6cd85fc002ad88c48179730400dc0bc36a7a9f5bDav Glass //Create a tmp DD instance under the hood.
1db7a264d82ab84bbc6a175fbb4d2aeeed45d052Dav Glass //var conf = Y.clone(this.get('dragConfig') || {}),
6cd85fc002ad88c48179730400dc0bc36a7a9f5bDav Glass //On end drag, detach the listeners
482da2d388e0f999f372383039af944e21bc717bDav Glass this.dd.after('drag:end', Y.bind(this._afterDragEnd, this));
482da2d388e0f999f372383039af944e21bc717bDav Glass this.dd.on('dragNodeChange', Y.bind(this._onNodeChange, this));
6cd85fc002ad88c48179730400dc0bc36a7a9f5bDav Glass //Attach the delegate to the container
0e2ca74abf5da92afe63a29d96776674f0412affDav Glass this._handles.push(Y.delegate(Y.DD.Drag.START_EVENT, Y.bind(this._delMouseDown, this), cont, this.get(NODES)));
eba99cf5219728ad7993f0b1ed3b75f7fdb78193Dav Glass this._handles.push(Y.on('mouseenter', Y.bind(this._onMouseEnter, this), cont));
eba99cf5219728ad7993f0b1ed3b75f7fdb78193Dav Glass this._handles.push(Y.on('mouseleave', Y.bind(this._onMouseLeave, this), cont));
4d589fe0c1bf5d088a90cdf29f3bc777942006cbDav Glass * @method syncTargets
4d589fe0c1bf5d088a90cdf29f3bc777942006cbDav Glass * @description Applies the Y.Plugin.Drop to all nodes matching the cont + nodes selector query.
4d589fe0c1bf5d088a90cdf29f3bc777942006cbDav Glass * @return {Self}
4d589fe0c1bf5d088a90cdf29f3bc777942006cbDav Glass * @chainable
eba99cf5219728ad7993f0b1ed3b75f7fdb78193Dav Glass syncTargets: function() {
eba99cf5219728ad7993f0b1ed3b75f7fdb78193Dav Glass items = Y.one(this.get(CONT)).all(this.get(NODES));
eba99cf5219728ad7993f0b1ed3b75f7fdb78193Dav Glass return this;
3b3bd34996b581ab171be1465201869cb009dbadDav Glass * @method createDrop
3b3bd34996b581ab171be1465201869cb009dbadDav Glass * @description Apply the Drop plugin to this node
3b3bd34996b581ab171be1465201869cb009dbadDav Glass * @param {Node} node The Node to apply the plugin to
3b3bd34996b581ab171be1465201869cb009dbadDav Glass * @param {Array} groups The default groups to assign this target to.
3b3bd34996b581ab171be1465201869cb009dbadDav Glass * @return Node
6cd85fc002ad88c48179730400dc0bc36a7a9f5bDav Glass destructor: function() {
3b3bd34996b581ab171be1465201869cb009dbadDav Glass if (this.dd) {
713a27b6ab5ab057e9b4ab551617b54730e8906eDav Glass var targets = Y.one(this.get(CONT)).all(this.get(NODES));
482da2d388e0f999f372383039af944e21bc717bDav Glass * @attribute container
482da2d388e0f999f372383039af944e21bc717bDav Glass * @description A selector query to get the container to listen for mousedown events on. All "nodes" should be a child of this container.
482da2d388e0f999f372383039af944e21bc717bDav Glass * @type String
482da2d388e0f999f372383039af944e21bc717bDav Glass * @attribute nodes
482da2d388e0f999f372383039af944e21bc717bDav Glass * @description A selector query to get the children of the "container" to make draggable elements from.
482da2d388e0f999f372383039af944e21bc717bDav Glass * @type String
482da2d388e0f999f372383039af944e21bc717bDav Glass * @attribute invalid
482da2d388e0f999f372383039af944e21bc717bDav Glass * @description A selector query to test a node to see if it's an invalid item.
482da2d388e0f999f372383039af944e21bc717bDav Glass * @type String
482da2d388e0f999f372383039af944e21bc717bDav Glass * @attribute lastNode
482da2d388e0f999f372383039af944e21bc717bDav Glass * @description Y.Node instance of the last item dragged.
482da2d388e0f999f372383039af944e21bc717bDav Glass * @type Node
482da2d388e0f999f372383039af944e21bc717bDav Glass * @attribute currentNode
482da2d388e0f999f372383039af944e21bc717bDav Glass * @description Y.Node instance of the dd node.
482da2d388e0f999f372383039af944e21bc717bDav Glass * @type Node
482da2d388e0f999f372383039af944e21bc717bDav Glass * @attribute dragNode
482da2d388e0f999f372383039af944e21bc717bDav Glass * @description Y.Node instance of the dd dragNode.
482da2d388e0f999f372383039af944e21bc717bDav Glass * @type Node
482da2d388e0f999f372383039af944e21bc717bDav Glass * @attribute over
482da2d388e0f999f372383039af944e21bc717bDav Glass * @description Is the mouse currently over the container
482da2d388e0f999f372383039af944e21bc717bDav Glass * @type Boolean
482da2d388e0f999f372383039af944e21bc717bDav Glass * @attribute target
482da2d388e0f999f372383039af944e21bc717bDav Glass * @description Should the items also be a drop target.
482da2d388e0f999f372383039af944e21bc717bDav Glass * @type Boolean
482da2d388e0f999f372383039af944e21bc717bDav Glass * @attribute dragConfig
482da2d388e0f999f372383039af944e21bc717bDav Glass * @description The default config to be used when creating the DD instance.
482da2d388e0f999f372383039af944e21bc717bDav Glass * @type Object
482da2d388e0f999f372383039af944e21bc717bDav Glass * @attribute handles
482da2d388e0f999f372383039af944e21bc717bDav Glass * @description The handles config option added to the temp DD instance.
482da2d388e0f999f372383039af944e21bc717bDav Glass * @type Array
3b3bd34996b581ab171be1465201869cb009dbadDav Glass * @property _delegates
3b3bd34996b581ab171be1465201869cb009dbadDav Glass * @description Holder for all Y.DD.Delegate instances
3b3bd34996b581ab171be1465201869cb009dbadDav Glass * @type Array
3b3bd34996b581ab171be1465201869cb009dbadDav Glass * @method regDelegate
3b3bd34996b581ab171be1465201869cb009dbadDav Glass * @description Register a Delegate with the DDM
3b3bd34996b581ab171be1465201869cb009dbadDav Glass * @method getDelegate
3b3bd34996b581ab171be1465201869cb009dbadDav Glass * @description Get a delegate instance from a container node
18e82681a4dfa7e04bd54297593e1da270fb7fd0Dav Glass * @return Y.DD.Delegate
3b3bd34996b581ab171be1465201869cb009dbadDav Glass var del = null;