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