PageSourceSearch

https://portal.uicalaska.com/Scripts/jquery-ui.slickgrid.js

js uicalaska.com collected 2026-09-25 04:10:32 UTC 73,682 bytes, 2,335 lines download raw bytes

vendor: 11,321 bytes, lines 1-414
1/*! jQuery UI - v1.11.3 - 2015-02-16
2* http://jqueryui.com
3* Includes: core.js, widget.js, mouse.js, sortable.js
4* Copyright 2015 jQuery Foundation and other contributors; Licensed MIT */
5
6(function( factory ) {
7	if ( typeof define === "function" && define.amd ) {
8
9		// AMD. Register as an anonymous module.
10		define([ "jquery" ], factory );
11	} else {
12
13		// Browser globals
14		factory( jQuery );
15	}
16}(function( $ ) {
17/*!
18 * jQuery UI Core 1.11.3
19 * http://jqueryui.com
20 *
21 * Copyright jQuery Foundation and other contributors
22 * Released under the MIT license.
23 * http://jquery.org/license
24 *
25 * http://api.jqueryui.com/category/ui-core/
26 */
27
28
29// $.ui might exist from components with no dependencies, e.g., $.ui.position
30$.ui = $.ui || {};
31
32$.extend( $.ui, {
33	version: "1.11.3",
34
35	keyCode: {
36		BACKSPACE: 8,
37		COMMA: 188,
38		DELETE: 46,
39		DOWN: 40,
40		END: 35,
41		ENTER: 13,
42		ESCAPE: 27,
43		HOME: 36,
44		LEFT: 37,
45		PAGE_DOWN: 34,
46		PAGE_UP: 33,
47		PERIOD: 190,
48		RIGHT: 39,
49		SPACE: 32,
50		TAB: 9,
51		UP: 38
52	}
53});
54
55// plugins
56$.fn.extend({
57	scrollParent: function( includeHidden ) {
58		var position = this.css( "position" ),
59			excludeStaticParent = position === "absolute",
60			overflowRegex = includeHidden ? /(auto|scroll|hidden)/ : /(auto|scroll)/,
61			scrollParent = this.parents().filter( function() {
62				var parent = $( this );
63				if ( excludeStaticParent && parent.css( "position" ) === "static" ) {
64					return false;
65				}
66				return overflowRegex.test( parent.css( "overflow" ) + parent.css( "overflow-y" ) + parent.css( "overflow-x" ) );
67			}).eq( 0 );
68
69		return position === "fixed" || !scrollParent.length ? $( this[ 0 ].ownerDocument || document ) : scrollParent;
70	},
71
72	uniqueId: (function() {
73		var uuid = 0;
74
75		return function() {
76			return this.each(function() {
77				if ( !this.id ) {
78					this.id = "ui-id-" + ( ++uuid );
79				}
80			});
81		};
82	})(),
83
84	removeUniqueId: function() {
85		return this.each(function() {
86			if ( /^ui-id-\d+$/.test( this.id ) ) {
87				$( this ).removeAttr( "id" );
88			}
89		});
90	}
91});
92
93// selectors
94function focusable( element, isTabIndexNotNaN ) {
95	var map, mapName, img,
96		nodeName = element.nodeName.toLowerCase();
97	if ( "area" === nodeName ) {
98		map = element.parentNode;
99		mapName = map.name;
100		if ( !element.href || !mapName || map.nodeName.toLowerCase() !== "map" ) {
101			return false;
102		}
103		img = $( "img[usemap='#" + mapName + "']" )[ 0 ];
104		return !!img && visible( img );
105	}
106	return ( /^(input|select|textarea|button|object)$/.test( nodeName ) ?
107		!element.disabled :
108		"a" === nodeName ?
109			element.href || isTabIndexNotNaN :
110			isTabIndexNotNaN) &&
111		// the element and all of its ancestors must be visible
112		visible( element );
113}
114
115function visible( element ) {
116	return $.expr.filters.visible( element ) &&
117		!$( element ).parents().addBack().filter(function() {
118			return $.css( this, "visibility" ) === "hidden";
119		}).length;
120}
121
122$.extend( $.expr[ ":" ], {
123	data: $.expr.createPseudo ?
124		$.expr.createPseudo(function( dataName ) {
125			return function( elem ) {
126				return !!$.data( elem, dataName );
127			};
128		}) :
129		// support: jQuery <1.8
130		function( elem, i, match ) {
131			return !!$.data( elem, match[ 3 ] );
132		},
133
134	focusable: function( element ) {
135		return focusable( element, !isNaN( $.attr( element, "tabindex" ) ) );
136	},
137
138	tabbable: function( element ) {
139		var tabIndex = $.attr( element, "tabindex" ),
140			isTabIndexNaN = isNaN( tabIndex );
141		return ( isTabIndexNaN || tabIndex >= 0 ) && focusable( element, !isTabIndexNaN );
142	}
143});
144
145// support: jQuery <1.8
146if ( !$( "<a>" ).outerWidth( 1 ).jquery ) {
147	$.each( [ "Width", "Height" ], function( i, name ) {
148		var side = name === "Width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ],
149			type = name.toLowerCase(),
150			orig = {
151				innerWidth: $.fn.innerWidth,
152				innerHeight: $.fn.innerHeight,
153				outerWidth: $.fn.outerWidth,
154				outerHeight: $.fn.outerHeight
155			};
156
157		function reduce( elem, size, border, margin ) {
158			$.each( side, function() {
159				size -= parseFloat( $.css( elem, "padding" + this ) ) || 0;
160				if ( border ) {
161					size -= parseFloat( $.css( elem, "border" + this + "Width" ) ) || 0;
162				}
163				if ( margin ) {
164					size -= parseFloat( $.css( elem, "margin" + this ) ) || 0;
165				}
166			});
167			return size;
168		}
169
170		$.fn[ "inner" + name ] = function( size ) {
171			if ( size === undefined ) {
172				return orig[ "inner" + name ].call( this );
173			}
174
175			return this.each(function() {
176				$( this ).css( type, reduce( this, size ) + "px" );
177			});
178		};
179
180		$.fn[ "outer" + name] = function( size, margin ) {
181			if ( typeof size !== "number" ) {
182				return orig[ "outer" + name ].call( this, size );
183			}
184
185			return this.each(function() {
186				$( this).css( type, reduce( this, size, true, margin ) + "px" );
187			});
188		};
189	});
190}
191
192// support: jQuery <1.8
193if ( !$.fn.addBack ) {
194	$.fn.addBack = function( selector ) {
195		return this.add( selector == null ?
196			this.prevObject : this.prevObject.filter( selector )
197		);
198	};
199}
200
201// support: jQuery 1.6.1, 1.6.2 (http://bugs.jquery.com/ticket/9413)
202if ( $( "<a>" ).data( "a-b", "a" ).removeData( "a-b" ).data( "a-b" ) ) {
203	$.fn.removeData = (function( removeData ) {
204		return function( key ) {
205			if ( arguments.length ) {
206				return removeData.call( this, $.camelCase( key ) );
207			} else {
208				return removeData.call( this );
209			}
210		};
211	})( $.fn.removeData );
212}
213
214// deprecated
215$.ui.ie = !!/msie [\w.]+/.exec( navigator.userAgent.toLowerCase() );
216
217$.fn.extend({
218	focus: (function( orig ) {
219		return function( delay, fn ) {
220			return typeof delay === "number" ?
221				this.each(function() {
222					var elem = this;
223					setTimeout(function() {
224						$( elem ).focus();
225						if ( fn ) {
226							fn.call( elem );
227						}
228					}, delay );
229				}) :
230				orig.apply( this, arguments );
231		};
232	})( $.fn.focus ),
233
234	disableSelection: (function() {
235		var eventType = "onselectstart" in document.createElement( "div" ) ?
236			"selectstart" :
237			"mousedown";
238
239		return function() {
240			return this.bind( eventType + ".ui-disableSelection", function( event ) {
241				event.preventDefault();
242			});
243		};
244	})(),
245
246	enableSelection: function() {
247		return this.unbind( ".ui-disableSelection" );
248	},
249
250	zIndex: function( zIndex ) {
251		if ( zIndex !== undefined ) {
252			return this.css( "zIndex", zIndex );
253		}
254
255		if ( this.length ) {
256			var elem = $( this[ 0 ] ), position, value;
257			while ( elem.length && elem[ 0 ] !== document ) {
258				// Ignore z-index if position is set to a value where z-index is ignored by the browser
259				// This makes behavior of this function consistent across browsers
260				// WebKit always returns auto if the element is positioned
261				position = elem.css( "position" );
262				if ( position === "absolute" || position === "relative" || position === "fixed" ) {
263					// IE returns 0 when zIndex is not specified
264					// other browsers return a string
265					// we ignore the case of nested elements with an explicit value of 0
266					// <div style="z-index: -10;"><div style="z-index: 0;"></div></div>
267					value = parseInt( elem.css( "zIndex" ), 10 );
268					if ( !isNaN( value ) && value !== 0 ) {
269						return value;
270					}
271				}
272				elem = elem.parent();
273			}
274		}
275
276		return 0;
277	}
278});
279
280// $.ui.plugin is deprecated. Use $.widget() extensions instead.
281$.ui.plugin = {
282	add: function( module, option, set ) {
283		var i,
284			proto = $.ui[ module ].prototype;
285		for ( i in set ) {
286			proto.plugins[ i ] = proto.plugins[ i ] || [];
287			proto.plugins[ i ].push( [ option, set[ i ] ] );
288		}
289	},
290	call: function( instance, name, args, allowDisconnected ) {
291		var i,
292			set = instance.plugins[ name ];
293
294		if ( !set ) {
295			return;
296		}
297
298		if ( !allowDisconnected && ( !instance.element[ 0 ].parentNode || instance.element[ 0 ].parentNode.nodeType === 11 ) ) {
299			return;
300		}
301
302		for ( i = 0; i < set.length; i++ ) {
303			if ( instance.options[ set[ i ][ 0 ] ] ) {
304				set[ i ][ 1 ].apply( instance.element, args );
305			}
306		}
307	}
308};
309
310
311/*!
312 * jQuery UI Widget 1.11.3
313 * http://jqueryui.com
314 *
315 * Copyright jQuery Foundation and other contributors
316 * Released under the MIT license.
317 * http://jquery.org/license
318 *
319 * http://api.jqueryui.com/jQuery.widget/
320 */
321
322
323var widget_uuid = 0,
324	widget_slice = Array.prototype.slice;
325
326$.cleanData = (function( orig ) {
327	return function( elems ) {
328		var events, elem, i;
329		for ( i = 0; (elem = elems[i]) != null; i++ ) {
330			try {
331
332				// Only trigger remove when necessary to save time
333				events = $._data( elem, "events" );
334				if ( events && events.remove ) {
335					$( elem ).triggerHandler( "remove" );
336				}
337
338			// http://bugs.jquery.com/ticket/8235
339			} catch ( e ) {}
340		}
341		orig( elems );
342	};
343})( $.cleanData );
344
345$.widget = function( name, base, prototype ) {
346	var fullName, existingConstructor, constructor, basePrototype,
347		// proxiedPrototype allows the provided prototype to remain unmodified
348		// so that it can be used as a mixin for multiple widgets (#8876)
349		proxiedPrototype = {},
350		namespace = name.split( "." )[ 0 ];
351
352	name = name.split( "." )[ 1 ];
353	fullName = namespace + "-" + name;
354
355	if ( !prototype ) {
356		prototype = base;
357		base = $.Widget;
358	}
359
360	// create selector for plugin
361	$.expr[ ":" ][ fullName.toLowerCase() ] = function( elem ) {
362		return !!$.data( elem, fullName );
363	};
364
365	$[ namespace ] = $[ namespace ] || {};
366	existingConstructor = $[ namespace ][ name ];
367	constructor = $[ namespace ][ name ] = function( options, element ) {
368		// allow instantiation without "new" keyword
369		if ( !this._createWidget ) {
370			return new constructor( options, element );
371		}
372
373		// allow instantiation without initializing for simple inheritance
374		// must use "new" keyword (the code above always passes args)
375		if ( arguments.length ) {
376			this._createWidget( options, element );
377		}
378	};
379	// extend with the existing constructor to carry over any static properties
380	$.extend( constructor, existingConstructor, {
381		version: prototype.version,
382		// copy the object used to create the prototype in case we need to
383		// redefine the widget later
384		_proto: $.extend( {}, prototype ),
385		// track widgets that inherit from this widget in case this widget is
386		// redefined after a widget inherits from it
387		_childConstructors: []
388	});
389
390	basePrototype = new base();
391	// we need to make the options hash a property directly on the new instance
392	// otherwise we'll modify the options hash on the prototype that we're
393	// inheriting from
394	basePrototype.options = $.widget.extend( {}, basePrototype.options );
395	$.each( prototype, function( prop, value ) {
396		if ( !$.isFunction( value ) ) {
397			proxiedPrototype[ prop ] = value;
398			return;
399		}
400		proxiedPrototype[ prop ] = (function() {
401			var _super = function() {
402					return base.prototype[ prop ].apply( this, arguments );
403				},
404				_superApply = function( args ) {
405					return base.prototype[ prop ].apply( this, args );
406				};
407			return function() {
408				var __super = this._super,
409					__superApply = this._superApply,
410					returnValue;
411
412				this._super = _super;
413				this._superApply = _superApply;
414
vendor: 16,374 bytes, lines 415-975
415				returnValue = value.apply( this, arguments );
416
417				this._super = __super;
418				this._superApply = __superApply;
419
420				return returnValue;
421			};
422		})();
423	});
424	constructor.prototype = $.widget.extend( basePrototype, {
425		// TODO: remove support for widgetEventPrefix
426		// always use the name + a colon as the prefix, e.g., draggable:start
427		// don't prefix for widgets that aren't DOM-based
428		widgetEventPrefix: existingConstructor ? (basePrototype.widgetEventPrefix || name) : name
429	}, proxiedPrototype, {
430		constructor: constructor,
431		namespace: namespace,
432		widgetName: name,
433		widgetFullName: fullName
434	});
435
436	// If this widget is being redefined then we need to find all widgets that
437	// are inheriting from it and redefine all of them so that they inherit from
438	// the new version of this widget. We're essentially trying to replace one
439	// level in the prototype chain.
440	if ( existingConstructor ) {
441		$.each( existingConstructor._childConstructors, function( i, child ) {
442			var childPrototype = child.prototype;
443
444			// redefine the child widget using the same prototype that was
445			// originally used, but inherit from the new version of the base
446			$.widget( childPrototype.namespace + "." + childPrototype.widgetName, constructor, child._proto );
447		});
448		// remove the list of existing child constructors from the old constructor
449		// so the old child constructors can be garbage collected
450		delete existingConstructor._childConstructors;
451	} else {
452		base._childConstructors.push( constructor );
453	}
454
455	$.widget.bridge( name, constructor );
456
457	return constructor;
458};
459
460$.widget.extend = function( target ) {
461	var input = widget_slice.call( arguments, 1 ),
462		inputIndex = 0,
463		inputLength = input.length,
464		key,
465		value;
466	for ( ; inputIndex < inputLength; inputIndex++ ) {
467		for ( key in input[ inputIndex ] ) {
468			value = input[ inputIndex ][ key ];
469			if ( input[ inputIndex ].hasOwnProperty( key ) && value !== undefined ) {
470				// Clone objects
471				if ( $.isPlainObject( value ) ) {
472					target[ key ] = $.isPlainObject( target[ key ] ) ?
473						$.widget.extend( {}, target[ key ], value ) :
474						// Don't extend strings, arrays, etc. with objects
475						$.widget.extend( {}, value );
476				// Copy everything else by reference
477				} else {
478					target[ key ] = value;
479				}
480			}
481		}
482	}
483	return target;
484};
485
486$.widget.bridge = function( name, object ) {
487	var fullName = object.prototype.widgetFullName || name;
488	$.fn[ name ] = function( options ) {
489		var isMethodCall = typeof options === "string",
490			args = widget_slice.call( arguments, 1 ),
491			returnValue = this;
492
493		if ( isMethodCall ) {
494			this.each(function() {
495				var methodValue,
496					instance = $.data( this, fullName );
497				if ( options === "instance" ) {
498					returnValue = instance;
499					return false;
500				}
501				if ( !instance ) {
502					return $.error( "cannot call methods on " + name + " prior to initialization; " +
503						"attempted to call method '" + options + "'" );
504				}
505				if ( !$.isFunction( instance[options] ) || options.charAt( 0 ) === "_" ) {
506					return $.error( "no such method '" + options + "' for " + name + " widget instance" );
507				}
508				methodValue = instance[ options ].apply( instance, args );
509				if ( methodValue !== instance && methodValue !== undefined ) {
510					returnValue = methodValue && methodValue.jquery ?
511						returnValue.pushStack( methodValue.get() ) :
512						methodValue;
513					return false;
514				}
515			});
516		} else {
517
518			// Allow multiple hashes to be passed on init
519			if ( args.length ) {
520				options = $.widget.extend.apply( null, [ options ].concat(args) );
521			}
522
523			this.each(function() {
524				var instance = $.data( this, fullName );
525				if ( instance ) {
526					instance.option( options || {} );
527					if ( instance._init ) {
528						instance._init();
529					}
530				} else {
531					$.data( this, fullName, new object( options, this ) );
532				}
533			});
534		}
535
536		return returnValue;
537	};
538};
539
540$.Widget = function( /* options, element */ ) {};
541$.Widget._childConstructors = [];
542
543$.Widget.prototype = {
544	widgetName: "widget",
545	widgetEventPrefix: "",
546	defaultElement: "<div>",
547	options: {
548		disabled: false,
549
550		// callbacks
551		create: null
552	},
553	_createWidget: function( options, element ) {
554		element = $( element || this.defaultElement || this )[ 0 ];
555		this.element = $( element );
556		this.uuid = widget_uuid++;
557		this.eventNamespace = "." + this.widgetName + this.uuid;
558
559		this.bindings = $();
560		this.hoverable = $();
561		this.focusable = $();
562
563		if ( element !== this ) {
564			$.data( element, this.widgetFullName, this );
565			this._on( true, this.element, {
566				remove: function( event ) {
567					if ( event.target === element ) {
568						this.destroy();
569					}
570				}
571			});
572			this.document = $( element.style ?
573				// element within the document
574				element.ownerDocument :
575				// element is window or document
576				element.document || element );
577			this.window = $( this.document[0].defaultView || this.document[0].parentWindow );
578		}
579
580		this.options = $.widget.extend( {},
581			this.options,
582			this._getCreateOptions(),
583			options );
584
585		this._create();
586		this._trigger( "create", null, this._getCreateEventData() );
587		this._init();
588	},
589	_getCreateOptions: $.noop,
590	_getCreateEventData: $.noop,
591	_create: $.noop,
592	_init: $.noop,
593
594	destroy: function() {
595		this._destroy();
596		// we can probably remove the unbind calls in 2.0
597		// all event bindings should go through this._on()
598		this.element
599			.unbind( this.eventNamespace )
600			.removeData( this.widgetFullName )
601			// support: jquery <1.6.3
602			// http://bugs.jquery.com/ticket/9413
603			.removeData( $.camelCase( this.widgetFullName ) );
604		this.widget()
605			.unbind( this.eventNamespace )
606			.removeAttr( "aria-disabled" )
607			.removeClass(
608				this.widgetFullName + "-disabled " +
609				"ui-state-disabled" );
610
611		// clean up events and states
612		this.bindings.unbind( this.eventNamespace );
613		this.hoverable.removeClass( "ui-state-hover" );
614		this.focusable.removeClass( "ui-state-focus" );
615	},
616	_destroy: $.noop,
617
618	widget: function() {
619		return this.element;
620	},
621
622	option: function( key, value ) {
623		var options = key,
624			parts,
625			curOption,
626			i;
627
628		if ( arguments.length === 0 ) {
629			// don't return a reference to the internal hash
630			return $.widget.extend( {}, this.options );
631		}
632
633		if ( typeof key === "string" ) {
634			// handle nested keys, e.g., "foo.bar" => { foo: { bar: ___ } }
635			options = {};
636			parts = key.split( "." );
637			key = parts.shift();
638			if ( parts.length ) {
639				curOption = options[ key ] = $.widget.extend( {}, this.options[ key ] );
640				for ( i = 0; i < parts.length - 1; i++ ) {
641					curOption[ parts[ i ] ] = curOption[ parts[ i ] ] || {};
642					curOption = curOption[ parts[ i ] ];
643				}
644				key = parts.pop();
645				if ( arguments.length === 1 ) {
646					return curOption[ key ] === undefined ? null : curOption[ key ];
647				}
648				curOption[ key ] = value;
649			} else {
650				if ( arguments.length === 1 ) {
651					return this.options[ key ] === undefined ? null : this.options[ key ];
652				}
653				options[ key ] = value;
654			}
655		}
656
657		this._setOptions( options );
658
659		return this;
660	},
661	_setOptions: function( options ) {
662		var key;
663
664		for ( key in options ) {
665			this._setOption( key, options[ key ] );
666		}
667
668		return this;
669	},
670	_setOption: function( key, value ) {
671		this.options[ key ] = value;
672
673		if ( key === "disabled" ) {
674			this.widget()
675				.toggleClass( this.widgetFullName + "-disabled", !!value );
676
677			// If the widget is becoming disabled, then nothing is interactive
678			if ( value ) {
679				this.hoverable.removeClass( "ui-state-hover" );
680				this.focusable.removeClass( "ui-state-focus" );
681			}
682		}
683
684		return this;
685	},
686
687	enable: function() {
688		return this._setOptions({ disabled: false });
689	},
690	disable: function() {
691		return this._setOptions({ disabled: true });
692	},
693
694	_on: function( suppressDisabledCheck, element, handlers ) {
695		var delegateElement,
696			instance = this;
697
698		// no suppressDisabledCheck flag, shuffle arguments
699		if ( typeof suppressDisabledCheck !== "boolean" ) {
700			handlers = element;
701			element = suppressDisabledCheck;
702			suppressDisabledCheck = false;
703		}
704
705		// no element argument, shuffle and use this.element
706		if ( !handlers ) {
707			handlers = element;
708			element = this.element;
709			delegateElement = this.widget();
710		} else {
711			element = delegateElement = $( element );
712			this.bindings = this.bindings.add( element );
713		}
714
715		$.each( handlers, function( event, handler ) {
716			function handlerProxy() {
717				// allow widgets to customize the disabled handling
718				// - disabled as an array instead of boolean
719				// - disabled class as method for disabling individual parts
720				if ( !suppressDisabledCheck &&
721						( instance.options.disabled === true ||
722							$( this ).hasClass( "ui-state-disabled" ) ) ) {
723					return;
724				}
725				return ( typeof handler === "string" ? instance[ handler ] : handler )
726					.apply( instance, arguments );
727			}
728
729			// copy the guid so direct unbinding works
730			if ( typeof handler !== "string" ) {
731				handlerProxy.guid = handler.guid =
732					handler.guid || handlerProxy.guid || $.guid++;
733			}
734
735			var match = event.match( /^([\w:-]*)\s*(.*)$/ ),
736				eventName = match[1] + instance.eventNamespace,
737				selector = match[2];
738			if ( selector ) {
739				delegateElement.delegate( selector, eventName, handlerProxy );
740			} else {
741				element.bind( eventName, handlerProxy );
742			}
743		});
744	},
745
746	_off: function( element, eventName ) {
747		eventName = (eventName || "").split( " " ).join( this.eventNamespace + " " ) +
748			this.eventNamespace;
749		element.unbind( eventName ).undelegate( eventName );
750
751		// Clear the stack to avoid memory leaks (#10056)
752		this.bindings = $( this.bindings.not( element ).get() );
753		this.focusable = $( this.focusable.not( element ).get() );
754		this.hoverable = $( this.hoverable.not( element ).get() );
755	},
756
757	_delay: function( handler, delay ) {
758		function handlerProxy() {
759			return ( typeof handler === "string" ? instance[ handler ] : handler )
760				.apply( instance, arguments );
761		}
762		var instance = this;
763		return setTimeout( handlerProxy, delay || 0 );
764	},
765
766	_hoverable: function( element ) {
767		this.hoverable = this.hoverable.add( element );
768		this._on( element, {
769			mouseenter: function( event ) {
770				$( event.currentTarget ).addClass( "ui-state-hover" );
771			},
772			mouseleave: function( event ) {
773				$( event.currentTarget ).removeClass( "ui-state-hover" );
774			}
775		});
776	},
777
778	_focusable: function( element ) {
779		this.focusable = this.focusable.add( element );
780		this._on( element, {
781			focusin: function( event ) {
782				$( event.currentTarget ).addClass( "ui-state-focus" );
783			},
784			focusout: function( event ) {
785				$( event.currentTarget ).removeClass( "ui-state-focus" );
786			}
787		});
788	},
789
790	_trigger: function( type, event, data ) {
791		var prop, orig,
792			callback = this.options[ type ];
793
794		data = data || {};
795		event = $.Event( event );
796		event.type = ( type === this.widgetEventPrefix ?
797			type :
798			this.widgetEventPrefix + type ).toLowerCase();
799		// the original event may come from any element
800		// so we need to reset the target on the new event
801		event.target = this.element[ 0 ];
802
803		// copy original event properties over to the new event
804		orig = event.originalEvent;
805		if ( orig ) {
806			for ( prop in orig ) {
807				if ( !( prop in event ) ) {
808					event[ prop ] = orig[ prop ];
809				}
810			}
811		}
812
813		this.element.trigger( event, data );
814		return !( $.isFunction( callback ) &&
815			callback.apply( this.element[0], [ event ].concat( data ) ) === false ||
816			event.isDefaultPrevented() );
817	}
818};
819
820$.each( { show: "fadeIn", hide: "fadeOut" }, function( method, defaultEffect ) {
821	$.Widget.prototype[ "_" + method ] = function( element, options, callback ) {
822		if ( typeof options === "string" ) {
823			options = { effect: options };
824		}
825		var hasOptions,
826			effectName = !options ?
827				method :
828				options === true || typeof options === "number" ?
829					defaultEffect :
830					options.effect || defaultEffect;
831		options = options || {};
832		if ( typeof options === "number" ) {
833			options = { duration: options };
834		}
835		hasOptions = !$.isEmptyObject( options );
836		options.complete = callback;
837		if ( options.delay ) {
838			element.delay( options.delay );
839		}
840		if ( hasOptions && $.effects && $.effects.effect[ effectName ] ) {
841			element[ method ]( options );
842		} else if ( effectName !== method && element[ effectName ] ) {
843			element[ effectName ]( options.duration, options.easing, callback );
844		} else {
845			element.queue(function( next ) {
846				$( this )[ method ]();
847				if ( callback ) {
848					callback.call( element[ 0 ] );
849				}
850				next();
851			});
852		}
853	};
854});
855
856var widget = $.widget;
857
858
859/*!
860 * jQuery UI Mouse 1.11.3
861 * http://jqueryui.com
862 *
863 * Copyright jQuery Foundation and other contributors
864 * Released under the MIT license.
865 * http://jquery.org/license
866 *
867 * http://api.jqueryui.com/mouse/
868 */
869
870
871var mouseHandled = false;
872$( document ).mouseup( function() {
873	mouseHandled = false;
874});
875
876var mouse = $.widget("ui.mouse", {
877	version: "1.11.3",
878	options: {
879		cancel: "input,textarea,button,select,option",
880		distance: 1,
881		delay: 0
882	},
883	_mouseInit: function() {
884		var that = this;
885
886		this.element
887			.bind("mousedown." + this.widgetName, function(event) {
888				return that._mouseDown(event);
889			})
890			.bind("click." + this.widgetName, function(event) {
891				if (true === $.data(event.target, that.widgetName + ".preventClickEvent")) {
892					$.removeData(event.target, that.widgetName + ".preventClickEvent");
893					event.stopImmediatePropagation();
894					return false;
895				}
896			});
897
898		this.started = false;
899	},
900
901	// TODO: make sure destroying one instance of mouse doesn't mess with
902	// other instances of mouse
903	_mouseDestroy: function() {
904		this.element.unbind("." + this.widgetName);
905		if ( this._mouseMoveDelegate ) {
906			this.document
907				.unbind("mousemove." + this.widgetName, this._mouseMoveDelegate)
908				.unbind("mouseup." + this.widgetName, this._mouseUpDelegate);
909		}
910	},
911
912	_mouseDown: function(event) {
913		// don't let more than one widget handle mouseStart
914		if ( mouseHandled ) {
915			return;
916		}
917
918		this._mouseMoved = false;
919
920		// we may have missed mouseup (out of window)
921		(this._mouseStarted && this._mouseUp(event));
922
923		this._mouseDownEvent = event;
924
925		var that = this,
926			btnIsLeft = (event.which === 1),
927			// event.target.nodeName works around a bug in IE 8 with
928			// disabled inputs (#7620)
929			elIsCancel = (typeof this.options.cancel === "string" && event.target.nodeName ? $(event.target).closest(this.options.cancel).length : false);
930		if (!btnIsLeft || elIsCancel || !this._mouseCapture(event)) {
931			return true;
932		}
933
934		this.mouseDelayMet = !this.options.delay;
935		if (!this.mouseDelayMet) {
936			this._mouseDelayTimer = setTimeout(function() {
937				that.mouseDelayMet = true;
938			}, this.options.delay);
939		}
940
941		if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
942			this._mouseStarted = (this._mouseStart(event) !== false);
943			if (!this._mouseStarted) {
944				event.preventDefault();
945				return true;
946			}
947		}
948
949		// Click event may never have fired (Gecko & Opera)
950		if (true === $.data(event.target, this.widgetName + ".preventClickEvent")) {
951			$.removeData(event.target, this.widgetName + ".preventClickEvent");
952		}
953
954		// these delegates are required to keep context
955		this._mouseMoveDelegate = function(event) {
956			return that._mouseMove(event);
957		};
958		this._mouseUpDelegate = function(event) {
959			return that._mouseUp(event);
960		};
961
962		this.document
963			.bind( "mousemove." + this.widgetName, this._mouseMoveDelegate )
964			.bind( "mouseup." + this.widgetName, this._mouseUpDelegate );
965
966		event.preventDefault();
967
968		mouseHandled = true;
969		return true;
970	},
971
972	_mouseMove: function(event) {
973		// Only check for mouseups outside the document if you've moved inside the document
974		// at least once. This prevents the firing of mouseup in the case of IE<9, which will
975		// fire a mousemove event if content is placed under the cursor. See #7778
vendor: 5,661 bytes, lines 976-1206
976		// Support: IE <9
977		if ( this._mouseMoved ) {
978			// IE mouseup check - mouseup happened when mouse was out of window
979			if ($.ui.ie && ( !document.documentMode || document.documentMode < 9 ) && !event.button) {
980				return this._mouseUp(event);
981
982			// Iframe mouseup check - mouseup occurred in another document
983			} else if ( !event.which ) {
984				return this._mouseUp( event );
985			}
986		}
987
988		if ( event.which || event.button ) {
989			this._mouseMoved = true;
990		}
991
992		if (this._mouseStarted) {
993			this._mouseDrag(event);
994			return event.preventDefault();
995		}
996
997		if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
998			this._mouseStarted =
999				(this._mouseStart(this._mouseDownEvent, event) !== false);
1000			(this._mouseStarted ? this._mouseDrag(event) : this._mouseUp(event));
1001		}
1002
1003		return !this._mouseStarted;
1004	},
1005
1006	_mouseUp: function(event) {
1007		this.document
1008			.unbind( "mousemove." + this.widgetName, this._mouseMoveDelegate )
1009			.unbind( "mouseup." + this.widgetName, this._mouseUpDelegate );
1010
1011		if (this._mouseStarted) {
1012			this._mouseStarted = false;
1013
1014			if (event.target === this._mouseDownEvent.target) {
1015				$.data(event.target, this.widgetName + ".preventClickEvent", true);
1016			}
1017
1018			this._mouseStop(event);
1019		}
1020
1021		mouseHandled = false;
1022		return false;
1023	},
1024
1025	_mouseDistanceMet: function(event) {
1026		return (Math.max(
1027				Math.abs(this._mouseDownEvent.pageX - event.pageX),
1028				Math.abs(this._mouseDownEvent.pageY - event.pageY)
1029			) >= this.options.distance
1030		);
1031	},
1032
1033	_mouseDelayMet: function(/* event */) {
1034		return this.mouseDelayMet;
1035	},
1036
1037	// These are placeholder methods, to be overriden by extending plugin
1038	_mouseStart: function(/* event */) {},
1039	_mouseDrag: function(/* event */) {},
1040	_mouseStop: function(/* event */) {},
1041	_mouseCapture: function(/* event */) { return true; }
1042});
1043
1044
1045/*!
1046 * jQuery UI Sortable 1.11.3
1047 * http://jqueryui.com
1048 *
1049 * Copyright jQuery Foundation and other contributors
1050 * Released under the MIT license.
1051 * http://jquery.org/license
1052 *
1053 * http://api.jqueryui.com/sortable/
1054 */
1055
1056
1057var sortable = $.widget("ui.sortable", $.ui.mouse, {
1058	version: "1.11.3",
1059	widgetEventPrefix: "sort",
1060	ready: false,
1061	options: {
1062		appendTo: "parent",
1063		axis: false,
1064		connectWith: false,
1065		containment: false,
1066		cursor: "auto",
1067		cursorAt: false,
1068		dropOnEmpty: true,
1069		forcePlaceholderSize: false,
1070		forceHelperSize: false,
1071		grid: false,
1072		handle: false,
1073		helper: "original",
1074		items: "> *",
1075		opacity: false,
1076		placeholder: false,
1077		revert: false,
1078		scroll: true,
1079		scrollSensitivity: 20,
1080		scrollSpeed: 20,
1081		scope: "default",
1082		tolerance: "intersect",
1083		zIndex: 1000,
1084
1085		// callbacks
1086		activate: null,
1087		beforeStop: null,
1088		change: null,
1089		deactivate: null,
1090		out: null,
1091		over: null,
1092		receive: null,
1093		remove: null,
1094		sort: null,
1095		start: null,
1096		stop: null,
1097		update: null
1098	},
1099
1100	_isOverAxis: function( x, reference, size ) {
1101		return ( x >= reference ) && ( x < ( reference + size ) );
1102	},
1103
1104	_isFloating: function( item ) {
1105		return (/left|right/).test(item.css("float")) || (/inline|table-cell/).test(item.css("display"));
1106	},
1107
1108	_create: function() {
1109
1110		var o = this.options;
1111		this.containerCache = {};
1112		this.element.addClass("ui-sortable");
1113
1114		//Get the items
1115		this.refresh();
1116
1117		//Let's determine if the items are being displayed horizontally
1118		this.floating = this.items.length ? o.axis === "x" || this._isFloating(this.items[0].item) : false;
1119
1120		//Let's determine the parent's offset
1121		this.offset = this.element.offset();
1122
1123		//Initialize mouse events for interaction
1124		this._mouseInit();
1125
1126		this._setHandleClassName();
1127
1128		//We're ready to go
1129		this.ready = true;
1130
1131	},
1132
1133	_setOption: function( key, value ) {
1134		this._super( key, value );
1135
1136		if ( key === "handle" ) {
1137			this._setHandleClassName();
1138		}
1139	},
1140
1141	_setHandleClassName: function() {
1142		this.element.find( ".ui-sortable-handle" ).removeClass( "ui-sortable-handle" );
1143		$.each( this.items, function() {
1144			( this.instance.options.handle ?
1145				this.item.find( this.instance.options.handle ) : this.item )
1146				.addClass( "ui-sortable-handle" );
1147		});
1148	},
1149
1150	_destroy: function() {
1151		this.element
1152			.removeClass( "ui-sortable ui-sortable-disabled" )
1153			.find( ".ui-sortable-handle" )
1154				.removeClass( "ui-sortable-handle" );
1155		this._mouseDestroy();
1156
1157		for ( var i = this.items.length - 1; i >= 0; i-- ) {
1158			this.items[i].item.removeData(this.widgetName + "-item");
1159		}
1160
1161		return this;
1162	},
1163
1164	_mouseCapture: function(event, overrideHandle) {
1165		var currentItem = null,
1166			validHandle = false,
1167			that = this;
1168
1169		if (this.reverting) {
1170			return false;
1171		}
1172
1173		if(this.options.disabled || this.options.type === "static") {
1174			return false;
1175		}
1176
1177		//We have to refresh the items data once first
1178		this._refreshItems(event);
1179
1180		//Find out if the clicked node (or one of its parents) is a actual item in this.items
1181		$(event.target).parents().each(function() {
1182			if($.data(this, that.widgetName + "-item") === that) {
1183				currentItem = $(this);
1184				return false;
1185			}
1186		});
1187		if($.data(event.target, that.widgetName + "-item") === that) {
1188			currentItem = $(event.target);
1189		}
1190
1191		if(!currentItem) {
1192			return false;
1193		}
1194		if(this.options.handle && !overrideHandle) {
1195			$(this.options.handle, currentItem).find("*").addBack().each(function() {
1196				if(this === event.target) {
1197					validHandle = true;
1198				}
1199			});
1200			if(!validHandle) {
1201				return false;
1202			}
1203		}
1204
1205		this.currentItem = currentItem;
1206		this._removeCurrentsFromItems();
vendor: 9,653 bytes, lines 1207-1505
1207		return true;
1208
1209	},
1210
1211	_mouseStart: function(event, overrideHandle, noActivation) {
1212
1213		var i, body,
1214			o = this.options;
1215
1216		this.currentContainer = this;
1217
1218		//We only need to call refreshPositions, because the refreshItems call has been moved to mouseCapture
1219		this.refreshPositions();
1220
1221		//Create and append the visible helper
1222		this.helper = this._createHelper(event);
1223
1224		//Cache the helper size
1225		this._cacheHelperProportions();
1226
1227		/*
1228		 * - Position generation -
1229		 * This block generates everything position related - it's the core of draggables.
1230		 */
1231
1232		//Cache the margins of the original element
1233		this._cacheMargins();
1234
1235		//Get the next scrolling parent
1236		this.scrollParent = this.helper.scrollParent();
1237
1238		//The element's absolute position on the page minus margins
1239		this.offset = this.currentItem.offset();
1240		this.offset = {
1241			top: this.offset.top - this.margins.top,
1242			left: this.offset.left - this.margins.left
1243		};
1244
1245		$.extend(this.offset, {
1246			click: { //Where the click happened, relative to the element
1247				left: event.pageX - this.offset.left,
1248				top: event.pageY - this.offset.top
1249			},
1250			parent: this._getParentOffset(),
1251			relative: this._getRelativeOffset() //This is a relative to absolute position minus the actual position calculation - only used for relative positioned helper
1252		});
1253
1254		// Only after we got the offset, we can change the helper's position to absolute
1255		// TODO: Still need to figure out a way to make relative sorting possible
1256		this.helper.css("position", "absolute");
1257		this.cssPosition = this.helper.css("position");
1258
1259		//Generate the original position
1260		this.originalPosition = this._generatePosition(event);
1261		this.originalPageX = event.pageX;
1262		this.originalPageY = event.pageY;
1263
1264		//Adjust the mouse offset relative to the helper if "cursorAt" is supplied
1265		(o.cursorAt && this._adjustOffsetFromHelper(o.cursorAt));
1266
1267		//Cache the former DOM position
1268		this.domPosition = { prev: this.currentItem.prev()[0], parent: this.currentItem.parent()[0] };
1269
1270		//If the helper is not the original, hide the original so it's not playing any role during the drag, won't cause anything bad this way
1271		if(this.helper[0] !== this.currentItem[0]) {
1272			this.currentItem.hide();
1273		}
1274
1275		//Create the placeholder
1276		this._createPlaceholder();
1277
1278		//Set a containment if given in the options
1279		if(o.containment) {
1280			this._setContainment();
1281		}
1282
1283		if( o.cursor && o.cursor !== "auto" ) { // cursor option
1284			body = this.document.find( "body" );
1285
1286			// support: IE
1287			this.storedCursor = body.css( "cursor" );
1288			body.css( "cursor", o.cursor );
1289
1290			this.storedStylesheet = $( "<style>*{ cursor: "+o.cursor+" !important; }</style>" ).appendTo( body );
1291		}
1292
1293		if(o.opacity) { // opacity option
1294			if (this.helper.css("opacity")) {
1295				this._storedOpacity = this.helper.css("opacity");
1296			}
1297			this.helper.css("opacity", o.opacity);
1298		}
1299
1300		if(o.zIndex) { // zIndex option
1301			if (this.helper.css("zIndex")) {
1302				this._storedZIndex = this.helper.css("zIndex");
1303			}
1304			this.helper.css("zIndex", o.zIndex);
1305		}
1306
1307		//Prepare scrolling
1308		if(this.scrollParent[0] !== this.document[0] && this.scrollParent[0].tagName !== "HTML") {
1309			this.overflowOffset = this.scrollParent.offset();
1310		}
1311
1312		//Call callbacks
1313		this._trigger("start", event, this._uiHash());
1314
1315		//Recache the helper size
1316		if(!this._preserveHelperProportions) {
1317			this._cacheHelperProportions();
1318		}
1319
1320
1321		//Post "activate" events to possible containers
1322		if( !noActivation ) {
1323			for ( i = this.containers.length - 1; i >= 0; i-- ) {
1324				this.containers[ i ]._trigger( "activate", event, this._uiHash( this ) );
1325			}
1326		}
1327
1328		//Prepare possible droppables
1329		if($.ui.ddmanager) {
1330			$.ui.ddmanager.current = this;
1331		}
1332
1333		if ($.ui.ddmanager && !o.dropBehaviour) {
1334			$.ui.ddmanager.prepareOffsets(this, event);
1335		}
1336
1337		this.dragging = true;
1338
1339		this.helper.addClass("ui-sortable-helper");
1340		this._mouseDrag(event); //Execute the drag once - this causes the helper not to be visible before getting its correct position
1341		return true;
1342
1343	},
1344
1345	_mouseDrag: function(event) {
1346		var i, item, itemElement, intersection,
1347			o = this.options,
1348			scrolled = false;
1349
1350		//Compute the helpers position
1351		this.position = this._generatePosition(event);
1352		this.positionAbs = this._convertPositionTo("absolute");
1353
1354		if (!this.lastPositionAbs) {
1355			this.lastPositionAbs = this.positionAbs;
1356		}
1357
1358		//Do scrolling
1359		if(this.options.scroll) {
1360			if(this.scrollParent[0] !== this.document[0] && this.scrollParent[0].tagName !== "HTML") {
1361
1362				if((this.overflowOffset.top + this.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity) {
1363					this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop + o.scrollSpeed;
1364				} else if(event.pageY - this.overflowOffset.top < o.scrollSensitivity) {
1365					this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop - o.scrollSpeed;
1366				}
1367
1368				if((this.overflowOffset.left + this.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity) {
1369					this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft + o.scrollSpeed;
1370				} else if(event.pageX - this.overflowOffset.left < o.scrollSensitivity) {
1371					this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft - o.scrollSpeed;
1372				}
1373
1374			} else {
1375
1376				if(event.pageY - this.document.scrollTop() < o.scrollSensitivity) {
1377					scrolled = this.document.scrollTop(this.document.scrollTop() - o.scrollSpeed);
1378				} else if(this.window.height() - (event.pageY - this.document.scrollTop()) < o.scrollSensitivity) {
1379					scrolled = this.document.scrollTop(this.document.scrollTop() + o.scrollSpeed);
1380				}
1381
1382				if(event.pageX - this.document.scrollLeft() < o.scrollSensitivity) {
1383					scrolled = this.document.scrollLeft(this.document.scrollLeft() - o.scrollSpeed);
1384				} else if(this.window.width() - (event.pageX - this.document.scrollLeft()) < o.scrollSensitivity) {
1385					scrolled = this.document.scrollLeft(this.document.scrollLeft() + o.scrollSpeed);
1386				}
1387
1388			}
1389
1390			if(scrolled !== false && $.ui.ddmanager && !o.dropBehaviour) {
1391				$.ui.ddmanager.prepareOffsets(this, event);
1392			}
1393		}
1394
1395		//Regenerate the absolute position used for position checks
1396		this.positionAbs = this._convertPositionTo("absolute");
1397
1398		//Set the helper position
1399		if(!this.options.axis || this.options.axis !== "y") {
1400			this.helper[0].style.left = this.position.left+"px";
1401		}
1402		if(!this.options.axis || this.options.axis !== "x") {
1403			this.helper[0].style.top = this.position.top+"px";
1404		}
1405
1406		//Rearrange
1407		for (i = this.items.length - 1; i >= 0; i--) {
1408
1409			//Cache variables and intersection, continue if no intersection
1410			item = this.items[i];
1411			itemElement = item.item[0];
1412			intersection = this._intersectsWithPointer(item);
1413			if (!intersection) {
1414				continue;
1415			}
1416
1417			// Only put the placeholder inside the current Container, skip all
1418			// items from other containers. This works because when moving
1419			// an item from one container to another the
1420			// currentContainer is switched before the placeholder is moved.
1421			//
1422			// Without this, moving items in "sub-sortables" can cause
1423			// the placeholder to jitter between the outer and inner container.
1424			if (item.instance !== this.currentContainer) {
1425				continue;
1426			}
1427
1428			// cannot intersect with itself
1429			// no useless actions that have been done before
1430			// no action if the item moved is the parent of the item checked
1431			if (itemElement !== this.currentItem[0] &&
1432				this.placeholder[intersection === 1 ? "next" : "prev"]()[0] !== itemElement &&
1433				!$.contains(this.placeholder[0], itemElement) &&
1434				(this.options.type === "semi-dynamic" ? !$.contains(this.element[0], itemElement) : true)
1435			) {
1436
1437				this.direction = intersection === 1 ? "down" : "up";
1438
1439				if (this.options.tolerance === "pointer" || this._intersectsWithSides(item)) {
1440					this._rearrange(event, item);
1441				} else {
1442					break;
1443				}
1444
1445				this._trigger("change", event, this._uiHash());
1446				break;
1447			}
1448		}
1449
1450		//Post events to containers
1451		this._contactContainers(event);
1452
1453		//Interconnect with droppables
1454		if($.ui.ddmanager) {
1455			$.ui.ddmanager.drag(this, event);
1456		}
1457
1458		//Call callbacks
1459		this._trigger("sort", event, this._uiHash());
1460
1461		this.lastPositionAbs = this.positionAbs;
1462		return false;
1463
1464	},
1465
1466	_mouseStop: function(event, noPropagation) {
1467
1468		if(!event) {
1469			return;
1470		}
1471
1472		//If we are using droppables, inform the manager about the drop
1473		if ($.ui.ddmanager && !this.options.dropBehaviour) {
1474			$.ui.ddmanager.drop(this, event);
1475		}
1476
1477		if(this.options.revert) {
1478			var that = this,
1479				cur = this.placeholder.offset(),
1480				axis = this.options.axis,
1481				animation = {};
1482
1483			if ( !axis || axis === "x" ) {
1484				animation.left = cur.left - this.offset.parent.left - this.margins.left + (this.offsetParent[0] === this.document[0].body ? 0 : this.offsetParent[0].scrollLeft);
1485			}
1486			if ( !axis || axis === "y" ) {
1487				animation.top = cur.top - this.offset.parent.top - this.margins.top + (this.offsetParent[0] === this.document[0].body ? 0 : this.offsetParent[0].scrollTop);
1488			}
1489			this.reverting = true;
1490			$(this.helper).animate( animation, parseInt(this.options.revert, 10) || 500, function() {
1491				that._clear(event);
1492			});
1493		} else {
1494			this._clear(event, noPropagation);
1495		}
1496
1497		return false;
1498
1499	},
1500
1501	cancel: function() {
1502
1503		if(this.dragging) {
1504
1505			this._mouseUp({ target: null });
vendor: 5,388 bytes, lines 1506-1668
1506
1507			if(this.options.helper === "original") {
1508				this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper");
1509			} else {
1510				this.currentItem.show();
1511			}
1512
1513			//Post deactivating events to containers
1514			for (var i = this.containers.length - 1; i >= 0; i--){
1515				this.containers[i]._trigger("deactivate", null, this._uiHash(this));
1516				if(this.containers[i].containerCache.over) {
1517					this.containers[i]._trigger("out", null, this._uiHash(this));
1518					this.containers[i].containerCache.over = 0;
1519				}
1520			}
1521
1522		}
1523
1524		if (this.placeholder) {
1525			//$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node!
1526			if(this.placeholder[0].parentNode) {
1527				this.placeholder[0].parentNode.removeChild(this.placeholder[0]);
1528			}
1529			if(this.options.helper !== "original" && this.helper && this.helper[0].parentNode) {
1530				this.helper.remove();
1531			}
1532
1533			$.extend(this, {
1534				helper: null,
1535				dragging: false,
1536				reverting: false,
1537				_noFinalSort: null
1538			});
1539
1540			if(this.domPosition.prev) {
1541				$(this.domPosition.prev).after(this.currentItem);
1542			} else {
1543				$(this.domPosition.parent).prepend(this.currentItem);
1544			}
1545		}
1546
1547		return this;
1548
1549	},
1550
1551	serialize: function(o) {
1552
1553		var items = this._getItemsAsjQuery(o && o.connected),
1554			str = [];
1555		o = o || {};
1556
1557		$(items).each(function() {
1558			var res = ($(o.item || this).attr(o.attribute || "id") || "").match(o.expression || (/(.+)[\-=_](.+)/));
1559			if (res) {
1560				str.push((o.key || res[1]+"[]")+"="+(o.key && o.expression ? res[1] : res[2]));
1561			}
1562		});
1563
1564		if(!str.length && o.key) {
1565			str.push(o.key + "=");
1566		}
1567
1568		return str.join("&");
1569
1570	},
1571
1572	toArray: function(o) {
1573
1574		var items = this._getItemsAsjQuery(o && o.connected),
1575			ret = [];
1576
1577		o = o || {};
1578
1579		items.each(function() { ret.push($(o.item || this).attr(o.attribute || "id") || ""); });
1580		return ret;
1581
1582	},
1583
1584	/* Be careful with the following core functions */
1585	_intersectsWith: function(item) {
1586
1587		var x1 = this.positionAbs.left,
1588			x2 = x1 + this.helperProportions.width,
1589			y1 = this.positionAbs.top,
1590			y2 = y1 + this.helperProportions.height,
1591			l = item.left,
1592			r = l + item.width,
1593			t = item.top,
1594			b = t + item.height,
1595			dyClick = this.offset.click.top,
1596			dxClick = this.offset.click.left,
1597			isOverElementHeight = ( this.options.axis === "x" ) || ( ( y1 + dyClick ) > t && ( y1 + dyClick ) < b ),
1598			isOverElementWidth = ( this.options.axis === "y" ) || ( ( x1 + dxClick ) > l && ( x1 + dxClick ) < r ),
1599			isOverElement = isOverElementHeight && isOverElementWidth;
1600
1601		if ( this.options.tolerance === "pointer" ||
1602			this.options.forcePointerForContainers ||
1603			(this.options.tolerance !== "pointer" && this.helperProportions[this.floating ? "width" : "height"] > item[this.floating ? "width" : "height"])
1604		) {
1605			return isOverElement;
1606		} else {
1607
1608			return (l < x1 + (this.helperProportions.width / 2) && // Right Half
1609				x2 - (this.helperProportions.width / 2) < r && // Left Half
1610				t < y1 + (this.helperProportions.height / 2) && // Bottom Half
1611				y2 - (this.helperProportions.height / 2) < b ); // Top Half
1612
1613		}
1614	},
1615
1616	_intersectsWithPointer: function(item) {
1617
1618		var isOverElementHeight = (this.options.axis === "x") || this._isOverAxis(this.positionAbs.top + this.offset.click.top, item.top, item.height),
1619			isOverElementWidth = (this.options.axis === "y") || this._isOverAxis(this.positionAbs.left + this.offset.click.left, item.left, item.width),
1620			isOverElement = isOverElementHeight && isOverElementWidth,
1621			verticalDirection = this._getDragVerticalDirection(),
1622			horizontalDirection = this._getDragHorizontalDirection();
1623
1624		if (!isOverElement) {
1625			return false;
1626		}
1627
1628		return this.floating ?
1629			( ((horizontalDirection && horizontalDirection === "right") || verticalDirection === "down") ? 2 : 1 )
1630			: ( verticalDirection && (verticalDirection === "down" ? 2 : 1) );
1631
1632	},
1633
1634	_intersectsWithSides: function(item) {
1635
1636		var isOverBottomHalf = this._isOverAxis(this.positionAbs.top + this.offset.click.top, item.top + (item.height/2), item.height),
1637			isOverRightHalf = this._isOverAxis(this.positionAbs.left + this.offset.click.left, item.left + (item.width/2), item.width),
1638			verticalDirection = this._getDragVerticalDirection(),
1639			horizontalDirection = this._getDragHorizontalDirection();
1640
1641		if (this.floating && horizontalDirection) {
1642			return ((horizontalDirection === "right" && isOverRightHalf) || (horizontalDirection === "left" && !isOverRightHalf));
1643		} else {
1644			return verticalDirection && ((verticalDirection === "down" && isOverBottomHalf) || (verticalDirection === "up" && !isOverBottomHalf));
1645		}
1646
1647	},
1648
1649	_getDragVerticalDirection: function() {
1650		var delta = this.positionAbs.top - this.lastPositionAbs.top;
1651		return delta !== 0 && (delta > 0 ? "down" : "up");
1652	},
1653
1654	_getDragHorizontalDirection: function() {
1655		var delta = this.positionAbs.left - this.lastPositionAbs.left;
1656		return delta !== 0 && (delta > 0 ? "right" : "left");
1657	},
1658
1659	refresh: function(event) {
1660		this._refreshItems(event);
1661		this._setHandleClassName();
1662		this.refreshPositions();
1663		return this;
1664	},
1665
1666	_connectWith: function() {
1667		var options = this.options;
1668		return options.connectWith.constructor === String ? [options.connectWith
vendor: 3,816 bytes, lines 1668-1790
1668] : options.connectWith;
1669	},
1670
1671	_getItemsAsjQuery: function(connected) {
1672
1673		var i, j, cur, inst,
1674			items = [],
1675			queries = [],
1676			connectWith = this._connectWith();
1677
1678		if(connectWith && connected) {
1679			for (i = connectWith.length - 1; i >= 0; i--){
1680				cur = $(connectWith[i], this.document[0]);
1681				for ( j = cur.length - 1; j >= 0; j--){
1682					inst = $.data(cur[j], this.widgetFullName);
1683					if(inst && inst !== this && !inst.options.disabled) {
1684						queries.push([$.isFunction(inst.options.items) ? inst.options.items.call(inst.element) : $(inst.options.items, inst.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"), inst]);
1685					}
1686				}
1687			}
1688		}
1689
1690		queries.push([$.isFunction(this.options.items) ? this.options.items.call(this.element, null, { options: this.options, item: this.currentItem }) : $(this.options.items, this.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"), this]);
1691
1692		function addItems() {
1693			items.push( this );
1694		}
1695		for (i = queries.length - 1; i >= 0; i--){
1696			queries[i][0].each( addItems );
1697		}
1698
1699		return $(items);
1700
1701	},
1702
1703	_removeCurrentsFromItems: function() {
1704
1705		var list = this.currentItem.find(":data(" + this.widgetName + "-item)");
1706
1707		this.items = $.grep(this.items, function (item) {
1708			for (var j=0; j < list.length; j++) {
1709				if(list[j] === item.item[0]) {
1710					return false;
1711				}
1712			}
1713			return true;
1714		});
1715
1716	},
1717
1718	_refreshItems: function(event) {
1719
1720		this.items = [];
1721		this.containers = [this];
1722
1723		var i, j, cur, inst, targetData, _queries, item, queriesLength,
1724			items = this.items,
1725			queries = [[$.isFunction(this.options.items) ? this.options.items.call(this.element[0], event, { item: this.currentItem }) : $(this.options.items, this.element), this]],
1726			connectWith = this._connectWith();
1727
1728		if(connectWith && this.ready) { //Shouldn't be run the first time through due to massive slow-down
1729			for (i = connectWith.length - 1; i >= 0; i--){
1730				cur = $(connectWith[i], this.document[0]);
1731				for (j = cur.length - 1; j >= 0; j--){
1732					inst = $.data(cur[j], this.widgetFullName);
1733					if(inst && inst !== this && !inst.options.disabled) {
1734						queries.push([$.isFunction(inst.options.items) ? inst.options.items.call(inst.element[0], event, { item: this.currentItem }) : $(inst.options.items, inst.element), inst]);
1735						this.containers.push(inst);
1736					}
1737				}
1738			}
1739		}
1740
1741		for (i = queries.length - 1; i >= 0; i--) {
1742			targetData = queries[i][1];
1743			_queries = queries[i][0];
1744
1745			for (j=0, queriesLength = _queries.length; j < queriesLength; j++) {
1746				item = $(_queries[j]);
1747
1748				item.data(this.widgetName + "-item", targetData); // Data for target checking (mouse manager)
1749
1750				items.push({
1751					item: item,
1752					instance: targetData,
1753					width: 0, height: 0,
1754					left: 0, top: 0
1755				});
1756			}
1757		}
1758
1759	},
1760
1761	refreshPositions: function(fast) {
1762
1763		//This has to be redone because due to the item being moved out/into the offsetParent, the offsetParent's position will change
1764		if(this.offsetParent && this.helper) {
1765			this.offset.parent = this._getParentOffset();
1766		}
1767
1768		var i, item, t, p;
1769
1770		for (i = this.items.length - 1; i >= 0; i--){
1771			item = this.items[i];
1772
1773			//We ignore calculating positions of all connected containers when we're not over them
1774			if(item.instance !== this.currentContainer && this.currentContainer && item.item[0] !== this.currentItem[0]) {
1775				continue;
1776			}
1777
1778			t = this.options.toleranceElement ? $(this.options.toleranceElement, item.item) : item.item;
1779
1780			if (!fast) {
1781				item.width = t.outerWidth();
1782				item.height = t.outerHeight();
1783			}
1784
1785			p = t.offset();
1786			item.left = p.left;
1787			item.top = p.top;
1788		}
1789
1790		if(this.options.custom && this.options.custom.refreshContainers
vendor: 1,960 bytes, lines 1790-1844
1790) {
1791			this.options.custom.refreshContainers.call(this);
1792		} else {
1793			for (i = this.containers.length - 1; i >= 0; i--){
1794				p = this.containers[i].element.offset();
1795				this.containers[i].containerCache.left = p.left;
1796				this.containers[i].containerCache.top = p.top;
1797				this.containers[i].containerCache.width = this.containers[i].element.outerWidth();
1798				this.containers[i].containerCache.height = this.containers[i].element.outerHeight();
1799			}
1800		}
1801
1802		return this;
1803	},
1804
1805	_createPlaceholder: function(that) {
1806		that = that || this;
1807		var className,
1808			o = that.options;
1809
1810		if(!o.placeholder || o.placeholder.constructor === String) {
1811			className = o.placeholder;
1812			o.placeholder = {
1813				element: function() {
1814
1815					var nodeName = that.currentItem[0].nodeName.toLowerCase(),
1816						element = $( "<" + nodeName + ">", that.document[0] )
1817							.addClass(className || that.currentItem[0].className+" ui-sortable-placeholder")
1818							.removeClass("ui-sortable-helper");
1819
1820					if ( nodeName === "tr" ) {
1821						that.currentItem.children().each(function() {
1822							$( "<td>&#160;</td>", that.document[0] )
1823								.attr( "colspan", $( this ).attr( "colspan" ) || 1 )
1824								.appendTo( element );
1825						});
1826					} else if ( nodeName === "img" ) {
1827						element.attr( "src", that.currentItem.attr( "src" ) );
1828					}
1829
1830					if ( !className ) {
1831						element.css( "visibility", "hidden" );
1832					}
1833
1834					return element;
1835				},
1836				update: function(container, p) {
1837
1838					// 1. If a className is set as 'placeholder option, we don't force sizes - the class is responsible for that
1839					// 2. The option 'forcePlaceholderSize can be enabled to force it even if a class name is specified
1840					if(className && !o.forcePlaceholderSize) {
1841						return;
1842					}
1843
1844					//If the element doesn't have a actual height by itself (without styles coming from a stylesheet), it receives the inline height from the dragged item
vendor: 5,016 bytes, lines 1845-1976
1845					if(!p.height()) { p.height(that.currentItem.innerHeight() - parseInt(that.currentItem.css("paddingTop")||0, 10) - parseInt(that.currentItem.css("paddingBottom")||0, 10)); }
1846					if(!p.width()) { p.width(that.currentItem.innerWidth() - parseInt(that.currentItem.css("paddingLeft")||0, 10) - parseInt(that.currentItem.css("paddingRight")||0, 10)); }
1847				}
1848			};
1849		}
1850
1851		//Create the placeholder
1852		that.placeholder = $(o.placeholder.element.call(that.element, that.currentItem));
1853
1854		//Append it after the actual current item
1855		that.currentItem.after(that.placeholder);
1856
1857		//Update the size of the placeholder (TODO: Logic to fuzzy, see line 316/317)
1858		o.placeholder.update(that, that.placeholder);
1859
1860	},
1861
1862	_contactContainers: function(event) {
1863		var i, j, dist, itemWithLeastDistance, posProperty, sizeProperty, cur, nearBottom, floating, axis,
1864			innermostContainer = null,
1865			innermostIndex = null;
1866
1867		// get innermost container that intersects with item
1868		for (i = this.containers.length - 1; i >= 0; i--) {
1869
1870			// never consider a container that's located within the item itself
1871			if($.contains(this.currentItem[0], this.containers[i].element[0])) {
1872				continue;
1873			}
1874
1875			if(this._intersectsWith(this.containers[i].containerCache)) {
1876
1877				// if we've already found a container and it's more "inner" than this, then continue
1878				if(innermostContainer && $.contains(this.containers[i].element[0], innermostContainer.element[0])) {
1879					continue;
1880				}
1881
1882				innermostContainer = this.containers[i];
1883				innermostIndex = i;
1884
1885			} else {
1886				// container doesn't intersect. trigger "out" event if necessary
1887				if(this.containers[i].containerCache.over) {
1888					this.containers[i]._trigger("out", event, this._uiHash(this));
1889					this.containers[i].containerCache.over = 0;
1890				}
1891			}
1892
1893		}
1894
1895		// if no intersecting containers found, return
1896		if(!innermostContainer) {
1897			return;
1898		}
1899
1900		// move the item into the container if it's not there already
1901		if(this.containers.length === 1) {
1902			if (!this.containers[innermostIndex].containerCache.over) {
1903				this.containers[innermostIndex]._trigger("over", event, this._uiHash(this));
1904				this.containers[innermostIndex].containerCache.over = 1;
1905			}
1906		} else {
1907
1908			//When entering a new container, we will find the item with the least distance and append our item near it
1909			dist = 10000;
1910			itemWithLeastDistance = null;
1911			floating = innermostContainer.floating || this._isFloating(this.currentItem);
1912			posProperty = floating ? "left" : "top";
1913			sizeProperty = floating ? "width" : "height";
1914			axis = floating ? "clientX" : "clientY";
1915
1916			for (j = this.items.length - 1; j >= 0; j--) {
1917				if(!$.contains(this.containers[innermostIndex].element[0], this.items[j].item[0])) {
1918					continue;
1919				}
1920				if(this.items[j].item[0] === this.currentItem[0]) {
1921					continue;
1922				}
1923
1924				cur = this.items[j].item.offset()[posProperty];
1925				nearBottom = false;
1926				if ( event[ axis ] - cur > this.items[ j ][ sizeProperty ] / 2 ) {
1927					nearBottom = true;
1928				}
1929
1930				if ( Math.abs( event[ axis ] - cur ) < dist ) {
1931					dist = Math.abs( event[ axis ] - cur );
1932					itemWithLeastDistance = this.items[ j ];
1933					this.direction = nearBottom ? "up": "down";
1934				}
1935			}
1936
1937			//Check if dropOnEmpty is enabled
1938			if(!itemWithLeastDistance && !this.options.dropOnEmpty) {
1939				return;
1940			}
1941
1942			if(this.currentContainer === this.containers[innermostIndex]) {
1943				if ( !this.currentContainer.containerCache.over ) {
1944					this.containers[ innermostIndex ]._trigger( "over", event, this._uiHash() );
1945					this.currentContainer.containerCache.over = 1;
1946				}
1947				return;
1948			}
1949
1950			itemWithLeastDistance ? this._rearrange(event, itemWithLeastDistance, null, true) : this._rearrange(event, null, this.containers[innermostIndex].element, true);
1951			this._trigger("change", event, this._uiHash());
1952			this.containers[innermostIndex]._trigger("change", event, this._uiHash(this));
1953			this.currentContainer = this.containers[innermostIndex];
1954
1955			//Update the placeholder
1956			this.options.placeholder.update(this.currentContainer, this.placeholder);
1957
1958			this.containers[innermostIndex]._trigger("over", event, this._uiHash(this));
1959			this.containers[innermostIndex].containerCache.over = 1;
1960		}
1961
1962
1963	},
1964
1965	_createHelper: function(event) {
1966
1967		var o = this.options,
1968			helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [event, this.currentItem])) : (o.helper === "clone" ? this.currentItem.clone() : this.currentItem);
1969
1970		//Add the helper to the DOM if that didn't happen already
1971		if(!helper.parents("body").length) {
1972			$(o.appendTo !== "parent" ? o.appendTo : this.currentItem[0].parentNode)[0].appendChild(helper[0]);
1973		}
1974
1975		if(helper[0] === this.currentItem[0]) {
1976			this._storedCSS = { width: this.currentItem[0].style.width, height: this.currentItem[0].style.height, position: this.currentItem.css("position"), top: this.currentItem.css("top"), left
vendor: 10,195 bytes, lines 1976-2205
1976: this.currentItem.css("left") };
1977		}
1978
1979		if(!helper[0].style.width || o.forceHelperSize) {
1980			helper.width(this.currentItem.width());
1981		}
1982		if(!helper[0].style.height || o.forceHelperSize) {
1983			helper.height(this.currentItem.height());
1984		}
1985
1986		return helper;
1987
1988	},
1989
1990	_adjustOffsetFromHelper: function(obj) {
1991		if (typeof obj === "string") {
1992			obj = obj.split(" ");
1993		}
1994		if ($.isArray(obj)) {
1995			obj = {left: +obj[0], top: +obj[1] || 0};
1996		}
1997		if ("left" in obj) {
1998			this.offset.click.left = obj.left + this.margins.left;
1999		}
2000		if ("right" in obj) {
2001			this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
2002		}
2003		if ("top" in obj) {
2004			this.offset.click.top = obj.top + this.margins.top;
2005		}
2006		if ("bottom" in obj) {
2007			this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
2008		}
2009	},
2010
2011	_getParentOffset: function() {
2012
2013
2014		//Get the offsetParent and cache its position
2015		this.offsetParent = this.helper.offsetParent();
2016		var po = this.offsetParent.offset();
2017
2018		// This is a special case where we need to modify a offset calculated on start, since the following happened:
2019		// 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent
2020		// 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that
2021		//    the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag
2022		if(this.cssPosition === "absolute" && this.scrollParent[0] !== this.document[0] && $.contains(this.scrollParent[0], this.offsetParent[0])) {
2023			po.left += this.scrollParent.scrollLeft();
2024			po.top += this.scrollParent.scrollTop();
2025		}
2026
2027		// This needs to be actually done for all browsers, since pageX/pageY includes this information
2028		// with an ugly IE fix
2029		if( this.offsetParent[0] === this.document[0].body || (this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() === "html" && $.ui.ie)) {
2030			po = { top: 0, left: 0 };
2031		}
2032
2033		return {
2034			top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"),10) || 0),
2035			left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"),10) || 0)
2036		};
2037
2038	},
2039
2040	_getRelativeOffset: function() {
2041
2042		if(this.cssPosition === "relative") {
2043			var p = this.currentItem.position();
2044			return {
2045				top: p.top - (parseInt(this.helper.css("top"),10) || 0) + this.scrollParent.scrollTop(),
2046				left: p.left - (parseInt(this.helper.css("left"),10) || 0) + this.scrollParent.scrollLeft()
2047			};
2048		} else {
2049			return { top: 0, left: 0 };
2050		}
2051
2052	},
2053
2054	_cacheMargins: function() {
2055		this.margins = {
2056			left: (parseInt(this.currentItem.css("marginLeft"),10) || 0),
2057			top: (parseInt(this.currentItem.css("marginTop"),10) || 0)
2058		};
2059	},
2060
2061	_cacheHelperProportions: function() {
2062		this.helperProportions = {
2063			width: this.helper.outerWidth(),
2064			height: this.helper.outerHeight()
2065		};
2066	},
2067
2068	_setContainment: function() {
2069
2070		var ce, co, over,
2071			o = this.options;
2072		if(o.containment === "parent") {
2073			o.containment = this.helper[0].parentNode;
2074		}
2075		if(o.containment === "document" || o.containment === "window") {
2076			this.containment = [
2077				0 - this.offset.relative.left - this.offset.parent.left,
2078				0 - this.offset.relative.top - this.offset.parent.top,
2079				o.containment === "document" ? this.document.width() : this.window.width() - this.helperProportions.width - this.margins.left,
2080				(o.containment === "document" ? this.document.width() : this.window.height() || this.document[0].body.parentNode.scrollHeight) - this.helperProportions.height - this.margins.top
2081			];
2082		}
2083
2084		if(!(/^(document|window|parent)$/).test(o.containment)) {
2085			ce = $(o.containment)[0];
2086			co = $(o.containment).offset();
2087			over = ($(ce).css("overflow") !== "hidden");
2088
2089			this.containment = [
2090				co.left + (parseInt($(ce).css("borderLeftWidth"),10) || 0) + (parseInt($(ce).css("paddingLeft"),10) || 0) - this.margins.left,
2091				co.top + (parseInt($(ce).css("borderTopWidth"),10) || 0) + (parseInt($(ce).css("paddingTop"),10) || 0) - this.margins.top,
2092				co.left+(over ? Math.max(ce.scrollWidth,ce.offsetWidth) : ce.offsetWidth) - (parseInt($(ce).css("borderLeftWidth"),10) || 0) - (parseInt($(ce).css("paddingRight"),10) || 0) - this.helperProportions.width - this.margins.left,
2093				co.top+(over ? Math.max(ce.scrollHeight,ce.offsetHeight) : ce.offsetHeight) - (parseInt($(ce).css("borderTopWidth"),10) || 0) - (parseInt($(ce).css("paddingBottom"),10) || 0) - this.helperProportions.height - this.margins.top
2094			];
2095		}
2096
2097	},
2098
2099	_convertPositionTo: function(d, pos) {
2100
2101		if(!pos) {
2102			pos = this.position;
2103		}
2104		var mod = d === "absolute" ? 1 : -1,
2105			scroll = this.cssPosition === "absolute" && !(this.scrollParent[0] !== this.document[0] && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent,
2106			scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
2107
2108		return {
2109			top: (
2110				pos.top	+																// The absolute mouse position
2111				this.offset.relative.top * mod +										// Only for relative positioned nodes: Relative offset from element to offset parent
2112				this.offset.parent.top * mod -											// The offsetParent's offset without borders (offset + border)
2113				( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod)
2114			),
2115			left: (
2116				pos.left +																// The absolute mouse position
2117				this.offset.relative.left * mod +										// Only for relative positioned nodes: Relative offset from element to offset parent
2118				this.offset.parent.left * mod	-										// The offsetParent's offset without borders (offset + border)
2119				( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ) * mod)
2120			)
2121		};
2122
2123	},
2124
2125	_generatePosition: function(event) {
2126
2127		var top, left,
2128			o = this.options,
2129			pageX = event.pageX,
2130			pageY = event.pageY,
2131			scroll = this.cssPosition === "absolute" && !(this.scrollParent[0] !== this.document[0] && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
2132
2133		// This is another very weird special case that only happens for relative elements:
2134		// 1. If the css position is relative
2135		// 2. and the scroll parent is the document or similar to the offset parent
2136		// we have to refresh the relative offset during the scroll so there are no jumps
2137		if(this.cssPosition === "relative" && !(this.scrollParent[0] !== this.document[0] && this.scrollParent[0] !== this.offsetParent[0])) {
2138			this.offset.relative = this._getRelativeOffset();
2139		}
2140
2141		/*
2142		 * - Position constraining -
2143		 * Constrain the position to a mix of grid, containment.
2144		 */
2145
2146		if(this.originalPosition) { //If we are not dragging yet, we won't check for options
2147
2148			if(this.containment) {
2149				if(event.pageX - this.offset.click.left < this.containment[0]) {
2150					pageX = this.containment[0] + this.offset.click.left;
2151				}
2152				if(event.pageY - this.offset.click.top < this.containment[1]) {
2153					pageY = this.containment[1] + this.offset.click.top;
2154				}
2155				if(event.pageX - this.offset.click.left > this.containment[2]) {
2156					pageX = this.containment[2] + this.offset.click.left;
2157				}
2158				if(event.pageY - this.offset.click.top > this.containment[3]) {
2159					pageY = this.containment[3] + this.offset.click.top;
2160				}
2161			}
2162
2163			if(o.grid) {
2164				top = this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1];
2165				pageY = this.containment ? ( (top - this.offset.click.top >= this.containment[1] && top - this.offset.click.top <= this.containment[3]) ? top : ((top - this.offset.click.top >= this.containment[1]) ? top - o.grid[1] : top + o.grid[1])) : top;
2166
2167				left = this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0];
2168				pageX = this.containment ? ( (left - this.offset.click.left >= this.containment[0] && left - this.offset.click.left <= this.containment[2]) ? left : ((left - this.offset.click.left >= this.containment[0]) ? left - o.grid[0] : left + o.grid[0])) : left;
2169			}
2170
2171		}
2172
2173		return {
2174			top: (
2175				pageY -																// The absolute mouse position
2176				this.offset.click.top -													// Click offset (relative to the element)
2177				this.offset.relative.top	-											// Only for relative positioned nodes: Relative offset from element to offset parent
2178				this.offset.parent.top +												// The offsetParent's offset without borders (offset + border)
2179				( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ))
2180			),
2181			left: (
2182				pageX -																// The absolute mouse position
2183				this.offset.click.left -												// Click offset (relative to the element)
2184				this.offset.relative.left	-											// Only for relative positioned nodes: Relative offset from element to offset parent
2185				this.offset.parent.left +												// The offsetParent's offset without borders (offset + border)
2186				( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ))
2187			)
2188		};
2189
2190	},
2191
2192	_rearrange: function(event, i, a, hardRefresh) {
2193
2194		a ? a[0].appendChild(this.placeholder[0]) : i.item[0].parentNode.insertBefore(this.placeholder[0], (this.direction === "down" ? i.item[0] : i.item[0].nextSibling));
2195
2196		//Various things done here to improve the performance:
2197		// 1. we create a setTimeout, that calls refreshPositions
2198		// 2. on the instance, we have a counter variable, that get's higher after every append
2199		// 3. on the local scope, we copy the counter variable, and check in the timeout, if it's still the same
2200		// 4. this lets only the last addition to the timeout stack through
2201		this.counter = this.counter ? ++this.counter : 1;
2202		var counter = this.counter;
2203
2204		this._delay(function() {
2205			if(counter === this.counter) {
vendor: 4,298 bytes, lines 2206-2335
2206				this.refreshPositions(!hardRefresh); //Precompute after each DOM insertion, NOT on mousemove
2207			}
2208		});
2209
2210	},
2211
2212	_clear: function(event, noPropagation) {
2213
2214		this.reverting = false;
2215		// We delay all events that have to be triggered to after the point where the placeholder has been removed and
2216		// everything else normalized again
2217		var i,
2218			delayedTriggers = [];
2219
2220		// We first have to update the dom position of the actual currentItem
2221		// Note: don't do it if the current item is already removed (by a user), or it gets reappended (see #4088)
2222		if(!this._noFinalSort && this.currentItem.parent().length) {
2223			this.placeholder.before(this.currentItem);
2224		}
2225		this._noFinalSort = null;
2226
2227		if(this.helper[0] === this.currentItem[0]) {
2228			for(i in this._storedCSS) {
2229				if(this._storedCSS[i] === "auto" || this._storedCSS[i] === "static") {
2230					this._storedCSS[i] = "";
2231				}
2232			}
2233			this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper");
2234		} else {
2235			this.currentItem.show();
2236		}
2237
2238		if(this.fromOutside && !noPropagation) {
2239			delayedTriggers.push(function(event) { this._trigger("receive", event, this._uiHash(this.fromOutside)); });
2240		}
2241		if((this.fromOutside || this.domPosition.prev !== this.currentItem.prev().not(".ui-sortable-helper")[0] || this.domPosition.parent !== this.currentItem.parent()[0]) && !noPropagation) {
2242			delayedTriggers.push(function(event) { this._trigger("update", event, this._uiHash()); }); //Trigger update callback if the DOM position has changed
2243		}
2244
2245		// Check if the items Container has Changed and trigger appropriate
2246		// events.
2247		if (this !== this.currentContainer) {
2248			if(!noPropagation) {
2249				delayedTriggers.push(function(event) { this._trigger("remove", event, this._uiHash()); });
2250				delayedTriggers.push((function(c) { return function(event) { c._trigger("receive", event, this._uiHash(this)); };  }).call(this, this.currentContainer));
2251				delayedTriggers.push((function(c) { return function(event) { c._trigger("update", event, this._uiHash(this));  }; }).call(this, this.currentContainer));
2252			}
2253		}
2254
2255
2256		//Post events to containers
2257		function delayEvent( type, instance, container ) {
2258			return function( event ) {
2259				container._trigger( type, event, instance._uiHash( instance ) );
2260			};
2261		}
2262		for (i = this.containers.length - 1; i >= 0; i--){
2263			if (!noPropagation) {
2264				delayedTriggers.push( delayEvent( "deactivate", this, this.containers[ i ] ) );
2265			}
2266			if(this.containers[i].containerCache.over) {
2267				delayedTriggers.push( delayEvent( "out", this, this.containers[ i ] ) );
2268				this.containers[i].containerCache.over = 0;
2269			}
2270		}
2271
2272		//Do what was originally in plugins
2273		if ( this.storedCursor ) {
2274			this.document.find( "body" ).css( "cursor", this.storedCursor );
2275			this.storedStylesheet.remove();
2276		}
2277		if(this._storedOpacity) {
2278			this.helper.css("opacity", this._storedOpacity);
2279		}
2280		if(this._storedZIndex) {
2281			this.helper.css("zIndex", this._storedZIndex === "auto" ? "" : this._storedZIndex);
2282		}
2283
2284		this.dragging = false;
2285
2286		if(!noPropagation) {
2287			this._trigger("beforeStop", event, this._uiHash());
2288		}
2289
2290		//$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node!
2291		this.placeholder[0].parentNode.removeChild(this.placeholder[0]);
2292
2293		if ( !this.cancelHelperRemoval ) {
2294			if ( this.helper[ 0 ] !== this.currentItem[ 0 ] ) {
2295				this.helper.remove();
2296			}
2297			this.helper = null;
2298		}
2299
2300		if(!noPropagation) {
2301			for (i=0; i < delayedTriggers.length; i++) {
2302				delayedTriggers[i].call(this, event);
2303			} //Trigger all delayed events
2304			this._trigger("stop", event, this._uiHash());
2305		}
2306
2307		this.fromOutside = false;
2308		return !this.cancelHelperRemoval;
2309
2310	},
2311
2312	_trigger: function() {
2313		if ($.Widget.prototype._trigger.apply(this, arguments) === false) {
2314			this.cancel();
2315		}
2316	},
2317
2318	_uiHash: function(_inst) {
2319		var inst = _inst || this;
2320		return {
2321			helper: inst.helper,
2322			placeholder: inst.placeholder || $([]),
2323			position: inst.position,
2324			originalPosition: inst.originalPosition,
2325			offset: inst.positionAbs,
2326			item: inst.currentItem,
2327			sender: _inst ? _inst.element : null
2328		};
2329	}
2330
2331});
2332
2333
2334
2335}));

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.