PageRenderTime 160ms CodeModel.GetById 20ms app.highlight 99ms RepoModel.GetById 1ms app.codeStats 4ms

/Scripts/jquery-ui-1.9.2.js

https://bitbucket.org/parivedasolutions/attributeroutingtest
JavaScript | 14912 lines | 12590 code | 1470 blank | 852 comment | 2060 complexity | 42417a1984f6f113247bb13a09a26542 MD5 | raw file

Large files files are truncated, but you can click here to view the full file

   1/*! jQuery UI - v1.9.2 - 2012-11-23
   2* http://jqueryui.com
   3* Includes: jquery.ui.core.js, jquery.ui.widget.js, jquery.ui.mouse.js, jquery.ui.draggable.js, jquery.ui.droppable.js, jquery.ui.resizable.js, jquery.ui.selectable.js, jquery.ui.sortable.js, jquery.ui.effect.js, jquery.ui.accordion.js, jquery.ui.autocomplete.js, jquery.ui.button.js, jquery.ui.datepicker.js, jquery.ui.dialog.js, jquery.ui.effect-blind.js, jquery.ui.effect-bounce.js, jquery.ui.effect-clip.js, jquery.ui.effect-drop.js, jquery.ui.effect-explode.js, jquery.ui.effect-fade.js, jquery.ui.effect-fold.js, jquery.ui.effect-highlight.js, jquery.ui.effect-pulsate.js, jquery.ui.effect-scale.js, jquery.ui.effect-shake.js, jquery.ui.effect-slide.js, jquery.ui.effect-transfer.js, jquery.ui.menu.js, jquery.ui.position.js, jquery.ui.progressbar.js, jquery.ui.slider.js, jquery.ui.spinner.js, jquery.ui.tabs.js, jquery.ui.tooltip.js
   4* Copyright 2012 jQuery Foundation and other contributors; Licensed MIT */
   5
   6(function( $, undefined ) {
   7
   8var uuid = 0,
   9	runiqueId = /^ui-id-\d+$/;
  10
  11// prevent duplicate loading
  12// this is only a problem because we proxy existing functions
  13// and we don't want to double proxy them
  14$.ui = $.ui || {};
  15if ( $.ui.version ) {
  16	return;
  17}
  18
  19$.extend( $.ui, {
  20	version: "1.9.2",
  21
  22	keyCode: {
  23		BACKSPACE: 8,
  24		COMMA: 188,
  25		DELETE: 46,
  26		DOWN: 40,
  27		END: 35,
  28		ENTER: 13,
  29		ESCAPE: 27,
  30		HOME: 36,
  31		LEFT: 37,
  32		NUMPAD_ADD: 107,
  33		NUMPAD_DECIMAL: 110,
  34		NUMPAD_DIVIDE: 111,
  35		NUMPAD_ENTER: 108,
  36		NUMPAD_MULTIPLY: 106,
  37		NUMPAD_SUBTRACT: 109,
  38		PAGE_DOWN: 34,
  39		PAGE_UP: 33,
  40		PERIOD: 190,
  41		RIGHT: 39,
  42		SPACE: 32,
  43		TAB: 9,
  44		UP: 38
  45	}
  46});
  47
  48// plugins
  49$.fn.extend({
  50	_focus: $.fn.focus,
  51	focus: function( delay, fn ) {
  52		return typeof delay === "number" ?
  53			this.each(function() {
  54				var elem = this;
  55				setTimeout(function() {
  56					$( elem ).focus();
  57					if ( fn ) {
  58						fn.call( elem );
  59					}
  60				}, delay );
  61			}) :
  62			this._focus.apply( this, arguments );
  63	},
  64
  65	scrollParent: function() {
  66		var scrollParent;
  67		if (($.ui.ie && (/(static|relative)/).test(this.css('position'))) || (/absolute/).test(this.css('position'))) {
  68			scrollParent = this.parents().filter(function() {
  69				return (/(relative|absolute|fixed)/).test($.css(this,'position')) && (/(auto|scroll)/).test($.css(this,'overflow')+$.css(this,'overflow-y')+$.css(this,'overflow-x'));
  70			}).eq(0);
  71		} else {
  72			scrollParent = this.parents().filter(function() {
  73				return (/(auto|scroll)/).test($.css(this,'overflow')+$.css(this,'overflow-y')+$.css(this,'overflow-x'));
  74			}).eq(0);
  75		}
  76
  77		return (/fixed/).test(this.css('position')) || !scrollParent.length ? $(document) : scrollParent;
  78	},
  79
  80	zIndex: function( zIndex ) {
  81		if ( zIndex !== undefined ) {
  82			return this.css( "zIndex", zIndex );
  83		}
  84
  85		if ( this.length ) {
  86			var elem = $( this[ 0 ] ), position, value;
  87			while ( elem.length && elem[ 0 ] !== document ) {
  88				// Ignore z-index if position is set to a value where z-index is ignored by the browser
  89				// This makes behavior of this function consistent across browsers
  90				// WebKit always returns auto if the element is positioned
  91				position = elem.css( "position" );
  92				if ( position === "absolute" || position === "relative" || position === "fixed" ) {
  93					// IE returns 0 when zIndex is not specified
  94					// other browsers return a string
  95					// we ignore the case of nested elements with an explicit value of 0
  96					// <div style="z-index: -10;"><div style="z-index: 0;"></div></div>
  97					value = parseInt( elem.css( "zIndex" ), 10 );
  98					if ( !isNaN( value ) && value !== 0 ) {
  99						return value;
 100					}
 101				}
 102				elem = elem.parent();
 103			}
 104		}
 105
 106		return 0;
 107	},
 108
 109	uniqueId: function() {
 110		return this.each(function() {
 111			if ( !this.id ) {
 112				this.id = "ui-id-" + (++uuid);
 113			}
 114		});
 115	},
 116
 117	removeUniqueId: function() {
 118		return this.each(function() {
 119			if ( runiqueId.test( this.id ) ) {
 120				$( this ).removeAttr( "id" );
 121			}
 122		});
 123	}
 124});
 125
 126// selectors
 127function focusable( element, isTabIndexNotNaN ) {
 128	var map, mapName, img,
 129		nodeName = element.nodeName.toLowerCase();
 130	if ( "area" === nodeName ) {
 131		map = element.parentNode;
 132		mapName = map.name;
 133		if ( !element.href || !mapName || map.nodeName.toLowerCase() !== "map" ) {
 134			return false;
 135		}
 136		img = $( "img[usemap=#" + mapName + "]" )[0];
 137		return !!img && visible( img );
 138	}
 139	return ( /input|select|textarea|button|object/.test( nodeName ) ?
 140		!element.disabled :
 141		"a" === nodeName ?
 142			element.href || isTabIndexNotNaN :
 143			isTabIndexNotNaN) &&
 144		// the element and all of its ancestors must be visible
 145		visible( element );
 146}
 147
 148function visible( element ) {
 149	return $.expr.filters.visible( element ) &&
 150		!$( element ).parents().andSelf().filter(function() {
 151			return $.css( this, "visibility" ) === "hidden";
 152		}).length;
 153}
 154
 155$.extend( $.expr[ ":" ], {
 156	data: $.expr.createPseudo ?
 157		$.expr.createPseudo(function( dataName ) {
 158			return function( elem ) {
 159				return !!$.data( elem, dataName );
 160			};
 161		}) :
 162		// support: jQuery <1.8
 163		function( elem, i, match ) {
 164			return !!$.data( elem, match[ 3 ] );
 165		},
 166
 167	focusable: function( element ) {
 168		return focusable( element, !isNaN( $.attr( element, "tabindex" ) ) );
 169	},
 170
 171	tabbable: function( element ) {
 172		var tabIndex = $.attr( element, "tabindex" ),
 173			isTabIndexNaN = isNaN( tabIndex );
 174		return ( isTabIndexNaN || tabIndex >= 0 ) && focusable( element, !isTabIndexNaN );
 175	}
 176});
 177
 178// support
 179$(function() {
 180	var body = document.body,
 181		div = body.appendChild( div = document.createElement( "div" ) );
 182
 183	// access offsetHeight before setting the style to prevent a layout bug
 184	// in IE 9 which causes the element to continue to take up space even
 185	// after it is removed from the DOM (#8026)
 186	div.offsetHeight;
 187
 188	$.extend( div.style, {
 189		minHeight: "100px",
 190		height: "auto",
 191		padding: 0,
 192		borderWidth: 0
 193	});
 194
 195	$.support.minHeight = div.offsetHeight === 100;
 196	$.support.selectstart = "onselectstart" in div;
 197
 198	// set display to none to avoid a layout bug in IE
 199	// http://dev.jquery.com/ticket/4014
 200	body.removeChild( div ).style.display = "none";
 201});
 202
 203// support: jQuery <1.8
 204if ( !$( "<a>" ).outerWidth( 1 ).jquery ) {
 205	$.each( [ "Width", "Height" ], function( i, name ) {
 206		var side = name === "Width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ],
 207			type = name.toLowerCase(),
 208			orig = {
 209				innerWidth: $.fn.innerWidth,
 210				innerHeight: $.fn.innerHeight,
 211				outerWidth: $.fn.outerWidth,
 212				outerHeight: $.fn.outerHeight
 213			};
 214
 215		function reduce( elem, size, border, margin ) {
 216			$.each( side, function() {
 217				size -= parseFloat( $.css( elem, "padding" + this ) ) || 0;
 218				if ( border ) {
 219					size -= parseFloat( $.css( elem, "border" + this + "Width" ) ) || 0;
 220				}
 221				if ( margin ) {
 222					size -= parseFloat( $.css( elem, "margin" + this ) ) || 0;
 223				}
 224			});
 225			return size;
 226		}
 227
 228		$.fn[ "inner" + name ] = function( size ) {
 229			if ( size === undefined ) {
 230				return orig[ "inner" + name ].call( this );
 231			}
 232
 233			return this.each(function() {
 234				$( this ).css( type, reduce( this, size ) + "px" );
 235			});
 236		};
 237
 238		$.fn[ "outer" + name] = function( size, margin ) {
 239			if ( typeof size !== "number" ) {
 240				return orig[ "outer" + name ].call( this, size );
 241			}
 242
 243			return this.each(function() {
 244				$( this).css( type, reduce( this, size, true, margin ) + "px" );
 245			});
 246		};
 247	});
 248}
 249
 250// support: jQuery 1.6.1, 1.6.2 (http://bugs.jquery.com/ticket/9413)
 251if ( $( "<a>" ).data( "a-b", "a" ).removeData( "a-b" ).data( "a-b" ) ) {
 252	$.fn.removeData = (function( removeData ) {
 253		return function( key ) {
 254			if ( arguments.length ) {
 255				return removeData.call( this, $.camelCase( key ) );
 256			} else {
 257				return removeData.call( this );
 258			}
 259		};
 260	})( $.fn.removeData );
 261}
 262
 263
 264
 265
 266
 267// deprecated
 268
 269(function() {
 270	var uaMatch = /msie ([\w.]+)/.exec( navigator.userAgent.toLowerCase() ) || [];
 271	$.ui.ie = uaMatch.length ? true : false;
 272	$.ui.ie6 = parseFloat( uaMatch[ 1 ], 10 ) === 6;
 273})();
 274
 275$.fn.extend({
 276	disableSelection: function() {
 277		return this.bind( ( $.support.selectstart ? "selectstart" : "mousedown" ) +
 278			".ui-disableSelection", function( event ) {
 279				event.preventDefault();
 280			});
 281	},
 282
 283	enableSelection: function() {
 284		return this.unbind( ".ui-disableSelection" );
 285	}
 286});
 287
 288$.extend( $.ui, {
 289	// $.ui.plugin is deprecated.  Use the proxy pattern instead.
 290	plugin: {
 291		add: function( module, option, set ) {
 292			var i,
 293				proto = $.ui[ module ].prototype;
 294			for ( i in set ) {
 295				proto.plugins[ i ] = proto.plugins[ i ] || [];
 296				proto.plugins[ i ].push( [ option, set[ i ] ] );
 297			}
 298		},
 299		call: function( instance, name, args ) {
 300			var i,
 301				set = instance.plugins[ name ];
 302			if ( !set || !instance.element[ 0 ].parentNode || instance.element[ 0 ].parentNode.nodeType === 11 ) {
 303				return;
 304			}
 305
 306			for ( i = 0; i < set.length; i++ ) {
 307				if ( instance.options[ set[ i ][ 0 ] ] ) {
 308					set[ i ][ 1 ].apply( instance.element, args );
 309				}
 310			}
 311		}
 312	},
 313
 314	contains: $.contains,
 315
 316	// only used by resizable
 317	hasScroll: function( el, a ) {
 318
 319		//If overflow is hidden, the element might have extra content, but the user wants to hide it
 320		if ( $( el ).css( "overflow" ) === "hidden") {
 321			return false;
 322		}
 323
 324		var scroll = ( a && a === "left" ) ? "scrollLeft" : "scrollTop",
 325			has = false;
 326
 327		if ( el[ scroll ] > 0 ) {
 328			return true;
 329		}
 330
 331		// TODO: determine which cases actually cause this to happen
 332		// if the element doesn't have the scroll set, see if it's possible to
 333		// set the scroll
 334		el[ scroll ] = 1;
 335		has = ( el[ scroll ] > 0 );
 336		el[ scroll ] = 0;
 337		return has;
 338	},
 339
 340	// these are odd functions, fix the API or move into individual plugins
 341	isOverAxis: function( x, reference, size ) {
 342		//Determines when x coordinate is over "b" element axis
 343		return ( x > reference ) && ( x < ( reference + size ) );
 344	},
 345	isOver: function( y, x, top, left, height, width ) {
 346		//Determines when x, y coordinates is over "b" element
 347		return $.ui.isOverAxis( y, top, height ) && $.ui.isOverAxis( x, left, width );
 348	}
 349});
 350
 351})( jQuery );
 352
 353(function( $, undefined ) {
 354
 355var uuid = 0,
 356	slice = Array.prototype.slice,
 357	_cleanData = $.cleanData;
 358$.cleanData = function( elems ) {
 359	for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {
 360		try {
 361			$( elem ).triggerHandler( "remove" );
 362		// http://bugs.jquery.com/ticket/8235
 363		} catch( e ) {}
 364	}
 365	_cleanData( elems );
 366};
 367
 368$.widget = function( name, base, prototype ) {
 369	var fullName, existingConstructor, constructor, basePrototype,
 370		namespace = name.split( "." )[ 0 ];
 371
 372	name = name.split( "." )[ 1 ];
 373	fullName = namespace + "-" + name;
 374
 375	if ( !prototype ) {
 376		prototype = base;
 377		base = $.Widget;
 378	}
 379
 380	// create selector for plugin
 381	$.expr[ ":" ][ fullName.toLowerCase() ] = function( elem ) {
 382		return !!$.data( elem, fullName );
 383	};
 384
 385	$[ namespace ] = $[ namespace ] || {};
 386	existingConstructor = $[ namespace ][ name ];
 387	constructor = $[ namespace ][ name ] = function( options, element ) {
 388		// allow instantiation without "new" keyword
 389		if ( !this._createWidget ) {
 390			return new constructor( options, element );
 391		}
 392
 393		// allow instantiation without initializing for simple inheritance
 394		// must use "new" keyword (the code above always passes args)
 395		if ( arguments.length ) {
 396			this._createWidget( options, element );
 397		}
 398	};
 399	// extend with the existing constructor to carry over any static properties
 400	$.extend( constructor, existingConstructor, {
 401		version: prototype.version,
 402		// copy the object used to create the prototype in case we need to
 403		// redefine the widget later
 404		_proto: $.extend( {}, prototype ),
 405		// track widgets that inherit from this widget in case this widget is
 406		// redefined after a widget inherits from it
 407		_childConstructors: []
 408	});
 409
 410	basePrototype = new base();
 411	// we need to make the options hash a property directly on the new instance
 412	// otherwise we'll modify the options hash on the prototype that we're
 413	// inheriting from
 414	basePrototype.options = $.widget.extend( {}, basePrototype.options );
 415	$.each( prototype, function( prop, value ) {
 416		if ( $.isFunction( value ) ) {
 417			prototype[ prop ] = (function() {
 418				var _super = function() {
 419						return base.prototype[ prop ].apply( this, arguments );
 420					},
 421					_superApply = function( args ) {
 422						return base.prototype[ prop ].apply( this, args );
 423					};
 424				return function() {
 425					var __super = this._super,
 426						__superApply = this._superApply,
 427						returnValue;
 428
 429					this._super = _super;
 430					this._superApply = _superApply;
 431
 432					returnValue = value.apply( this, arguments );
 433
 434					this._super = __super;
 435					this._superApply = __superApply;
 436
 437					return returnValue;
 438				};
 439			})();
 440		}
 441	});
 442	constructor.prototype = $.widget.extend( basePrototype, {
 443		// TODO: remove support for widgetEventPrefix
 444		// always use the name + a colon as the prefix, e.g., draggable:start
 445		// don't prefix for widgets that aren't DOM-based
 446		widgetEventPrefix: existingConstructor ? basePrototype.widgetEventPrefix : name
 447	}, prototype, {
 448		constructor: constructor,
 449		namespace: namespace,
 450		widgetName: name,
 451		// TODO remove widgetBaseClass, see #8155
 452		widgetBaseClass: fullName,
 453		widgetFullName: fullName
 454	});
 455
 456	// If this widget is being redefined then we need to find all widgets that
 457	// are inheriting from it and redefine all of them so that they inherit from
 458	// the new version of this widget. We're essentially trying to replace one
 459	// level in the prototype chain.
 460	if ( existingConstructor ) {
 461		$.each( existingConstructor._childConstructors, function( i, child ) {
 462			var childPrototype = child.prototype;
 463
 464			// redefine the child widget using the same prototype that was
 465			// originally used, but inherit from the new version of the base
 466			$.widget( childPrototype.namespace + "." + childPrototype.widgetName, constructor, child._proto );
 467		});
 468		// remove the list of existing child constructors from the old constructor
 469		// so the old child constructors can be garbage collected
 470		delete existingConstructor._childConstructors;
 471	} else {
 472		base._childConstructors.push( constructor );
 473	}
 474
 475	$.widget.bridge( name, constructor );
 476};
 477
 478$.widget.extend = function( target ) {
 479	var input = slice.call( arguments, 1 ),
 480		inputIndex = 0,
 481		inputLength = input.length,
 482		key,
 483		value;
 484	for ( ; inputIndex < inputLength; inputIndex++ ) {
 485		for ( key in input[ inputIndex ] ) {
 486			value = input[ inputIndex ][ key ];
 487			if ( input[ inputIndex ].hasOwnProperty( key ) && value !== undefined ) {
 488				// Clone objects
 489				if ( $.isPlainObject( value ) ) {
 490					target[ key ] = $.isPlainObject( target[ key ] ) ?
 491						$.widget.extend( {}, target[ key ], value ) :
 492						// Don't extend strings, arrays, etc. with objects
 493						$.widget.extend( {}, value );
 494				// Copy everything else by reference
 495				} else {
 496					target[ key ] = value;
 497				}
 498			}
 499		}
 500	}
 501	return target;
 502};
 503
 504$.widget.bridge = function( name, object ) {
 505	var fullName = object.prototype.widgetFullName || name;
 506	$.fn[ name ] = function( options ) {
 507		var isMethodCall = typeof options === "string",
 508			args = slice.call( arguments, 1 ),
 509			returnValue = this;
 510
 511		// allow multiple hashes to be passed on init
 512		options = !isMethodCall && args.length ?
 513			$.widget.extend.apply( null, [ options ].concat(args) ) :
 514			options;
 515
 516		if ( isMethodCall ) {
 517			this.each(function() {
 518				var methodValue,
 519					instance = $.data( this, fullName );
 520				if ( !instance ) {
 521					return $.error( "cannot call methods on " + name + " prior to initialization; " +
 522						"attempted to call method '" + options + "'" );
 523				}
 524				if ( !$.isFunction( instance[options] ) || options.charAt( 0 ) === "_" ) {
 525					return $.error( "no such method '" + options + "' for " + name + " widget instance" );
 526				}
 527				methodValue = instance[ options ].apply( instance, args );
 528				if ( methodValue !== instance && methodValue !== undefined ) {
 529					returnValue = methodValue && methodValue.jquery ?
 530						returnValue.pushStack( methodValue.get() ) :
 531						methodValue;
 532					return false;
 533				}
 534			});
 535		} else {
 536			this.each(function() {
 537				var instance = $.data( this, fullName );
 538				if ( instance ) {
 539					instance.option( options || {} )._init();
 540				} else {
 541					$.data( this, fullName, new object( options, this ) );
 542				}
 543			});
 544		}
 545
 546		return returnValue;
 547	};
 548};
 549
 550$.Widget = function( /* options, element */ ) {};
 551$.Widget._childConstructors = [];
 552
 553$.Widget.prototype = {
 554	widgetName: "widget",
 555	widgetEventPrefix: "",
 556	defaultElement: "<div>",
 557	options: {
 558		disabled: false,
 559
 560		// callbacks
 561		create: null
 562	},
 563	_createWidget: function( options, element ) {
 564		element = $( element || this.defaultElement || this )[ 0 ];
 565		this.element = $( element );
 566		this.uuid = uuid++;
 567		this.eventNamespace = "." + this.widgetName + this.uuid;
 568		this.options = $.widget.extend( {},
 569			this.options,
 570			this._getCreateOptions(),
 571			options );
 572
 573		this.bindings = $();
 574		this.hoverable = $();
 575		this.focusable = $();
 576
 577		if ( element !== this ) {
 578			// 1.9 BC for #7810
 579			// TODO remove dual storage
 580			$.data( element, this.widgetName, this );
 581			$.data( element, this.widgetFullName, this );
 582			this._on( true, this.element, {
 583				remove: function( event ) {
 584					if ( event.target === element ) {
 585						this.destroy();
 586					}
 587				}
 588			});
 589			this.document = $( element.style ?
 590				// element within the document
 591				element.ownerDocument :
 592				// element is window or document
 593				element.document || element );
 594			this.window = $( this.document[0].defaultView || this.document[0].parentWindow );
 595		}
 596
 597		this._create();
 598		this._trigger( "create", null, this._getCreateEventData() );
 599		this._init();
 600	},
 601	_getCreateOptions: $.noop,
 602	_getCreateEventData: $.noop,
 603	_create: $.noop,
 604	_init: $.noop,
 605
 606	destroy: function() {
 607		this._destroy();
 608		// we can probably remove the unbind calls in 2.0
 609		// all event bindings should go through this._on()
 610		this.element
 611			.unbind( this.eventNamespace )
 612			// 1.9 BC for #7810
 613			// TODO remove dual storage
 614			.removeData( this.widgetName )
 615			.removeData( this.widgetFullName )
 616			// support: jquery <1.6.3
 617			// http://bugs.jquery.com/ticket/9413
 618			.removeData( $.camelCase( this.widgetFullName ) );
 619		this.widget()
 620			.unbind( this.eventNamespace )
 621			.removeAttr( "aria-disabled" )
 622			.removeClass(
 623				this.widgetFullName + "-disabled " +
 624				"ui-state-disabled" );
 625
 626		// clean up events and states
 627		this.bindings.unbind( this.eventNamespace );
 628		this.hoverable.removeClass( "ui-state-hover" );
 629		this.focusable.removeClass( "ui-state-focus" );
 630	},
 631	_destroy: $.noop,
 632
 633	widget: function() {
 634		return this.element;
 635	},
 636
 637	option: function( key, value ) {
 638		var options = key,
 639			parts,
 640			curOption,
 641			i;
 642
 643		if ( arguments.length === 0 ) {
 644			// don't return a reference to the internal hash
 645			return $.widget.extend( {}, this.options );
 646		}
 647
 648		if ( typeof key === "string" ) {
 649			// handle nested keys, e.g., "foo.bar" => { foo: { bar: ___ } }
 650			options = {};
 651			parts = key.split( "." );
 652			key = parts.shift();
 653			if ( parts.length ) {
 654				curOption = options[ key ] = $.widget.extend( {}, this.options[ key ] );
 655				for ( i = 0; i < parts.length - 1; i++ ) {
 656					curOption[ parts[ i ] ] = curOption[ parts[ i ] ] || {};
 657					curOption = curOption[ parts[ i ] ];
 658				}
 659				key = parts.pop();
 660				if ( value === undefined ) {
 661					return curOption[ key ] === undefined ? null : curOption[ key ];
 662				}
 663				curOption[ key ] = value;
 664			} else {
 665				if ( value === undefined ) {
 666					return this.options[ key ] === undefined ? null : this.options[ key ];
 667				}
 668				options[ key ] = value;
 669			}
 670		}
 671
 672		this._setOptions( options );
 673
 674		return this;
 675	},
 676	_setOptions: function( options ) {
 677		var key;
 678
 679		for ( key in options ) {
 680			this._setOption( key, options[ key ] );
 681		}
 682
 683		return this;
 684	},
 685	_setOption: function( key, value ) {
 686		this.options[ key ] = value;
 687
 688		if ( key === "disabled" ) {
 689			this.widget()
 690				.toggleClass( this.widgetFullName + "-disabled ui-state-disabled", !!value )
 691				.attr( "aria-disabled", value );
 692			this.hoverable.removeClass( "ui-state-hover" );
 693			this.focusable.removeClass( "ui-state-focus" );
 694		}
 695
 696		return this;
 697	},
 698
 699	enable: function() {
 700		return this._setOption( "disabled", false );
 701	},
 702	disable: function() {
 703		return this._setOption( "disabled", true );
 704	},
 705
 706	_on: function( suppressDisabledCheck, element, handlers ) {
 707		var delegateElement,
 708			instance = this;
 709
 710		// no suppressDisabledCheck flag, shuffle arguments
 711		if ( typeof suppressDisabledCheck !== "boolean" ) {
 712			handlers = element;
 713			element = suppressDisabledCheck;
 714			suppressDisabledCheck = false;
 715		}
 716
 717		// no element argument, shuffle and use this.element
 718		if ( !handlers ) {
 719			handlers = element;
 720			element = this.element;
 721			delegateElement = this.widget();
 722		} else {
 723			// accept selectors, DOM elements
 724			element = delegateElement = $( element );
 725			this.bindings = this.bindings.add( element );
 726		}
 727
 728		$.each( handlers, function( event, handler ) {
 729			function handlerProxy() {
 730				// allow widgets to customize the disabled handling
 731				// - disabled as an array instead of boolean
 732				// - disabled class as method for disabling individual parts
 733				if ( !suppressDisabledCheck &&
 734						( instance.options.disabled === true ||
 735							$( this ).hasClass( "ui-state-disabled" ) ) ) {
 736					return;
 737				}
 738				return ( typeof handler === "string" ? instance[ handler ] : handler )
 739					.apply( instance, arguments );
 740			}
 741
 742			// copy the guid so direct unbinding works
 743			if ( typeof handler !== "string" ) {
 744				handlerProxy.guid = handler.guid =
 745					handler.guid || handlerProxy.guid || $.guid++;
 746			}
 747
 748			var match = event.match( /^(\w+)\s*(.*)$/ ),
 749				eventName = match[1] + instance.eventNamespace,
 750				selector = match[2];
 751			if ( selector ) {
 752				delegateElement.delegate( selector, eventName, handlerProxy );
 753			} else {
 754				element.bind( eventName, handlerProxy );
 755			}
 756		});
 757	},
 758
 759	_off: function( element, eventName ) {
 760		eventName = (eventName || "").split( " " ).join( this.eventNamespace + " " ) + this.eventNamespace;
 761		element.unbind( eventName ).undelegate( eventName );
 762	},
 763
 764	_delay: function( handler, delay ) {
 765		function handlerProxy() {
 766			return ( typeof handler === "string" ? instance[ handler ] : handler )
 767				.apply( instance, arguments );
 768		}
 769		var instance = this;
 770		return setTimeout( handlerProxy, delay || 0 );
 771	},
 772
 773	_hoverable: function( element ) {
 774		this.hoverable = this.hoverable.add( element );
 775		this._on( element, {
 776			mouseenter: function( event ) {
 777				$( event.currentTarget ).addClass( "ui-state-hover" );
 778			},
 779			mouseleave: function( event ) {
 780				$( event.currentTarget ).removeClass( "ui-state-hover" );
 781			}
 782		});
 783	},
 784
 785	_focusable: function( element ) {
 786		this.focusable = this.focusable.add( element );
 787		this._on( element, {
 788			focusin: function( event ) {
 789				$( event.currentTarget ).addClass( "ui-state-focus" );
 790			},
 791			focusout: function( event ) {
 792				$( event.currentTarget ).removeClass( "ui-state-focus" );
 793			}
 794		});
 795	},
 796
 797	_trigger: function( type, event, data ) {
 798		var prop, orig,
 799			callback = this.options[ type ];
 800
 801		data = data || {};
 802		event = $.Event( event );
 803		event.type = ( type === this.widgetEventPrefix ?
 804			type :
 805			this.widgetEventPrefix + type ).toLowerCase();
 806		// the original event may come from any element
 807		// so we need to reset the target on the new event
 808		event.target = this.element[ 0 ];
 809
 810		// copy original event properties over to the new event
 811		orig = event.originalEvent;
 812		if ( orig ) {
 813			for ( prop in orig ) {
 814				if ( !( prop in event ) ) {
 815					event[ prop ] = orig[ prop ];
 816				}
 817			}
 818		}
 819
 820		this.element.trigger( event, data );
 821		return !( $.isFunction( callback ) &&
 822			callback.apply( this.element[0], [ event ].concat( data ) ) === false ||
 823			event.isDefaultPrevented() );
 824	}
 825};
 826
 827$.each( { show: "fadeIn", hide: "fadeOut" }, function( method, defaultEffect ) {
 828	$.Widget.prototype[ "_" + method ] = function( element, options, callback ) {
 829		if ( typeof options === "string" ) {
 830			options = { effect: options };
 831		}
 832		var hasOptions,
 833			effectName = !options ?
 834				method :
 835				options === true || typeof options === "number" ?
 836					defaultEffect :
 837					options.effect || defaultEffect;
 838		options = options || {};
 839		if ( typeof options === "number" ) {
 840			options = { duration: options };
 841		}
 842		hasOptions = !$.isEmptyObject( options );
 843		options.complete = callback;
 844		if ( options.delay ) {
 845			element.delay( options.delay );
 846		}
 847		if ( hasOptions && $.effects && ( $.effects.effect[ effectName ] || $.uiBackCompat !== false && $.effects[ effectName ] ) ) {
 848			element[ method ]( options );
 849		} else if ( effectName !== method && element[ effectName ] ) {
 850			element[ effectName ]( options.duration, options.easing, callback );
 851		} else {
 852			element.queue(function( next ) {
 853				$( this )[ method ]();
 854				if ( callback ) {
 855					callback.call( element[ 0 ] );
 856				}
 857				next();
 858			});
 859		}
 860	};
 861});
 862
 863// DEPRECATED
 864if ( $.uiBackCompat !== false ) {
 865	$.Widget.prototype._getCreateOptions = function() {
 866		return $.metadata && $.metadata.get( this.element[0] )[ this.widgetName ];
 867	};
 868}
 869
 870})( jQuery );
 871
 872(function( $, undefined ) {
 873
 874var mouseHandled = false;
 875$( document ).mouseup( function( e ) {
 876	mouseHandled = false;
 877});
 878
 879$.widget("ui.mouse", {
 880	version: "1.9.2",
 881	options: {
 882		cancel: 'input,textarea,button,select,option',
 883		distance: 1,
 884		delay: 0
 885	},
 886	_mouseInit: function() {
 887		var that = this;
 888
 889		this.element
 890			.bind('mousedown.'+this.widgetName, function(event) {
 891				return that._mouseDown(event);
 892			})
 893			.bind('click.'+this.widgetName, function(event) {
 894				if (true === $.data(event.target, that.widgetName + '.preventClickEvent')) {
 895					$.removeData(event.target, that.widgetName + '.preventClickEvent');
 896					event.stopImmediatePropagation();
 897					return false;
 898				}
 899			});
 900
 901		this.started = false;
 902	},
 903
 904	// TODO: make sure destroying one instance of mouse doesn't mess with
 905	// other instances of mouse
 906	_mouseDestroy: function() {
 907		this.element.unbind('.'+this.widgetName);
 908		if ( this._mouseMoveDelegate ) {
 909			$(document)
 910				.unbind('mousemove.'+this.widgetName, this._mouseMoveDelegate)
 911				.unbind('mouseup.'+this.widgetName, this._mouseUpDelegate);
 912		}
 913	},
 914
 915	_mouseDown: function(event) {
 916		// don't let more than one widget handle mouseStart
 917		if( mouseHandled ) { return; }
 918
 919		// we may have missed mouseup (out of window)
 920		(this._mouseStarted && this._mouseUp(event));
 921
 922		this._mouseDownEvent = event;
 923
 924		var that = this,
 925			btnIsLeft = (event.which === 1),
 926			// event.target.nodeName works around a bug in IE 8 with
 927			// disabled inputs (#7620)
 928			elIsCancel = (typeof this.options.cancel === "string" && event.target.nodeName ? $(event.target).closest(this.options.cancel).length : false);
 929		if (!btnIsLeft || elIsCancel || !this._mouseCapture(event)) {
 930			return true;
 931		}
 932
 933		this.mouseDelayMet = !this.options.delay;
 934		if (!this.mouseDelayMet) {
 935			this._mouseDelayTimer = setTimeout(function() {
 936				that.mouseDelayMet = true;
 937			}, this.options.delay);
 938		}
 939
 940		if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
 941			this._mouseStarted = (this._mouseStart(event) !== false);
 942			if (!this._mouseStarted) {
 943				event.preventDefault();
 944				return true;
 945			}
 946		}
 947
 948		// Click event may never have fired (Gecko & Opera)
 949		if (true === $.data(event.target, this.widgetName + '.preventClickEvent')) {
 950			$.removeData(event.target, this.widgetName + '.preventClickEvent');
 951		}
 952
 953		// these delegates are required to keep context
 954		this._mouseMoveDelegate = function(event) {
 955			return that._mouseMove(event);
 956		};
 957		this._mouseUpDelegate = function(event) {
 958			return that._mouseUp(event);
 959		};
 960		$(document)
 961			.bind('mousemove.'+this.widgetName, this._mouseMoveDelegate)
 962			.bind('mouseup.'+this.widgetName, this._mouseUpDelegate);
 963
 964		event.preventDefault();
 965
 966		mouseHandled = true;
 967		return true;
 968	},
 969
 970	_mouseMove: function(event) {
 971		// IE mouseup check - mouseup happened when mouse was out of window
 972		if ($.ui.ie && !(document.documentMode >= 9) && !event.button) {
 973			return this._mouseUp(event);
 974		}
 975
 976		if (this._mouseStarted) {
 977			this._mouseDrag(event);
 978			return event.preventDefault();
 979		}
 980
 981		if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
 982			this._mouseStarted =
 983				(this._mouseStart(this._mouseDownEvent, event) !== false);
 984			(this._mouseStarted ? this._mouseDrag(event) : this._mouseUp(event));
 985		}
 986
 987		return !this._mouseStarted;
 988	},
 989
 990	_mouseUp: function(event) {
 991		$(document)
 992			.unbind('mousemove.'+this.widgetName, this._mouseMoveDelegate)
 993			.unbind('mouseup.'+this.widgetName, this._mouseUpDelegate);
 994
 995		if (this._mouseStarted) {
 996			this._mouseStarted = false;
 997
 998			if (event.target === this._mouseDownEvent.target) {
 999				$.data(event.target, this.widgetName + '.preventClickEvent', true);
1000			}
1001
1002			this._mouseStop(event);
1003		}
1004
1005		return false;
1006	},
1007
1008	_mouseDistanceMet: function(event) {
1009		return (Math.max(
1010				Math.abs(this._mouseDownEvent.pageX - event.pageX),
1011				Math.abs(this._mouseDownEvent.pageY - event.pageY)
1012			) >= this.options.distance
1013		);
1014	},
1015
1016	_mouseDelayMet: function(event) {
1017		return this.mouseDelayMet;
1018	},
1019
1020	// These are placeholder methods, to be overriden by extending plugin
1021	_mouseStart: function(event) {},
1022	_mouseDrag: function(event) {},
1023	_mouseStop: function(event) {},
1024	_mouseCapture: function(event) { return true; }
1025});
1026
1027})(jQuery);
1028
1029(function( $, undefined ) {
1030
1031$.widget("ui.draggable", $.ui.mouse, {
1032	version: "1.9.2",
1033	widgetEventPrefix: "drag",
1034	options: {
1035		addClasses: true,
1036		appendTo: "parent",
1037		axis: false,
1038		connectToSortable: false,
1039		containment: false,
1040		cursor: "auto",
1041		cursorAt: false,
1042		grid: false,
1043		handle: false,
1044		helper: "original",
1045		iframeFix: false,
1046		opacity: false,
1047		refreshPositions: false,
1048		revert: false,
1049		revertDuration: 500,
1050		scope: "default",
1051		scroll: true,
1052		scrollSensitivity: 20,
1053		scrollSpeed: 20,
1054		snap: false,
1055		snapMode: "both",
1056		snapTolerance: 20,
1057		stack: false,
1058		zIndex: false
1059	},
1060	_create: function() {
1061
1062		if (this.options.helper == 'original' && !(/^(?:r|a|f)/).test(this.element.css("position")))
1063			this.element[0].style.position = 'relative';
1064
1065		(this.options.addClasses && this.element.addClass("ui-draggable"));
1066		(this.options.disabled && this.element.addClass("ui-draggable-disabled"));
1067
1068		this._mouseInit();
1069
1070	},
1071
1072	_destroy: function() {
1073		this.element.removeClass( "ui-draggable ui-draggable-dragging ui-draggable-disabled" );
1074		this._mouseDestroy();
1075	},
1076
1077	_mouseCapture: function(event) {
1078
1079		var o = this.options;
1080
1081		// among others, prevent a drag on a resizable-handle
1082		if (this.helper || o.disabled || $(event.target).is('.ui-resizable-handle'))
1083			return false;
1084
1085		//Quit if we're not on a valid handle
1086		this.handle = this._getHandle(event);
1087		if (!this.handle)
1088			return false;
1089
1090		$(o.iframeFix === true ? "iframe" : o.iframeFix).each(function() {
1091			$('<div class="ui-draggable-iframeFix" style="background: #fff;"></div>')
1092			.css({
1093				width: this.offsetWidth+"px", height: this.offsetHeight+"px",
1094				position: "absolute", opacity: "0.001", zIndex: 1000
1095			})
1096			.css($(this).offset())
1097			.appendTo("body");
1098		});
1099
1100		return true;
1101
1102	},
1103
1104	_mouseStart: function(event) {
1105
1106		var o = this.options;
1107
1108		//Create and append the visible helper
1109		this.helper = this._createHelper(event);
1110
1111		this.helper.addClass("ui-draggable-dragging");
1112
1113		//Cache the helper size
1114		this._cacheHelperProportions();
1115
1116		//If ddmanager is used for droppables, set the global draggable
1117		if($.ui.ddmanager)
1118			$.ui.ddmanager.current = this;
1119
1120		/*
1121		 * - Position generation -
1122		 * This block generates everything position related - it's the core of draggables.
1123		 */
1124
1125		//Cache the margins of the original element
1126		this._cacheMargins();
1127
1128		//Store the helper's css position
1129		this.cssPosition = this.helper.css("position");
1130		this.scrollParent = this.helper.scrollParent();
1131
1132		//The element's absolute position on the page minus margins
1133		this.offset = this.positionAbs = this.element.offset();
1134		this.offset = {
1135			top: this.offset.top - this.margins.top,
1136			left: this.offset.left - this.margins.left
1137		};
1138
1139		$.extend(this.offset, {
1140			click: { //Where the click happened, relative to the element
1141				left: event.pageX - this.offset.left,
1142				top: event.pageY - this.offset.top
1143			},
1144			parent: this._getParentOffset(),
1145			relative: this._getRelativeOffset() //This is a relative to absolute position minus the actual position calculation - only used for relative positioned helper
1146		});
1147
1148		//Generate the original position
1149		this.originalPosition = this.position = this._generatePosition(event);
1150		this.originalPageX = event.pageX;
1151		this.originalPageY = event.pageY;
1152
1153		//Adjust the mouse offset relative to the helper if 'cursorAt' is supplied
1154		(o.cursorAt && this._adjustOffsetFromHelper(o.cursorAt));
1155
1156		//Set a containment if given in the options
1157		if(o.containment)
1158			this._setContainment();
1159
1160		//Trigger event + callbacks
1161		if(this._trigger("start", event) === false) {
1162			this._clear();
1163			return false;
1164		}
1165
1166		//Recache the helper size
1167		this._cacheHelperProportions();
1168
1169		//Prepare the droppable offsets
1170		if ($.ui.ddmanager && !o.dropBehaviour)
1171			$.ui.ddmanager.prepareOffsets(this, event);
1172
1173
1174		this._mouseDrag(event, true); //Execute the drag once - this causes the helper not to be visible before getting its correct position
1175
1176		//If the ddmanager is used for droppables, inform the manager that dragging has started (see #5003)
1177		if ( $.ui.ddmanager ) $.ui.ddmanager.dragStart(this, event);
1178
1179		return true;
1180	},
1181
1182	_mouseDrag: function(event, noPropagation) {
1183
1184		//Compute the helpers position
1185		this.position = this._generatePosition(event);
1186		this.positionAbs = this._convertPositionTo("absolute");
1187
1188		//Call plugins and callbacks and use the resulting position if something is returned
1189		if (!noPropagation) {
1190			var ui = this._uiHash();
1191			if(this._trigger('drag', event, ui) === false) {
1192				this._mouseUp({});
1193				return false;
1194			}
1195			this.position = ui.position;
1196		}
1197
1198		if(!this.options.axis || this.options.axis != "y") this.helper[0].style.left = this.position.left+'px';
1199		if(!this.options.axis || this.options.axis != "x") this.helper[0].style.top = this.position.top+'px';
1200		if($.ui.ddmanager) $.ui.ddmanager.drag(this, event);
1201
1202		return false;
1203	},
1204
1205	_mouseStop: function(event) {
1206
1207		//If we are using droppables, inform the manager about the drop
1208		var dropped = false;
1209		if ($.ui.ddmanager && !this.options.dropBehaviour)
1210			dropped = $.ui.ddmanager.drop(this, event);
1211
1212		//if a drop comes from outside (a sortable)
1213		if(this.dropped) {
1214			dropped = this.dropped;
1215			this.dropped = false;
1216		}
1217
1218		//if the original element is no longer in the DOM don't bother to continue (see #8269)
1219		var element = this.element[0], elementInDom = false;
1220		while ( element && (element = element.parentNode) ) {
1221			if (element == document ) {
1222				elementInDom = true;
1223			}
1224		}
1225		if ( !elementInDom && this.options.helper === "original" )
1226			return false;
1227
1228		if((this.options.revert == "invalid" && !dropped) || (this.options.revert == "valid" && dropped) || this.options.revert === true || ($.isFunction(this.options.revert) && this.options.revert.call(this.element, dropped))) {
1229			var that = this;
1230			$(this.helper).animate(this.originalPosition, parseInt(this.options.revertDuration, 10), function() {
1231				if(that._trigger("stop", event) !== false) {
1232					that._clear();
1233				}
1234			});
1235		} else {
1236			if(this._trigger("stop", event) !== false) {
1237				this._clear();
1238			}
1239		}
1240
1241		return false;
1242	},
1243
1244	_mouseUp: function(event) {
1245		//Remove frame helpers
1246		$("div.ui-draggable-iframeFix").each(function() {
1247			this.parentNode.removeChild(this);
1248		});
1249
1250		//If the ddmanager is used for droppables, inform the manager that dragging has stopped (see #5003)
1251		if( $.ui.ddmanager ) $.ui.ddmanager.dragStop(this, event);
1252
1253		return $.ui.mouse.prototype._mouseUp.call(this, event);
1254	},
1255
1256	cancel: function() {
1257
1258		if(this.helper.is(".ui-draggable-dragging")) {
1259			this._mouseUp({});
1260		} else {
1261			this._clear();
1262		}
1263
1264		return this;
1265
1266	},
1267
1268	_getHandle: function(event) {
1269
1270		var handle = !this.options.handle || !$(this.options.handle, this.element).length ? true : false;
1271		$(this.options.handle, this.element)
1272			.find("*")
1273			.andSelf()
1274			.each(function() {
1275				if(this == event.target) handle = true;
1276			});
1277
1278		return handle;
1279
1280	},
1281
1282	_createHelper: function(event) {
1283
1284		var o = this.options;
1285		var helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [event])) : (o.helper == 'clone' ? this.element.clone().removeAttr('id') : this.element);
1286
1287		if(!helper.parents('body').length)
1288			helper.appendTo((o.appendTo == 'parent' ? this.element[0].parentNode : o.appendTo));
1289
1290		if(helper[0] != this.element[0] && !(/(fixed|absolute)/).test(helper.css("position")))
1291			helper.css("position", "absolute");
1292
1293		return helper;
1294
1295	},
1296
1297	_adjustOffsetFromHelper: function(obj) {
1298		if (typeof obj == 'string') {
1299			obj = obj.split(' ');
1300		}
1301		if ($.isArray(obj)) {
1302			obj = {left: +obj[0], top: +obj[1] || 0};
1303		}
1304		if ('left' in obj) {
1305			this.offset.click.left = obj.left + this.margins.left;
1306		}
1307		if ('right' in obj) {
1308			this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
1309		}
1310		if ('top' in obj) {
1311			this.offset.click.top = obj.top + this.margins.top;
1312		}
1313		if ('bottom' in obj) {
1314			this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
1315		}
1316	},
1317
1318	_getParentOffset: function() {
1319
1320		//Get the offsetParent and cache its position
1321		this.offsetParent = this.helper.offsetParent();
1322		var po = this.offsetParent.offset();
1323
1324		// This is a special case where we need to modify a offset calculated on start, since the following happened:
1325		// 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent
1326		// 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that
1327		//    the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag
1328		if(this.cssPosition == 'absolute' && this.scrollParent[0] != document && $.contains(this.scrollParent[0], this.offsetParent[0])) {
1329			po.left += this.scrollParent.scrollLeft();
1330			po.top += this.scrollParent.scrollTop();
1331		}
1332
1333		if((this.offsetParent[0] == document.body) //This needs to be actually done for all browsers, since pageX/pageY includes this information
1334		|| (this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() == 'html' && $.ui.ie)) //Ugly IE fix
1335			po = { top: 0, left: 0 };
1336
1337		return {
1338			top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"),10) || 0),
1339			left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"),10) || 0)
1340		};
1341
1342	},
1343
1344	_getRelativeOffset: function() {
1345
1346		if(this.cssPosition == "relative") {
1347			var p = this.element.position();
1348			return {
1349				top: p.top - (parseInt(this.helper.css("top"),10) || 0) + this.scrollParent.scrollTop(),
1350				left: p.left - (parseInt(this.helper.css("left"),10) || 0) + this.scrollParent.scrollLeft()
1351			};
1352		} else {
1353			return { top: 0, left: 0 };
1354		}
1355
1356	},
1357
1358	_cacheMargins: function() {
1359		this.margins = {
1360			left: (parseInt(this.element.css("marginLeft"),10) || 0),
1361			top: (parseInt(this.element.css("marginTop"),10) || 0),
1362			right: (parseInt(this.element.css("marginRight"),10) || 0),
1363			bottom: (parseInt(this.element.css("marginBottom"),10) || 0)
1364		};
1365	},
1366
1367	_cacheHelperProportions: function() {
1368		this.helperProportions = {
1369			width: this.helper.outerWidth(),
1370			height: this.helper.outerHeight()
1371		};
1372	},
1373
1374	_setContainment: function() {
1375
1376		var o = this.options;
1377		if(o.containment == 'parent') o.containment = this.helper[0].parentNode;
1378		if(o.containment == 'document' || o.containment == 'window') this.containment = [
1379			o.containment == 'document' ? 0 : $(window).scrollLeft() - this.offset.relative.left - this.offset.parent.left,
1380			o.containment == 'document' ? 0 : $(window).scrollTop() - this.offset.relative.top - this.offset.parent.top,
1381			(o.containment == 'document' ? 0 : $(window).scrollLeft()) + $(o.containment == 'document' ? document : window).width() - this.helperProportions.width - this.margins.left,
1382			(o.containment == 'document' ? 0 : $(window).scrollTop()) + ($(o.containment == 'document' ? document : window).height() || document.body.parentNode.scrollHeight) - this.helperProportions.height - this.margins.top
1383		];
1384
1385		if(!(/^(document|window|parent)$/).test(o.containment) && o.containment.constructor != Array) {
1386			var c = $(o.containment);
1387			var ce = c[0]; if(!ce) return;
1388			var co = c.offset();
1389			var over = ($(ce).css("overflow") != 'hidden');
1390
1391			this.containment = [
1392				(parseInt($(ce).css("borderLeftWidth"),10) || 0) + (parseInt($(ce).css("paddingLeft"),10) || 0),
1393				(parseInt($(ce).css("borderTopWidth"),10) || 0) + (parseInt($(ce).css("paddingTop"),10) || 0),
1394				(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 - this.margins.right,
1395				(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  - this.margins.bottom
1396			];
1397			this.relative_container = c;
1398
1399		} else if(o.containment.constructor == Array) {
1400			this.containment = o.containment;
1401		}
1402
1403	},
1404
1405	_convertPositionTo: function(d, pos) {
1406
1407		if(!pos) pos = this.position;
1408		var mod = d == "absolute" ? 1 : -1;
1409		var o = this.options, scroll = this.cssPosition == 'absolute' && !(this.scrollParent[0] != document && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
1410
1411		return {
1412			top: (
1413				pos.top																	// The absolute mouse position
1414				+ this.offset.relative.top * mod										// Only for relative positioned nodes: Relative offset from element to offset parent
1415				+ this.offset.parent.top * mod											// The offsetParent's offset without borders (offset + border)
1416				- ( ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod)
1417			),
1418			left: (
1419				pos.left																// The absolute mouse position
1420				+ this.offset.relative.left * mod										// Only for relative positioned nodes: Relative offset from element to offset parent
1421				+ this.offset.parent.left * mod											// The offsetParent's offset without borders (offset + border)
1422				- ( ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ) * mod)
1423			)
1424		};
1425
1426	},
1427
1428	_generatePosition: function(event) {
1429
1430		var o = this.options, scroll = this.cssPosition == 'absolute' && !(this.scrollParent[0] != document && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
1431		var pageX = event.pageX;
1432		var pageY = event.pageY;
1433
1434		/*
1435		 * - Position constraining -
1436		 * Constrain the position to a mix of grid, containment.
1437		 */
1438
1439		if(this.originalPosition) { //If we are not dragging yet, we won't check for options
1440			var containment;
1441			if(this.containment) {
1442			if (this.relative_container){
1443				var co = this.relative_container.offset();
1444				containment = [ this.containment[0] + co.left,
1445					this.containment[1] + co.top,
1446					this.containment[2] + co.left,
1447					this.containment[3] + co.top ];
1448			}
1449			else {
1450				containment = this.containment;
1451			}
1452
1453				if(event.pageX - this.offset.click.left < containment[0]) pageX = containment[0] + this.offset.click.left;
1454				if(event.pageY - this.offset.click.top < containment[1]) pageY = containment[1] + this.offset.click.top;
1455				if(event.pageX - this.offset.click.left > containment[2]) pageX = containment[2] + this.offset.click.left;
1456				if(event.pageY - this.offset.click.top > containment[3]) pageY = containment[3] + this.offset.click.top;
1457			}
1458
1459			if(o.grid) {
1460				//Check for grid elements set to 0 to prevent divide by 0 error causing invalid argument errors in IE (see ticket #6950)
1461				var top = o.grid[1] ? this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1] : this.originalPageY;
1462				pageY = containment ? (!(top - this.offset.click.top < containment[1] || top - this.offset.click.top > containment[3]) ? top : (!(top - this.offset.click.top < containment[1]) ? top - o.grid[1] : top + o.grid[1])) : top;
1463
1464				var left = o.grid[0] ? this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0] : this.originalPageX;
1465				pageX = containment ? (!(left - this.offset.click.left < containment[0] || left - this.offset.click.left > containment[2]) ? left : (!(left - this.offset.click.left < containment[0]) ? left - o.grid[0] : left + o.grid[0])) : left;
1466			}
1467
1468		}
1469
1470		return {
1471			top: (
1472				pageY																// The absolute mouse position
1473				- this.offset.click.top													// Click offset (relative to the element)
1474				- this.offset.relative.top												// Only for relative positioned nodes: Relative offset from element to offset parent
1475				- this.offset.parent.top												// The offsetParent's offset without borders (offset + border)
1476				+ ( ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ))
1477			),
1478			left: (
1479				pageX																// The absolute mouse position
1480				- this.offset.click.left												// Click offset (relative to the element)
1481				- this.offset.relative.left												// Only for relative positioned nodes: Relative offset from element to offset parent
1482				- this.offset.parent.left												// The offsetParent's offset without borders (offset + border)
1483				+ ( ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ))
1484			)
1485		};
1486
1487	},
1488
1489	_clear: function() {
1490		this.helper.removeClass("ui-draggable-dragging");
1491		if(this.helper[0] != this.element[0] && !this.cancelHelperRemoval) this.helper.remove();
1492		//if($.ui.ddmanager) $.ui.ddmanager.current = null;
1493		this.helper = null;
1494		this.cancelHelperRemoval = false;
1495	},
1496
1497	// From now on bulk stuff - mainly helpers
1498
1499	_trigger: function(type, event, ui) {
1500		ui = ui || this._uiHash();
1501		$.ui.plugin.call(this, type, [event, ui]);
1502		if(type == "drag") this.positionAbs = this._convertPositionTo("absolute"); //The absolute position has to be recalculated after plugins
1503		return $.Widget.prototype._trigger.call(this, type, event, ui);
1504	},
1505
1506	plugins: {},
1507
1508	_uiHash: function(event) {
1509		return {
1510			helper: this.helper,
1511			position: this.position,
1512			originalPosition: this.originalPosition,
1513			offset: this.positionAbs
1514		};
1515	}
1516
1517});
1518
1519$.ui.plugin.add("draggable", "connectToSortable", {
1520	start: function(event, ui) {
1521
1522		var inst = $(this).data("draggable"), o = inst.options,
1523			uiSortable = $.extend({}, ui, { item: inst.element });
1524		inst.sortables = [];
1525		$(o.connectToSortable).each(function() {
1526			var sortable = $.data(this, 'sortable');
1527			if (sortable && !sortable.options.disabled) {
1528				inst.sortables.push({
1529					instance: sortable,
1530					shouldRevert: sortable.options.revert
1531				});
1532				sortable.refreshPositions();	// Call the sortable's refreshPositions at drag start to refresh the containerCache since the sortable container cache is used in drag and needs to be up to date (this will ensure it's initialised as well as being kept in step with any changes that might have happened on the page).
1533				sortable._trigger("activate", event, uiSortable);
1534			}
1535		});
1536
1537	},
1538	stop: function(event, ui) {
1539
1540		//If we are still over the sortable, we fake the stop event of the sortable, but also remove helper
1541		var inst = $(this).data("draggable"),
1542			uiSortable = $.extend({}, ui, { item: inst.element });
1543
1544		$.each(inst.sortables, function() {
1545			if(this.instance.isOver) {
1546
1547				this.instance.isOver = 0;
1548
1549				inst.cancelHelperRemoval = true; //Don't remove the helper in the draggable instance
1550				this.instance.cancelHelperRemoval = false; //Remove it in the sortable instance (so sortable plugins like revert still work)
1551
1552				//The sortable revert is supported, and we have to set a temporary dropped variable on the draggable to support revert: 'valid/invalid'
1553				if(this.shouldRevert) this.instance.options.revert = true;
1554
1555				//Trigger the stop of the sortable
1556				this.instance._mouseStop(event);
1557
1558				this.instance.options.helper = this.instance.options._helper;
1559
1560				//If the helper has been the original item, restore properties in the sortable
1561				if(inst.options.helper == 'original')
1562					this.instance.currentItem.css({ top: 'auto', left: 'auto' });
1563
1564			} else {
1565				this.instance.cancelHelperRemoval = false; //Remove the helper in the sortable instance
1566				this.instance._trigger("deactivate", event, uiSortable);
1567			}
1568
1569		});
1570
1571	},
1572	drag: function(event, ui) {
1573
1574		var inst = $(this).data("draggable"), that = this;
1575
1576		var checkPos = function(o) {
1577			var dyClick = this.offset.click.top, dxClick = this.offset.click.left;
1578			var helperTop = this.positionAbs.top, helperLeft = this.positionAbs.left;
1579			var itemHeight = o.height, itemWidth = o.width;
1580			var itemTop = o.top, itemLeft = o.left;
1581
1582			return $.ui.isOver(helperTop + dyClick, helperLeft + dxClick, itemTop, itemLeft, itemHeight, itemWidth);
1583		};
1584
1585		$.each(inst.sortables, function(i) {
1586
1587			var innermostIntersecting = false;
1588			var thisSortable = this;
1589			//Copy over some variables to allow calling the sortable's native _intersectsWith
1590			this.instance.positionAbs = inst.positionAbs;
1591			this.instance.helperProportions = inst.helperProportions;
1592			this.instance.offset.click = inst.offset.click;
1593
1594			if(this.instance._intersectsWith(this.instance.containerCache)) {
1595				innermostIntersecting = true;
1596				$.each(inst.sortables, function () {
1597					this.instance.positionAbs = inst.positionAbs;
1598					this.instance.helperProportions = inst.helperProportions;
1599					this.inst

Large files files are truncated, but you can click here to view the full file