pywebexec 2.4.8__py3-none-any.whl → 2.4.9__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,3476 @@
1
+ /*! jQuery UI - v1.12.1 - 2018-11-27
2
+ * http://jqueryui.com
3
+ * Includes: widget.js, position.js, data.js, disable-selection.js, focusable.js, form-reset-mixin.js, jquery-1-7.js, keycode.js, labels.js, scroll-parent.js, tabbable.js, unique-id.js, widgets/sortable.js, widgets/mouse.js
4
+ * Copyright jQuery Foundation and other contributors; Licensed MIT */
5
+
6
+ (function( factory ) {
7
+ if ( typeof define === "function" && define.amd ) {
8
+
9
+ // AMD. Register as an anonymous module.
10
+ define([ "jquery" ], factory );
11
+ } else {
12
+
13
+ // Browser globals
14
+ factory( jQuery );
15
+ }
16
+ }(function( $ ) {
17
+
18
+ $.ui = $.ui || {};
19
+
20
+ var version = $.ui.version = "1.12.1";
21
+
22
+
23
+ /*!
24
+ * jQuery UI Widget 1.12.1
25
+ * http://jqueryui.com
26
+ *
27
+ * Copyright jQuery Foundation and other contributors
28
+ * Released under the MIT license.
29
+ * http://jquery.org/license
30
+ */
31
+
32
+ //>>label: Widget
33
+ //>>group: Core
34
+ //>>description: Provides a factory for creating stateful widgets with a common API.
35
+ //>>docs: http://api.jqueryui.com/jQuery.widget/
36
+ //>>demos: http://jqueryui.com/widget/
37
+
38
+
39
+
40
+ var widgetUuid = 0;
41
+ var widgetSlice = Array.prototype.slice;
42
+
43
+ $.cleanData = ( function( orig ) {
44
+ return function( elems ) {
45
+ var events, elem, i;
46
+ for ( i = 0; ( elem = elems[ i ] ) != null; i++ ) {
47
+ try {
48
+
49
+ // Only trigger remove when necessary to save time
50
+ events = $._data( elem, "events" );
51
+ if ( events && events.remove ) {
52
+ $( elem ).triggerHandler( "remove" );
53
+ }
54
+
55
+ // Http://bugs.jquery.com/ticket/8235
56
+ } catch ( e ) {}
57
+ }
58
+ orig( elems );
59
+ };
60
+ } )( $.cleanData );
61
+
62
+ $.widget = function( name, base, prototype ) {
63
+ var existingConstructor, constructor, basePrototype;
64
+
65
+ // ProxiedPrototype allows the provided prototype to remain unmodified
66
+ // so that it can be used as a mixin for multiple widgets (#8876)
67
+ var proxiedPrototype = {};
68
+
69
+ var namespace = name.split( "." )[ 0 ];
70
+ name = name.split( "." )[ 1 ];
71
+ var fullName = namespace + "-" + name;
72
+
73
+ if ( !prototype ) {
74
+ prototype = base;
75
+ base = $.Widget;
76
+ }
77
+
78
+ if ( $.isArray( prototype ) ) {
79
+ prototype = $.extend.apply( null, [ {} ].concat( prototype ) );
80
+ }
81
+
82
+ // Create selector for plugin
83
+ $.expr[ ":" ][ fullName.toLowerCase() ] = function( elem ) {
84
+ return !!$.data( elem, fullName );
85
+ };
86
+
87
+ $[ namespace ] = $[ namespace ] || {};
88
+ existingConstructor = $[ namespace ][ name ];
89
+ constructor = $[ namespace ][ name ] = function( options, element ) {
90
+
91
+ // Allow instantiation without "new" keyword
92
+ if ( !this._createWidget ) {
93
+ return new constructor( options, element );
94
+ }
95
+
96
+ // Allow instantiation without initializing for simple inheritance
97
+ // must use "new" keyword (the code above always passes args)
98
+ if ( arguments.length ) {
99
+ this._createWidget( options, element );
100
+ }
101
+ };
102
+
103
+ // Extend with the existing constructor to carry over any static properties
104
+ $.extend( constructor, existingConstructor, {
105
+ version: prototype.version,
106
+
107
+ // Copy the object used to create the prototype in case we need to
108
+ // redefine the widget later
109
+ _proto: $.extend( {}, prototype ),
110
+
111
+ // Track widgets that inherit from this widget in case this widget is
112
+ // redefined after a widget inherits from it
113
+ _childConstructors: []
114
+ } );
115
+
116
+ basePrototype = new base();
117
+
118
+ // We need to make the options hash a property directly on the new instance
119
+ // otherwise we'll modify the options hash on the prototype that we're
120
+ // inheriting from
121
+ basePrototype.options = $.widget.extend( {}, basePrototype.options );
122
+ $.each( prototype, function( prop, value ) {
123
+ if ( !$.isFunction( value ) ) {
124
+ proxiedPrototype[ prop ] = value;
125
+ return;
126
+ }
127
+ proxiedPrototype[ prop ] = ( function() {
128
+ function _super() {
129
+ return base.prototype[ prop ].apply( this, arguments );
130
+ }
131
+
132
+ function _superApply( args ) {
133
+ return base.prototype[ prop ].apply( this, args );
134
+ }
135
+
136
+ return function() {
137
+ var __super = this._super;
138
+ var __superApply = this._superApply;
139
+ var returnValue;
140
+
141
+ this._super = _super;
142
+ this._superApply = _superApply;
143
+
144
+ returnValue = value.apply( this, arguments );
145
+
146
+ this._super = __super;
147
+ this._superApply = __superApply;
148
+
149
+ return returnValue;
150
+ };
151
+ } )();
152
+ } );
153
+ constructor.prototype = $.widget.extend( basePrototype, {
154
+
155
+ // TODO: remove support for widgetEventPrefix
156
+ // always use the name + a colon as the prefix, e.g., draggable:start
157
+ // don't prefix for widgets that aren't DOM-based
158
+ widgetEventPrefix: existingConstructor ? ( basePrototype.widgetEventPrefix || name ) : name
159
+ }, proxiedPrototype, {
160
+ constructor: constructor,
161
+ namespace: namespace,
162
+ widgetName: name,
163
+ widgetFullName: fullName
164
+ } );
165
+
166
+ // If this widget is being redefined then we need to find all widgets that
167
+ // are inheriting from it and redefine all of them so that they inherit from
168
+ // the new version of this widget. We're essentially trying to replace one
169
+ // level in the prototype chain.
170
+ if ( existingConstructor ) {
171
+ $.each( existingConstructor._childConstructors, function( i, child ) {
172
+ var childPrototype = child.prototype;
173
+
174
+ // Redefine the child widget using the same prototype that was
175
+ // originally used, but inherit from the new version of the base
176
+ $.widget( childPrototype.namespace + "." + childPrototype.widgetName, constructor,
177
+ child._proto );
178
+ } );
179
+
180
+ // Remove the list of existing child constructors from the old constructor
181
+ // so the old child constructors can be garbage collected
182
+ delete existingConstructor._childConstructors;
183
+ } else {
184
+ base._childConstructors.push( constructor );
185
+ }
186
+
187
+ $.widget.bridge( name, constructor );
188
+
189
+ return constructor;
190
+ };
191
+
192
+ $.widget.extend = function( target ) {
193
+ var input = widgetSlice.call( arguments, 1 );
194
+ var inputIndex = 0;
195
+ var inputLength = input.length;
196
+ var key;
197
+ var value;
198
+
199
+ for ( ; inputIndex < inputLength; inputIndex++ ) {
200
+ for ( key in input[ inputIndex ] ) {
201
+ value = input[ inputIndex ][ key ];
202
+ if ( input[ inputIndex ].hasOwnProperty( key ) && value !== undefined ) {
203
+
204
+ // Clone objects
205
+ if ( $.isPlainObject( value ) ) {
206
+ target[ key ] = $.isPlainObject( target[ key ] ) ?
207
+ $.widget.extend( {}, target[ key ], value ) :
208
+
209
+ // Don't extend strings, arrays, etc. with objects
210
+ $.widget.extend( {}, value );
211
+
212
+ // Copy everything else by reference
213
+ } else {
214
+ target[ key ] = value;
215
+ }
216
+ }
217
+ }
218
+ }
219
+ return target;
220
+ };
221
+
222
+ $.widget.bridge = function( name, object ) {
223
+ var fullName = object.prototype.widgetFullName || name;
224
+ $.fn[ name ] = function( options ) {
225
+ var isMethodCall = typeof options === "string";
226
+ var args = widgetSlice.call( arguments, 1 );
227
+ var returnValue = this;
228
+
229
+ if ( isMethodCall ) {
230
+
231
+ // If this is an empty collection, we need to have the instance method
232
+ // return undefined instead of the jQuery instance
233
+ if ( !this.length && options === "instance" ) {
234
+ returnValue = undefined;
235
+ } else {
236
+ this.each( function() {
237
+ var methodValue;
238
+ var instance = $.data( this, fullName );
239
+
240
+ if ( options === "instance" ) {
241
+ returnValue = instance;
242
+ return false;
243
+ }
244
+
245
+ if ( !instance ) {
246
+ return $.error( "cannot call methods on " + name +
247
+ " prior to initialization; " +
248
+ "attempted to call method '" + options + "'" );
249
+ }
250
+
251
+ if ( !$.isFunction( instance[ options ] ) || options.charAt( 0 ) === "_" ) {
252
+ return $.error( "no such method '" + options + "' for " + name +
253
+ " widget instance" );
254
+ }
255
+
256
+ methodValue = instance[ options ].apply( instance, args );
257
+
258
+ if ( methodValue !== instance && methodValue !== undefined ) {
259
+ returnValue = methodValue && methodValue.jquery ?
260
+ returnValue.pushStack( methodValue.get() ) :
261
+ methodValue;
262
+ return false;
263
+ }
264
+ } );
265
+ }
266
+ } else {
267
+
268
+ // Allow multiple hashes to be passed on init
269
+ if ( args.length ) {
270
+ options = $.widget.extend.apply( null, [ options ].concat( args ) );
271
+ }
272
+
273
+ this.each( function() {
274
+ var instance = $.data( this, fullName );
275
+ if ( instance ) {
276
+ instance.option( options || {} );
277
+ if ( instance._init ) {
278
+ instance._init();
279
+ }
280
+ } else {
281
+ $.data( this, fullName, new object( options, this ) );
282
+ }
283
+ } );
284
+ }
285
+
286
+ return returnValue;
287
+ };
288
+ };
289
+
290
+ $.Widget = function( /* options, element */ ) {};
291
+ $.Widget._childConstructors = [];
292
+
293
+ $.Widget.prototype = {
294
+ widgetName: "widget",
295
+ widgetEventPrefix: "",
296
+ defaultElement: "<div>",
297
+
298
+ options: {
299
+ classes: {},
300
+ disabled: false,
301
+
302
+ // Callbacks
303
+ create: null
304
+ },
305
+
306
+ _createWidget: function( options, element ) {
307
+ element = $( element || this.defaultElement || this )[ 0 ];
308
+ this.element = $( element );
309
+ this.uuid = widgetUuid++;
310
+ this.eventNamespace = "." + this.widgetName + this.uuid;
311
+
312
+ this.bindings = $();
313
+ this.hoverable = $();
314
+ this.focusable = $();
315
+ this.classesElementLookup = {};
316
+
317
+ if ( element !== this ) {
318
+ $.data( element, this.widgetFullName, this );
319
+ this._on( true, this.element, {
320
+ remove: function( event ) {
321
+ if ( event.target === element ) {
322
+ this.destroy();
323
+ }
324
+ }
325
+ } );
326
+ this.document = $( element.style ?
327
+
328
+ // Element within the document
329
+ element.ownerDocument :
330
+
331
+ // Element is window or document
332
+ element.document || element );
333
+ this.window = $( this.document[ 0 ].defaultView || this.document[ 0 ].parentWindow );
334
+ }
335
+
336
+ this.options = $.widget.extend( {},
337
+ this.options,
338
+ this._getCreateOptions(),
339
+ options );
340
+
341
+ this._create();
342
+
343
+ if ( this.options.disabled ) {
344
+ this._setOptionDisabled( this.options.disabled );
345
+ }
346
+
347
+ this._trigger( "create", null, this._getCreateEventData() );
348
+ this._init();
349
+ },
350
+
351
+ _getCreateOptions: function() {
352
+ return {};
353
+ },
354
+
355
+ _getCreateEventData: $.noop,
356
+
357
+ _create: $.noop,
358
+
359
+ _init: $.noop,
360
+
361
+ destroy: function() {
362
+ var that = this;
363
+
364
+ this._destroy();
365
+ $.each( this.classesElementLookup, function( key, value ) {
366
+ that._removeClass( value, key );
367
+ } );
368
+
369
+ // We can probably remove the unbind calls in 2.0
370
+ // all event bindings should go through this._on()
371
+ this.element
372
+ .off( this.eventNamespace )
373
+ .removeData( this.widgetFullName );
374
+ this.widget()
375
+ .off( this.eventNamespace )
376
+ .removeAttr( "aria-disabled" );
377
+
378
+ // Clean up events and states
379
+ this.bindings.off( this.eventNamespace );
380
+ },
381
+
382
+ _destroy: $.noop,
383
+
384
+ widget: function() {
385
+ return this.element;
386
+ },
387
+
388
+ option: function( key, value ) {
389
+ var options = key;
390
+ var parts;
391
+ var curOption;
392
+ var i;
393
+
394
+ if ( arguments.length === 0 ) {
395
+
396
+ // Don't return a reference to the internal hash
397
+ return $.widget.extend( {}, this.options );
398
+ }
399
+
400
+ if ( typeof key === "string" ) {
401
+
402
+ // Handle nested keys, e.g., "foo.bar" => { foo: { bar: ___ } }
403
+ options = {};
404
+ parts = key.split( "." );
405
+ key = parts.shift();
406
+ if ( parts.length ) {
407
+ curOption = options[ key ] = $.widget.extend( {}, this.options[ key ] );
408
+ for ( i = 0; i < parts.length - 1; i++ ) {
409
+ curOption[ parts[ i ] ] = curOption[ parts[ i ] ] || {};
410
+ curOption = curOption[ parts[ i ] ];
411
+ }
412
+ key = parts.pop();
413
+ if ( arguments.length === 1 ) {
414
+ return curOption[ key ] === undefined ? null : curOption[ key ];
415
+ }
416
+ curOption[ key ] = value;
417
+ } else {
418
+ if ( arguments.length === 1 ) {
419
+ return this.options[ key ] === undefined ? null : this.options[ key ];
420
+ }
421
+ options[ key ] = value;
422
+ }
423
+ }
424
+
425
+ this._setOptions( options );
426
+
427
+ return this;
428
+ },
429
+
430
+ _setOptions: function( options ) {
431
+ var key;
432
+
433
+ for ( key in options ) {
434
+ this._setOption( key, options[ key ] );
435
+ }
436
+
437
+ return this;
438
+ },
439
+
440
+ _setOption: function( key, value ) {
441
+ if ( key === "classes" ) {
442
+ this._setOptionClasses( value );
443
+ }
444
+
445
+ this.options[ key ] = value;
446
+
447
+ if ( key === "disabled" ) {
448
+ this._setOptionDisabled( value );
449
+ }
450
+
451
+ return this;
452
+ },
453
+
454
+ _setOptionClasses: function( value ) {
455
+ var classKey, elements, currentElements;
456
+
457
+ for ( classKey in value ) {
458
+ currentElements = this.classesElementLookup[ classKey ];
459
+ if ( value[ classKey ] === this.options.classes[ classKey ] ||
460
+ !currentElements ||
461
+ !currentElements.length ) {
462
+ continue;
463
+ }
464
+
465
+ // We are doing this to create a new jQuery object because the _removeClass() call
466
+ // on the next line is going to destroy the reference to the current elements being
467
+ // tracked. We need to save a copy of this collection so that we can add the new classes
468
+ // below.
469
+ elements = $( currentElements.get() );
470
+ this._removeClass( currentElements, classKey );
471
+
472
+ // We don't use _addClass() here, because that uses this.options.classes
473
+ // for generating the string of classes. We want to use the value passed in from
474
+ // _setOption(), this is the new value of the classes option which was passed to
475
+ // _setOption(). We pass this value directly to _classes().
476
+ elements.addClass( this._classes( {
477
+ element: elements,
478
+ keys: classKey,
479
+ classes: value,
480
+ add: true
481
+ } ) );
482
+ }
483
+ },
484
+
485
+ _setOptionDisabled: function( value ) {
486
+ this._toggleClass( this.widget(), this.widgetFullName + "-disabled", null, !!value );
487
+
488
+ // If the widget is becoming disabled, then nothing is interactive
489
+ if ( value ) {
490
+ this._removeClass( this.hoverable, null, "ui-state-hover" );
491
+ this._removeClass( this.focusable, null, "ui-state-focus" );
492
+ }
493
+ },
494
+
495
+ enable: function() {
496
+ return this._setOptions( { disabled: false } );
497
+ },
498
+
499
+ disable: function() {
500
+ return this._setOptions( { disabled: true } );
501
+ },
502
+
503
+ _classes: function( options ) {
504
+ var full = [];
505
+ var that = this;
506
+
507
+ options = $.extend( {
508
+ element: this.element,
509
+ classes: this.options.classes || {}
510
+ }, options );
511
+
512
+ function processClassString( classes, checkOption ) {
513
+ var current, i;
514
+ for ( i = 0; i < classes.length; i++ ) {
515
+ current = that.classesElementLookup[ classes[ i ] ] || $();
516
+ if ( options.add ) {
517
+ current = $( $.unique( current.get().concat( options.element.get() ) ) );
518
+ } else {
519
+ current = $( current.not( options.element ).get() );
520
+ }
521
+ that.classesElementLookup[ classes[ i ] ] = current;
522
+ full.push( classes[ i ] );
523
+ if ( checkOption && options.classes[ classes[ i ] ] ) {
524
+ full.push( options.classes[ classes[ i ] ] );
525
+ }
526
+ }
527
+ }
528
+
529
+ this._on( options.element, {
530
+ "remove": "_untrackClassesElement"
531
+ } );
532
+
533
+ if ( options.keys ) {
534
+ processClassString( options.keys.match( /\S+/g ) || [], true );
535
+ }
536
+ if ( options.extra ) {
537
+ processClassString( options.extra.match( /\S+/g ) || [] );
538
+ }
539
+
540
+ return full.join( " " );
541
+ },
542
+
543
+ _untrackClassesElement: function( event ) {
544
+ var that = this;
545
+ $.each( that.classesElementLookup, function( key, value ) {
546
+ if ( $.inArray( event.target, value ) !== -1 ) {
547
+ that.classesElementLookup[ key ] = $( value.not( event.target ).get() );
548
+ }
549
+ } );
550
+ },
551
+
552
+ _removeClass: function( element, keys, extra ) {
553
+ return this._toggleClass( element, keys, extra, false );
554
+ },
555
+
556
+ _addClass: function( element, keys, extra ) {
557
+ return this._toggleClass( element, keys, extra, true );
558
+ },
559
+
560
+ _toggleClass: function( element, keys, extra, add ) {
561
+ add = ( typeof add === "boolean" ) ? add : extra;
562
+ var shift = ( typeof element === "string" || element === null ),
563
+ options = {
564
+ extra: shift ? keys : extra,
565
+ keys: shift ? element : keys,
566
+ element: shift ? this.element : element,
567
+ add: add
568
+ };
569
+ options.element.toggleClass( this._classes( options ), add );
570
+ return this;
571
+ },
572
+
573
+ _on: function( suppressDisabledCheck, element, handlers ) {
574
+ var delegateElement;
575
+ var instance = this;
576
+
577
+ // No suppressDisabledCheck flag, shuffle arguments
578
+ if ( typeof suppressDisabledCheck !== "boolean" ) {
579
+ handlers = element;
580
+ element = suppressDisabledCheck;
581
+ suppressDisabledCheck = false;
582
+ }
583
+
584
+ // No element argument, shuffle and use this.element
585
+ if ( !handlers ) {
586
+ handlers = element;
587
+ element = this.element;
588
+ delegateElement = this.widget();
589
+ } else {
590
+ element = delegateElement = $( element );
591
+ this.bindings = this.bindings.add( element );
592
+ }
593
+
594
+ $.each( handlers, function( event, handler ) {
595
+ function handlerProxy() {
596
+
597
+ // Allow widgets to customize the disabled handling
598
+ // - disabled as an array instead of boolean
599
+ // - disabled class as method for disabling individual parts
600
+ if ( !suppressDisabledCheck &&
601
+ ( instance.options.disabled === true ||
602
+ $( this ).hasClass( "ui-state-disabled" ) ) ) {
603
+ return;
604
+ }
605
+ return ( typeof handler === "string" ? instance[ handler ] : handler )
606
+ .apply( instance, arguments );
607
+ }
608
+
609
+ // Copy the guid so direct unbinding works
610
+ if ( typeof handler !== "string" ) {
611
+ handlerProxy.guid = handler.guid =
612
+ handler.guid || handlerProxy.guid || $.guid++;
613
+ }
614
+
615
+ var match = event.match( /^([\w:-]*)\s*(.*)$/ );
616
+ var eventName = match[ 1 ] + instance.eventNamespace;
617
+ var selector = match[ 2 ];
618
+
619
+ if ( selector ) {
620
+ delegateElement.on( eventName, selector, handlerProxy );
621
+ } else {
622
+ element.on( eventName, handlerProxy );
623
+ }
624
+ } );
625
+ },
626
+
627
+ _off: function( element, eventName ) {
628
+ eventName = ( eventName || "" ).split( " " ).join( this.eventNamespace + " " ) +
629
+ this.eventNamespace;
630
+ element.off( eventName ).off( eventName );
631
+
632
+ // Clear the stack to avoid memory leaks (#10056)
633
+ this.bindings = $( this.bindings.not( element ).get() );
634
+ this.focusable = $( this.focusable.not( element ).get() );
635
+ this.hoverable = $( this.hoverable.not( element ).get() );
636
+ },
637
+
638
+ _delay: function( handler, delay ) {
639
+ function handlerProxy() {
640
+ return ( typeof handler === "string" ? instance[ handler ] : handler )
641
+ .apply( instance, arguments );
642
+ }
643
+ var instance = this;
644
+ return setTimeout( handlerProxy, delay || 0 );
645
+ },
646
+
647
+ _hoverable: function( element ) {
648
+ this.hoverable = this.hoverable.add( element );
649
+ this._on( element, {
650
+ mouseenter: function( event ) {
651
+ this._addClass( $( event.currentTarget ), null, "ui-state-hover" );
652
+ },
653
+ mouseleave: function( event ) {
654
+ this._removeClass( $( event.currentTarget ), null, "ui-state-hover" );
655
+ }
656
+ } );
657
+ },
658
+
659
+ _focusable: function( element ) {
660
+ this.focusable = this.focusable.add( element );
661
+ this._on( element, {
662
+ focusin: function( event ) {
663
+ this._addClass( $( event.currentTarget ), null, "ui-state-focus" );
664
+ },
665
+ focusout: function( event ) {
666
+ this._removeClass( $( event.currentTarget ), null, "ui-state-focus" );
667
+ }
668
+ } );
669
+ },
670
+
671
+ _trigger: function( type, event, data ) {
672
+ var prop, orig;
673
+ var callback = this.options[ type ];
674
+
675
+ data = data || {};
676
+ event = $.Event( event );
677
+ event.type = ( type === this.widgetEventPrefix ?
678
+ type :
679
+ this.widgetEventPrefix + type ).toLowerCase();
680
+
681
+ // The original event may come from any element
682
+ // so we need to reset the target on the new event
683
+ event.target = this.element[ 0 ];
684
+
685
+ // Copy original event properties over to the new event
686
+ orig = event.originalEvent;
687
+ if ( orig ) {
688
+ for ( prop in orig ) {
689
+ if ( !( prop in event ) ) {
690
+ event[ prop ] = orig[ prop ];
691
+ }
692
+ }
693
+ }
694
+
695
+ this.element.trigger( event, data );
696
+ return !( $.isFunction( callback ) &&
697
+ callback.apply( this.element[ 0 ], [ event ].concat( data ) ) === false ||
698
+ event.isDefaultPrevented() );
699
+ }
700
+ };
701
+
702
+ $.each( { show: "fadeIn", hide: "fadeOut" }, function( method, defaultEffect ) {
703
+ $.Widget.prototype[ "_" + method ] = function( element, options, callback ) {
704
+ if ( typeof options === "string" ) {
705
+ options = { effect: options };
706
+ }
707
+
708
+ var hasOptions;
709
+ var effectName = !options ?
710
+ method :
711
+ options === true || typeof options === "number" ?
712
+ defaultEffect :
713
+ options.effect || defaultEffect;
714
+
715
+ options = options || {};
716
+ if ( typeof options === "number" ) {
717
+ options = { duration: options };
718
+ }
719
+
720
+ hasOptions = !$.isEmptyObject( options );
721
+ options.complete = callback;
722
+
723
+ if ( options.delay ) {
724
+ element.delay( options.delay );
725
+ }
726
+
727
+ if ( hasOptions && $.effects && $.effects.effect[ effectName ] ) {
728
+ element[ method ]( options );
729
+ } else if ( effectName !== method && element[ effectName ] ) {
730
+ element[ effectName ]( options.duration, options.easing, callback );
731
+ } else {
732
+ element.queue( function( next ) {
733
+ $( this )[ method ]();
734
+ if ( callback ) {
735
+ callback.call( element[ 0 ] );
736
+ }
737
+ next();
738
+ } );
739
+ }
740
+ };
741
+ } );
742
+
743
+ var widget = $.widget;
744
+
745
+
746
+ /*!
747
+ * jQuery UI Position 1.12.1
748
+ * http://jqueryui.com
749
+ *
750
+ * Copyright jQuery Foundation and other contributors
751
+ * Released under the MIT license.
752
+ * http://jquery.org/license
753
+ *
754
+ * http://api.jqueryui.com/position/
755
+ */
756
+
757
+ //>>label: Position
758
+ //>>group: Core
759
+ //>>description: Positions elements relative to other elements.
760
+ //>>docs: http://api.jqueryui.com/position/
761
+ //>>demos: http://jqueryui.com/position/
762
+
763
+
764
+ ( function() {
765
+ var cachedScrollbarWidth,
766
+ max = Math.max,
767
+ abs = Math.abs,
768
+ rhorizontal = /left|center|right/,
769
+ rvertical = /top|center|bottom/,
770
+ roffset = /[\+\-]\d+(\.[\d]+)?%?/,
771
+ rposition = /^\w+/,
772
+ rpercent = /%$/,
773
+ _position = $.fn.position;
774
+
775
+ function getOffsets( offsets, width, height ) {
776
+ return [
777
+ parseFloat( offsets[ 0 ] ) * ( rpercent.test( offsets[ 0 ] ) ? width / 100 : 1 ),
778
+ parseFloat( offsets[ 1 ] ) * ( rpercent.test( offsets[ 1 ] ) ? height / 100 : 1 )
779
+ ];
780
+ }
781
+
782
+ function parseCss( element, property ) {
783
+ return parseInt( $.css( element, property ), 10 ) || 0;
784
+ }
785
+
786
+ function getDimensions( elem ) {
787
+ var raw = elem[ 0 ];
788
+ if ( raw.nodeType === 9 ) {
789
+ return {
790
+ width: elem.width(),
791
+ height: elem.height(),
792
+ offset: { top: 0, left: 0 }
793
+ };
794
+ }
795
+ if ( $.isWindow( raw ) ) {
796
+ return {
797
+ width: elem.width(),
798
+ height: elem.height(),
799
+ offset: { top: elem.scrollTop(), left: elem.scrollLeft() }
800
+ };
801
+ }
802
+ if ( raw.preventDefault ) {
803
+ return {
804
+ width: 0,
805
+ height: 0,
806
+ offset: { top: raw.pageY, left: raw.pageX }
807
+ };
808
+ }
809
+ return {
810
+ width: elem.outerWidth(),
811
+ height: elem.outerHeight(),
812
+ offset: elem.offset()
813
+ };
814
+ }
815
+
816
+ $.position = {
817
+ scrollbarWidth: function() {
818
+ if ( cachedScrollbarWidth !== undefined ) {
819
+ return cachedScrollbarWidth;
820
+ }
821
+ var w1, w2,
822
+ div = $( "<div " +
823
+ "style='display:block;position:absolute;width:50px;height:50px;overflow:hidden;'>" +
824
+ "<div style='height:100px;width:auto;'></div></div>" ),
825
+ innerDiv = div.children()[ 0 ];
826
+
827
+ $( "body" ).append( div );
828
+ w1 = innerDiv.offsetWidth;
829
+ div.css( "overflow", "scroll" );
830
+
831
+ w2 = innerDiv.offsetWidth;
832
+
833
+ if ( w1 === w2 ) {
834
+ w2 = div[ 0 ].clientWidth;
835
+ }
836
+
837
+ div.remove();
838
+
839
+ return ( cachedScrollbarWidth = w1 - w2 );
840
+ },
841
+ getScrollInfo: function( within ) {
842
+ var overflowX = within.isWindow || within.isDocument ? "" :
843
+ within.element.css( "overflow-x" ),
844
+ overflowY = within.isWindow || within.isDocument ? "" :
845
+ within.element.css( "overflow-y" ),
846
+ hasOverflowX = overflowX === "scroll" ||
847
+ ( overflowX === "auto" && within.width < within.element[ 0 ].scrollWidth ),
848
+ hasOverflowY = overflowY === "scroll" ||
849
+ ( overflowY === "auto" && within.height < within.element[ 0 ].scrollHeight );
850
+ return {
851
+ width: hasOverflowY ? $.position.scrollbarWidth() : 0,
852
+ height: hasOverflowX ? $.position.scrollbarWidth() : 0
853
+ };
854
+ },
855
+ getWithinInfo: function( element ) {
856
+ var withinElement = $( element || window ),
857
+ isWindow = $.isWindow( withinElement[ 0 ] ),
858
+ isDocument = !!withinElement[ 0 ] && withinElement[ 0 ].nodeType === 9,
859
+ hasOffset = !isWindow && !isDocument;
860
+ return {
861
+ element: withinElement,
862
+ isWindow: isWindow,
863
+ isDocument: isDocument,
864
+ offset: hasOffset ? $( element ).offset() : { left: 0, top: 0 },
865
+ scrollLeft: withinElement.scrollLeft(),
866
+ scrollTop: withinElement.scrollTop(),
867
+ width: withinElement.outerWidth(),
868
+ height: withinElement.outerHeight()
869
+ };
870
+ }
871
+ };
872
+
873
+ $.fn.position = function( options ) {
874
+ if ( !options || !options.of ) {
875
+ return _position.apply( this, arguments );
876
+ }
877
+
878
+ // Make a copy, we don't want to modify arguments
879
+ options = $.extend( {}, options );
880
+
881
+ var atOffset, targetWidth, targetHeight, targetOffset, basePosition, dimensions,
882
+ target = $( options.of ),
883
+ within = $.position.getWithinInfo( options.within ),
884
+ scrollInfo = $.position.getScrollInfo( within ),
885
+ collision = ( options.collision || "flip" ).split( " " ),
886
+ offsets = {};
887
+
888
+ dimensions = getDimensions( target );
889
+ if ( target[ 0 ].preventDefault ) {
890
+
891
+ // Force left top to allow flipping
892
+ options.at = "left top";
893
+ }
894
+ targetWidth = dimensions.width;
895
+ targetHeight = dimensions.height;
896
+ targetOffset = dimensions.offset;
897
+
898
+ // Clone to reuse original targetOffset later
899
+ basePosition = $.extend( {}, targetOffset );
900
+
901
+ // Force my and at to have valid horizontal and vertical positions
902
+ // if a value is missing or invalid, it will be converted to center
903
+ $.each( [ "my", "at" ], function() {
904
+ var pos = ( options[ this ] || "" ).split( " " ),
905
+ horizontalOffset,
906
+ verticalOffset;
907
+
908
+ if ( pos.length === 1 ) {
909
+ pos = rhorizontal.test( pos[ 0 ] ) ?
910
+ pos.concat( [ "center" ] ) :
911
+ rvertical.test( pos[ 0 ] ) ?
912
+ [ "center" ].concat( pos ) :
913
+ [ "center", "center" ];
914
+ }
915
+ pos[ 0 ] = rhorizontal.test( pos[ 0 ] ) ? pos[ 0 ] : "center";
916
+ pos[ 1 ] = rvertical.test( pos[ 1 ] ) ? pos[ 1 ] : "center";
917
+
918
+ // Calculate offsets
919
+ horizontalOffset = roffset.exec( pos[ 0 ] );
920
+ verticalOffset = roffset.exec( pos[ 1 ] );
921
+ offsets[ this ] = [
922
+ horizontalOffset ? horizontalOffset[ 0 ] : 0,
923
+ verticalOffset ? verticalOffset[ 0 ] : 0
924
+ ];
925
+
926
+ // Reduce to just the positions without the offsets
927
+ options[ this ] = [
928
+ rposition.exec( pos[ 0 ] )[ 0 ],
929
+ rposition.exec( pos[ 1 ] )[ 0 ]
930
+ ];
931
+ } );
932
+
933
+ // Normalize collision option
934
+ if ( collision.length === 1 ) {
935
+ collision[ 1 ] = collision[ 0 ];
936
+ }
937
+
938
+ if ( options.at[ 0 ] === "right" ) {
939
+ basePosition.left += targetWidth;
940
+ } else if ( options.at[ 0 ] === "center" ) {
941
+ basePosition.left += targetWidth / 2;
942
+ }
943
+
944
+ if ( options.at[ 1 ] === "bottom" ) {
945
+ basePosition.top += targetHeight;
946
+ } else if ( options.at[ 1 ] === "center" ) {
947
+ basePosition.top += targetHeight / 2;
948
+ }
949
+
950
+ atOffset = getOffsets( offsets.at, targetWidth, targetHeight );
951
+ basePosition.left += atOffset[ 0 ];
952
+ basePosition.top += atOffset[ 1 ];
953
+
954
+ return this.each( function() {
955
+ var collisionPosition, using,
956
+ elem = $( this ),
957
+ elemWidth = elem.outerWidth(),
958
+ elemHeight = elem.outerHeight(),
959
+ marginLeft = parseCss( this, "marginLeft" ),
960
+ marginTop = parseCss( this, "marginTop" ),
961
+ collisionWidth = elemWidth + marginLeft + parseCss( this, "marginRight" ) +
962
+ scrollInfo.width,
963
+ collisionHeight = elemHeight + marginTop + parseCss( this, "marginBottom" ) +
964
+ scrollInfo.height,
965
+ position = $.extend( {}, basePosition ),
966
+ myOffset = getOffsets( offsets.my, elem.outerWidth(), elem.outerHeight() );
967
+
968
+ if ( options.my[ 0 ] === "right" ) {
969
+ position.left -= elemWidth;
970
+ } else if ( options.my[ 0 ] === "center" ) {
971
+ position.left -= elemWidth / 2;
972
+ }
973
+
974
+ if ( options.my[ 1 ] === "bottom" ) {
975
+ position.top -= elemHeight;
976
+ } else if ( options.my[ 1 ] === "center" ) {
977
+ position.top -= elemHeight / 2;
978
+ }
979
+
980
+ position.left += myOffset[ 0 ];
981
+ position.top += myOffset[ 1 ];
982
+
983
+ collisionPosition = {
984
+ marginLeft: marginLeft,
985
+ marginTop: marginTop
986
+ };
987
+
988
+ $.each( [ "left", "top" ], function( i, dir ) {
989
+ if ( $.ui.position[ collision[ i ] ] ) {
990
+ $.ui.position[ collision[ i ] ][ dir ]( position, {
991
+ targetWidth: targetWidth,
992
+ targetHeight: targetHeight,
993
+ elemWidth: elemWidth,
994
+ elemHeight: elemHeight,
995
+ collisionPosition: collisionPosition,
996
+ collisionWidth: collisionWidth,
997
+ collisionHeight: collisionHeight,
998
+ offset: [ atOffset[ 0 ] + myOffset[ 0 ], atOffset [ 1 ] + myOffset[ 1 ] ],
999
+ my: options.my,
1000
+ at: options.at,
1001
+ within: within,
1002
+ elem: elem
1003
+ } );
1004
+ }
1005
+ } );
1006
+
1007
+ if ( options.using ) {
1008
+
1009
+ // Adds feedback as second argument to using callback, if present
1010
+ using = function( props ) {
1011
+ var left = targetOffset.left - position.left,
1012
+ right = left + targetWidth - elemWidth,
1013
+ top = targetOffset.top - position.top,
1014
+ bottom = top + targetHeight - elemHeight,
1015
+ feedback = {
1016
+ target: {
1017
+ element: target,
1018
+ left: targetOffset.left,
1019
+ top: targetOffset.top,
1020
+ width: targetWidth,
1021
+ height: targetHeight
1022
+ },
1023
+ element: {
1024
+ element: elem,
1025
+ left: position.left,
1026
+ top: position.top,
1027
+ width: elemWidth,
1028
+ height: elemHeight
1029
+ },
1030
+ horizontal: right < 0 ? "left" : left > 0 ? "right" : "center",
1031
+ vertical: bottom < 0 ? "top" : top > 0 ? "bottom" : "middle"
1032
+ };
1033
+ if ( targetWidth < elemWidth && abs( left + right ) < targetWidth ) {
1034
+ feedback.horizontal = "center";
1035
+ }
1036
+ if ( targetHeight < elemHeight && abs( top + bottom ) < targetHeight ) {
1037
+ feedback.vertical = "middle";
1038
+ }
1039
+ if ( max( abs( left ), abs( right ) ) > max( abs( top ), abs( bottom ) ) ) {
1040
+ feedback.important = "horizontal";
1041
+ } else {
1042
+ feedback.important = "vertical";
1043
+ }
1044
+ options.using.call( this, props, feedback );
1045
+ };
1046
+ }
1047
+
1048
+ elem.offset( $.extend( position, { using: using } ) );
1049
+ } );
1050
+ };
1051
+
1052
+ $.ui.position = {
1053
+ fit: {
1054
+ left: function( position, data ) {
1055
+ var within = data.within,
1056
+ withinOffset = within.isWindow ? within.scrollLeft : within.offset.left,
1057
+ outerWidth = within.width,
1058
+ collisionPosLeft = position.left - data.collisionPosition.marginLeft,
1059
+ overLeft = withinOffset - collisionPosLeft,
1060
+ overRight = collisionPosLeft + data.collisionWidth - outerWidth - withinOffset,
1061
+ newOverRight;
1062
+
1063
+ // Element is wider than within
1064
+ if ( data.collisionWidth > outerWidth ) {
1065
+
1066
+ // Element is initially over the left side of within
1067
+ if ( overLeft > 0 && overRight <= 0 ) {
1068
+ newOverRight = position.left + overLeft + data.collisionWidth - outerWidth -
1069
+ withinOffset;
1070
+ position.left += overLeft - newOverRight;
1071
+
1072
+ // Element is initially over right side of within
1073
+ } else if ( overRight > 0 && overLeft <= 0 ) {
1074
+ position.left = withinOffset;
1075
+
1076
+ // Element is initially over both left and right sides of within
1077
+ } else {
1078
+ if ( overLeft > overRight ) {
1079
+ position.left = withinOffset + outerWidth - data.collisionWidth;
1080
+ } else {
1081
+ position.left = withinOffset;
1082
+ }
1083
+ }
1084
+
1085
+ // Too far left -> align with left edge
1086
+ } else if ( overLeft > 0 ) {
1087
+ position.left += overLeft;
1088
+
1089
+ // Too far right -> align with right edge
1090
+ } else if ( overRight > 0 ) {
1091
+ position.left -= overRight;
1092
+
1093
+ // Adjust based on position and margin
1094
+ } else {
1095
+ position.left = max( position.left - collisionPosLeft, position.left );
1096
+ }
1097
+ },
1098
+ top: function( position, data ) {
1099
+ var within = data.within,
1100
+ withinOffset = within.isWindow ? within.scrollTop : within.offset.top,
1101
+ outerHeight = data.within.height,
1102
+ collisionPosTop = position.top - data.collisionPosition.marginTop,
1103
+ overTop = withinOffset - collisionPosTop,
1104
+ overBottom = collisionPosTop + data.collisionHeight - outerHeight - withinOffset,
1105
+ newOverBottom;
1106
+
1107
+ // Element is taller than within
1108
+ if ( data.collisionHeight > outerHeight ) {
1109
+
1110
+ // Element is initially over the top of within
1111
+ if ( overTop > 0 && overBottom <= 0 ) {
1112
+ newOverBottom = position.top + overTop + data.collisionHeight - outerHeight -
1113
+ withinOffset;
1114
+ position.top += overTop - newOverBottom;
1115
+
1116
+ // Element is initially over bottom of within
1117
+ } else if ( overBottom > 0 && overTop <= 0 ) {
1118
+ position.top = withinOffset;
1119
+
1120
+ // Element is initially over both top and bottom of within
1121
+ } else {
1122
+ if ( overTop > overBottom ) {
1123
+ position.top = withinOffset + outerHeight - data.collisionHeight;
1124
+ } else {
1125
+ position.top = withinOffset;
1126
+ }
1127
+ }
1128
+
1129
+ // Too far up -> align with top
1130
+ } else if ( overTop > 0 ) {
1131
+ position.top += overTop;
1132
+
1133
+ // Too far down -> align with bottom edge
1134
+ } else if ( overBottom > 0 ) {
1135
+ position.top -= overBottom;
1136
+
1137
+ // Adjust based on position and margin
1138
+ } else {
1139
+ position.top = max( position.top - collisionPosTop, position.top );
1140
+ }
1141
+ }
1142
+ },
1143
+ flip: {
1144
+ left: function( position, data ) {
1145
+ var within = data.within,
1146
+ withinOffset = within.offset.left + within.scrollLeft,
1147
+ outerWidth = within.width,
1148
+ offsetLeft = within.isWindow ? within.scrollLeft : within.offset.left,
1149
+ collisionPosLeft = position.left - data.collisionPosition.marginLeft,
1150
+ overLeft = collisionPosLeft - offsetLeft,
1151
+ overRight = collisionPosLeft + data.collisionWidth - outerWidth - offsetLeft,
1152
+ myOffset = data.my[ 0 ] === "left" ?
1153
+ -data.elemWidth :
1154
+ data.my[ 0 ] === "right" ?
1155
+ data.elemWidth :
1156
+ 0,
1157
+ atOffset = data.at[ 0 ] === "left" ?
1158
+ data.targetWidth :
1159
+ data.at[ 0 ] === "right" ?
1160
+ -data.targetWidth :
1161
+ 0,
1162
+ offset = -2 * data.offset[ 0 ],
1163
+ newOverRight,
1164
+ newOverLeft;
1165
+
1166
+ if ( overLeft < 0 ) {
1167
+ newOverRight = position.left + myOffset + atOffset + offset + data.collisionWidth -
1168
+ outerWidth - withinOffset;
1169
+ if ( newOverRight < 0 || newOverRight < abs( overLeft ) ) {
1170
+ position.left += myOffset + atOffset + offset;
1171
+ }
1172
+ } else if ( overRight > 0 ) {
1173
+ newOverLeft = position.left - data.collisionPosition.marginLeft + myOffset +
1174
+ atOffset + offset - offsetLeft;
1175
+ if ( newOverLeft > 0 || abs( newOverLeft ) < overRight ) {
1176
+ position.left += myOffset + atOffset + offset;
1177
+ }
1178
+ }
1179
+ },
1180
+ top: function( position, data ) {
1181
+ var within = data.within,
1182
+ withinOffset = within.offset.top + within.scrollTop,
1183
+ outerHeight = within.height,
1184
+ offsetTop = within.isWindow ? within.scrollTop : within.offset.top,
1185
+ collisionPosTop = position.top - data.collisionPosition.marginTop,
1186
+ overTop = collisionPosTop - offsetTop,
1187
+ overBottom = collisionPosTop + data.collisionHeight - outerHeight - offsetTop,
1188
+ top = data.my[ 1 ] === "top",
1189
+ myOffset = top ?
1190
+ -data.elemHeight :
1191
+ data.my[ 1 ] === "bottom" ?
1192
+ data.elemHeight :
1193
+ 0,
1194
+ atOffset = data.at[ 1 ] === "top" ?
1195
+ data.targetHeight :
1196
+ data.at[ 1 ] === "bottom" ?
1197
+ -data.targetHeight :
1198
+ 0,
1199
+ offset = -2 * data.offset[ 1 ],
1200
+ newOverTop,
1201
+ newOverBottom;
1202
+ if ( overTop < 0 ) {
1203
+ newOverBottom = position.top + myOffset + atOffset + offset + data.collisionHeight -
1204
+ outerHeight - withinOffset;
1205
+ if ( newOverBottom < 0 || newOverBottom < abs( overTop ) ) {
1206
+ position.top += myOffset + atOffset + offset;
1207
+ }
1208
+ } else if ( overBottom > 0 ) {
1209
+ newOverTop = position.top - data.collisionPosition.marginTop + myOffset + atOffset +
1210
+ offset - offsetTop;
1211
+ if ( newOverTop > 0 || abs( newOverTop ) < overBottom ) {
1212
+ position.top += myOffset + atOffset + offset;
1213
+ }
1214
+ }
1215
+ }
1216
+ },
1217
+ flipfit: {
1218
+ left: function() {
1219
+ $.ui.position.flip.left.apply( this, arguments );
1220
+ $.ui.position.fit.left.apply( this, arguments );
1221
+ },
1222
+ top: function() {
1223
+ $.ui.position.flip.top.apply( this, arguments );
1224
+ $.ui.position.fit.top.apply( this, arguments );
1225
+ }
1226
+ }
1227
+ };
1228
+
1229
+ } )();
1230
+
1231
+ var position = $.ui.position;
1232
+
1233
+
1234
+ /*!
1235
+ * jQuery UI :data 1.12.1
1236
+ * http://jqueryui.com
1237
+ *
1238
+ * Copyright jQuery Foundation and other contributors
1239
+ * Released under the MIT license.
1240
+ * http://jquery.org/license
1241
+ */
1242
+
1243
+ //>>label: :data Selector
1244
+ //>>group: Core
1245
+ //>>description: Selects elements which have data stored under the specified key.
1246
+ //>>docs: http://api.jqueryui.com/data-selector/
1247
+
1248
+
1249
+ var data = $.extend( $.expr[ ":" ], {
1250
+ data: $.expr.createPseudo ?
1251
+ $.expr.createPseudo( function( dataName ) {
1252
+ return function( elem ) {
1253
+ return !!$.data( elem, dataName );
1254
+ };
1255
+ } ) :
1256
+
1257
+ // Support: jQuery <1.8
1258
+ function( elem, i, match ) {
1259
+ return !!$.data( elem, match[ 3 ] );
1260
+ }
1261
+ } );
1262
+
1263
+ /*!
1264
+ * jQuery UI Disable Selection 1.12.1
1265
+ * http://jqueryui.com
1266
+ *
1267
+ * Copyright jQuery Foundation and other contributors
1268
+ * Released under the MIT license.
1269
+ * http://jquery.org/license
1270
+ */
1271
+
1272
+ //>>label: disableSelection
1273
+ //>>group: Core
1274
+ //>>description: Disable selection of text content within the set of matched elements.
1275
+ //>>docs: http://api.jqueryui.com/disableSelection/
1276
+
1277
+ // This file is deprecated
1278
+
1279
+
1280
+ var disableSelection = $.fn.extend( {
1281
+ disableSelection: ( function() {
1282
+ var eventType = "onselectstart" in document.createElement( "div" ) ?
1283
+ "selectstart" :
1284
+ "mousedown";
1285
+
1286
+ return function() {
1287
+ return this.on( eventType + ".ui-disableSelection", function( event ) {
1288
+ event.preventDefault();
1289
+ } );
1290
+ };
1291
+ } )(),
1292
+
1293
+ enableSelection: function() {
1294
+ return this.off( ".ui-disableSelection" );
1295
+ }
1296
+ } );
1297
+
1298
+
1299
+ /*!
1300
+ * jQuery UI Focusable 1.12.1
1301
+ * http://jqueryui.com
1302
+ *
1303
+ * Copyright jQuery Foundation and other contributors
1304
+ * Released under the MIT license.
1305
+ * http://jquery.org/license
1306
+ */
1307
+
1308
+ //>>label: :focusable Selector
1309
+ //>>group: Core
1310
+ //>>description: Selects elements which can be focused.
1311
+ //>>docs: http://api.jqueryui.com/focusable-selector/
1312
+
1313
+
1314
+
1315
+ // Selectors
1316
+ $.ui.focusable = function( element, hasTabindex ) {
1317
+ var map, mapName, img, focusableIfVisible, fieldset,
1318
+ nodeName = element.nodeName.toLowerCase();
1319
+
1320
+ if ( "area" === nodeName ) {
1321
+ map = element.parentNode;
1322
+ mapName = map.name;
1323
+ if ( !element.href || !mapName || map.nodeName.toLowerCase() !== "map" ) {
1324
+ return false;
1325
+ }
1326
+ img = $( "img[usemap='#" + mapName + "']" );
1327
+ return img.length > 0 && img.is( ":visible" );
1328
+ }
1329
+
1330
+ if ( /^(input|select|textarea|button|object)$/.test( nodeName ) ) {
1331
+ focusableIfVisible = !element.disabled;
1332
+
1333
+ if ( focusableIfVisible ) {
1334
+
1335
+ // Form controls within a disabled fieldset are disabled.
1336
+ // However, controls within the fieldset's legend do not get disabled.
1337
+ // Since controls generally aren't placed inside legends, we skip
1338
+ // this portion of the check.
1339
+ fieldset = $( element ).closest( "fieldset" )[ 0 ];
1340
+ if ( fieldset ) {
1341
+ focusableIfVisible = !fieldset.disabled;
1342
+ }
1343
+ }
1344
+ } else if ( "a" === nodeName ) {
1345
+ focusableIfVisible = element.href || hasTabindex;
1346
+ } else {
1347
+ focusableIfVisible = hasTabindex;
1348
+ }
1349
+
1350
+ return focusableIfVisible && $( element ).is( ":visible" ) && visible( $( element ) );
1351
+ };
1352
+
1353
+ // Support: IE 8 only
1354
+ // IE 8 doesn't resolve inherit to visible/hidden for computed values
1355
+ function visible( element ) {
1356
+ var visibility = element.css( "visibility" );
1357
+ while ( visibility === "inherit" ) {
1358
+ element = element.parent();
1359
+ visibility = element.css( "visibility" );
1360
+ }
1361
+ return visibility !== "hidden";
1362
+ }
1363
+
1364
+ $.extend( $.expr[ ":" ], {
1365
+ focusable: function( element ) {
1366
+ return $.ui.focusable( element, $.attr( element, "tabindex" ) != null );
1367
+ }
1368
+ } );
1369
+
1370
+ var focusable = $.ui.focusable;
1371
+
1372
+
1373
+
1374
+
1375
+ // Support: IE8 Only
1376
+ // IE8 does not support the form attribute and when it is supplied. It overwrites the form prop
1377
+ // with a string, so we need to find the proper form.
1378
+ var form = $.fn.form = function() {
1379
+ return typeof this[ 0 ].form === "string" ? this.closest( "form" ) : $( this[ 0 ].form );
1380
+ };
1381
+
1382
+
1383
+ /*!
1384
+ * jQuery UI Form Reset Mixin 1.12.1
1385
+ * http://jqueryui.com
1386
+ *
1387
+ * Copyright jQuery Foundation and other contributors
1388
+ * Released under the MIT license.
1389
+ * http://jquery.org/license
1390
+ */
1391
+
1392
+ //>>label: Form Reset Mixin
1393
+ //>>group: Core
1394
+ //>>description: Refresh input widgets when their form is reset
1395
+ //>>docs: http://api.jqueryui.com/form-reset-mixin/
1396
+
1397
+
1398
+
1399
+ var formResetMixin = $.ui.formResetMixin = {
1400
+ _formResetHandler: function() {
1401
+ var form = $( this );
1402
+
1403
+ // Wait for the form reset to actually happen before refreshing
1404
+ setTimeout( function() {
1405
+ var instances = form.data( "ui-form-reset-instances" );
1406
+ $.each( instances, function() {
1407
+ this.refresh();
1408
+ } );
1409
+ } );
1410
+ },
1411
+
1412
+ _bindFormResetHandler: function() {
1413
+ this.form = this.element.form();
1414
+ if ( !this.form.length ) {
1415
+ return;
1416
+ }
1417
+
1418
+ var instances = this.form.data( "ui-form-reset-instances" ) || [];
1419
+ if ( !instances.length ) {
1420
+
1421
+ // We don't use _on() here because we use a single event handler per form
1422
+ this.form.on( "reset.ui-form-reset", this._formResetHandler );
1423
+ }
1424
+ instances.push( this );
1425
+ this.form.data( "ui-form-reset-instances", instances );
1426
+ },
1427
+
1428
+ _unbindFormResetHandler: function() {
1429
+ if ( !this.form.length ) {
1430
+ return;
1431
+ }
1432
+
1433
+ var instances = this.form.data( "ui-form-reset-instances" );
1434
+ instances.splice( $.inArray( this, instances ), 1 );
1435
+ if ( instances.length ) {
1436
+ this.form.data( "ui-form-reset-instances", instances );
1437
+ } else {
1438
+ this.form
1439
+ .removeData( "ui-form-reset-instances" )
1440
+ .off( "reset.ui-form-reset" );
1441
+ }
1442
+ }
1443
+ };
1444
+
1445
+
1446
+ /*!
1447
+ * jQuery UI Support for jQuery core 1.7.x 1.12.1
1448
+ * http://jqueryui.com
1449
+ *
1450
+ * Copyright jQuery Foundation and other contributors
1451
+ * Released under the MIT license.
1452
+ * http://jquery.org/license
1453
+ *
1454
+ */
1455
+
1456
+ //>>label: jQuery 1.7 Support
1457
+ //>>group: Core
1458
+ //>>description: Support version 1.7.x of jQuery core
1459
+
1460
+
1461
+
1462
+ // Support: jQuery 1.7 only
1463
+ // Not a great way to check versions, but since we only support 1.7+ and only
1464
+ // need to detect <1.8, this is a simple check that should suffice. Checking
1465
+ // for "1.7." would be a bit safer, but the version string is 1.7, not 1.7.0
1466
+ // and we'll never reach 1.70.0 (if we do, we certainly won't be supporting
1467
+ // 1.7 anymore). See #11197 for why we're not using feature detection.
1468
+ if ( $.fn.jquery.substring( 0, 3 ) === "1.7" ) {
1469
+
1470
+ // Setters for .innerWidth(), .innerHeight(), .outerWidth(), .outerHeight()
1471
+ // Unlike jQuery Core 1.8+, these only support numeric values to set the
1472
+ // dimensions in pixels
1473
+ $.each( [ "Width", "Height" ], function( i, name ) {
1474
+ var side = name === "Width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ],
1475
+ type = name.toLowerCase(),
1476
+ orig = {
1477
+ innerWidth: $.fn.innerWidth,
1478
+ innerHeight: $.fn.innerHeight,
1479
+ outerWidth: $.fn.outerWidth,
1480
+ outerHeight: $.fn.outerHeight
1481
+ };
1482
+
1483
+ function reduce( elem, size, border, margin ) {
1484
+ $.each( side, function() {
1485
+ size -= parseFloat( $.css( elem, "padding" + this ) ) || 0;
1486
+ if ( border ) {
1487
+ size -= parseFloat( $.css( elem, "border" + this + "Width" ) ) || 0;
1488
+ }
1489
+ if ( margin ) {
1490
+ size -= parseFloat( $.css( elem, "margin" + this ) ) || 0;
1491
+ }
1492
+ } );
1493
+ return size;
1494
+ }
1495
+
1496
+ $.fn[ "inner" + name ] = function( size ) {
1497
+ if ( size === undefined ) {
1498
+ return orig[ "inner" + name ].call( this );
1499
+ }
1500
+
1501
+ return this.each( function() {
1502
+ $( this ).css( type, reduce( this, size ) + "px" );
1503
+ } );
1504
+ };
1505
+
1506
+ $.fn[ "outer" + name ] = function( size, margin ) {
1507
+ if ( typeof size !== "number" ) {
1508
+ return orig[ "outer" + name ].call( this, size );
1509
+ }
1510
+
1511
+ return this.each( function() {
1512
+ $( this ).css( type, reduce( this, size, true, margin ) + "px" );
1513
+ } );
1514
+ };
1515
+ } );
1516
+
1517
+ $.fn.addBack = function( selector ) {
1518
+ return this.add( selector == null ?
1519
+ this.prevObject : this.prevObject.filter( selector )
1520
+ );
1521
+ };
1522
+ }
1523
+
1524
+ ;
1525
+ /*!
1526
+ * jQuery UI Keycode 1.12.1
1527
+ * http://jqueryui.com
1528
+ *
1529
+ * Copyright jQuery Foundation and other contributors
1530
+ * Released under the MIT license.
1531
+ * http://jquery.org/license
1532
+ */
1533
+
1534
+ //>>label: Keycode
1535
+ //>>group: Core
1536
+ //>>description: Provide keycodes as keynames
1537
+ //>>docs: http://api.jqueryui.com/jQuery.ui.keyCode/
1538
+
1539
+
1540
+ var keycode = $.ui.keyCode = {
1541
+ BACKSPACE: 8,
1542
+ COMMA: 188,
1543
+ DELETE: 46,
1544
+ DOWN: 40,
1545
+ END: 35,
1546
+ ENTER: 13,
1547
+ ESCAPE: 27,
1548
+ HOME: 36,
1549
+ LEFT: 37,
1550
+ PAGE_DOWN: 34,
1551
+ PAGE_UP: 33,
1552
+ PERIOD: 190,
1553
+ RIGHT: 39,
1554
+ SPACE: 32,
1555
+ TAB: 9,
1556
+ UP: 38
1557
+ };
1558
+
1559
+
1560
+
1561
+
1562
+ // Internal use only
1563
+ var escapeSelector = $.ui.escapeSelector = ( function() {
1564
+ var selectorEscape = /([!"#$%&'()*+,./:;<=>?@[\]^`{|}~])/g;
1565
+ return function( selector ) {
1566
+ return selector.replace( selectorEscape, "\\$1" );
1567
+ };
1568
+ } )();
1569
+
1570
+
1571
+ /*!
1572
+ * jQuery UI Labels 1.12.1
1573
+ * http://jqueryui.com
1574
+ *
1575
+ * Copyright jQuery Foundation and other contributors
1576
+ * Released under the MIT license.
1577
+ * http://jquery.org/license
1578
+ */
1579
+
1580
+ //>>label: labels
1581
+ //>>group: Core
1582
+ //>>description: Find all the labels associated with a given input
1583
+ //>>docs: http://api.jqueryui.com/labels/
1584
+
1585
+
1586
+
1587
+ var labels = $.fn.labels = function() {
1588
+ var ancestor, selector, id, labels, ancestors;
1589
+
1590
+ // Check control.labels first
1591
+ if ( this[ 0 ].labels && this[ 0 ].labels.length ) {
1592
+ return this.pushStack( this[ 0 ].labels );
1593
+ }
1594
+
1595
+ // Support: IE <= 11, FF <= 37, Android <= 2.3 only
1596
+ // Above browsers do not support control.labels. Everything below is to support them
1597
+ // as well as document fragments. control.labels does not work on document fragments
1598
+ labels = this.eq( 0 ).parents( "label" );
1599
+
1600
+ // Look for the label based on the id
1601
+ id = this.attr( "id" );
1602
+ if ( id ) {
1603
+
1604
+ // We don't search against the document in case the element
1605
+ // is disconnected from the DOM
1606
+ ancestor = this.eq( 0 ).parents().last();
1607
+
1608
+ // Get a full set of top level ancestors
1609
+ ancestors = ancestor.add( ancestor.length ? ancestor.siblings() : this.siblings() );
1610
+
1611
+ // Create a selector for the label based on the id
1612
+ selector = "label[for='" + $.ui.escapeSelector( id ) + "']";
1613
+
1614
+ labels = labels.add( ancestors.find( selector ).addBack( selector ) );
1615
+
1616
+ }
1617
+
1618
+ // Return whatever we have found for labels
1619
+ return this.pushStack( labels );
1620
+ };
1621
+
1622
+
1623
+ /*!
1624
+ * jQuery UI Scroll Parent 1.12.1
1625
+ * http://jqueryui.com
1626
+ *
1627
+ * Copyright jQuery Foundation and other contributors
1628
+ * Released under the MIT license.
1629
+ * http://jquery.org/license
1630
+ */
1631
+
1632
+ //>>label: scrollParent
1633
+ //>>group: Core
1634
+ //>>description: Get the closest ancestor element that is scrollable.
1635
+ //>>docs: http://api.jqueryui.com/scrollParent/
1636
+
1637
+
1638
+
1639
+ var scrollParent = $.fn.scrollParent = function( includeHidden ) {
1640
+ var position = this.css( "position" ),
1641
+ excludeStaticParent = position === "absolute",
1642
+ overflowRegex = includeHidden ? /(auto|scroll|hidden)/ : /(auto|scroll)/,
1643
+ scrollParent = this.parents().filter( function() {
1644
+ var parent = $( this );
1645
+ if ( excludeStaticParent && parent.css( "position" ) === "static" ) {
1646
+ return false;
1647
+ }
1648
+ return overflowRegex.test( parent.css( "overflow" ) + parent.css( "overflow-y" ) +
1649
+ parent.css( "overflow-x" ) );
1650
+ } ).eq( 0 );
1651
+
1652
+ return position === "fixed" || !scrollParent.length ?
1653
+ $( this[ 0 ].ownerDocument || document ) :
1654
+ scrollParent;
1655
+ };
1656
+
1657
+
1658
+ /*!
1659
+ * jQuery UI Tabbable 1.12.1
1660
+ * http://jqueryui.com
1661
+ *
1662
+ * Copyright jQuery Foundation and other contributors
1663
+ * Released under the MIT license.
1664
+ * http://jquery.org/license
1665
+ */
1666
+
1667
+ //>>label: :tabbable Selector
1668
+ //>>group: Core
1669
+ //>>description: Selects elements which can be tabbed to.
1670
+ //>>docs: http://api.jqueryui.com/tabbable-selector/
1671
+
1672
+
1673
+
1674
+ var tabbable = $.extend( $.expr[ ":" ], {
1675
+ tabbable: function( element ) {
1676
+ var tabIndex = $.attr( element, "tabindex" ),
1677
+ hasTabindex = tabIndex != null;
1678
+ return ( !hasTabindex || tabIndex >= 0 ) && $.ui.focusable( element, hasTabindex );
1679
+ }
1680
+ } );
1681
+
1682
+
1683
+ /*!
1684
+ * jQuery UI Unique ID 1.12.1
1685
+ * http://jqueryui.com
1686
+ *
1687
+ * Copyright jQuery Foundation and other contributors
1688
+ * Released under the MIT license.
1689
+ * http://jquery.org/license
1690
+ */
1691
+
1692
+ //>>label: uniqueId
1693
+ //>>group: Core
1694
+ //>>description: Functions to generate and remove uniqueId's
1695
+ //>>docs: http://api.jqueryui.com/uniqueId/
1696
+
1697
+
1698
+
1699
+ var uniqueId = $.fn.extend( {
1700
+ uniqueId: ( function() {
1701
+ var uuid = 0;
1702
+
1703
+ return function() {
1704
+ return this.each( function() {
1705
+ if ( !this.id ) {
1706
+ this.id = "ui-id-" + ( ++uuid );
1707
+ }
1708
+ } );
1709
+ };
1710
+ } )(),
1711
+
1712
+ removeUniqueId: function() {
1713
+ return this.each( function() {
1714
+ if ( /^ui-id-\d+$/.test( this.id ) ) {
1715
+ $( this ).removeAttr( "id" );
1716
+ }
1717
+ } );
1718
+ }
1719
+ } );
1720
+
1721
+
1722
+
1723
+
1724
+ // This file is deprecated
1725
+ var ie = $.ui.ie = !!/msie [\w.]+/.exec( navigator.userAgent.toLowerCase() );
1726
+
1727
+ /*!
1728
+ * jQuery UI Mouse 1.12.1
1729
+ * http://jqueryui.com
1730
+ *
1731
+ * Copyright jQuery Foundation and other contributors
1732
+ * Released under the MIT license.
1733
+ * http://jquery.org/license
1734
+ */
1735
+
1736
+ //>>label: Mouse
1737
+ //>>group: Widgets
1738
+ //>>description: Abstracts mouse-based interactions to assist in creating certain widgets.
1739
+ //>>docs: http://api.jqueryui.com/mouse/
1740
+
1741
+
1742
+
1743
+ var mouseHandled = false;
1744
+ $( document ).on( "mouseup", function() {
1745
+ mouseHandled = false;
1746
+ } );
1747
+
1748
+ var widgetsMouse = $.widget( "ui.mouse", {
1749
+ version: "1.12.1",
1750
+ options: {
1751
+ cancel: "input, textarea, button, select, option",
1752
+ distance: 1,
1753
+ delay: 0
1754
+ },
1755
+ _mouseInit: function() {
1756
+ var that = this;
1757
+
1758
+ this.element
1759
+ .on( "mousedown." + this.widgetName, function( event ) {
1760
+ return that._mouseDown( event );
1761
+ } )
1762
+ .on( "click." + this.widgetName, function( event ) {
1763
+ if ( true === $.data( event.target, that.widgetName + ".preventClickEvent" ) ) {
1764
+ $.removeData( event.target, that.widgetName + ".preventClickEvent" );
1765
+ event.stopImmediatePropagation();
1766
+ return false;
1767
+ }
1768
+ } );
1769
+
1770
+ this.started = false;
1771
+ },
1772
+
1773
+ // TODO: make sure destroying one instance of mouse doesn't mess with
1774
+ // other instances of mouse
1775
+ _mouseDestroy: function() {
1776
+ this.element.off( "." + this.widgetName );
1777
+ if ( this._mouseMoveDelegate ) {
1778
+ this.document
1779
+ .off( "mousemove." + this.widgetName, this._mouseMoveDelegate )
1780
+ .off( "mouseup." + this.widgetName, this._mouseUpDelegate );
1781
+ }
1782
+ },
1783
+
1784
+ _mouseDown: function( event ) {
1785
+
1786
+ // don't let more than one widget handle mouseStart
1787
+ if ( mouseHandled ) {
1788
+ return;
1789
+ }
1790
+
1791
+ this._mouseMoved = false;
1792
+
1793
+ // We may have missed mouseup (out of window)
1794
+ ( this._mouseStarted && this._mouseUp( event ) );
1795
+
1796
+ this._mouseDownEvent = event;
1797
+
1798
+ var that = this,
1799
+ btnIsLeft = ( event.which === 1 ),
1800
+
1801
+ // event.target.nodeName works around a bug in IE 8 with
1802
+ // disabled inputs (#7620)
1803
+ elIsCancel = ( typeof this.options.cancel === "string" && event.target.nodeName ?
1804
+ $( event.target ).closest( this.options.cancel ).length : false );
1805
+ if ( !btnIsLeft || elIsCancel || !this._mouseCapture( event ) ) {
1806
+ return true;
1807
+ }
1808
+
1809
+ this.mouseDelayMet = !this.options.delay;
1810
+ if ( !this.mouseDelayMet ) {
1811
+ this._mouseDelayTimer = setTimeout( function() {
1812
+ that.mouseDelayMet = true;
1813
+ }, this.options.delay );
1814
+ }
1815
+
1816
+ if ( this._mouseDistanceMet( event ) && this._mouseDelayMet( event ) ) {
1817
+ this._mouseStarted = ( this._mouseStart( event ) !== false );
1818
+ if ( !this._mouseStarted ) {
1819
+ event.preventDefault();
1820
+ return true;
1821
+ }
1822
+ }
1823
+
1824
+ // Click event may never have fired (Gecko & Opera)
1825
+ if ( true === $.data( event.target, this.widgetName + ".preventClickEvent" ) ) {
1826
+ $.removeData( event.target, this.widgetName + ".preventClickEvent" );
1827
+ }
1828
+
1829
+ // These delegates are required to keep context
1830
+ this._mouseMoveDelegate = function( event ) {
1831
+ return that._mouseMove( event );
1832
+ };
1833
+ this._mouseUpDelegate = function( event ) {
1834
+ return that._mouseUp( event );
1835
+ };
1836
+
1837
+ this.document
1838
+ .on( "mousemove." + this.widgetName, this._mouseMoveDelegate )
1839
+ .on( "mouseup." + this.widgetName, this._mouseUpDelegate );
1840
+
1841
+ event.preventDefault();
1842
+
1843
+ mouseHandled = true;
1844
+ return true;
1845
+ },
1846
+
1847
+ _mouseMove: function( event ) {
1848
+
1849
+ // Only check for mouseups outside the document if you've moved inside the document
1850
+ // at least once. This prevents the firing of mouseup in the case of IE<9, which will
1851
+ // fire a mousemove event if content is placed under the cursor. See #7778
1852
+ // Support: IE <9
1853
+ if ( this._mouseMoved ) {
1854
+
1855
+ // IE mouseup check - mouseup happened when mouse was out of window
1856
+ if ( $.ui.ie && ( !document.documentMode || document.documentMode < 9 ) &&
1857
+ !event.button ) {
1858
+ return this._mouseUp( event );
1859
+
1860
+ // Iframe mouseup check - mouseup occurred in another document
1861
+ } else if ( !event.which ) {
1862
+
1863
+ // Support: Safari <=8 - 9
1864
+ // Safari sets which to 0 if you press any of the following keys
1865
+ // during a drag (#14461)
1866
+ if ( event.originalEvent.altKey || event.originalEvent.ctrlKey ||
1867
+ event.originalEvent.metaKey || event.originalEvent.shiftKey ) {
1868
+ this.ignoreMissingWhich = true;
1869
+ } else if ( !this.ignoreMissingWhich ) {
1870
+ return this._mouseUp( event );
1871
+ }
1872
+ }
1873
+ }
1874
+
1875
+ if ( event.which || event.button ) {
1876
+ this._mouseMoved = true;
1877
+ }
1878
+
1879
+ if ( this._mouseStarted ) {
1880
+ this._mouseDrag( event );
1881
+ return event.preventDefault();
1882
+ }
1883
+
1884
+ if ( this._mouseDistanceMet( event ) && this._mouseDelayMet( event ) ) {
1885
+ this._mouseStarted =
1886
+ ( this._mouseStart( this._mouseDownEvent, event ) !== false );
1887
+ ( this._mouseStarted ? this._mouseDrag( event ) : this._mouseUp( event ) );
1888
+ }
1889
+
1890
+ return !this._mouseStarted;
1891
+ },
1892
+
1893
+ _mouseUp: function( event ) {
1894
+ this.document
1895
+ .off( "mousemove." + this.widgetName, this._mouseMoveDelegate )
1896
+ .off( "mouseup." + this.widgetName, this._mouseUpDelegate );
1897
+
1898
+ if ( this._mouseStarted ) {
1899
+ this._mouseStarted = false;
1900
+
1901
+ if ( event.target === this._mouseDownEvent.target ) {
1902
+ $.data( event.target, this.widgetName + ".preventClickEvent", true );
1903
+ }
1904
+
1905
+ this._mouseStop( event );
1906
+ }
1907
+
1908
+ if ( this._mouseDelayTimer ) {
1909
+ clearTimeout( this._mouseDelayTimer );
1910
+ delete this._mouseDelayTimer;
1911
+ }
1912
+
1913
+ this.ignoreMissingWhich = false;
1914
+ mouseHandled = false;
1915
+ event.preventDefault();
1916
+ },
1917
+
1918
+ _mouseDistanceMet: function( event ) {
1919
+ return ( Math.max(
1920
+ Math.abs( this._mouseDownEvent.pageX - event.pageX ),
1921
+ Math.abs( this._mouseDownEvent.pageY - event.pageY )
1922
+ ) >= this.options.distance
1923
+ );
1924
+ },
1925
+
1926
+ _mouseDelayMet: function( /* event */ ) {
1927
+ return this.mouseDelayMet;
1928
+ },
1929
+
1930
+ // These are placeholder methods, to be overriden by extending plugin
1931
+ _mouseStart: function( /* event */ ) {},
1932
+ _mouseDrag: function( /* event */ ) {},
1933
+ _mouseStop: function( /* event */ ) {},
1934
+ _mouseCapture: function( /* event */ ) { return true; }
1935
+ } );
1936
+
1937
+
1938
+ /*!
1939
+ * jQuery UI Sortable 1.12.1
1940
+ * http://jqueryui.com
1941
+ *
1942
+ * Copyright jQuery Foundation and other contributors
1943
+ * Released under the MIT license.
1944
+ * http://jquery.org/license
1945
+ */
1946
+
1947
+ //>>label: Sortable
1948
+ //>>group: Interactions
1949
+ //>>description: Enables items in a list to be sorted using the mouse.
1950
+ //>>docs: http://api.jqueryui.com/sortable/
1951
+ //>>demos: http://jqueryui.com/sortable/
1952
+ //>>css.structure: ../../themes/base/sortable.css
1953
+
1954
+
1955
+
1956
+ var widgetsSortable = $.widget( "ui.sortable", $.ui.mouse, {
1957
+ version: "1.12.1",
1958
+ widgetEventPrefix: "sort",
1959
+ ready: false,
1960
+ options: {
1961
+ appendTo: "parent",
1962
+ axis: false,
1963
+ connectWith: false,
1964
+ containment: false,
1965
+ cursor: "auto",
1966
+ cursorAt: false,
1967
+ dropOnEmpty: true,
1968
+ forcePlaceholderSize: false,
1969
+ forceHelperSize: false,
1970
+ grid: false,
1971
+ handle: false,
1972
+ helper: "original",
1973
+ items: "> *",
1974
+ opacity: false,
1975
+ placeholder: false,
1976
+ revert: false,
1977
+ scroll: true,
1978
+ scrollSensitivity: 20,
1979
+ scrollSpeed: 20,
1980
+ scope: "default",
1981
+ tolerance: "intersect",
1982
+ zIndex: 1000,
1983
+
1984
+ // Callbacks
1985
+ activate: null,
1986
+ beforeStop: null,
1987
+ change: null,
1988
+ deactivate: null,
1989
+ out: null,
1990
+ over: null,
1991
+ receive: null,
1992
+ remove: null,
1993
+ sort: null,
1994
+ start: null,
1995
+ stop: null,
1996
+ update: null
1997
+ },
1998
+
1999
+ _isOverAxis: function( x, reference, size ) {
2000
+ return ( x >= reference ) && ( x < ( reference + size ) );
2001
+ },
2002
+
2003
+ _isFloating: function( item ) {
2004
+ return ( /left|right/ ).test( item.css( "float" ) ) ||
2005
+ ( /inline|table-cell/ ).test( item.css( "display" ) );
2006
+ },
2007
+
2008
+ _create: function() {
2009
+ this.containerCache = {};
2010
+ this._addClass( "ui-sortable" );
2011
+
2012
+ //Get the items
2013
+ this.refresh();
2014
+
2015
+ //Let's determine the parent's offset
2016
+ this.offset = this.element.offset();
2017
+
2018
+ //Initialize mouse events for interaction
2019
+ this._mouseInit();
2020
+
2021
+ this._setHandleClassName();
2022
+
2023
+ //We're ready to go
2024
+ this.ready = true;
2025
+
2026
+ },
2027
+
2028
+ _setOption: function( key, value ) {
2029
+ this._super( key, value );
2030
+
2031
+ if ( key === "handle" ) {
2032
+ this._setHandleClassName();
2033
+ }
2034
+ },
2035
+
2036
+ _setHandleClassName: function() {
2037
+ var that = this;
2038
+ this._removeClass( this.element.find( ".ui-sortable-handle" ), "ui-sortable-handle" );
2039
+ $.each( this.items, function() {
2040
+ that._addClass(
2041
+ this.instance.options.handle ?
2042
+ this.item.find( this.instance.options.handle ) :
2043
+ this.item,
2044
+ "ui-sortable-handle"
2045
+ );
2046
+ } );
2047
+ },
2048
+
2049
+ _destroy: function() {
2050
+ this._mouseDestroy();
2051
+
2052
+ for ( var i = this.items.length - 1; i >= 0; i-- ) {
2053
+ this.items[ i ].item.removeData( this.widgetName + "-item" );
2054
+ }
2055
+
2056
+ return this;
2057
+ },
2058
+
2059
+ _mouseCapture: function( event, overrideHandle ) {
2060
+ var currentItem = null,
2061
+ validHandle = false,
2062
+ that = this;
2063
+
2064
+ if ( this.reverting ) {
2065
+ return false;
2066
+ }
2067
+
2068
+ if ( this.options.disabled || this.options.type === "static" ) {
2069
+ return false;
2070
+ }
2071
+
2072
+ //We have to refresh the items data once first
2073
+ this._refreshItems( event );
2074
+
2075
+ //Find out if the clicked node (or one of its parents) is a actual item in this.items
2076
+ $( event.target ).parents().each( function() {
2077
+ if ( $.data( this, that.widgetName + "-item" ) === that ) {
2078
+ currentItem = $( this );
2079
+ return false;
2080
+ }
2081
+ } );
2082
+ if ( $.data( event.target, that.widgetName + "-item" ) === that ) {
2083
+ currentItem = $( event.target );
2084
+ }
2085
+
2086
+ if ( !currentItem ) {
2087
+ return false;
2088
+ }
2089
+ if ( this.options.handle && !overrideHandle ) {
2090
+ $( this.options.handle, currentItem ).find( "*" ).addBack().each( function() {
2091
+ if ( this === event.target ) {
2092
+ validHandle = true;
2093
+ }
2094
+ } );
2095
+ if ( !validHandle ) {
2096
+ return false;
2097
+ }
2098
+ }
2099
+
2100
+ this.currentItem = currentItem;
2101
+ this._removeCurrentsFromItems();
2102
+ return true;
2103
+
2104
+ },
2105
+
2106
+ _mouseStart: function( event, overrideHandle, noActivation ) {
2107
+
2108
+ var i, body,
2109
+ o = this.options;
2110
+
2111
+ this.currentContainer = this;
2112
+
2113
+ //We only need to call refreshPositions, because the refreshItems call has been moved to
2114
+ // mouseCapture
2115
+ this.refreshPositions();
2116
+
2117
+ //Create and append the visible helper
2118
+ this.helper = this._createHelper( event );
2119
+
2120
+ //Cache the helper size
2121
+ this._cacheHelperProportions();
2122
+
2123
+ /*
2124
+ * - Position generation -
2125
+ * This block generates everything position related - it's the core of draggables.
2126
+ */
2127
+
2128
+ //Cache the margins of the original element
2129
+ this._cacheMargins();
2130
+
2131
+ //Get the next scrolling parent
2132
+ this.scrollParent = this.helper.scrollParent();
2133
+
2134
+ //The element's absolute position on the page minus margins
2135
+ this.offset = this.currentItem.offset();
2136
+ this.offset = {
2137
+ top: this.offset.top - this.margins.top,
2138
+ left: this.offset.left - this.margins.left
2139
+ };
2140
+
2141
+ $.extend( this.offset, {
2142
+ click: { //Where the click happened, relative to the element
2143
+ left: event.pageX - this.offset.left,
2144
+ top: event.pageY - this.offset.top
2145
+ },
2146
+ parent: this._getParentOffset(),
2147
+
2148
+ // This is a relative to absolute position minus the actual position calculation -
2149
+ // only used for relative positioned helper
2150
+ relative: this._getRelativeOffset()
2151
+ } );
2152
+
2153
+ // Only after we got the offset, we can change the helper's position to absolute
2154
+ // TODO: Still need to figure out a way to make relative sorting possible
2155
+ this.helper.css( "position", "absolute" );
2156
+ this.cssPosition = this.helper.css( "position" );
2157
+
2158
+ //Generate the original position
2159
+ this.originalPosition = this._generatePosition( event );
2160
+ this.originalPageX = event.pageX;
2161
+ this.originalPageY = event.pageY;
2162
+
2163
+ //Adjust the mouse offset relative to the helper if "cursorAt" is supplied
2164
+ ( o.cursorAt && this._adjustOffsetFromHelper( o.cursorAt ) );
2165
+
2166
+ //Cache the former DOM position
2167
+ this.domPosition = {
2168
+ prev: this.currentItem.prev()[ 0 ],
2169
+ parent: this.currentItem.parent()[ 0 ]
2170
+ };
2171
+
2172
+ // If the helper is not the original, hide the original so it's not playing any role during
2173
+ // the drag, won't cause anything bad this way
2174
+ if ( this.helper[ 0 ] !== this.currentItem[ 0 ] ) {
2175
+ this.currentItem.hide();
2176
+ }
2177
+
2178
+ //Create the placeholder
2179
+ this._createPlaceholder();
2180
+
2181
+ //Set a containment if given in the options
2182
+ if ( o.containment ) {
2183
+ this._setContainment();
2184
+ }
2185
+
2186
+ if ( o.cursor && o.cursor !== "auto" ) { // cursor option
2187
+ body = this.document.find( "body" );
2188
+
2189
+ // Support: IE
2190
+ this.storedCursor = body.css( "cursor" );
2191
+ body.css( "cursor", o.cursor );
2192
+
2193
+ this.storedStylesheet =
2194
+ $( "<style>*{ cursor: " + o.cursor + " !important; }</style>" ).appendTo( body );
2195
+ }
2196
+
2197
+ if ( o.opacity ) { // opacity option
2198
+ if ( this.helper.css( "opacity" ) ) {
2199
+ this._storedOpacity = this.helper.css( "opacity" );
2200
+ }
2201
+ this.helper.css( "opacity", o.opacity );
2202
+ }
2203
+
2204
+ if ( o.zIndex ) { // zIndex option
2205
+ if ( this.helper.css( "zIndex" ) ) {
2206
+ this._storedZIndex = this.helper.css( "zIndex" );
2207
+ }
2208
+ this.helper.css( "zIndex", o.zIndex );
2209
+ }
2210
+
2211
+ //Prepare scrolling
2212
+ if ( this.scrollParent[ 0 ] !== this.document[ 0 ] &&
2213
+ this.scrollParent[ 0 ].tagName !== "HTML" ) {
2214
+ this.overflowOffset = this.scrollParent.offset();
2215
+ }
2216
+
2217
+ //Call callbacks
2218
+ this._trigger( "start", event, this._uiHash() );
2219
+
2220
+ //Recache the helper size
2221
+ if ( !this._preserveHelperProportions ) {
2222
+ this._cacheHelperProportions();
2223
+ }
2224
+
2225
+ //Post "activate" events to possible containers
2226
+ if ( !noActivation ) {
2227
+ for ( i = this.containers.length - 1; i >= 0; i-- ) {
2228
+ this.containers[ i ]._trigger( "activate", event, this._uiHash( this ) );
2229
+ }
2230
+ }
2231
+
2232
+ //Prepare possible droppables
2233
+ if ( $.ui.ddmanager ) {
2234
+ $.ui.ddmanager.current = this;
2235
+ }
2236
+
2237
+ if ( $.ui.ddmanager && !o.dropBehaviour ) {
2238
+ $.ui.ddmanager.prepareOffsets( this, event );
2239
+ }
2240
+
2241
+ this.dragging = true;
2242
+
2243
+ this._addClass( this.helper, "ui-sortable-helper" );
2244
+
2245
+ // Execute the drag once - this causes the helper not to be visiblebefore getting its
2246
+ // correct position
2247
+ this._mouseDrag( event );
2248
+ return true;
2249
+
2250
+ },
2251
+
2252
+ _mouseDrag: function( event ) {
2253
+ var i, item, itemElement, intersection,
2254
+ o = this.options,
2255
+ scrolled = false;
2256
+
2257
+ //Compute the helpers position
2258
+ this.position = this._generatePosition( event );
2259
+ this.positionAbs = this._convertPositionTo( "absolute" );
2260
+
2261
+ if ( !this.lastPositionAbs ) {
2262
+ this.lastPositionAbs = this.positionAbs;
2263
+ }
2264
+
2265
+ //Do scrolling
2266
+ if ( this.options.scroll ) {
2267
+ if ( this.scrollParent[ 0 ] !== this.document[ 0 ] &&
2268
+ this.scrollParent[ 0 ].tagName !== "HTML" ) {
2269
+
2270
+ if ( ( this.overflowOffset.top + this.scrollParent[ 0 ].offsetHeight ) -
2271
+ event.pageY < o.scrollSensitivity ) {
2272
+ this.scrollParent[ 0 ].scrollTop =
2273
+ scrolled = this.scrollParent[ 0 ].scrollTop + o.scrollSpeed;
2274
+ } else if ( event.pageY - this.overflowOffset.top < o.scrollSensitivity ) {
2275
+ this.scrollParent[ 0 ].scrollTop =
2276
+ scrolled = this.scrollParent[ 0 ].scrollTop - o.scrollSpeed;
2277
+ }
2278
+
2279
+ if ( ( this.overflowOffset.left + this.scrollParent[ 0 ].offsetWidth ) -
2280
+ event.pageX < o.scrollSensitivity ) {
2281
+ this.scrollParent[ 0 ].scrollLeft = scrolled =
2282
+ this.scrollParent[ 0 ].scrollLeft + o.scrollSpeed;
2283
+ } else if ( event.pageX - this.overflowOffset.left < o.scrollSensitivity ) {
2284
+ this.scrollParent[ 0 ].scrollLeft = scrolled =
2285
+ this.scrollParent[ 0 ].scrollLeft - o.scrollSpeed;
2286
+ }
2287
+
2288
+ } else {
2289
+
2290
+ if ( event.pageY - this.document.scrollTop() < o.scrollSensitivity ) {
2291
+ scrolled = this.document.scrollTop( this.document.scrollTop() - o.scrollSpeed );
2292
+ } else if ( this.window.height() - ( event.pageY - this.document.scrollTop() ) <
2293
+ o.scrollSensitivity ) {
2294
+ scrolled = this.document.scrollTop( this.document.scrollTop() + o.scrollSpeed );
2295
+ }
2296
+
2297
+ if ( event.pageX - this.document.scrollLeft() < o.scrollSensitivity ) {
2298
+ scrolled = this.document.scrollLeft(
2299
+ this.document.scrollLeft() - o.scrollSpeed
2300
+ );
2301
+ } else if ( this.window.width() - ( event.pageX - this.document.scrollLeft() ) <
2302
+ o.scrollSensitivity ) {
2303
+ scrolled = this.document.scrollLeft(
2304
+ this.document.scrollLeft() + o.scrollSpeed
2305
+ );
2306
+ }
2307
+
2308
+ }
2309
+
2310
+ if ( scrolled !== false && $.ui.ddmanager && !o.dropBehaviour ) {
2311
+ $.ui.ddmanager.prepareOffsets( this, event );
2312
+ }
2313
+ }
2314
+
2315
+ //Regenerate the absolute position used for position checks
2316
+ this.positionAbs = this._convertPositionTo( "absolute" );
2317
+
2318
+ //Set the helper position
2319
+ if ( !this.options.axis || this.options.axis !== "y" ) {
2320
+ this.helper[ 0 ].style.left = this.position.left + "px";
2321
+ }
2322
+ if ( !this.options.axis || this.options.axis !== "x" ) {
2323
+ this.helper[ 0 ].style.top = this.position.top + "px";
2324
+ }
2325
+
2326
+ //Rearrange
2327
+ for ( i = this.items.length - 1; i >= 0; i-- ) {
2328
+
2329
+ //Cache variables and intersection, continue if no intersection
2330
+ item = this.items[ i ];
2331
+ itemElement = item.item[ 0 ];
2332
+ intersection = this._intersectsWithPointer( item );
2333
+ if ( !intersection ) {
2334
+ continue;
2335
+ }
2336
+
2337
+ // Only put the placeholder inside the current Container, skip all
2338
+ // items from other containers. This works because when moving
2339
+ // an item from one container to another the
2340
+ // currentContainer is switched before the placeholder is moved.
2341
+ //
2342
+ // Without this, moving items in "sub-sortables" can cause
2343
+ // the placeholder to jitter between the outer and inner container.
2344
+ if ( item.instance !== this.currentContainer ) {
2345
+ continue;
2346
+ }
2347
+
2348
+ // Cannot intersect with itself
2349
+ // no useless actions that have been done before
2350
+ // no action if the item moved is the parent of the item checked
2351
+ if ( itemElement !== this.currentItem[ 0 ] &&
2352
+ this.placeholder[ intersection === 1 ? "next" : "prev" ]()[ 0 ] !== itemElement &&
2353
+ !$.contains( this.placeholder[ 0 ], itemElement ) &&
2354
+ ( this.options.type === "semi-dynamic" ?
2355
+ !$.contains( this.element[ 0 ], itemElement ) :
2356
+ true
2357
+ )
2358
+ ) {
2359
+
2360
+ this.direction = intersection === 1 ? "down" : "up";
2361
+
2362
+ if ( this.options.tolerance === "pointer" || this._intersectsWithSides( item ) ) {
2363
+ this._rearrange( event, item );
2364
+ } else {
2365
+ break;
2366
+ }
2367
+
2368
+ this._trigger( "change", event, this._uiHash() );
2369
+ break;
2370
+ }
2371
+ }
2372
+
2373
+ //Post events to containers
2374
+ this._contactContainers( event );
2375
+
2376
+ //Interconnect with droppables
2377
+ if ( $.ui.ddmanager ) {
2378
+ $.ui.ddmanager.drag( this, event );
2379
+ }
2380
+
2381
+ //Call callbacks
2382
+ this._trigger( "sort", event, this._uiHash() );
2383
+
2384
+ this.lastPositionAbs = this.positionAbs;
2385
+ return false;
2386
+
2387
+ },
2388
+
2389
+ _mouseStop: function( event, noPropagation ) {
2390
+
2391
+ if ( !event ) {
2392
+ return;
2393
+ }
2394
+
2395
+ //If we are using droppables, inform the manager about the drop
2396
+ if ( $.ui.ddmanager && !this.options.dropBehaviour ) {
2397
+ $.ui.ddmanager.drop( this, event );
2398
+ }
2399
+
2400
+ if ( this.options.revert ) {
2401
+ var that = this,
2402
+ cur = this.placeholder.offset(),
2403
+ axis = this.options.axis,
2404
+ animation = {};
2405
+
2406
+ if ( !axis || axis === "x" ) {
2407
+ animation.left = cur.left - this.offset.parent.left - this.margins.left +
2408
+ ( this.offsetParent[ 0 ] === this.document[ 0 ].body ?
2409
+ 0 :
2410
+ this.offsetParent[ 0 ].scrollLeft
2411
+ );
2412
+ }
2413
+ if ( !axis || axis === "y" ) {
2414
+ animation.top = cur.top - this.offset.parent.top - this.margins.top +
2415
+ ( this.offsetParent[ 0 ] === this.document[ 0 ].body ?
2416
+ 0 :
2417
+ this.offsetParent[ 0 ].scrollTop
2418
+ );
2419
+ }
2420
+ this.reverting = true;
2421
+ $( this.helper ).animate(
2422
+ animation,
2423
+ parseInt( this.options.revert, 10 ) || 500,
2424
+ function() {
2425
+ that._clear( event );
2426
+ }
2427
+ );
2428
+ } else {
2429
+ this._clear( event, noPropagation );
2430
+ }
2431
+
2432
+ return false;
2433
+
2434
+ },
2435
+
2436
+ cancel: function() {
2437
+
2438
+ if ( this.dragging ) {
2439
+
2440
+ this._mouseUp( new $.Event( "mouseup", { target: null } ) );
2441
+
2442
+ if ( this.options.helper === "original" ) {
2443
+ this.currentItem.css( this._storedCSS );
2444
+ this._removeClass( this.currentItem, "ui-sortable-helper" );
2445
+ } else {
2446
+ this.currentItem.show();
2447
+ }
2448
+
2449
+ //Post deactivating events to containers
2450
+ for ( var i = this.containers.length - 1; i >= 0; i-- ) {
2451
+ this.containers[ i ]._trigger( "deactivate", null, this._uiHash( this ) );
2452
+ if ( this.containers[ i ].containerCache.over ) {
2453
+ this.containers[ i ]._trigger( "out", null, this._uiHash( this ) );
2454
+ this.containers[ i ].containerCache.over = 0;
2455
+ }
2456
+ }
2457
+
2458
+ }
2459
+
2460
+ if ( this.placeholder ) {
2461
+
2462
+ //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately,
2463
+ // it unbinds ALL events from the original node!
2464
+ if ( this.placeholder[ 0 ].parentNode ) {
2465
+ this.placeholder[ 0 ].parentNode.removeChild( this.placeholder[ 0 ] );
2466
+ }
2467
+ if ( this.options.helper !== "original" && this.helper &&
2468
+ this.helper[ 0 ].parentNode ) {
2469
+ this.helper.remove();
2470
+ }
2471
+
2472
+ $.extend( this, {
2473
+ helper: null,
2474
+ dragging: false,
2475
+ reverting: false,
2476
+ _noFinalSort: null
2477
+ } );
2478
+
2479
+ if ( this.domPosition.prev ) {
2480
+ $( this.domPosition.prev ).after( this.currentItem );
2481
+ } else {
2482
+ $( this.domPosition.parent ).prepend( this.currentItem );
2483
+ }
2484
+ }
2485
+
2486
+ return this;
2487
+
2488
+ },
2489
+
2490
+ serialize: function( o ) {
2491
+
2492
+ var items = this._getItemsAsjQuery( o && o.connected ),
2493
+ str = [];
2494
+ o = o || {};
2495
+
2496
+ $( items ).each( function() {
2497
+ var res = ( $( o.item || this ).attr( o.attribute || "id" ) || "" )
2498
+ .match( o.expression || ( /(.+)[\-=_](.+)/ ) );
2499
+ if ( res ) {
2500
+ str.push(
2501
+ ( o.key || res[ 1 ] + "[]" ) +
2502
+ "=" + ( o.key && o.expression ? res[ 1 ] : res[ 2 ] ) );
2503
+ }
2504
+ } );
2505
+
2506
+ if ( !str.length && o.key ) {
2507
+ str.push( o.key + "=" );
2508
+ }
2509
+
2510
+ return str.join( "&" );
2511
+
2512
+ },
2513
+
2514
+ toArray: function( o ) {
2515
+
2516
+ var items = this._getItemsAsjQuery( o && o.connected ),
2517
+ ret = [];
2518
+
2519
+ o = o || {};
2520
+
2521
+ items.each( function() {
2522
+ ret.push( $( o.item || this ).attr( o.attribute || "id" ) || "" );
2523
+ } );
2524
+ return ret;
2525
+
2526
+ },
2527
+
2528
+ /* Be careful with the following core functions */
2529
+ _intersectsWith: function( item ) {
2530
+
2531
+ var x1 = this.positionAbs.left,
2532
+ x2 = x1 + this.helperProportions.width,
2533
+ y1 = this.positionAbs.top,
2534
+ y2 = y1 + this.helperProportions.height,
2535
+ l = item.left,
2536
+ r = l + item.width,
2537
+ t = item.top,
2538
+ b = t + item.height,
2539
+ dyClick = this.offset.click.top,
2540
+ dxClick = this.offset.click.left,
2541
+ isOverElementHeight = ( this.options.axis === "x" ) || ( ( y1 + dyClick ) > t &&
2542
+ ( y1 + dyClick ) < b ),
2543
+ isOverElementWidth = ( this.options.axis === "y" ) || ( ( x1 + dxClick ) > l &&
2544
+ ( x1 + dxClick ) < r ),
2545
+ isOverElement = isOverElementHeight && isOverElementWidth;
2546
+
2547
+ if ( this.options.tolerance === "pointer" ||
2548
+ this.options.forcePointerForContainers ||
2549
+ ( this.options.tolerance !== "pointer" &&
2550
+ this.helperProportions[ this.floating ? "width" : "height" ] >
2551
+ item[ this.floating ? "width" : "height" ] )
2552
+ ) {
2553
+ return isOverElement;
2554
+ } else {
2555
+
2556
+ return ( l < x1 + ( this.helperProportions.width / 2 ) && // Right Half
2557
+ x2 - ( this.helperProportions.width / 2 ) < r && // Left Half
2558
+ t < y1 + ( this.helperProportions.height / 2 ) && // Bottom Half
2559
+ y2 - ( this.helperProportions.height / 2 ) < b ); // Top Half
2560
+
2561
+ }
2562
+ },
2563
+
2564
+ _intersectsWithPointer: function( item ) {
2565
+ var verticalDirection, horizontalDirection,
2566
+ isOverElementHeight = ( this.options.axis === "x" ) ||
2567
+ this._isOverAxis(
2568
+ this.positionAbs.top + this.offset.click.top, item.top, item.height ),
2569
+ isOverElementWidth = ( this.options.axis === "y" ) ||
2570
+ this._isOverAxis(
2571
+ this.positionAbs.left + this.offset.click.left, item.left, item.width ),
2572
+ isOverElement = isOverElementHeight && isOverElementWidth;
2573
+
2574
+ if ( !isOverElement ) {
2575
+ return false;
2576
+ }
2577
+
2578
+ verticalDirection = this._getDragVerticalDirection();
2579
+ horizontalDirection = this._getDragHorizontalDirection();
2580
+
2581
+ return this.floating ?
2582
+ ( ( horizontalDirection === "right" || verticalDirection === "down" ) ? 2 : 1 )
2583
+ : ( verticalDirection && ( verticalDirection === "down" ? 2 : 1 ) );
2584
+
2585
+ },
2586
+
2587
+ _intersectsWithSides: function( item ) {
2588
+
2589
+ var isOverBottomHalf = this._isOverAxis( this.positionAbs.top +
2590
+ this.offset.click.top, item.top + ( item.height / 2 ), item.height ),
2591
+ isOverRightHalf = this._isOverAxis( this.positionAbs.left +
2592
+ this.offset.click.left, item.left + ( item.width / 2 ), item.width ),
2593
+ verticalDirection = this._getDragVerticalDirection(),
2594
+ horizontalDirection = this._getDragHorizontalDirection();
2595
+
2596
+ if ( this.floating && horizontalDirection ) {
2597
+ return ( ( horizontalDirection === "right" && isOverRightHalf ) ||
2598
+ ( horizontalDirection === "left" && !isOverRightHalf ) );
2599
+ } else {
2600
+ return verticalDirection && ( ( verticalDirection === "down" && isOverBottomHalf ) ||
2601
+ ( verticalDirection === "up" && !isOverBottomHalf ) );
2602
+ }
2603
+
2604
+ },
2605
+
2606
+ _getDragVerticalDirection: function() {
2607
+ var delta = this.positionAbs.top - this.lastPositionAbs.top;
2608
+ return delta !== 0 && ( delta > 0 ? "down" : "up" );
2609
+ },
2610
+
2611
+ _getDragHorizontalDirection: function() {
2612
+ var delta = this.positionAbs.left - this.lastPositionAbs.left;
2613
+ return delta !== 0 && ( delta > 0 ? "right" : "left" );
2614
+ },
2615
+
2616
+ refresh: function( event ) {
2617
+ this._refreshItems( event );
2618
+ this._setHandleClassName();
2619
+ this.refreshPositions();
2620
+ return this;
2621
+ },
2622
+
2623
+ _connectWith: function() {
2624
+ var options = this.options;
2625
+ return options.connectWith.constructor === String ?
2626
+ [ options.connectWith ] :
2627
+ options.connectWith;
2628
+ },
2629
+
2630
+ _getItemsAsjQuery: function( connected ) {
2631
+
2632
+ var i, j, cur, inst,
2633
+ items = [],
2634
+ queries = [],
2635
+ connectWith = this._connectWith();
2636
+
2637
+ if ( connectWith && connected ) {
2638
+ for ( i = connectWith.length - 1; i >= 0; i-- ) {
2639
+ cur = $( connectWith[ i ], this.document[ 0 ] );
2640
+ for ( j = cur.length - 1; j >= 0; j-- ) {
2641
+ inst = $.data( cur[ j ], this.widgetFullName );
2642
+ if ( inst && inst !== this && !inst.options.disabled ) {
2643
+ queries.push( [ $.isFunction( inst.options.items ) ?
2644
+ inst.options.items.call( inst.element ) :
2645
+ $( inst.options.items, inst.element )
2646
+ .not( ".ui-sortable-helper" )
2647
+ .not( ".ui-sortable-placeholder" ), inst ] );
2648
+ }
2649
+ }
2650
+ }
2651
+ }
2652
+
2653
+ queries.push( [ $.isFunction( this.options.items ) ?
2654
+ this.options.items
2655
+ .call( this.element, null, { options: this.options, item: this.currentItem } ) :
2656
+ $( this.options.items, this.element )
2657
+ .not( ".ui-sortable-helper" )
2658
+ .not( ".ui-sortable-placeholder" ), this ] );
2659
+
2660
+ function addItems() {
2661
+ items.push( this );
2662
+ }
2663
+ for ( i = queries.length - 1; i >= 0; i-- ) {
2664
+ queries[ i ][ 0 ].each( addItems );
2665
+ }
2666
+
2667
+ return $( items );
2668
+
2669
+ },
2670
+
2671
+ _removeCurrentsFromItems: function() {
2672
+
2673
+ var list = this.currentItem.find( ":data(" + this.widgetName + "-item)" );
2674
+
2675
+ this.items = $.grep( this.items, function( item ) {
2676
+ for ( var j = 0; j < list.length; j++ ) {
2677
+ if ( list[ j ] === item.item[ 0 ] ) {
2678
+ return false;
2679
+ }
2680
+ }
2681
+ return true;
2682
+ } );
2683
+
2684
+ },
2685
+
2686
+ _refreshItems: function( event ) {
2687
+
2688
+ this.items = [];
2689
+ this.containers = [ this ];
2690
+
2691
+ var i, j, cur, inst, targetData, _queries, item, queriesLength,
2692
+ items = this.items,
2693
+ queries = [ [ $.isFunction( this.options.items ) ?
2694
+ this.options.items.call( this.element[ 0 ], event, { item: this.currentItem } ) :
2695
+ $( this.options.items, this.element ), this ] ],
2696
+ connectWith = this._connectWith();
2697
+
2698
+ //Shouldn't be run the first time through due to massive slow-down
2699
+ if ( connectWith && this.ready ) {
2700
+ for ( i = connectWith.length - 1; i >= 0; i-- ) {
2701
+ cur = $( connectWith[ i ], this.document[ 0 ] );
2702
+ for ( j = cur.length - 1; j >= 0; j-- ) {
2703
+ inst = $.data( cur[ j ], this.widgetFullName );
2704
+ if ( inst && inst !== this && !inst.options.disabled ) {
2705
+ queries.push( [ $.isFunction( inst.options.items ) ?
2706
+ inst.options.items
2707
+ .call( inst.element[ 0 ], event, { item: this.currentItem } ) :
2708
+ $( inst.options.items, inst.element ), inst ] );
2709
+ this.containers.push( inst );
2710
+ }
2711
+ }
2712
+ }
2713
+ }
2714
+
2715
+ for ( i = queries.length - 1; i >= 0; i-- ) {
2716
+ targetData = queries[ i ][ 1 ];
2717
+ _queries = queries[ i ][ 0 ];
2718
+
2719
+ for ( j = 0, queriesLength = _queries.length; j < queriesLength; j++ ) {
2720
+ item = $( _queries[ j ] );
2721
+
2722
+ // Data for target checking (mouse manager)
2723
+ item.data( this.widgetName + "-item", targetData );
2724
+
2725
+ items.push( {
2726
+ item: item,
2727
+ instance: targetData,
2728
+ width: 0, height: 0,
2729
+ left: 0, top: 0
2730
+ } );
2731
+ }
2732
+ }
2733
+
2734
+ },
2735
+
2736
+ refreshPositions: function( fast ) {
2737
+
2738
+ // Determine whether items are being displayed horizontally
2739
+ this.floating = this.items.length ?
2740
+ this.options.axis === "x" || this._isFloating( this.items[ 0 ].item ) :
2741
+ false;
2742
+
2743
+ //This has to be redone because due to the item being moved out/into the offsetParent,
2744
+ // the offsetParent's position will change
2745
+ if ( this.offsetParent && this.helper ) {
2746
+ this.offset.parent = this._getParentOffset();
2747
+ }
2748
+
2749
+ var i, item, t, p;
2750
+
2751
+ for ( i = this.items.length - 1; i >= 0; i-- ) {
2752
+ item = this.items[ i ];
2753
+
2754
+ //We ignore calculating positions of all connected containers when we're not over them
2755
+ if ( item.instance !== this.currentContainer && this.currentContainer &&
2756
+ item.item[ 0 ] !== this.currentItem[ 0 ] ) {
2757
+ continue;
2758
+ }
2759
+
2760
+ t = this.options.toleranceElement ?
2761
+ $( this.options.toleranceElement, item.item ) :
2762
+ item.item;
2763
+
2764
+ if ( !fast ) {
2765
+ item.width = t.outerWidth();
2766
+ item.height = t.outerHeight();
2767
+ }
2768
+
2769
+ p = t.offset();
2770
+ item.left = p.left;
2771
+ item.top = p.top;
2772
+ }
2773
+
2774
+ if ( this.options.custom && this.options.custom.refreshContainers ) {
2775
+ this.options.custom.refreshContainers.call( this );
2776
+ } else {
2777
+ for ( i = this.containers.length - 1; i >= 0; i-- ) {
2778
+ p = this.containers[ i ].element.offset();
2779
+ this.containers[ i ].containerCache.left = p.left;
2780
+ this.containers[ i ].containerCache.top = p.top;
2781
+ this.containers[ i ].containerCache.width =
2782
+ this.containers[ i ].element.outerWidth();
2783
+ this.containers[ i ].containerCache.height =
2784
+ this.containers[ i ].element.outerHeight();
2785
+ }
2786
+ }
2787
+
2788
+ return this;
2789
+ },
2790
+
2791
+ _createPlaceholder: function( that ) {
2792
+ that = that || this;
2793
+ var className,
2794
+ o = that.options;
2795
+
2796
+ if ( !o.placeholder || o.placeholder.constructor === String ) {
2797
+ className = o.placeholder;
2798
+ o.placeholder = {
2799
+ element: function() {
2800
+
2801
+ var nodeName = that.currentItem[ 0 ].nodeName.toLowerCase(),
2802
+ element = $( "<" + nodeName + ">", that.document[ 0 ] );
2803
+
2804
+ that._addClass( element, "ui-sortable-placeholder",
2805
+ className || that.currentItem[ 0 ].className )
2806
+ ._removeClass( element, "ui-sortable-helper" );
2807
+
2808
+ if ( nodeName === "tbody" ) {
2809
+ that._createTrPlaceholder(
2810
+ that.currentItem.find( "tr" ).eq( 0 ),
2811
+ $( "<tr>", that.document[ 0 ] ).appendTo( element )
2812
+ );
2813
+ } else if ( nodeName === "tr" ) {
2814
+ that._createTrPlaceholder( that.currentItem, element );
2815
+ } else if ( nodeName === "img" ) {
2816
+ element.attr( "src", that.currentItem.attr( "src" ) );
2817
+ }
2818
+
2819
+ if ( !className ) {
2820
+ element.css( "visibility", "hidden" );
2821
+ }
2822
+
2823
+ return element;
2824
+ },
2825
+ update: function( container, p ) {
2826
+
2827
+ // 1. If a className is set as 'placeholder option, we don't force sizes -
2828
+ // the class is responsible for that
2829
+ // 2. The option 'forcePlaceholderSize can be enabled to force it even if a
2830
+ // class name is specified
2831
+ if ( className && !o.forcePlaceholderSize ) {
2832
+ return;
2833
+ }
2834
+
2835
+ //If the element doesn't have a actual height by itself (without styles coming
2836
+ // from a stylesheet), it receives the inline height from the dragged item
2837
+ if ( !p.height() ) {
2838
+ p.height(
2839
+ that.currentItem.innerHeight() -
2840
+ parseInt( that.currentItem.css( "paddingTop" ) || 0, 10 ) -
2841
+ parseInt( that.currentItem.css( "paddingBottom" ) || 0, 10 ) );
2842
+ }
2843
+ if ( !p.width() ) {
2844
+ p.width(
2845
+ that.currentItem.innerWidth() -
2846
+ parseInt( that.currentItem.css( "paddingLeft" ) || 0, 10 ) -
2847
+ parseInt( that.currentItem.css( "paddingRight" ) || 0, 10 ) );
2848
+ }
2849
+ }
2850
+ };
2851
+ }
2852
+
2853
+ //Create the placeholder
2854
+ that.placeholder = $( o.placeholder.element.call( that.element, that.currentItem ) );
2855
+
2856
+ //Append it after the actual current item
2857
+ that.currentItem.after( that.placeholder );
2858
+
2859
+ //Update the size of the placeholder (TODO: Logic to fuzzy, see line 316/317)
2860
+ o.placeholder.update( that, that.placeholder );
2861
+
2862
+ },
2863
+
2864
+ _createTrPlaceholder: function( sourceTr, targetTr ) {
2865
+ var that = this;
2866
+
2867
+ sourceTr.children().each( function() {
2868
+ $( "<td>&#160;</td>", that.document[ 0 ] )
2869
+ .attr( "colspan", $( this ).attr( "colspan" ) || 1 )
2870
+ .appendTo( targetTr );
2871
+ } );
2872
+ },
2873
+
2874
+ _contactContainers: function( event ) {
2875
+ var i, j, dist, itemWithLeastDistance, posProperty, sizeProperty, cur, nearBottom,
2876
+ floating, axis,
2877
+ innermostContainer = null,
2878
+ innermostIndex = null;
2879
+
2880
+ // Get innermost container that intersects with item
2881
+ for ( i = this.containers.length - 1; i >= 0; i-- ) {
2882
+
2883
+ // Never consider a container that's located within the item itself
2884
+ if ( $.contains( this.currentItem[ 0 ], this.containers[ i ].element[ 0 ] ) ) {
2885
+ continue;
2886
+ }
2887
+
2888
+ if ( this._intersectsWith( this.containers[ i ].containerCache ) ) {
2889
+
2890
+ // If we've already found a container and it's more "inner" than this, then continue
2891
+ if ( innermostContainer &&
2892
+ $.contains(
2893
+ this.containers[ i ].element[ 0 ],
2894
+ innermostContainer.element[ 0 ] ) ) {
2895
+ continue;
2896
+ }
2897
+
2898
+ innermostContainer = this.containers[ i ];
2899
+ innermostIndex = i;
2900
+
2901
+ } else {
2902
+
2903
+ // container doesn't intersect. trigger "out" event if necessary
2904
+ if ( this.containers[ i ].containerCache.over ) {
2905
+ this.containers[ i ]._trigger( "out", event, this._uiHash( this ) );
2906
+ this.containers[ i ].containerCache.over = 0;
2907
+ }
2908
+ }
2909
+
2910
+ }
2911
+
2912
+ // If no intersecting containers found, return
2913
+ if ( !innermostContainer ) {
2914
+ return;
2915
+ }
2916
+
2917
+ // Move the item into the container if it's not there already
2918
+ if ( this.containers.length === 1 ) {
2919
+ if ( !this.containers[ innermostIndex ].containerCache.over ) {
2920
+ this.containers[ innermostIndex ]._trigger( "over", event, this._uiHash( this ) );
2921
+ this.containers[ innermostIndex ].containerCache.over = 1;
2922
+ }
2923
+ } else {
2924
+
2925
+ // When entering a new container, we will find the item with the least distance and
2926
+ // append our item near it
2927
+ dist = 10000;
2928
+ itemWithLeastDistance = null;
2929
+ floating = innermostContainer.floating || this._isFloating( this.currentItem );
2930
+ posProperty = floating ? "left" : "top";
2931
+ sizeProperty = floating ? "width" : "height";
2932
+ axis = floating ? "pageX" : "pageY";
2933
+
2934
+ for ( j = this.items.length - 1; j >= 0; j-- ) {
2935
+ if ( !$.contains(
2936
+ this.containers[ innermostIndex ].element[ 0 ], this.items[ j ].item[ 0 ] )
2937
+ ) {
2938
+ continue;
2939
+ }
2940
+ if ( this.items[ j ].item[ 0 ] === this.currentItem[ 0 ] ) {
2941
+ continue;
2942
+ }
2943
+
2944
+ cur = this.items[ j ].item.offset()[ posProperty ];
2945
+ nearBottom = false;
2946
+ if ( event[ axis ] - cur > this.items[ j ][ sizeProperty ] / 2 ) {
2947
+ nearBottom = true;
2948
+ }
2949
+
2950
+ if ( Math.abs( event[ axis ] - cur ) < dist ) {
2951
+ dist = Math.abs( event[ axis ] - cur );
2952
+ itemWithLeastDistance = this.items[ j ];
2953
+ this.direction = nearBottom ? "up" : "down";
2954
+ }
2955
+ }
2956
+
2957
+ //Check if dropOnEmpty is enabled
2958
+ if ( !itemWithLeastDistance && !this.options.dropOnEmpty ) {
2959
+ return;
2960
+ }
2961
+
2962
+ if ( this.currentContainer === this.containers[ innermostIndex ] ) {
2963
+ if ( !this.currentContainer.containerCache.over ) {
2964
+ this.containers[ innermostIndex ]._trigger( "over", event, this._uiHash() );
2965
+ this.currentContainer.containerCache.over = 1;
2966
+ }
2967
+ return;
2968
+ }
2969
+
2970
+ itemWithLeastDistance ?
2971
+ this._rearrange( event, itemWithLeastDistance, null, true ) :
2972
+ this._rearrange( event, null, this.containers[ innermostIndex ].element, true );
2973
+ this._trigger( "change", event, this._uiHash() );
2974
+ this.containers[ innermostIndex ]._trigger( "change", event, this._uiHash( this ) );
2975
+ this.currentContainer = this.containers[ innermostIndex ];
2976
+
2977
+ //Update the placeholder
2978
+ this.options.placeholder.update( this.currentContainer, this.placeholder );
2979
+
2980
+ this.containers[ innermostIndex ]._trigger( "over", event, this._uiHash( this ) );
2981
+ this.containers[ innermostIndex ].containerCache.over = 1;
2982
+ }
2983
+
2984
+ },
2985
+
2986
+ _createHelper: function( event ) {
2987
+
2988
+ var o = this.options,
2989
+ helper = $.isFunction( o.helper ) ?
2990
+ $( o.helper.apply( this.element[ 0 ], [ event, this.currentItem ] ) ) :
2991
+ ( o.helper === "clone" ? this.currentItem.clone() : this.currentItem );
2992
+
2993
+ //Add the helper to the DOM if that didn't happen already
2994
+ if ( !helper.parents( "body" ).length ) {
2995
+ $( o.appendTo !== "parent" ?
2996
+ o.appendTo :
2997
+ this.currentItem[ 0 ].parentNode )[ 0 ].appendChild( helper[ 0 ] );
2998
+ }
2999
+
3000
+ if ( helper[ 0 ] === this.currentItem[ 0 ] ) {
3001
+ this._storedCSS = {
3002
+ width: this.currentItem[ 0 ].style.width,
3003
+ height: this.currentItem[ 0 ].style.height,
3004
+ position: this.currentItem.css( "position" ),
3005
+ top: this.currentItem.css( "top" ),
3006
+ left: this.currentItem.css( "left" )
3007
+ };
3008
+ }
3009
+
3010
+ if ( !helper[ 0 ].style.width || o.forceHelperSize ) {
3011
+ helper.width( this.currentItem.width() );
3012
+ }
3013
+ if ( !helper[ 0 ].style.height || o.forceHelperSize ) {
3014
+ helper.height( this.currentItem.height() );
3015
+ }
3016
+
3017
+ return helper;
3018
+
3019
+ },
3020
+
3021
+ _adjustOffsetFromHelper: function( obj ) {
3022
+ if ( typeof obj === "string" ) {
3023
+ obj = obj.split( " " );
3024
+ }
3025
+ if ( $.isArray( obj ) ) {
3026
+ obj = { left: +obj[ 0 ], top: +obj[ 1 ] || 0 };
3027
+ }
3028
+ if ( "left" in obj ) {
3029
+ this.offset.click.left = obj.left + this.margins.left;
3030
+ }
3031
+ if ( "right" in obj ) {
3032
+ this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
3033
+ }
3034
+ if ( "top" in obj ) {
3035
+ this.offset.click.top = obj.top + this.margins.top;
3036
+ }
3037
+ if ( "bottom" in obj ) {
3038
+ this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
3039
+ }
3040
+ },
3041
+
3042
+ _getParentOffset: function() {
3043
+
3044
+ //Get the offsetParent and cache its position
3045
+ this.offsetParent = this.helper.offsetParent();
3046
+ var po = this.offsetParent.offset();
3047
+
3048
+ // This is a special case where we need to modify a offset calculated on start, since the
3049
+ // following happened:
3050
+ // 1. The position of the helper is absolute, so it's position is calculated based on the
3051
+ // next positioned parent
3052
+ // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't
3053
+ // the document, which means that the scroll is included in the initial calculation of the
3054
+ // offset of the parent, and never recalculated upon drag
3055
+ if ( this.cssPosition === "absolute" && this.scrollParent[ 0 ] !== this.document[ 0 ] &&
3056
+ $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) {
3057
+ po.left += this.scrollParent.scrollLeft();
3058
+ po.top += this.scrollParent.scrollTop();
3059
+ }
3060
+
3061
+ // This needs to be actually done for all browsers, since pageX/pageY includes this
3062
+ // information with an ugly IE fix
3063
+ if ( this.offsetParent[ 0 ] === this.document[ 0 ].body ||
3064
+ ( this.offsetParent[ 0 ].tagName &&
3065
+ this.offsetParent[ 0 ].tagName.toLowerCase() === "html" && $.ui.ie ) ) {
3066
+ po = { top: 0, left: 0 };
3067
+ }
3068
+
3069
+ return {
3070
+ top: po.top + ( parseInt( this.offsetParent.css( "borderTopWidth" ), 10 ) || 0 ),
3071
+ left: po.left + ( parseInt( this.offsetParent.css( "borderLeftWidth" ), 10 ) || 0 )
3072
+ };
3073
+
3074
+ },
3075
+
3076
+ _getRelativeOffset: function() {
3077
+
3078
+ if ( this.cssPosition === "relative" ) {
3079
+ var p = this.currentItem.position();
3080
+ return {
3081
+ top: p.top - ( parseInt( this.helper.css( "top" ), 10 ) || 0 ) +
3082
+ this.scrollParent.scrollTop(),
3083
+ left: p.left - ( parseInt( this.helper.css( "left" ), 10 ) || 0 ) +
3084
+ this.scrollParent.scrollLeft()
3085
+ };
3086
+ } else {
3087
+ return { top: 0, left: 0 };
3088
+ }
3089
+
3090
+ },
3091
+
3092
+ _cacheMargins: function() {
3093
+ this.margins = {
3094
+ left: ( parseInt( this.currentItem.css( "marginLeft" ), 10 ) || 0 ),
3095
+ top: ( parseInt( this.currentItem.css( "marginTop" ), 10 ) || 0 )
3096
+ };
3097
+ },
3098
+
3099
+ _cacheHelperProportions: function() {
3100
+ this.helperProportions = {
3101
+ width: this.helper.outerWidth(),
3102
+ height: this.helper.outerHeight()
3103
+ };
3104
+ },
3105
+
3106
+ _setContainment: function() {
3107
+
3108
+ var ce, co, over,
3109
+ o = this.options;
3110
+ if ( o.containment === "parent" ) {
3111
+ o.containment = this.helper[ 0 ].parentNode;
3112
+ }
3113
+ if ( o.containment === "document" || o.containment === "window" ) {
3114
+ this.containment = [
3115
+ 0 - this.offset.relative.left - this.offset.parent.left,
3116
+ 0 - this.offset.relative.top - this.offset.parent.top,
3117
+ o.containment === "document" ?
3118
+ this.document.width() :
3119
+ this.window.width() - this.helperProportions.width - this.margins.left,
3120
+ ( o.containment === "document" ?
3121
+ ( this.document.height() || document.body.parentNode.scrollHeight ) :
3122
+ this.window.height() || this.document[ 0 ].body.parentNode.scrollHeight
3123
+ ) - this.helperProportions.height - this.margins.top
3124
+ ];
3125
+ }
3126
+
3127
+ if ( !( /^(document|window|parent)$/ ).test( o.containment ) ) {
3128
+ ce = $( o.containment )[ 0 ];
3129
+ co = $( o.containment ).offset();
3130
+ over = ( $( ce ).css( "overflow" ) !== "hidden" );
3131
+
3132
+ this.containment = [
3133
+ co.left + ( parseInt( $( ce ).css( "borderLeftWidth" ), 10 ) || 0 ) +
3134
+ ( parseInt( $( ce ).css( "paddingLeft" ), 10 ) || 0 ) - this.margins.left,
3135
+ co.top + ( parseInt( $( ce ).css( "borderTopWidth" ), 10 ) || 0 ) +
3136
+ ( parseInt( $( ce ).css( "paddingTop" ), 10 ) || 0 ) - this.margins.top,
3137
+ co.left + ( over ? Math.max( ce.scrollWidth, ce.offsetWidth ) : ce.offsetWidth ) -
3138
+ ( parseInt( $( ce ).css( "borderLeftWidth" ), 10 ) || 0 ) -
3139
+ ( parseInt( $( ce ).css( "paddingRight" ), 10 ) || 0 ) -
3140
+ this.helperProportions.width - this.margins.left,
3141
+ co.top + ( over ? Math.max( ce.scrollHeight, ce.offsetHeight ) : ce.offsetHeight ) -
3142
+ ( parseInt( $( ce ).css( "borderTopWidth" ), 10 ) || 0 ) -
3143
+ ( parseInt( $( ce ).css( "paddingBottom" ), 10 ) || 0 ) -
3144
+ this.helperProportions.height - this.margins.top
3145
+ ];
3146
+ }
3147
+
3148
+ },
3149
+
3150
+ _convertPositionTo: function( d, pos ) {
3151
+
3152
+ if ( !pos ) {
3153
+ pos = this.position;
3154
+ }
3155
+ var mod = d === "absolute" ? 1 : -1,
3156
+ scroll = this.cssPosition === "absolute" &&
3157
+ !( this.scrollParent[ 0 ] !== this.document[ 0 ] &&
3158
+ $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) ?
3159
+ this.offsetParent :
3160
+ this.scrollParent,
3161
+ scrollIsRootNode = ( /(html|body)/i ).test( scroll[ 0 ].tagName );
3162
+
3163
+ return {
3164
+ top: (
3165
+
3166
+ // The absolute mouse position
3167
+ pos.top +
3168
+
3169
+ // Only for relative positioned nodes: Relative offset from element to offset parent
3170
+ this.offset.relative.top * mod +
3171
+
3172
+ // The offsetParent's offset without borders (offset + border)
3173
+ this.offset.parent.top * mod -
3174
+ ( ( this.cssPosition === "fixed" ?
3175
+ -this.scrollParent.scrollTop() :
3176
+ ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod )
3177
+ ),
3178
+ left: (
3179
+
3180
+ // The absolute mouse position
3181
+ pos.left +
3182
+
3183
+ // Only for relative positioned nodes: Relative offset from element to offset parent
3184
+ this.offset.relative.left * mod +
3185
+
3186
+ // The offsetParent's offset without borders (offset + border)
3187
+ this.offset.parent.left * mod -
3188
+ ( ( this.cssPosition === "fixed" ?
3189
+ -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 :
3190
+ scroll.scrollLeft() ) * mod )
3191
+ )
3192
+ };
3193
+
3194
+ },
3195
+
3196
+ _generatePosition: function( event ) {
3197
+
3198
+ var top, left,
3199
+ o = this.options,
3200
+ pageX = event.pageX,
3201
+ pageY = event.pageY,
3202
+ scroll = this.cssPosition === "absolute" &&
3203
+ !( this.scrollParent[ 0 ] !== this.document[ 0 ] &&
3204
+ $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) ?
3205
+ this.offsetParent :
3206
+ this.scrollParent,
3207
+ scrollIsRootNode = ( /(html|body)/i ).test( scroll[ 0 ].tagName );
3208
+
3209
+ // This is another very weird special case that only happens for relative elements:
3210
+ // 1. If the css position is relative
3211
+ // 2. and the scroll parent is the document or similar to the offset parent
3212
+ // we have to refresh the relative offset during the scroll so there are no jumps
3213
+ if ( this.cssPosition === "relative" && !( this.scrollParent[ 0 ] !== this.document[ 0 ] &&
3214
+ this.scrollParent[ 0 ] !== this.offsetParent[ 0 ] ) ) {
3215
+ this.offset.relative = this._getRelativeOffset();
3216
+ }
3217
+
3218
+ /*
3219
+ * - Position constraining -
3220
+ * Constrain the position to a mix of grid, containment.
3221
+ */
3222
+
3223
+ if ( this.originalPosition ) { //If we are not dragging yet, we won't check for options
3224
+
3225
+ if ( this.containment ) {
3226
+ if ( event.pageX - this.offset.click.left < this.containment[ 0 ] ) {
3227
+ pageX = this.containment[ 0 ] + this.offset.click.left;
3228
+ }
3229
+ if ( event.pageY - this.offset.click.top < this.containment[ 1 ] ) {
3230
+ pageY = this.containment[ 1 ] + this.offset.click.top;
3231
+ }
3232
+ if ( event.pageX - this.offset.click.left > this.containment[ 2 ] ) {
3233
+ pageX = this.containment[ 2 ] + this.offset.click.left;
3234
+ }
3235
+ if ( event.pageY - this.offset.click.top > this.containment[ 3 ] ) {
3236
+ pageY = this.containment[ 3 ] + this.offset.click.top;
3237
+ }
3238
+ }
3239
+
3240
+ if ( o.grid ) {
3241
+ top = this.originalPageY + Math.round( ( pageY - this.originalPageY ) /
3242
+ o.grid[ 1 ] ) * o.grid[ 1 ];
3243
+ pageY = this.containment ?
3244
+ ( ( top - this.offset.click.top >= this.containment[ 1 ] &&
3245
+ top - this.offset.click.top <= this.containment[ 3 ] ) ?
3246
+ top :
3247
+ ( ( top - this.offset.click.top >= this.containment[ 1 ] ) ?
3248
+ top - o.grid[ 1 ] : top + o.grid[ 1 ] ) ) :
3249
+ top;
3250
+
3251
+ left = this.originalPageX + Math.round( ( pageX - this.originalPageX ) /
3252
+ o.grid[ 0 ] ) * o.grid[ 0 ];
3253
+ pageX = this.containment ?
3254
+ ( ( left - this.offset.click.left >= this.containment[ 0 ] &&
3255
+ left - this.offset.click.left <= this.containment[ 2 ] ) ?
3256
+ left :
3257
+ ( ( left - this.offset.click.left >= this.containment[ 0 ] ) ?
3258
+ left - o.grid[ 0 ] : left + o.grid[ 0 ] ) ) :
3259
+ left;
3260
+ }
3261
+
3262
+ }
3263
+
3264
+ return {
3265
+ top: (
3266
+
3267
+ // The absolute mouse position
3268
+ pageY -
3269
+
3270
+ // Click offset (relative to the element)
3271
+ this.offset.click.top -
3272
+
3273
+ // Only for relative positioned nodes: Relative offset from element to offset parent
3274
+ this.offset.relative.top -
3275
+
3276
+ // The offsetParent's offset without borders (offset + border)
3277
+ this.offset.parent.top +
3278
+ ( ( this.cssPosition === "fixed" ?
3279
+ -this.scrollParent.scrollTop() :
3280
+ ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) )
3281
+ ),
3282
+ left: (
3283
+
3284
+ // The absolute mouse position
3285
+ pageX -
3286
+
3287
+ // Click offset (relative to the element)
3288
+ this.offset.click.left -
3289
+
3290
+ // Only for relative positioned nodes: Relative offset from element to offset parent
3291
+ this.offset.relative.left -
3292
+
3293
+ // The offsetParent's offset without borders (offset + border)
3294
+ this.offset.parent.left +
3295
+ ( ( this.cssPosition === "fixed" ?
3296
+ -this.scrollParent.scrollLeft() :
3297
+ scrollIsRootNode ? 0 : scroll.scrollLeft() ) )
3298
+ )
3299
+ };
3300
+
3301
+ },
3302
+
3303
+ _rearrange: function( event, i, a, hardRefresh ) {
3304
+
3305
+ a ? a[ 0 ].appendChild( this.placeholder[ 0 ] ) :
3306
+ i.item[ 0 ].parentNode.insertBefore( this.placeholder[ 0 ],
3307
+ ( this.direction === "down" ? i.item[ 0 ] : i.item[ 0 ].nextSibling ) );
3308
+
3309
+ //Various things done here to improve the performance:
3310
+ // 1. we create a setTimeout, that calls refreshPositions
3311
+ // 2. on the instance, we have a counter variable, that get's higher after every append
3312
+ // 3. on the local scope, we copy the counter variable, and check in the timeout,
3313
+ // if it's still the same
3314
+ // 4. this lets only the last addition to the timeout stack through
3315
+ this.counter = this.counter ? ++this.counter : 1;
3316
+ var counter = this.counter;
3317
+
3318
+ this._delay( function() {
3319
+ if ( counter === this.counter ) {
3320
+
3321
+ //Precompute after each DOM insertion, NOT on mousemove
3322
+ this.refreshPositions( !hardRefresh );
3323
+ }
3324
+ } );
3325
+
3326
+ },
3327
+
3328
+ _clear: function( event, noPropagation ) {
3329
+
3330
+ this.reverting = false;
3331
+
3332
+ // We delay all events that have to be triggered to after the point where the placeholder
3333
+ // has been removed and everything else normalized again
3334
+ var i,
3335
+ delayedTriggers = [];
3336
+
3337
+ // We first have to update the dom position of the actual currentItem
3338
+ // Note: don't do it if the current item is already removed (by a user), or it gets
3339
+ // reappended (see #4088)
3340
+ if ( !this._noFinalSort && this.currentItem.parent().length ) {
3341
+ this.placeholder.before( this.currentItem );
3342
+ }
3343
+ this._noFinalSort = null;
3344
+
3345
+ if ( this.helper[ 0 ] === this.currentItem[ 0 ] ) {
3346
+ for ( i in this._storedCSS ) {
3347
+ if ( this._storedCSS[ i ] === "auto" || this._storedCSS[ i ] === "static" ) {
3348
+ this._storedCSS[ i ] = "";
3349
+ }
3350
+ }
3351
+ this.currentItem.css( this._storedCSS );
3352
+ this._removeClass( this.currentItem, "ui-sortable-helper" );
3353
+ } else {
3354
+ this.currentItem.show();
3355
+ }
3356
+
3357
+ if ( this.fromOutside && !noPropagation ) {
3358
+ delayedTriggers.push( function( event ) {
3359
+ this._trigger( "receive", event, this._uiHash( this.fromOutside ) );
3360
+ } );
3361
+ }
3362
+ if ( ( this.fromOutside ||
3363
+ this.domPosition.prev !==
3364
+ this.currentItem.prev().not( ".ui-sortable-helper" )[ 0 ] ||
3365
+ this.domPosition.parent !== this.currentItem.parent()[ 0 ] ) && !noPropagation ) {
3366
+
3367
+ // Trigger update callback if the DOM position has changed
3368
+ delayedTriggers.push( function( event ) {
3369
+ this._trigger( "update", event, this._uiHash() );
3370
+ } );
3371
+ }
3372
+
3373
+ // Check if the items Container has Changed and trigger appropriate
3374
+ // events.
3375
+ if ( this !== this.currentContainer ) {
3376
+ if ( !noPropagation ) {
3377
+ delayedTriggers.push( function( event ) {
3378
+ this._trigger( "remove", event, this._uiHash() );
3379
+ } );
3380
+ delayedTriggers.push( ( function( c ) {
3381
+ return function( event ) {
3382
+ c._trigger( "receive", event, this._uiHash( this ) );
3383
+ };
3384
+ } ).call( this, this.currentContainer ) );
3385
+ delayedTriggers.push( ( function( c ) {
3386
+ return function( event ) {
3387
+ c._trigger( "update", event, this._uiHash( this ) );
3388
+ };
3389
+ } ).call( this, this.currentContainer ) );
3390
+ }
3391
+ }
3392
+
3393
+ //Post events to containers
3394
+ function delayEvent( type, instance, container ) {
3395
+ return function( event ) {
3396
+ container._trigger( type, event, instance._uiHash( instance ) );
3397
+ };
3398
+ }
3399
+ for ( i = this.containers.length - 1; i >= 0; i-- ) {
3400
+ if ( !noPropagation ) {
3401
+ delayedTriggers.push( delayEvent( "deactivate", this, this.containers[ i ] ) );
3402
+ }
3403
+ if ( this.containers[ i ].containerCache.over ) {
3404
+ delayedTriggers.push( delayEvent( "out", this, this.containers[ i ] ) );
3405
+ this.containers[ i ].containerCache.over = 0;
3406
+ }
3407
+ }
3408
+
3409
+ //Do what was originally in plugins
3410
+ if ( this.storedCursor ) {
3411
+ this.document.find( "body" ).css( "cursor", this.storedCursor );
3412
+ this.storedStylesheet.remove();
3413
+ }
3414
+ if ( this._storedOpacity ) {
3415
+ this.helper.css( "opacity", this._storedOpacity );
3416
+ }
3417
+ if ( this._storedZIndex ) {
3418
+ this.helper.css( "zIndex", this._storedZIndex === "auto" ? "" : this._storedZIndex );
3419
+ }
3420
+
3421
+ this.dragging = false;
3422
+
3423
+ if ( !noPropagation ) {
3424
+ this._trigger( "beforeStop", event, this._uiHash() );
3425
+ }
3426
+
3427
+ //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately,
3428
+ // it unbinds ALL events from the original node!
3429
+ this.placeholder[ 0 ].parentNode.removeChild( this.placeholder[ 0 ] );
3430
+
3431
+ if ( !this.cancelHelperRemoval ) {
3432
+ if ( this.helper[ 0 ] !== this.currentItem[ 0 ] ) {
3433
+ this.helper.remove();
3434
+ }
3435
+ this.helper = null;
3436
+ }
3437
+
3438
+ if ( !noPropagation ) {
3439
+ for ( i = 0; i < delayedTriggers.length; i++ ) {
3440
+
3441
+ // Trigger all delayed events
3442
+ delayedTriggers[ i ].call( this, event );
3443
+ }
3444
+ this._trigger( "stop", event, this._uiHash() );
3445
+ }
3446
+
3447
+ this.fromOutside = false;
3448
+ return !this.cancelHelperRemoval;
3449
+
3450
+ },
3451
+
3452
+ _trigger: function() {
3453
+ if ( $.Widget.prototype._trigger.apply( this, arguments ) === false ) {
3454
+ this.cancel();
3455
+ }
3456
+ },
3457
+
3458
+ _uiHash: function( _inst ) {
3459
+ var inst = _inst || this;
3460
+ return {
3461
+ helper: inst.helper,
3462
+ placeholder: inst.placeholder || $( [] ),
3463
+ position: inst.position,
3464
+ originalPosition: inst.originalPosition,
3465
+ offset: inst.positionAbs,
3466
+ item: inst.currentItem,
3467
+ sender: _inst ? _inst.element : null
3468
+ };
3469
+ }
3470
+
3471
+ } );
3472
+
3473
+
3474
+
3475
+
3476
+ }));