xonecas.io
142
St

startsInvasion / files

startsInvasion / libs / node_modules / bean / support / syn / resources / jquery.event.drag.js

23.9 KB
1(function( $ ) {
2	var getSetZero = function( v ) {
3		return v !== undefined ? (this.array[0] = v) : this.array[0];
4	},
5		getSetOne = function( v ) {
6			return v !== undefined ? (this.array[1] = v) : this.array[1];
7		};
8	/**
9	 * @class jQuery.Vector
10	 * A vector class
11	 * @constructor creates a new vector instance from the arguments.  Example:
12	 * @codestart
13	 * new jQuery.Vector(1,2)
14	 * @codeend
15	 * 
16	 */
17	$.Vector = function() {
18		this.update($.makeArray(arguments));
19	};
20	$.Vector.prototype =
21	/* @Prototype*/
22	{
23		/**
24		 * Applys the function to every item in the vector.  Returns the new vector.
25		 * @param {Function} f
26		 * @return {jQuery.Vector} new vector class.
27		 */
28		app: function( f ) {
29			var i, vec, newArr = [];
30
31			for ( i = 0; i < this.array.length; i++ ) {
32				newArr.push(f(this.array[i]));
33			}
34			vec = new $.Vector();
35			return vec.update(newArr);
36		},
37		/**
38		 * Adds two vectors together.  Example:
39		 * @codestart
40		 * new Vector(1,2).plus(2,3) //-> &lt;3,5>
41		 * new Vector(3,5).plus(new Vector(4,5)) //-> &lt;7,10>
42		 * @codeend
43		 * @return {$.Vector}
44		 */
45		plus: function() {
46			var i, args = arguments[0] instanceof $.Vector ? arguments[0].array : $.makeArray(arguments),
47				arr = this.array.slice(0),
48				vec = new $.Vector();
49			for ( i = 0; i < args.length; i++ ) {
50				arr[i] = (arr[i] ? arr[i] : 0) + args[i];
51			}
52			return vec.update(arr);
53		},
54		/**
55		 * Like plus but subtracts 2 vectors
56		 * @return {jQuery.Vector}
57		 */
58		minus: function() {
59			var i, args = arguments[0] instanceof $.Vector ? arguments[0].array : $.makeArray(arguments),
60				arr = this.array.slice(0),
61				vec = new $.Vector();
62			for ( i = 0; i < args.length; i++ ) {
63				arr[i] = (arr[i] ? arr[i] : 0) - args[i];
64			}
65			return vec.update(arr);
66		},
67		/**
68		 * Returns the current vector if it is equal to the vector passed in.  
69		 * False if otherwise.
70		 * @return {jQuery.Vector}
71		 */
72		equals: function() {
73			var i, args = arguments[0] instanceof $.Vector ? arguments[0].array : $.makeArray(arguments),
74				arr = this.array.slice(0),
75				vec = new $.Vector();
76			for ( i = 0; i < args.length; i++ ) {
77				if ( arr[i] != args[i] ) {
78					return null;
79				}
80			}
81			return vec.update(arr);
82		},
83/*
84	 * Returns the 2nd value of the vector
85	 * @return {Number}
86	 */
87		x: getSetZero,
88		width: getSetZero,
89		/**
90		 * Returns the first value of the vector
91		 * @return {Number}
92		 */
93		y: getSetOne,
94		height: getSetOne,
95		/**
96		 * Same as x()
97		 * @return {Number}
98		 */
99		top: getSetOne,
100		/**
101		 * same as y()
102		 * @return {Number}
103		 */
104		left: getSetZero,
105		/**
106		 * returns (x,y)
107		 * @return {String}
108		 */
109		toString: function() {
110			return "(" + this.array[0] + "," + this.array[1] + ")";
111		},
112		/**
113		 * Replaces the vectors contents
114		 * @param {Object} array
115		 */
116		update: function( array ) {
117			var i;
118			if ( this.array ) {
119				for ( i = 0; i < this.array.length; i++ ) {
120					delete this.array[i];
121				}
122			}
123			this.array = array;
124			for ( i = 0; i < array.length; i++ ) {
125				this[i] = this.array[i];
126			}
127			return this;
128		}
129	};
130
131	$.Event.prototype.vector = function() {
132		if ( this.originalEvent.synthetic ) {
133			var doc = document.documentElement,
134				body = document.body;
135			return new $.Vector(this.clientX + (doc && doc.scrollLeft || body && body.scrollLeft || 0) - (doc.clientLeft || 0), this.clientY + (doc && doc.scrollTop || body && body.scrollTop || 0) - (doc.clientTop || 0));
136		} else {
137			return new $.Vector(this.pageX, this.pageY);
138		}
139	};
140
141	$.fn.offsetv = function() {
142		if ( this[0] == window ) {
143			return new $.Vector(window.pageXOffset ? window.pageXOffset : document.documentElement.scrollLeft, window.pageYOffset ? window.pageYOffset : document.documentElement.scrollTop);
144		} else {
145			var offset = this.offset();
146			return new $.Vector(offset.left, offset.top);
147		}
148	};
149
150	$.fn.dimensionsv = function( which ) {
151		if ( this[0] == window || !which ) {
152			return new $.Vector(this.width(), this.height());
153		}
154		else {
155			return new $.Vector(this[which + "Width"](), this[which + "Height"]());
156		}
157	};
158})(jQuery);
159(function() {
160
161	var event = jQuery.event,
162
163		//helper that finds handlers by type and calls back a function, this is basically handle
164		findHelper = function( events, types, callback ) {
165			var t, type, typeHandlers, all, h, handle, namespaces, namespace;
166			for ( t = 0; t < types.length; t++ ) {
167				type = types[t];
168				all = type.indexOf(".") < 0;
169				if (!all ) {
170					namespaces = type.split(".");
171					type = namespaces.shift();
172					namespace = new RegExp("(^|\\.)" + namespaces.slice(0).sort().join("\\.(?:.*\\.)?") + "(\\.|$)");
173				}
174				typeHandlers = (events[type] || []).slice(0);
175
176				for ( h = 0; h < typeHandlers.length; h++ ) {
177					handle = typeHandlers[h];
178					if (!handle.selector && (all || namespace.test(handle.namespace)) ) {
179						callback(type, handle.origHandler || handle.handler);
180					}
181				}
182			}
183		};
184
185	/**
186	 * Finds event handlers of a given type on an element.
187	 * @param {HTMLElement} el
188	 * @param {Array} types an array of event names
189	 * @param {String} [selector] optional selector
190	 * @return {Array} an array of event handlers
191	 */
192	event.find = function( el, types, selector ) {
193		var events = $.data(el, "events"),
194			handlers = [],
195			t, liver, live;
196
197		if (!events ) {
198			return handlers;
199		}
200
201		if ( selector ) {
202			if (!events.live ) {
203				return [];
204			}
205			live = events.live;
206
207			for ( t = 0; t < live.length; t++ ) {
208				liver = live[t];
209				if ( liver.selector === selector && $.inArray(liver.origType, types) !== -1 ) {
210					handlers.push(liver.origHandler || liver.handler);
211				}
212			}
213		} else {
214			// basically re-create handler's logic
215			findHelper(events, types, function( type, handler ) {
216				handlers.push(handler);
217			});
218		}
219		return handlers;
220	};
221	/**
222	 * Finds 
223	 * @param {HTMLElement} el
224	 * @param {Array} types
225	 */
226	event.findBySelector = function( el, types ) {
227		var events = $.data(el, "events"),
228			selectors = {},
229			//adds a handler for a given selector and event
230			add = function( selector, event, handler ) {
231				var select = selectors[selector] || (selectors[selector] = {}),
232					events = select[event] || (select[event] = []);
233				events.push(handler);
234			};
235
236		if (!events ) {
237			return selectors;
238		}
239		//first check live:
240		$.each(events.live || [], function( i, live ) {
241			if ( $.inArray(live.origType, types) !== -1 ) {
242				add(live.selector, live.origType, live.origHandler || live.handler);
243			}
244		});
245		//then check straight binds
246		findHelper(events, types, function( type, handler ) {
247			add("", type, handler);
248		});
249
250		return selectors;
251	};
252	$.fn.respondsTo = function( events ) {
253		if (!this.length ) {
254			return false;
255		} else {
256			//add default ?
257			return event.find(this[0], $.isArray(events) ? events : [events]).length > 0;
258		}
259	};
260	$.fn.triggerHandled = function( event, data ) {
261		event = (typeof event == "string" ? $.Event(event) : event);
262		this.trigger(event, data);
263		return event.handled;
264	};
265	/**
266	 * Only attaches one event handler for all types ...
267	 * @param {Array} types llist of types that will delegate here
268	 * @param {Object} startingEvent the first event to start listening to
269	 * @param {Object} onFirst a function to call 
270	 */
271	event.setupHelper = function( types, startingEvent, onFirst ) {
272		if (!onFirst ) {
273			onFirst = startingEvent;
274			startingEvent = null;
275		}
276		var add = function( handleObj ) {
277
278			var bySelector, selector = handleObj.selector || "";
279			if ( selector ) {
280				bySelector = event.find(this, types, selector);
281				if (!bySelector.length ) {
282					$(this).delegate(selector, startingEvent, onFirst);
283				}
284			}
285			else {
286				//var bySelector = event.find(this, types, selector);
287				if (!event.find(this, types, selector).length ) {
288					event.add(this, startingEvent, onFirst, {
289						selector: selector,
290						delegate: this
291					});
292				}
293
294			}
295
296		},
297			remove = function( handleObj ) {
298				var bySelector, selector = handleObj.selector || "";
299				if ( selector ) {
300					bySelector = event.find(this, types, selector);
301					if (!bySelector.length ) {
302						$(this).undelegate(selector, startingEvent, onFirst);
303					}
304				}
305				else {
306					if (!event.find(this, types, selector).length ) {
307						event.remove(this, startingEvent, onFirst, {
308							selector: selector,
309							delegate: this
310						});
311					}
312				}
313			};
314		$.each(types, function() {
315			event.special[this] = {
316				add: add,
317				remove: remove,
318				setup: function() {},
319				teardown: function() {}
320			};
321		});
322	};
323})(jQuery);
324(function( $ ) {
325	//modify live
326	//steal the live handler ....
327	var bind = function( object, method ) {
328		var args = Array.prototype.slice.call(arguments, 2);
329		return function() {
330			var args2 = [this].concat(args, $.makeArray(arguments));
331			return method.apply(object, args2);
332		};
333	},
334		event = $.event;
335	// var handle = event.handle; //unused
336	/**
337	 * @class jQuery.Drag
338	 * @parent specialevents
339	 * @plugin jquery/event/drag
340	 * @download  http://jmvcsite.heroku.com/pluginify?plugins[]=jquery/event/drag/drag.js
341	 * @test jquery/event/drag/qunit.html
342	 * Provides drag events as a special events to jQuery.  
343	 * A jQuery.Drag instance is created on a drag and passed
344	 * as a parameter to the drag event callbacks.  By calling
345	 * methods on the drag event, you can alter the drag's
346	 * behavior.
347	 * <h2>Drag Events</h2>
348	 * The drag plugin allows you to listen to the following events:
349	 * <ul>
350	 *  <li><code>dragdown</code> - the mouse cursor is pressed down</li>
351	 *  <li><code>draginit</code> - the drag motion is started</li>
352	 *  <li><code>dragmove</code> - the drag is moved</li>
353	 *  <li><code>dragend</code> - the drag has ended</li>
354	 *  <li><code>dragover</code> - the drag is over a drop point</li>
355	 *  <li><code>dragout</code> - the drag moved out of a drop point</li>
356	 * </ul>
357	 * <p>Just by binding or delegating on one of these events, you make
358	 * the element dragable.  You can change the behavior of the drag
359	 * by calling methods on the drag object passed to the callback.
360	 * <h3>Example</h3>
361	 * Here's a quick example:
362	 * @codestart
363	 * //makes the drag vertical
364	 * $(".drags").live("draginit", function(event, drag){
365	 *   drag.vertical();
366	 * })
367	 * //gets the position of the drag and uses that to set the width
368	 * //of an element
369	 * $(".resize").live("dragmove",function(event, drag){
370	 *   $(this).width(drag.position.left() - $(this).offset().left   )
371	 * })
372	 * @codeend
373	 * <h2>Drag Object</h2>
374	 * <p>The drag object is passed after the event to drag 
375	 * event callback functions.  By calling methods
376	 * and changing the properties of the drag object,
377	 * you can alter how the drag behaves.
378	 * </p>
379	 * <p>The drag properties and methods:</p>
380	 * <ul>
381	 *  <li><code>[jQuery.Drag.prototype.cancel cancel]</code> - stops the drag motion from happening</li>
382	 *  <li><code>[jQuery.Drag.prototype.ghost ghost]</code> - copys the draggable and drags the cloned element</li>
383	 *  <li><code>[jQuery.Drag.prototype.horizontal horizontal]</code> - limits the scroll to horizontal movement</li>
384	 *  <li><code>[jQuery.Drag.prototype.location location]</code> - where the drag should be on the screen</li>
385	 *  <li><code>[jQuery.Drag.prototype.mouseElementPosition mouseElementPosition]</code> - where the mouse should be on the drag</li>
386	 *  <li><code>[jQuery.Drag.prototype.only only]</code> - only have drags, no drops</li>
387	 *  <li><code>[jQuery.Drag.prototype.representative representative]</code> - move another element in place of this element</li>
388	 *  <li><code>[jQuery.Drag.prototype.revert revert]</code> - animate the drag back to its position</li>
389	 *  <li><code>[jQuery.Drag.prototype.vertical vertical]</code> - limit the drag to vertical movement</li>
390	 *  <li><code>[jQuery.Drag.prototype.limit limit]</code> - limit the drag within an element (*limit plugin)</li>
391	 *  <li><code>[jQuery.Drag.prototype.scrolls scrolls]</code> - scroll scrollable areas when dragging near their boundries (*scroll plugin)</li>
392	 * </ul>
393	 * <h2>Demo</h2>
394	 * Now lets see some examples:
395	 * @demo jquery/event/drag/drag.html 1000
396	 * @constructor
397	 * The constructor is never called directly.
398	 */
399	$.Drag = function() {};
400
401	/**
402	 * @Static
403	 */
404	$.extend($.Drag, {
405		lowerName: "drag",
406		current: null,
407		/**
408		 * Called when someone mouses down on a draggable object.
409		 * Gathers all callback functions and creates a new Draggable.
410		 * @hide
411		 */
412		mousedown: function( ev, element ) {
413			var isLeftButton = ev.button === 0 || ev.button == 1;
414			if (!isLeftButton || this.current ) {
415				return;
416			} //only allows 1 drag at a time, but in future could allow more
417			//ev.preventDefault();
418			//create Drag
419			var drag = new $.Drag(),
420				delegate = ev.liveFired || element,
421				selector = ev.handleObj.selector,
422				self = this;
423			this.current = drag;
424
425			drag.setup({
426				element: element,
427				delegate: ev.liveFired || element,
428				selector: ev.handleObj.selector,
429				moved: false,
430				callbacks: {
431					dragdown: event.find(delegate, ["dragdown"], selector),
432					draginit: event.find(delegate, ["draginit"], selector),
433					dragover: event.find(delegate, ["dragover"], selector),
434					dragmove: event.find(delegate, ["dragmove"], selector),
435					dragout: event.find(delegate, ["dragout"], selector),
436					dragend: event.find(delegate, ["dragend"], selector)
437				},
438				destroyed: function() {
439					self.current = null;
440				}
441			}, ev);
442		}
443	});
444
445
446
447
448
449	/**
450	 * @Prototype
451	 */
452	$.extend($.Drag.prototype, {
453		setup: function( options, ev ) {
454			//this.noSelection();
455			$.extend(this, options);
456			this.element = $(this.element);
457			this.event = ev;
458			this.moved = false;
459			this.allowOtherDrags = false;
460			var mousemove = bind(this, this.mousemove),
461				mouseup = bind(this, this.mouseup);
462			this._mousemove = mousemove;
463			this._mouseup = mouseup;
464			$(document).bind('mousemove', mousemove);
465			$(document).bind('mouseup', mouseup);
466
467			if (!this.callEvents('down', this.element, ev) ) {
468				ev.preventDefault();
469			}
470		},
471		/**
472		 * Unbinds listeners and allows other drags ...
473		 * @hide
474		 */
475		destroy: function() {
476			$(document).unbind('mousemove', this._mousemove);
477			$(document).unbind('mouseup', this._mouseup);
478			if (!this.moved ) {
479				this.event = this.element = null;
480			}
481			//this.selection();
482			this.destroyed();
483		},
484		mousemove: function( docEl, ev ) {
485			if (!this.moved ) {
486				this.init(this.element, ev);
487				this.moved = true;
488			}
489
490			var pointer = ev.vector();
491			if ( this._start_position && this._start_position.equals(pointer) ) {
492				return;
493			}
494			//e.preventDefault();
495			this.draw(pointer, ev);
496		},
497		mouseup: function( docEl, event ) {
498			//if there is a current, we should call its dragstop
499			if ( this.moved ) {
500				this.end(event);
501			}
502			this.destroy();
503		},
504		noSelection: function() {
505			document.documentElement.onselectstart = function() {
506				return false;
507			};
508			document.documentElement.unselectable = "on";
509			$(document.documentElement).css('-moz-user-select', 'none');
510		},
511		selection: function() {
512			document.documentElement.onselectstart = function() {};
513			document.documentElement.unselectable = "off";
514			$(document.documentElement).css('-moz-user-select', '');
515		},
516		init: function( element, event ) {
517			element = $(element);
518			var startElement = (this.movingElement = (this.element = $(element))); //the element that has been clicked on
519			//if a mousemove has come after the click
520			this._cancelled = false; //if the drag has been cancelled
521			this.event = event;
522			this.mouseStartPosition = event.vector(); //where the mouse is located
523			/**
524			 * @attribute mouseElementPosition
525			 * The position of start of the cursor on the element
526			 */
527			this.mouseElementPosition = this.mouseStartPosition.minus(this.element.offsetv()); //where the mouse is on the Element
528			//this.callStart(element, event);
529			this.callEvents('init', element, event);
530
531			//Check what they have set and respond accordingly
532			//  if they canceled
533			if ( this._cancelled === true ) {
534				return;
535			}
536			//if they set something else as the element
537			this.startPosition = startElement != this.movingElement ? this.movingElement.offsetv() : this.currentDelta();
538
539			this.makePositioned(this.movingElement);
540			this.oldZIndex = this.movingElement.css('zIndex');
541			this.movingElement.css('zIndex', 1000);
542			if (!this._only && this.constructor.responder ) {
543				this.constructor.responder.compile(event, this);
544			}
545		},
546		makePositioned: function( that ) {
547			var style, pos = that.css('position');
548
549			if (!pos || pos == 'static' ) {
550				style = {
551					position: 'relative'
552				};
553
554				if ( window.opera ) {
555					style.top = '0px';
556					style.left = '0px';
557				}
558				that.css(style);
559			}
560		},
561		callEvents: function( type, element, event, drop ) {
562			var i, cbs = this.callbacks[this.constructor.lowerName + type];
563			for ( i = 0; i < cbs.length; i++ ) {
564				cbs[i].call(element, event, this, drop);
565			}
566			return cbs.length;
567		},
568		/**
569		 * Returns the position of the movingElement by taking its top and left.
570		 * @hide
571		 * @return {Vector}
572		 */
573		currentDelta: function() {
574			return new $.Vector(parseInt(this.movingElement.css('left'), 10) || 0, parseInt(this.movingElement.css('top'), 10) || 0);
575		},
576		//draws the position of the dragmove object
577		draw: function( pointer, event ) {
578			// only drag if we haven't been cancelled;
579			if ( this._cancelled ) {
580				return;
581			}
582			/**
583			 * @attribute location
584			 * The location of where the element should be in the page.  This 
585			 * takes into account the start position of the cursor on the element.
586			 */
587			this.location = pointer.minus(this.mouseElementPosition); // the offset between the mouse pointer and the representative that the user asked for
588			// position = mouse - (dragOffset - dragTopLeft) - mousePosition
589			this.move(event);
590			if ( this._cancelled ) {
591				return;
592			}
593			if (!event.isDefaultPrevented() ) {
594				this.position(this.location);
595			}
596
597			//fill in
598			if (!this._only && this.constructor.responder ) {
599				this.constructor.responder.show(pointer, this, event);
600			}
601		},
602		/**
603		 * Sets the position of this drag.  
604		 * 
605		 * The limit and scroll plugins
606		 * overwrite this to make sure the drag follows a particular path.
607		 * 
608		 * @param {jQuery.Vector} newOffsetv the position of the element (not the mouse)
609		 */
610		position: function( newOffsetv ) { //should draw it on the page
611			var style, dragged_element_css_offset = this.currentDelta(),
612				//  the drag element's current left + top css attributes
613				dragged_element_position_vector = // the vector between the movingElement's page and css positions
614				this.movingElement.offsetv().minus(dragged_element_css_offset); // this can be thought of as the original offset
615			this.required_css_position = newOffsetv.minus(dragged_element_position_vector);
616
617			this.offsetv = newOffsetv;
618			//dragged_element vector can probably be cached.
619			style = this.movingElement[0].style;
620			if (!this._cancelled && !this._horizontal ) {
621				style.top = this.required_css_position.top() + "px";
622			}
623			if (!this._cancelled && !this._vertical ) {
624				style.left = this.required_css_position.left() + "px";
625			}
626		},
627		move: function( event ) {
628			this.callEvents('move', this.element, event);
629		},
630		over: function( event, drop ) {
631			this.callEvents('over', this.element, event, drop);
632		},
633		out: function( event, drop ) {
634			this.callEvents('out', this.element, event, drop);
635		},
636		/**
637		 * Called on drag up
638		 * @hide
639		 * @param {Event} event a mouseup event signalling drag/drop has completed
640		 */
641		end: function( event ) {
642			if ( this._cancelled ) {
643				return;
644			}
645			if (!this._only && this.constructor.responder ) {
646				this.constructor.responder.end(event, this);
647			}
648
649			this.callEvents('end', this.element, event);
650
651			if ( this._revert ) {
652				var self = this;
653				this.movingElement.animate({
654					top: this.startPosition.top() + "px",
655					left: this.startPosition.left() + "px"
656				}, function() {
657					self.cleanup.apply(self, arguments);
658				});
659			}
660			else {
661				this.cleanup();
662			}
663			this.event = null;
664		},
665		/**
666		 * Cleans up drag element after drag drop.
667		 * @hide
668		 */
669		cleanup: function() {
670			this.movingElement.css({
671				zIndex: this.oldZIndex
672			});
673			if ( this.movingElement[0] !== this.element[0] ) {
674				this.movingElement.css({
675					display: 'none'
676				});
677			}
678			if ( this._removeMovingElement ) {
679				this.movingElement.remove();
680			}
681
682			this.movingElement = this.element = this.event = null;
683		},
684		/**
685		 * Stops drag drop from running.
686		 */
687		cancel: function() {
688			this._cancelled = true;
689			//this.end(this.event);
690			if (!this._only && this.constructor.responder ) {
691				this.constructor.responder.clear(this.event.vector(), this, this.event);
692			}
693			this.destroy();
694
695		},
696		/**
697		 * Clones the element and uses it as the moving element.
698		 * @return {jQuery.fn} the ghost
699		 */
700		ghost: function( loc ) {
701			// create a ghost by cloning the source element and attach the clone to the dom after the source element
702			var ghost = this.movingElement.clone().css('position', 'absolute');
703			(loc ? $(loc) : this.movingElement).after(ghost);
704			ghost.width(this.movingElement.width()).height(this.movingElement.height());
705
706			// store the original element and make the ghost the dragged element
707			this.movingElement = ghost;
708			this._removeMovingElement = true;
709			return ghost;
710		},
711		/**
712		 * Use a representative element, instead of the movingElement.
713		 * @param {HTMLElement} element the element you want to actually drag
714		 * @param {Number} offsetX the x position where you want your mouse on the object
715		 * @param {Number} offsetY the y position where you want your mouse on the object
716		 */
717		representative: function( element, offsetX, offsetY ) {
718			this._offsetX = offsetX || 0;
719			this._offsetY = offsetY || 0;
720
721			var p = this.mouseStartPosition;
722
723			this.movingElement = $(element);
724			this.movingElement.css({
725				top: (p.y() - this._offsetY) + "px",
726				left: (p.x() - this._offsetX) + "px",
727				display: 'block',
728				position: 'absolute'
729			}).show();
730
731			this.mouseElementPosition = new $.Vector(this._offsetX, this._offsetY);
732		},
733		/**
734		 * Makes the movingElement go back to its original position after drop.
735		 * @codestart
736		 * ".handle dragend" : function( el, ev, drag ) {
737		 *    drag.revert()
738		 * }
739		 * @codeend
740		 * @param {Boolean} [val] optional, set to false if you don't want to revert.
741		 */
742		revert: function( val ) {
743			this._revert = val === null ? true : val;
744		},
745		/**
746		 * Isolates the drag to vertical movement.
747		 */
748		vertical: function() {
749			this._vertical = true;
750		},
751		/**
752		 * Isolates the drag to horizontal movement.
753		 */
754		horizontal: function() {
755			this._horizontal = true;
756		},
757
758
759		/**
760		 * Respondables will not be alerted to this drag.
761		 */
762		only: function( only ) {
763			return (this._only = (only === undefined ? true : only));
764		}
765	});
766
767	/**
768	 * @add jQuery.event.special
769	 */
770	event.setupHelper([
771	/**
772	 * @attribute dragdown
773	 * <p>Listens for when a drag movement has started on a mousedown.
774	 * If you listen to this, the mousedown's default event (preventing
775	 * text selection) is not prevented.  You are responsible for calling it
776	 * if you want it (you probably do).  </p>
777	 * <p><b>Why might you not want it?</b></p>
778	 * <p>You might want it if you want to allow text selection on element
779	 * within the drag element.  Typically these are input elements.</p>
780	 * <p>Drag events are covered in more detail in [jQuery.Drag].</p>
781	 * @codestart
782	 * $(".handles").live("dragdown", function(ev, drag){})
783	 * @codeend
784	 */
785	'dragdown',
786	/**
787	 * @attribute draginit
788	 * Called when the drag starts.
789	 * <p>Drag events are covered in more detail in [jQuery.Drag].</p>
790	 */
791	'draginit',
792	/**
793	 * @attribute dragover
794	 * Called when the drag is over a drop.
795	 * <p>Drag events are covered in more detail in [jQuery.Drag].</p>
796	 */
797	'dragover',
798	/**
799	 * @attribute dragmove
800	 * Called when the drag is moved.
801	 * <p>Drag events are covered in more detail in [jQuery.Drag].</p>
802	 */
803	'dragmove',
804	/**
805	 * @attribute dragout
806	 * When the drag leaves a drop point.
807	 * <p>Drag events are covered in more detail in [jQuery.Drag].</p>
808	 */
809	'dragout',
810	/**
811	 * @attribute dragend
812	 * Called when the drag is done.
813	 * <p>Drag events are covered in more detail in [jQuery.Drag].</p>
814	 */
815	'dragend'], "mousedown", function( e ) {
816		$.Drag.mousedown.call($.Drag, e, this);
817
818	});
819
820
821
822
823})(jQuery)