JavaScript Page /Include/jquery-ui.js (VB.NET)
1: /*! jQuery UI - v1.9.0 - 2012-10-05
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:
8: var 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 || {};
15: if ( $.ui.version ) {
16:     return;
17: }
18:
19: $.extend( $.ui, {
20:     version: "1.9.0",
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 (($.browser.msie && (/(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: // support: jQuery <1.8
127: if ( !$( "<a>" ).outerWidth( 1 ).jquery ) {
128:     $.each( [ "Width", "Height" ], function( i, name ) {
129:         var side = name === "Width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ],
130:             type = name.toLowerCase(),
131:             orig = {
132:                 innerWidth: $.fn.innerWidth,
133:                 innerHeight: $.fn.innerHeight,
134:                 outerWidth: $.fn.outerWidth,
135:                 outerHeight: $.fn.outerHeight
136:             };
137:
138:         function reduce( elem, size, border, margin ) {
139:             $.each( side, function() {
140:                 size -= parseFloat( $.css( elem, "padding" + this ) ) || 0;
141:                 if ( border ) {
142:                     size -= parseFloat( $.css( elem, "border" + this + "Width" ) ) || 0;
143:                 }
144:                 if ( margin ) {
145:                     size -= parseFloat( $.css( elem, "margin" + this ) ) || 0;
146:                 }
147:             });
148:             return size;
149:         }
150:
151:         $.fn[ "inner" + name ] = function( size ) {
152:             if ( size === undefined ) {
153:                 return orig[ "inner" + name ].call( this );
154:             }
155:
156:             return this.each(function() {
157:                 $( this ).css( type, reduce( this, size ) + "px" );
158:             });
159:         };
160:
161:         $.fn[ "outer" + name] = function( size, margin ) {
162:             if ( typeof size !== "number" ) {
163:                 return orig[ "outer" + name ].call( this, size );
164:             }
165:
166:             return this.each(function() {
167:                 $( this).css( type, reduce( this, size, true, margin ) + "px" );
168:             });
169:         };
170:     });
171: }
172:
173: // selectors
174: function focusable( element, isTabIndexNotNaN ) {
175:     var map, mapName, img,
176:         nodeName = element.nodeName.toLowerCase();
177:     if ( "area" === nodeName ) {
178:         map = element.parentNode;
179:         mapName = map.name;
180:         if ( !element.href || !mapName || map.nodeName.toLowerCase() !== "map" ) {
181:             return false;
182:         }
183:         img = $( "img[usemap=#" + mapName + "]" )[0];
184:         return !!img && visible( img );
185:     }
186:     return ( /input|select|textarea|button|object/.test( nodeName ) ?
187:         !element.disabled :
188:         "a" === nodeName ?
189:             element.href || isTabIndexNotNaN :
190:             isTabIndexNotNaN) &&
191:         // the element and all of its ancestors must be visible
192:         visible( element );
193: }
194:
195: function visible( element ) {
196:     return !$( element ).parents().andSelf().filter(function() {
197:         return $.css( this, "visibility" ) === "hidden" ||
198:             $.expr.filters.hidden( this );
199:     }).length;
200: }
201:
202: $.extend( $.expr[ ":" ], {
203:     data: $.expr.createPseudo ?
204:         $.expr.createPseudo(function( dataName ) {
205:             return function( elem ) {
206:                 return !!$.data( elem, dataName );
207:             };
208:         }) :
209:         // support: jQuery <1.8
210:         function( elem, i, match ) {
211:             return !!$.data( elem, match[ 3 ] );
212:         },
213:
214:     focusable: function( element ) {
215:         return focusable( element, !isNaN( $.attr( element, "tabindex" ) ) );
216:     },
217:
218:     tabbable: function( element ) {
219:         var tabIndex = $.attr( element, "tabindex" ),
220:             isTabIndexNaN = isNaN( tabIndex );
221:         return ( isTabIndexNaN || tabIndex >= 0 ) && focusable( element, !isTabIndexNaN );
222:     }
223: });
224:
225: // support
226: $(function() {
227:     var body = document.body,
228:         div = body.appendChild( div = document.createElement( "div" ) );
229:
230:     // access offsetHeight before setting the style to prevent a layout bug
231:     // in IE 9 which causes the element to continue to take up space even
232:     // after it is removed from the DOM (#8026)
233:     div.offsetHeight;
234:
235:     $.extend( div.style, {
236:         minHeight: "100px",
237:         height: "auto",
238:         padding: 0,
239:         borderWidth: 0
240:     });
241:
242:     $.support.minHeight = div.offsetHeight === 100;
243:     $.support.selectstart = "onselectstart" in div;
244:
245:     // set display to none to avoid a layout bug in IE
246:     // http://dev.jquery.com/ticket/4014
247:     body.removeChild( div ).style.display = "none";
248: });
249:
250:
251:
252:
253:
254: // deprecated
255:
256: $.fn.extend({
257:     disableSelection: function() {
258:         return this.bind( ( $.support.selectstart ? "selectstart" : "mousedown" ) +
259:             ".ui-disableSelection", function( event ) {
260:                 event.preventDefault();
261:             });
262:     },
263:
264:     enableSelection: function() {
265:         return this.unbind( ".ui-disableSelection" );
266:     }
267: });
268:
269: $.extend( $.ui, {
270:     // $.ui.plugin is deprecated. Use the proxy pattern instead.
271:     plugin: {
272:         add: function( module, option, set ) {
273:             var i,
274:                 proto = $.ui[ module ].prototype;
275:             for ( i in set ) {
276:                 proto.plugins[ i ] = proto.plugins[ i ] || [];
277:                 proto.plugins[ i ].push( [ option, set[ i ] ] );
278:             }
279:         },
280:         call: function( instance, name, args ) {
281:             var i,
282:                 set = instance.plugins[ name ];
283:             if ( !set || !instance.element[ 0 ].parentNode || instance.element[ 0 ].parentNode.nodeType === 11 ) {
284:                 return;
285:             }
286:
287:             for ( i = 0; i < set.length; i++ ) {
288:                 if ( instance.options[ set[ i ][ 0 ] ] ) {
289:                     set[ i ][ 1 ].apply( instance.element, args );
290:                 }
291:             }
292:         }
293:     },
294:
295:     contains: $.contains,
296:
297:     // only used by resizable
298:     hasScroll: function( el, a ) {
299:
300:         //If overflow is hidden, the element might have extra content, but the user wants to hide it
301:         if ( $( el ).css( "overflow" ) === "hidden") {
302:             return false;
303:         }
304:
305:         var scroll = ( a && a === "left" ) ? "scrollLeft" : "scrollTop",
306:             has = false;
307:
308:         if ( el[ scroll ] > 0 ) {
309:             return true;
310:         }
311:
312:         // TODO: determine which cases actually cause this to happen
313:         // if the element doesn't have the scroll set, see if it's possible to
314:         // set the scroll
315:         el[ scroll ] = 1;
316:         has = ( el[ scroll ] > 0 );
317:         el[ scroll ] = 0;
318:         return has;
319:     },
320:
321:     // these are odd functions, fix the API or move into individual plugins
322:     isOverAxis: function( x, reference, size ) {
323:         //Determines when x coordinate is over "b" element axis
324:         return ( x > reference ) && ( x < ( reference + size ) );
325:     },
326:     isOver: function( y, x, top, left, height, width ) {
327:         //Determines when x, y coordinates is over "b" element
328:         return $.ui.isOverAxis( y, top, height ) && $.ui.isOverAxis( x, left, width );
329:     }
330: });
331:
332: })( jQuery );
333:
334: (function( $, undefined ) {
335:
336: var uuid = 0,
337:     slice = Array.prototype.slice,
338:     _cleanData = $.cleanData;
339: $.cleanData = function( elems ) {
340:     for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {
341:         try {
342:             $( elem ).triggerHandler( "remove" );
343:         // http://bugs.jquery.com/ticket/8235
344:         } catch( e ) {}
345:     }
346:     _cleanData( elems );
347: };
348:
349: $.widget = function( name, base, prototype ) {
350:     var fullName, existingConstructor, constructor, basePrototype,
351:         namespace = name.split( "." )[ 0 ];
352:
353:     name = name.split( "." )[ 1 ];
354:     fullName = namespace + "-" + name;
355:
356:     if ( !prototype ) {
357:         prototype = base;
358:         base = $.Widget;
359:     }
360:
361:     // create selector for plugin
362:     $.expr[ ":" ][ fullName.toLowerCase() ] = function( elem ) {
363:         return !!$.data( elem, fullName );
364:     };
365:
366:     $[ namespace ] = $[ namespace ] || {};
367:     existingConstructor = $[ namespace ][ name ];
368:     constructor = $[ namespace ][ name ] = function( options, element ) {
369:         // allow instantiation without "new" keyword
370:         if ( !this._createWidget ) {
371:             return new constructor( options, element );
372:         }
373:
374:         // allow instantiation without initializing for simple inheritance
375:         // must use "new" keyword (the code above always passes args)
376:         if ( arguments.length ) {
377:             this._createWidget( options, element );
378:         }
379:     };
380:     // extend with the existing constructor to carry over any static properties
381:     $.extend( constructor, existingConstructor, {
382:         version: prototype.version,
383:         // copy the object used to create the prototype in case we need to
384:         // redefine the widget later
385:         _proto: $.extend( {}, prototype ),
386:         // track widgets that inherit from this widget in case this widget is
387:         // redefined after a widget inherits from it
388:         _childConstructors: []
389:     });
390:
391:     basePrototype = new base();
392:     // we need to make the options hash a property directly on the new instance
393:     // otherwise we'll modify the options hash on the prototype that we're
394:     // inheriting from
395:     basePrototype.options = $.widget.extend( {}, basePrototype.options );
396:     $.each( prototype, function( prop, value ) {
397:         if ( $.isFunction( value ) ) {
398:             prototype[ prop ] = (function() {
399:                 var _super = function() {
400:                         return base.prototype[ prop ].apply( this, arguments );
401:                     },
402:                     _superApply = function( args ) {
403:                         return base.prototype[ prop ].apply( this, args );
404:                     };
405:                 return function() {
406:                     var __super = this._super,
407:                         __superApply = this._superApply,
408:                         returnValue;
409:
410:                     this._super = _super;
411:                     this._superApply = _superApply;
412:
413:                     returnValue = value.apply( this, arguments );
414:
415:                     this._super = __super;
416:                     this._superApply = __superApply;
417:
418:                     return returnValue;
419:                 };
420:             })();
421:         }
422:     });
423:     constructor.prototype = $.widget.extend( basePrototype, {
424:         // TODO: remove support for widgetEventPrefix
425:         // always use the name + a colon as the prefix, e.g., draggable:start
426:         // don't prefix for widgets that aren't DOM-based
427:         widgetEventPrefix: name
428:     }, prototype, {
429:         constructor: constructor,
430:         namespace: namespace,
431:         widgetName: name,
432:         // TODO remove widgetBaseClass, see #8155
433:         widgetBaseClass: fullName,
434:         widgetFullName: fullName
435:     });
436:
437:     // If this widget is being redefined then we need to find all widgets that
438:     // are inheriting from it and redefine all of them so that they inherit from
439:     // the new version of this widget. We're essentially trying to replace one
440:     // level in the prototype chain.
441:     if ( existingConstructor ) {
442:         $.each( existingConstructor._childConstructors, function( i, child ) {
443:             var childPrototype = child.prototype;
444:
445:             // redefine the child widget using the same prototype that was
446:             // originally used, but inherit from the new version of the base
447:             $.widget( childPrototype.namespace + "." + childPrototype.widgetName, constructor, child._proto );
448:         });
449:         // remove the list of existing child constructors from the old constructor
450:         // so the old child constructors can be garbage collected
451:         delete existingConstructor._childConstructors;
452:     } else {
453:         base._childConstructors.push( constructor );
454:     }
455:
456:     $.widget.bridge( name, constructor );
457: };
458:
459: $.widget.extend = function( target ) {
460:     var input = slice.call( arguments, 1 ),
461:         inputIndex = 0,
462:         inputLength = input.length,
463:         key,
464:         value;
465:     for ( ; inputIndex < inputLength; inputIndex++ ) {
466:         for ( key in input[ inputIndex ] ) {
467:             value = input[ inputIndex ][ key ];
468:             if (input[ inputIndex ].hasOwnProperty( key ) && value !== undefined ) {
469:                 target[ key ] = $.isPlainObject( value ) ? $.widget.extend( {}, target[ key ], value ) : value;
470:             }
471:         }
472:     }
473:     return target;
474: };
475:
476: $.widget.bridge = function( name, object ) {
477:     var fullName = object.prototype.widgetFullName;
478:     $.fn[ name ] = function( options ) {
479:         var isMethodCall = typeof options === "string",
480:             args = slice.call( arguments, 1 ),
481:             returnValue = this;
482:
483:         // allow multiple hashes to be passed on init
484:         options = !isMethodCall && args.length ?
485:             $.widget.extend.apply( null, [ options ].concat(args) ) :
486:             options;
487:
488:         if ( isMethodCall ) {
489:             this.each(function() {
490:                 var methodValue,
491:                     instance = $.data( this, fullName );
492:                 if ( !instance ) {
493:                     return $.error( "cannot call methods on " + name + " prior to initialization; " +
494:                         "attempted to call method '" + options + "'" );
495:                 }
496:                 if ( !$.isFunction( instance[options] ) || options.charAt( 0 ) === "_" ) {
497:                     return $.error( "no such method '" + options + "' for " + name + " widget instance" );
498:                 }
499:                 methodValue = instance[ options ].apply( instance, args );
500:                 if ( methodValue !== instance && methodValue !== undefined ) {
501:                     returnValue = methodValue && methodValue.jquery ?
502:                         returnValue.pushStack( methodValue.get() ) :
503:                         methodValue;
504:                     return false;
505:                 }
506:             });
507:         } else {
508:             this.each(function() {
509:                 var instance = $.data( this, fullName );
510:                 if ( instance ) {
511:                     instance.option( options || {} )._init();
512:                 } else {
513:                     new object( options, this );
514:                 }
515:             });
516:         }
517:
518:         return returnValue;
519:     };
520: };
521:
522: $.Widget = function( options, element ) {};
523: $.Widget._childConstructors = [];
524:
525: $.Widget.prototype = {
526:     widgetName: "widget",
527:     widgetEventPrefix: "",
528:     defaultElement: "<div>",
529:     options: {
530:         disabled: false,
531:
532:         // callbacks
533:         create: null
534:     },
535:     _createWidget: function( options, element ) {
536:         element = $( element || this.defaultElement || this )[ 0 ];
537:         this.element = $( element );
538:         this.uuid = uuid++;
539:         this.eventNamespace = "." + this.widgetName + this.uuid;
540:         this.options = $.widget.extend( {},
541:             this.options,
542:             this._getCreateOptions(),
543:             options );
544:
545:         this.bindings = $();
546:         this.hoverable = $();
547:         this.focusable = $();
548:
549:         if ( element !== this ) {
550:             // 1.9 BC for #7810
551:             // TODO remove dual storage
552:             $.data( element, this.widgetName, this );
553:             $.data( element, this.widgetFullName, this );
554:             this._on({ remove: "destroy" });
555:             this.document = $( element.style ?
556:                 // element within the document
557:                 element.ownerDocument :
558:                 // element is window or document
559:                 element.document || element );
560:             this.window = $( this.document[0].defaultView || this.document[0].parentWindow );
561:         }
562:
563:         this._create();
564:         this._trigger( "create", null, this._getCreateEventData() );
565:         this._init();
566:     },
567:     _getCreateOptions: $.noop,
568:     _getCreateEventData: $.noop,
569:     _create: $.noop,
570:     _init: $.noop,
571:
572:     destroy: function() {
573:         this._destroy();
574:         // we can probably remove the unbind calls in 2.0
575:         // all event bindings should go through this._on()
576:         this.element
577:             .unbind( this.eventNamespace )
578:             // 1.9 BC for #7810
579:             // TODO remove dual storage
580:             .removeData( this.widgetName )
581:             .removeData( this.widgetFullName )
582:             // support: jquery <1.6.3
583:             // http://bugs.jquery.com/ticket/9413
584:             .removeData( $.camelCase( this.widgetFullName ) );
585:         this.widget()
586:             .unbind( this.eventNamespace )
587:             .removeAttr( "aria-disabled" )
588:             .removeClass(
589:                 this.widgetFullName + "-disabled " +
590:                 "ui-state-disabled" );
591:
592:         // clean up events and states
593:         this.bindings.unbind( this.eventNamespace );
594:         this.hoverable.removeClass( "ui-state-hover" );
595:         this.focusable.removeClass( "ui-state-focus" );
596:     },
597:     _destroy: $.noop,
598:
599:     widget: function() {
600:         return this.element;
601:     },
602:
603:     option: function( key, value ) {
604:         var options = key,
605:             parts,
606:             curOption,
607:             i;
608:
609:         if ( arguments.length === 0 ) {
610:             // don't return a reference to the internal hash
611:             return $.widget.extend( {}, this.options );
612:         }
613:
614:         if ( typeof key === "string" ) {
615:             // handle nested keys, e.g., "foo.bar" => { foo: { bar: ___ } }
616:             options = {};
617:             parts = key.split( "." );
618:             key = parts.shift();
619:             if ( parts.length ) {
620:                 curOption = options[ key ] = $.widget.extend( {}, this.options[ key ] );
621:                 for ( i = 0; i < parts.length - 1; i++ ) {
622:                     curOption[ parts[ i ] ] = curOption[ parts[ i ] ] || {};
623:                     curOption = curOption[ parts[ i ] ];
624:                 }
625:                 key = parts.pop();
626:                 if ( value === undefined ) {
627:                     return curOption[ key ] === undefined ? null : curOption[ key ];
628:                 }
629:                 curOption[ key ] = value;
630:             } else {
631:                 if ( value === undefined ) {
632:                     return this.options[ key ] === undefined ? null : this.options[ key ];
633:                 }
634:                 options[ key ] = value;
635:             }
636:         }
637:
638:         this._setOptions( options );
639:
640:         return this;
641:     },
642:     _setOptions: function( options ) {
643:         var key;
644:
645:         for ( key in options ) {
646:             this._setOption( key, options[ key ] );
647:         }
648:
649:         return this;
650:     },
651:     _setOption: function( key, value ) {
652:         this.options[ key ] = value;
653:
654:         if ( key === "disabled" ) {
655:             this.widget()
656:                 .toggleClass( this.widgetFullName + "-disabled ui-state-disabled", !!value )
657:                 .attr( "aria-disabled", value );
658:             this.hoverable.removeClass( "ui-state-hover" );
659:             this.focusable.removeClass( "ui-state-focus" );
660:         }
661:
662:         return this;
663:     },
664:
665:     enable: function() {
666:         return this._setOption( "disabled", false );
667:     },
668:     disable: function() {
669:         return this._setOption( "disabled", true );
670:     },
671:
672:     _on: function( element, handlers ) {
673:         // no element argument, shuffle and use this.element
674:         if ( !handlers ) {
675:             handlers = element;
676:             element = this.element;
677:         } else {
678:             // accept selectors, DOM elements
679:             element = $( element );
680:             this.bindings = this.bindings.add( element );
681:         }
682:
683:         var instance = this;
684:         $.each( handlers, function( event, handler ) {
685:             function handlerProxy() {
686:                 // allow widgets to customize the disabled handling
687:                 // - disabled as an array instead of boolean
688:                 // - disabled class as method for disabling individual parts
689:                 if ( instance.options.disabled === true ||
690:                         $( this ).hasClass( "ui-state-disabled" ) ) {
691:                     return;
692:                 }
693:                 return ( typeof handler === "string" ? instance[ handler ] : handler )
694:                     .apply( instance, arguments );
695:             }
696:
697:             // copy the guid so direct unbinding works
698:             if ( typeof handler !== "string" ) {
699:                 handlerProxy.guid = handler.guid =
700:                     handler.guid || handlerProxy.guid || $.guid++;
701:             }
702:
703:             var match = event.match( /^(\w+)\s*(.*)$/ ),
704:                 eventName = match[1] + instance.eventNamespace,
705:                 selector = match[2];
706:             if ( selector ) {
707:                 instance.widget().delegate( selector, eventName, handlerProxy );
708:             } else {
709:                 element.bind( eventName, handlerProxy );
710:             }
711:         });
712:     },
713:
714:     _off: function( element, eventName ) {
715:         eventName = (eventName || "").split( " " ).join( this.eventNamespace + " " ) + this.eventNamespace;
716:         element.unbind( eventName ).undelegate( eventName );
717:     },
718:
719:     _delay: function( handler, delay ) {
720:         function handlerProxy() {
721:             return ( typeof handler === "string" ? instance[ handler ] : handler )
722:                 .apply( instance, arguments );
723:         }
724:         var instance = this;
725:         return setTimeout( handlerProxy, delay || 0 );
726:     },
727:
728:     _hoverable: function( element ) {
729:         this.hoverable = this.hoverable.add( element );
730:         this._on( element, {
731:             mouseenter: function( event ) {
732:                 $( event.currentTarget ).addClass( "ui-state-hover" );
733:             },
734:             mouseleave: function( event ) {
735:                 $( event.currentTarget ).removeClass( "ui-state-hover" );
736:             }
737:         });
738:     },
739:
740:     _focusable: function( element ) {
741:         this.focusable = this.focusable.add( element );
742:         this._on( element, {
743:             focusin: function( event ) {
744:                 $( event.currentTarget ).addClass( "ui-state-focus" );
745:             },
746:             focusout: function( event ) {
747:                 $( event.currentTarget ).removeClass( "ui-state-focus" );
748:             }
749:         });
750:     },
751:
752:     _trigger: function( type, event, data ) {
753:         var prop, orig,
754:             callback = this.options[ type ];
755:
756:         data = data || {};
757:         event = $.Event( event );
758:         event.type = ( type === this.widgetEventPrefix ?
759:             type :
760:             this.widgetEventPrefix + type ).toLowerCase();
761:         // the original event may come from any element
762:         // so we need to reset the target on the new event
763:         event.target = this.element[ 0 ];
764:
765:         // copy original event properties over to the new event
766:         orig = event.originalEvent;
767:         if ( orig ) {
768:             for ( prop in orig ) {
769:                 if ( !( prop in event ) ) {
770:                     event[ prop ] = orig[ prop ];
771:                 }
772:             }
773:         }
774:
775:         this.element.trigger( event, data );
776:         return !( $.isFunction( callback ) &&
777:             callback.apply( this.element[0], [ event ].concat( data ) ) === false ||
778:             event.isDefaultPrevented() );
779:     }
780: };
781:
782: $.each( { show: "fadeIn", hide: "fadeOut" }, function( method, defaultEffect ) {
783:     $.Widget.prototype[ "_" + method ] = function( element, options, callback ) {
784:         if ( typeof options === "string" ) {
785:             options = { effect: options };
786:         }
787:         var hasOptions,
788:             effectName = !options ?
789:                 method :
790:                 options === true || typeof options === "number" ?
791:                     defaultEffect :
792:                     options.effect || defaultEffect;
793:         options = options || {};
794:         if ( typeof options === "number" ) {
795:             options = { duration: options };
796:         }
797:         hasOptions = !$.isEmptyObject( options );
798:         options.complete = callback;
799:         if ( options.delay ) {
800:             element.delay( options.delay );
801:         }
802:         if ( hasOptions && $.effects && ( $.effects.effect[ effectName ] || $.uiBackCompat !== false && $.effects[ effectName ] ) ) {
803:             element[ method ]( options );
804:         } else if ( effectName !== method && element[ effectName ] ) {
805:             element[ effectName ]( options.duration, options.easing, callback );
806:         } else {
807:             element.queue(function( next ) {
808:                 $( this )[ method ]();
809:                 if ( callback ) {
810:                     callback.call( element[ 0 ] );
811:                 }
812:                 next();
813:             });
814:         }
815:     };
816: });
817:
818: // DEPRECATED
819: if ( $.uiBackCompat !== false ) {
820:     $.Widget.prototype._getCreateOptions = function() {
821:         return $.metadata && $.metadata.get( this.element[0] )[ this.widgetName ];
822:     };
823: }
824:
825: })( jQuery );
826:
827: (function( $, undefined ) {
828:
829: var mouseHandled = false;
830: $( document ).mouseup( function( e ) {
831:     mouseHandled = false;
832: });
833:
834: $.widget("ui.mouse", {
835:     version: "1.9.0",
836:     options: {
837:         cancel: 'input,textarea,button,select,option',
838:         distance: 1,
839:         delay: 0
840:     },
841:     _mouseInit: function() {
842:         var that = this;
843:
844:         this.element
845:             .bind('mousedown.'+this.widgetName, function(event) {
846:                 return that._mouseDown(event);
847:             })
848:             .bind('click.'+this.widgetName, function(event) {
849:                 if (true === $.data(event.target, that.widgetName + '.preventClickEvent')) {
850:                     $.removeData(event.target, that.widgetName + '.preventClickEvent');
851:                     event.stopImmediatePropagation();
852:                     return false;
853:                 }
854:             });
855:
856:         this.started = false;
857:     },
858:
859:     // TODO: make sure destroying one instance of mouse doesn't mess with
860:     // other instances of mouse
861:     _mouseDestroy: function() {
862:         this.element.unbind('.'+this.widgetName);
863:         if ( this._mouseMoveDelegate ) {
864:             $(document)
865:                 .unbind('mousemove.'+this.widgetName, this._mouseMoveDelegate)
866:                 .unbind('mouseup.'+this.widgetName, this._mouseUpDelegate);
867:         }
868:     },
869:
870:     _mouseDown: function(event) {
871:         // don't let more than one widget handle mouseStart
872:         if( mouseHandled ) { return; }
873:
874:         // we may have missed mouseup (out of window)
875:         (this._mouseStarted && this._mouseUp(event));
876:
877:         this._mouseDownEvent = event;
878:
879:         var that = this,
880:             btnIsLeft = (event.which === 1),
881:             // event.target.nodeName works around a bug in IE 8 with
882:             // disabled inputs (#7620)
883:             elIsCancel = (typeof this.options.cancel === "string" && event.target.nodeName ? $(event.target).closest(this.options.cancel).length : false);
884:         if (!btnIsLeft || elIsCancel || !this._mouseCapture(event)) {
885:             return true;
886:         }
887:
888:         this.mouseDelayMet = !this.options.delay;
889:         if (!this.mouseDelayMet) {
890:             this._mouseDelayTimer = setTimeout(function() {
891:                 that.mouseDelayMet = true;
892:             }, this.options.delay);
893:         }
894:
895:         if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
896:             this._mouseStarted = (this._mouseStart(event) !== false);
897:             if (!this._mouseStarted) {
898:                 event.preventDefault();
899:                 return true;
900:             }
901:         }
902:
903:         // Click event may never have fired (Gecko & Opera)
904:         if (true === $.data(event.target, this.widgetName + '.preventClickEvent')) {
905:             $.removeData(event.target, this.widgetName + '.preventClickEvent');
906:         }
907:
908:         // these delegates are required to keep context
909:         this._mouseMoveDelegate = function(event) {
910:             return that._mouseMove(event);
911:         };
912:         this._mouseUpDelegate = function(event) {
913:             return that._mouseUp(event);
914:         };
915:         $(document)
916:             .bind('mousemove.'+this.widgetName, this._mouseMoveDelegate)
917:             .bind('mouseup.'+this.widgetName, this._mouseUpDelegate);
918:
919:         event.preventDefault();
920:         
921:         mouseHandled = true;
922:         return true;
923:     },
924:
925:     _mouseMove: function(event) {
926:         // IE mouseup check - mouseup happened when mouse was out of window
927:         if ($.browser.msie && !(document.documentMode >= 9) && !event.button) {
928:             return this._mouseUp(event);
929:         }
930:
931:         if (this._mouseStarted) {
932:             this._mouseDrag(event);
933:             return event.preventDefault();
934:         }
935:
936:         if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
937:             this._mouseStarted =
938:                 (this._mouseStart(this._mouseDownEvent, event) !== false);
939:             (this._mouseStarted ? this._mouseDrag(event) : this._mouseUp(event));
940:         }
941:
942:         return !this._mouseStarted;
943:     },
944:
945:     _mouseUp: function(event) {
946:         $(document)
947:             .unbind('mousemove.'+this.widgetName, this._mouseMoveDelegate)
948:             .unbind('mouseup.'+this.widgetName, this._mouseUpDelegate);
949:
950:         if (this._mouseStarted) {
951:             this._mouseStarted = false;
952:
953:             if (event.target === this._mouseDownEvent.target) {
954:                 $.data(event.target, this.widgetName + '.preventClickEvent', true);
955:             }
956:
957:             this._mouseStop(event);
958:         }
959:
960:         return false;
961:     },
962:
963:     _mouseDistanceMet: function(event) {
964:         return (Math.max(
965:                 Math.abs(this._mouseDownEvent.pageX - event.pageX),
966:                 Math.abs(this._mouseDownEvent.pageY - event.pageY)
967:             ) >= this.options.distance
968:         );
969:     },
970:
971:     _mouseDelayMet: function(event) {
972:         return this.mouseDelayMet;
973:     },
974:
975:     // These are placeholder methods, to be overriden by extending plugin
976:     _mouseStart: function(event) {},
977:     _mouseDrag: function(event) {},
978:     _mouseStop: function(event) {},
979:     _mouseCapture: function(event) { return true; }
980: });
981:
982: })(jQuery);
983:
984: (function( $, undefined ) {
985:
986: $.widget("ui.draggable", $.ui.mouse, {
987:     version: "1.9.0",
988:     widgetEventPrefix: "drag",
989:     options: {
990:         addClasses: true,
991:         appendTo: "parent",
992:         axis: false,
993:         connectToSortable: false,
994:         containment: false,
995:         cursor: "auto",
996:         cursorAt: false,
997:         grid: false,
998:         handle: false,
999:         helper: "original",
1000:         iframeFix: false,
1001:         opacity: false,
1002:         refreshPositions: false,
1003:         revert: false,
1004:         revertDuration: 500,
1005:         scope: "default",
1006:         scroll: true,
1007:         scrollSensitivity: 20,
1008:         scrollSpeed: 20,
1009:         snap: false,
1010:         snapMode: "both",
1011:         snapTolerance: 20,
1012:         stack: false,
1013:         zIndex: false
1014:     },
1015:     _create: function() {
1016:
1017:         if (this.options.helper == 'original' && !(/^(?:r|a|f)/).test(this.element.css("position")))
1018:             this.element[0].style.position = 'relative';
1019:
1020:         (this.options.addClasses && this.element.addClass("ui-draggable"));
1021:         (this.options.disabled && this.element.addClass("ui-draggable-disabled"));
1022:
1023:         this._mouseInit();
1024:
1025:     },
1026:
1027:     _destroy: function() {
1028:         this.element.removeClass( "ui-draggable ui-draggable-dragging ui-draggable-disabled" );
1029:         this._mouseDestroy();
1030:     },
1031:
1032:     _mouseCapture: function(event) {
1033:
1034:         var o = this.options;
1035:
1036:         // among others, prevent a drag on a resizable-handle
1037:         if (this.helper || o.disabled || $(event.target).is('.ui-resizable-handle'))
1038:             return false;
1039:
1040:         //Quit if we're not on a valid handle
1041:         this.handle = this._getHandle(event);
1042:         if (!this.handle)
1043:             return false;
1044:         
1045:         $(o.iframeFix === true ? "iframe" : o.iframeFix).each(function() {
1046:             $('<div class="ui-draggable-iframeFix" style="background: #fff;"></div>')
1047:             .css({
1048:                 width: this.offsetWidth+"px", height: this.offsetHeight+"px",
1049:                 position: "absolute", opacity: "0.001", zIndex: 1000
1050:             })
1051:             .css($(this).offset())
1052:             .appendTo("body");
1053:         });
1054:
1055:         return true;
1056:
1057:     },
1058:
1059:     _mouseStart: function(event) {
1060:
1061:         var o = this.options;
1062:
1063:         //Create and append the visible helper
1064:         this.helper = this._createHelper(event);
1065:
1066:         this.helper.addClass("ui-draggable-dragging");
1067:
1068:         //Cache the helper size
1069:         this._cacheHelperProportions();
1070:
1071:         //If ddmanager is used for droppables, set the global draggable
1072:         if($.ui.ddmanager)
1073:             $.ui.ddmanager.current = this;
1074:
1075:         /*
1076:          * - Position generation -
1077:          * This block generates everything position related - it's the core of draggables.
1078:          */
1079:
1080:         //Cache the margins of the original element
1081:         this._cacheMargins();
1082:
1083:         //Store the helper's css position
1084:         this.cssPosition = this.helper.css("position");
1085:         this.scrollParent = this.helper.scrollParent();
1086:
1087:         //The element's absolute position on the page minus margins
1088:         this.offset = this.positionAbs = this.element.offset();
1089:         this.offset = {
1090:             top: this.offset.top - this.margins.top,
1091:             left: this.offset.left - this.margins.left
1092:         };
1093:
1094:         $.extend(this.offset, {
1095:             click: { //Where the click happened, relative to the element
1096:                 left: event.pageX - this.offset.left,
1097:                 top: event.pageY - this.offset.top
1098:             },
1099:             parent: this._getParentOffset(),
1100:             relative: this._getRelativeOffset() //This is a relative to absolute position minus the actual position calculation - only used for relative positioned helper
1101:         });
1102:
1103:         //Generate the original position
1104:         this.originalPosition = this.position = this._generatePosition(event);
1105:         this.originalPageX = event.pageX;
1106:         this.originalPageY = event.pageY;
1107:
1108:         //Adjust the mouse offset relative to the helper if 'cursorAt' is supplied
1109:         (o.cursorAt && this._adjustOffsetFromHelper(o.cursorAt));
1110:
1111:         //Set a containment if given in the options
1112:         if(o.containment)
1113:             this._setContainment();
1114:
1115:         //Trigger event + callbacks
1116:         if(this._trigger("start", event) === false) {
1117:             this._clear();
1118:             return false;
1119:         }
1120:
1121:         //Recache the helper size
1122:         this._cacheHelperProportions();
1123:
1124:         //Prepare the droppable offsets
1125:         if ($.ui.ddmanager && !o.dropBehaviour)
1126:             $.ui.ddmanager.prepareOffsets(this, event);
1127:
1128:         
1129:         this._mouseDrag(event, true); //Execute the drag once - this causes the helper not to be visible before getting its correct position
1130:         
1131:         //If the ddmanager is used for droppables, inform the manager that dragging has started (see #5003)
1132:         if ( $.ui.ddmanager ) $.ui.ddmanager.dragStart(this, event);
1133:         
1134:         return true;
1135:     },
1136:
1137:     _mouseDrag: function(event, noPropagation) {
1138:
1139:         //Compute the helpers position
1140:         this.position = this._generatePosition(event);
1141:         this.positionAbs = this._convertPositionTo("absolute");
1142:
1143:         //Call plugins and callbacks and use the resulting position if something is returned
1144:         if (!noPropagation) {
1145:             var ui = this._uiHash();
1146:             if(this._trigger('drag', event, ui) === false) {
1147:                 this._mouseUp({});
1148:                 return false;
1149:             }
1150:             this.position = ui.position;
1151:         }
1152:
1153:         if(!this.options.axis || this.options.axis != "y") this.helper[0].style.left = this.position.left+'px';
1154:         if(!this.options.axis || this.options.axis != "x") this.helper[0].style.top = this.position.top+'px';
1155:         if($.ui.ddmanager) $.ui.ddmanager.drag(this, event);
1156:
1157:         return false;
1158:     },
1159:
1160:     _mouseStop: function(event) {
1161:
1162:         //If we are using droppables, inform the manager about the drop
1163:         var dropped = false;
1164:         if ($.ui.ddmanager && !this.options.dropBehaviour)
1165:             dropped = $.ui.ddmanager.drop(this, event);
1166:
1167:         //if a drop comes from outside (a sortable)
1168:         if(this.dropped) {
1169:             dropped = this.dropped;
1170:             this.dropped = false;
1171:         }
1172:         
1173:         //if the original element is no longer in the DOM don't bother to continue (see #8269)
1174:         var element = this.element[0], elementInDom = false;
1175:         while ( element && (element = element.parentNode) ) {
1176:             if (element == document ) {
1177:                 elementInDom = true;
1178:             }
1179:         }
1180:         if ( !elementInDom && this.options.helper === "original" )
1181:             return false;
1182:
1183:         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))) {
1184:             var that = this;
1185:             $(this.helper).animate(this.originalPosition, parseInt(this.options.revertDuration, 10), function() {
1186:                 if(that._trigger("stop", event) !== false) {
1187:                     that._clear();
1188:                 }
1189:             });
1190:         } else {
1191:             if(this._trigger("stop", event) !== false) {
1192:                 this._clear();
1193:             }
1194:         }
1195:
1196:         return false;
1197:     },
1198:     
1199:     _mouseUp: function(event) {
1200:         //Remove frame helpers
1201:         $("div.ui-draggable-iframeFix").each(function() {
1202:             this.parentNode.removeChild(this);
1203:         });
1204:         
1205:         //If the ddmanager is used for droppables, inform the manager that dragging has stopped (see #5003)
1206:         if( $.ui.ddmanager ) $.ui.ddmanager.dragStop(this, event);
1207:         
1208:         return $.ui.mouse.prototype._mouseUp.call(this, event);
1209:     },
1210:     
1211:     cancel: function() {
1212:         
1213:         if(this.helper.is(".ui-draggable-dragging")) {
1214:             this._mouseUp({});
1215:         } else {
1216:             this._clear();
1217:         }
1218:         
1219:         return this;
1220:         
1221:     },
1222:
1223:     _getHandle: function(event) {
1224:
1225:         var handle = !this.options.handle || !$(this.options.handle, this.element).length ? true : false;
1226:         $(this.options.handle, this.element)
1227:             .find("*")
1228:             .andSelf()
1229:             .each(function() {
1230:                 if(this == event.target) handle = true;
1231:             });
1232:
1233:         return handle;
1234:
1235:     },
1236:
1237:     _createHelper: function(event) {
1238:
1239:         var o = this.options;
1240:         var helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [event])) : (o.helper == 'clone' ? this.element.clone().removeAttr('id') : this.element);
1241:
1242:         if(!helper.parents('body').length)
1243:             helper.appendTo((o.appendTo == 'parent' ? this.element[0].parentNode : o.appendTo));
1244:
1245:         if(helper[0] != this.element[0] && !(/(fixed|absolute)/).test(helper.css("position")))
1246:             helper.css("position", "absolute");
1247:
1248:         return helper;
1249:
1250:     },
1251:
1252:     _adjustOffsetFromHelper: function(obj) {
1253:         if (typeof obj == 'string') {
1254:             obj = obj.split(' ');
1255:         }
1256:         if ($.isArray(obj)) {
1257:             obj = {left: +obj[0], top: +obj[1] || 0};
1258:         }
1259:         if ('left' in obj) {
1260:             this.offset.click.left = obj.left + this.margins.left;
1261:         }
1262:         if ('right' in obj) {
1263:             this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
1264:         }
1265:         if ('top' in obj) {
1266:             this.offset.click.top = obj.top + this.margins.top;
1267:         }
1268:         if ('bottom' in obj) {
1269:             this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
1270:         }
1271:     },
1272:
1273:     _getParentOffset: function() {
1274:
1275:         //Get the offsetParent and cache its position
1276:         this.offsetParent = this.helper.offsetParent();
1277:         var po = this.offsetParent.offset();
1278:
1279:         // This is a special case where we need to modify a offset calculated on start, since the following happened:
1280:         // 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent
1281:         // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that
1282:         // the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag
1283:         if(this.cssPosition == 'absolute' && this.scrollParent[0] != document && $.contains(this.scrollParent[0], this.offsetParent[0])) {
1284:             po.left += this.scrollParent.scrollLeft();
1285:             po.top += this.scrollParent.scrollTop();
1286:         }
1287:
1288:         if((this.offsetParent[0] == document.body) //This needs to be actually done for all browsers, since pageX/pageY includes this information
1289:         || (this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() == 'html' && $.browser.msie)) //Ugly IE fix
1290:             po = { top: 0, left: 0 };
1291:
1292:         return {
1293:             top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"),10) || 0),
1294:             left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"),10) || 0)
1295:         };
1296:
1297:     },
1298:
1299:     _getRelativeOffset: function() {
1300:
1301:         if(this.cssPosition == "relative") {
1302:             var p = this.element.position();
1303:             return {
1304:                 top: p.top - (parseInt(this.helper.css("top"),10) || 0) + this.scrollParent.scrollTop(),
1305:                 left: p.left - (parseInt(this.helper.css("left"),10) || 0) + this.scrollParent.scrollLeft()
1306:             };
1307:         } else {
1308:             return { top: 0, left: 0 };
1309:         }
1310:
1311:     },
1312:
1313:     _cacheMargins: function() {
1314:         this.margins = {
1315:             left: (parseInt(this.element.css("marginLeft"),10) || 0),
1316:             top: (parseInt(this.element.css("marginTop"),10) || 0),
1317:             right: (parseInt(this.element.css("marginRight"),10) || 0),
1318:             bottom: (parseInt(this.element.css("marginBottom"),10) || 0)
1319:         };
1320:     },
1321:
1322:     _cacheHelperProportions: function() {
1323:         this.helperProportions = {
1324:             width: this.helper.outerWidth(),
1325:             height: this.helper.outerHeight()
1326:         };
1327:     },
1328:
1329:     _setContainment: function() {
1330:
1331:         var o = this.options;
1332:         if(o.containment == 'parent') o.containment = this.helper[0].parentNode;
1333:         if(o.containment == 'document' || o.containment == 'window') this.containment = [
1334:             o.containment == 'document' ? 0 : $(window).scrollLeft() - this.offset.relative.left - this.offset.parent.left,
1335:             o.containment == 'document' ? 0 : $(window).scrollTop() - this.offset.relative.top - this.offset.parent.top,
1336:             (o.containment == 'document' ? 0 : $(window).scrollLeft()) + $(o.containment == 'document' ? document : window).width() - this.helperProportions.width - this.margins.left,
1337:             (o.containment == 'document' ? 0 : $(window).scrollTop()) + ($(o.containment == 'document' ? document : window).height() || document.body.parentNode.scrollHeight) - this.helperProportions.height - this.margins.top
1338:         ];
1339:
1340:         if(!(/^(document|window|parent)$/).test(o.containment) && o.containment.constructor != Array) {
1341:             var c = $(o.containment);
1342:             var ce = c[0]; if(!ce) return;
1343:             var co = c.offset();
1344:             var over = ($(ce).css("overflow") != 'hidden');
1345:
1346:             this.containment = [
1347:                 (parseInt($(ce).css("borderLeftWidth"),10) || 0) + (parseInt($(ce).css("paddingLeft"),10) || 0),
1348:                 (parseInt($(ce).css("borderTopWidth"),10) || 0) + (parseInt($(ce).css("paddingTop"),10) || 0),
1349:                 (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,
1350:                 (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
1351:             ];
1352:             this.relative_container = c;
1353:
1354:         } else if(o.containment.constructor == Array) {
1355:             this.containment = o.containment;
1356:         }
1357:
1358:     },
1359:
1360:     _convertPositionTo: function(d, pos) {
1361:
1362:         if(!pos) pos = this.position;
1363:         var mod = d == "absolute" ? 1 : -1;
1364:         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);
1365:
1366:         return {
1367:             top: (
1368:                 pos.top                                                                    // The absolute mouse position
1369:                 + this.offset.relative.top * mod                                        // Only for relative positioned nodes: Relative offset from element to offset parent
1370:                 + this.offset.parent.top * mod                                            // The offsetParent's offset without borders (offset + border)
1371:                 - ( ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod)
1372:             ),
1373:             left: (
1374:                 pos.left                                                                // The absolute mouse position
1375:                 + this.offset.relative.left * mod                                        // Only for relative positioned nodes: Relative offset from element to offset parent
1376:                 + this.offset.parent.left * mod                                            // The offsetParent's offset without borders (offset + border)
1377:                 - ( ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ) * mod)
1378:             )
1379:         };
1380:
1381:     },
1382:
1383:     _generatePosition: function(event) {
1384:
1385:         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);
1386:         var pageX = event.pageX;
1387:         var pageY = event.pageY;
1388:
1389:         /*
1390:          * - Position constraining -
1391:          * Constrain the position to a mix of grid, containment.
1392:          */
1393:
1394:         if(this.originalPosition) { //If we are not dragging yet, we won't check for options
1395:             var containment;
1396:             if(this.containment) {
1397:             if (this.relative_container){
1398:                 var co = this.relative_container.offset();
1399:                 containment = [ this.containment[0] + co.left,
1400:                     this.containment[1] + co.top,
1401:                     this.containment[2] + co.left,
1402:                     this.containment[3] + co.top ];
1403:             }
1404:             else {
1405:                 containment = this.containment;
1406:             }
1407:
1408:                 if(event.pageX - this.offset.click.left < containment[0]) pageX = containment[0] + this.offset.click.left;
1409:                 if(event.pageY - this.offset.click.top < containment[1]) pageY = containment[1] + this.offset.click.top;
1410:                 if(event.pageX - this.offset.click.left > containment[2]) pageX = containment[2] + this.offset.click.left;
1411:                 if(event.pageY - this.offset.click.top > containment[3]) pageY = containment[3] + this.offset.click.top;
1412:             }
1413:
1414:             if(o.grid) {
1415:                 //Check for grid elements set to 0 to prevent divide by 0 error causing invalid argument errors in IE (see ticket #6950)
1416:                 var top = o.grid[1] ? this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1] : this.originalPageY;
1417:                 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;
1418:
1419:                 var left = o.grid[0] ? this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0] : this.originalPageX;
1420:                 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;
1421:             }
1422:
1423:         }
1424:
1425:         return {
1426:             top: (
1427:                 pageY                                                                // The absolute mouse position
1428:                 - this.offset.click.top                                                    // Click offset (relative to the element)
1429:                 - this.offset.relative.top                                                // Only for relative positioned nodes: Relative offset from element to offset parent
1430:                 - this.offset.parent.top                                                // The offsetParent's offset without borders (offset + border)
1431:                 + ( ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ))
1432:             ),
1433:             left: (
1434:                 pageX                                                                // The absolute mouse position
1435:                 - this.offset.click.left                                                // Click offset (relative to the element)
1436:                 - this.offset.relative.left                                                // Only for relative positioned nodes: Relative offset from element to offset parent
1437:                 - this.offset.parent.left                                                // The offsetParent's offset without borders (offset + border)
1438:                 + ( ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ))
1439:             )
1440:         };
1441:
1442:     },
1443:
1444:     _clear: function() {
1445:         this.helper.removeClass("ui-draggable-dragging");
1446:         if(this.helper[0] != this.element[0] && !this.cancelHelperRemoval) this.helper.remove();
1447:         //if($.ui.ddmanager) $.ui.ddmanager.current = null;
1448:         this.helper = null;
1449:         this.cancelHelperRemoval = false;
1450:     },
1451:
1452:     // From now on bulk stuff - mainly helpers
1453:
1454:     _trigger: function(type, event, ui) {
1455:         ui = ui || this._uiHash();
1456:         $.ui.plugin.call(this, type, [event, ui]);
1457:         if(type == "drag") this.positionAbs = this._convertPositionTo("absolute"); //The absolute position has to be recalculated after plugins
1458:         return $.Widget.prototype._trigger.call(this, type, event, ui);
1459:     },
1460:
1461:     plugins: {},
1462:
1463:     _uiHash: function(event) {
1464:         return {
1465:             helper: this.helper,
1466:             position: this.position,
1467:             originalPosition: this.originalPosition,
1468:             offset: this.positionAbs
1469:         };
1470:     }
1471:
1472: });
1473:
1474: $.ui.plugin.add("draggable", "connectToSortable", {
1475:     start: function(event, ui) {
1476:
1477:         var inst = $(this).data("draggable"), o = inst.options,
1478:             uiSortable = $.extend({}, ui, { item: inst.element });
1479:         inst.sortables = [];
1480:         $(o.connectToSortable).each(function() {
1481:             var sortable = $.data(this, 'sortable');
1482:             if (sortable && !sortable.options.disabled) {
1483:                 inst.sortables.push({
1484:                     instance: sortable,
1485:                     shouldRevert: sortable.options.revert
1486:                 });
1487:                 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).
1488:                 sortable._trigger("activate", event, uiSortable);
1489:             }
1490:         });
1491:
1492:     },
1493:     stop: function(event, ui) {
1494:
1495:         //If we are still over the sortable, we fake the stop event of the sortable, but also remove helper
1496:         var inst = $(this).data("draggable"),
1497:             uiSortable = $.extend({}, ui, { item: inst.element });
1498:
1499:         $.each(inst.sortables, function() {
1500:             if(this.instance.isOver) {
1501:
1502:                 this.instance.isOver = 0;
1503:
1504:                 inst.cancelHelperRemoval = true; //Don't remove the helper in the draggable instance
1505:                 this.instance.cancelHelperRemoval = false; //Remove it in the sortable instance (so sortable plugins like revert still work)
1506:
1507:                 //The sortable revert is supported, and we have to set a temporary dropped variable on the draggable to support revert: 'valid/invalid'
1508:                 if(this.shouldRevert) this.instance.options.revert = true;
1509:
1510:                 //Trigger the stop of the sortable
1511:                 this.instance._mouseStop(event);
1512:
1513:                 this.instance.options.helper = this.instance.options._helper;
1514:
1515:                 //If the helper has been the original item, restore properties in the sortable
1516:                 if(inst.options.helper == 'original')
1517:                     this.instance.currentItem.css({ top: 'auto', left: 'auto' });
1518:
1519:             } else {
1520:                 this.instance.cancelHelperRemoval = false; //Remove the helper in the sortable instance
1521:                 this.instance._trigger("deactivate", event, uiSortable);
1522:             }
1523:
1524:         });
1525:
1526:     },
1527:     drag: function(event, ui) {
1528:
1529:         var inst = $(this).data("draggable"), that = this;
1530:
1531:         var checkPos = function(o) {
1532:             var dyClick = this.offset.click.top, dxClick = this.offset.click.left;
1533:             var helperTop = this.positionAbs.top, helperLeft = this.positionAbs.left;
1534:             var itemHeight = o.height, itemWidth = o.width;
1535:             var itemTop = o.top, itemLeft = o.left;
1536:
1537:             return $.ui.isOver(helperTop + dyClick, helperLeft + dxClick, itemTop, itemLeft, itemHeight, itemWidth);
1538:         };
1539:
1540:         $.each(inst.sortables, function(i) {
1541:             
1542:             //Copy over some variables to allow calling the sortable's native _intersectsWith
1543:             this.instance.positionAbs = inst.positionAbs;
1544:             this.instance.helperProportions = inst.helperProportions;
1545:             this.instance.offset.click = inst.offset.click;
1546:             
1547:             if(this.instance._intersectsWith(this.instance.containerCache)) {
1548:
1549:                 //If it intersects, we use a little isOver variable and set it once, so our move-in stuff gets fired only once
1550:                 if(!this.instance.isOver) {
1551:
1552:                     this.instance.isOver = 1;
1553:                     //Now we fake the start of dragging for the sortable instance,
1554:                     //by cloning the list group item, appending it to the sortable and using it as inst.currentItem
1555:                     //We can then fire the start event of the sortable with our passed browser event, and our own helper (so it doesn't create a new one)
1556:                     this.instance.currentItem = $(that).clone().removeAttr('id').appendTo(this.instance.element).data("sortable-item", true);
1557:                     this.instance.options._helper = this.instance.options.helper; //Store helper option to later restore it
1558:                     this.instance.options.helper = function() { return ui.helper[0]; };
1559:
1560:                     event.target = this.instance.currentItem[0];
1561:                     this.instance._mouseCapture(event, true);
1562:                     this.instance._mouseStart(event, true, true);
1563:
1564:                     //Because the browser event is way off the new appended portlet, we modify a couple of variables to reflect the changes
1565:                     this.instance.offset.click.top = inst.offset.click.top;
1566:                     this.instance.offset.click.left = inst.offset.click.left;
1567:                     this.instance.offset.parent.left -= inst.offset.parent.left - this.instance.offset.parent.left;
1568:                     this.instance.offset.parent.top -= inst.offset.parent.top - this.instance.offset.parent.top;
1569:
1570:                     inst._trigger("toSortable", event);
1571:                     inst.dropped = this.instance.element; //draggable revert needs that
1572:                     //hack so receive/update callbacks work (mostly)
1573:                     inst.currentItem = inst.element;
1574:                     this.instance.fromOutside = inst;
1575:
1576:                 }
1577:
1578:                 //Provided we did all the previous steps, we can fire the drag event of the sortable on every draggable drag, when it intersects with the sortable
1579:                 if(this.instance.currentItem) this.instance._mouseDrag(event);
1580:
1581:             } else {
1582:
1583:                 //If it doesn't intersect with the sortable, and it intersected before,
1584:                 //we fake the drag stop of the sortable, but make sure it doesn't remove the helper by using cancelHelperRemoval
1585:                 if(this.instance.isOver) {
1586:
1587:                     this.instance.isOver = 0;
1588:                     this.instance.cancelHelperRemoval = true;
1589:                     
1590:                     //Prevent reverting on this forced stop
1591:                     this.instance.options.revert = false;
1592:                     
1593:                     // The out event needs to be triggered independently
1594:                     this.instance._trigger('out', event, this.instance._uiHash(this.instance));
1595:                     
1596:                     this.instance._mouseStop(event, true);
1597:                     this.instance.options.helper = this.instance.options._helper;
1598:
1599:                     //Now we remove our currentItem, the list group clone again, and the placeholder, and animate the helper back to it's original size
1600:                     this.instance.currentItem.remove();
1601:                     if(this.instance.placeholder) this.instance.placeholder.remove();
1602:
1603:                     inst._trigger("fromSortable", event);
1604:                     inst.dropped = false; //draggable revert needs that
1605:                 }
1606:
1607:             };
1608:
1609:         });
1610:
1611:     }
1612: });
1613:
1614: $.ui.plugin.add("draggable", "cursor", {
1615:     start: function(event, ui) {
1616:         var t = $('body'), o = $(this).data('draggable').options;
1617:         if (t.css("cursor")) o._cursor = t.css("cursor");
1618:         t.css("cursor", o.cursor);
1619:     },
1620:     stop: function(event, ui) {
1621:         var o = $(this).data('draggable').options;
1622:         if (o._cursor) $('body').css("cursor", o._cursor);
1623:     }
1624: });
1625:
1626: $.ui.plugin.add("draggable", "opacity", {
1627:     start: function(event, ui) {
1628:         var t = $(ui.helper), o = $(this).data('draggable').options;
1629:         if(t.css("opacity")) o._opacity = t.css("opacity");
1630:         t.css('opacity', o.opacity);
1631:     },
1632:     stop: function(event, ui) {
1633:         var o = $(this).data('draggable').options;
1634:         if(o._opacity) $(ui.helper).css('opacity', o._opacity);
1635:     }
1636: });
1637:
1638: $.ui.plugin.add("draggable", "scroll", {
1639:     start: function(event, ui) {
1640:         var i = $(this).data("draggable");
1641:         if(i.scrollParent[0] != document && i.scrollParent[0].tagName != 'HTML') i.overflowOffset = i.scrollParent.offset();
1642:     },
1643:     drag: function(event, ui) {
1644:
1645:         var i = $(this).data("draggable"), o = i.options, scrolled = false;
1646:
1647:         if(i.scrollParent[0] != document && i.scrollParent[0].tagName != 'HTML') {
1648:
1649:             if(!o.axis || o.axis != 'x') {
1650:                 if((i.overflowOffset.top + i.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity)
1651:                     i.scrollParent[0].scrollTop = scrolled = i.scrollParent[0].scrollTop + o.scrollSpeed;
1652:                 else if(event.pageY - i.overflowOffset.top < o.scrollSensitivity)
1653:                     i.scrollParent[0].scrollTop = scrolled = i.scrollParent[0].scrollTop - o.scrollSpeed;
1654:             }
1655:
1656:             if(!o.axis || o.axis != 'y') {
1657:                 if((i.overflowOffset.left + i.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity)
1658:                     i.scrollParent[0].scrollLeft = scrolled = i.scrollParent[0].scrollLeft + o.scrollSpeed;
1659:                 else if(event.pageX - i.overflowOffset.left < o.scrollSensitivity)
1660:                     i.scrollParent[0].scrollLeft = scrolled = i.scrollParent[0].scrollLeft - o.scrollSpeed;
1661:             }
1662:
1663:         } else {
1664:
1665:             if(!o.axis || o.axis != 'x') {
1666:                 if(event.pageY - $(document).scrollTop() < o.scrollSensitivity)
1667:                     scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed);
1668:                 else if($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity)
1669:                     scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed);
1670:             }
1671:
1672:             if(!o.axis || o.axis != 'y') {
1673:                 if(event.pageX - $(document).scrollLeft() < o.scrollSensitivity)
1674:                     scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed);
1675:                 else if($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity)
1676:                     scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);
1677:             }
1678:
1679:         }
1680:
1681:         if(scrolled !== false && $.ui.ddmanager && !o.dropBehaviour)
1682:             $.ui.ddmanager.prepareOffsets(i, event);
1683:
1684:     }
1685: });
1686:
1687: $.ui.plugin.add("draggable", "snap", {
1688:     start: function(event, ui) {
1689:
1690:         var i = $(this).data("draggable"), o = i.options;
1691:         i.snapElements = [];
1692:
1693:         $(o.snap.constructor != String ? ( o.snap.items || ':data(draggable)' ) : o.snap).each(function() {
1694:             var $t = $(this); var $o = $t.offset();
1695:             if(this != i.element[0]) i.snapElements.push({
1696:                 item: this,
1697:                 width: $t.outerWidth(), height: $t.outerHeight(),
1698:                 top: $o.top, left: $o.left
1699:             });
1700:         });
1701:
1702:     },
1703:     drag: function(event, ui) {
1704:
1705:         var inst = $(this).data("draggable"), o = inst.options;
1706:         var d = o.snapTolerance;
1707:
1708:         var x1 = ui.offset.left, x2 = x1 + inst.helperProportions.width,
1709:             y1 = ui.offset.top, y2 = y1 + inst.helperProportions.height;
1710:
1711:         for (var i = inst.snapElements.length - 1; i >= 0; i--){
1712:
1713:             var l = inst.snapElements[i].left, r = l + inst.snapElements[i].width,
1714:                 t = inst.snapElements[i].top, b = t + inst.snapElements[i].height;
1715:
1716:             //Yes, I know, this is insane ;)
1717:             if(!((l-d < x1 && x1 < r+d && t-d < y1 && y1 < b+d) || (l-d < x1 && x1 < r+d && t-d < y2 && y2 < b+d) || (l-d < x2 && x2 < r+d && t-d < y1 && y1 < b+d) || (l-d < x2 && x2 < r+d && t-d < y2 && y2 < b+d))) {
1718:                 if(inst.snapElements[i].snapping) (inst.options.snap.release && inst.options.snap.release.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item })));
1719:                 inst.snapElements[i].snapping = false;
1720:                 continue;
1721:             }
1722:
1723:             if(o.snapMode != 'inner') {
1724:                 var ts = Math.abs(t - y2) <= d;
1725:                 var bs = Math.abs(b - y1) <= d;
1726:                 var ls = Math.abs(l - x2) <= d;
1727:                 var rs = Math.abs(r - x1) <= d;
1728:                 if(ts) ui.position.top = inst._convertPositionTo("relative", { top: t - inst.helperProportions.height, left: 0 }).top - inst.margins.top;
1729:                 if(bs) ui.position.top = inst._convertPositionTo("relative", { top: b, left: 0 }).top - inst.margins.top;
1730:                 if(ls) ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l - inst.helperProportions.width }).left - inst.margins.left;
1731:                 if(rs) ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r }).left - inst.margins.left;
1732:             }
1733:
1734:             var first = (ts || bs || ls || rs);
1735:
1736:             if(o.snapMode != 'outer') {
1737:                 var ts = Math.abs(t - y1) <= d;
1738:                 var bs = Math.abs(b - y2) <= d;
1739:                 var ls = Math.abs(l - x1) <= d;
1740:                 var rs = Math.abs(r - x2) <= d;
1741:                 if(ts) ui.position.top = inst._convertPositionTo("relative", { top: t, left: 0 }).top - inst.margins.top;
1742:                 if(bs) ui.position.top = inst._convertPositionTo("relative", { top: b - inst.helperProportions.height, left: 0 }).top - inst.margins.top;
1743:                 if(ls) ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l }).left - inst.margins.left;
1744:                 if(rs) ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r - inst.helperProportions.width }).left - inst.margins.left;
1745:             }
1746:
1747:             if(!inst.snapElements[i].snapping && (ts || bs || ls || rs || first))
1748:                 (inst.options.snap.snap && inst.options.snap.snap.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item })));
1749:             inst.snapElements[i].snapping = (ts || bs || ls || rs || first);
1750:
1751:         };
1752:
1753:     }
1754: });
1755:
1756: $.ui.plugin.add("draggable", "stack", {
1757:     start: function(event, ui) {
1758:
1759:         var o = $(this).data("draggable").options;
1760:
1761:         var group = $.makeArray($(o.stack)).sort(function(a,b) {
1762:             return (parseInt($(a).css("zIndex"),10) || 0) - (parseInt($(b).css("zIndex"),10) || 0);
1763:         });
1764:         if (!group.length) { return; }
1765:         
1766:         var min = parseInt(group[0].style.zIndex) || 0;
1767:         $(group).each(function(i) {
1768:             this.style.zIndex = min + i;
1769:         });
1770:
1771:         this[0].style.zIndex = min + group.length;
1772:
1773:     }
1774: });
1775:
1776: $.ui.plugin.add("draggable", "zIndex", {
1777:     start: function(event, ui) {
1778:         var t = $(ui.helper), o = $(this).data("draggable").options;
1779:         if(t.css("zIndex")) o._zIndex = t.css("zIndex");
1780:         t.css('zIndex', o.zIndex);
1781:     },
1782:     stop: function(event, ui) {
1783:         var o = $(this).data("draggable").options;
1784:         if(o._zIndex) $(ui.helper).css('zIndex', o._zIndex);
1785:     }
1786: });
1787:
1788: })(jQuery);
1789:
1790: (function( $, undefined ) {
1791:
1792: $.widget("ui.droppable", {
1793:     version: "1.9.0",
1794:     widgetEventPrefix: "drop",
1795:     options: {
1796:         accept: '*',
1797:         activeClass: false,
1798:         addClasses: true,
1799:         greedy: false,
1800:         hoverClass: false,
1801:         scope: 'default',
1802:         tolerance: 'intersect'
1803:     },
1804:     _create: function() {
1805:
1806:         var o = this.options, accept = o.accept;
1807:         this.isover = 0; this.isout = 1;
1808:
1809:         this.accept = $.isFunction(accept) ? accept : function(d) {
1810:             return d.is(accept);
1811:         };
1812:
1813:         //Store the droppable's proportions
1814:         this.proportions = { width: this.element[0].offsetWidth, height: this.element[0].offsetHeight };
1815:
1816:         // Add the reference and positions to the manager
1817:         $.ui.ddmanager.droppables[o.scope] = $.ui.ddmanager.droppables[o.scope] || [];
1818:         $.ui.ddmanager.droppables[o.scope].push(this);
1819:
1820:         (o.addClasses && this.element.addClass("ui-droppable"));
1821:
1822:     },
1823:
1824:     _destroy: function() {
1825:         var drop = $.ui.ddmanager.droppables[this.options.scope];
1826:         for ( var i = 0; i < drop.length; i++ )
1827:             if ( drop[i] == this )
1828:                 drop.splice(i, 1);
1829:
1830:         this.element.removeClass("ui-droppable ui-droppable-disabled");
1831:     },
1832:
1833:     _setOption: function(key, value) {
1834:
1835:         if(key == 'accept') {
1836:             this.accept = $.isFunction(value) ? value : function(d) {
1837:                 return d.is(value);
1838:             };
1839:         }
1840:         $.Widget.prototype._setOption.apply(this, arguments);
1841:     },
1842:
1843:     _activate: function(event) {
1844:         var draggable = $.ui.ddmanager.current;
1845:         if(this.options.activeClass) this.element.addClass(this.options.activeClass);
1846:         (draggable && this._trigger('activate', event, this.ui(draggable)));
1847:     },
1848:
1849:     _deactivate: function(event) {
1850:         var draggable = $.ui.ddmanager.current;
1851:         if(this.options.activeClass) this.element.removeClass(this.options.activeClass);
1852:         (draggable && this._trigger('deactivate', event, this.ui(draggable)));
1853:     },
1854:
1855:     _over: function(event) {
1856:
1857:         var draggable = $.ui.ddmanager.current;
1858:         if (!draggable || (draggable.currentItem || draggable.element)[0] == this.element[0]) return; // Bail if draggable and droppable are same element
1859:
1860:         if (this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) {
1861:             if(this.options.hoverClass) this.element.addClass(this.options.hoverClass);
1862:             this._trigger('over', event, this.ui(draggable));
1863:         }
1864:
1865:     },
1866:
1867:     _out: function(event) {
1868:
1869:         var draggable = $.ui.ddmanager.current;
1870:         if (!draggable || (draggable.currentItem || draggable.element)[0] == this.element[0]) return; // Bail if draggable and droppable are same element
1871:
1872:         if (this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) {
1873:             if(this.options.hoverClass) this.element.removeClass(this.options.hoverClass);
1874:             this._trigger('out', event, this.ui(draggable));
1875:         }
1876:
1877:     },
1878:
1879:     _drop: function(event,custom) {
1880:
1881:         var draggable = custom || $.ui.ddmanager.current;
1882:         if (!draggable || (draggable.currentItem || draggable.element)[0] == this.element[0]) return false; // Bail if draggable and droppable are same element
1883:
1884:         var childrenIntersection = false;
1885:         this.element.find(":data(droppable)").not(".ui-draggable-dragging").each(function() {
1886:             var inst = $.data(this, 'droppable');
1887:             if(
1888:                 inst.options.greedy
1889:                 && !inst.options.disabled
1890:                 && inst.options.scope == draggable.options.scope
1891:                 && inst.accept.call(inst.element[0], (draggable.currentItem || draggable.element))
1892:                 && $.ui.intersect(draggable, $.extend(inst, { offset: inst.element.offset() }), inst.options.tolerance)
1893:             ) { childrenIntersection = true; return false; }
1894:         });
1895:         if(childrenIntersection) return false;
1896:
1897:         if(this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) {
1898:             if(this.options.activeClass) this.element.removeClass(this.options.activeClass);
1899:             if(this.options.hoverClass) this.element.removeClass(this.options.hoverClass);
1900:             this._trigger('drop', event, this.ui(draggable));
1901:             return this.element;
1902:         }
1903:
1904:         return false;
1905:
1906:     },
1907:
1908:     ui: function(c) {
1909:         return {
1910:             draggable: (c.currentItem || c.element),
1911:             helper: c.helper,
1912:             position: c.position,
1913:             offset: c.positionAbs
1914:         };
1915:     }
1916:
1917: });
1918:
1919: $.ui.intersect = function(draggable, droppable, toleranceMode) {
1920:
1921:     if (!droppable.offset) return false;
1922:
1923:     var x1 = (draggable.positionAbs || draggable.position.absolute).left, x2 = x1 + draggable.helperProportions.width,
1924:         y1 = (draggable.positionAbs || draggable.position.absolute).top, y2 = y1 + draggable.helperProportions.height;
1925:     var l = droppable.offset.left, r = l + droppable.proportions.width,
1926:         t = droppable.offset.top, b = t + droppable.proportions.height;
1927:
1928:     switch (toleranceMode) {
1929:         case 'fit':
1930:             return (l <= x1 && x2 <= r
1931:                 && t <= y1 && y2 <= b);
1932:             break;
1933:         case 'intersect':
1934:             return (l < x1 + (draggable.helperProportions.width / 2) // Right Half
1935:                 && x2 - (draggable.helperProportions.width / 2) < r // Left Half
1936:                 && t < y1 + (draggable.helperProportions.height / 2) // Bottom Half
1937:                 && y2 - (draggable.helperProportions.height / 2) < b ); // Top Half
1938:             break;
1939:         case 'pointer':
1940:             var draggableLeft = ((draggable.positionAbs || draggable.position.absolute).left + (draggable.clickOffset || draggable.offset.click).left),
1941:                 draggableTop = ((draggable.positionAbs || draggable.position.absolute).top + (draggable.clickOffset || draggable.offset.click).top),
1942:                 isOver = $.ui.isOver(draggableTop, draggableLeft, t, l, droppable.proportions.height, droppable.proportions.width);
1943:             return isOver;
1944:             break;
1945:         case 'touch':
1946:             return (
1947:                     (y1 >= t && y1 <= b) ||    // Top edge touching
1948:                     (y2 >= t && y2 <= b) ||    // Bottom edge touching
1949:                     (y1 < t && y2 > b)        // Surrounded vertically
1950:                 ) && (
1951:                     (x1 >= l && x1 <= r) ||    // Left edge touching
1952:                     (x2 >= l && x2 <= r) ||    // Right edge touching
1953:                     (x1 < l && x2 > r)        // Surrounded horizontally
1954:                 );
1955:             break;
1956:         default:
1957:             return false;
1958:             break;
1959:         }
1960:
1961: };
1962:
1963: /*
1964:     This manager tracks offsets of draggables and droppables
1965: */
1966: $.ui.ddmanager = {
1967:     current: null,
1968:     droppables: { 'default': [] },
1969:     prepareOffsets: function(t, event) {
1970:
1971:         var m = $.ui.ddmanager.droppables[t.options.scope] || [];
1972:         var type = event ? event.type : null; // workaround for #2317
1973:         var list = (t.currentItem || t.element).find(":data(droppable)").andSelf();
1974:
1975:         droppablesLoop: for (var i = 0; i < m.length; i++) {
1976:
1977:             if(m[i].options.disabled || (t && !m[i].accept.call(m[i].element[0],(t.currentItem || t.element)))) continue;    //No disabled and non-accepted
1978:             for (var j=0; j < list.length; j++) { if(list[j] == m[i].element[0]) { m[i].proportions.height = 0; continue droppablesLoop; } }; //Filter out elements in the current dragged item
1979:             m[i].visible = m[i].element.css("display") != "none"; if(!m[i].visible) continue;                                     //If the element is not visible, continue
1980:
1981:             if(type == "mousedown") m[i]._activate.call(m[i], event); //Activate the droppable if used directly from draggables
1982:
1983:             m[i].offset = m[i].element.offset();
1984:             m[i].proportions = { width: m[i].element[0].offsetWidth, height: m[i].element[0].offsetHeight };
1985:
1986:         }
1987:
1988:     },
1989:     drop: function(draggable, event) {
1990:
1991:         var dropped = false;
1992:         $.each($.ui.ddmanager.droppables[draggable.options.scope] || [], function() {
1993:
1994:             if(!this.options) return;
1995:             if (!this.options.disabled && this.visible && $.ui.intersect(draggable, this, this.options.tolerance))
1996:                 dropped = this._drop.call(this, event) || dropped;
1997:
1998:             if (!this.options.disabled && this.visible && this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) {
1999:                 this.isout = 1; this.isover = 0;
2000:                 this._deactivate.call(this, event);
2001:             }
2002:
2003:         });
2004:         return dropped;
2005:
2006:     },
2007:     dragStart: function( draggable, event ) {
2008:         //Listen for scrolling so that if the dragging causes scrolling the position of the droppables can be recalculated (see #5003)
2009:         draggable.element.parentsUntil( "body" ).bind( "scroll.droppable", function() {
2010:             if( !draggable.options.refreshPositions ) $.ui.ddmanager.prepareOffsets( draggable, event );
2011:         });
2012:     },
2013:     drag: function(draggable, event) {
2014:
2015:         //If you have a highly dynamic page, you might try this option. It renders positions every time you move the mouse.
2016:         if(draggable.options.refreshPositions) $.ui.ddmanager.prepareOffsets(draggable, event);
2017:
2018:         //Run through all droppables and check their positions based on specific tolerance options
2019:         $.each($.ui.ddmanager.droppables[draggable.options.scope] || [], function() {
2020:
2021:             if(this.options.disabled || this.greedyChild || !this.visible) return;
2022:             var intersects = $.ui.intersect(draggable, this, this.options.tolerance);
2023:
2024:             var c = !intersects && this.isover == 1 ? 'isout' : (intersects && this.isover == 0 ? 'isover' : null);
2025:             if(!c) return;
2026:
2027:             var parentInstance;
2028:             if (this.options.greedy) {
2029:                 // find droppable parents with same scope
2030:                 var scope = this.options.scope;
2031:                 var parent = this.element.parents(':data(droppable)').filter(function () {
2032:                     return $.data(this, 'droppable').options.scope === scope;
2033:                 });
2034:
2035:                 if (parent.length) {
2036:                     parentInstance = $.data(parent[0], 'droppable');
2037:                     parentInstance.greedyChild = (c == 'isover' ? 1 : 0);
2038:                 }
2039:             }
2040:
2041:             // we just moved into a greedy child
2042:             if (parentInstance && c == 'isover') {
2043:                 parentInstance['isover'] = 0;
2044:                 parentInstance['isout'] = 1;
2045:                 parentInstance._out.call(parentInstance, event);
2046:             }
2047:
2048:             this[c] = 1; this[c == 'isout' ? 'isover' : 'isout'] = 0;
2049:             this[c == "isover" ? "_over" : "_out"].call(this, event);
2050:
2051:             // we just moved out of a greedy child
2052:             if (parentInstance && c == 'isout') {
2053:                 parentInstance['isout'] = 0;
2054:                 parentInstance['isover'] = 1;
2055:                 parentInstance._over.call(parentInstance, event);
2056:             }
2057:         });
2058:
2059:     },
2060:     dragStop: function( draggable, event ) {
2061:         draggable.element.parentsUntil( "body" ).unbind( "scroll.droppable" );
2062:         //Call prepareOffsets one final time since IE does not fire return scroll events when overflow was caused by drag (see #5003)
2063:         if( !draggable.options.refreshPositions ) $.ui.ddmanager.prepareOffsets( draggable, event );
2064:     }
2065: };
2066:
2067: })(jQuery);
2068:
2069: (function( $, undefined ) {
2070:
2071: $.widget("ui.resizable", $.ui.mouse, {
2072:     version: "1.9.0",
2073:     widgetEventPrefix: "resize",
2074:     options: {
2075:         alsoResize: false,
2076:         animate: false,
2077:         animateDuration: "slow",
2078:         animateEasing: "swing",
2079:         aspectRatio: false,
2080:         autoHide: false,
2081:         containment: false,
2082:         ghost: false,
2083:         grid: false,
2084:         handles: "e,s,se",
2085:         helper: false,
2086:         maxHeight: null,
2087:         maxWidth: null,
2088:         minHeight: 10,
2089:         minWidth: 10,
2090:         zIndex: 1000
2091:     },
2092:     _create: function() {
2093:
2094:         var that = this, o = this.options;
2095:         this.element.addClass("ui-resizable");
2096:
2097:         $.extend(this, {
2098:             _aspectRatio: !!(o.aspectRatio),
2099:             aspectRatio: o.aspectRatio,
2100:             originalElement: this.element,
2101:             _proportionallyResizeElements: [],
2102:             _helper: o.helper || o.ghost || o.animate ? o.helper || 'ui-resizable-helper' : null
2103:         });
2104:
2105:         //Wrap the element if it cannot hold child nodes
2106:         if(this.element[0].nodeName.match(/canvas|textarea|input|select|button|img/i)) {
2107:
2108:             //Create a wrapper element and set the wrapper to the new current internal element
2109:             this.element.wrap(
2110:                 $('<div class="ui-wrapper" style="overflow: hidden;"></div>').css({
2111:                     position: this.element.css('position'),
2112:                     width: this.element.outerWidth(),
2113:                     height: this.element.outerHeight(),
2114:                     top: this.element.css('top'),
2115:                     left: this.element.css('left')
2116:                 })
2117:             );
2118:
2119:             //Overwrite the original this.element
2120:             this.element = this.element.parent().data(
2121:                 "resizable", this.element.data('resizable')
2122:             );
2123:
2124:             this.elementIsWrapper = true;
2125:
2126:             //Move margins to the wrapper
2127:             this.element.css({ marginLeft: this.originalElement.css("marginLeft"), marginTop: this.originalElement.css("marginTop"), marginRight: this.originalElement.css("marginRight"), marginBottom: this.originalElement.css("marginBottom") });
2128:             this.originalElement.css({ marginLeft: 0, marginTop: 0, marginRight: 0, marginBottom: 0});
2129:
2130:             //Prevent Safari textarea resize
2131:             this.originalResizeStyle = this.originalElement.css('resize');
2132:             this.originalElement.css('resize', 'none');
2133:
2134:             //Push the actual element to our proportionallyResize internal array
2135:             this._proportionallyResizeElements.push(this.originalElement.css({ position: 'static', zoom: 1, display: 'block' }));
2136:
2137:             // avoid IE jump (hard set the margin)
2138:             this.originalElement.css({ margin: this.originalElement.css('margin') });
2139:
2140:             // fix handlers offset
2141:             this._proportionallyResize();
2142:
2143:         }
2144:
2145:         this.handles = o.handles || (!$('.ui-resizable-handle', this.element).length ? "e,s,se" : { n: '.ui-resizable-n', e: '.ui-resizable-e', s: '.ui-resizable-s', w: '.ui-resizable-w', se: '.ui-resizable-se', sw: '.ui-resizable-sw', ne: '.ui-resizable-ne', nw: '.ui-resizable-nw' });
2146:         if(this.handles.constructor == String) {
2147:
2148:             if(this.handles == 'all') this.handles = 'n,e,s,w,se,sw,ne,nw';
2149:             var n = this.handles.split(","); this.handles = {};
2150:
2151:             for(var i = 0; i < n.length; i++) {
2152:
2153:                 var handle = $.trim(n[i]), hname = 'ui-resizable-'+handle;
2154:                 var axis = $('<div class="ui-resizable-handle ' + hname + '"></div>');
2155:
2156:                 // Apply zIndex to all handles - see #7960
2157:                 axis.css({ zIndex: o.zIndex });
2158:
2159:                 //TODO : What's going on here?
2160:                 if ('se' == handle) {
2161:                     axis.addClass('ui-icon ui-icon-gripsmall-diagonal-se');
2162:                 };
2163:
2164:                 //Insert into internal handles object and append to element
2165:                 this.handles[handle] = '.ui-resizable-'+handle;
2166:                 this.element.append(axis);
2167:             }
2168:
2169:         }
2170:
2171:         this._renderAxis = function(target) {
2172:
2173:             target = target || this.element;
2174:
2175:             for(var i in this.handles) {
2176:
2177:                 if(this.handles[i].constructor == String)
2178:                     this.handles[i] = $(this.handles[i], this.element).show();
2179:
2180:                 //Apply pad to wrapper element, needed to fix axis position (textarea, inputs, scrolls)
2181:                 if (this.elementIsWrapper && this.originalElement[0].nodeName.match(/textarea|input|select|button/i)) {
2182:
2183:                     var axis = $(this.handles[i], this.element), padWrapper = 0;
2184:
2185:                     //Checking the correct pad and border
2186:                     padWrapper = /sw|ne|nw|se|n|s/.test(i) ? axis.outerHeight() : axis.outerWidth();
2187:
2188:                     //The padding type i have to apply...
2189:                     var padPos = [ 'padding',
2190:                         /ne|nw|n/.test(i) ? 'Top' :
2191:                         /se|sw|s/.test(i) ? 'Bottom' :
2192:                         /^e$/.test(i) ? 'Right' : 'Left' ].join("");
2193:
2194:                     target.css(padPos, padWrapper);
2195:
2196:                     this._proportionallyResize();
2197:
2198:                 }
2199:
2200:                 //TODO: What's that good for? There's not anything to be executed left
2201:                 if(!$(this.handles[i]).length)
2202:                     continue;
2203:
2204:             }
2205:         };
2206:
2207:         //TODO: make renderAxis a prototype function
2208:         this._renderAxis(this.element);
2209:
2210:         this._handles = $('.ui-resizable-handle', this.element)
2211:             .disableSelection();
2212:
2213:         //Matching axis name
2214:         this._handles.mouseover(function() {
2215:             if (!that.resizing) {
2216:                 if (this.className)
2217:                     var axis = this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i);
2218:                 //Axis, default = se
2219:                 that.axis = axis && axis[1] ? axis[1] : 'se';
2220:             }
2221:         });
2222:
2223:         //If we want to auto hide the elements
2224:         if (o.autoHide) {
2225:             this._handles.hide();
2226:             $(this.element)
2227:                 .addClass("ui-resizable-autohide")
2228:                 .mouseenter(function() {
2229:                     if (o.disabled) return;
2230:                     $(this).removeClass("ui-resizable-autohide");
2231:                     that._handles.show();
2232:                 })
2233:                 .mouseleave(function(){
2234:                     if (o.disabled) return;
2235:                     if (!that.resizing) {
2236:                         $(this).addClass("ui-resizable-autohide");
2237:                         that._handles.hide();
2238:                     }
2239:                 });
2240:         }
2241:
2242:         //Initialize the mouse interaction
2243:         this._mouseInit();
2244:
2245:     },
2246:
2247:     _destroy: function() {
2248:
2249:         this._mouseDestroy();
2250:
2251:         var _destroy = function(exp) {
2252:             $(exp).removeClass("ui-resizable ui-resizable-disabled ui-resizable-resizing")
2253:                 .removeData("resizable").removeData("ui-resizable").unbind(".resizable").find('.ui-resizable-handle').remove();
2254:         };
2255:
2256:         //TODO: Unwrap at same DOM position
2257:         if (this.elementIsWrapper) {
2258:             _destroy(this.element);
2259:             var wrapper = this.element;
2260:             wrapper.after(
2261:                 this.originalElement.css({
2262:                     position: wrapper.css('position'),
2263:                     width: wrapper.outerWidth(),
2264:                     height: wrapper.outerHeight(),
2265:                     top: wrapper.css('top'),
2266:                     left: wrapper.css('left')
2267:                 })
2268:             ).remove();
2269:         }
2270:
2271:         this.originalElement.css('resize', this.originalResizeStyle);
2272:         _destroy(this.originalElement);
2273:
2274:         return this;
2275:     },
2276:
2277:     _mouseCapture: function(event) {
2278:         var handle = false;
2279:         for (var i in this.handles) {
2280:             if ($(this.handles[i])[0] == event.target) {
2281:                 handle = true;
2282:             }
2283:         }
2284:
2285:         return !this.options.disabled && handle;
2286:     },
2287:
2288:     _mouseStart: function(event) {
2289:
2290:         var o = this.options, iniPos = this.element.position(), el = this.element;
2291:
2292:         this.resizing = true;
2293:         this.documentScroll = { top: $(document).scrollTop(), left: $(document).scrollLeft() };
2294:
2295:         // bugfix for http://dev.jquery.com/ticket/1749
2296:         if (el.is('.ui-draggable') || (/absolute/).test(el.css('position'))) {
2297:             el.css({ position: 'absolute', top: iniPos.top, left: iniPos.left });
2298:         }
2299:
2300:         this._renderProxy();
2301:
2302:         var curleft = num(this.helper.css('left')), curtop = num(this.helper.css('top'));
2303:
2304:         if (o.containment) {
2305:             curleft += $(o.containment).scrollLeft() || 0;
2306:             curtop += $(o.containment).scrollTop() || 0;
2307:         }
2308:
2309:         //Store needed variables
2310:         this.offset = this.helper.offset();
2311:         this.position = { left: curleft, top: curtop };
2312:         this.size = this._helper ? { width: el.outerWidth(), height: el.outerHeight() } : { width: el.width(), height: el.height() };
2313:         this.originalSize = this._helper ? { width: el.outerWidth(), height: el.outerHeight() } : { width: el.width(), height: el.height() };
2314:         this.originalPosition = { left: curleft, top: curtop };
2315:         this.sizeDiff = { width: el.outerWidth() - el.width(), height: el.outerHeight() - el.height() };
2316:         this.originalMousePosition = { left: event.pageX, top: event.pageY };
2317:
2318:         //Aspect Ratio
2319:         this.aspectRatio = (typeof o.aspectRatio == 'number') ? o.aspectRatio : ((this.originalSize.width / this.originalSize.height) || 1);
2320:
2321:         var cursor = $('.ui-resizable-' + this.axis).css('cursor');
2322:         $('body').css('cursor', cursor == 'auto' ? this.axis + '-resize' : cursor);
2323:
2324:         el.addClass("ui-resizable-resizing");
2325:         this._propagate("start", event);
2326:         return true;
2327:     },
2328:
2329:     _mouseDrag: function(event) {
2330:
2331:         //Increase performance, avoid regex
2332:         var el = this.helper, o = this.options, props = {},
2333:             that = this, smp = this.originalMousePosition, a = this.axis;
2334:
2335:         var dx = (event.pageX-smp.left)||0, dy = (event.pageY-smp.top)||0;
2336:         var trigger = this._change[a];
2337:         if (!trigger) return false;
2338:
2339:         // Calculate the attrs that will be change
2340:         var data = trigger.apply(this, [event, dx, dy]);
2341:
2342:         // Put this in the mouseDrag handler since the user can start pressing shift while resizing
2343:         this._updateVirtualBoundaries(event.shiftKey);
2344:         if (this._aspectRatio || event.shiftKey)
2345:             data = this._updateRatio(data, event);
2346:
2347:         data = this._respectSize(data, event);
2348:
2349:         // plugins callbacks need to be called first
2350:         this._propagate("resize", event);
2351:
2352:         el.css({
2353:             top: this.position.top + "px", left: this.position.left + "px",
2354:             width: this.size.width + "px", height: this.size.height + "px"
2355:         });
2356:
2357:         if (!this._helper && this._proportionallyResizeElements.length)
2358:             this._proportionallyResize();
2359:
2360:         this._updateCache(data);
2361:
2362:         // calling the user callback at the end
2363:         this._trigger('resize', event, this.ui());
2364:
2365:         return false;
2366:     },
2367:
2368:     _mouseStop: function(event) {
2369:
2370:         this.resizing = false;
2371:         var o = this.options, that = this;
2372:
2373:         if(this._helper) {
2374:             var pr = this._proportionallyResizeElements, ista = pr.length && (/textarea/i).test(pr[0].nodeName),
2375:                 soffseth = ista && $.ui.hasScroll(pr[0], 'left') /* TODO - jump height */ ? 0 : that.sizeDiff.height,
2376:                 soffsetw = ista ? 0 : that.sizeDiff.width;
2377:
2378:             var s = { width: (that.helper.width() - soffsetw), height: (that.helper.height() - soffseth) },
2379:                 left = (parseInt(that.element.css('left'), 10) + (that.position.left - that.originalPosition.left)) || null,
2380:                 top = (parseInt(that.element.css('top'), 10) + (that.position.top - that.originalPosition.top)) || null;
2381:
2382:             if (!o.animate)
2383:                 this.element.css($.extend(s, { top: top, left: left }));
2384:
2385:             that.helper.height(that.size.height);
2386:             that.helper.width(that.size.width);
2387:
2388:             if (this._helper && !o.animate) this._proportionallyResize();
2389:         }
2390:
2391:         $('body').css('cursor', 'auto');
2392:
2393:         this.element.removeClass("ui-resizable-resizing");
2394:
2395:         this._propagate("stop", event);
2396:
2397:         if (this._helper) this.helper.remove();
2398:         return false;
2399:
2400:     },
2401:
2402:     _updateVirtualBoundaries: function(forceAspectRatio) {
2403:         var o = this.options, pMinWidth, pMaxWidth, pMinHeight, pMaxHeight, b;
2404:
2405:         b = {
2406:             minWidth: isNumber(o.minWidth) ? o.minWidth : 0,
2407:             maxWidth: isNumber(o.maxWidth) ? o.maxWidth : Infinity,
2408:             minHeight: isNumber(o.minHeight) ? o.minHeight : 0,
2409:             maxHeight: isNumber(o.maxHeight) ? o.maxHeight : Infinity
2410:         };
2411:
2412:         if(this._aspectRatio || forceAspectRatio) {
2413:             // We want to create an enclosing box whose aspect ration is the requested one
2414:             // First, compute the "projected" size for each dimension based on the aspect ratio and other dimension
2415:             pMinWidth = b.minHeight * this.aspectRatio;
2416:             pMinHeight = b.minWidth / this.aspectRatio;
2417:             pMaxWidth = b.maxHeight * this.aspectRatio;
2418:             pMaxHeight = b.maxWidth / this.aspectRatio;
2419:
2420:             if(pMinWidth > b.minWidth) b.minWidth = pMinWidth;
2421:             if(pMinHeight > b.minHeight) b.minHeight = pMinHeight;
2422:             if(pMaxWidth < b.maxWidth) b.maxWidth = pMaxWidth;
2423:             if(pMaxHeight < b.maxHeight) b.maxHeight = pMaxHeight;
2424:         }
2425:         this._vBoundaries = b;
2426:     },
2427:
2428:     _updateCache: function(data) {
2429:         var o = this.options;
2430:         this.offset = this.helper.offset();
2431:         if (isNumber(data.left)) this.position.left = data.left;
2432:         if (isNumber(data.top)) this.position.top = data.top;
2433:         if (isNumber(data.height)) this.size.height = data.height;
2434:         if (isNumber(data.width)) this.size.width = data.width;
2435:     },
2436:
2437:     _updateRatio: function(data, event) {
2438:
2439:         var o = this.options, cpos = this.position, csize = this.size, a = this.axis;
2440:
2441:         if (isNumber(data.height)) data.width = (data.height * this.aspectRatio);
2442:         else if (isNumber(data.width)) data.height = (data.width / this.aspectRatio);
2443:
2444:         if (a == 'sw') {
2445:             data.left = cpos.left + (csize.width - data.width);
2446:             data.top = null;
2447:         }
2448:         if (a == 'nw') {
2449:             data.top = cpos.top + (csize.height - data.height);
2450:             data.left = cpos.left + (csize.width - data.width);
2451:         }
2452:
2453:         return data;
2454:     },
2455:
2456:     _respectSize: function(data, event) {
2457:
2458:         var el = this.helper, o = this._vBoundaries, pRatio = this._aspectRatio || event.shiftKey, a = this.axis,
2459:                 ismaxw = isNumber(data.width) && o.maxWidth && (o.maxWidth < data.width), ismaxh = isNumber(data.height) && o.maxHeight && (o.maxHeight < data.height),
2460:                     isminw = isNumber(data.width) && o.minWidth && (o.minWidth > data.width), isminh = isNumber(data.height) && o.minHeight && (o.minHeight > data.height);
2461:
2462:         if (isminw) data.width = o.minWidth;
2463:         if (isminh) data.height = o.minHeight;
2464:         if (ismaxw) data.width = o.maxWidth;
2465:         if (ismaxh) data.height = o.maxHeight;
2466:
2467:         var dw = this.originalPosition.left + this.originalSize.width, dh = this.position.top + this.size.height;
2468:         var cw = /sw|nw|w/.test(a), ch = /nw|ne|n/.test(a);
2469:
2470:         if (isminw && cw) data.left = dw - o.minWidth;
2471:         if (ismaxw && cw) data.left = dw - o.maxWidth;
2472:         if (isminh && ch)    data.top = dh - o.minHeight;
2473:         if (ismaxh && ch)    data.top = dh - o.maxHeight;
2474:
2475:         // fixing jump error on top/left - bug #2330
2476:         var isNotwh = !data.width && !data.height;
2477:         if (isNotwh && !data.left && data.top) data.top = null;
2478:         else if (isNotwh && !data.top && data.left) data.left = null;
2479:
2480:         return data;
2481:     },
2482:
2483:     _proportionallyResize: function() {
2484:
2485:         var o = this.options;
2486:         if (!this._proportionallyResizeElements.length) return;
2487:         var element = this.helper || this.element;
2488:
2489:         for (var i=0; i < this._proportionallyResizeElements.length; i++) {
2490:
2491:             var prel = this._proportionallyResizeElements[i];
2492:
2493:             if (!this.borderDif) {
2494:                 var b = [prel.css('borderTopWidth'), prel.css('borderRightWidth'), prel.css('borderBottomWidth'), prel.css('borderLeftWidth')],
2495:                     p = [prel.css('paddingTop'), prel.css('paddingRight'), prel.css('paddingBottom'), prel.css('paddingLeft')];
2496:
2497:                 this.borderDif = $.map(b, function(v, i) {
2498:                     var border = parseInt(v,10)||0, padding = parseInt(p[i],10)||0;
2499:                     return border + padding;
2500:                 });
2501:             }
2502:
2503:             prel.css({
2504:                 height: (element.height() - this.borderDif[0] - this.borderDif[2]) || 0,
2505:                 width: (element.width() - this.borderDif[1] - this.borderDif[3]) || 0
2506:             });
2507:
2508:         };
2509:
2510:     },
2511:
2512:     _renderProxy: function() {
2513:
2514:         var el = this.element, o = this.options;
2515:         this.elementOffset = el.offset();
2516:
2517:         if(this._helper) {
2518:
2519:             this.helper = this.helper || $('<div style="overflow:hidden;"></div>');
2520:
2521:             // fix ie6 offset TODO: This seems broken
2522:             var ie6 = $.browser.msie && $.browser.version < 7, ie6offset = (ie6 ? 1 : 0),
2523:             pxyoffset = ( ie6 ? 2 : -1 );
2524:
2525:             this.helper.addClass(this._helper).css({
2526:                 width: this.element.outerWidth() + pxyoffset,
2527:                 height: this.element.outerHeight() + pxyoffset,
2528:                 position: 'absolute',
2529:                 left: this.elementOffset.left - ie6offset +'px',
2530:                 top: this.elementOffset.top - ie6offset +'px',
2531:                 zIndex: ++o.zIndex //TODO: Don't modify option
2532:             });
2533:
2534:             this.helper
2535:                 .appendTo("body")
2536:                 .disableSelection();
2537:
2538:         } else {
2539:             this.helper = this.element;
2540:         }
2541:
2542:     },
2543:
2544:     _change: {
2545:         e: function(event, dx, dy) {
2546:             return { width: this.originalSize.width + dx };
2547:         },
2548:         w: function(event, dx, dy) {
2549:             var o = this.options, cs = this.originalSize, sp = this.originalPosition;
2550:             return { left: sp.left + dx, width: cs.width - dx };
2551:         },
2552:         n: function(event, dx, dy) {
2553:             var o = this.options, cs = this.originalSize, sp = this.originalPosition;
2554:             return { top: sp.top + dy, height: cs.height - dy };
2555:         },
2556:         s: function(event, dx, dy) {
2557:             return { height: this.originalSize.height + dy };
2558:         },
2559:         se: function(event, dx, dy) {
2560:             return $.extend(this._change.s.apply(this, arguments), this._change.e.apply(this, [event, dx, dy]));
2561:         },
2562:         sw: function(event, dx, dy) {
2563:             return $.extend(this._change.s.apply(this, arguments), this._change.w.apply(this, [event, dx, dy]));
2564:         },
2565:         ne: function(event, dx, dy) {
2566:             return $.extend(this._change.n.apply(this, arguments), this._change.e.apply(this, [event, dx, dy]));
2567:         },
2568:         nw: function(event, dx, dy) {
2569:             return $.extend(this._change.n.apply(this, arguments), this._change.w.apply(this, [event, dx, dy]));
2570:         }
2571:     },
2572:
2573:     _propagate: function(n, event) {
2574:         $.ui.plugin.call(this, n, [event, this.ui()]);
2575:         (n != "resize" && this._trigger(n, event, this.ui()));
2576:     },
2577:
2578:     plugins: {},
2579:
2580:     ui: function() {
2581:         return {
2582:             originalElement: this.originalElement,
2583:             element: this.element,
2584:             helper: this.helper,
2585:             position: this.position,
2586:             size: this.size,
2587:             originalSize: this.originalSize,
2588:             originalPosition: this.originalPosition
2589:         };
2590:     }
2591:
2592: });
2593:
2594: /*
2595: * Resizable Extensions
2596: */
2597:
2598: $.ui.plugin.add("resizable", "alsoResize", {
2599:
2600:     start: function (event, ui) {
2601:         var that = $(this).data("resizable"), o = that.options;
2602:
2603:         var _store = function (exp) {
2604:             $(exp).each(function() {
2605:                 var el = $(this);
2606:                 el.data("resizable-alsoresize", {
2607:                     width: parseInt(el.width(), 10), height: parseInt(el.height(), 10),
2608:                     left: parseInt(el.css('left'), 10), top: parseInt(el.css('top'), 10)
2609:                 });
2610:             });
2611:         };
2612:
2613:         if (typeof(o.alsoResize) == 'object' && !o.alsoResize.parentNode) {
2614:             if (o.alsoResize.length) { o.alsoResize = o.alsoResize[0]; _store(o.alsoResize); }
2615:             else { $.each(o.alsoResize, function (exp) { _store(exp); }); }
2616:         }else{
2617:             _store(o.alsoResize);
2618:         }
2619:     },
2620:
2621:     resize: function (event, ui) {
2622:         var that = $(this).data("resizable"), o = that.options, os = that.originalSize, op = that.originalPosition;
2623:
2624:         var delta = {
2625:             height: (that.size.height - os.height) || 0, width: (that.size.width - os.width) || 0,
2626:             top: (that.position.top - op.top) || 0, left: (that.position.left - op.left) || 0
2627:         },
2628:
2629:         _alsoResize = function (exp, c) {
2630:             $(exp).each(function() {
2631:                 var el = $(this), start = $(this).data("resizable-alsoresize"), style = {},
2632:                     css = c && c.length ? c : el.parents(ui.originalElement[0]).length ? ['width', 'height'] : ['width', 'height', 'top', 'left'];
2633:
2634:                 $.each(css, function (i, prop) {
2635:                     var sum = (start[prop]||0) + (delta[prop]||0);
2636:                     if (sum && sum >= 0)
2637:                         style[prop] = sum || null;
2638:                 });
2639:
2640:                 el.css(style);
2641:             });
2642:         };
2643:
2644:         if (typeof(o.alsoResize) == 'object' && !o.alsoResize.nodeType) {
2645:             $.each(o.alsoResize, function (exp, c) { _alsoResize(exp, c); });
2646:         }else{
2647:             _alsoResize(o.alsoResize);
2648:         }
2649:     },
2650:
2651:     stop: function (event, ui) {
2652:         $(this).removeData("resizable-alsoresize");
2653:     }
2654: });
2655:
2656: $.ui.plugin.add("resizable", "animate", {
2657:
2658:     stop: function(event, ui) {
2659:         var that = $(this).data("resizable"), o = that.options;
2660:
2661:         var pr = that._proportionallyResizeElements, ista = pr.length && (/textarea/i).test(pr[0].nodeName),
2662:                     soffseth = ista && $.ui.hasScroll(pr[0], 'left') /* TODO - jump height */ ? 0 : that.sizeDiff.height,
2663:                         soffsetw = ista ? 0 : that.sizeDiff.width;
2664:
2665:         var style = { width: (that.size.width - soffsetw), height: (that.size.height - soffseth) },
2666:                     left = (parseInt(that.element.css('left'), 10) + (that.position.left - that.originalPosition.left)) || null,
2667:                         top = (parseInt(that.element.css('top'), 10) + (that.position.top - that.originalPosition.top)) || null;
2668:
2669:         that.element.animate(
2670:             $.extend(style, top && left ? { top: top, left: left } : {}), {
2671:                 duration: o.animateDuration,
2672:                 easing: o.animateEasing,
2673:                 step: function() {
2674:
2675:                     var data = {
2676:                         width: parseInt(that.element.css('width'), 10),
2677:                         height: parseInt(that.element.css('height'), 10),
2678:                         top: parseInt(that.element.css('top'), 10),
2679:                         left: parseInt(that.element.css('left'), 10)
2680:                     };
2681:
2682:                     if (pr && pr.length) $(pr[0]).css({ width: data.width, height: data.height });
2683:
2684:                     // propagating resize, and updating values for each animation step
2685:                     that._updateCache(data);
2686:                     that._propagate("resize", event);
2687:
2688:                 }
2689:             }
2690:         );
2691:     }
2692:
2693: });
2694:
2695: $.ui.plugin.add("resizable", "containment", {
2696:
2697:     start: function(event, ui) {
2698:         var that = $(this).data("resizable"), o = that.options, el = that.element;
2699:         var oc = o.containment,    ce = (oc instanceof $) ? oc.get(0) : (/parent/.test(oc)) ? el.parent().get(0) : oc;
2700:         if (!ce) return;
2701:
2702:         that.containerElement = $(ce);
2703:
2704:         if (/document/.test(oc) || oc == document) {
2705:             that.containerOffset = { left: 0, top: 0 };
2706:             that.containerPosition = { left: 0, top: 0 };
2707:
2708:             that.parentData = {
2709:                 element: $(document), left: 0, top: 0,
2710:                 width: $(document).width(), height: $(document).height() || document.body.parentNode.scrollHeight
2711:             };
2712:         }
2713:
2714:         // i'm a node, so compute top, left, right, bottom
2715:         else {
2716:             var element = $(ce), p = [];
2717:             $([ "Top", "Right", "Left", "Bottom" ]).each(function(i, name) { p[i] = num(element.css("padding" + name)); });
2718:
2719:             that.containerOffset = element.offset();
2720:             that.containerPosition = element.position();
2721:             that.containerSize = { height: (element.innerHeight() - p[3]), width: (element.innerWidth() - p[1]) };
2722:
2723:             var co = that.containerOffset, ch = that.containerSize.height,    cw = that.containerSize.width,
2724:                         width = ($.ui.hasScroll(ce, "left") ? ce.scrollWidth : cw ), height = ($.ui.hasScroll(ce) ? ce.scrollHeight : ch);
2725:
2726:             that.parentData = {
2727:                 element: ce, left: co.left, top: co.top, width: width, height: height
2728:             };
2729:         }
2730:     },
2731:
2732:     resize: function(event, ui) {
2733:         var that = $(this).data("resizable"), o = that.options,
2734:                 ps = that.containerSize, co = that.containerOffset, cs = that.size, cp = that.position,
2735:                 pRatio = that._aspectRatio || event.shiftKey, cop = { top:0, left:0 }, ce = that.containerElement;
2736:
2737:         if (ce[0] != document && (/static/).test(ce.css('position'))) cop = co;
2738:
2739:         if (cp.left < (that._helper ? co.left : 0)) {
2740:             that.size.width = that.size.width + (that._helper ? (that.position.left - co.left) : (that.position.left - cop.left));
2741:             if (pRatio) that.size.height = that.size.width / that.aspectRatio;
2742:             that.position.left = o.helper ? co.left : 0;
2743:         }
2744:
2745:         if (cp.top < (that._helper ? co.top : 0)) {
2746:             that.size.height = that.size.height + (that._helper ? (that.position.top - co.top) : that.position.top);
2747:             if (pRatio) that.size.width = that.size.height * that.aspectRatio;
2748:             that.position.top = that._helper ? co.top : 0;
2749:         }
2750:
2751:         that.offset.left = that.parentData.left+that.position.left;
2752:         that.offset.top = that.parentData.top+that.position.top;
2753:
2754:         var woset = Math.abs( (that._helper ? that.offset.left - cop.left : (that.offset.left - cop.left)) + that.sizeDiff.width ),
2755:                     hoset = Math.abs( (that._helper ? that.offset.top - cop.top : (that.offset.top - co.top)) + that.sizeDiff.height );
2756:
2757:         var isParent = that.containerElement.get(0) == that.element.parent().get(0),
2758:             isOffsetRelative = /relative|absolute/.test(that.containerElement.css('position'));
2759:
2760:         if(isParent && isOffsetRelative) woset -= that.parentData.left;
2761:
2762:         if (woset + that.size.width >= that.parentData.width) {
2763:             that.size.width = that.parentData.width - woset;
2764:             if (pRatio) that.size.height = that.size.width / that.aspectRatio;
2765:         }
2766:
2767:         if (hoset + that.size.height >= that.parentData.height) {
2768:             that.size.height = that.parentData.height - hoset;
2769:             if (pRatio) that.size.width = that.size.height * that.aspectRatio;
2770:         }
2771:     },
2772:
2773:     stop: function(event, ui){
2774:         var that = $(this).data("resizable"), o = that.options, cp = that.position,
2775:                 co = that.containerOffset, cop = that.containerPosition, ce = that.containerElement;
2776:
2777:         var helper = $(that.helper), ho = helper.offset(), w = helper.outerWidth() - that.sizeDiff.width, h = helper.outerHeight() - that.sizeDiff.height;
2778:
2779:         if (that._helper && !o.animate && (/relative/).test(ce.css('position')))
2780:             $(this).css({ left: ho.left - cop.left - co.left, width: w, height: h });
2781:
2782:         if (that._helper && !o.animate && (/static/).test(ce.css('position')))
2783:             $(this).css({ left: ho.left - cop.left - co.left, width: w, height: h });
2784:
2785:     }
2786: });
2787:
2788: $.ui.plugin.add("resizable", "ghost", {
2789:
2790:     start: function(event, ui) {
2791:
2792:         var that = $(this).data("resizable"), o = that.options, cs = that.size;
2793:
2794:         that.ghost = that.originalElement.clone();
2795:         that.ghost
2796:             .css({ opacity: .25, display: 'block', position: 'relative', height: cs.height, width: cs.width, margin: 0, left: 0, top: 0 })
2797:             .addClass('ui-resizable-ghost')
2798:             .addClass(typeof o.ghost == 'string' ? o.ghost : '');
2799:
2800:         that.ghost.appendTo(that.helper);
2801:
2802:     },
2803:
2804:     resize: function(event, ui){
2805:         var that = $(this).data("resizable"), o = that.options;
2806:         if (that.ghost) that.ghost.css({ position: 'relative', height: that.size.height, width: that.size.width });
2807:     },
2808:
2809:     stop: function(event, ui){
2810:         var that = $(this).data("resizable"), o = that.options;
2811:         if (that.ghost && that.helper) that.helper.get(0).removeChild(that.ghost.get(0));
2812:     }
2813:
2814: });
2815:
2816: $.ui.plugin.add("resizable", "grid", {
2817:
2818:     resize: function(event, ui) {
2819:         var that = $(this).data("resizable"), o = that.options, cs = that.size, os = that.originalSize, op = that.originalPosition, a = that.axis, ratio = o._aspectRatio || event.shiftKey;
2820:         o.grid = typeof o.grid == "number" ? [o.grid, o.grid] : o.grid;
2821:         var ox = Math.round((cs.width - os.width) / (o.grid[0]||1)) * (o.grid[0]||1), oy = Math.round((cs.height - os.height) / (o.grid[1]||1)) * (o.grid[1]||1);
2822:
2823:         if (/^(se|s|e)$/.test(a)) {
2824:             that.size.width = os.width + ox;
2825:             that.size.height = os.height + oy;
2826:         }
2827:         else if (/^(ne)$/.test(a)) {
2828:             that.size.width = os.width + ox;
2829:             that.size.height = os.height + oy;
2830:             that.position.top = op.top - oy;
2831:         }
2832:         else if (/^(sw)$/.test(a)) {
2833:             that.size.width = os.width + ox;
2834:             that.size.height = os.height + oy;
2835:             that.position.left = op.left - ox;
2836:         }
2837:         else {
2838:             that.size.width = os.width + ox;
2839:             that.size.height = os.height + oy;
2840:             that.position.top = op.top - oy;
2841:             that.position.left = op.left - ox;
2842:         }
2843:     }
2844:
2845: });
2846:
2847: var num = function(v) {
2848:     return parseInt(v, 10) || 0;
2849: };
2850:
2851: var isNumber = function(value) {
2852:     return !isNaN(parseInt(value, 10));
2853: };
2854:
2855: })(jQuery);
2856:
2857: (function( $, undefined ) {
2858:
2859: $.widget("ui.selectable", $.ui.mouse, {
2860:     version: "1.9.0",
2861:     options: {
2862:         appendTo: 'body',
2863:         autoRefresh: true,
2864:         distance: 0,
2865:         filter: '*',
2866:         tolerance: 'touch'
2867:     },
2868:     _create: function() {
2869:         var that = this;
2870:
2871:         this.element.addClass("ui-selectable");
2872:
2873:         this.dragged = false;
2874:
2875:         // cache selectee children based on filter
2876:         var selectees;
2877:         this.refresh = function() {
2878:             selectees = $(that.options.filter, that.element[0]);
2879:             selectees.addClass("ui-selectee");
2880:             selectees.each(function() {
2881:                 var $this = $(this);
2882:                 var pos = $this.offset();
2883:                 $.data(this, "selectable-item", {
2884:                     element: this,
2885:                     $element: $this,
2886:                     left: pos.left,
2887:                     top: pos.top,
2888:                     right: pos.left + $this.outerWidth(),
2889:                     bottom: pos.top + $this.outerHeight(),
2890:                     startselected: false,
2891:                     selected: $this.hasClass('ui-selected'),
2892:                     selecting: $this.hasClass('ui-selecting'),
2893:                     unselecting: $this.hasClass('ui-unselecting')
2894:                 });
2895:             });
2896:         };
2897:         this.refresh();
2898:
2899:         this.selectees = selectees.addClass("ui-selectee");
2900:
2901:         this._mouseInit();
2902:
2903:         this.helper = $("<div class='ui-selectable-helper'></div>");
2904:     },
2905:
2906:     _destroy: function() {
2907:         this.selectees
2908:             .removeClass("ui-selectee")
2909:             .removeData("selectable-item");
2910:         this.element
2911:             .removeClass("ui-selectable ui-selectable-disabled");
2912:         this._mouseDestroy();
2913:     },
2914:
2915:     _mouseStart: function(event) {
2916:         var that = this;
2917:
2918:         this.opos = [event.pageX, event.pageY];
2919:
2920:         if (this.options.disabled)
2921:             return;
2922:
2923:         var options = this.options;
2924:
2925:         this.selectees = $(options.filter, this.element[0]);
2926:
2927:         this._trigger("start", event);
2928:
2929:         $(options.appendTo).append(this.helper);
2930:         // position helper (lasso)
2931:         this.helper.css({
2932:             "left": event.clientX,
2933:             "top": event.clientY,
2934:             "width": 0,
2935:             "height": 0
2936:         });
2937:
2938:         if (options.autoRefresh) {
2939:             this.refresh();
2940:         }
2941:
2942:         this.selectees.filter('.ui-selected').each(function() {
2943:             var selectee = $.data(this, "selectable-item");
2944:             selectee.startselected = true;
2945:             if (!event.metaKey && !event.ctrlKey) {
2946:                 selectee.$element.removeClass('ui-selected');
2947:                 selectee.selected = false;
2948:                 selectee.$element.addClass('ui-unselecting');
2949:                 selectee.unselecting = true;
2950:                 // selectable UNSELECTING callback
2951:                 that._trigger("unselecting", event, {
2952:                     unselecting: selectee.element
2953:                 });
2954:             }
2955:         });
2956:
2957:         $(event.target).parents().andSelf().each(function() {
2958:             var selectee = $.data(this, "selectable-item");
2959:             if (selectee) {
2960:                 var doSelect = (!event.metaKey && !event.ctrlKey) || !selectee.$element.hasClass('ui-selected');
2961:                 selectee.$element
2962:                     .removeClass(doSelect ? "ui-unselecting" : "ui-selected")
2963:                     .addClass(doSelect ? "ui-selecting" : "ui-unselecting");
2964:                 selectee.unselecting = !doSelect;
2965:                 selectee.selecting = doSelect;
2966:                 selectee.selected = doSelect;
2967:                 // selectable (UN)SELECTING callback
2968:                 if (doSelect) {
2969:                     that._trigger("selecting", event, {
2970:                         selecting: selectee.element
2971:                     });
2972:                 } else {
2973:                     that._trigger("unselecting", event, {
2974:                         unselecting: selectee.element
2975:                     });
2976:                 }
2977:                 return false;
2978:             }
2979:         });
2980:
2981:     },
2982:
2983:     _mouseDrag: function(event) {
2984:         var that = this;
2985:         this.dragged = true;
2986:
2987:         if (this.options.disabled)
2988:             return;
2989:
2990:         var options = this.options;
2991:
2992:         var x1 = this.opos[0], y1 = this.opos[1], x2 = event.pageX, y2 = event.pageY;
2993:         if (x1 > x2) { var tmp = x2; x2 = x1; x1 = tmp; }
2994:         if (y1 > y2) { var tmp = y2; y2 = y1; y1 = tmp; }
2995:         this.helper.css({left: x1, top: y1, width: x2-x1, height: y2-y1});
2996:
2997:         this.selectees.each(function() {
2998:             var selectee = $.data(this, "selectable-item");
2999:             //prevent helper from being selected if appendTo: selectable
3000:             if (!selectee || selectee.element == that.element[0])
3001:                 return;
3002:             var hit = false;
3003:             if (options.tolerance == 'touch') {
3004:                 hit = ( !(selectee.left > x2 || selectee.right < x1 || selectee.top > y2 || selectee.bottom < y1) );
3005:             } else if (options.tolerance == 'fit') {
3006:                 hit = (selectee.left > x1 && selectee.right < x2 && selectee.top > y1 && selectee.bottom < y2);
3007:             }
3008:
3009:             if (hit) {
3010:                 // SELECT
3011:                 if (selectee.selected) {
3012:                     selectee.$element.removeClass('ui-selected');
3013:                     selectee.selected = false;
3014:                 }
3015:                 if (selectee.unselecting) {
3016:                     selectee.$element.removeClass('ui-unselecting');
3017:                     selectee.unselecting = false;
3018:                 }
3019:                 if (!selectee.selecting) {
3020:                     selectee.$element.addClass('ui-selecting');
3021:                     selectee.selecting = true;
3022:                     // selectable SELECTING callback
3023:                     that._trigger("selecting", event, {
3024:                         selecting: selectee.element
3025:                     });
3026:                 }
3027:             } else {
3028:                 // UNSELECT
3029:                 if (selectee.selecting) {
3030:                     if ((event.metaKey || event.ctrlKey) && selectee.startselected) {
3031:                         selectee.$element.removeClass('ui-selecting');
3032:                         selectee.selecting = false;
3033:                         selectee.$element.addClass('ui-selected');
3034:                         selectee.selected = true;
3035:                     } else {
3036:                         selectee.$element.removeClass('ui-selecting');
3037:                         selectee.selecting = false;
3038:                         if (selectee.startselected) {
3039:                             selectee.$element.addClass('ui-unselecting');
3040:                             selectee.unselecting = true;
3041:                         }
3042:                         // selectable UNSELECTING callback
3043:                         that._trigger("unselecting", event, {
3044:                             unselecting: selectee.element
3045:                         });
3046:                     }
3047:                 }
3048:                 if (selectee.selected) {
3049:                     if (!event.metaKey && !event.ctrlKey && !selectee.startselected) {
3050:                         selectee.$element.removeClass('ui-selected');
3051:                         selectee.selected = false;
3052:
3053:                         selectee.$element.addClass('ui-unselecting');
3054:                         selectee.unselecting = true;
3055:                         // selectable UNSELECTING callback
3056:                         that._trigger("unselecting", event, {
3057:                             unselecting: selectee.element
3058:                         });
3059:                     }
3060:                 }
3061:             }
3062:         });
3063:
3064:         return false;
3065:     },
3066:
3067:     _mouseStop: function(event) {
3068:         var that = this;
3069:
3070:         this.dragged = false;
3071:
3072:         var options = this.options;
3073:
3074:         $('.ui-unselecting', this.element[0]).each(function() {
3075:             var selectee = $.data(this, "selectable-item");
3076:             selectee.$element.removeClass('ui-unselecting');
3077:             selectee.unselecting = false;
3078:             selectee.startselected = false;
3079:             that._trigger("unselected", event, {
3080:                 unselected: selectee.element
3081:             });
3082:         });
3083:         $('.ui-selecting', this.element[0]).each(function() {
3084:             var selectee = $.data(this, "selectable-item");
3085:             selectee.$element.removeClass('ui-selecting').addClass('ui-selected');
3086:             selectee.selecting = false;
3087:             selectee.selected = true;
3088:             selectee.startselected = true;
3089:             that._trigger("selected", event, {
3090:                 selected: selectee.element
3091:             });
3092:         });
3093:         this._trigger("stop", event);
3094:
3095:         this.helper.remove();
3096:
3097:         return false;
3098:     }
3099:
3100: });
3101:
3102: })(jQuery);
3103:
3104: (function( $, undefined ) {
3105:
3106: $.widget("ui.sortable", $.ui.mouse, {
3107:     version: "1.9.0",
3108:     widgetEventPrefix: "sort",
3109:     ready: false,
3110:     options: {
3111:         appendTo: "parent",
3112:         axis: false,
3113:         connectWith: false,
3114:         containment: false,
3115:         cursor: 'auto',
3116:         cursorAt: false,
3117:         dropOnEmpty: true,
3118:         forcePlaceholderSize: false,
3119:         forceHelperSize: false,
3120:         grid: false,
3121:         handle: false,
3122:         helper: "original",
3123:         items: '> *',
3124:         opacity: false,
3125:         placeholder: false,
3126:         revert: false,
3127:         scroll: true,
3128:         scrollSensitivity: 20,
3129:         scrollSpeed: 20,
3130:         scope: "default",
3131:         tolerance: "intersect",
3132:         zIndex: 1000
3133:     },
3134:     _create: function() {
3135:
3136:         var o = this.options;
3137:         this.containerCache = {};
3138:         this.element.addClass("ui-sortable");
3139:
3140:         //Get the items
3141:         this.refresh();
3142:
3143:         //Let's determine if the items are being displayed horizontally
3144:         this.floating = this.items.length ? o.axis === 'x' || (/left|right/).test(this.items[0].item.css('float')) || (/inline|table-cell/).test(this.items[0].item.css('display')) : false;
3145:
3146:         //Let's determine the parent's offset
3147:         this.offset = this.element.offset();
3148:
3149:         //Initialize mouse events for interaction
3150:         this._mouseInit();
3151:
3152:         //We're ready to go
3153:         this.ready = true
3154:
3155:     },
3156:
3157:     _destroy: function() {
3158:         this.element
3159:             .removeClass("ui-sortable ui-sortable-disabled");
3160:         this._mouseDestroy();
3161:
3162:         for ( var i = this.items.length - 1; i >= 0; i-- )
3163:             this.items[i].item.removeData(this.widgetName + "-item");
3164:
3165:         return this;
3166:     },
3167:
3168:     _setOption: function(key, value){
3169:         if ( key === "disabled" ) {
3170:             this.options[ key ] = value;
3171:
3172:             this.widget().toggleClass( "ui-sortable-disabled", !!value );
3173:         } else {
3174:             // Don't call widget base _setOption for disable as it adds ui-state-disabled class
3175:             $.Widget.prototype._setOption.apply(this, arguments);
3176:         }
3177:     },
3178:
3179:     _mouseCapture: function(event, overrideHandle) {
3180:         var that = this;
3181:
3182:         if (this.reverting) {
3183:             return false;
3184:         }
3185:
3186:         if(this.options.disabled || this.options.type == 'static') return false;
3187:
3188:         //We have to refresh the items data once first
3189:         this._refreshItems(event);
3190:
3191:         //Find out if the clicked node (or one of its parents) is a actual item in this.items
3192:         var currentItem = null, nodes = $(event.target).parents().each(function() {
3193:             if($.data(this, that.widgetName + '-item') == that) {
3194:                 currentItem = $(this);
3195:                 return false;
3196:             }
3197:         });
3198:         if($.data(event.target, that.widgetName + '-item') == that) currentItem = $(event.target);
3199:
3200:         if(!currentItem) return false;
3201:         if(this.options.handle && !overrideHandle) {
3202:             var validHandle = false;
3203:
3204:             $(this.options.handle, currentItem).find("*").andSelf().each(function() { if(this == event.target) validHandle = true; });
3205:             if(!validHandle) return false;
3206:         }
3207:
3208:         this.currentItem = currentItem;
3209:         this._removeCurrentsFromItems();
3210:         return true;
3211:
3212:     },
3213:
3214:     _mouseStart: function(event, overrideHandle, noActivation) {
3215:
3216:         var o = this.options;
3217:         this.currentContainer = this;
3218:
3219:         //We only need to call refreshPositions, because the refreshItems call has been moved to mouseCapture
3220:         this.refreshPositions();
3221:
3222:         //Create and append the visible helper
3223:         this.helper = this._createHelper(event);
3224:
3225:         //Cache the helper size
3226:         this._cacheHelperProportions();
3227:
3228:         /*
3229:          * - Position generation -
3230:          * This block generates everything position related - it's the core of draggables.
3231:          */
3232:
3233:         //Cache the margins of the original element
3234:         this._cacheMargins();
3235:
3236:         //Get the next scrolling parent
3237:         this.scrollParent = this.helper.scrollParent();
3238:
3239:         //The element's absolute position on the page minus margins
3240:         this.offset = this.currentItem.offset();
3241:         this.offset = {
3242:             top: this.offset.top - this.margins.top,
3243:             left: this.offset.left - this.margins.left
3244:         };
3245:
3246:         $.extend(this.offset, {
3247:             click: { //Where the click happened, relative to the element
3248:                 left: event.pageX - this.offset.left,
3249:                 top: event.pageY - this.offset.top
3250:             },
3251:             parent: this._getParentOffset(),
3252:             relative: this._getRelativeOffset() //This is a relative to absolute position minus the actual position calculation - only used for relative positioned helper
3253:         });
3254:
3255:         // Only after we got the offset, we can change the helper's position to absolute
3256:         // TODO: Still need to figure out a way to make relative sorting possible
3257:         this.helper.css("position", "absolute");
3258:         this.cssPosition = this.helper.css("position");
3259:
3260:         //Generate the original position
3261:         this.originalPosition = this._generatePosition(event);
3262:         this.originalPageX = event.pageX;
3263:         this.originalPageY = event.pageY;
3264:
3265:         //Adjust the mouse offset relative to the helper if 'cursorAt' is supplied
3266:         (o.cursorAt && this._adjustOffsetFromHelper(o.cursorAt));
3267:
3268:         //Cache the former DOM position
3269:         this.domPosition = { prev: this.currentItem.prev()[0], parent: this.currentItem.parent()[0] };
3270:
3271:         //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
3272:         if(this.helper[0] != this.currentItem[0]) {
3273:             this.currentItem.hide();
3274:         }
3275:
3276:         //Create the placeholder
3277:         this._createPlaceholder();
3278:
3279:         //Set a containment if given in the options
3280:         if(o.containment)
3281:             this._setContainment();
3282:
3283:         if(o.cursor) { // cursor option
3284:             if ($('body').css("cursor")) this._storedCursor = $('body').css("cursor");
3285:             $('body').css("cursor", o.cursor);
3286:         }
3287:
3288:         if(o.opacity) { // opacity option
3289:             if (this.helper.css("opacity")) this._storedOpacity = this.helper.css("opacity");
3290:             this.helper.css("opacity", o.opacity);
3291:         }
3292:
3293:         if(o.zIndex) { // zIndex option
3294:             if (this.helper.css("zIndex")) this._storedZIndex = this.helper.css("zIndex");
3295:             this.helper.css("zIndex", o.zIndex);
3296:         }
3297:
3298:         //Prepare scrolling
3299:         if(this.scrollParent[0] != document && this.scrollParent[0].tagName != 'HTML')
3300:             this.overflowOffset = this.scrollParent.offset();
3301:
3302:         //Call callbacks
3303:         this._trigger("start", event, this._uiHash());
3304:
3305:         //Recache the helper size
3306:         if(!this._preserveHelperProportions)
3307:             this._cacheHelperProportions();
3308:
3309:
3310:         //Post 'activate' events to possible containers
3311:         if(!noActivation) {
3312:              for (var i = this.containers.length - 1; i >= 0; i--) { this.containers[i]._trigger("activate", event, this._uiHash(this)); }
3313:         }
3314:
3315:         //Prepare possible droppables
3316:         if($.ui.ddmanager)
3317:             $.ui.ddmanager.current = this;
3318:
3319:         if ($.ui.ddmanager && !o.dropBehaviour)
3320:             $.ui.ddmanager.prepareOffsets(this, event);
3321:
3322:         this.dragging = true;
3323:
3324:         this.helper.addClass("ui-sortable-helper");
3325:         this._mouseDrag(event); //Execute the drag once - this causes the helper not to be visible before getting its correct position
3326:         return true;
3327:
3328:     },
3329:
3330:     _mouseDrag: function(event) {
3331:
3332:         //Compute the helpers position
3333:         this.position = this._generatePosition(event);
3334:         this.positionAbs = this._convertPositionTo("absolute");
3335:
3336:         if (!this.lastPositionAbs) {
3337:             this.lastPositionAbs = this.positionAbs;
3338:         }
3339:
3340:         //Do scrolling
3341:         if(this.options.scroll) {
3342:             var o = this.options, scrolled = false;
3343:             if(this.scrollParent[0] != document && this.scrollParent[0].tagName != 'HTML') {
3344:
3345:                 if((this.overflowOffset.top + this.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity)
3346:                     this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop + o.scrollSpeed;
3347:                 else if(event.pageY - this.overflowOffset.top < o.scrollSensitivity)
3348:                     this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop - o.scrollSpeed;
3349:
3350:                 if((this.overflowOffset.left + this.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity)
3351:                     this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft + o.scrollSpeed;
3352:                 else if(event.pageX - this.overflowOffset.left < o.scrollSensitivity)
3353:                     this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft - o.scrollSpeed;
3354:
3355:             } else {
3356:
3357:                 if(event.pageY - $(document).scrollTop() < o.scrollSensitivity)
3358:                     scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed);
3359:                 else if($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity)
3360:                     scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed);
3361:
3362:                 if(event.pageX - $(document).scrollLeft() < o.scrollSensitivity)
3363:                     scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed);
3364:                 else if($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity)
3365:                     scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);
3366:
3367:             }
3368:
3369:             if(scrolled !== false && $.ui.ddmanager && !o.dropBehaviour)
3370:                 $.ui.ddmanager.prepareOffsets(this, event);
3371:         }
3372:
3373:         //Regenerate the absolute position used for position checks
3374:         this.positionAbs = this._convertPositionTo("absolute");
3375:
3376:         //Set the helper position
3377:         if(!this.options.axis || this.options.axis != "y") this.helper[0].style.left = this.position.left+'px';
3378:         if(!this.options.axis || this.options.axis != "x") this.helper[0].style.top = this.position.top+'px';
3379:
3380:         //Rearrange
3381:         for (var i = this.items.length - 1; i >= 0; i--) {
3382:
3383:             //Cache variables and intersection, continue if no intersection
3384:             var item = this.items[i], itemElement = item.item[0], intersection = this._intersectsWithPointer(item);
3385:             if (!intersection) continue;
3386:
3387:             // Only put the placeholder inside the current Container, skip all
3388:             // items form other containers. This works because when moving
3389:             // an item from one container to another the
3390:             // currentContainer is switched before the placeholder is moved.
3391:             //
3392:             // Without this moving items in "sub-sortables" can cause the placeholder to jitter
3393:             // beetween the outer and inner container.
3394:             if (item.instance !== this.currentContainer) continue;
3395:
3396:             if (itemElement != this.currentItem[0] //cannot intersect with itself
3397:                 &&    this.placeholder[intersection == 1 ? "next" : "prev"]()[0] != itemElement //no useless actions that have been done before
3398:                 &&    !$.contains(this.placeholder[0], itemElement) //no action if the item moved is the parent of the item checked
3399:                 && (this.options.type == 'semi-dynamic' ? !$.contains(this.element[0], itemElement) : true)
3400:                 //&& itemElement.parentNode == this.placeholder[0].parentNode // only rearrange items within the same container
3401:             ) {
3402:
3403:                 this.direction = intersection == 1 ? "down" : "up";
3404:
3405:                 if (this.options.tolerance == "pointer" || this._intersectsWithSides(item)) {
3406:                     this._rearrange(event, item);
3407:                 } else {
3408:                     break;
3409:                 }
3410:
3411:                 this._trigger("change", event, this._uiHash());
3412:                 break;
3413:             }
3414:         }
3415:
3416:         //Post events to containers
3417:         this._contactContainers(event);
3418:
3419:         //Interconnect with droppables
3420:         if($.ui.ddmanager) $.ui.ddmanager.drag(this, event);
3421:
3422:         //Call callbacks
3423:         this._trigger('sort', event, this._uiHash());
3424:
3425:         this.lastPositionAbs = this.positionAbs;
3426:         return false;
3427:
3428:     },
3429:
3430:     _mouseStop: function(event, noPropagation) {
3431:
3432:         if(!event) return;
3433:
3434:         //If we are using droppables, inform the manager about the drop
3435:         if ($.ui.ddmanager && !this.options.dropBehaviour)
3436:             $.ui.ddmanager.drop(this, event);
3437:
3438:         if(this.options.revert) {
3439:             var that = this;
3440:             var cur = this.placeholder.offset();
3441:
3442:             this.reverting = true;
3443:
3444:             $(this.helper).animate({
3445:                 left: cur.left - this.offset.parent.left - this.margins.left + (this.offsetParent[0] == document.body ? 0 : this.offsetParent[0].scrollLeft),
3446:                 top: cur.top - this.offset.parent.top - this.margins.top + (this.offsetParent[0] == document.body ? 0 : this.offsetParent[0].scrollTop)
3447:             }, parseInt(this.options.revert, 10) || 500, function() {
3448:                 that._clear(event);
3449:             });
3450:         } else {
3451:             this._clear(event, noPropagation);
3452:         }
3453:
3454:         return false;
3455:
3456:     },
3457:
3458:     cancel: function() {
3459:
3460:         if(this.dragging) {
3461:
3462:             this._mouseUp({ target: null });
3463:
3464:             if(this.options.helper == "original")
3465:                 this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper");
3466:             else
3467:                 this.currentItem.show();
3468:
3469:             //Post deactivating events to containers
3470:             for (var i = this.containers.length - 1; i >= 0; i--){
3471:                 this.containers[i]._trigger("deactivate", null, this._uiHash(this));
3472:                 if(this.containers[i].containerCache.over) {
3473:                     this.containers[i]._trigger("out", null, this._uiHash(this));
3474:                     this.containers[i].containerCache.over = 0;
3475:                 }
3476:             }
3477:
3478:         }
3479:
3480:         if (this.placeholder) {
3481:             //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node!
3482:             if(this.placeholder[0].parentNode) this.placeholder[0].parentNode.removeChild(this.placeholder[0]);
3483:             if(this.options.helper != "original" && this.helper && this.helper[0].parentNode) this.helper.remove();
3484:
3485:             $.extend(this, {
3486:                 helper: null,
3487:                 dragging: false,
3488:                 reverting: false,
3489:                 _noFinalSort: null
3490:             });
3491:
3492:             if(this.domPosition.prev) {
3493:                 $(this.domPosition.prev).after(this.currentItem);
3494:             } else {
3495:                 $(this.domPosition.parent).prepend(this.currentItem);
3496:             }
3497:         }
3498:
3499:         return this;
3500:
3501:     },
3502:
3503:     serialize: function(o) {
3504:
3505:         var items = this._getItemsAsjQuery(o && o.connected);
3506:         var str = []; o = o || {};
3507:
3508:         $(items).each(function() {
3509:             var res = ($(o.item || this).attr(o.attribute || 'id') || '').match(o.expression || (/(.+)[-=_](.+)/));
3510:             if(res) str.push((o.key || res[1]+'[]')+'='+(o.key && o.expression ? res[1] : res[2]));
3511:         });
3512:
3513:         if(!str.length && o.key) {
3514:             str.push(o.key + '=');
3515:         }
3516:
3517:         return str.join('&');
3518:
3519:     },
3520:
3521:     toArray: function(o) {
3522:
3523:         var items = this._getItemsAsjQuery(o && o.connected);
3524:         var ret = []; o = o || {};
3525:
3526:         items.each(function() { ret.push($(o.item || this).attr(o.attribute || 'id') || ''); });
3527:         return ret;
3528:
3529:     },
3530:
3531:     /* Be careful with the following core functions */
3532:     _intersectsWith: function(item) {
3533:
3534:         var x1 = this.positionAbs.left,
3535:             x2 = x1 + this.helperProportions.width,
3536:             y1 = this.positionAbs.top,
3537:             y2 = y1 + this.helperProportions.height;
3538:
3539:         var l = item.left,
3540:             r = l + item.width,
3541:             t = item.top,
3542:             b = t + item.height;
3543:
3544:         var dyClick = this.offset.click.top,
3545:             dxClick = this.offset.click.left;
3546:
3547:         var isOverElement = (y1 + dyClick) > t && (y1 + dyClick) < b && (x1 + dxClick) > l && (x1 + dxClick) < r;
3548:
3549:         if(     this.options.tolerance == "pointer"
3550:             || this.options.forcePointerForContainers
3551:             || (this.options.tolerance != "pointer" && this.helperProportions[this.floating ? 'width' : 'height'] > item[this.floating ? 'width' : 'height'])
3552:         ) {
3553:             return isOverElement;
3554:         } else {
3555:
3556:             return (l < x1 + (this.helperProportions.width / 2) // Right Half
3557:                 && x2 - (this.helperProportions.width / 2) < r // Left Half
3558:                 && t < y1 + (this.helperProportions.height / 2) // Bottom Half
3559:                 && y2 - (this.helperProportions.height / 2) < b ); // Top Half
3560:
3561:         }
3562:     },
3563:
3564:     _intersectsWithPointer: function(item) {
3565:
3566:         var isOverElementHeight = (this.options.axis === 'x') || $.ui.isOverAxis(this.positionAbs.top + this.offset.click.top, item.top, item.height),
3567:             isOverElementWidth = (this.options.axis === 'y') || $.ui.isOverAxis(this.positionAbs.left + this.offset.click.left, item.left, item.width),
3568:             isOverElement = isOverElementHeight && isOverElementWidth,
3569:             verticalDirection = this._getDragVerticalDirection(),
3570:             horizontalDirection = this._getDragHorizontalDirection();
3571:
3572:         if (!isOverElement)
3573:             return false;
3574:
3575:         return this.floating ?
3576:             ( ((horizontalDirection && horizontalDirection == "right") || verticalDirection == "down") ? 2 : 1 )
3577:             : ( verticalDirection && (verticalDirection == "down" ? 2 : 1) );
3578:
3579:     },
3580:
3581:     _intersectsWithSides: function(item) {
3582:
3583:         var isOverBottomHalf = $.ui.isOverAxis(this.positionAbs.top + this.offset.click.top, item.top + (item.height/2), item.height),
3584:             isOverRightHalf = $.ui.isOverAxis(this.positionAbs.left + this.offset.click.left, item.left + (item.width/2), item.width),
3585:             verticalDirection = this._getDragVerticalDirection(),
3586:             horizontalDirection = this._getDragHorizontalDirection();
3587:
3588:         if (this.floating && horizontalDirection) {
3589:             return ((horizontalDirection == "right" && isOverRightHalf) || (horizontalDirection == "left" && !isOverRightHalf));
3590:         } else {
3591:             return verticalDirection && ((verticalDirection == "down" && isOverBottomHalf) || (verticalDirection == "up" && !isOverBottomHalf));
3592:         }
3593:
3594:     },
3595:
3596:     _getDragVerticalDirection: function() {
3597:         var delta = this.positionAbs.top - this.lastPositionAbs.top;
3598:         return delta != 0 && (delta > 0 ? "down" : "up");
3599:     },
3600:
3601:     _getDragHorizontalDirection: function() {
3602:         var delta = this.positionAbs.left - this.lastPositionAbs.left;
3603:         return delta != 0 && (delta > 0 ? "right" : "left");
3604:     },
3605:
3606:     refresh: function(event) {
3607:         this._refreshItems(event);
3608:         this.refreshPositions();
3609:         return this;
3610:     },
3611:
3612:     _connectWith: function() {
3613:         var options = this.options;
3614:         return options.connectWith.constructor == String
3615:             ? [options.connectWith]
3616:             : options.connectWith;
3617:     },
3618:
3619:     _getItemsAsjQuery: function(connected) {
3620:
3621:         var items = [];
3622:         var queries = [];
3623:         var connectWith = this._connectWith();
3624:
3625:         if(connectWith && connected) {
3626:             for (var i = connectWith.length - 1; i >= 0; i--){
3627:                 var cur = $(connectWith[i]);
3628:                 for (var j = cur.length - 1; j >= 0; j--){
3629:                     var inst = $.data(cur[j], this.widgetName);
3630:                     if(inst && inst != this && !inst.options.disabled) {
3631:                         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]);
3632:                     }
3633:                 };
3634:             };
3635:         }
3636:
3637:         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]);
3638:
3639:         for (var i = queries.length - 1; i >= 0; i--){
3640:             queries[i][0].each(function() {
3641:                 items.push(this);
3642:             });
3643:         };
3644:
3645:         return $(items);
3646:
3647:     },
3648:
3649:     _removeCurrentsFromItems: function() {
3650:
3651:         var list = this.currentItem.find(":data(" + this.widgetName + "-item)");
3652:
3653:         for (var i=0; i < this.items.length; i++) {
3654:
3655:             for (var j=0; j < list.length; j++) {
3656:                 if(list[j] == this.items[i].item[0])
3657:                     this.items.splice(i,1);
3658:             };
3659:
3660:         };
3661:
3662:     },
3663:
3664:     _refreshItems: function(event) {
3665:
3666:         this.items = [];
3667:         this.containers = [this];
3668:         var items = this.items;
3669:         var queries = [[$.isFunction(this.options.items) ? this.options.items.call(this.element[0], event, { item: this.currentItem }) : $(this.options.items, this.element), this]];
3670:         var connectWith = this._connectWith();
3671:
3672:         if(connectWith && this.ready) { //Shouldn't be run the first time through due to massive slow-down
3673:             for (var i = connectWith.length - 1; i >= 0; i--){
3674:                 var cur = $(connectWith[i]);
3675:                 for (var j = cur.length - 1; j >= 0; j--){
3676:                     var inst = $.data(cur[j], this.widgetName);
3677:                     if(inst && inst != this && !inst.options.disabled) {
3678:                         queries.push([$.isFunction(inst.options.items) ? inst.options.items.call(inst.element[0], event, { item: this.currentItem }) : $(inst.options.items, inst.element), inst]);
3679:                         this.containers.push(inst);
3680:                     }
3681:                 };
3682:             };
3683:         }
3684:
3685:         for (var i = queries.length - 1; i >= 0; i--) {
3686:             var targetData = queries[i][1];
3687:             var _queries = queries[i][0];
3688:
3689:             for (var j=0, queriesLength = _queries.length; j < queriesLength; j++) {
3690:                 var item = $(_queries[j]);
3691:
3692:                 item.data(this.widgetName + '-item', targetData); // Data for target checking (mouse manager)
3693:
3694:                 items.push({
3695:                     item: item,
3696:                     instance: targetData,
3697:                     width: 0, height: 0,
3698:                     left: 0, top: 0
3699:                 });
3700:             };
3701:         };
3702:
3703:     },
3704:
3705:     refreshPositions: function(fast) {
3706:
3707:         //This has to be redone because due to the item being moved out/into the offsetParent, the offsetParent's position will change
3708:         if(this.offsetParent && this.helper) {
3709:             this.offset.parent = this._getParentOffset();
3710:         }
3711:
3712:         for (var i = this.items.length - 1; i >= 0; i--){
3713:             var item = this.items[i];
3714:
3715:             //We ignore calculating positions of all connected containers when we're not over them
3716:             if(item.instance != this.currentContainer && this.currentContainer && item.item[0] != this.currentItem[0])
3717:                 continue;
3718:
3719:             var t = this.options.toleranceElement ? $(this.options.toleranceElement, item.item) : item.item;
3720:
3721:             if (!fast) {
3722:                 item.width = t.outerWidth();
3723:                 item.height = t.outerHeight();
3724:             }
3725:
3726:             var p = t.offset();
3727:             item.left = p.left;
3728:             item.top = p.top;
3729:         };
3730:
3731:         if(this.options.custom && this.options.custom.refreshContainers) {
3732:             this.options.custom.refreshContainers.call(this);
3733:         } else {
3734:             for (var i = this.containers.length - 1; i >= 0; i--){
3735:                 var p = this.containers[i].element.offset();
3736:                 this.containers[i].containerCache.left = p.left;
3737:                 this.containers[i].containerCache.top = p.top;
3738:                 this.containers[i].containerCache.width    = this.containers[i].element.outerWidth();
3739:                 this.containers[i].containerCache.height = this.containers[i].element.outerHeight();
3740:             };
3741:         }
3742:
3743:         return this;
3744:     },
3745:
3746:     _createPlaceholder: function(that) {
3747:         that = that || this;
3748:         var o = that.options;
3749:
3750:         if(!o.placeholder || o.placeholder.constructor == String) {
3751:             var className = o.placeholder;
3752:             o.placeholder = {
3753:                 element: function() {
3754:
3755:                     var el = $(document.createElement(that.currentItem[0].nodeName))
3756:                         .addClass(className || that.currentItem[0].className+" ui-sortable-placeholder")
3757:                         .removeClass("ui-sortable-helper")[0];
3758:
3759:                     if(!className)
3760:                         el.style.visibility = "hidden";
3761:
3762:                     return el;
3763:                 },
3764:                 update: function(container, p) {
3765:
3766:                     // 1. If a className is set as 'placeholder option, we don't force sizes - the class is responsible for that
3767:                     // 2. The option 'forcePlaceholderSize can be enabled to force it even if a class name is specified
3768:                     if(className && !o.forcePlaceholderSize) return;
3769:
3770:                     //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
3771:                     if(!p.height()) { p.height(that.currentItem.innerHeight() - parseInt(that.currentItem.css('paddingTop')||0, 10) - parseInt(that.currentItem.css('paddingBottom')||0, 10)); };
3772:                     if(!p.width()) { p.width(that.currentItem.innerWidth() - parseInt(that.currentItem.css('paddingLeft')||0, 10) - parseInt(that.currentItem.css('paddingRight')||0, 10)); };
3773:                 }
3774:             };
3775:         }
3776:
3777:         //Create the placeholder
3778:         that.placeholder = $(o.placeholder.element.call(that.element, that.currentItem));
3779:
3780:         //Append it after the actual current item
3781:         that.currentItem.after(that.placeholder);
3782:
3783:         //Update the size of the placeholder (TODO: Logic to fuzzy, see line 316/317)
3784:         o.placeholder.update(that, that.placeholder);
3785:
3786:     },
3787:
3788:     _contactContainers: function(event) {
3789:
3790:         // get innermost container that intersects with item
3791:         var innermostContainer = null, innermostIndex = null;
3792:
3793:
3794:         for (var i = this.containers.length - 1; i >= 0; i--){
3795:
3796:             // never consider a container that's located within the item itself
3797:             if($.contains(this.currentItem[0], this.containers[i].element[0]))
3798:                 continue;
3799:
3800:             if(this._intersectsWith(this.containers[i].containerCache)) {
3801:
3802:                 // if we've already found a container and it's more "inner" than this, then continue
3803:                 if(innermostContainer && $.contains(this.containers[i].element[0], innermostContainer.element[0]))
3804:                     continue;
3805:
3806:                 innermostContainer = this.containers[i];
3807:                 innermostIndex = i;
3808:
3809:             } else {
3810:                 // container doesn't intersect. trigger "out" event if necessary
3811:                 if(this.containers[i].containerCache.over) {
3812:                     this.containers[i]._trigger("out", event, this._uiHash(this));
3813:                     this.containers[i].containerCache.over = 0;
3814:                 }
3815:             }
3816:
3817:         }
3818:
3819:         // if no intersecting containers found, return
3820:         if(!innermostContainer) return;
3821:
3822:         // move the item into the container if it's not there already
3823:         if(this.containers.length === 1) {
3824:             this.containers[innermostIndex]._trigger("over", event, this._uiHash(this));
3825:             this.containers[innermostIndex].containerCache.over = 1;
3826:         } else if(this.currentContainer != this.containers[innermostIndex]) {
3827:
3828:             //When entering a new container, we will find the item with the least distance and append our item near it
3829:             var dist = 10000; var itemWithLeastDistance = null; var base = this.positionAbs[this.containers[innermostIndex].floating ? 'left' : 'top'];
3830:             for (var j = this.items.length - 1; j >= 0; j--) {
3831:                 if(!$.contains(this.containers[innermostIndex].element[0], this.items[j].item[0])) continue;
3832:                 var cur = this.containers[innermostIndex].floating ? this.items[j].item.offset().left : this.items[j].item.offset().top;
3833:                 if(Math.abs(cur - base) < dist) {
3834:                     dist = Math.abs(cur - base); itemWithLeastDistance = this.items[j];
3835:                     this.direction = (cur - base > 0) ? 'down' : 'up';
3836:                 }
3837:             }
3838:
3839:             if(!itemWithLeastDistance && !this.options.dropOnEmpty) //Check if dropOnEmpty is enabled
3840:                 return;
3841:
3842:             this.currentContainer = this.containers[innermostIndex];
3843:             itemWithLeastDistance ? this._rearrange(event, itemWithLeastDistance, null, true) : this._rearrange(event, null, this.containers[innermostIndex].element, true);
3844:             this._trigger("change", event, this._uiHash());
3845:             this.containers[innermostIndex]._trigger("change", event, this._uiHash(this));
3846:
3847:             //Update the placeholder
3848:             this.options.placeholder.update(this.currentContainer, this.placeholder);
3849:
3850:             this.containers[innermostIndex]._trigger("over", event, this._uiHash(this));
3851:             this.containers[innermostIndex].containerCache.over = 1;
3852:         }
3853:
3854:
3855:     },
3856:
3857:     _createHelper: function(event) {
3858:
3859:         var o = this.options;
3860:         var helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [event, this.currentItem])) : (o.helper == 'clone' ? this.currentItem.clone() : this.currentItem);
3861:
3862:         if(!helper.parents('body').length) //Add the helper to the DOM if that didn't happen already
3863:             $(o.appendTo != 'parent' ? o.appendTo : this.currentItem[0].parentNode)[0].appendChild(helper[0]);
3864:
3865:         if(helper[0] == this.currentItem[0])
3866:             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: this.currentItem.css("left") };
3867:
3868:         if(helper[0].style.width == '' || o.forceHelperSize) helper.width(this.currentItem.width());
3869:         if(helper[0].style.height == '' || o.forceHelperSize) helper.height(this.currentItem.height());
3870:
3871:         return helper;
3872:
3873:     },
3874:
3875:     _adjustOffsetFromHelper: function(obj) {
3876:         if (typeof obj == 'string') {
3877:             obj = obj.split(' ');
3878:         }
3879:         if ($.isArray(obj)) {
3880:             obj = {left: +obj[0], top: +obj[1] || 0};
3881:         }
3882:         if ('left' in obj) {
3883:             this.offset.click.left = obj.left + this.margins.left;
3884:         }
3885:         if ('right' in obj) {
3886:             this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
3887:         }
3888:         if ('top' in obj) {
3889:             this.offset.click.top = obj.top + this.margins.top;
3890:         }
3891:         if ('bottom' in obj) {
3892:             this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
3893:         }
3894:     },
3895:
3896:     _getParentOffset: function() {
3897:
3898:
3899:         //Get the offsetParent and cache its position
3900:         this.offsetParent = this.helper.offsetParent();
3901:         var po = this.offsetParent.offset();
3902:
3903:         // This is a special case where we need to modify a offset calculated on start, since the following happened:
3904:         // 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent
3905:         // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that
3906:         // the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag
3907:         if(this.cssPosition == 'absolute' && this.scrollParent[0] != document && $.contains(this.scrollParent[0], this.offsetParent[0])) {
3908:             po.left += this.scrollParent.scrollLeft();
3909:             po.top += this.scrollParent.scrollTop();
3910:         }
3911:
3912:         if((this.offsetParent[0] == document.body) //This needs to be actually done for all browsers, since pageX/pageY includes this information
3913:         || (this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() == 'html' && $.browser.msie)) //Ugly IE fix
3914:             po = { top: 0, left: 0 };
3915:
3916:         return {
3917:             top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"),10) || 0),
3918:             left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"),10) || 0)
3919:         };
3920:
3921:     },
3922:
3923:     _getRelativeOffset: function() {
3924:
3925:         if(this.cssPosition == "relative") {
3926:             var p = this.currentItem.position();
3927:             return {
3928:                 top: p.top - (parseInt(this.helper.css("top"),10) || 0) + this.scrollParent.scrollTop(),
3929:                 left: p.left - (parseInt(this.helper.css("left"),10) || 0) + this.scrollParent.scrollLeft()
3930:             };
3931:         } else {
3932:             return { top: 0, left: 0 };
3933:         }
3934:
3935:     },
3936:
3937:     _cacheMargins: function() {
3938:         this.margins = {
3939:             left: (parseInt(this.currentItem.css("marginLeft"),10) || 0),
3940:             top: (parseInt(this.currentItem.css("marginTop"),10) || 0)
3941:         };
3942:     },
3943:
3944:     _cacheHelperProportions: function() {
3945:         this.helperProportions = {
3946:             width: this.helper.outerWidth(),
3947:             height: this.helper.outerHeight()
3948:         };
3949:     },
3950:
3951:     _setContainment: function() {
3952:
3953:         var o = this.options;
3954:         if(o.containment == 'parent') o.containment = this.helper[0].parentNode;
3955:         if(o.containment == 'document' || o.containment == 'window') this.containment = [
3956:             0 - this.offset.relative.left - this.offset.parent.left,
3957:             0 - this.offset.relative.top - this.offset.parent.top,
3958:             $(o.containment == 'document' ? document : window).width() - this.helperProportions.width - this.margins.left,
3959:             ($(o.containment == 'document' ? document : window).height() || document.body.parentNode.scrollHeight) - this.helperProportions.height - this.margins.top
3960:         ];
3961:
3962:         if(!(/^(document|window|parent)$/).test(o.containment)) {
3963:             var ce = $(o.containment)[0];
3964:             var co = $(o.containment).offset();
3965:             var over = ($(ce).css("overflow") != 'hidden');
3966:
3967:             this.containment = [
3968:                 co.left + (parseInt($(ce).css("borderLeftWidth"),10) || 0) + (parseInt($(ce).css("paddingLeft"),10) || 0) - this.margins.left,
3969:                 co.top + (parseInt($(ce).css("borderTopWidth"),10) || 0) + (parseInt($(ce).css("paddingTop"),10) || 0) - this.margins.top,
3970:                 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,
3971:                 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
3972:             ];
3973:         }
3974:
3975:     },
3976:
3977:     _convertPositionTo: function(d, pos) {
3978:
3979:         if(!pos) pos = this.position;
3980:         var mod = d == "absolute" ? 1 : -1;
3981:         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);
3982:
3983:         return {
3984:             top: (
3985:                 pos.top                                                                    // The absolute mouse position
3986:                 + this.offset.relative.top * mod                                        // Only for relative positioned nodes: Relative offset from element to offset parent
3987:                 + this.offset.parent.top * mod                                            // The offsetParent's offset without borders (offset + border)
3988:                 - ( ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod)
3989:             ),
3990:             left: (
3991:                 pos.left                                                                // The absolute mouse position
3992:                 + this.offset.relative.left * mod                                        // Only for relative positioned nodes: Relative offset from element to offset parent
3993:                 + this.offset.parent.left * mod                                            // The offsetParent's offset without borders (offset + border)
3994:                 - ( ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ) * mod)
3995:             )
3996:         };
3997:
3998:     },
3999:
4000:     _generatePosition: function(event) {
4001:
4002:         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);
4003:
4004:         // This is another very weird special case that only happens for relative elements:
4005:         // 1. If the css position is relative
4006:         // 2. and the scroll parent is the document or similar to the offset parent
4007:         // we have to refresh the relative offset during the scroll so there are no jumps
4008:         if(this.cssPosition == 'relative' && !(this.scrollParent[0] != document && this.scrollParent[0] != this.offsetParent[0])) {
4009:             this.offset.relative = this._getRelativeOffset();
4010:         }
4011:
4012:         var pageX = event.pageX;
4013:         var pageY = event.pageY;
4014:
4015:         /*
4016:          * - Position constraining -
4017:          * Constrain the position to a mix of grid, containment.
4018:          */
4019:
4020:         if(this.originalPosition) { //If we are not dragging yet, we won't check for options
4021:
4022:             if(this.containment) {
4023:                 if(event.pageX - this.offset.click.left < this.containment[0]) pageX = this.containment[0] + this.offset.click.left;
4024:                 if(event.pageY - this.offset.click.top < this.containment[1]) pageY = this.containment[1] + this.offset.click.top;
4025:                 if(event.pageX - this.offset.click.left > this.containment[2]) pageX = this.containment[2] + this.offset.click.left;
4026:                 if(event.pageY - this.offset.click.top > this.containment[3]) pageY = this.containment[3] + this.offset.click.top;
4027:             }
4028:
4029:             if(o.grid) {
4030:                 var top = this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1];
4031:                 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;
4032:
4033:                 var left = this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0];
4034:                 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;
4035:             }
4036:
4037:         }
4038:
4039:         return {
4040:             top: (
4041:                 pageY                                                                // The absolute mouse position
4042:                 - this.offset.click.top                                                    // Click offset (relative to the element)
4043:                 - this.offset.relative.top                                                // Only for relative positioned nodes: Relative offset from element to offset parent
4044:                 - this.offset.parent.top                                                // The offsetParent's offset without borders (offset + border)
4045:                 + ( ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ))
4046:             ),
4047:             left: (
4048:                 pageX                                                                // The absolute mouse position
4049:                 - this.offset.click.left                                                // Click offset (relative to the element)
4050:                 - this.offset.relative.left                                                // Only for relative positioned nodes: Relative offset from element to offset parent
4051:                 - this.offset.parent.left                                                // The offsetParent's offset without borders (offset + border)
4052:                 + ( ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ))
4053:             )
4054:         };
4055:
4056:     },
4057:
4058:     _rearrange: function(event, i, a, hardRefresh) {
4059:
4060:         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));
4061:
4062:         //Various things done here to improve the performance:
4063:         // 1. we create a setTimeout, that calls refreshPositions
4064:         // 2. on the instance, we have a counter variable, that get's higher after every append
4065:         // 3. on the local scope, we copy the counter variable, and check in the timeout, if it's still the same
4066:         // 4. this lets only the last addition to the timeout stack through
4067:         this.counter = this.counter ? ++this.counter : 1;
4068:         var counter = this.counter;
4069:
4070:         this._delay(function() {
4071:             if(counter == this.counter) this.refreshPositions(!hardRefresh); //Precompute after each DOM insertion, NOT on mousemove
4072:         });
4073:
4074:     },
4075:
4076:     _clear: function(event, noPropagation) {
4077:
4078:         this.reverting = false;
4079:         // We delay all events that have to be triggered to after the point where the placeholder has been removed and
4080:         // everything else normalized again
4081:         var delayedTriggers = [];
4082:
4083:         // We first have to update the dom position of the actual currentItem
4084:         // Note: don't do it if the current item is already removed (by a user), or it gets reappended (see #4088)
4085:         if(!this._noFinalSort && this.currentItem.parent().length) this.placeholder.before(this.currentItem);
4086:         this._noFinalSort = null;
4087:
4088:         if(this.helper[0] == this.currentItem[0]) {
4089:             for(var i in this._storedCSS) {
4090:                 if(this._storedCSS[i] == 'auto' || this._storedCSS[i] == 'static') this._storedCSS[i] = '';
4091:             }
4092:             this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper");
4093:         } else {
4094:             this.currentItem.show();
4095:         }
4096:
4097:         if(this.fromOutside && !noPropagation) delayedTriggers.push(function(event) { this._trigger("receive", event, this._uiHash(this.fromOutside)); });
4098:         if((this.fromOutside || this.domPosition.prev != this.currentItem.prev().not(".ui-sortable-helper")[0] || this.domPosition.parent != this.currentItem.parent()[0]) && !noPropagation) delayedTriggers.push(function(event) { this._trigger("update", event, this._uiHash()); }); //Trigger update callback if the DOM position has changed
4099:
4100:         // Check if the items Container has Changed and trigger appropriate
4101:         // events.
4102:         if (this !== this.currentContainer) {
4103:             if(!noPropagation) {
4104:                 delayedTriggers.push(function(event) { this._trigger("remove", event, this._uiHash()); });
4105:                 delayedTriggers.push((function(c) { return function(event) { c._trigger("receive", event, this._uiHash(this)); }; }).call(this, this.currentContainer));
4106:                 delayedTriggers.push((function(c) { return function(event) { c._trigger("update", event, this._uiHash(this)); }; }).call(this, this.currentContainer));
4107:             }
4108:         }
4109:
4110:
4111:         //Post events to containers
4112:         for (var i = this.containers.length - 1; i >= 0; i--){
4113:             if(!noPropagation) delayedTriggers.push((function(c) { return function(event) { c._trigger("deactivate", event, this._uiHash(this)); }; }).call(this, this.containers[i]));
4114:             if(this.containers[i].containerCache.over) {
4115:                 delayedTriggers.push((function(c) { return function(event) { c._trigger("out", event, this._uiHash(this)); }; }).call(this, this.containers[i]));
4116:                 this.containers[i].containerCache.over = 0;
4117:             }
4118:         }
4119:
4120:         //Do what was originally in plugins
4121:         if(this._storedCursor) $('body').css("cursor", this._storedCursor); //Reset cursor
4122:         if(this._storedOpacity) this.helper.css("opacity", this._storedOpacity); //Reset opacity
4123:         if(this._storedZIndex) this.helper.css("zIndex", this._storedZIndex == 'auto' ? '' : this._storedZIndex); //Reset z-index
4124:
4125:         this.dragging = false;
4126:         if(this.cancelHelperRemoval) {
4127:             if(!noPropagation) {
4128:                 this._trigger("beforeStop", event, this._uiHash());
4129:                 for (var i=0; i < delayedTriggers.length; i++) { delayedTriggers[i].call(this, event); }; //Trigger all delayed events
4130:                 this._trigger("stop", event, this._uiHash());
4131:             }
4132:
4133:             this.fromOutside = false;
4134:             return false;
4135:         }
4136:
4137:         if(!noPropagation) this._trigger("beforeStop", event, this._uiHash());
4138:
4139:         //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node!
4140:         this.placeholder[0].parentNode.removeChild(this.placeholder[0]);
4141:
4142:         if(this.helper[0] != this.currentItem[0]) this.helper.remove(); this.helper = null;
4143:
4144:         if(!noPropagation) {
4145:             for (var i=0; i < delayedTriggers.length; i++) { delayedTriggers[i].call(this, event); }; //Trigger all delayed events
4146:             this._trigger("stop", event, this._uiHash());
4147:         }
4148:
4149:         this.fromOutside = false;
4150:         return true;
4151:
4152:     },
4153:
4154:     _trigger: function() {
4155:         if ($.Widget.prototype._trigger.apply(this, arguments) === false) {
4156:             this.cancel();
4157:         }
4158:     },
4159:
4160:     _uiHash: function(_inst) {
4161:         var inst = _inst || this;
4162:         return {
4163:             helper: inst.helper,
4164:             placeholder: inst.placeholder || $([]),
4165:             position: inst.position,
4166:             originalPosition: inst.originalPosition,
4167:             offset: inst.positionAbs,
4168:             item: inst.currentItem,
4169:             sender: _inst ? _inst.element : null
4170:         };
4171:     }
4172:
4173: });
4174:
4175: })(jQuery);
4176:
4177: ;(jQuery.effects || (function($, undefined) {
4178:
4179: var backCompat = $.uiBackCompat !== false,
4180:     // prefix used for storing data on .data()
4181:     dataSpace = "ui-effects-";
4182:
4183: $.effects = {
4184:     effect: {}
4185: };
4186:
4187: /*!
4188: * jQuery Color Animations v2.0.0
4189: * http://jquery.com/
4190: *
4191: * Copyright 2012 jQuery Foundation and other contributors
4192: * Released under the MIT license.
4193: * http://jquery.org/license
4194: *
4195: * Date: Mon Aug 13 13:41:02 2012 -0500
4196: */
4197: (function( jQuery, undefined ) {
4198:
4199:     var stepHooks = "backgroundColor borderBottomColor borderLeftColor borderRightColor borderTopColor color columnRuleColor outlineColor textDecorationColor textEmphasisColor".split(" "),
4200:
4201:     // plusequals test for += 100 -= 100
4202:     rplusequals = /^([\-+])=\s*(\d+\.?\d*)/,
4203:     // a set of RE's that can match strings and generate color tuples.
4204:     stringParsers = [{
4205:             re: /rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*(\d+(?:\.\d+)?)\s*)?\)/,
4206:             parse: function( execResult ) {
4207:                 return [
4208:                     execResult[ 1 ],
4209:                     execResult[ 2 ],
4210:                     execResult[ 3 ],
4211:                     execResult[ 4 ]
4212:                 ];
4213:             }
4214:         }, {
4215:             re: /rgba?\(\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d+(?:\.\d+)?)\s*)?\)/,
4216:             parse: function( execResult ) {
4217:                 return [
4218:                     execResult[ 1 ] * 2.55,
4219:                     execResult[ 2 ] * 2.55,
4220:                     execResult[ 3 ] * 2.55,
4221:                     execResult[ 4 ]
4222:                 ];
4223:             }
4224:         }, {
4225:             // this regex ignores A-F because it's compared against an already lowercased string
4226:             re: /#([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})/,
4227:             parse: function( execResult ) {
4228:                 return [
4229:                     parseInt( execResult[ 1 ], 16 ),
4230:                     parseInt( execResult[ 2 ], 16 ),
4231:                     parseInt( execResult[ 3 ], 16 )
4232:                 ];
4233:             }
4234:         }, {
4235:             // this regex ignores A-F because it's compared against an already lowercased string
4236:             re: /#([a-f0-9])([a-f0-9])([a-f0-9])/,
4237:             parse: function( execResult ) {
4238:                 return [
4239:                     parseInt( execResult[ 1 ] + execResult[ 1 ], 16 ),
4240:                     parseInt( execResult[ 2 ] + execResult[ 2 ], 16 ),
4241:                     parseInt( execResult[ 3 ] + execResult[ 3 ], 16 )
4242:                 ];
4243:             }
4244:         }, {
4245:             re: /hsla?\(\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d+(?:\.\d+)?)\s*)?\)/,
4246:             space: "hsla",
4247:             parse: function( execResult ) {
4248:                 return [
4249:                     execResult[ 1 ],
4250:                     execResult[ 2 ] / 100,
4251:                     execResult[ 3 ] / 100,
4252:                     execResult[ 4 ]
4253:                 ];
4254:             }
4255:         }],
4256:
4257:     // jQuery.Color( )
4258:     color = jQuery.Color = function( color, green, blue, alpha ) {
4259:         return new jQuery.Color.fn.parse( color, green, blue, alpha );
4260:     },
4261:     spaces = {
4262:         rgba: {
4263:             props: {
4264:                 red: {
4265:                     idx: 0,
4266:                     type: "byte"
4267:                 },
4268:                 green: {
4269:                     idx: 1,
4270:                     type: "byte"
4271:                 },
4272:                 blue: {
4273:                     idx: 2,
4274:                     type: "byte"
4275:                 }
4276:             }
4277:         },
4278:
4279:         hsla: {
4280:             props: {
4281:                 hue: {
4282:                     idx: 0,
4283:                     type: "degrees"
4284:                 },
4285:                 saturation: {
4286:                     idx: 1,
4287:                     type: "percent"
4288:                 },
4289:                 lightness: {
4290:                     idx: 2,
4291:                     type: "percent"
4292:                 }
4293:             }
4294:         }
4295:     },
4296:     propTypes = {
4297:         "byte": {
4298:             floor: true,
4299:             max: 255
4300:         },
4301:         "percent": {
4302:             max: 1
4303:         },
4304:         "degrees": {
4305:             mod: 360,
4306:             floor: true
4307:         }
4308:     },
4309:     support = color.support = {},
4310:
4311:     // element for support tests
4312:     supportElem = jQuery( "<p>" )[ 0 ],
4313:
4314:     // colors = jQuery.Color.names
4315:     colors,
4316:
4317:     // local aliases of functions called often
4318:     each = jQuery.each;
4319:
4320: // determine rgba support immediately
4321: supportElem.style.cssText = "background-color:rgba(1,1,1,.5)";
4322: support.rgba = supportElem.style.backgroundColor.indexOf( "rgba" ) > -1;
4323:
4324: // define cache name and alpha properties
4325: // for rgba and hsla spaces
4326: each( spaces, function( spaceName, space ) {
4327:     space.cache = "_" + spaceName;
4328:     space.props.alpha = {
4329:         idx: 3,
4330:         type: "percent",
4331:         def: 1
4332:     };
4333: });
4334:
4335: function clamp( value, prop, allowEmpty ) {
4336:     var type = propTypes[ prop.type ] || {};
4337:
4338:     if ( value == null ) {
4339:         return (allowEmpty || !prop.def) ? null : prop.def;
4340:     }
4341:
4342:     // ~~ is an short way of doing floor for positive numbers
4343:     value = type.floor ? ~~value : parseFloat( value );
4344:
4345:     // IE will pass in empty strings as value for alpha,
4346:     // which will hit this case
4347:     if ( isNaN( value ) ) {
4348:         return prop.def;
4349:     }
4350:
4351:     if ( type.mod ) {
4352:         // we add mod before modding to make sure that negatives values
4353:         // get converted properly: -10 -> 350
4354:         return (value + type.mod) % type.mod;
4355:     }
4356:
4357:     // for now all property types without mod have min and max
4358:     return 0 > value ? 0 : type.max < value ? type.max : value;
4359: }
4360:
4361: function stringParse( string ) {
4362:     var inst = color(),
4363:         rgba = inst._rgba = [];
4364:
4365:     string = string.toLowerCase();
4366:
4367:     each( stringParsers, function( i, parser ) {
4368:         var parsed,
4369:             match = parser.re.exec( string ),
4370:             values = match && parser.parse( match ),
4371:             spaceName = parser.space || "rgba";
4372:
4373:         if ( values ) {
4374:             parsed = inst[ spaceName ]( values );
4375:
4376:             // if this was an rgba parse the assignment might happen twice
4377:             // oh well....
4378:             inst[ spaces[ spaceName ].cache ] = parsed[ spaces[ spaceName ].cache ];
4379:             rgba = inst._rgba = parsed._rgba;
4380:
4381:             // exit each( stringParsers ) here because we matched
4382:             return false;
4383:         }
4384:     });
4385:
4386:     // Found a stringParser that handled it
4387:     if ( rgba.length ) {
4388:
4389:         // if this came from a parsed string, force "transparent" when alpha is 0
4390:         // chrome, (and maybe others) return "transparent" as rgba(0,0,0,0)
4391:         if ( rgba.join() === "0,0,0,0" ) {
4392:             jQuery.extend( rgba, colors.transparent );
4393:         }
4394:         return inst;
4395:     }
4396:
4397:     // named colors
4398:     return colors[ string ];
4399: }
4400:
4401: color.fn = jQuery.extend( color.prototype, {
4402:     parse: function( red, green, blue, alpha ) {
4403:         if ( red === undefined ) {
4404:             this._rgba = [ null, null, null, null ];
4405:             return this;
4406:         }
4407:         if ( red.jquery || red.nodeType ) {
4408:             red = jQuery( red ).css( green );
4409:             green = undefined;
4410:         }
4411:
4412:         var inst = this,
4413:             type = jQuery.type( red ),
4414:             rgba = this._rgba = [],
4415:             source;
4416:
4417:         // more than 1 argument specified - assume ( red, green, blue, alpha )
4418:         if ( green !== undefined ) {
4419:             red = [ red, green, blue, alpha ];
4420:             type = "array";
4421:         }
4422:
4423:         if ( type === "string" ) {
4424:             return this.parse( stringParse( red ) || colors._default );
4425:         }
4426:
4427:         if ( type === "array" ) {
4428:             each( spaces.rgba.props, function( key, prop ) {
4429:                 rgba[ prop.idx ] = clamp( red[ prop.idx ], prop );
4430:             });
4431:             return this;
4432:         }
4433:
4434:         if ( type === "object" ) {
4435:             if ( red instanceof color ) {
4436:                 each( spaces, function( spaceName, space ) {
4437:                     if ( red[ space.cache ] ) {
4438:                         inst[ space.cache ] = red[ space.cache ].slice();
4439:                     }
4440:                 });
4441:             } else {
4442:                 each( spaces, function( spaceName, space ) {
4443:                     var cache = space.cache;
4444:                     each( space.props, function( key, prop ) {
4445:
4446:                         // if the cache doesn't exist, and we know how to convert
4447:                         if ( !inst[ cache ] && space.to ) {
4448:
4449:                             // if the value was null, we don't need to copy it
4450:                             // if the key was alpha, we don't need to copy it either
4451:                             if ( key === "alpha" || red[ key ] == null ) {
4452:                                 return;
4453:                             }
4454:                             inst[ cache ] = space.to( inst._rgba );
4455:                         }
4456:
4457:                         // this is the only case where we allow nulls for ALL properties.
4458:                         // call clamp with alwaysAllowEmpty
4459:                         inst[ cache ][ prop.idx ] = clamp( red[ key ], prop, true );
4460:                     });
4461:
4462:                     // everything defined but alpha?
4463:                     if ( inst[ cache ] && $.inArray( null, inst[ cache ].slice( 0, 3 ) ) < 0 ) {
4464:                         // use the default of 1
4465:                         inst[ cache ][ 3 ] = 1;
4466:                         if ( space.from ) {
4467:                             inst._rgba = space.from( inst[ cache ] );
4468:                         }
4469:                     }
4470:                 });
4471:             }
4472:             return this;
4473:         }
4474:     },
4475:     is: function( compare ) {
4476:         var is = color( compare ),
4477:             same = true,
4478:             inst = this;
4479:
4480:         each( spaces, function( _, space ) {
4481:             var localCache,
4482:                 isCache = is[ space.cache ];
4483:             if (isCache) {
4484:                 localCache = inst[ space.cache ] || space.to && space.to( inst._rgba ) || [];
4485:                 each( space.props, function( _, prop ) {
4486:                     if ( isCache[ prop.idx ] != null ) {
4487:                         same = ( isCache[ prop.idx ] === localCache[ prop.idx ] );
4488:                         return same;
4489:                     }
4490:                 });
4491:             }
4492:             return same;
4493:         });
4494:         return same;
4495:     },
4496:     _space: function() {
4497:         var used = [],
4498:             inst = this;
4499:         each( spaces, function( spaceName, space ) {
4500:             if ( inst[ space.cache ] ) {
4501:                 used.push( spaceName );
4502:             }
4503:         });
4504:         return used.pop();
4505:     },
4506:     transition: function( other, distance ) {
4507:         var end = color( other ),
4508:             spaceName = end._space(),
4509:             space = spaces[ spaceName ],
4510:             startColor = this.alpha() === 0 ? color( "transparent" ) : this,
4511:             start = startColor[ space.cache ] || space.to( startColor._rgba ),
4512:             result = start.slice();
4513:
4514:         end = end[ space.cache ];
4515:         each( space.props, function( key, prop ) {
4516:             var index = prop.idx,
4517:                 startValue = start[ index ],
4518:                 endValue = end[ index ],
4519:                 type = propTypes[ prop.type ] || {};
4520:
4521:             // if null, don't override start value
4522:             if ( endValue === null ) {
4523:                 return;
4524:             }
4525:             // if null - use end
4526:             if ( startValue === null ) {
4527:                 result[ index ] = endValue;
4528:             } else {
4529:                 if ( type.mod ) {
4530:                     if ( endValue - startValue > type.mod / 2 ) {
4531:                         startValue += type.mod;
4532:                     } else if ( startValue - endValue > type.mod / 2 ) {
4533:                         startValue -= type.mod;
4534:                     }
4535:                 }
4536:                 result[ index ] = clamp( ( endValue - startValue ) * distance + startValue, prop );
4537:             }
4538:         });
4539:         return this[ spaceName ]( result );
4540:     },
4541:     blend: function( opaque ) {
4542:         // if we are already opaque - return ourself
4543:         if ( this._rgba[ 3 ] === 1 ) {
4544:             return this;
4545:         }
4546:
4547:         var rgb = this._rgba.slice(),
4548:             a = rgb.pop(),
4549:             blend = color( opaque )._rgba;
4550:
4551:         return color( jQuery.map( rgb, function( v, i ) {
4552:             return ( 1 - a ) * blend[ i ] + a * v;
4553:         }));
4554:     },
4555:     toRgbaString: function() {
4556:         var prefix = "rgba(",
4557:             rgba = jQuery.map( this._rgba, function( v, i ) {
4558:                 return v == null ? ( i > 2 ? 1 : 0 ) : v;
4559:             });
4560:
4561:         if ( rgba[ 3 ] === 1 ) {
4562:             rgba.pop();
4563:             prefix = "rgb(";
4564:         }
4565:
4566:         return prefix + rgba.join() + ")";
4567:     },
4568:     toHslaString: function() {
4569:         var prefix = "hsla(",
4570:             hsla = jQuery.map( this.hsla(), function( v, i ) {
4571:                 if ( v == null ) {
4572:                     v = i > 2 ? 1 : 0;
4573:                 }
4574:
4575:                 // catch 1 and 2
4576:                 if ( i && i < 3 ) {
4577:                     v = Math.round( v * 100 ) + "%";
4578:                 }
4579:                 return v;
4580:             });
4581:
4582:         if ( hsla[ 3 ] === 1 ) {
4583:             hsla.pop();
4584:             prefix = "hsl(";
4585:         }
4586:         return prefix + hsla.join() + ")";
4587:     },
4588:     toHexString: function( includeAlpha ) {
4589:         var rgba = this._rgba.slice(),
4590:             alpha = rgba.pop();
4591:
4592:         if ( includeAlpha ) {
4593:             rgba.push( ~~( alpha * 255 ) );
4594:         }
4595:
4596:         return "#" + jQuery.map( rgba, function( v, i ) {
4597:
4598:             // default to 0 when nulls exist
4599:             v = ( v || 0 ).toString( 16 );
4600:             return v.length === 1 ? "0" + v : v;
4601:         }).join("");
4602:     },
4603:     toString: function() {
4604:         return this._rgba[ 3 ] === 0 ? "transparent" : this.toRgbaString();
4605:     }
4606: });
4607: color.fn.parse.prototype = color.fn;
4608:
4609: // hsla conversions adapted from:
4610: // https://code.google.com/p/maashaack/source/browse/packages/graphics/trunk/src/graphics/colors/HUE2RGB.as?r=5021
4611:
4612: function hue2rgb( p, q, h ) {
4613:     h = ( h + 1 ) % 1;
4614:     if ( h * 6 < 1 ) {
4615:         return p + (q - p) * h * 6;
4616:     }
4617:     if ( h * 2 < 1) {
4618:         return q;
4619:     }
4620:     if ( h * 3 < 2 ) {
4621:         return p + (q - p) * ((2/3) - h) * 6;
4622:     }
4623:     return p;
4624: }
4625:
4626: spaces.hsla.to = function ( rgba ) {
4627:     if ( rgba[ 0 ] == null || rgba[ 1 ] == null || rgba[ 2 ] == null ) {
4628:         return [ null, null, null, rgba[ 3 ] ];
4629:     }
4630:     var r = rgba[ 0 ] / 255,
4631:         g = rgba[ 1 ] / 255,
4632:         b = rgba[ 2 ] / 255,
4633:         a = rgba[ 3 ],
4634:         max = Math.max( r, g, b ),
4635:         min = Math.min( r, g, b ),
4636:         diff = max - min,
4637:         add = max + min,
4638:         l = add * 0.5,
4639:         h, s;
4640:
4641:     if ( min === max ) {
4642:         h = 0;
4643:     } else if ( r === max ) {
4644:         h = ( 60 * ( g - b ) / diff ) + 360;
4645:     } else if ( g === max ) {
4646:         h = ( 60 * ( b - r ) / diff ) + 120;
4647:     } else {
4648:         h = ( 60 * ( r - g ) / diff ) + 240;
4649:     }
4650:
4651:     if ( l === 0 || l === 1 ) {
4652:         s = l;
4653:     } else if ( l <= 0.5 ) {
4654:         s = diff / add;
4655:     } else {
4656:         s = diff / ( 2 - add );
4657:     }
4658:     return [ Math.round(h) % 360, s, l, a == null ? 1 : a ];
4659: };
4660:
4661: spaces.hsla.from = function ( hsla ) {
4662:     if ( hsla[ 0 ] == null || hsla[ 1 ] == null || hsla[ 2 ] == null ) {
4663:         return [ null, null, null, hsla[ 3 ] ];
4664:     }
4665:     var h = hsla[ 0 ] / 360,
4666:         s = hsla[ 1 ],
4667:         l = hsla[ 2 ],
4668:         a = hsla[ 3 ],
4669:         q = l <= 0.5 ? l * ( 1 + s ) : l + s - l * s,
4670:         p = 2 * l - q,
4671:         r, g, b;
4672:
4673:     return [
4674:         Math.round( hue2rgb( p, q, h + ( 1 / 3 ) ) * 255 ),
4675:         Math.round( hue2rgb( p, q, h ) * 255 ),
4676:         Math.round( hue2rgb( p, q, h - ( 1 / 3 ) ) * 255 ),
4677:         a
4678:     ];
4679: };
4680:
4681:
4682: each( spaces, function( spaceName, space ) {
4683:     var props = space.props,
4684:         cache = space.cache,
4685:         to = space.to,
4686:         from = space.from;
4687:
4688:     // makes rgba() and hsla()
4689:     color.fn[ spaceName ] = function( value ) {
4690:
4691:         // generate a cache for this space if it doesn't exist
4692:         if ( to && !this[ cache ] ) {
4693:             this[ cache ] = to( this._rgba );
4694:         }
4695:         if ( value === undefined ) {
4696:             return this[ cache ].slice();
4697:         }
4698:
4699:         var ret,
4700:             type = jQuery.type( value ),
4701:             arr = ( type === "array" || type === "object" ) ? value : arguments,
4702:             local = this[ cache ].slice();
4703:
4704:         each( props, function( key, prop ) {
4705:             var val = arr[ type === "object" ? key : prop.idx ];
4706:             if ( val == null ) {
4707:                 val = local[ prop.idx ];
4708:             }
4709:             local[ prop.idx ] = clamp( val, prop );
4710:         });
4711:
4712:         if ( from ) {
4713:             ret = color( from( local ) );
4714:             ret[ cache ] = local;
4715:             return ret;
4716:         } else {
4717:             return color( local );
4718:         }
4719:     };
4720:
4721:     // makes red() green() blue() alpha() hue() saturation() lightness()
4722:     each( props, function( key, prop ) {
4723:         // alpha is included in more than one space
4724:         if ( color.fn[ key ] ) {
4725:             return;
4726:         }
4727:         color.fn[ key ] = function( value ) {
4728:             var vtype = jQuery.type( value ),
4729:                 fn = ( key === "alpha" ? ( this._hsla ? "hsla" : "rgba" ) : spaceName ),
4730:                 local = this[ fn ](),
4731:                 cur = local[ prop.idx ],
4732:                 match;
4733:
4734:             if ( vtype === "undefined" ) {
4735:                 return cur;
4736:             }
4737:
4738:             if ( vtype === "function" ) {
4739:                 value = value.call( this, cur );
4740:                 vtype = jQuery.type( value );
4741:             }
4742:             if ( value == null && prop.empty ) {
4743:                 return this;
4744:             }
4745:             if ( vtype === "string" ) {
4746:                 match = rplusequals.exec( value );
4747:                 if ( match ) {
4748:                     value = cur + parseFloat( match[ 2 ] ) * ( match[ 1 ] === "+" ? 1 : -1 );
4749:                 }
4750:             }
4751:             local[ prop.idx ] = value;
4752:             return this[ fn ]( local );
4753:         };
4754:     });
4755: });
4756:
4757: // add .fx.step functions
4758: each( stepHooks, function( i, hook ) {
4759:     jQuery.cssHooks[ hook ] = {
4760:         set: function( elem, value ) {
4761:             var parsed, curElem,
4762:                 backgroundColor = "";
4763:
4764:             if ( jQuery.type( value ) !== "string" || ( parsed = stringParse( value ) ) ) {
4765:                 value = color( parsed || value );
4766:                 if ( !support.rgba && value._rgba[ 3 ] !== 1 ) {
4767:                     curElem = hook === "backgroundColor" ? elem.parentNode : elem;
4768:                     while (
4769:                         (backgroundColor === "" || backgroundColor === "transparent") &&
4770:                         curElem && curElem.style
4771:                     ) {
4772:                         try {
4773:                             backgroundColor = jQuery.css( curElem, "backgroundColor" );
4774:                             curElem = curElem.parentNode;
4775:                         } catch ( e ) {
4776:                         }
4777:                     }
4778:
4779:                     value = value.blend( backgroundColor && backgroundColor !== "transparent" ?
4780:                         backgroundColor :
4781:                         "_default" );
4782:                 }
4783:
4784:                 value = value.toRgbaString();
4785:             }
4786:             try {
4787:                 elem.style[ hook ] = value;
4788:             } catch( value ) {
4789:                 // wrapped to prevent IE from throwing errors on "invalid" values like 'auto' or 'inherit'
4790:             }
4791:         }
4792:     };
4793:     jQuery.fx.step[ hook ] = function( fx ) {
4794:         if ( !fx.colorInit ) {
4795:             fx.start = color( fx.elem, hook );
4796:             fx.end = color( fx.end );
4797:             fx.colorInit = true;
4798:         }
4799:         jQuery.cssHooks[ hook ].set( fx.elem, fx.start.transition( fx.end, fx.pos ) );
4800:     };
4801: });
4802:
4803: jQuery.cssHooks.borderColor = {
4804:     expand: function( value ) {
4805:         var expanded = {};
4806:
4807:         each( [ "Top", "Right", "Bottom", "Left" ], function( i, part ) {
4808:             expanded[ "border" + part + "Color" ] = value;
4809:         });
4810:         return expanded;
4811:     }
4812: };
4813:
4814: // Basic color names only.
4815: // Usage of any of the other color names requires adding yourself or including
4816: // jquery.color.svg-names.js.
4817: colors = jQuery.Color.names = {
4818:     // 4.1. Basic color keywords
4819:     aqua: "#00ffff",
4820:     black: "#000000",
4821:     blue: "#0000ff",
4822:     fuchsia: "#ff00ff",
4823:     gray: "#808080",
4824:     green: "#008000",
4825:     lime: "#00ff00",
4826:     maroon: "#800000",
4827:     navy: "#000080",
4828:     olive: "#808000",
4829:     purple: "#800080",
4830:     red: "#ff0000",
4831:     silver: "#c0c0c0",
4832:     teal: "#008080",
4833:     white: "#ffffff",
4834:     yellow: "#ffff00",
4835:
4836:     // 4.2.3. "transparent" color keyword
4837:     transparent: [ null, null, null, 0 ],
4838:
4839:     _default: "#ffffff"
4840: };
4841:
4842: })( jQuery );
4843:
4844:
4845:
4846: /******************************************************************************/
4847: /****************************** CLASS ANIMATIONS ******************************/
4848: /******************************************************************************/
4849: (function() {
4850:
4851: var classAnimationActions = [ "add", "remove", "toggle" ],
4852:     shorthandStyles = {
4853:         border: 1,
4854:         borderBottom: 1,
4855:         borderColor: 1,
4856:         borderLeft: 1,
4857:         borderRight: 1,
4858:         borderTop: 1,
4859:         borderWidth: 1,
4860:         margin: 1,
4861:         padding: 1
4862:     };
4863:
4864: $.each([ "borderLeftStyle", "borderRightStyle", "borderBottomStyle", "borderTopStyle" ], function( _, prop ) {
4865:     $.fx.step[ prop ] = function( fx ) {
4866:         if ( fx.end !== "none" && !fx.setAttr || fx.pos === 1 && !fx.setAttr ) {
4867:             jQuery.style( fx.elem, prop, fx.end );
4868:             fx.setAttr = true;
4869:         }
4870:     };
4871: });
4872:
4873: function getElementStyles() {
4874:     var style = this.ownerDocument.defaultView ?
4875:             this.ownerDocument.defaultView.getComputedStyle( this, null ) :
4876:             this.currentStyle,
4877:         newStyle = {},
4878:         key,
4879:         camelCase,
4880:         len;
4881:
4882:     // webkit enumerates style porperties
4883:     if ( style && style.length && style[ 0 ] && style[ style[ 0 ] ] ) {
4884:         len = style.length;
4885:         while ( len-- ) {
4886:             key = style[ len ];
4887:             if ( typeof style[ key ] === "string" ) {
4888:                 newStyle[ $.camelCase( key ) ] = style[ key ];
4889:             }
4890:         }
4891:     } else {
4892:         for ( key in style ) {
4893:             if ( typeof style[ key ] === "string" ) {
4894:                 newStyle[ key ] = style[ key ];
4895:             }
4896:         }
4897:     }
4898:
4899:     return newStyle;
4900: }
4901:
4902:
4903: function styleDifference( oldStyle, newStyle ) {
4904:     var diff = {},
4905:         name, value;
4906:
4907:     for ( name in newStyle ) {
4908:         value = newStyle[ name ];
4909:         if ( oldStyle[ name ] !== value ) {
4910:             if ( !shorthandStyles[ name ] ) {
4911:                 if ( $.fx.step[ name ] || !isNaN( parseFloat( value ) ) ) {
4912:                     diff[ name ] = value;
4913:                 }
4914:             }
4915:         }
4916:     }
4917:
4918:     return diff;
4919: }
4920:
4921: $.effects.animateClass = function( value, duration, easing, callback ) {
4922:     var o = $.speed( duration, easing, callback );
4923:
4924:     return this.queue( function() {
4925:         var animated = $( this ),
4926:             baseClass = animated.attr( "class" ) || "",
4927:             applyClassChange,
4928:             allAnimations = o.children ? animated.find( "*" ).andSelf() : animated;
4929:
4930:         // map the animated objects to store the original styles.
4931:         allAnimations = allAnimations.map(function() {
4932:             var el = $( this );
4933:             return {
4934:                 el: el,
4935:                 start: getElementStyles.call( this )
4936:             };
4937:         });
4938:
4939:         // apply class change
4940:         applyClassChange = function() {
4941:             $.each( classAnimationActions, function(i, action) {
4942:                 if ( value[ action ] ) {
4943:                     animated[ action + "Class" ]( value[ action ] );
4944:                 }
4945:             });
4946:         };
4947:         applyClassChange();
4948:
4949:         // map all animated objects again - calculate new styles and diff
4950:         allAnimations = allAnimations.map(function() {
4951:             this.end = getElementStyles.call( this.el[ 0 ] );
4952:             this.diff = styleDifference( this.start, this.end );
4953:             return this;
4954:         });
4955:
4956:         // apply original class
4957:         animated.attr( "class", baseClass );
4958:
4959:         // map all animated objects again - this time collecting a promise
4960:         allAnimations = allAnimations.map(function() {
4961:             var styleInfo = this,
4962:                 dfd = $.Deferred(),
4963:                 opts = jQuery.extend({}, o, {
4964:                     queue: false,
4965:                     complete: function() {
4966:                         dfd.resolve( styleInfo );
4967:                     }
4968:                 });
4969:
4970:             this.el.animate( this.diff, opts );
4971:             return dfd.promise();
4972:         });
4973:
4974:         // once all animations have completed:
4975:         $.when.apply( $, allAnimations.get() ).done(function() {
4976:
4977:             // set the final class
4978:             applyClassChange();
4979:
4980:             // for each animated element,
4981:             // clear all css properties that were animated
4982:             $.each( arguments, function() {
4983:                 var el = this.el;
4984:                 $.each( this.diff, function(key) {
4985:                     el.css( key, '' );
4986:                 });
4987:             });
4988:
4989:             // this is guarnteed to be there if you use jQuery.speed()
4990:             // it also handles dequeuing the next anim...
4991:             o.complete.call( animated[ 0 ] );
4992:         });
4993:     });
4994: };
4995:
4996: $.fn.extend({
4997:     _addClass: $.fn.addClass,
4998:     addClass: function( classNames, speed, easing, callback ) {
4999:         return speed ?
5000:             $.effects.animateClass.call( this,
5001:                 { add: classNames }, speed, easing, callback ) :
5002:             this._addClass( classNames );
5003:     },
5004:
5005:     _removeClass: $.fn.removeClass,
5006:     removeClass: function( classNames, speed, easing, callback ) {
5007:         return speed ?
5008:             $.effects.animateClass.call( this,
5009:                 { remove: classNames }, speed, easing, callback ) :
5010:             this._removeClass( classNames );
5011:     },
5012:
5013:     _toggleClass: $.fn.toggleClass,
5014:     toggleClass: function( classNames, force, speed, easing, callback ) {
5015:         if ( typeof force === "boolean" || force === undefined ) {
5016:             if ( !speed ) {
5017:                 // without speed parameter
5018:                 return this._toggleClass( classNames, force );
5019:             } else {
5020:                 return $.effects.animateClass.call( this,
5021:                     (force ? { add: classNames } : { remove: classNames }),
5022:                     speed, easing, callback );
5023:             }
5024:         } else {
5025:             // without force parameter
5026:             return $.effects.animateClass.call( this,
5027:                 { toggle: classNames }, force, speed, easing );
5028:         }
5029:     },
5030:
5031:     switchClass: function( remove, add, speed, easing, callback) {
5032:         return $.effects.animateClass.call( this, {
5033:             add: add,
5034:             remove: remove
5035:         }, speed, easing, callback );
5036:     }
5037: });
5038:
5039: })();
5040:
5041: /******************************************************************************/
5042: /*********************************** EFFECTS **********************************/
5043: /******************************************************************************/
5044:
5045: (function() {
5046:
5047: $.extend( $.effects, {
5048:     version: "1.9.0",
5049:
5050:     // Saves a set of properties in a data storage
5051:     save: function( element, set ) {
5052:         for( var i=0; i < set.length; i++ ) {
5053:             if ( set[ i ] !== null ) {
5054:                 element.data( dataSpace + set[ i ], element[ 0 ].style[ set[ i ] ] );
5055:             }
5056:         }
5057:     },
5058:
5059:     // Restores a set of previously saved properties from a data storage
5060:     restore: function( element, set ) {
5061:         var val, i;
5062:         for( i=0; i < set.length; i++ ) {
5063:             if ( set[ i ] !== null ) {
5064:                 val = element.data( dataSpace + set[ i ] );
5065:                 // support: jQuery 1.6.2
5066:                 // http://bugs.jquery.com/ticket/9917
5067:                 // jQuery 1.6.2 incorrectly returns undefined for any falsy value.
5068:                 // We can't differentiate between "" and 0 here, so we just assume
5069:                 // empty string since it's likely to be a more common value...
5070:                 if ( val === undefined ) {
5071:                     val = "";
5072:                 }
5073:                 element.css( set[ i ], val );
5074:             }
5075:         }
5076:     },
5077:
5078:     setMode: function( el, mode ) {
5079:         if (mode === "toggle") {
5080:             mode = el.is( ":hidden" ) ? "show" : "hide";
5081:         }
5082:         return mode;
5083:     },
5084:
5085:     // Translates a [top,left] array into a baseline value
5086:     // this should be a little more flexible in the future to handle a string & hash
5087:     getBaseline: function( origin, original ) {
5088:         var y, x;
5089:         switch ( origin[ 0 ] ) {
5090:             case "top": y = 0; break;
5091:             case "middle": y = 0.5; break;
5092:             case "bottom": y = 1; break;
5093:             default: y = origin[ 0 ] / original.height;
5094:         }
5095:         switch ( origin[ 1 ] ) {
5096:             case "left": x = 0; break;
5097:             case "center": x = 0.5; break;
5098:             case "right": x = 1; break;
5099:             default: x = origin[ 1 ] / original.width;
5100:         }
5101:         return {
5102:             x: x,
5103:             y: y
5104:         };
5105:     },
5106:
5107:     // Wraps the element around a wrapper that copies position properties
5108:     createWrapper: function( element ) {
5109:
5110:         // if the element is already wrapped, return it
5111:         if ( element.parent().is( ".ui-effects-wrapper" )) {
5112:             return element.parent();
5113:         }
5114:
5115:         // wrap the element
5116:         var props = {
5117:                 width: element.outerWidth(true),
5118:                 height: element.outerHeight(true),
5119:                 "float": element.css( "float" )
5120:             },
5121:             wrapper = $( "<div></div>" )
5122:                 .addClass( "ui-effects-wrapper" )
5123:                 .css({
5124:                     fontSize: "100%",
5125:                     background: "transparent",
5126:                     border: "none",
5127:                     margin: 0,
5128:                     padding: 0
5129:                 }),
5130:             // Store the size in case width/height are defined in % - Fixes #5245
5131:             size = {
5132:                 width: element.width(),
5133:                 height: element.height()
5134:             },
5135:             active = document.activeElement;
5136:
5137:         // support: Firefox
5138:         // Firefox incorrectly exposes anonymous content
5139:         // https://bugzilla.mozilla.org/show_bug.cgi?id=561664
5140:         try {
5141:             active.id;
5142:         } catch( e ) {
5143:             active = document.body;
5144:         }
5145:
5146:         element.wrap( wrapper );
5147:
5148:         // Fixes #7595 - Elements lose focus when wrapped.
5149:         if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) {
5150:             $( active ).focus();
5151:         }
5152:
5153:         wrapper = element.parent(); //Hotfix for jQuery 1.4 since some change in wrap() seems to actually lose the reference to the wrapped element
5154:
5155:         // transfer positioning properties to the wrapper
5156:         if ( element.css( "position" ) === "static" ) {
5157:             wrapper.css({ position: "relative" });
5158:             element.css({ position: "relative" });
5159:         } else {
5160:             $.extend( props, {
5161:                 position: element.css( "position" ),
5162:                 zIndex: element.css( "z-index" )
5163:             });
5164:             $.each([ "top", "left", "bottom", "right" ], function(i, pos) {
5165:                 props[ pos ] = element.css( pos );
5166:                 if ( isNaN( parseInt( props[ pos ], 10 ) ) ) {
5167:                     props[ pos ] = "auto";
5168:                 }
5169:             });
5170:             element.css({
5171:                 position: "relative",
5172:                 top: 0,
5173:                 left: 0,
5174:                 right: "auto",
5175:                 bottom: "auto"
5176:             });
5177:         }
5178:         element.css(size);
5179:
5180:         return wrapper.css( props ).show();
5181:     },
5182:
5183:     removeWrapper: function( element ) {
5184:         var active = document.activeElement;
5185:
5186:         if ( element.parent().is( ".ui-effects-wrapper" ) ) {
5187:             element.parent().replaceWith( element );
5188:
5189:             // Fixes #7595 - Elements lose focus when wrapped.
5190:             if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) {
5191:                 $( active ).focus();
5192:             }
5193:         }
5194:
5195:
5196:         return element;
5197:     },
5198:
5199:     setTransition: function( element, list, factor, value ) {
5200:         value = value || {};
5201:         $.each( list, function( i, x ) {
5202:             var unit = element.cssUnit( x );
5203:             if ( unit[ 0 ] > 0 ) {
5204:                 value[ x ] = unit[ 0 ] * factor + unit[ 1 ];
5205:             }
5206:         });
5207:         return value;
5208:     }
5209: });
5210:
5211: // return an effect options object for the given parameters:
5212: function _normalizeArguments( effect, options, speed, callback ) {
5213:
5214:     // allow passing all optinos as the first parameter
5215:     if ( $.isPlainObject( effect ) ) {
5216:         options = effect;
5217:         effect = effect.effect;
5218:     }
5219:
5220:     // convert to an object
5221:     effect = { effect: effect };
5222:
5223:     // catch (effect)
5224:     if ( options === undefined ) {
5225:         options = {};
5226:     }
5227:
5228:     // catch (effect, callback)
5229:     if ( $.isFunction( options ) ) {
5230:         callback = options;
5231:         speed = null;
5232:         options = {};
5233:     }
5234:
5235:     // catch (effect, speed, ?)
5236:     if ( typeof options === "number" || $.fx.speeds[ options ] ) {
5237:         callback = speed;
5238:         speed = options;
5239:         options = {};
5240:     }
5241:
5242:     // catch (effect, options, callback)
5243:     if ( $.isFunction( speed ) ) {
5244:         callback = speed;
5245:         speed = null;
5246:     }
5247:
5248:     // add options to effect
5249:     if ( options ) {
5250:         $.extend( effect, options );
5251:     }
5252:
5253:     speed = speed || options.duration;
5254:     effect.duration = $.fx.off ? 0 :
5255:         typeof speed === "number" ? speed :
5256:         speed in $.fx.speeds ? $.fx.speeds[ speed ] :
5257:         $.fx.speeds._default;
5258:
5259:     effect.complete = callback || options.complete;
5260:
5261:     return effect;
5262: }
5263:
5264: function standardSpeed( speed ) {
5265:     // valid standard speeds
5266:     if ( !speed || typeof speed === "number" || $.fx.speeds[ speed ] ) {
5267:         return true;
5268:     }
5269:
5270:     // invalid strings - treat as "normal" speed
5271:     if ( typeof speed === "string" && !$.effects.effect[ speed ] ) {
5272:         // TODO: remove in 2.0 (#7115)
5273:         if ( backCompat && $.effects[ speed ] ) {
5274:             return false;
5275:         }
5276:         return true;
5277:     }
5278:
5279:     return false;
5280: }
5281:
5282: $.fn.extend({
5283:     effect: function( effect, options, speed, callback ) {
5284:         var args = _normalizeArguments.apply( this, arguments ),
5285:             mode = args.mode,
5286:             queue = args.queue,
5287:             effectMethod = $.effects.effect[ args.effect ],
5288:
5289:             // DEPRECATED: remove in 2.0 (#7115)
5290:             oldEffectMethod = !effectMethod && backCompat && $.effects[ args.effect ];
5291:
5292:         if ( $.fx.off || !( effectMethod || oldEffectMethod ) ) {
5293:             // delegate to the original method (e.g., .show()) if possible
5294:             if ( mode ) {
5295:                 return this[ mode ]( args.duration, args.complete );
5296:             } else {
5297:                 return this.each( function() {
5298:                     if ( args.complete ) {
5299:                         args.complete.call( this );
5300:                     }
5301:                 });
5302:             }
5303:         }
5304:
5305:         function run( next ) {
5306:             var elem = $( this ),
5307:                 complete = args.complete,
5308:                 mode = args.mode;
5309:
5310:             function done() {
5311:                 if ( $.isFunction( complete ) ) {
5312:                     complete.call( elem[0] );
5313:                 }
5314:                 if ( $.isFunction( next ) ) {
5315:                     next();
5316:                 }
5317:             }
5318:
5319:             // if the element is hiddden and mode is hide,
5320:             // or element is visible and mode is show
5321:             if ( elem.is( ":hidden" ) ? mode === "hide" : mode === "show" ) {
5322:                 done();
5323:             } else {
5324:                 effectMethod.call( elem[0], args, done );
5325:             }
5326:         }
5327:
5328:         // TODO: remove this check in 2.0, effectMethod will always be true
5329:         if ( effectMethod ) {
5330:             return queue === false ? this.each( run ) : this.queue( queue || "fx", run );
5331:         } else {
5332:             // DEPRECATED: remove in 2.0 (#7115)
5333:             return oldEffectMethod.call(this, {
5334:                 options: args,
5335:                 duration: args.duration,
5336:                 callback: args.complete,
5337:                 mode: args.mode
5338:             });
5339:         }
5340:     },
5341:
5342:     _show: $.fn.show,
5343:     show: function( speed ) {
5344:         if ( standardSpeed( speed ) ) {
5345:             return this._show.apply( this, arguments );
5346:         } else {
5347:             var args = _normalizeArguments.apply( this, arguments );
5348:             args.mode = "show";
5349:             return this.effect.call( this, args );
5350:         }
5351:     },
5352:
5353:     _hide: $.fn.hide,
5354:     hide: function( speed ) {
5355:         if ( standardSpeed( speed ) ) {
5356:             return this._hide.apply( this, arguments );
5357:         } else {
5358:             var args = _normalizeArguments.apply( this, arguments );
5359:             args.mode = "hide";
5360:             return this.effect.call( this, args );
5361:         }
5362:     },
5363:
5364:     // jQuery core overloads toggle and creates _toggle
5365:     __toggle: $.fn.toggle,
5366:     toggle: function( speed ) {
5367:         if ( standardSpeed( speed ) || typeof speed === "boolean" || $.isFunction( speed ) ) {
5368:             return this.__toggle.apply( this, arguments );
5369:         } else {
5370:             var args = _normalizeArguments.apply( this, arguments );
5371:             args.mode = "toggle";
5372:             return this.effect.call( this, args );
5373:         }
5374:     },
5375:
5376:     // helper functions
5377:     cssUnit: function(key) {
5378:         var style = this.css( key ),
5379:             val = [];
5380:
5381:         $.each( [ "em", "px", "%", "pt" ], function( i, unit ) {
5382:             if ( style.indexOf( unit ) > 0 ) {
5383:                 val = [ parseFloat( style ), unit ];
5384:             }
5385:         });
5386:         return val;
5387:     }
5388: });
5389:
5390: })();
5391:
5392: /******************************************************************************/
5393: /*********************************** EASING ***********************************/
5394: /******************************************************************************/
5395:
5396: (function() {
5397:
5398: // based on easing equations from Robert Penner (http://www.robertpenner.com/easing)
5399:
5400: var baseEasings = {};
5401:
5402: $.each( [ "Quad", "Cubic", "Quart", "Quint", "Expo" ], function( i, name ) {
5403:     baseEasings[ name ] = function( p ) {
5404:         return Math.pow( p, i + 2 );
5405:     };
5406: });
5407:
5408: $.extend( baseEasings, {
5409:     Sine: function ( p ) {
5410:         return 1 - Math.cos( p * Math.PI / 2 );
5411:     },
5412:     Circ: function ( p ) {
5413:         return 1 - Math.sqrt( 1 - p * p );
5414:     },
5415:     Elastic: function( p ) {
5416:         return p === 0 || p === 1 ? p :
5417:             -Math.pow( 2, 8 * (p - 1) ) * Math.sin( ( (p - 1) * 80 - 7.5 ) * Math.PI / 15 );
5418:     },
5419:     Back: function( p ) {
5420:         return p * p * ( 3 * p - 2 );
5421:     },
5422:     Bounce: function ( p ) {
5423:         var pow2,
5424:             bounce = 4;
5425:
5426:         while ( p < ( ( pow2 = Math.pow( 2, --bounce ) ) - 1 ) / 11 ) {}
5427:         return 1 / Math.pow( 4, 3 - bounce ) - 7.5625 * Math.pow( ( pow2 * 3 - 2 ) / 22 - p, 2 );
5428:     }
5429: });
5430:
5431: $.each( baseEasings, function( name, easeIn ) {
5432:     $.easing[ "easeIn" + name ] = easeIn;
5433:     $.easing[ "easeOut" + name ] = function( p ) {
5434:         return 1 - easeIn( 1 - p );
5435:     };
5436:     $.easing[ "easeInOut" + name ] = function( p ) {
5437:         return p < 0.5 ?
5438:             easeIn( p * 2 ) / 2 :
5439:             1 - easeIn( p * -2 + 2 ) / 2;
5440:     };
5441: });
5442:
5443: })();
5444:
5445: })(jQuery));
5446:
5447: (function( $, undefined ) {
5448:
5449: var uid = 0,
5450:     hideProps = {},
5451:     showProps = {};
5452:
5453: hideProps.height = hideProps.paddingTop = hideProps.paddingBottom =
5454:     hideProps.borderTopWidth = hideProps.borderBottomWidth = "hide";
5455: showProps.height = showProps.paddingTop = showProps.paddingBottom =
5456:     showProps.borderTopWidth = showProps.borderBottomWidth = "show";
5457:
5458: $.widget( "ui.accordion", {
5459:     version: "1.9.0",
5460:     options: {
5461:         active: 0,
5462:         animate: {},
5463:         collapsible: false,
5464:         event: "click",
5465:         header: "> li > :first-child,> :not(li):even",
5466:         heightStyle: "auto",
5467:         icons: {
5468:             activeHeader: "ui-icon-triangle-1-s",
5469:             header: "ui-icon-triangle-1-e"
5470:         },
5471:
5472:         // callbacks
5473:         activate: null,
5474:         beforeActivate: null
5475:     },
5476:
5477:     _create: function() {
5478:         var accordionId = this.accordionId = "ui-accordion-" +
5479:                 (this.element.attr( "id" ) || ++uid),
5480:             options = this.options;
5481:
5482:         this.prevShow = this.prevHide = $();
5483:         this.element.addClass( "ui-accordion ui-widget ui-helper-reset" );
5484:
5485:         this.headers = this.element.find( options.header )
5486:             .addClass( "ui-accordion-header ui-helper-reset ui-state-default ui-corner-all" );
5487:         this._hoverable( this.headers );
5488:         this._focusable( this.headers );
5489:
5490:         this.headers.next()
5491:             .addClass( "ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom" )
5492:             .hide();
5493:
5494:         // don't allow collapsible: false and active: false
5495:         if ( !options.collapsible && options.active === false ) {
5496:             options.active = 0;
5497:         }
5498:         // handle negative values
5499:         if ( options.active < 0 ) {
5500:             options.active += this.headers.length;
5501:         }
5502:         this.active = this._findActive( options.active )
5503:             .addClass( "ui-accordion-header-active ui-state-active" )
5504:             .toggleClass( "ui-corner-all ui-corner-top" );
5505:         this.active.next()
5506:             .addClass( "ui-accordion-content-active" )
5507:             .show();
5508:
5509:         this._createIcons();
5510:         this.originalHeight = this.element[0].style.height;
5511:         this.refresh();
5512:
5513:         // ARIA
5514:         this.element.attr( "role", "tablist" );
5515:
5516:         this.headers
5517:             .attr( "role", "tab" )
5518:             .each(function( i ) {
5519:                 var header = $( this ),
5520:                     headerId = header.attr( "id" ),
5521:                     panel = header.next(),
5522:                     panelId = panel.attr( "id" );
5523:                 if ( !headerId ) {
5524:                     headerId = accordionId + "-header-" + i;
5525:                     header.attr( "id", headerId );
5526:                 }
5527:                 if ( !panelId ) {
5528:                     panelId = accordionId + "-panel-" + i;
5529:                     panel.attr( "id", panelId );
5530:                 }
5531:                 header.attr( "aria-controls", panelId );
5532:                 panel.attr( "aria-labelledby", headerId );
5533:             })
5534:             .next()
5535:                 .attr( "role", "tabpanel" );
5536:
5537:         this.headers
5538:             .not( this.active )
5539:             .attr({
5540:                 "aria-selected": "false",
5541:                 tabIndex: -1
5542:             })
5543:             .next()
5544:                 .attr({
5545:                     "aria-expanded": "false",
5546:                     "aria-hidden": "true"
5547:                 })
5548:                 .hide();
5549:
5550:         // make sure at least one header is in the tab order
5551:         if ( !this.active.length ) {
5552:             this.headers.eq( 0 ).attr( "tabIndex", 0 );
5553:         } else {
5554:             this.active.attr({
5555:                 "aria-selected": "true",
5556:                 tabIndex: 0
5557:             })
5558:             .next()
5559:                 .attr({
5560:                     "aria-expanded": "true",
5561:                     "aria-hidden": "false"
5562:                 });
5563:         }
5564:
5565:         this._on( this.headers, { keydown: "_keydown" });
5566:         this._on( this.headers.next(), { keydown: "_panelKeyDown" });
5567:         this._setupEvents( options.event );
5568:     },
5569:
5570:     _getCreateEventData: function() {
5571:         return {
5572:             header: this.active,
5573:             content: !this.active.length ? $() : this.active.next()
5574:         };
5575:     },
5576:
5577:     _createIcons: function() {
5578:         var icons = this.options.icons;
5579:         if ( icons ) {
5580:             $( "<span>" )
5581:                 .addClass( "ui-accordion-header-icon ui-icon " + icons.header )
5582:                 .prependTo( this.headers );
5583:             this.active.children( ".ui-accordion-header-icon" )
5584:                 .removeClass( icons.header )
5585:                 .addClass( icons.activeHeader );
5586:             this.headers.addClass( "ui-accordion-icons" );
5587:         }
5588:     },
5589:
5590:     _destroyIcons: function() {
5591:         this.headers
5592:             .removeClass( "ui-accordion-icons" )
5593:             .children( ".ui-accordion-header-icon" )
5594:                 .remove();
5595:     },
5596:
5597:     _destroy: function() {
5598:         var contents;
5599:
5600:         // clean up main element
5601:         this.element
5602:             .removeClass( "ui-accordion ui-widget ui-helper-reset" )
5603:             .removeAttr( "role" );
5604:
5605:         // clean up headers
5606:         this.headers
5607:             .removeClass( "ui-accordion-header ui-accordion-header-active ui-helper-reset ui-state-default ui-corner-all ui-state-active ui-state-disabled ui-corner-top" )
5608:             .removeAttr( "role" )
5609:             .removeAttr( "aria-selected" )
5610:             .removeAttr( "aria-controls" )
5611:             .removeAttr( "tabIndex" )
5612:             .each(function() {
5613:                 if ( /^ui-accordion/.test( this.id ) ) {
5614:                     this.removeAttribute( "id" );
5615:                 }
5616:             });
5617:         this._destroyIcons();
5618:
5619:         // clean up content panels
5620:         contents = this.headers.next()
5621:             .css( "display", "" )
5622:             .removeAttr( "role" )
5623:             .removeAttr( "aria-expanded" )
5624:             .removeAttr( "aria-hidden" )
5625:             .removeAttr( "aria-labelledby" )
5626:             .removeClass( "ui-helper-reset ui-widget-content ui-corner-bottom ui-accordion-content ui-accordion-content-active ui-state-disabled" )
5627:             .each(function() {
5628:                 if ( /^ui-accordion/.test( this.id ) ) {
5629:                     this.removeAttribute( "id" );
5630:                 }
5631:             });
5632:         if ( this.options.heightStyle !== "content" ) {
5633:             this.element.css( "height", this.originalHeight );
5634:             contents.css( "height", "" );
5635:         }
5636:     },
5637:
5638:     _setOption: function( key, value ) {
5639:         if ( key === "active" ) {
5640:             // _activate() will handle invalid values and update this.options
5641:             this._activate( value );
5642:             return;
5643:         }
5644:
5645:         if ( key === "event" ) {
5646:             if ( this.options.event ) {
5647:                 this._off( this.headers, this.options.event );
5648:             }
5649:             this._setupEvents( value );
5650:         }
5651:
5652:         this._super( key, value );
5653:
5654:         // setting collapsible: false while collapsed; open first panel
5655:         if ( key === "collapsible" && !value && this.options.active === false ) {
5656:             this._activate( 0 );
5657:         }
5658:
5659:         if ( key === "icons" ) {
5660:             this._destroyIcons();
5661:             if ( value ) {
5662:                 this._createIcons();
5663:             }
5664:         }
5665:
5666:         // #5332 - opacity doesn't cascade to positioned elements in IE
5667:         // so we need to add the disabled class to the headers and panels
5668:         if ( key === "disabled" ) {
5669:             this.headers.add( this.headers.next() )
5670:                 .toggleClass( "ui-state-disabled", !!value );
5671:         }
5672:     },
5673:
5674:     _keydown: function( event ) {
5675:         if ( event.altKey || event.ctrlKey ) {
5676:             return;
5677:         }
5678:
5679:         var keyCode = $.ui.keyCode,
5680:             length = this.headers.length,
5681:             currentIndex = this.headers.index( event.target ),
5682:             toFocus = false;
5683:
5684:         switch ( event.keyCode ) {
5685:             case keyCode.RIGHT:
5686:             case keyCode.DOWN:
5687:                 toFocus = this.headers[ ( currentIndex + 1 ) % length ];
5688:                 break;
5689:             case keyCode.LEFT:
5690:             case keyCode.UP:
5691:                 toFocus = this.headers[ ( currentIndex - 1 + length ) % length ];
5692:                 break;
5693:             case keyCode.SPACE:
5694:             case keyCode.ENTER:
5695:                 this._eventHandler( event );
5696:                 break;
5697:             case keyCode.HOME:
5698:                 toFocus = this.headers[ 0 ];
5699:                 break;
5700:             case keyCode.END:
5701:                 toFocus = this.headers[ length - 1 ];
5702:                 break;
5703:         }
5704:
5705:         if ( toFocus ) {
5706:             $( event.target ).attr( "tabIndex", -1 );
5707:             $( toFocus ).attr( "tabIndex", 0 );
5708:             toFocus.focus();
5709:             event.preventDefault();
5710:         }
5711:     },
5712:
5713:     _panelKeyDown : function( event ) {
5714:         if ( event.keyCode === $.ui.keyCode.UP && event.ctrlKey ) {
5715:             $( event.currentTarget ).prev().focus();
5716:         }
5717:     },
5718:
5719:     refresh: function() {
5720:         var maxHeight, overflow,
5721:             heightStyle = this.options.heightStyle,
5722:             parent = this.element.parent();
5723:
5724:         this.element.css( "height", this.originalHeight );
5725:
5726:         if ( heightStyle === "fill" ) {
5727:             // IE 6 treats height like minHeight, so we need to turn off overflow
5728:             // in order to get a reliable height
5729:             // we use the minHeight support test because we assume that only
5730:             // browsers that don't support minHeight will treat height as minHeight
5731:             if ( !$.support.minHeight ) {
5732:                 overflow = parent.css( "overflow" );
5733:                 parent.css( "overflow", "hidden");
5734:             }
5735:             maxHeight = parent.height();
5736:             this.element.siblings( ":visible" ).each(function() {
5737:                 var elem = $( this ),
5738:                     position = elem.css( "position" );
5739:
5740:                 if ( position === "absolute" || position === "fixed" ) {
5741:                     return;
5742:                 }
5743:                 maxHeight -= elem.outerHeight( true );
5744:             });
5745:             if ( overflow ) {
5746:                 parent.css( "overflow", overflow );
5747:             }
5748:
5749:             this.headers.each(function() {
5750:                 maxHeight -= $( this ).outerHeight( true );
5751:             });
5752:
5753:             this.headers.next()
5754:                 .each(function() {
5755:                     $( this ).height( Math.max( 0, maxHeight -
5756:                         $( this ).innerHeight() + $( this ).height() ) );
5757:                 })
5758:                 .css( "overflow", "auto" );
5759:         } else if ( heightStyle === "auto" ) {
5760:             maxHeight = 0;
5761:             this.headers.next()
5762:                 .each(function() {
5763:                     maxHeight = Math.max( maxHeight, $( this ).height( "" ).height() );
5764:                 })
5765:                 .height( maxHeight );
5766:         }
5767:
5768:         if ( heightStyle !== "content" ) {
5769:             this.element.height( this.element.height() );
5770:         }
5771:     },
5772:
5773:     _activate: function( index ) {
5774:         var active = this._findActive( index )[ 0 ];
5775:
5776:         // trying to activate the already active panel
5777:         if ( active === this.active[ 0 ] ) {
5778:             return;
5779:         }
5780:
5781:         // trying to collapse, simulate a click on the currently active header
5782:         active = active || this.active[ 0 ];
5783:
5784:         this._eventHandler({
5785:             target: active,
5786:             currentTarget: active,
5787:             preventDefault: $.noop
5788:         });
5789:     },
5790:
5791:     _findActive: function( selector ) {
5792:         return typeof selector === "number" ? this.headers.eq( selector ) : $();
5793:     },
5794:
5795:     _setupEvents: function( event ) {
5796:         var events = {};
5797:         if ( !event ) {
5798:             return;
5799:         }
5800:         $.each( event.split(" "), function( index, eventName ) {
5801:             events[ eventName ] = "_eventHandler";
5802:         });
5803:         this._on( this.headers, events );
5804:     },
5805:
5806:     _eventHandler: function( event ) {
5807:         var options = this.options,
5808:             active = this.active,
5809:             clicked = $( event.currentTarget ),
5810:             clickedIsActive = clicked[ 0 ] === active[ 0 ],
5811:             collapsing = clickedIsActive && options.collapsible,
5812:             toShow = collapsing ? $() : clicked.next(),
5813:             toHide = active.next(),
5814:             eventData = {
5815:                 oldHeader: active,
5816:                 oldPanel: toHide,
5817:                 newHeader: collapsing ? $() : clicked,
5818:                 newPanel: toShow
5819:             };
5820:
5821:         event.preventDefault();
5822:
5823:         if (
5824:                 // click on active header, but not collapsible
5825:                 ( clickedIsActive && !options.collapsible ) ||
5826:                 // allow canceling activation
5827:                 ( this._trigger( "beforeActivate", event, eventData ) === false ) ) {
5828:             return;
5829:         }
5830:
5831:         options.active = collapsing ? false : this.headers.index( clicked );
5832:
5833:         // when the call to ._toggle() comes after the class changes
5834:         // it causes a very odd bug in IE 8 (see #6720)
5835:         this.active = clickedIsActive ? $() : clicked;
5836:         this._toggle( eventData );
5837:
5838:         // switch classes
5839:         // corner classes on the previously active header stay after the animation
5840:         active.removeClass( "ui-accordion-header-active ui-state-active" );
5841:         if ( options.icons ) {
5842:             active.children( ".ui-accordion-header-icon" )
5843:                 .removeClass( options.icons.activeHeader )
5844:                 .addClass( options.icons.header );
5845:         }
5846:
5847:         if ( !clickedIsActive ) {
5848:             clicked
5849:                 .removeClass( "ui-corner-all" )
5850:                 .addClass( "ui-accordion-header-active ui-state-active ui-corner-top" );
5851:             if ( options.icons ) {
5852:                 clicked.children( ".ui-accordion-header-icon" )
5853:                     .removeClass( options.icons.header )
5854:                     .addClass( options.icons.activeHeader );
5855:             }
5856:
5857:             clicked
5858:                 .next()
5859:                 .addClass( "ui-accordion-content-active" );
5860:         }
5861:     },
5862:
5863:     _toggle: function( data ) {
5864:         var toShow = data.newPanel,
5865:             toHide = this.prevShow.length ? this.prevShow : data.oldPanel;
5866:
5867:         // handle activating a panel during the animation for another activation
5868:         this.prevShow.add( this.prevHide ).stop( true, true );
5869:         this.prevShow = toShow;
5870:         this.prevHide = toHide;
5871:
5872:         if ( this.options.animate ) {
5873:             this._animate( toShow, toHide, data );
5874:         } else {
5875:             toHide.hide();
5876:             toShow.show();
5877:             this._toggleComplete( data );
5878:         }
5879:
5880:         toHide.attr({
5881:             "aria-expanded": "false",
5882:             "aria-hidden": "true"
5883:         });
5884:         toHide.prev().attr( "aria-selected", "false" );
5885:         // if we're switching panels, remove the old header from the tab order
5886:         // if we're opening from collapsed state, remove the previous header from the tab order
5887:         // if we're collapsing, then keep the collapsing header in the tab order
5888:         if ( toShow.length && toHide.length ) {
5889:             toHide.prev().attr( "tabIndex", -1 );
5890:         } else if ( toShow.length ) {
5891:             this.headers.filter(function() {
5892:                 return $( this ).attr( "tabIndex" ) === 0;
5893:             })
5894:             .attr( "tabIndex", -1 );
5895:         }
5896:
5897:         toShow
5898:             .attr({
5899:                 "aria-expanded": "true",
5900:                 "aria-hidden": "false"
5901:             })
5902:             .prev()
5903:                 .attr({
5904:                     "aria-selected": "true",
5905:                     tabIndex: 0
5906:                 });
5907:     },
5908:
5909:     _animate: function( toShow, toHide, data ) {
5910:         var total, easing, duration,
5911:             that = this,
5912:             adjust = 0,
5913:             down = toShow.length &&
5914:                 ( !toHide.length || ( toShow.index() < toHide.index() ) ),
5915:             animate = this.options.animate || {},
5916:             options = down && animate.down || animate,
5917:             complete = function() {
5918:                 that._toggleComplete( data );
5919:             };
5920:
5921:         if ( typeof options === "number" ) {
5922:             duration = options;
5923:         }
5924:         if ( typeof options === "string" ) {
5925:             easing = options;
5926:         }
5927:         // fall back from options to animation in case of partial down settings
5928:         easing = easing || options.easing || animate.easing;
5929:         duration = duration || options.duration || animate.duration;
5930:
5931:         if ( !toHide.length ) {
5932:             return toShow.animate( showProps, duration, easing, complete );
5933:         }
5934:         if ( !toShow.length ) {
5935:             return toHide.animate( hideProps, duration, easing, complete );
5936:         }
5937:
5938:         total = toShow.show().outerHeight();
5939:         toHide.animate( hideProps, {
5940:             duration: duration,
5941:             easing: easing,
5942:             step: function( now, fx ) {
5943:                 fx.now = Math.round( now );
5944:             }
5945:         });
5946:         toShow
5947:             .hide()
5948:             .animate( showProps, {
5949:                 duration: duration,
5950:                 easing: easing,
5951:                 complete: complete,
5952:                 step: function( now, fx ) {
5953:                     fx.now = Math.round( now );
5954:                     if ( fx.prop !== "height" ) {
5955:                         adjust += fx.now;
5956:                     } else if ( that.options.heightStyle !== "content" ) {
5957:                         fx.now = Math.round( total - toHide.outerHeight() - adjust );
5958:                         adjust = 0;
5959:                     }
5960:                 }
5961:             });
5962:     },
5963:
5964:     _toggleComplete: function( data ) {
5965:         var toHide = data.oldPanel;
5966:
5967:         toHide
5968:             .removeClass( "ui-accordion-content-active" )
5969:             .prev()
5970:                 .removeClass( "ui-corner-top" )
5971:                 .addClass( "ui-corner-all" );
5972:
5973:         // Work around for rendering bug in IE (#5421)
5974:         if ( toHide.length ) {
5975:             toHide.parent()[0].className = toHide.parent()[0].className;
5976:         }
5977:
5978:         this._trigger( "activate", null, data );
5979:     }
5980: });
5981:
5982:
5983:
5984: // DEPRECATED
5985: if ( $.uiBackCompat !== false ) {
5986:     // navigation options
5987:     (function( $, prototype ) {
5988:         $.extend( prototype.options, {
5989:             navigation: false,
5990:             navigationFilter: function() {
5991:                 return this.href.toLowerCase() === location.href.toLowerCase();
5992:             }
5993:         });
5994:
5995:         var _create = prototype._create;
5996:         prototype._create = function() {
5997:             if ( this.options.navigation ) {
5998:                 var that = this,
5999:                     headers = this.element.find( this.options.header ),
6000:                     content = headers.next(),
6001:                     current = headers.add( content )
6002:                         .find( "a" )
6003:                         .filter( this.options.navigationFilter )
6004:                         [ 0 ];
6005:                 if ( current ) {
6006:                     headers.add( content ).each( function( index ) {
6007:                         if ( $.contains( this, current ) ) {
6008:                             that.options.active = Math.floor( index / 2 );
6009:                             return false;
6010:                         }
6011:                     });
6012:                 }
6013:             }
6014:             _create.call( this );
6015:         };
6016:     }( jQuery, jQuery.ui.accordion.prototype ) );
6017:
6018:     // height options
6019:     (function( $, prototype ) {
6020:         $.extend( prototype.options, {
6021:             heightStyle: null, // remove default so we fall back to old values
6022:             autoHeight: true, // use heightStyle: "auto"
6023:             clearStyle: false, // use heightStyle: "content"
6024:             fillSpace: false // use heightStyle: "fill"
6025:         });
6026:
6027:         var _create = prototype._create,
6028:             _setOption = prototype._setOption;
6029:
6030:         $.extend( prototype, {
6031:             _create: function() {
6032:                 this.options.heightStyle = this.options.heightStyle ||
6033:                     this._mergeHeightStyle();
6034:
6035:                 _create.call( this );
6036:             },
6037:
6038:             _setOption: function( key, value ) {
6039:                 if ( key === "autoHeight" || key === "clearStyle" || key === "fillSpace" ) {
6040:                     this.options.heightStyle = this._mergeHeightStyle();
6041:                 }
6042:                 _setOption.apply( this, arguments );
6043:             },
6044:
6045:             _mergeHeightStyle: function() {
6046:                 var options = this.options;
6047:
6048:                 if ( options.fillSpace ) {
6049:                     return "fill";
6050:                 }
6051:
6052:                 if ( options.clearStyle ) {
6053:                     return "content";
6054:                 }
6055:
6056:                 if ( options.autoHeight ) {
6057:                     return "auto";
6058:                 }
6059:             }
6060:         });
6061:     }( jQuery, jQuery.ui.accordion.prototype ) );
6062:
6063:     // icon options
6064:     (function( $, prototype ) {
6065:         $.extend( prototype.options.icons, {
6066:             activeHeader: null, // remove default so we fall back to old values
6067:             headerSelected: "ui-icon-triangle-1-s"
6068:         });
6069:
6070:         var _createIcons = prototype._createIcons;
6071:         prototype._createIcons = function() {
6072:             if ( this.options.icons ) {
6073:                 this.options.icons.activeHeader = this.options.icons.activeHeader ||
6074:                     this.options.icons.headerSelected;
6075:             }
6076:             _createIcons.call( this );
6077:         };
6078:     }( jQuery, jQuery.ui.accordion.prototype ) );
6079:
6080:     // expanded active option, activate method
6081:     (function( $, prototype ) {
6082:         prototype.activate = prototype._activate;
6083:
6084:         var _findActive = prototype._findActive;
6085:         prototype._findActive = function( index ) {
6086:             if ( index === -1 ) {
6087:                 index = false;
6088:             }
6089:             if ( index && typeof index !== "number" ) {
6090:                 index = this.headers.index( this.headers.filter( index ) );
6091:                 if ( index === -1 ) {
6092:                     index = false;
6093:                 }
6094:             }
6095:             return _findActive.call( this, index );
6096:         };
6097:     }( jQuery, jQuery.ui.accordion.prototype ) );
6098:
6099:     // resize method
6100:     jQuery.ui.accordion.prototype.resize = jQuery.ui.accordion.prototype.refresh;
6101:
6102:     // change events
6103:     (function( $, prototype ) {
6104:         $.extend( prototype.options, {
6105:             change: null,
6106:             changestart: null
6107:         });
6108:
6109:         var _trigger = prototype._trigger;
6110:         prototype._trigger = function( type, event, data ) {
6111:             var ret = _trigger.apply( this, arguments );
6112:             if ( !ret ) {
6113:                 return false;
6114:             }
6115:
6116:             if ( type === "beforeActivate" ) {
6117:                 ret = _trigger.call( this, "changestart", event, {
6118:                     oldHeader: data.oldHeader,
6119:                     oldContent: data.oldPanel,
6120:                     newHeader: data.newHeader,
6121:                     newContent: data.newPanel
6122:                 });
6123:             } else if ( type === "activate" ) {
6124:                 ret = _trigger.call( this, "change", event, {
6125:                     oldHeader: data.oldHeader,
6126:                     oldContent: data.oldPanel,
6127:                     newHeader: data.newHeader,
6128:                     newContent: data.newPanel
6129:                 });
6130:             }
6131:             return ret;
6132:         };
6133:     }( jQuery, jQuery.ui.accordion.prototype ) );
6134:
6135:     // animated option
6136:     // NOTE: this only provides support for "slide", "bounceslide", and easings
6137:     // not the full $.ui.accordion.animations API
6138:     (function( $, prototype ) {
6139:         $.extend( prototype.options, {
6140:             animate: null,
6141:             animated: "slide"
6142:         });
6143:
6144:         var _create = prototype._create;
6145:         prototype._create = function() {
6146:             var options = this.options;
6147:       &n