個人ページに期毎打撃成績を追加。
@@ -0,0 +1,18626 @@ | ||
1 | +/*! jQuery UI - v1.12.0-rc.2 - 2016-04-21 | |
2 | +* http://jqueryui.com | |
3 | +* Includes: widget.js, position.js, data.js, disable-selection.js, effect.js, effects/effect-blind.js, effects/effect-bounce.js, effects/effect-clip.js, effects/effect-drop.js, effects/effect-explode.js, effects/effect-fade.js, effects/effect-fold.js, effects/effect-highlight.js, effects/effect-puff.js, effects/effect-pulsate.js, effects/effect-scale.js, effects/effect-shake.js, effects/effect-size.js, effects/effect-slide.js, effects/effect-transfer.js, focusable.js, form-reset-mixin.js, jquery-1-7.js, keycode.js, labels.js, scroll-parent.js, tabbable.js, unique-id.js, widgets/accordion.js, widgets/autocomplete.js, widgets/button.js, widgets/checkboxradio.js, widgets/controlgroup.js, widgets/datepicker.js, widgets/dialog.js, widgets/draggable.js, widgets/droppable.js, widgets/menu.js, widgets/mouse.js, widgets/progressbar.js, widgets/resizable.js, widgets/selectable.js, widgets/selectmenu.js, widgets/slider.js, widgets/sortable.js, widgets/spinner.js, widgets/tabs.js, widgets/tooltip.js | |
4 | +* Copyright jQuery Foundation and other contributors; Licensed MIT */ | |
5 | + | |
6 | +(function( factory ) { | |
7 | + if ( typeof define === "function" && define.amd ) { | |
8 | + | |
9 | + // AMD. Register as an anonymous module. | |
10 | + define([ "jquery" ], factory ); | |
11 | + } else { | |
12 | + | |
13 | + // Browser globals | |
14 | + factory( jQuery ); | |
15 | + } | |
16 | +}(function( $ ) { | |
17 | + | |
18 | +$.ui = $.ui || {}; | |
19 | + | |
20 | +var version = $.ui.version = "1.12.0-rc.2"; | |
21 | + | |
22 | + | |
23 | +/*! | |
24 | + * jQuery UI Widget 1.12.0-rc.2 | |
25 | + * http://jqueryui.com | |
26 | + * | |
27 | + * Copyright jQuery Foundation and other contributors | |
28 | + * Released under the MIT license. | |
29 | + * http://jquery.org/license | |
30 | + */ | |
31 | + | |
32 | +//>>label: Widget | |
33 | +//>>group: Core | |
34 | +//>>description: Provides a factory for creating stateful widgets with a common API. | |
35 | +//>>docs: http://api.jqueryui.com/jQuery.widget/ | |
36 | +//>>demos: http://jqueryui.com/widget/ | |
37 | + | |
38 | + | |
39 | + | |
40 | +var widgetUuid = 0; | |
41 | +var widgetSlice = Array.prototype.slice; | |
42 | + | |
43 | +$.cleanData = ( function( orig ) { | |
44 | + return function( elems ) { | |
45 | + var events, elem, i; | |
46 | + for ( i = 0; ( elem = elems[ i ] ) != null; i++ ) { | |
47 | + try { | |
48 | + | |
49 | + // Only trigger remove when necessary to save time | |
50 | + events = $._data( elem, "events" ); | |
51 | + if ( events && events.remove ) { | |
52 | + $( elem ).triggerHandler( "remove" ); | |
53 | + } | |
54 | + | |
55 | + // Http://bugs.jquery.com/ticket/8235 | |
56 | + } catch ( e ) {} | |
57 | + } | |
58 | + orig( elems ); | |
59 | + }; | |
60 | +} )( $.cleanData ); | |
61 | + | |
62 | +$.widget = function( name, base, prototype ) { | |
63 | + var existingConstructor, constructor, basePrototype; | |
64 | + | |
65 | + // ProxiedPrototype allows the provided prototype to remain unmodified | |
66 | + // so that it can be used as a mixin for multiple widgets (#8876) | |
67 | + var proxiedPrototype = {}; | |
68 | + | |
69 | + var namespace = name.split( "." )[ 0 ]; | |
70 | + name = name.split( "." )[ 1 ]; | |
71 | + var fullName = namespace + "-" + name; | |
72 | + | |
73 | + if ( !prototype ) { | |
74 | + prototype = base; | |
75 | + base = $.Widget; | |
76 | + } | |
77 | + | |
78 | + if ( $.isArray( prototype ) ) { | |
79 | + prototype = $.extend.apply( null, [ {} ].concat( prototype ) ); | |
80 | + } | |
81 | + | |
82 | + // Create selector for plugin | |
83 | + $.expr[ ":" ][ fullName.toLowerCase() ] = function( elem ) { | |
84 | + return !!$.data( elem, fullName ); | |
85 | + }; | |
86 | + | |
87 | + $[ namespace ] = $[ namespace ] || {}; | |
88 | + existingConstructor = $[ namespace ][ name ]; | |
89 | + constructor = $[ namespace ][ name ] = function( options, element ) { | |
90 | + | |
91 | + // Allow instantiation without "new" keyword | |
92 | + if ( !this._createWidget ) { | |
93 | + return new constructor( options, element ); | |
94 | + } | |
95 | + | |
96 | + // Allow instantiation without initializing for simple inheritance | |
97 | + // must use "new" keyword (the code above always passes args) | |
98 | + if ( arguments.length ) { | |
99 | + this._createWidget( options, element ); | |
100 | + } | |
101 | + }; | |
102 | + | |
103 | + // Extend with the existing constructor to carry over any static properties | |
104 | + $.extend( constructor, existingConstructor, { | |
105 | + version: prototype.version, | |
106 | + | |
107 | + // Copy the object used to create the prototype in case we need to | |
108 | + // redefine the widget later | |
109 | + _proto: $.extend( {}, prototype ), | |
110 | + | |
111 | + // Track widgets that inherit from this widget in case this widget is | |
112 | + // redefined after a widget inherits from it | |
113 | + _childConstructors: [] | |
114 | + } ); | |
115 | + | |
116 | + basePrototype = new base(); | |
117 | + | |
118 | + // We need to make the options hash a property directly on the new instance | |
119 | + // otherwise we'll modify the options hash on the prototype that we're | |
120 | + // inheriting from | |
121 | + basePrototype.options = $.widget.extend( {}, basePrototype.options ); | |
122 | + $.each( prototype, function( prop, value ) { | |
123 | + if ( !$.isFunction( value ) ) { | |
124 | + proxiedPrototype[ prop ] = value; | |
125 | + return; | |
126 | + } | |
127 | + proxiedPrototype[ prop ] = ( function() { | |
128 | + function _super() { | |
129 | + return base.prototype[ prop ].apply( this, arguments ); | |
130 | + } | |
131 | + | |
132 | + function _superApply( args ) { | |
133 | + return base.prototype[ prop ].apply( this, args ); | |
134 | + } | |
135 | + | |
136 | + return function() { | |
137 | + var __super = this._super; | |
138 | + var __superApply = this._superApply; | |
139 | + var returnValue; | |
140 | + | |
141 | + this._super = _super; | |
142 | + this._superApply = _superApply; | |
143 | + | |
144 | + returnValue = value.apply( this, arguments ); | |
145 | + | |
146 | + this._super = __super; | |
147 | + this._superApply = __superApply; | |
148 | + | |
149 | + return returnValue; | |
150 | + }; | |
151 | + } )(); | |
152 | + } ); | |
153 | + constructor.prototype = $.widget.extend( basePrototype, { | |
154 | + | |
155 | + // TODO: remove support for widgetEventPrefix | |
156 | + // always use the name + a colon as the prefix, e.g., draggable:start | |
157 | + // don't prefix for widgets that aren't DOM-based | |
158 | + widgetEventPrefix: existingConstructor ? ( basePrototype.widgetEventPrefix || name ) : name | |
159 | + }, proxiedPrototype, { | |
160 | + constructor: constructor, | |
161 | + namespace: namespace, | |
162 | + widgetName: name, | |
163 | + widgetFullName: fullName | |
164 | + } ); | |
165 | + | |
166 | + // If this widget is being redefined then we need to find all widgets that | |
167 | + // are inheriting from it and redefine all of them so that they inherit from | |
168 | + // the new version of this widget. We're essentially trying to replace one | |
169 | + // level in the prototype chain. | |
170 | + if ( existingConstructor ) { | |
171 | + $.each( existingConstructor._childConstructors, function( i, child ) { | |
172 | + var childPrototype = child.prototype; | |
173 | + | |
174 | + // Redefine the child widget using the same prototype that was | |
175 | + // originally used, but inherit from the new version of the base | |
176 | + $.widget( childPrototype.namespace + "." + childPrototype.widgetName, constructor, | |
177 | + child._proto ); | |
178 | + } ); | |
179 | + | |
180 | + // Remove the list of existing child constructors from the old constructor | |
181 | + // so the old child constructors can be garbage collected | |
182 | + delete existingConstructor._childConstructors; | |
183 | + } else { | |
184 | + base._childConstructors.push( constructor ); | |
185 | + } | |
186 | + | |
187 | + $.widget.bridge( name, constructor ); | |
188 | + | |
189 | + return constructor; | |
190 | +}; | |
191 | + | |
192 | +$.widget.extend = function( target ) { | |
193 | + var input = widgetSlice.call( arguments, 1 ); | |
194 | + var inputIndex = 0; | |
195 | + var inputLength = input.length; | |
196 | + var key; | |
197 | + var value; | |
198 | + | |
199 | + for ( ; inputIndex < inputLength; inputIndex++ ) { | |
200 | + for ( key in input[ inputIndex ] ) { | |
201 | + value = input[ inputIndex ][ key ]; | |
202 | + if ( input[ inputIndex ].hasOwnProperty( key ) && value !== undefined ) { | |
203 | + | |
204 | + // Clone objects | |
205 | + if ( $.isPlainObject( value ) ) { | |
206 | + target[ key ] = $.isPlainObject( target[ key ] ) ? | |
207 | + $.widget.extend( {}, target[ key ], value ) : | |
208 | + | |
209 | + // Don't extend strings, arrays, etc. with objects | |
210 | + $.widget.extend( {}, value ); | |
211 | + | |
212 | + // Copy everything else by reference | |
213 | + } else { | |
214 | + target[ key ] = value; | |
215 | + } | |
216 | + } | |
217 | + } | |
218 | + } | |
219 | + return target; | |
220 | +}; | |
221 | + | |
222 | +$.widget.bridge = function( name, object ) { | |
223 | + var fullName = object.prototype.widgetFullName || name; | |
224 | + $.fn[ name ] = function( options ) { | |
225 | + var isMethodCall = typeof options === "string"; | |
226 | + var args = widgetSlice.call( arguments, 1 ); | |
227 | + var returnValue = this; | |
228 | + | |
229 | + if ( isMethodCall ) { | |
230 | + this.each( function() { | |
231 | + var methodValue; | |
232 | + var instance = $.data( this, fullName ); | |
233 | + | |
234 | + if ( options === "instance" ) { | |
235 | + returnValue = instance; | |
236 | + return false; | |
237 | + } | |
238 | + | |
239 | + if ( !instance ) { | |
240 | + return $.error( "cannot call methods on " + name + | |
241 | + " prior to initialization; " + | |
242 | + "attempted to call method '" + options + "'" ); | |
243 | + } | |
244 | + | |
245 | + if ( !$.isFunction( instance[ options ] ) || options.charAt( 0 ) === "_" ) { | |
246 | + return $.error( "no such method '" + options + "' for " + name + | |
247 | + " widget instance" ); | |
248 | + } | |
249 | + | |
250 | + methodValue = instance[ options ].apply( instance, args ); | |
251 | + | |
252 | + if ( methodValue !== instance && methodValue !== undefined ) { | |
253 | + returnValue = methodValue && methodValue.jquery ? | |
254 | + returnValue.pushStack( methodValue.get() ) : | |
255 | + methodValue; | |
256 | + return false; | |
257 | + } | |
258 | + } ); | |
259 | + } else { | |
260 | + | |
261 | + // Allow multiple hashes to be passed on init | |
262 | + if ( args.length ) { | |
263 | + options = $.widget.extend.apply( null, [ options ].concat( args ) ); | |
264 | + } | |
265 | + | |
266 | + this.each( function() { | |
267 | + var instance = $.data( this, fullName ); | |
268 | + if ( instance ) { | |
269 | + instance.option( options || {} ); | |
270 | + if ( instance._init ) { | |
271 | + instance._init(); | |
272 | + } | |
273 | + } else { | |
274 | + $.data( this, fullName, new object( options, this ) ); | |
275 | + } | |
276 | + } ); | |
277 | + } | |
278 | + | |
279 | + return returnValue; | |
280 | + }; | |
281 | +}; | |
282 | + | |
283 | +$.Widget = function( /* options, element */ ) {}; | |
284 | +$.Widget._childConstructors = []; | |
285 | + | |
286 | +$.Widget.prototype = { | |
287 | + widgetName: "widget", | |
288 | + widgetEventPrefix: "", | |
289 | + defaultElement: "<div>", | |
290 | + | |
291 | + options: { | |
292 | + classes: {}, | |
293 | + disabled: false, | |
294 | + | |
295 | + // Callbacks | |
296 | + create: null | |
297 | + }, | |
298 | + | |
299 | + _createWidget: function( options, element ) { | |
300 | + element = $( element || this.defaultElement || this )[ 0 ]; | |
301 | + this.element = $( element ); | |
302 | + this.uuid = widgetUuid++; | |
303 | + this.eventNamespace = "." + this.widgetName + this.uuid; | |
304 | + | |
305 | + this.bindings = $(); | |
306 | + this.hoverable = $(); | |
307 | + this.focusable = $(); | |
308 | + this.classesElementLookup = {}; | |
309 | + | |
310 | + if ( element !== this ) { | |
311 | + $.data( element, this.widgetFullName, this ); | |
312 | + this._on( true, this.element, { | |
313 | + remove: function( event ) { | |
314 | + if ( event.target === element ) { | |
315 | + this.destroy(); | |
316 | + } | |
317 | + } | |
318 | + } ); | |
319 | + this.document = $( element.style ? | |
320 | + | |
321 | + // Element within the document | |
322 | + element.ownerDocument : | |
323 | + | |
324 | + // Element is window or document | |
325 | + element.document || element ); | |
326 | + this.window = $( this.document[ 0 ].defaultView || this.document[ 0 ].parentWindow ); | |
327 | + } | |
328 | + | |
329 | + this.options = $.widget.extend( {}, | |
330 | + this.options, | |
331 | + this._getCreateOptions(), | |
332 | + options ); | |
333 | + | |
334 | + this._create(); | |
335 | + | |
336 | + if ( this.options.disabled ) { | |
337 | + this._setOptionDisabled( this.options.disabled ); | |
338 | + } | |
339 | + | |
340 | + this._trigger( "create", null, this._getCreateEventData() ); | |
341 | + this._init(); | |
342 | + }, | |
343 | + | |
344 | + _getCreateOptions: function() { | |
345 | + return {}; | |
346 | + }, | |
347 | + | |
348 | + _getCreateEventData: $.noop, | |
349 | + | |
350 | + _create: $.noop, | |
351 | + | |
352 | + _init: $.noop, | |
353 | + | |
354 | + destroy: function() { | |
355 | + var that = this; | |
356 | + | |
357 | + this._destroy(); | |
358 | + $.each( this.classesElementLookup, function( key, value ) { | |
359 | + that._removeClass( value, key ); | |
360 | + } ); | |
361 | + | |
362 | + // We can probably remove the unbind calls in 2.0 | |
363 | + // all event bindings should go through this._on() | |
364 | + this.element | |
365 | + .off( this.eventNamespace ) | |
366 | + .removeData( this.widgetFullName ); | |
367 | + this.widget() | |
368 | + .off( this.eventNamespace ) | |
369 | + .removeAttr( "aria-disabled" ); | |
370 | + | |
371 | + // Clean up events and states | |
372 | + this.bindings.off( this.eventNamespace ); | |
373 | + }, | |
374 | + | |
375 | + _destroy: $.noop, | |
376 | + | |
377 | + widget: function() { | |
378 | + return this.element; | |
379 | + }, | |
380 | + | |
381 | + option: function( key, value ) { | |
382 | + var options = key; | |
383 | + var parts; | |
384 | + var curOption; | |
385 | + var i; | |
386 | + | |
387 | + if ( arguments.length === 0 ) { | |
388 | + | |
389 | + // Don't return a reference to the internal hash | |
390 | + return $.widget.extend( {}, this.options ); | |
391 | + } | |
392 | + | |
393 | + if ( typeof key === "string" ) { | |
394 | + | |
395 | + // Handle nested keys, e.g., "foo.bar" => { foo: { bar: ___ } } | |
396 | + options = {}; | |
397 | + parts = key.split( "." ); | |
398 | + key = parts.shift(); | |
399 | + if ( parts.length ) { | |
400 | + curOption = options[ key ] = $.widget.extend( {}, this.options[ key ] ); | |
401 | + for ( i = 0; i < parts.length - 1; i++ ) { | |
402 | + curOption[ parts[ i ] ] = curOption[ parts[ i ] ] || {}; | |
403 | + curOption = curOption[ parts[ i ] ]; | |
404 | + } | |
405 | + key = parts.pop(); | |
406 | + if ( arguments.length === 1 ) { | |
407 | + return curOption[ key ] === undefined ? null : curOption[ key ]; | |
408 | + } | |
409 | + curOption[ key ] = value; | |
410 | + } else { | |
411 | + if ( arguments.length === 1 ) { | |
412 | + return this.options[ key ] === undefined ? null : this.options[ key ]; | |
413 | + } | |
414 | + options[ key ] = value; | |
415 | + } | |
416 | + } | |
417 | + | |
418 | + this._setOptions( options ); | |
419 | + | |
420 | + return this; | |
421 | + }, | |
422 | + | |
423 | + _setOptions: function( options ) { | |
424 | + var key; | |
425 | + | |
426 | + for ( key in options ) { | |
427 | + this._setOption( key, options[ key ] ); | |
428 | + } | |
429 | + | |
430 | + return this; | |
431 | + }, | |
432 | + | |
433 | + _setOption: function( key, value ) { | |
434 | + if ( key === "classes" ) { | |
435 | + this._setOptionClasses( value ); | |
436 | + } | |
437 | + | |
438 | + this.options[ key ] = value; | |
439 | + | |
440 | + if ( key === "disabled" ) { | |
441 | + this._setOptionDisabled( value ); | |
442 | + } | |
443 | + | |
444 | + return this; | |
445 | + }, | |
446 | + | |
447 | + _setOptionClasses: function( value ) { | |
448 | + var classKey, elements, currentElements; | |
449 | + | |
450 | + for ( classKey in value ) { | |
451 | + currentElements = this.classesElementLookup[ classKey ]; | |
452 | + if ( value[ classKey ] === this.options.classes[ classKey ] || | |
453 | + !currentElements || | |
454 | + !currentElements.length ) { | |
455 | + continue; | |
456 | + } | |
457 | + | |
458 | + // We are doing this to create a new jQuery object because the _removeClass() call | |
459 | + // on the next line is going to destroy the reference to the current elements being | |
460 | + // tracked. We need to save a copy of this collection so that we can add the new classes | |
461 | + // below. | |
462 | + elements = $( currentElements.get() ); | |
463 | + this._removeClass( currentElements, classKey ); | |
464 | + | |
465 | + // We don't use _addClass() here, because that uses this.options.classes | |
466 | + // for generating the string of classes. We want to use the value passed in from | |
467 | + // _setOption(), this is the new value of the classes option which was passed to | |
468 | + // _setOption(). We pass this value directly to _classes(). | |
469 | + elements.addClass( this._classes( { | |
470 | + element: elements, | |
471 | + keys: classKey, | |
472 | + classes: value, | |
473 | + add: true | |
474 | + } ) ); | |
475 | + } | |
476 | + }, | |
477 | + | |
478 | + _setOptionDisabled: function( value ) { | |
479 | + this._toggleClass( this.widget(), this.widgetFullName + "-disabled", null, !!value ); | |
480 | + | |
481 | + // If the widget is becoming disabled, then nothing is interactive | |
482 | + if ( value ) { | |
483 | + this._removeClass( this.hoverable, null, "ui-state-hover" ); | |
484 | + this._removeClass( this.focusable, null, "ui-state-focus" ); | |
485 | + } | |
486 | + }, | |
487 | + | |
488 | + enable: function() { | |
489 | + return this._setOptions( { disabled: false } ); | |
490 | + }, | |
491 | + | |
492 | + disable: function() { | |
493 | + return this._setOptions( { disabled: true } ); | |
494 | + }, | |
495 | + | |
496 | + _classes: function( options ) { | |
497 | + var full = []; | |
498 | + var that = this; | |
499 | + | |
500 | + options = $.extend( { | |
501 | + element: this.element, | |
502 | + classes: this.options.classes || {} | |
503 | + }, options ); | |
504 | + | |
505 | + function processClassString( classes, checkOption ) { | |
506 | + var current, i; | |
507 | + for ( i = 0; i < classes.length; i++ ) { | |
508 | + current = that.classesElementLookup[ classes[ i ] ] || $(); | |
509 | + if ( options.add ) { | |
510 | + current = $( $.unique( current.get().concat( options.element.get() ) ) ); | |
511 | + } else { | |
512 | + current = $( current.not( options.element ).get() ); | |
513 | + } | |
514 | + that.classesElementLookup[ classes[ i ] ] = current; | |
515 | + full.push( classes[ i ] ); | |
516 | + if ( checkOption && options.classes[ classes[ i ] ] ) { | |
517 | + full.push( options.classes[ classes[ i ] ] ); | |
518 | + } | |
519 | + } | |
520 | + } | |
521 | + | |
522 | + if ( options.keys ) { | |
523 | + processClassString( options.keys.match( /\S+/g ) || [], true ); | |
524 | + } | |
525 | + if ( options.extra ) { | |
526 | + processClassString( options.extra.match( /\S+/g ) || [] ); | |
527 | + } | |
528 | + | |
529 | + return full.join( " " ); | |
530 | + }, | |
531 | + | |
532 | + _removeClass: function( element, keys, extra ) { | |
533 | + return this._toggleClass( element, keys, extra, false ); | |
534 | + }, | |
535 | + | |
536 | + _addClass: function( element, keys, extra ) { | |
537 | + return this._toggleClass( element, keys, extra, true ); | |
538 | + }, | |
539 | + | |
540 | + _toggleClass: function( element, keys, extra, add ) { | |
541 | + add = ( typeof add === "boolean" ) ? add : extra; | |
542 | + var shift = ( typeof element === "string" || element === null ), | |
543 | + options = { | |
544 | + extra: shift ? keys : extra, | |
545 | + keys: shift ? element : keys, | |
546 | + element: shift ? this.element : element, | |
547 | + add: add | |
548 | + }; | |
549 | + options.element.toggleClass( this._classes( options ), add ); | |
550 | + return this; | |
551 | + }, | |
552 | + | |
553 | + _on: function( suppressDisabledCheck, element, handlers ) { | |
554 | + var delegateElement; | |
555 | + var instance = this; | |
556 | + | |
557 | + // No suppressDisabledCheck flag, shuffle arguments | |
558 | + if ( typeof suppressDisabledCheck !== "boolean" ) { | |
559 | + handlers = element; | |
560 | + element = suppressDisabledCheck; | |
561 | + suppressDisabledCheck = false; | |
562 | + } | |
563 | + | |
564 | + // No element argument, shuffle and use this.element | |
565 | + if ( !handlers ) { | |
566 | + handlers = element; | |
567 | + element = this.element; | |
568 | + delegateElement = this.widget(); | |
569 | + } else { | |
570 | + element = delegateElement = $( element ); | |
571 | + this.bindings = this.bindings.add( element ); | |
572 | + } | |
573 | + | |
574 | + $.each( handlers, function( event, handler ) { | |
575 | + function handlerProxy() { | |
576 | + | |
577 | + // Allow widgets to customize the disabled handling | |
578 | + // - disabled as an array instead of boolean | |
579 | + // - disabled class as method for disabling individual parts | |
580 | + if ( !suppressDisabledCheck && | |
581 | + ( instance.options.disabled === true || | |
582 | + $( this ).hasClass( "ui-state-disabled" ) ) ) { | |
583 | + return; | |
584 | + } | |
585 | + return ( typeof handler === "string" ? instance[ handler ] : handler ) | |
586 | + .apply( instance, arguments ); | |
587 | + } | |
588 | + | |
589 | + // Copy the guid so direct unbinding works | |
590 | + if ( typeof handler !== "string" ) { | |
591 | + handlerProxy.guid = handler.guid = | |
592 | + handler.guid || handlerProxy.guid || $.guid++; | |
593 | + } | |
594 | + | |
595 | + var match = event.match( /^([\w:-]*)\s*(.*)$/ ); | |
596 | + var eventName = match[ 1 ] + instance.eventNamespace; | |
597 | + var selector = match[ 2 ]; | |
598 | + | |
599 | + if ( selector ) { | |
600 | + delegateElement.on( eventName, selector, handlerProxy ); | |
601 | + } else { | |
602 | + element.on( eventName, handlerProxy ); | |
603 | + } | |
604 | + } ); | |
605 | + }, | |
606 | + | |
607 | + _off: function( element, eventName ) { | |
608 | + eventName = ( eventName || "" ).split( " " ).join( this.eventNamespace + " " ) + | |
609 | + this.eventNamespace; | |
610 | + element.off( eventName ).off( eventName ); | |
611 | + | |
612 | + // Clear the stack to avoid memory leaks (#10056) | |
613 | + this.bindings = $( this.bindings.not( element ).get() ); | |
614 | + this.focusable = $( this.focusable.not( element ).get() ); | |
615 | + this.hoverable = $( this.hoverable.not( element ).get() ); | |
616 | + }, | |
617 | + | |
618 | + _delay: function( handler, delay ) { | |
619 | + function handlerProxy() { | |
620 | + return ( typeof handler === "string" ? instance[ handler ] : handler ) | |
621 | + .apply( instance, arguments ); | |
622 | + } | |
623 | + var instance = this; | |
624 | + return setTimeout( handlerProxy, delay || 0 ); | |
625 | + }, | |
626 | + | |
627 | + _hoverable: function( element ) { | |
628 | + this.hoverable = this.hoverable.add( element ); | |
629 | + this._on( element, { | |
630 | + mouseenter: function( event ) { | |
631 | + this._addClass( $( event.currentTarget ), null, "ui-state-hover" ); | |
632 | + }, | |
633 | + mouseleave: function( event ) { | |
634 | + this._removeClass( $( event.currentTarget ), null, "ui-state-hover" ); | |
635 | + } | |
636 | + } ); | |
637 | + }, | |
638 | + | |
639 | + _focusable: function( element ) { | |
640 | + this.focusable = this.focusable.add( element ); | |
641 | + this._on( element, { | |
642 | + focusin: function( event ) { | |
643 | + this._addClass( $( event.currentTarget ), null, "ui-state-focus" ); | |
644 | + }, | |
645 | + focusout: function( event ) { | |
646 | + this._removeClass( $( event.currentTarget ), null, "ui-state-focus" ); | |
647 | + } | |
648 | + } ); | |
649 | + }, | |
650 | + | |
651 | + _trigger: function( type, event, data ) { | |
652 | + var prop, orig; | |
653 | + var callback = this.options[ type ]; | |
654 | + | |
655 | + data = data || {}; | |
656 | + event = $.Event( event ); | |
657 | + event.type = ( type === this.widgetEventPrefix ? | |
658 | + type : | |
659 | + this.widgetEventPrefix + type ).toLowerCase(); | |
660 | + | |
661 | + // The original event may come from any element | |
662 | + // so we need to reset the target on the new event | |
663 | + event.target = this.element[ 0 ]; | |
664 | + | |
665 | + // Copy original event properties over to the new event | |
666 | + orig = event.originalEvent; | |
667 | + if ( orig ) { | |
668 | + for ( prop in orig ) { | |
669 | + if ( !( prop in event ) ) { | |
670 | + event[ prop ] = orig[ prop ]; | |
671 | + } | |
672 | + } | |
673 | + } | |
674 | + | |
675 | + this.element.trigger( event, data ); | |
676 | + return !( $.isFunction( callback ) && | |
677 | + callback.apply( this.element[ 0 ], [ event ].concat( data ) ) === false || | |
678 | + event.isDefaultPrevented() ); | |
679 | + } | |
680 | +}; | |
681 | + | |
682 | +$.each( { show: "fadeIn", hide: "fadeOut" }, function( method, defaultEffect ) { | |
683 | + $.Widget.prototype[ "_" + method ] = function( element, options, callback ) { | |
684 | + if ( typeof options === "string" ) { | |
685 | + options = { effect: options }; | |
686 | + } | |
687 | + | |
688 | + var hasOptions; | |
689 | + var effectName = !options ? | |
690 | + method : | |
691 | + options === true || typeof options === "number" ? | |
692 | + defaultEffect : | |
693 | + options.effect || defaultEffect; | |
694 | + | |
695 | + options = options || {}; | |
696 | + if ( typeof options === "number" ) { | |
697 | + options = { duration: options }; | |
698 | + } | |
699 | + | |
700 | + hasOptions = !$.isEmptyObject( options ); | |
701 | + options.complete = callback; | |
702 | + | |
703 | + if ( options.delay ) { | |
704 | + element.delay( options.delay ); | |
705 | + } | |
706 | + | |
707 | + if ( hasOptions && $.effects && $.effects.effect[ effectName ] ) { | |
708 | + element[ method ]( options ); | |
709 | + } else if ( effectName !== method && element[ effectName ] ) { | |
710 | + element[ effectName ]( options.duration, options.easing, callback ); | |
711 | + } else { | |
712 | + element.queue( function( next ) { | |
713 | + $( this )[ method ](); | |
714 | + if ( callback ) { | |
715 | + callback.call( element[ 0 ] ); | |
716 | + } | |
717 | + next(); | |
718 | + } ); | |
719 | + } | |
720 | + }; | |
721 | +} ); | |
722 | + | |
723 | +var widget = $.widget; | |
724 | + | |
725 | + | |
726 | +/*! | |
727 | + * jQuery UI Position 1.12.0-rc.2 | |
728 | + * http://jqueryui.com | |
729 | + * | |
730 | + * Copyright jQuery Foundation and other contributors | |
731 | + * Released under the MIT license. | |
732 | + * http://jquery.org/license | |
733 | + * | |
734 | + * http://api.jqueryui.com/position/ | |
735 | + */ | |
736 | + | |
737 | +//>>label: Position | |
738 | +//>>group: Core | |
739 | +//>>description: Positions elements relative to other elements. | |
740 | +//>>docs: http://api.jqueryui.com/position/ | |
741 | +//>>demos: http://jqueryui.com/position/ | |
742 | + | |
743 | + | |
744 | +( function() { | |
745 | +var cachedScrollbarWidth, supportsOffsetFractions, | |
746 | + max = Math.max, | |
747 | + abs = Math.abs, | |
748 | + round = Math.round, | |
749 | + rhorizontal = /left|center|right/, | |
750 | + rvertical = /top|center|bottom/, | |
751 | + roffset = /[\+\-]\d+(\.[\d]+)?%?/, | |
752 | + rposition = /^\w+/, | |
753 | + rpercent = /%$/, | |
754 | + _position = $.fn.position; | |
755 | + | |
756 | +// Support: IE <=9 only | |
757 | +supportsOffsetFractions = function() { | |
758 | + var element = $( "<div>" ) | |
759 | + .css( "position", "absolute" ) | |
760 | + .appendTo( "body" ) | |
761 | + .offset( { | |
762 | + top: 1.5, | |
763 | + left: 1.5 | |
764 | + } ), | |
765 | + support = element.offset().top === 1.5; | |
766 | + | |
767 | + element.remove(); | |
768 | + | |
769 | + supportsOffsetFractions = function() { | |
770 | + return support; | |
771 | + }; | |
772 | + | |
773 | + return support; | |
774 | +}; | |
775 | + | |
776 | +function getOffsets( offsets, width, height ) { | |
777 | + return [ | |
778 | + parseFloat( offsets[ 0 ] ) * ( rpercent.test( offsets[ 0 ] ) ? width / 100 : 1 ), | |
779 | + parseFloat( offsets[ 1 ] ) * ( rpercent.test( offsets[ 1 ] ) ? height / 100 : 1 ) | |
780 | + ]; | |
781 | +} | |
782 | + | |
783 | +function parseCss( element, property ) { | |
784 | + return parseInt( $.css( element, property ), 10 ) || 0; | |
785 | +} | |
786 | + | |
787 | +function getDimensions( elem ) { | |
788 | + var raw = elem[ 0 ]; | |
789 | + if ( raw.nodeType === 9 ) { | |
790 | + return { | |
791 | + width: elem.width(), | |
792 | + height: elem.height(), | |
793 | + offset: { top: 0, left: 0 } | |
794 | + }; | |
795 | + } | |
796 | + if ( $.isWindow( raw ) ) { | |
797 | + return { | |
798 | + width: elem.width(), | |
799 | + height: elem.height(), | |
800 | + offset: { top: elem.scrollTop(), left: elem.scrollLeft() } | |
801 | + }; | |
802 | + } | |
803 | + if ( raw.preventDefault ) { | |
804 | + return { | |
805 | + width: 0, | |
806 | + height: 0, | |
807 | + offset: { top: raw.pageY, left: raw.pageX } | |
808 | + }; | |
809 | + } | |
810 | + return { | |
811 | + width: elem.outerWidth(), | |
812 | + height: elem.outerHeight(), | |
813 | + offset: elem.offset() | |
814 | + }; | |
815 | +} | |
816 | + | |
817 | +$.position = { | |
818 | + scrollbarWidth: function() { | |
819 | + if ( cachedScrollbarWidth !== undefined ) { | |
820 | + return cachedScrollbarWidth; | |
821 | + } | |
822 | + var w1, w2, | |
823 | + div = $( "<div " + | |
824 | + "style='display:block;position:absolute;width:50px;height:50px;overflow:hidden;'>" + | |
825 | + "<div style='height:100px;width:auto;'></div></div>" ), | |
826 | + innerDiv = div.children()[ 0 ]; | |
827 | + | |
828 | + $( "body" ).append( div ); | |
829 | + w1 = innerDiv.offsetWidth; | |
830 | + div.css( "overflow", "scroll" ); | |
831 | + | |
832 | + w2 = innerDiv.offsetWidth; | |
833 | + | |
834 | + if ( w1 === w2 ) { | |
835 | + w2 = div[ 0 ].clientWidth; | |
836 | + } | |
837 | + | |
838 | + div.remove(); | |
839 | + | |
840 | + return ( cachedScrollbarWidth = w1 - w2 ); | |
841 | + }, | |
842 | + getScrollInfo: function( within ) { | |
843 | + var overflowX = within.isWindow || within.isDocument ? "" : | |
844 | + within.element.css( "overflow-x" ), | |
845 | + overflowY = within.isWindow || within.isDocument ? "" : | |
846 | + within.element.css( "overflow-y" ), | |
847 | + hasOverflowX = overflowX === "scroll" || | |
848 | + ( overflowX === "auto" && within.width < within.element[ 0 ].scrollWidth ), | |
849 | + hasOverflowY = overflowY === "scroll" || | |
850 | + ( overflowY === "auto" && within.height < within.element[ 0 ].scrollHeight ); | |
851 | + return { | |
852 | + width: hasOverflowY ? $.position.scrollbarWidth() : 0, | |
853 | + height: hasOverflowX ? $.position.scrollbarWidth() : 0 | |
854 | + }; | |
855 | + }, | |
856 | + getWithinInfo: function( element ) { | |
857 | + var withinElement = $( element || window ), | |
858 | + isWindow = $.isWindow( withinElement[ 0 ] ), | |
859 | + isDocument = !!withinElement[ 0 ] && withinElement[ 0 ].nodeType === 9, | |
860 | + hasOffset = !isWindow && !isDocument; | |
861 | + return { | |
862 | + element: withinElement, | |
863 | + isWindow: isWindow, | |
864 | + isDocument: isDocument, | |
865 | + offset: hasOffset ? $( element ).offset() : { left: 0, top: 0 }, | |
866 | + scrollLeft: withinElement.scrollLeft(), | |
867 | + scrollTop: withinElement.scrollTop(), | |
868 | + width: withinElement.outerWidth(), | |
869 | + height: withinElement.outerHeight() | |
870 | + }; | |
871 | + } | |
872 | +}; | |
873 | + | |
874 | +$.fn.position = function( options ) { | |
875 | + if ( !options || !options.of ) { | |
876 | + return _position.apply( this, arguments ); | |
877 | + } | |
878 | + | |
879 | + // Make a copy, we don't want to modify arguments | |
880 | + options = $.extend( {}, options ); | |
881 | + | |
882 | + var atOffset, targetWidth, targetHeight, targetOffset, basePosition, dimensions, | |
883 | + target = $( options.of ), | |
884 | + within = $.position.getWithinInfo( options.within ), | |
885 | + scrollInfo = $.position.getScrollInfo( within ), | |
886 | + collision = ( options.collision || "flip" ).split( " " ), | |
887 | + offsets = {}; | |
888 | + | |
889 | + dimensions = getDimensions( target ); | |
890 | + if ( target[ 0 ].preventDefault ) { | |
891 | + | |
892 | + // Force left top to allow flipping | |
893 | + options.at = "left top"; | |
894 | + } | |
895 | + targetWidth = dimensions.width; | |
896 | + targetHeight = dimensions.height; | |
897 | + targetOffset = dimensions.offset; | |
898 | + | |
899 | + // Clone to reuse original targetOffset later | |
900 | + basePosition = $.extend( {}, targetOffset ); | |
901 | + | |
902 | + // Force my and at to have valid horizontal and vertical positions | |
903 | + // if a value is missing or invalid, it will be converted to center | |
904 | + $.each( [ "my", "at" ], function() { | |
905 | + var pos = ( options[ this ] || "" ).split( " " ), | |
906 | + horizontalOffset, | |
907 | + verticalOffset; | |
908 | + | |
909 | + if ( pos.length === 1 ) { | |
910 | + pos = rhorizontal.test( pos[ 0 ] ) ? | |
911 | + pos.concat( [ "center" ] ) : | |
912 | + rvertical.test( pos[ 0 ] ) ? | |
913 | + [ "center" ].concat( pos ) : | |
914 | + [ "center", "center" ]; | |
915 | + } | |
916 | + pos[ 0 ] = rhorizontal.test( pos[ 0 ] ) ? pos[ 0 ] : "center"; | |
917 | + pos[ 1 ] = rvertical.test( pos[ 1 ] ) ? pos[ 1 ] : "center"; | |
918 | + | |
919 | + // Calculate offsets | |
920 | + horizontalOffset = roffset.exec( pos[ 0 ] ); | |
921 | + verticalOffset = roffset.exec( pos[ 1 ] ); | |
922 | + offsets[ this ] = [ | |
923 | + horizontalOffset ? horizontalOffset[ 0 ] : 0, | |
924 | + verticalOffset ? verticalOffset[ 0 ] : 0 | |
925 | + ]; | |
926 | + | |
927 | + // Reduce to just the positions without the offsets | |
928 | + options[ this ] = [ | |
929 | + rposition.exec( pos[ 0 ] )[ 0 ], | |
930 | + rposition.exec( pos[ 1 ] )[ 0 ] | |
931 | + ]; | |
932 | + } ); | |
933 | + | |
934 | + // Normalize collision option | |
935 | + if ( collision.length === 1 ) { | |
936 | + collision[ 1 ] = collision[ 0 ]; | |
937 | + } | |
938 | + | |
939 | + if ( options.at[ 0 ] === "right" ) { | |
940 | + basePosition.left += targetWidth; | |
941 | + } else if ( options.at[ 0 ] === "center" ) { | |
942 | + basePosition.left += targetWidth / 2; | |
943 | + } | |
944 | + | |
945 | + if ( options.at[ 1 ] === "bottom" ) { | |
946 | + basePosition.top += targetHeight; | |
947 | + } else if ( options.at[ 1 ] === "center" ) { | |
948 | + basePosition.top += targetHeight / 2; | |
949 | + } | |
950 | + | |
951 | + atOffset = getOffsets( offsets.at, targetWidth, targetHeight ); | |
952 | + basePosition.left += atOffset[ 0 ]; | |
953 | + basePosition.top += atOffset[ 1 ]; | |
954 | + | |
955 | + return this.each( function() { | |
956 | + var collisionPosition, using, | |
957 | + elem = $( this ), | |
958 | + elemWidth = elem.outerWidth(), | |
959 | + elemHeight = elem.outerHeight(), | |
960 | + marginLeft = parseCss( this, "marginLeft" ), | |
961 | + marginTop = parseCss( this, "marginTop" ), | |
962 | + collisionWidth = elemWidth + marginLeft + parseCss( this, "marginRight" ) + | |
963 | + scrollInfo.width, | |
964 | + collisionHeight = elemHeight + marginTop + parseCss( this, "marginBottom" ) + | |
965 | + scrollInfo.height, | |
966 | + position = $.extend( {}, basePosition ), | |
967 | + myOffset = getOffsets( offsets.my, elem.outerWidth(), elem.outerHeight() ); | |
968 | + | |
969 | + if ( options.my[ 0 ] === "right" ) { | |
970 | + position.left -= elemWidth; | |
971 | + } else if ( options.my[ 0 ] === "center" ) { | |
972 | + position.left -= elemWidth / 2; | |
973 | + } | |
974 | + | |
975 | + if ( options.my[ 1 ] === "bottom" ) { | |
976 | + position.top -= elemHeight; | |
977 | + } else if ( options.my[ 1 ] === "center" ) { | |
978 | + position.top -= elemHeight / 2; | |
979 | + } | |
980 | + | |
981 | + position.left += myOffset[ 0 ]; | |
982 | + position.top += myOffset[ 1 ]; | |
983 | + | |
984 | + // If the browser doesn't support fractions, then round for consistent results | |
985 | + if ( !supportsOffsetFractions() ) { | |
986 | + position.left = round( position.left ); | |
987 | + position.top = round( position.top ); | |
988 | + } | |
989 | + | |
990 | + collisionPosition = { | |
991 | + marginLeft: marginLeft, | |
992 | + marginTop: marginTop | |
993 | + }; | |
994 | + | |
995 | + $.each( [ "left", "top" ], function( i, dir ) { | |
996 | + if ( $.ui.position[ collision[ i ] ] ) { | |
997 | + $.ui.position[ collision[ i ] ][ dir ]( position, { | |
998 | + targetWidth: targetWidth, | |
999 | + targetHeight: targetHeight, | |
1000 | + elemWidth: elemWidth, | |
1001 | + elemHeight: elemHeight, | |
1002 | + collisionPosition: collisionPosition, | |
1003 | + collisionWidth: collisionWidth, | |
1004 | + collisionHeight: collisionHeight, | |
1005 | + offset: [ atOffset[ 0 ] + myOffset[ 0 ], atOffset [ 1 ] + myOffset[ 1 ] ], | |
1006 | + my: options.my, | |
1007 | + at: options.at, | |
1008 | + within: within, | |
1009 | + elem: elem | |
1010 | + } ); | |
1011 | + } | |
1012 | + } ); | |
1013 | + | |
1014 | + if ( options.using ) { | |
1015 | + | |
1016 | + // Adds feedback as second argument to using callback, if present | |
1017 | + using = function( props ) { | |
1018 | + var left = targetOffset.left - position.left, | |
1019 | + right = left + targetWidth - elemWidth, | |
1020 | + top = targetOffset.top - position.top, | |
1021 | + bottom = top + targetHeight - elemHeight, | |
1022 | + feedback = { | |
1023 | + target: { | |
1024 | + element: target, | |
1025 | + left: targetOffset.left, | |
1026 | + top: targetOffset.top, | |
1027 | + width: targetWidth, | |
1028 | + height: targetHeight | |
1029 | + }, | |
1030 | + element: { | |
1031 | + element: elem, | |
1032 | + left: position.left, | |
1033 | + top: position.top, | |
1034 | + width: elemWidth, | |
1035 | + height: elemHeight | |
1036 | + }, | |
1037 | + horizontal: right < 0 ? "left" : left > 0 ? "right" : "center", | |
1038 | + vertical: bottom < 0 ? "top" : top > 0 ? "bottom" : "middle" | |
1039 | + }; | |
1040 | + if ( targetWidth < elemWidth && abs( left + right ) < targetWidth ) { | |
1041 | + feedback.horizontal = "center"; | |
1042 | + } | |
1043 | + if ( targetHeight < elemHeight && abs( top + bottom ) < targetHeight ) { | |
1044 | + feedback.vertical = "middle"; | |
1045 | + } | |
1046 | + if ( max( abs( left ), abs( right ) ) > max( abs( top ), abs( bottom ) ) ) { | |
1047 | + feedback.important = "horizontal"; | |
1048 | + } else { | |
1049 | + feedback.important = "vertical"; | |
1050 | + } | |
1051 | + options.using.call( this, props, feedback ); | |
1052 | + }; | |
1053 | + } | |
1054 | + | |
1055 | + elem.offset( $.extend( position, { using: using } ) ); | |
1056 | + } ); | |
1057 | +}; | |
1058 | + | |
1059 | +$.ui.position = { | |
1060 | + fit: { | |
1061 | + left: function( position, data ) { | |
1062 | + var within = data.within, | |
1063 | + withinOffset = within.isWindow ? within.scrollLeft : within.offset.left, | |
1064 | + outerWidth = within.width, | |
1065 | + collisionPosLeft = position.left - data.collisionPosition.marginLeft, | |
1066 | + overLeft = withinOffset - collisionPosLeft, | |
1067 | + overRight = collisionPosLeft + data.collisionWidth - outerWidth - withinOffset, | |
1068 | + newOverRight; | |
1069 | + | |
1070 | + // Element is wider than within | |
1071 | + if ( data.collisionWidth > outerWidth ) { | |
1072 | + | |
1073 | + // Element is initially over the left side of within | |
1074 | + if ( overLeft > 0 && overRight <= 0 ) { | |
1075 | + newOverRight = position.left + overLeft + data.collisionWidth - outerWidth - | |
1076 | + withinOffset; | |
1077 | + position.left += overLeft - newOverRight; | |
1078 | + | |
1079 | + // Element is initially over right side of within | |
1080 | + } else if ( overRight > 0 && overLeft <= 0 ) { | |
1081 | + position.left = withinOffset; | |
1082 | + | |
1083 | + // Element is initially over both left and right sides of within | |
1084 | + } else { | |
1085 | + if ( overLeft > overRight ) { | |
1086 | + position.left = withinOffset + outerWidth - data.collisionWidth; | |
1087 | + } else { | |
1088 | + position.left = withinOffset; | |
1089 | + } | |
1090 | + } | |
1091 | + | |
1092 | + // Too far left -> align with left edge | |
1093 | + } else if ( overLeft > 0 ) { | |
1094 | + position.left += overLeft; | |
1095 | + | |
1096 | + // Too far right -> align with right edge | |
1097 | + } else if ( overRight > 0 ) { | |
1098 | + position.left -= overRight; | |
1099 | + | |
1100 | + // Adjust based on position and margin | |
1101 | + } else { | |
1102 | + position.left = max( position.left - collisionPosLeft, position.left ); | |
1103 | + } | |
1104 | + }, | |
1105 | + top: function( position, data ) { | |
1106 | + var within = data.within, | |
1107 | + withinOffset = within.isWindow ? within.scrollTop : within.offset.top, | |
1108 | + outerHeight = data.within.height, | |
1109 | + collisionPosTop = position.top - data.collisionPosition.marginTop, | |
1110 | + overTop = withinOffset - collisionPosTop, | |
1111 | + overBottom = collisionPosTop + data.collisionHeight - outerHeight - withinOffset, | |
1112 | + newOverBottom; | |
1113 | + | |
1114 | + // Element is taller than within | |
1115 | + if ( data.collisionHeight > outerHeight ) { | |
1116 | + | |
1117 | + // Element is initially over the top of within | |
1118 | + if ( overTop > 0 && overBottom <= 0 ) { | |
1119 | + newOverBottom = position.top + overTop + data.collisionHeight - outerHeight - | |
1120 | + withinOffset; | |
1121 | + position.top += overTop - newOverBottom; | |
1122 | + | |
1123 | + // Element is initially over bottom of within | |
1124 | + } else if ( overBottom > 0 && overTop <= 0 ) { | |
1125 | + position.top = withinOffset; | |
1126 | + | |
1127 | + // Element is initially over both top and bottom of within | |
1128 | + } else { | |
1129 | + if ( overTop > overBottom ) { | |
1130 | + position.top = withinOffset + outerHeight - data.collisionHeight; | |
1131 | + } else { | |
1132 | + position.top = withinOffset; | |
1133 | + } | |
1134 | + } | |
1135 | + | |
1136 | + // Too far up -> align with top | |
1137 | + } else if ( overTop > 0 ) { | |
1138 | + position.top += overTop; | |
1139 | + | |
1140 | + // Too far down -> align with bottom edge | |
1141 | + } else if ( overBottom > 0 ) { | |
1142 | + position.top -= overBottom; | |
1143 | + | |
1144 | + // Adjust based on position and margin | |
1145 | + } else { | |
1146 | + position.top = max( position.top - collisionPosTop, position.top ); | |
1147 | + } | |
1148 | + } | |
1149 | + }, | |
1150 | + flip: { | |
1151 | + left: function( position, data ) { | |
1152 | + var within = data.within, | |
1153 | + withinOffset = within.offset.left + within.scrollLeft, | |
1154 | + outerWidth = within.width, | |
1155 | + offsetLeft = within.isWindow ? within.scrollLeft : within.offset.left, | |
1156 | + collisionPosLeft = position.left - data.collisionPosition.marginLeft, | |
1157 | + overLeft = collisionPosLeft - offsetLeft, | |
1158 | + overRight = collisionPosLeft + data.collisionWidth - outerWidth - offsetLeft, | |
1159 | + myOffset = data.my[ 0 ] === "left" ? | |
1160 | + -data.elemWidth : | |
1161 | + data.my[ 0 ] === "right" ? | |
1162 | + data.elemWidth : | |
1163 | + 0, | |
1164 | + atOffset = data.at[ 0 ] === "left" ? | |
1165 | + data.targetWidth : | |
1166 | + data.at[ 0 ] === "right" ? | |
1167 | + -data.targetWidth : | |
1168 | + 0, | |
1169 | + offset = -2 * data.offset[ 0 ], | |
1170 | + newOverRight, | |
1171 | + newOverLeft; | |
1172 | + | |
1173 | + if ( overLeft < 0 ) { | |
1174 | + newOverRight = position.left + myOffset + atOffset + offset + data.collisionWidth - | |
1175 | + outerWidth - withinOffset; | |
1176 | + if ( newOverRight < 0 || newOverRight < abs( overLeft ) ) { | |
1177 | + position.left += myOffset + atOffset + offset; | |
1178 | + } | |
1179 | + } else if ( overRight > 0 ) { | |
1180 | + newOverLeft = position.left - data.collisionPosition.marginLeft + myOffset + | |
1181 | + atOffset + offset - offsetLeft; | |
1182 | + if ( newOverLeft > 0 || abs( newOverLeft ) < overRight ) { | |
1183 | + position.left += myOffset + atOffset + offset; | |
1184 | + } | |
1185 | + } | |
1186 | + }, | |
1187 | + top: function( position, data ) { | |
1188 | + var within = data.within, | |
1189 | + withinOffset = within.offset.top + within.scrollTop, | |
1190 | + outerHeight = within.height, | |
1191 | + offsetTop = within.isWindow ? within.scrollTop : within.offset.top, | |
1192 | + collisionPosTop = position.top - data.collisionPosition.marginTop, | |
1193 | + overTop = collisionPosTop - offsetTop, | |
1194 | + overBottom = collisionPosTop + data.collisionHeight - outerHeight - offsetTop, | |
1195 | + top = data.my[ 1 ] === "top", | |
1196 | + myOffset = top ? | |
1197 | + -data.elemHeight : | |
1198 | + data.my[ 1 ] === "bottom" ? | |
1199 | + data.elemHeight : | |
1200 | + 0, | |
1201 | + atOffset = data.at[ 1 ] === "top" ? | |
1202 | + data.targetHeight : | |
1203 | + data.at[ 1 ] === "bottom" ? | |
1204 | + -data.targetHeight : | |
1205 | + 0, | |
1206 | + offset = -2 * data.offset[ 1 ], | |
1207 | + newOverTop, | |
1208 | + newOverBottom; | |
1209 | + if ( overTop < 0 ) { | |
1210 | + newOverBottom = position.top + myOffset + atOffset + offset + data.collisionHeight - | |
1211 | + outerHeight - withinOffset; | |
1212 | + if ( newOverBottom < 0 || newOverBottom < abs( overTop ) ) { | |
1213 | + position.top += myOffset + atOffset + offset; | |
1214 | + } | |
1215 | + } else if ( overBottom > 0 ) { | |
1216 | + newOverTop = position.top - data.collisionPosition.marginTop + myOffset + atOffset + | |
1217 | + offset - offsetTop; | |
1218 | + if ( newOverTop > 0 || abs( newOverTop ) < overBottom ) { | |
1219 | + position.top += myOffset + atOffset + offset; | |
1220 | + } | |
1221 | + } | |
1222 | + } | |
1223 | + }, | |
1224 | + flipfit: { | |
1225 | + left: function() { | |
1226 | + $.ui.position.flip.left.apply( this, arguments ); | |
1227 | + $.ui.position.fit.left.apply( this, arguments ); | |
1228 | + }, | |
1229 | + top: function() { | |
1230 | + $.ui.position.flip.top.apply( this, arguments ); | |
1231 | + $.ui.position.fit.top.apply( this, arguments ); | |
1232 | + } | |
1233 | + } | |
1234 | +}; | |
1235 | + | |
1236 | +} )(); | |
1237 | + | |
1238 | +var position = $.ui.position; | |
1239 | + | |
1240 | + | |
1241 | +/*! | |
1242 | + * jQuery UI :data 1.12.0-rc.2 | |
1243 | + * http://jqueryui.com | |
1244 | + * | |
1245 | + * Copyright jQuery Foundation and other contributors | |
1246 | + * Released under the MIT license. | |
1247 | + * http://jquery.org/license | |
1248 | + */ | |
1249 | + | |
1250 | +//>>label: :data Selector | |
1251 | +//>>group: Core | |
1252 | +//>>description: Selects elements which have data stored under the specified key. | |
1253 | +//>>docs: http://api.jqueryui.com/data-selector/ | |
1254 | + | |
1255 | + | |
1256 | +var data = $.extend( $.expr[ ":" ], { | |
1257 | + data: $.expr.createPseudo ? | |
1258 | + $.expr.createPseudo( function( dataName ) { | |
1259 | + return function( elem ) { | |
1260 | + return !!$.data( elem, dataName ); | |
1261 | + }; | |
1262 | + } ) : | |
1263 | + | |
1264 | + // Support: jQuery <1.8 | |
1265 | + function( elem, i, match ) { | |
1266 | + return !!$.data( elem, match[ 3 ] ); | |
1267 | + } | |
1268 | +} ); | |
1269 | + | |
1270 | +/*! | |
1271 | + * jQuery UI Disable Selection 1.12.0-rc.2 | |
1272 | + * http://jqueryui.com | |
1273 | + * | |
1274 | + * Copyright jQuery Foundation and other contributors | |
1275 | + * Released under the MIT license. | |
1276 | + * http://jquery.org/license | |
1277 | + */ | |
1278 | + | |
1279 | +//>>label: disableSelection | |
1280 | +//>>group: Core | |
1281 | +//>>description: Disable selection of text content within the set of matched elements. | |
1282 | +//>>docs: http://api.jqueryui.com/disableSelection/ | |
1283 | + | |
1284 | +// This file is deprecated | |
1285 | + | |
1286 | + | |
1287 | +var disableSelection = $.fn.extend( { | |
1288 | + disableSelection: ( function() { | |
1289 | + var eventType = "onselectstart" in document.createElement( "div" ) ? | |
1290 | + "selectstart" : | |
1291 | + "mousedown"; | |
1292 | + | |
1293 | + return function() { | |
1294 | + return this.on( eventType + ".ui-disableSelection", function( event ) { | |
1295 | + event.preventDefault(); | |
1296 | + } ); | |
1297 | + }; | |
1298 | + } )(), | |
1299 | + | |
1300 | + enableSelection: function() { | |
1301 | + return this.off( ".ui-disableSelection" ); | |
1302 | + } | |
1303 | +} ); | |
1304 | + | |
1305 | + | |
1306 | +/*! | |
1307 | + * jQuery UI Effects 1.12.0-rc.2 | |
1308 | + * http://jqueryui.com | |
1309 | + * | |
1310 | + * Copyright jQuery Foundation and other contributors | |
1311 | + * Released under the MIT license. | |
1312 | + * http://jquery.org/license | |
1313 | + */ | |
1314 | + | |
1315 | +//>>label: Effects Core | |
1316 | +//>>group: Effects | |
1317 | +// jscs:disable maximumLineLength | |
1318 | +//>>description: Extends the internal jQuery effects. Includes morphing and easing. Required by all other effects. | |
1319 | +// jscs:enable maximumLineLength | |
1320 | +//>>docs: http://api.jqueryui.com/category/effects-core/ | |
1321 | +//>>demos: http://jqueryui.com/effect/ | |
1322 | + | |
1323 | + | |
1324 | + | |
1325 | +var dataSpace = "ui-effects-", | |
1326 | + dataSpaceStyle = "ui-effects-style", | |
1327 | + dataSpaceAnimated = "ui-effects-animated", | |
1328 | + | |
1329 | + // Create a local jQuery because jQuery Color relies on it and the | |
1330 | + // global may not exist with AMD and a custom build (#10199) | |
1331 | + jQuery = $; | |
1332 | + | |
1333 | +$.effects = { | |
1334 | + effect: {} | |
1335 | +}; | |
1336 | + | |
1337 | +/*! | |
1338 | + * jQuery Color Animations v2.1.2 | |
1339 | + * https://github.com/jquery/jquery-color | |
1340 | + * | |
1341 | + * Copyright 2014 jQuery Foundation and other contributors | |
1342 | + * Released under the MIT license. | |
1343 | + * http://jquery.org/license | |
1344 | + * | |
1345 | + * Date: Wed Jan 16 08:47:09 2013 -0600 | |
1346 | + */ | |
1347 | +( function( jQuery, undefined ) { | |
1348 | + | |
1349 | + var stepHooks = "backgroundColor borderBottomColor borderLeftColor borderRightColor " + | |
1350 | + "borderTopColor color columnRuleColor outlineColor textDecorationColor textEmphasisColor", | |
1351 | + | |
1352 | + // Plusequals test for += 100 -= 100 | |
1353 | + rplusequals = /^([\-+])=\s*(\d+\.?\d*)/, | |
1354 | + | |
1355 | + // A set of RE's that can match strings and generate color tuples. | |
1356 | + stringParsers = [ { | |
1357 | + re: /rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/, | |
1358 | + parse: function( execResult ) { | |
1359 | + return [ | |
1360 | + execResult[ 1 ], | |
1361 | + execResult[ 2 ], | |
1362 | + execResult[ 3 ], | |
1363 | + execResult[ 4 ] | |
1364 | + ]; | |
1365 | + } | |
1366 | + }, { | |
1367 | + re: /rgba?\(\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/, | |
1368 | + parse: function( execResult ) { | |
1369 | + return [ | |
1370 | + execResult[ 1 ] * 2.55, | |
1371 | + execResult[ 2 ] * 2.55, | |
1372 | + execResult[ 3 ] * 2.55, | |
1373 | + execResult[ 4 ] | |
1374 | + ]; | |
1375 | + } | |
1376 | + }, { | |
1377 | + | |
1378 | + // This regex ignores A-F because it's compared against an already lowercased string | |
1379 | + re: /#([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})/, | |
1380 | + parse: function( execResult ) { | |
1381 | + return [ | |
1382 | + parseInt( execResult[ 1 ], 16 ), | |
1383 | + parseInt( execResult[ 2 ], 16 ), | |
1384 | + parseInt( execResult[ 3 ], 16 ) | |
1385 | + ]; | |
1386 | + } | |
1387 | + }, { | |
1388 | + | |
1389 | + // This regex ignores A-F because it's compared against an already lowercased string | |
1390 | + re: /#([a-f0-9])([a-f0-9])([a-f0-9])/, | |
1391 | + parse: function( execResult ) { | |
1392 | + return [ | |
1393 | + parseInt( execResult[ 1 ] + execResult[ 1 ], 16 ), | |
1394 | + parseInt( execResult[ 2 ] + execResult[ 2 ], 16 ), | |
1395 | + parseInt( execResult[ 3 ] + execResult[ 3 ], 16 ) | |
1396 | + ]; | |
1397 | + } | |
1398 | + }, { | |
1399 | + re: /hsla?\(\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/, | |
1400 | + space: "hsla", | |
1401 | + parse: function( execResult ) { | |
1402 | + return [ | |
1403 | + execResult[ 1 ], | |
1404 | + execResult[ 2 ] / 100, | |
1405 | + execResult[ 3 ] / 100, | |
1406 | + execResult[ 4 ] | |
1407 | + ]; | |
1408 | + } | |
1409 | + } ], | |
1410 | + | |
1411 | + // JQuery.Color( ) | |
1412 | + color = jQuery.Color = function( color, green, blue, alpha ) { | |
1413 | + return new jQuery.Color.fn.parse( color, green, blue, alpha ); | |
1414 | + }, | |
1415 | + spaces = { | |
1416 | + rgba: { | |
1417 | + props: { | |
1418 | + red: { | |
1419 | + idx: 0, | |
1420 | + type: "byte" | |
1421 | + }, | |
1422 | + green: { | |
1423 | + idx: 1, | |
1424 | + type: "byte" | |
1425 | + }, | |
1426 | + blue: { | |
1427 | + idx: 2, | |
1428 | + type: "byte" | |
1429 | + } | |
1430 | + } | |
1431 | + }, | |
1432 | + | |
1433 | + hsla: { | |
1434 | + props: { | |
1435 | + hue: { | |
1436 | + idx: 0, | |
1437 | + type: "degrees" | |
1438 | + }, | |
1439 | + saturation: { | |
1440 | + idx: 1, | |
1441 | + type: "percent" | |
1442 | + }, | |
1443 | + lightness: { | |
1444 | + idx: 2, | |
1445 | + type: "percent" | |
1446 | + } | |
1447 | + } | |
1448 | + } | |
1449 | + }, | |
1450 | + propTypes = { | |
1451 | + "byte": { | |
1452 | + floor: true, | |
1453 | + max: 255 | |
1454 | + }, | |
1455 | + "percent": { | |
1456 | + max: 1 | |
1457 | + }, | |
1458 | + "degrees": { | |
1459 | + mod: 360, | |
1460 | + floor: true | |
1461 | + } | |
1462 | + }, | |
1463 | + support = color.support = {}, | |
1464 | + | |
1465 | + // Element for support tests | |
1466 | + supportElem = jQuery( "<p>" )[ 0 ], | |
1467 | + | |
1468 | + // Colors = jQuery.Color.names | |
1469 | + colors, | |
1470 | + | |
1471 | + // Local aliases of functions called often | |
1472 | + each = jQuery.each; | |
1473 | + | |
1474 | +// Determine rgba support immediately | |
1475 | +supportElem.style.cssText = "background-color:rgba(1,1,1,.5)"; | |
1476 | +support.rgba = supportElem.style.backgroundColor.indexOf( "rgba" ) > -1; | |
1477 | + | |
1478 | +// Define cache name and alpha properties | |
1479 | +// for rgba and hsla spaces | |
1480 | +each( spaces, function( spaceName, space ) { | |
1481 | + space.cache = "_" + spaceName; | |
1482 | + space.props.alpha = { | |
1483 | + idx: 3, | |
1484 | + type: "percent", | |
1485 | + def: 1 | |
1486 | + }; | |
1487 | +} ); | |
1488 | + | |
1489 | +function clamp( value, prop, allowEmpty ) { | |
1490 | + var type = propTypes[ prop.type ] || {}; | |
1491 | + | |
1492 | + if ( value == null ) { | |
1493 | + return ( allowEmpty || !prop.def ) ? null : prop.def; | |
1494 | + } | |
1495 | + | |
1496 | + // ~~ is an short way of doing floor for positive numbers | |
1497 | + value = type.floor ? ~~value : parseFloat( value ); | |
1498 | + | |
1499 | + // IE will pass in empty strings as value for alpha, | |
1500 | + // which will hit this case | |
1501 | + if ( isNaN( value ) ) { | |
1502 | + return prop.def; | |
1503 | + } | |
1504 | + | |
1505 | + if ( type.mod ) { | |
1506 | + | |
1507 | + // We add mod before modding to make sure that negatives values | |
1508 | + // get converted properly: -10 -> 350 | |
1509 | + return ( value + type.mod ) % type.mod; | |
1510 | + } | |
1511 | + | |
1512 | + // For now all property types without mod have min and max | |
1513 | + return 0 > value ? 0 : type.max < value ? type.max : value; | |
1514 | +} | |
1515 | + | |
1516 | +function stringParse( string ) { | |
1517 | + var inst = color(), | |
1518 | + rgba = inst._rgba = []; | |
1519 | + | |
1520 | + string = string.toLowerCase(); | |
1521 | + | |
1522 | + each( stringParsers, function( i, parser ) { | |
1523 | + var parsed, | |
1524 | + match = parser.re.exec( string ), | |
1525 | + values = match && parser.parse( match ), | |
1526 | + spaceName = parser.space || "rgba"; | |
1527 | + | |
1528 | + if ( values ) { | |
1529 | + parsed = inst[ spaceName ]( values ); | |
1530 | + | |
1531 | + // If this was an rgba parse the assignment might happen twice | |
1532 | + // oh well.... | |
1533 | + inst[ spaces[ spaceName ].cache ] = parsed[ spaces[ spaceName ].cache ]; | |
1534 | + rgba = inst._rgba = parsed._rgba; | |
1535 | + | |
1536 | + // Exit each( stringParsers ) here because we matched | |
1537 | + return false; | |
1538 | + } | |
1539 | + } ); | |
1540 | + | |
1541 | + // Found a stringParser that handled it | |
1542 | + if ( rgba.length ) { | |
1543 | + | |
1544 | + // If this came from a parsed string, force "transparent" when alpha is 0 | |
1545 | + // chrome, (and maybe others) return "transparent" as rgba(0,0,0,0) | |
1546 | + if ( rgba.join() === "0,0,0,0" ) { | |
1547 | + jQuery.extend( rgba, colors.transparent ); | |
1548 | + } | |
1549 | + return inst; | |
1550 | + } | |
1551 | + | |
1552 | + // Named colors | |
1553 | + return colors[ string ]; | |
1554 | +} | |
1555 | + | |
1556 | +color.fn = jQuery.extend( color.prototype, { | |
1557 | + parse: function( red, green, blue, alpha ) { | |
1558 | + if ( red === undefined ) { | |
1559 | + this._rgba = [ null, null, null, null ]; | |
1560 | + return this; | |
1561 | + } | |
1562 | + if ( red.jquery || red.nodeType ) { | |
1563 | + red = jQuery( red ).css( green ); | |
1564 | + green = undefined; | |
1565 | + } | |
1566 | + | |
1567 | + var inst = this, | |
1568 | + type = jQuery.type( red ), | |
1569 | + rgba = this._rgba = []; | |
1570 | + | |
1571 | + // More than 1 argument specified - assume ( red, green, blue, alpha ) | |
1572 | + if ( green !== undefined ) { | |
1573 | + red = [ red, green, blue, alpha ]; | |
1574 | + type = "array"; | |
1575 | + } | |
1576 | + | |
1577 | + if ( type === "string" ) { | |
1578 | + return this.parse( stringParse( red ) || colors._default ); | |
1579 | + } | |
1580 | + | |
1581 | + if ( type === "array" ) { | |
1582 | + each( spaces.rgba.props, function( key, prop ) { | |
1583 | + rgba[ prop.idx ] = clamp( red[ prop.idx ], prop ); | |
1584 | + } ); | |
1585 | + return this; | |
1586 | + } | |
1587 | + | |
1588 | + if ( type === "object" ) { | |
1589 | + if ( red instanceof color ) { | |
1590 | + each( spaces, function( spaceName, space ) { | |
1591 | + if ( red[ space.cache ] ) { | |
1592 | + inst[ space.cache ] = red[ space.cache ].slice(); | |
1593 | + } | |
1594 | + } ); | |
1595 | + } else { | |
1596 | + each( spaces, function( spaceName, space ) { | |
1597 | + var cache = space.cache; | |
1598 | + each( space.props, function( key, prop ) { | |
1599 | + | |
1600 | + // If the cache doesn't exist, and we know how to convert | |
1601 | + if ( !inst[ cache ] && space.to ) { | |
1602 | + | |
1603 | + // If the value was null, we don't need to copy it | |
1604 | + // if the key was alpha, we don't need to copy it either | |
1605 | + if ( key === "alpha" || red[ key ] == null ) { | |
1606 | + return; | |
1607 | + } | |
1608 | + inst[ cache ] = space.to( inst._rgba ); | |
1609 | + } | |
1610 | + | |
1611 | + // This is the only case where we allow nulls for ALL properties. | |
1612 | + // call clamp with alwaysAllowEmpty | |
1613 | + inst[ cache ][ prop.idx ] = clamp( red[ key ], prop, true ); | |
1614 | + } ); | |
1615 | + | |
1616 | + // Everything defined but alpha? | |
1617 | + if ( inst[ cache ] && | |
1618 | + jQuery.inArray( null, inst[ cache ].slice( 0, 3 ) ) < 0 ) { | |
1619 | + | |
1620 | + // Use the default of 1 | |
1621 | + inst[ cache ][ 3 ] = 1; | |
1622 | + if ( space.from ) { | |
1623 | + inst._rgba = space.from( inst[ cache ] ); | |
1624 | + } | |
1625 | + } | |
1626 | + } ); | |
1627 | + } | |
1628 | + return this; | |
1629 | + } | |
1630 | + }, | |
1631 | + is: function( compare ) { | |
1632 | + var is = color( compare ), | |
1633 | + same = true, | |
1634 | + inst = this; | |
1635 | + | |
1636 | + each( spaces, function( _, space ) { | |
1637 | + var localCache, | |
1638 | + isCache = is[ space.cache ]; | |
1639 | + if ( isCache ) { | |
1640 | + localCache = inst[ space.cache ] || space.to && space.to( inst._rgba ) || []; | |
1641 | + each( space.props, function( _, prop ) { | |
1642 | + if ( isCache[ prop.idx ] != null ) { | |
1643 | + same = ( isCache[ prop.idx ] === localCache[ prop.idx ] ); | |
1644 | + return same; | |
1645 | + } | |
1646 | + } ); | |
1647 | + } | |
1648 | + return same; | |
1649 | + } ); | |
1650 | + return same; | |
1651 | + }, | |
1652 | + _space: function() { | |
1653 | + var used = [], | |
1654 | + inst = this; | |
1655 | + each( spaces, function( spaceName, space ) { | |
1656 | + if ( inst[ space.cache ] ) { | |
1657 | + used.push( spaceName ); | |
1658 | + } | |
1659 | + } ); | |
1660 | + return used.pop(); | |
1661 | + }, | |
1662 | + transition: function( other, distance ) { | |
1663 | + var end = color( other ), | |
1664 | + spaceName = end._space(), | |
1665 | + space = spaces[ spaceName ], | |
1666 | + startColor = this.alpha() === 0 ? color( "transparent" ) : this, | |
1667 | + start = startColor[ space.cache ] || space.to( startColor._rgba ), | |
1668 | + result = start.slice(); | |
1669 | + | |
1670 | + end = end[ space.cache ]; | |
1671 | + each( space.props, function( key, prop ) { | |
1672 | + var index = prop.idx, | |
1673 | + startValue = start[ index ], | |
1674 | + endValue = end[ index ], | |
1675 | + type = propTypes[ prop.type ] || {}; | |
1676 | + | |
1677 | + // If null, don't override start value | |
1678 | + if ( endValue === null ) { | |
1679 | + return; | |
1680 | + } | |
1681 | + | |
1682 | + // If null - use end | |
1683 | + if ( startValue === null ) { | |
1684 | + result[ index ] = endValue; | |
1685 | + } else { | |
1686 | + if ( type.mod ) { | |
1687 | + if ( endValue - startValue > type.mod / 2 ) { | |
1688 | + startValue += type.mod; | |
1689 | + } else if ( startValue - endValue > type.mod / 2 ) { | |
1690 | + startValue -= type.mod; | |
1691 | + } | |
1692 | + } | |
1693 | + result[ index ] = clamp( ( endValue - startValue ) * distance + startValue, prop ); | |
1694 | + } | |
1695 | + } ); | |
1696 | + return this[ spaceName ]( result ); | |
1697 | + }, | |
1698 | + blend: function( opaque ) { | |
1699 | + | |
1700 | + // If we are already opaque - return ourself | |
1701 | + if ( this._rgba[ 3 ] === 1 ) { | |
1702 | + return this; | |
1703 | + } | |
1704 | + | |
1705 | + var rgb = this._rgba.slice(), | |
1706 | + a = rgb.pop(), | |
1707 | + blend = color( opaque )._rgba; | |
1708 | + | |
1709 | + return color( jQuery.map( rgb, function( v, i ) { | |
1710 | + return ( 1 - a ) * blend[ i ] + a * v; | |
1711 | + } ) ); | |
1712 | + }, | |
1713 | + toRgbaString: function() { | |
1714 | + var prefix = "rgba(", | |
1715 | + rgba = jQuery.map( this._rgba, function( v, i ) { | |
1716 | + return v == null ? ( i > 2 ? 1 : 0 ) : v; | |
1717 | + } ); | |
1718 | + | |
1719 | + if ( rgba[ 3 ] === 1 ) { | |
1720 | + rgba.pop(); | |
1721 | + prefix = "rgb("; | |
1722 | + } | |
1723 | + | |
1724 | + return prefix + rgba.join() + ")"; | |
1725 | + }, | |
1726 | + toHslaString: function() { | |
1727 | + var prefix = "hsla(", | |
1728 | + hsla = jQuery.map( this.hsla(), function( v, i ) { | |
1729 | + if ( v == null ) { | |
1730 | + v = i > 2 ? 1 : 0; | |
1731 | + } | |
1732 | + | |
1733 | + // Catch 1 and 2 | |
1734 | + if ( i && i < 3 ) { | |
1735 | + v = Math.round( v * 100 ) + "%"; | |
1736 | + } | |
1737 | + return v; | |
1738 | + } ); | |
1739 | + | |
1740 | + if ( hsla[ 3 ] === 1 ) { | |
1741 | + hsla.pop(); | |
1742 | + prefix = "hsl("; | |
1743 | + } | |
1744 | + return prefix + hsla.join() + ")"; | |
1745 | + }, | |
1746 | + toHexString: function( includeAlpha ) { | |
1747 | + var rgba = this._rgba.slice(), | |
1748 | + alpha = rgba.pop(); | |
1749 | + | |
1750 | + if ( includeAlpha ) { | |
1751 | + rgba.push( ~~( alpha * 255 ) ); | |
1752 | + } | |
1753 | + | |
1754 | + return "#" + jQuery.map( rgba, function( v ) { | |
1755 | + | |
1756 | + // Default to 0 when nulls exist | |
1757 | + v = ( v || 0 ).toString( 16 ); | |
1758 | + return v.length === 1 ? "0" + v : v; | |
1759 | + } ).join( "" ); | |
1760 | + }, | |
1761 | + toString: function() { | |
1762 | + return this._rgba[ 3 ] === 0 ? "transparent" : this.toRgbaString(); | |
1763 | + } | |
1764 | +} ); | |
1765 | +color.fn.parse.prototype = color.fn; | |
1766 | + | |
1767 | +// Hsla conversions adapted from: | |
1768 | +// https://code.google.com/p/maashaack/source/browse/packages/graphics/trunk/src/graphics/colors/HUE2RGB.as?r=5021 | |
1769 | + | |
1770 | +function hue2rgb( p, q, h ) { | |
1771 | + h = ( h + 1 ) % 1; | |
1772 | + if ( h * 6 < 1 ) { | |
1773 | + return p + ( q - p ) * h * 6; | |
1774 | + } | |
1775 | + if ( h * 2 < 1 ) { | |
1776 | + return q; | |
1777 | + } | |
1778 | + if ( h * 3 < 2 ) { | |
1779 | + return p + ( q - p ) * ( ( 2 / 3 ) - h ) * 6; | |
1780 | + } | |
1781 | + return p; | |
1782 | +} | |
1783 | + | |
1784 | +spaces.hsla.to = function( rgba ) { | |
1785 | + if ( rgba[ 0 ] == null || rgba[ 1 ] == null || rgba[ 2 ] == null ) { | |
1786 | + return [ null, null, null, rgba[ 3 ] ]; | |
1787 | + } | |
1788 | + var r = rgba[ 0 ] / 255, | |
1789 | + g = rgba[ 1 ] / 255, | |
1790 | + b = rgba[ 2 ] / 255, | |
1791 | + a = rgba[ 3 ], | |
1792 | + max = Math.max( r, g, b ), | |
1793 | + min = Math.min( r, g, b ), | |
1794 | + diff = max - min, | |
1795 | + add = max + min, | |
1796 | + l = add * 0.5, | |
1797 | + h, s; | |
1798 | + | |
1799 | + if ( min === max ) { | |
1800 | + h = 0; | |
1801 | + } else if ( r === max ) { | |
1802 | + h = ( 60 * ( g - b ) / diff ) + 360; | |
1803 | + } else if ( g === max ) { | |
1804 | + h = ( 60 * ( b - r ) / diff ) + 120; | |
1805 | + } else { | |
1806 | + h = ( 60 * ( r - g ) / diff ) + 240; | |
1807 | + } | |
1808 | + | |
1809 | + // Chroma (diff) == 0 means greyscale which, by definition, saturation = 0% | |
1810 | + // otherwise, saturation is based on the ratio of chroma (diff) to lightness (add) | |
1811 | + if ( diff === 0 ) { | |
1812 | + s = 0; | |
1813 | + } else if ( l <= 0.5 ) { | |
1814 | + s = diff / add; | |
1815 | + } else { | |
1816 | + s = diff / ( 2 - add ); | |
1817 | + } | |
1818 | + return [ Math.round( h ) % 360, s, l, a == null ? 1 : a ]; | |
1819 | +}; | |
1820 | + | |
1821 | +spaces.hsla.from = function( hsla ) { | |
1822 | + if ( hsla[ 0 ] == null || hsla[ 1 ] == null || hsla[ 2 ] == null ) { | |
1823 | + return [ null, null, null, hsla[ 3 ] ]; | |
1824 | + } | |
1825 | + var h = hsla[ 0 ] / 360, | |
1826 | + s = hsla[ 1 ], | |
1827 | + l = hsla[ 2 ], | |
1828 | + a = hsla[ 3 ], | |
1829 | + q = l <= 0.5 ? l * ( 1 + s ) : l + s - l * s, | |
1830 | + p = 2 * l - q; | |
1831 | + | |
1832 | + return [ | |
1833 | + Math.round( hue2rgb( p, q, h + ( 1 / 3 ) ) * 255 ), | |
1834 | + Math.round( hue2rgb( p, q, h ) * 255 ), | |
1835 | + Math.round( hue2rgb( p, q, h - ( 1 / 3 ) ) * 255 ), | |
1836 | + a | |
1837 | + ]; | |
1838 | +}; | |
1839 | + | |
1840 | +each( spaces, function( spaceName, space ) { | |
1841 | + var props = space.props, | |
1842 | + cache = space.cache, | |
1843 | + to = space.to, | |
1844 | + from = space.from; | |
1845 | + | |
1846 | + // Makes rgba() and hsla() | |
1847 | + color.fn[ spaceName ] = function( value ) { | |
1848 | + | |
1849 | + // Generate a cache for this space if it doesn't exist | |
1850 | + if ( to && !this[ cache ] ) { | |
1851 | + this[ cache ] = to( this._rgba ); | |
1852 | + } | |
1853 | + if ( value === undefined ) { | |
1854 | + return this[ cache ].slice(); | |
1855 | + } | |
1856 | + | |
1857 | + var ret, | |
1858 | + type = jQuery.type( value ), | |
1859 | + arr = ( type === "array" || type === "object" ) ? value : arguments, | |
1860 | + local = this[ cache ].slice(); | |
1861 | + | |
1862 | + each( props, function( key, prop ) { | |
1863 | + var val = arr[ type === "object" ? key : prop.idx ]; | |
1864 | + if ( val == null ) { | |
1865 | + val = local[ prop.idx ]; | |
1866 | + } | |
1867 | + local[ prop.idx ] = clamp( val, prop ); | |
1868 | + } ); | |
1869 | + | |
1870 | + if ( from ) { | |
1871 | + ret = color( from( local ) ); | |
1872 | + ret[ cache ] = local; | |
1873 | + return ret; | |
1874 | + } else { | |
1875 | + return color( local ); | |
1876 | + } | |
1877 | + }; | |
1878 | + | |
1879 | + // Makes red() green() blue() alpha() hue() saturation() lightness() | |
1880 | + each( props, function( key, prop ) { | |
1881 | + | |
1882 | + // Alpha is included in more than one space | |
1883 | + if ( color.fn[ key ] ) { | |
1884 | + return; | |
1885 | + } | |
1886 | + color.fn[ key ] = function( value ) { | |
1887 | + var vtype = jQuery.type( value ), | |
1888 | + fn = ( key === "alpha" ? ( this._hsla ? "hsla" : "rgba" ) : spaceName ), | |
1889 | + local = this[ fn ](), | |
1890 | + cur = local[ prop.idx ], | |
1891 | + match; | |
1892 | + | |
1893 | + if ( vtype === "undefined" ) { | |
1894 | + return cur; | |
1895 | + } | |
1896 | + | |
1897 | + if ( vtype === "function" ) { | |
1898 | + value = value.call( this, cur ); | |
1899 | + vtype = jQuery.type( value ); | |
1900 | + } | |
1901 | + if ( value == null && prop.empty ) { | |
1902 | + return this; | |
1903 | + } | |
1904 | + if ( vtype === "string" ) { | |
1905 | + match = rplusequals.exec( value ); | |
1906 | + if ( match ) { | |
1907 | + value = cur + parseFloat( match[ 2 ] ) * ( match[ 1 ] === "+" ? 1 : -1 ); | |
1908 | + } | |
1909 | + } | |
1910 | + local[ prop.idx ] = value; | |
1911 | + return this[ fn ]( local ); | |
1912 | + }; | |
1913 | + } ); | |
1914 | +} ); | |
1915 | + | |
1916 | +// Add cssHook and .fx.step function for each named hook. | |
1917 | +// accept a space separated string of properties | |
1918 | +color.hook = function( hook ) { | |
1919 | + var hooks = hook.split( " " ); | |
1920 | + each( hooks, function( i, hook ) { | |
1921 | + jQuery.cssHooks[ hook ] = { | |
1922 | + set: function( elem, value ) { | |
1923 | + var parsed, curElem, | |
1924 | + backgroundColor = ""; | |
1925 | + | |
1926 | + if ( value !== "transparent" && ( jQuery.type( value ) !== "string" || | |
1927 | + ( parsed = stringParse( value ) ) ) ) { | |
1928 | + value = color( parsed || value ); | |
1929 | + if ( !support.rgba && value._rgba[ 3 ] !== 1 ) { | |
1930 | + curElem = hook === "backgroundColor" ? elem.parentNode : elem; | |
1931 | + while ( | |
1932 | + ( backgroundColor === "" || backgroundColor === "transparent" ) && | |
1933 | + curElem && curElem.style | |
1934 | + ) { | |
1935 | + try { | |
1936 | + backgroundColor = jQuery.css( curElem, "backgroundColor" ); | |
1937 | + curElem = curElem.parentNode; | |
1938 | + } catch ( e ) { | |
1939 | + } | |
1940 | + } | |
1941 | + | |
1942 | + value = value.blend( backgroundColor && backgroundColor !== "transparent" ? | |
1943 | + backgroundColor : | |
1944 | + "_default" ); | |
1945 | + } | |
1946 | + | |
1947 | + value = value.toRgbaString(); | |
1948 | + } | |
1949 | + try { | |
1950 | + elem.style[ hook ] = value; | |
1951 | + } catch ( e ) { | |
1952 | + | |
1953 | + // Wrapped to prevent IE from throwing errors on "invalid" values like | |
1954 | + // 'auto' or 'inherit' | |
1955 | + } | |
1956 | + } | |
1957 | + }; | |
1958 | + jQuery.fx.step[ hook ] = function( fx ) { | |
1959 | + if ( !fx.colorInit ) { | |
1960 | + fx.start = color( fx.elem, hook ); | |
1961 | + fx.end = color( fx.end ); | |
1962 | + fx.colorInit = true; | |
1963 | + } | |
1964 | + jQuery.cssHooks[ hook ].set( fx.elem, fx.start.transition( fx.end, fx.pos ) ); | |
1965 | + }; | |
1966 | + } ); | |
1967 | + | |
1968 | +}; | |
1969 | + | |
1970 | +color.hook( stepHooks ); | |
1971 | + | |
1972 | +jQuery.cssHooks.borderColor = { | |
1973 | + expand: function( value ) { | |
1974 | + var expanded = {}; | |
1975 | + | |
1976 | + each( [ "Top", "Right", "Bottom", "Left" ], function( i, part ) { | |
1977 | + expanded[ "border" + part + "Color" ] = value; | |
1978 | + } ); | |
1979 | + return expanded; | |
1980 | + } | |
1981 | +}; | |
1982 | + | |
1983 | +// Basic color names only. | |
1984 | +// Usage of any of the other color names requires adding yourself or including | |
1985 | +// jquery.color.svg-names.js. | |
1986 | +colors = jQuery.Color.names = { | |
1987 | + | |
1988 | + // 4.1. Basic color keywords | |
1989 | + aqua: "#00ffff", | |
1990 | + black: "#000000", | |
1991 | + blue: "#0000ff", | |
1992 | + fuchsia: "#ff00ff", | |
1993 | + gray: "#808080", | |
1994 | + green: "#008000", | |
1995 | + lime: "#00ff00", | |
1996 | + maroon: "#800000", | |
1997 | + navy: "#000080", | |
1998 | + olive: "#808000", | |
1999 | + purple: "#800080", | |
2000 | + red: "#ff0000", | |
2001 | + silver: "#c0c0c0", | |
2002 | + teal: "#008080", | |
2003 | + white: "#ffffff", | |
2004 | + yellow: "#ffff00", | |
2005 | + | |
2006 | + // 4.2.3. "transparent" color keyword | |
2007 | + transparent: [ null, null, null, 0 ], | |
2008 | + | |
2009 | + _default: "#ffffff" | |
2010 | +}; | |
2011 | + | |
2012 | +} )( jQuery ); | |
2013 | + | |
2014 | +/******************************************************************************/ | |
2015 | +/****************************** CLASS ANIMATIONS ******************************/ | |
2016 | +/******************************************************************************/ | |
2017 | +( function() { | |
2018 | + | |
2019 | +var classAnimationActions = [ "add", "remove", "toggle" ], | |
2020 | + shorthandStyles = { | |
2021 | + border: 1, | |
2022 | + borderBottom: 1, | |
2023 | + borderColor: 1, | |
2024 | + borderLeft: 1, | |
2025 | + borderRight: 1, | |
2026 | + borderTop: 1, | |
2027 | + borderWidth: 1, | |
2028 | + margin: 1, | |
2029 | + padding: 1 | |
2030 | + }; | |
2031 | + | |
2032 | +$.each( | |
2033 | + [ "borderLeftStyle", "borderRightStyle", "borderBottomStyle", "borderTopStyle" ], | |
2034 | + function( _, prop ) { | |
2035 | + $.fx.step[ prop ] = function( fx ) { | |
2036 | + if ( fx.end !== "none" && !fx.setAttr || fx.pos === 1 && !fx.setAttr ) { | |
2037 | + jQuery.style( fx.elem, prop, fx.end ); | |
2038 | + fx.setAttr = true; | |
2039 | + } | |
2040 | + }; | |
2041 | + } | |
2042 | +); | |
2043 | + | |
2044 | +function getElementStyles( elem ) { | |
2045 | + var key, len, | |
2046 | + style = elem.ownerDocument.defaultView ? | |
2047 | + elem.ownerDocument.defaultView.getComputedStyle( elem, null ) : | |
2048 | + elem.currentStyle, | |
2049 | + styles = {}; | |
2050 | + | |
2051 | + if ( style && style.length && style[ 0 ] && style[ style[ 0 ] ] ) { | |
2052 | + len = style.length; | |
2053 | + while ( len-- ) { | |
2054 | + key = style[ len ]; | |
2055 | + if ( typeof style[ key ] === "string" ) { | |
2056 | + styles[ $.camelCase( key ) ] = style[ key ]; | |
2057 | + } | |
2058 | + } | |
2059 | + | |
2060 | + // Support: Opera, IE <9 | |
2061 | + } else { | |
2062 | + for ( key in style ) { | |
2063 | + if ( typeof style[ key ] === "string" ) { | |
2064 | + styles[ key ] = style[ key ]; | |
2065 | + } | |
2066 | + } | |
2067 | + } | |
2068 | + | |
2069 | + return styles; | |
2070 | +} | |
2071 | + | |
2072 | +function styleDifference( oldStyle, newStyle ) { | |
2073 | + var diff = {}, | |
2074 | + name, value; | |
2075 | + | |
2076 | + for ( name in newStyle ) { | |
2077 | + value = newStyle[ name ]; | |
2078 | + if ( oldStyle[ name ] !== value ) { | |
2079 | + if ( !shorthandStyles[ name ] ) { | |
2080 | + if ( $.fx.step[ name ] || !isNaN( parseFloat( value ) ) ) { | |
2081 | + diff[ name ] = value; | |
2082 | + } | |
2083 | + } | |
2084 | + } | |
2085 | + } | |
2086 | + | |
2087 | + return diff; | |
2088 | +} | |
2089 | + | |
2090 | +// Support: jQuery <1.8 | |
2091 | +if ( !$.fn.addBack ) { | |
2092 | + $.fn.addBack = function( selector ) { | |
2093 | + return this.add( selector == null ? | |
2094 | + this.prevObject : this.prevObject.filter( selector ) | |
2095 | + ); | |
2096 | + }; | |
2097 | +} | |
2098 | + | |
2099 | +$.effects.animateClass = function( value, duration, easing, callback ) { | |
2100 | + var o = $.speed( duration, easing, callback ); | |
2101 | + | |
2102 | + return this.queue( function() { | |
2103 | + var animated = $( this ), | |
2104 | + baseClass = animated.attr( "class" ) || "", | |
2105 | + applyClassChange, | |
2106 | + allAnimations = o.children ? animated.find( "*" ).addBack() : animated; | |
2107 | + | |
2108 | + // Map the animated objects to store the original styles. | |
2109 | + allAnimations = allAnimations.map( function() { | |
2110 | + var el = $( this ); | |
2111 | + return { | |
2112 | + el: el, | |
2113 | + start: getElementStyles( this ) | |
2114 | + }; | |
2115 | + } ); | |
2116 | + | |
2117 | + // Apply class change | |
2118 | + applyClassChange = function() { | |
2119 | + $.each( classAnimationActions, function( i, action ) { | |
2120 | + if ( value[ action ] ) { | |
2121 | + animated[ action + "Class" ]( value[ action ] ); | |
2122 | + } | |
2123 | + } ); | |
2124 | + }; | |
2125 | + applyClassChange(); | |
2126 | + | |
2127 | + // Map all animated objects again - calculate new styles and diff | |
2128 | + allAnimations = allAnimations.map( function() { | |
2129 | + this.end = getElementStyles( this.el[ 0 ] ); | |
2130 | + this.diff = styleDifference( this.start, this.end ); | |
2131 | + return this; | |
2132 | + } ); | |
2133 | + | |
2134 | + // Apply original class | |
2135 | + animated.attr( "class", baseClass ); | |
2136 | + | |
2137 | + // Map all animated objects again - this time collecting a promise | |
2138 | + allAnimations = allAnimations.map( function() { | |
2139 | + var styleInfo = this, | |
2140 | + dfd = $.Deferred(), | |
2141 | + opts = $.extend( {}, o, { | |
2142 | + queue: false, | |
2143 | + complete: function() { | |
2144 | + dfd.resolve( styleInfo ); | |
2145 | + } | |
2146 | + } ); | |
2147 | + | |
2148 | + this.el.animate( this.diff, opts ); | |
2149 | + return dfd.promise(); | |
2150 | + } ); | |
2151 | + | |
2152 | + // Once all animations have completed: | |
2153 | + $.when.apply( $, allAnimations.get() ).done( function() { | |
2154 | + | |
2155 | + // Set the final class | |
2156 | + applyClassChange(); | |
2157 | + | |
2158 | + // For each animated element, | |
2159 | + // clear all css properties that were animated | |
2160 | + $.each( arguments, function() { | |
2161 | + var el = this.el; | |
2162 | + $.each( this.diff, function( key ) { | |
2163 | + el.css( key, "" ); | |
2164 | + } ); | |
2165 | + } ); | |
2166 | + | |
2167 | + // This is guarnteed to be there if you use jQuery.speed() | |
2168 | + // it also handles dequeuing the next anim... | |
2169 | + o.complete.call( animated[ 0 ] ); | |
2170 | + } ); | |
2171 | + } ); | |
2172 | +}; | |
2173 | + | |
2174 | +$.fn.extend( { | |
2175 | + addClass: ( function( orig ) { | |
2176 | + return function( classNames, speed, easing, callback ) { | |
2177 | + return speed ? | |
2178 | + $.effects.animateClass.call( this, | |
2179 | + { add: classNames }, speed, easing, callback ) : | |
2180 | + orig.apply( this, arguments ); | |
2181 | + }; | |
2182 | + } )( $.fn.addClass ), | |
2183 | + | |
2184 | + removeClass: ( function( orig ) { | |
2185 | + return function( classNames, speed, easing, callback ) { | |
2186 | + return arguments.length > 1 ? | |
2187 | + $.effects.animateClass.call( this, | |
2188 | + { remove: classNames }, speed, easing, callback ) : | |
2189 | + orig.apply( this, arguments ); | |
2190 | + }; | |
2191 | + } )( $.fn.removeClass ), | |
2192 | + | |
2193 | + toggleClass: ( function( orig ) { | |
2194 | + return function( classNames, force, speed, easing, callback ) { | |
2195 | + if ( typeof force === "boolean" || force === undefined ) { | |
2196 | + if ( !speed ) { | |
2197 | + | |
2198 | + // Without speed parameter | |
2199 | + return orig.apply( this, arguments ); | |
2200 | + } else { | |
2201 | + return $.effects.animateClass.call( this, | |
2202 | + ( force ? { add: classNames } : { remove: classNames } ), | |
2203 | + speed, easing, callback ); | |
2204 | + } | |
2205 | + } else { | |
2206 | + | |
2207 | + // Without force parameter | |
2208 | + return $.effects.animateClass.call( this, | |
2209 | + { toggle: classNames }, force, speed, easing ); | |
2210 | + } | |
2211 | + }; | |
2212 | + } )( $.fn.toggleClass ), | |
2213 | + | |
2214 | + switchClass: function( remove, add, speed, easing, callback ) { | |
2215 | + return $.effects.animateClass.call( this, { | |
2216 | + add: add, | |
2217 | + remove: remove | |
2218 | + }, speed, easing, callback ); | |
2219 | + } | |
2220 | +} ); | |
2221 | + | |
2222 | +} )(); | |
2223 | + | |
2224 | +/******************************************************************************/ | |
2225 | +/*********************************** EFFECTS **********************************/ | |
2226 | +/******************************************************************************/ | |
2227 | + | |
2228 | +( function() { | |
2229 | + | |
2230 | +if ( $.expr && $.expr.filters && $.expr.filters.animated ) { | |
2231 | + $.expr.filters.animated = ( function( orig ) { | |
2232 | + return function( elem ) { | |
2233 | + return !!$( elem ).data( dataSpaceAnimated ) || orig( elem ); | |
2234 | + }; | |
2235 | + } )( $.expr.filters.animated ); | |
2236 | +} | |
2237 | + | |
2238 | +if ( $.uiBackCompat !== false ) { | |
2239 | + $.extend( $.effects, { | |
2240 | + | |
2241 | + // Saves a set of properties in a data storage | |
2242 | + save: function( element, set ) { | |
2243 | + var i = 0, length = set.length; | |
2244 | + for ( ; i < length; i++ ) { | |
2245 | + if ( set[ i ] !== null ) { | |
2246 | + element.data( dataSpace + set[ i ], element[ 0 ].style[ set[ i ] ] ); | |
2247 | + } | |
2248 | + } | |
2249 | + }, | |
2250 | + | |
2251 | + // Restores a set of previously saved properties from a data storage | |
2252 | + restore: function( element, set ) { | |
2253 | + var val, i = 0, length = set.length; | |
2254 | + for ( ; i < length; i++ ) { | |
2255 | + if ( set[ i ] !== null ) { | |
2256 | + val = element.data( dataSpace + set[ i ] ); | |
2257 | + element.css( set[ i ], val ); | |
2258 | + } | |
2259 | + } | |
2260 | + }, | |
2261 | + | |
2262 | + setMode: function( el, mode ) { | |
2263 | + if ( mode === "toggle" ) { | |
2264 | + mode = el.is( ":hidden" ) ? "show" : "hide"; | |
2265 | + } | |
2266 | + return mode; | |
2267 | + }, | |
2268 | + | |
2269 | + // Wraps the element around a wrapper that copies position properties | |
2270 | + createWrapper: function( element ) { | |
2271 | + | |
2272 | + // If the element is already wrapped, return it | |
2273 | + if ( element.parent().is( ".ui-effects-wrapper" ) ) { | |
2274 | + return element.parent(); | |
2275 | + } | |
2276 | + | |
2277 | + // Wrap the element | |
2278 | + var props = { | |
2279 | + width: element.outerWidth( true ), | |
2280 | + height: element.outerHeight( true ), | |
2281 | + "float": element.css( "float" ) | |
2282 | + }, | |
2283 | + wrapper = $( "<div></div>" ) | |
2284 | + .addClass( "ui-effects-wrapper" ) | |
2285 | + .css( { | |
2286 | + fontSize: "100%", | |
2287 | + background: "transparent", | |
2288 | + border: "none", | |
2289 | + margin: 0, | |
2290 | + padding: 0 | |
2291 | + } ), | |
2292 | + | |
2293 | + // Store the size in case width/height are defined in % - Fixes #5245 | |
2294 | + size = { | |
2295 | + width: element.width(), | |
2296 | + height: element.height() | |
2297 | + }, | |
2298 | + active = document.activeElement; | |
2299 | + | |
2300 | + // Support: Firefox | |
2301 | + // Firefox incorrectly exposes anonymous content | |
2302 | + // https://bugzilla.mozilla.org/show_bug.cgi?id=561664 | |
2303 | + try { | |
2304 | + active.id; | |
2305 | + } catch ( e ) { | |
2306 | + active = document.body; | |
2307 | + } | |
2308 | + | |
2309 | + element.wrap( wrapper ); | |
2310 | + | |
2311 | + // Fixes #7595 - Elements lose focus when wrapped. | |
2312 | + if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) { | |
2313 | + $( active ).trigger( "focus" ); | |
2314 | + } | |
2315 | + | |
2316 | + // Hotfix for jQuery 1.4 since some change in wrap() seems to actually | |
2317 | + // lose the reference to the wrapped element | |
2318 | + wrapper = element.parent(); | |
2319 | + | |
2320 | + // Transfer positioning properties to the wrapper | |
2321 | + if ( element.css( "position" ) === "static" ) { | |
2322 | + wrapper.css( { position: "relative" } ); | |
2323 | + element.css( { position: "relative" } ); | |
2324 | + } else { | |
2325 | + $.extend( props, { | |
2326 | + position: element.css( "position" ), | |
2327 | + zIndex: element.css( "z-index" ) | |
2328 | + } ); | |
2329 | + $.each( [ "top", "left", "bottom", "right" ], function( i, pos ) { | |
2330 | + props[ pos ] = element.css( pos ); | |
2331 | + if ( isNaN( parseInt( props[ pos ], 10 ) ) ) { | |
2332 | + props[ pos ] = "auto"; | |
2333 | + } | |
2334 | + } ); | |
2335 | + element.css( { | |
2336 | + position: "relative", | |
2337 | + top: 0, | |
2338 | + left: 0, | |
2339 | + right: "auto", | |
2340 | + bottom: "auto" | |
2341 | + } ); | |
2342 | + } | |
2343 | + element.css( size ); | |
2344 | + | |
2345 | + return wrapper.css( props ).show(); | |
2346 | + }, | |
2347 | + | |
2348 | + removeWrapper: function( element ) { | |
2349 | + var active = document.activeElement; | |
2350 | + | |
2351 | + if ( element.parent().is( ".ui-effects-wrapper" ) ) { | |
2352 | + element.parent().replaceWith( element ); | |
2353 | + | |
2354 | + // Fixes #7595 - Elements lose focus when wrapped. | |
2355 | + if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) { | |
2356 | + $( active ).trigger( "focus" ); | |
2357 | + } | |
2358 | + } | |
2359 | + | |
2360 | + return element; | |
2361 | + } | |
2362 | + } ); | |
2363 | +} | |
2364 | + | |
2365 | +$.extend( $.effects, { | |
2366 | + version: "1.12.0-rc.2", | |
2367 | + | |
2368 | + define: function( name, mode, effect ) { | |
2369 | + if ( !effect ) { | |
2370 | + effect = mode; | |
2371 | + mode = "effect"; | |
2372 | + } | |
2373 | + | |
2374 | + $.effects.effect[ name ] = effect; | |
2375 | + $.effects.effect[ name ].mode = mode; | |
2376 | + | |
2377 | + return effect; | |
2378 | + }, | |
2379 | + | |
2380 | + scaledDimensions: function( element, percent, direction ) { | |
2381 | + if ( percent === 0 ) { | |
2382 | + return { | |
2383 | + height: 0, | |
2384 | + width: 0, | |
2385 | + outerHeight: 0, | |
2386 | + outerWidth: 0 | |
2387 | + }; | |
2388 | + } | |
2389 | + | |
2390 | + var x = direction !== "horizontal" ? ( ( percent || 100 ) / 100 ) : 1, | |
2391 | + y = direction !== "vertical" ? ( ( percent || 100 ) / 100 ) : 1; | |
2392 | + | |
2393 | + return { | |
2394 | + height: element.height() * y, | |
2395 | + width: element.width() * x, | |
2396 | + outerHeight: element.outerHeight() * y, | |
2397 | + outerWidth: element.outerWidth() * x | |
2398 | + }; | |
2399 | + | |
2400 | + }, | |
2401 | + | |
2402 | + clipToBox: function( animation ) { | |
2403 | + return { | |
2404 | + width: animation.clip.right - animation.clip.left, | |
2405 | + height: animation.clip.bottom - animation.clip.top, | |
2406 | + left: animation.clip.left, | |
2407 | + top: animation.clip.top | |
2408 | + }; | |
2409 | + }, | |
2410 | + | |
2411 | + // Injects recently queued functions to be first in line (after "inprogress") | |
2412 | + unshift: function( element, queueLength, count ) { | |
2413 | + var queue = element.queue(); | |
2414 | + | |
2415 | + if ( queueLength > 1 ) { | |
2416 | + queue.splice.apply( queue, | |
2417 | + [ 1, 0 ].concat( queue.splice( queueLength, count ) ) ); | |
2418 | + } | |
2419 | + element.dequeue(); | |
2420 | + }, | |
2421 | + | |
2422 | + saveStyle: function( element ) { | |
2423 | + element.data( dataSpaceStyle, element[ 0 ].style.cssText ); | |
2424 | + }, | |
2425 | + | |
2426 | + restoreStyle: function( element ) { | |
2427 | + element[ 0 ].style.cssText = element.data( dataSpaceStyle ) || ""; | |
2428 | + element.removeData( dataSpaceStyle ); | |
2429 | + }, | |
2430 | + | |
2431 | + mode: function( element, mode ) { | |
2432 | + var hidden = element.is( ":hidden" ); | |
2433 | + | |
2434 | + if ( mode === "toggle" ) { | |
2435 | + mode = hidden ? "show" : "hide"; | |
2436 | + } | |
2437 | + if ( hidden ? mode === "hide" : mode === "show" ) { | |
2438 | + mode = "none"; | |
2439 | + } | |
2440 | + return mode; | |
2441 | + }, | |
2442 | + | |
2443 | + // Translates a [top,left] array into a baseline value | |
2444 | + getBaseline: function( origin, original ) { | |
2445 | + var y, x; | |
2446 | + | |
2447 | + switch ( origin[ 0 ] ) { | |
2448 | + case "top": | |
2449 | + y = 0; | |
2450 | + break; | |
2451 | + case "middle": | |
2452 | + y = 0.5; | |
2453 | + break; | |
2454 | + case "bottom": | |
2455 | + y = 1; | |
2456 | + break; | |
2457 | + default: | |
2458 | + y = origin[ 0 ] / original.height; | |
2459 | + } | |
2460 | + | |
2461 | + switch ( origin[ 1 ] ) { | |
2462 | + case "left": | |
2463 | + x = 0; | |
2464 | + break; | |
2465 | + case "center": | |
2466 | + x = 0.5; | |
2467 | + break; | |
2468 | + case "right": | |
2469 | + x = 1; | |
2470 | + break; | |
2471 | + default: | |
2472 | + x = origin[ 1 ] / original.width; | |
2473 | + } | |
2474 | + | |
2475 | + return { | |
2476 | + x: x, | |
2477 | + y: y | |
2478 | + }; | |
2479 | + }, | |
2480 | + | |
2481 | + // Creates a placeholder element so that the original element can be made absolute | |
2482 | + createPlaceholder: function( element ) { | |
2483 | + var placeholder, | |
2484 | + cssPosition = element.css( "position" ), | |
2485 | + position = element.position(); | |
2486 | + | |
2487 | + // Lock in margins first to account for form elements, which | |
2488 | + // will change margin if you explicitly set height | |
2489 | + // see: http://jsfiddle.net/JZSMt/3/ https://bugs.webkit.org/show_bug.cgi?id=107380 | |
2490 | + // Support: Safari | |
2491 | + element.css( { | |
2492 | + marginTop: element.css( "marginTop" ), | |
2493 | + marginBottom: element.css( "marginBottom" ), | |
2494 | + marginLeft: element.css( "marginLeft" ), | |
2495 | + marginRight: element.css( "marginRight" ) | |
2496 | + } ) | |
2497 | + .outerWidth( element.outerWidth() ) | |
2498 | + .outerHeight( element.outerHeight() ); | |
2499 | + | |
2500 | + if ( /^(static|relative)/.test( cssPosition ) ) { | |
2501 | + cssPosition = "absolute"; | |
2502 | + | |
2503 | + placeholder = $( "<" + element[ 0 ].nodeName + ">" ).insertAfter( element ).css( { | |
2504 | + | |
2505 | + // Convert inline to inline block to account for inline elements | |
2506 | + // that turn to inline block based on content (like img) | |
2507 | + display: /^(inline|ruby)/.test( element.css( "display" ) ) ? | |
2508 | + "inline-block" : | |
2509 | + "block", | |
2510 | + visibility: "hidden", | |
2511 | + | |
2512 | + // Margins need to be set to account for margin collapse | |
2513 | + marginTop: element.css( "marginTop" ), | |
2514 | + marginBottom: element.css( "marginBottom" ), | |
2515 | + marginLeft: element.css( "marginLeft" ), | |
2516 | + marginRight: element.css( "marginRight" ), | |
2517 | + "float": element.css( "float" ) | |
2518 | + } ) | |
2519 | + .outerWidth( element.outerWidth() ) | |
2520 | + .outerHeight( element.outerHeight() ) | |
2521 | + .addClass( "ui-effects-placeholder" ); | |
2522 | + | |
2523 | + element.data( dataSpace + "placeholder", placeholder ); | |
2524 | + } | |
2525 | + | |
2526 | + element.css( { | |
2527 | + position: cssPosition, | |
2528 | + left: position.left, | |
2529 | + top: position.top | |
2530 | + } ); | |
2531 | + | |
2532 | + return placeholder; | |
2533 | + }, | |
2534 | + | |
2535 | + removePlaceholder: function( element ) { | |
2536 | + var dataKey = dataSpace + "placeholder", | |
2537 | + placeholder = element.data( dataKey ); | |
2538 | + | |
2539 | + if ( placeholder ) { | |
2540 | + placeholder.remove(); | |
2541 | + element.removeData( dataKey ); | |
2542 | + } | |
2543 | + }, | |
2544 | + | |
2545 | + // Removes a placeholder if it exists and restores | |
2546 | + // properties that were modified during placeholder creation | |
2547 | + cleanUp: function( element ) { | |
2548 | + $.effects.restoreStyle( element ); | |
2549 | + $.effects.removePlaceholder( element ); | |
2550 | + }, | |
2551 | + | |
2552 | + setTransition: function( element, list, factor, value ) { | |
2553 | + value = value || {}; | |
2554 | + $.each( list, function( i, x ) { | |
2555 | + var unit = element.cssUnit( x ); | |
2556 | + if ( unit[ 0 ] > 0 ) { | |
2557 | + value[ x ] = unit[ 0 ] * factor + unit[ 1 ]; | |
2558 | + } | |
2559 | + } ); | |
2560 | + return value; | |
2561 | + } | |
2562 | +} ); | |
2563 | + | |
2564 | +// Return an effect options object for the given parameters: | |
2565 | +function _normalizeArguments( effect, options, speed, callback ) { | |
2566 | + | |
2567 | + // Allow passing all options as the first parameter | |
2568 | + if ( $.isPlainObject( effect ) ) { | |
2569 | + options = effect; | |
2570 | + effect = effect.effect; | |
2571 | + } | |
2572 | + | |
2573 | + // Convert to an object | |
2574 | + effect = { effect: effect }; | |
2575 | + | |
2576 | + // Catch (effect, null, ...) | |
2577 | + if ( options == null ) { | |
2578 | + options = {}; | |
2579 | + } | |
2580 | + | |
2581 | + // Catch (effect, callback) | |
2582 | + if ( $.isFunction( options ) ) { | |
2583 | + callback = options; | |
2584 | + speed = null; | |
2585 | + options = {}; | |
2586 | + } | |
2587 | + | |
2588 | + // Catch (effect, speed, ?) | |
2589 | + if ( typeof options === "number" || $.fx.speeds[ options ] ) { | |
2590 | + callback = speed; | |
2591 | + speed = options; | |
2592 | + options = {}; | |
2593 | + } | |
2594 | + | |
2595 | + // Catch (effect, options, callback) | |
2596 | + if ( $.isFunction( speed ) ) { | |
2597 | + callback = speed; | |
2598 | + speed = null; | |
2599 | + } | |
2600 | + | |
2601 | + // Add options to effect | |
2602 | + if ( options ) { | |
2603 | + $.extend( effect, options ); | |
2604 | + } | |
2605 | + | |
2606 | + speed = speed || options.duration; | |
2607 | + effect.duration = $.fx.off ? 0 : | |
2608 | + typeof speed === "number" ? speed : | |
2609 | + speed in $.fx.speeds ? $.fx.speeds[ speed ] : | |
2610 | + $.fx.speeds._default; | |
2611 | + | |
2612 | + effect.complete = callback || options.complete; | |
2613 | + | |
2614 | + return effect; | |
2615 | +} | |
2616 | + | |
2617 | +function standardAnimationOption( option ) { | |
2618 | + | |
2619 | + // Valid standard speeds (nothing, number, named speed) | |
2620 | + if ( !option || typeof option === "number" || $.fx.speeds[ option ] ) { | |
2621 | + return true; | |
2622 | + } | |
2623 | + | |
2624 | + // Invalid strings - treat as "normal" speed | |
2625 | + if ( typeof option === "string" && !$.effects.effect[ option ] ) { | |
2626 | + return true; | |
2627 | + } | |
2628 | + | |
2629 | + // Complete callback | |
2630 | + if ( $.isFunction( option ) ) { | |
2631 | + return true; | |
2632 | + } | |
2633 | + | |
2634 | + // Options hash (but not naming an effect) | |
2635 | + if ( typeof option === "object" && !option.effect ) { | |
2636 | + return true; | |
2637 | + } | |
2638 | + | |
2639 | + // Didn't match any standard API | |
2640 | + return false; | |
2641 | +} | |
2642 | + | |
2643 | +$.fn.extend( { | |
2644 | + effect: function( /* effect, options, speed, callback */ ) { | |
2645 | + var args = _normalizeArguments.apply( this, arguments ), | |
2646 | + effectMethod = $.effects.effect[ args.effect ], | |
2647 | + defaultMode = effectMethod.mode, | |
2648 | + queue = args.queue, | |
2649 | + queueName = queue || "fx", | |
2650 | + complete = args.complete, | |
2651 | + mode = args.mode, | |
2652 | + modes = [], | |
2653 | + prefilter = function( next ) { | |
2654 | + var el = $( this ), | |
2655 | + normalizedMode = $.effects.mode( el, mode ) || defaultMode; | |
2656 | + | |
2657 | + // Sentinel for duck-punching the :animated psuedo-selector | |
2658 | + el.data( dataSpaceAnimated, true ); | |
2659 | + | |
2660 | + // Save effect mode for later use, | |
2661 | + // we can't just call $.effects.mode again later, | |
2662 | + // as the .show() below destroys the initial state | |
2663 | + modes.push( normalizedMode ); | |
2664 | + | |
2665 | + // See $.uiBackCompat inside of run() for removal of defaultMode in 1.13 | |
2666 | + if ( defaultMode && ( normalizedMode === "show" || | |
2667 | + ( normalizedMode === defaultMode && normalizedMode === "hide" ) ) ) { | |
2668 | + el.show(); | |
2669 | + } | |
2670 | + | |
2671 | + if ( !defaultMode || normalizedMode !== "none" ) { | |
2672 | + $.effects.saveStyle( el ); | |
2673 | + } | |
2674 | + | |
2675 | + if ( $.isFunction( next ) ) { | |
2676 | + next(); | |
2677 | + } | |
2678 | + }; | |
2679 | + | |
2680 | + if ( $.fx.off || !effectMethod ) { | |
2681 | + | |
2682 | + // Delegate to the original method (e.g., .show()) if possible | |
2683 | + if ( mode ) { | |
2684 | + return this[ mode ]( args.duration, complete ); | |
2685 | + } else { | |
2686 | + return this.each( function() { | |
2687 | + if ( complete ) { | |
2688 | + complete.call( this ); | |
2689 | + } | |
2690 | + } ); | |
2691 | + } | |
2692 | + } | |
2693 | + | |
2694 | + function run( next ) { | |
2695 | + var elem = $( this ); | |
2696 | + | |
2697 | + function cleanup() { | |
2698 | + elem.removeData( dataSpaceAnimated ); | |
2699 | + | |
2700 | + $.effects.cleanUp( elem ); | |
2701 | + | |
2702 | + if ( args.mode === "hide" ) { | |
2703 | + elem.hide(); | |
2704 | + } | |
2705 | + | |
2706 | + done(); | |
2707 | + } | |
2708 | + | |
2709 | + function done() { | |
2710 | + if ( $.isFunction( complete ) ) { | |
2711 | + complete.call( elem[ 0 ] ); | |
2712 | + } | |
2713 | + | |
2714 | + if ( $.isFunction( next ) ) { | |
2715 | + next(); | |
2716 | + } | |
2717 | + } | |
2718 | + | |
2719 | + // Override mode option on a per element basis, | |
2720 | + // as toggle can be either show or hide depending on element state | |
2721 | + args.mode = modes.shift(); | |
2722 | + | |
2723 | + if ( $.uiBackCompat !== false && !defaultMode ) { | |
2724 | + if ( elem.is( ":hidden" ) ? mode === "hide" : mode === "show" ) { | |
2725 | + | |
2726 | + // Call the core method to track "olddisplay" properly | |
2727 | + elem[ mode ](); | |
2728 | + done(); | |
2729 | + } else { | |
2730 | + effectMethod.call( elem[ 0 ], args, done ); | |
2731 | + } | |
2732 | + } else { | |
2733 | + if ( args.mode === "none" ) { | |
2734 | + | |
2735 | + // Call the core method to track "olddisplay" properly | |
2736 | + elem[ mode ](); | |
2737 | + done(); | |
2738 | + } else { | |
2739 | + effectMethod.call( elem[ 0 ], args, cleanup ); | |
2740 | + } | |
2741 | + } | |
2742 | + } | |
2743 | + | |
2744 | + // Run prefilter on all elements first to ensure that | |
2745 | + // any showing or hiding happens before placeholder creation, | |
2746 | + // which ensures that any layout changes are correctly captured. | |
2747 | + return queue === false ? | |
2748 | + this.each( prefilter ).each( run ) : | |
2749 | + this.queue( queueName, prefilter ).queue( queueName, run ); | |
2750 | + }, | |
2751 | + | |
2752 | + show: ( function( orig ) { | |
2753 | + return function( option ) { | |
2754 | + if ( standardAnimationOption( option ) ) { | |
2755 | + return orig.apply( this, arguments ); | |
2756 | + } else { | |
2757 | + var args = _normalizeArguments.apply( this, arguments ); | |
2758 | + args.mode = "show"; | |
2759 | + return this.effect.call( this, args ); | |
2760 | + } | |
2761 | + }; | |
2762 | + } )( $.fn.show ), | |
2763 | + | |
2764 | + hide: ( function( orig ) { | |
2765 | + return function( option ) { | |
2766 | + if ( standardAnimationOption( option ) ) { | |
2767 | + return orig.apply( this, arguments ); | |
2768 | + } else { | |
2769 | + var args = _normalizeArguments.apply( this, arguments ); | |
2770 | + args.mode = "hide"; | |
2771 | + return this.effect.call( this, args ); | |
2772 | + } | |
2773 | + }; | |
2774 | + } )( $.fn.hide ), | |
2775 | + | |
2776 | + toggle: ( function( orig ) { | |
2777 | + return function( option ) { | |
2778 | + if ( standardAnimationOption( option ) || typeof option === "boolean" ) { | |
2779 | + return orig.apply( this, arguments ); | |
2780 | + } else { | |
2781 | + var args = _normalizeArguments.apply( this, arguments ); | |
2782 | + args.mode = "toggle"; | |
2783 | + return this.effect.call( this, args ); | |
2784 | + } | |
2785 | + }; | |
2786 | + } )( $.fn.toggle ), | |
2787 | + | |
2788 | + cssUnit: function( key ) { | |
2789 | + var style = this.css( key ), | |
2790 | + val = []; | |
2791 | + | |
2792 | + $.each( [ "em", "px", "%", "pt" ], function( i, unit ) { | |
2793 | + if ( style.indexOf( unit ) > 0 ) { | |
2794 | + val = [ parseFloat( style ), unit ]; | |
2795 | + } | |
2796 | + } ); | |
2797 | + return val; | |
2798 | + }, | |
2799 | + | |
2800 | + cssClip: function( clipObj ) { | |
2801 | + if ( clipObj ) { | |
2802 | + return this.css( "clip", "rect(" + clipObj.top + "px " + clipObj.right + "px " + | |
2803 | + clipObj.bottom + "px " + clipObj.left + "px)" ); | |
2804 | + } | |
2805 | + return parseClip( this.css( "clip" ), this ); | |
2806 | + }, | |
2807 | + | |
2808 | + transfer: function( options, done ) { | |
2809 | + var element = $( this ), | |
2810 | + target = $( options.to ), | |
2811 | + targetFixed = target.css( "position" ) === "fixed", | |
2812 | + body = $( "body" ), | |
2813 | + fixTop = targetFixed ? body.scrollTop() : 0, | |
2814 | + fixLeft = targetFixed ? body.scrollLeft() : 0, | |
2815 | + endPosition = target.offset(), | |
2816 | + animation = { | |
2817 | + top: endPosition.top - fixTop, | |
2818 | + left: endPosition.left - fixLeft, | |
2819 | + height: target.innerHeight(), | |
2820 | + width: target.innerWidth() | |
2821 | + }, | |
2822 | + startPosition = element.offset(), | |
2823 | + transfer = $( "<div class='ui-effects-transfer'></div>" ) | |
2824 | + .appendTo( "body" ) | |
2825 | + .addClass( options.className ) | |
2826 | + .css( { | |
2827 | + top: startPosition.top - fixTop, | |
2828 | + left: startPosition.left - fixLeft, | |
2829 | + height: element.innerHeight(), | |
2830 | + width: element.innerWidth(), | |
2831 | + position: targetFixed ? "fixed" : "absolute" | |
2832 | + } ) | |
2833 | + .animate( animation, options.duration, options.easing, function() { | |
2834 | + transfer.remove(); | |
2835 | + if ( $.isFunction( done ) ) { | |
2836 | + done(); | |
2837 | + } | |
2838 | + } ); | |
2839 | + } | |
2840 | +} ); | |
2841 | + | |
2842 | +function parseClip( str, element ) { | |
2843 | + var outerWidth = element.outerWidth(), | |
2844 | + outerHeight = element.outerHeight(), | |
2845 | + clipRegex = /^rect\((-?\d*\.?\d*px|-?\d+%|auto),?\s*(-?\d*\.?\d*px|-?\d+%|auto),?\s*(-?\d*\.?\d*px|-?\d+%|auto),?\s*(-?\d*\.?\d*px|-?\d+%|auto)\)$/, | |
2846 | + values = clipRegex.exec( str ) || [ "", 0, outerWidth, outerHeight, 0 ]; | |
2847 | + | |
2848 | + return { | |
2849 | + top: parseFloat( values[ 1 ] ) || 0, | |
2850 | + right: values[ 2 ] === "auto" ? outerWidth : parseFloat( values[ 2 ] ), | |
2851 | + bottom: values[ 3 ] === "auto" ? outerHeight : parseFloat( values[ 3 ] ), | |
2852 | + left: parseFloat( values[ 4 ] ) || 0 | |
2853 | + }; | |
2854 | +} | |
2855 | + | |
2856 | +$.fx.step.clip = function( fx ) { | |
2857 | + if ( !fx.clipInit ) { | |
2858 | + fx.start = $( fx.elem ).cssClip(); | |
2859 | + if ( typeof fx.end === "string" ) { | |
2860 | + fx.end = parseClip( fx.end, fx.elem ); | |
2861 | + } | |
2862 | + fx.clipInit = true; | |
2863 | + } | |
2864 | + | |
2865 | + $( fx.elem ).cssClip( { | |
2866 | + top: fx.pos * ( fx.end.top - fx.start.top ) + fx.start.top, | |
2867 | + right: fx.pos * ( fx.end.right - fx.start.right ) + fx.start.right, | |
2868 | + bottom: fx.pos * ( fx.end.bottom - fx.start.bottom ) + fx.start.bottom, | |
2869 | + left: fx.pos * ( fx.end.left - fx.start.left ) + fx.start.left | |
2870 | + } ); | |
2871 | +}; | |
2872 | + | |
2873 | +} )(); | |
2874 | + | |
2875 | +/******************************************************************************/ | |
2876 | +/*********************************** EASING ***********************************/ | |
2877 | +/******************************************************************************/ | |
2878 | + | |
2879 | +( function() { | |
2880 | + | |
2881 | +// Based on easing equations from Robert Penner (http://www.robertpenner.com/easing) | |
2882 | + | |
2883 | +var baseEasings = {}; | |
2884 | + | |
2885 | +$.each( [ "Quad", "Cubic", "Quart", "Quint", "Expo" ], function( i, name ) { | |
2886 | + baseEasings[ name ] = function( p ) { | |
2887 | + return Math.pow( p, i + 2 ); | |
2888 | + }; | |
2889 | +} ); | |
2890 | + | |
2891 | +$.extend( baseEasings, { | |
2892 | + Sine: function( p ) { | |
2893 | + return 1 - Math.cos( p * Math.PI / 2 ); | |
2894 | + }, | |
2895 | + Circ: function( p ) { | |
2896 | + return 1 - Math.sqrt( 1 - p * p ); | |
2897 | + }, | |
2898 | + Elastic: function( p ) { | |
2899 | + return p === 0 || p === 1 ? p : | |
2900 | + -Math.pow( 2, 8 * ( p - 1 ) ) * Math.sin( ( ( p - 1 ) * 80 - 7.5 ) * Math.PI / 15 ); | |
2901 | + }, | |
2902 | + Back: function( p ) { | |
2903 | + return p * p * ( 3 * p - 2 ); | |
2904 | + }, | |
2905 | + Bounce: function( p ) { | |
2906 | + var pow2, | |
2907 | + bounce = 4; | |
2908 | + | |
2909 | + while ( p < ( ( pow2 = Math.pow( 2, --bounce ) ) - 1 ) / 11 ) {} | |
2910 | + return 1 / Math.pow( 4, 3 - bounce ) - 7.5625 * Math.pow( ( pow2 * 3 - 2 ) / 22 - p, 2 ); | |
2911 | + } | |
2912 | +} ); | |
2913 | + | |
2914 | +$.each( baseEasings, function( name, easeIn ) { | |
2915 | + $.easing[ "easeIn" + name ] = easeIn; | |
2916 | + $.easing[ "easeOut" + name ] = function( p ) { | |
2917 | + return 1 - easeIn( 1 - p ); | |
2918 | + }; | |
2919 | + $.easing[ "easeInOut" + name ] = function( p ) { | |
2920 | + return p < 0.5 ? | |
2921 | + easeIn( p * 2 ) / 2 : | |
2922 | + 1 - easeIn( p * -2 + 2 ) / 2; | |
2923 | + }; | |
2924 | +} ); | |
2925 | + | |
2926 | +} )(); | |
2927 | + | |
2928 | +var effect = $.effects; | |
2929 | + | |
2930 | + | |
2931 | +/*! | |
2932 | + * jQuery UI Effects Blind 1.12.0-rc.2 | |
2933 | + * http://jqueryui.com | |
2934 | + * | |
2935 | + * Copyright jQuery Foundation and other contributors | |
2936 | + * Released under the MIT license. | |
2937 | + * http://jquery.org/license | |
2938 | + */ | |
2939 | + | |
2940 | +//>>label: Blind Effect | |
2941 | +//>>group: Effects | |
2942 | +//>>description: Blinds the element. | |
2943 | +//>>docs: http://api.jqueryui.com/blind-effect/ | |
2944 | +//>>demos: http://jqueryui.com/effect/ | |
2945 | + | |
2946 | + | |
2947 | + | |
2948 | +var effectsEffectBlind = $.effects.define( "blind", "hide", function( options, done ) { | |
2949 | + var map = { | |
2950 | + up: [ "bottom", "top" ], | |
2951 | + vertical: [ "bottom", "top" ], | |
2952 | + down: [ "top", "bottom" ], | |
2953 | + left: [ "right", "left" ], | |
2954 | + horizontal: [ "right", "left" ], | |
2955 | + right: [ "left", "right" ] | |
2956 | + }, | |
2957 | + element = $( this ), | |
2958 | + direction = options.direction || "up", | |
2959 | + start = element.cssClip(), | |
2960 | + animate = { clip: $.extend( {}, start ) }, | |
2961 | + placeholder = $.effects.createPlaceholder( element ); | |
2962 | + | |
2963 | + animate.clip[ map[ direction ][ 0 ] ] = animate.clip[ map[ direction ][ 1 ] ]; | |
2964 | + | |
2965 | + if ( options.mode === "show" ) { | |
2966 | + element.cssClip( animate.clip ); | |
2967 | + if ( placeholder ) { | |
2968 | + placeholder.css( $.effects.clipToBox( animate ) ); | |
2969 | + } | |
2970 | + | |
2971 | + animate.clip = start; | |
2972 | + } | |
2973 | + | |
2974 | + if ( placeholder ) { | |
2975 | + placeholder.animate( $.effects.clipToBox( animate ), options.duration, options.easing ); | |
2976 | + } | |
2977 | + | |
2978 | + element.animate( animate, { | |
2979 | + queue: false, | |
2980 | + duration: options.duration, | |
2981 | + easing: options.easing, | |
2982 | + complete: done | |
2983 | + } ); | |
2984 | +} ); | |
2985 | + | |
2986 | + | |
2987 | +/*! | |
2988 | + * jQuery UI Effects Bounce 1.12.0-rc.2 | |
2989 | + * http://jqueryui.com | |
2990 | + * | |
2991 | + * Copyright jQuery Foundation and other contributors | |
2992 | + * Released under the MIT license. | |
2993 | + * http://jquery.org/license | |
2994 | + */ | |
2995 | + | |
2996 | +//>>label: Bounce Effect | |
2997 | +//>>group: Effects | |
2998 | +//>>description: Bounces an element horizontally or vertically n times. | |
2999 | +//>>docs: http://api.jqueryui.com/bounce-effect/ | |
3000 | +//>>demos: http://jqueryui.com/effect/ | |
3001 | + | |
3002 | + | |
3003 | + | |
3004 | +var effectsEffectBounce = $.effects.define( "bounce", function( options, done ) { | |
3005 | + var upAnim, downAnim, refValue, | |
3006 | + element = $( this ), | |
3007 | + | |
3008 | + // Defaults: | |
3009 | + mode = options.mode, | |
3010 | + hide = mode === "hide", | |
3011 | + show = mode === "show", | |
3012 | + direction = options.direction || "up", | |
3013 | + distance = options.distance, | |
3014 | + times = options.times || 5, | |
3015 | + | |
3016 | + // Number of internal animations | |
3017 | + anims = times * 2 + ( show || hide ? 1 : 0 ), | |
3018 | + speed = options.duration / anims, | |
3019 | + easing = options.easing, | |
3020 | + | |
3021 | + // Utility: | |
3022 | + ref = ( direction === "up" || direction === "down" ) ? "top" : "left", | |
3023 | + motion = ( direction === "up" || direction === "left" ), | |
3024 | + i = 0, | |
3025 | + | |
3026 | + queuelen = element.queue().length; | |
3027 | + | |
3028 | + $.effects.createPlaceholder( element ); | |
3029 | + | |
3030 | + refValue = element.css( ref ); | |
3031 | + | |
3032 | + // Default distance for the BIGGEST bounce is the outer Distance / 3 | |
3033 | + if ( !distance ) { | |
3034 | + distance = element[ ref === "top" ? "outerHeight" : "outerWidth" ]() / 3; | |
3035 | + } | |
3036 | + | |
3037 | + if ( show ) { | |
3038 | + downAnim = { opacity: 1 }; | |
3039 | + downAnim[ ref ] = refValue; | |
3040 | + | |
3041 | + // If we are showing, force opacity 0 and set the initial position | |
3042 | + // then do the "first" animation | |
3043 | + element | |
3044 | + .css( "opacity", 0 ) | |
3045 | + .css( ref, motion ? -distance * 2 : distance * 2 ) | |
3046 | + .animate( downAnim, speed, easing ); | |
3047 | + } | |
3048 | + | |
3049 | + // Start at the smallest distance if we are hiding | |
3050 | + if ( hide ) { | |
3051 | + distance = distance / Math.pow( 2, times - 1 ); | |
3052 | + } | |
3053 | + | |
3054 | + downAnim = {}; | |
3055 | + downAnim[ ref ] = refValue; | |
3056 | + | |
3057 | + // Bounces up/down/left/right then back to 0 -- times * 2 animations happen here | |
3058 | + for ( ; i < times; i++ ) { | |
3059 | + upAnim = {}; | |
3060 | + upAnim[ ref ] = ( motion ? "-=" : "+=" ) + distance; | |
3061 | + | |
3062 | + element | |
3063 | + .animate( upAnim, speed, easing ) | |
3064 | + .animate( downAnim, speed, easing ); | |
3065 | + | |
3066 | + distance = hide ? distance * 2 : distance / 2; | |
3067 | + } | |
3068 | + | |
3069 | + // Last Bounce when Hiding | |
3070 | + if ( hide ) { | |
3071 | + upAnim = { opacity: 0 }; | |
3072 | + upAnim[ ref ] = ( motion ? "-=" : "+=" ) + distance; | |
3073 | + | |
3074 | + element.animate( upAnim, speed, easing ); | |
3075 | + } | |
3076 | + | |
3077 | + element.queue( done ); | |
3078 | + | |
3079 | + $.effects.unshift( element, queuelen, anims + 1 ); | |
3080 | +} ); | |
3081 | + | |
3082 | + | |
3083 | +/*! | |
3084 | + * jQuery UI Effects Clip 1.12.0-rc.2 | |
3085 | + * http://jqueryui.com | |
3086 | + * | |
3087 | + * Copyright jQuery Foundation and other contributors | |
3088 | + * Released under the MIT license. | |
3089 | + * http://jquery.org/license | |
3090 | + */ | |
3091 | + | |
3092 | +//>>label: Clip Effect | |
3093 | +//>>group: Effects | |
3094 | +//>>description: Clips the element on and off like an old TV. | |
3095 | +//>>docs: http://api.jqueryui.com/clip-effect/ | |
3096 | +//>>demos: http://jqueryui.com/effect/ | |
3097 | + | |
3098 | + | |
3099 | + | |
3100 | +var effectsEffectClip = $.effects.define( "clip", "hide", function( options, done ) { | |
3101 | + var start, | |
3102 | + animate = {}, | |
3103 | + element = $( this ), | |
3104 | + direction = options.direction || "vertical", | |
3105 | + both = direction === "both", | |
3106 | + horizontal = both || direction === "horizontal", | |
3107 | + vertical = both || direction === "vertical"; | |
3108 | + | |
3109 | + start = element.cssClip(); | |
3110 | + animate.clip = { | |
3111 | + top: vertical ? ( start.bottom - start.top ) / 2 : start.top, | |
3112 | + right: horizontal ? ( start.right - start.left ) / 2 : start.right, | |
3113 | + bottom: vertical ? ( start.bottom - start.top ) / 2 : start.bottom, | |
3114 | + left: horizontal ? ( start.right - start.left ) / 2 : start.left | |
3115 | + }; | |
3116 | + | |
3117 | + $.effects.createPlaceholder( element ); | |
3118 | + | |
3119 | + if ( options.mode === "show" ) { | |
3120 | + element.cssClip( animate.clip ); | |
3121 | + animate.clip = start; | |
3122 | + } | |
3123 | + | |
3124 | + element.animate( animate, { | |
3125 | + queue: false, | |
3126 | + duration: options.duration, | |
3127 | + easing: options.easing, | |
3128 | + complete: done | |
3129 | + } ); | |
3130 | + | |
3131 | +} ); | |
3132 | + | |
3133 | + | |
3134 | +/*! | |
3135 | + * jQuery UI Effects Drop 1.12.0-rc.2 | |
3136 | + * http://jqueryui.com | |
3137 | + * | |
3138 | + * Copyright jQuery Foundation and other contributors | |
3139 | + * Released under the MIT license. | |
3140 | + * http://jquery.org/license | |
3141 | + */ | |
3142 | + | |
3143 | +//>>label: Drop Effect | |
3144 | +//>>group: Effects | |
3145 | +//>>description: Moves an element in one direction and hides it at the same time. | |
3146 | +//>>docs: http://api.jqueryui.com/drop-effect/ | |
3147 | +//>>demos: http://jqueryui.com/effect/ | |
3148 | + | |
3149 | + | |
3150 | + | |
3151 | +var effectsEffectDrop = $.effects.define( "drop", "hide", function( options, done ) { | |
3152 | + | |
3153 | + var distance, | |
3154 | + element = $( this ), | |
3155 | + mode = options.mode, | |
3156 | + show = mode === "show", | |
3157 | + direction = options.direction || "left", | |
3158 | + ref = ( direction === "up" || direction === "down" ) ? "top" : "left", | |
3159 | + motion = ( direction === "up" || direction === "left" ) ? "-=" : "+=", | |
3160 | + oppositeMotion = ( motion === "+=" ) ? "-=" : "+=", | |
3161 | + animation = { | |
3162 | + opacity: 0 | |
3163 | + }; | |
3164 | + | |
3165 | + $.effects.createPlaceholder( element ); | |
3166 | + | |
3167 | + distance = options.distance || | |
3168 | + element[ ref === "top" ? "outerHeight" : "outerWidth" ]( true ) / 2; | |
3169 | + | |
3170 | + animation[ ref ] = motion + distance; | |
3171 | + | |
3172 | + if ( show ) { | |
3173 | + element.css( animation ); | |
3174 | + | |
3175 | + animation[ ref ] = oppositeMotion + distance; | |
3176 | + animation.opacity = 1; | |
3177 | + } | |
3178 | + | |
3179 | + // Animate | |
3180 | + element.animate( animation, { | |
3181 | + queue: false, | |
3182 | + duration: options.duration, | |
3183 | + easing: options.easing, | |
3184 | + complete: done | |
3185 | + } ); | |
3186 | +} ); | |
3187 | + | |
3188 | + | |
3189 | +/*! | |
3190 | + * jQuery UI Effects Explode 1.12.0-rc.2 | |
3191 | + * http://jqueryui.com | |
3192 | + * | |
3193 | + * Copyright jQuery Foundation and other contributors | |
3194 | + * Released under the MIT license. | |
3195 | + * http://jquery.org/license | |
3196 | + */ | |
3197 | + | |
3198 | +//>>label: Explode Effect | |
3199 | +//>>group: Effects | |
3200 | +// jscs:disable maximumLineLength | |
3201 | +//>>description: Explodes an element in all directions into n pieces. Implodes an element to its original wholeness. | |
3202 | +// jscs:enable maximumLineLength | |
3203 | +//>>docs: http://api.jqueryui.com/explode-effect/ | |
3204 | +//>>demos: http://jqueryui.com/effect/ | |
3205 | + | |
3206 | + | |
3207 | + | |
3208 | +var effectsEffectExplode = $.effects.define( "explode", "hide", function( options, done ) { | |
3209 | + | |
3210 | + var i, j, left, top, mx, my, | |
3211 | + rows = options.pieces ? Math.round( Math.sqrt( options.pieces ) ) : 3, | |
3212 | + cells = rows, | |
3213 | + element = $( this ), | |
3214 | + mode = options.mode, | |
3215 | + show = mode === "show", | |
3216 | + | |
3217 | + // Show and then visibility:hidden the element before calculating offset | |
3218 | + offset = element.show().css( "visibility", "hidden" ).offset(), | |
3219 | + | |
3220 | + // Width and height of a piece | |
3221 | + width = Math.ceil( element.outerWidth() / cells ), | |
3222 | + height = Math.ceil( element.outerHeight() / rows ), | |
3223 | + pieces = []; | |
3224 | + | |
3225 | + // Children animate complete: | |
3226 | + function childComplete() { | |
3227 | + pieces.push( this ); | |
3228 | + if ( pieces.length === rows * cells ) { | |
3229 | + animComplete(); | |
3230 | + } | |
3231 | + } | |
3232 | + | |
3233 | + // Clone the element for each row and cell. | |
3234 | + for ( i = 0; i < rows; i++ ) { // ===> | |
3235 | + top = offset.top + i * height; | |
3236 | + my = i - ( rows - 1 ) / 2; | |
3237 | + | |
3238 | + for ( j = 0; j < cells; j++ ) { // ||| | |
3239 | + left = offset.left + j * width; | |
3240 | + mx = j - ( cells - 1 ) / 2; | |
3241 | + | |
3242 | + // Create a clone of the now hidden main element that will be absolute positioned | |
3243 | + // within a wrapper div off the -left and -top equal to size of our pieces | |
3244 | + element | |
3245 | + .clone() | |
3246 | + .appendTo( "body" ) | |
3247 | + .wrap( "<div></div>" ) | |
3248 | + .css( { | |
3249 | + position: "absolute", | |
3250 | + visibility: "visible", | |
3251 | + left: -j * width, | |
3252 | + top: -i * height | |
3253 | + } ) | |
3254 | + | |
3255 | + // Select the wrapper - make it overflow: hidden and absolute positioned based on | |
3256 | + // where the original was located +left and +top equal to the size of pieces | |
3257 | + .parent() | |
3258 | + .addClass( "ui-effects-explode" ) | |
3259 | + .css( { | |
3260 | + position: "absolute", | |
3261 | + overflow: "hidden", | |
3262 | + width: width, | |
3263 | + height: height, | |
3264 | + left: left + ( show ? mx * width : 0 ), | |
3265 | + top: top + ( show ? my * height : 0 ), | |
3266 | + opacity: show ? 0 : 1 | |
3267 | + } ) | |
3268 | + .animate( { | |
3269 | + left: left + ( show ? 0 : mx * width ), | |
3270 | + top: top + ( show ? 0 : my * height ), | |
3271 | + opacity: show ? 1 : 0 | |
3272 | + }, options.duration || 500, options.easing, childComplete ); | |
3273 | + } | |
3274 | + } | |
3275 | + | |
3276 | + function animComplete() { | |
3277 | + element.css( { | |
3278 | + visibility: "visible" | |
3279 | + } ); | |
3280 | + $( pieces ).remove(); | |
3281 | + done(); | |
3282 | + } | |
3283 | +} ); | |
3284 | + | |
3285 | + | |
3286 | +/*! | |
3287 | + * jQuery UI Effects Fade 1.12.0-rc.2 | |
3288 | + * http://jqueryui.com | |
3289 | + * | |
3290 | + * Copyright jQuery Foundation and other contributors | |
3291 | + * Released under the MIT license. | |
3292 | + * http://jquery.org/license | |
3293 | + */ | |
3294 | + | |
3295 | +//>>label: Fade Effect | |
3296 | +//>>group: Effects | |
3297 | +//>>description: Fades the element. | |
3298 | +//>>docs: http://api.jqueryui.com/fade-effect/ | |
3299 | +//>>demos: http://jqueryui.com/effect/ | |
3300 | + | |
3301 | + | |
3302 | + | |
3303 | +var effectsEffectFade = $.effects.define( "fade", "toggle", function( options, done ) { | |
3304 | + var show = options.mode === "show"; | |
3305 | + | |
3306 | + $( this ) | |
3307 | + .css( "opacity", show ? 0 : 1 ) | |
3308 | + .animate( { | |
3309 | + opacity: show ? 1 : 0 | |
3310 | + }, { | |
3311 | + queue: false, | |
3312 | + duration: options.duration, | |
3313 | + easing: options.easing, | |
3314 | + complete: done | |
3315 | + } ); | |
3316 | +} ); | |
3317 | + | |
3318 | + | |
3319 | +/*! | |
3320 | + * jQuery UI Effects Fold 1.12.0-rc.2 | |
3321 | + * http://jqueryui.com | |
3322 | + * | |
3323 | + * Copyright jQuery Foundation and other contributors | |
3324 | + * Released under the MIT license. | |
3325 | + * http://jquery.org/license | |
3326 | + */ | |
3327 | + | |
3328 | +//>>label: Fold Effect | |
3329 | +//>>group: Effects | |
3330 | +//>>description: Folds an element first horizontally and then vertically. | |
3331 | +//>>docs: http://api.jqueryui.com/fold-effect/ | |
3332 | +//>>demos: http://jqueryui.com/effect/ | |
3333 | + | |
3334 | + | |
3335 | + | |
3336 | +var effectsEffectFold = $.effects.define( "fold", "hide", function( options, done ) { | |
3337 | + | |
3338 | + // Create element | |
3339 | + var element = $( this ), | |
3340 | + mode = options.mode, | |
3341 | + show = mode === "show", | |
3342 | + hide = mode === "hide", | |
3343 | + size = options.size || 15, | |
3344 | + percent = /([0-9]+)%/.exec( size ), | |
3345 | + horizFirst = !!options.horizFirst, | |
3346 | + ref = horizFirst ? [ "right", "bottom" ] : [ "bottom", "right" ], | |
3347 | + duration = options.duration / 2, | |
3348 | + | |
3349 | + placeholder = $.effects.createPlaceholder( element ), | |
3350 | + | |
3351 | + start = element.cssClip(), | |
3352 | + animation1 = { clip: $.extend( {}, start ) }, | |
3353 | + animation2 = { clip: $.extend( {}, start ) }, | |
3354 | + | |
3355 | + distance = [ start[ ref[ 0 ] ], start[ ref[ 1 ] ] ], | |
3356 | + | |
3357 | + queuelen = element.queue().length; | |
3358 | + | |
3359 | + if ( percent ) { | |
3360 | + size = parseInt( percent[ 1 ], 10 ) / 100 * distance[ hide ? 0 : 1 ]; | |
3361 | + } | |
3362 | + animation1.clip[ ref[ 0 ] ] = size; | |
3363 | + animation2.clip[ ref[ 0 ] ] = size; | |
3364 | + animation2.clip[ ref[ 1 ] ] = 0; | |
3365 | + | |
3366 | + if ( show ) { | |
3367 | + element.cssClip( animation2.clip ); | |
3368 | + if ( placeholder ) { | |
3369 | + placeholder.css( $.effects.clipToBox( animation2 ) ); | |
3370 | + } | |
3371 | + | |
3372 | + animation2.clip = start; | |
3373 | + } | |
3374 | + | |
3375 | + // Animate | |
3376 | + element | |
3377 | + .queue( function( next ) { | |
3378 | + if ( placeholder ) { | |
3379 | + placeholder | |
3380 | + .animate( $.effects.clipToBox( animation1 ), duration, options.easing ) | |
3381 | + .animate( $.effects.clipToBox( animation2 ), duration, options.easing ); | |
3382 | + } | |
3383 | + | |
3384 | + next(); | |
3385 | + } ) | |
3386 | + .animate( animation1, duration, options.easing ) | |
3387 | + .animate( animation2, duration, options.easing ) | |
3388 | + .queue( done ); | |
3389 | + | |
3390 | + $.effects.unshift( element, queuelen, 4 ); | |
3391 | +} ); | |
3392 | + | |
3393 | + | |
3394 | +/*! | |
3395 | + * jQuery UI Effects Highlight 1.12.0-rc.2 | |
3396 | + * http://jqueryui.com | |
3397 | + * | |
3398 | + * Copyright jQuery Foundation and other contributors | |
3399 | + * Released under the MIT license. | |
3400 | + * http://jquery.org/license | |
3401 | + */ | |
3402 | + | |
3403 | +//>>label: Highlight Effect | |
3404 | +//>>group: Effects | |
3405 | +//>>description: Highlights the background of an element in a defined color for a custom duration. | |
3406 | +//>>docs: http://api.jqueryui.com/highlight-effect/ | |
3407 | +//>>demos: http://jqueryui.com/effect/ | |
3408 | + | |
3409 | + | |
3410 | + | |
3411 | +var effectsEffectHighlight = $.effects.define( "highlight", "show", function( options, done ) { | |
3412 | + var element = $( this ), | |
3413 | + animation = { | |
3414 | + backgroundColor: element.css( "backgroundColor" ) | |
3415 | + }; | |
3416 | + | |
3417 | + if ( options.mode === "hide" ) { | |
3418 | + animation.opacity = 0; | |
3419 | + } | |
3420 | + | |
3421 | + $.effects.saveStyle( element ); | |
3422 | + | |
3423 | + element | |
3424 | + .css( { | |
3425 | + backgroundImage: "none", | |
3426 | + backgroundColor: options.color || "#ffff99" | |
3427 | + } ) | |
3428 | + .animate( animation, { | |
3429 | + queue: false, | |
3430 | + duration: options.duration, | |
3431 | + easing: options.easing, | |
3432 | + complete: done | |
3433 | + } ); | |
3434 | +} ); | |
3435 | + | |
3436 | + | |
3437 | +/*! | |
3438 | + * jQuery UI Effects Size 1.12.0-rc.2 | |
3439 | + * http://jqueryui.com | |
3440 | + * | |
3441 | + * Copyright jQuery Foundation and other contributors | |
3442 | + * Released under the MIT license. | |
3443 | + * http://jquery.org/license | |
3444 | + */ | |
3445 | + | |
3446 | +//>>label: Size Effect | |
3447 | +//>>group: Effects | |
3448 | +//>>description: Resize an element to a specified width and height. | |
3449 | +//>>docs: http://api.jqueryui.com/size-effect/ | |
3450 | +//>>demos: http://jqueryui.com/effect/ | |
3451 | + | |
3452 | + | |
3453 | + | |
3454 | +var effectsEffectSize = $.effects.define( "size", function( options, done ) { | |
3455 | + | |
3456 | + // Create element | |
3457 | + var baseline, factor, temp, | |
3458 | + element = $( this ), | |
3459 | + | |
3460 | + // Copy for children | |
3461 | + cProps = [ "fontSize" ], | |
3462 | + vProps = [ "borderTopWidth", "borderBottomWidth", "paddingTop", "paddingBottom" ], | |
3463 | + hProps = [ "borderLeftWidth", "borderRightWidth", "paddingLeft", "paddingRight" ], | |
3464 | + | |
3465 | + // Set options | |
3466 | + mode = options.mode, | |
3467 | + restore = mode !== "effect", | |
3468 | + scale = options.scale || "both", | |
3469 | + origin = options.origin || [ "middle", "center" ], | |
3470 | + position = element.css( "position" ), | |
3471 | + pos = element.position(), | |
3472 | + original = $.effects.scaledDimensions( element ), | |
3473 | + from = options.from || original, | |
3474 | + to = options.to || $.effects.scaledDimensions( element, 0 ); | |
3475 | + | |
3476 | + $.effects.createPlaceholder( element ); | |
3477 | + | |
3478 | + if ( mode === "show" ) { | |
3479 | + temp = from; | |
3480 | + from = to; | |
3481 | + to = temp; | |
3482 | + } | |
3483 | + | |
3484 | + // Set scaling factor | |
3485 | + factor = { | |
3486 | + from: { | |
3487 | + y: from.height / original.height, | |
3488 | + x: from.width / original.width | |
3489 | + }, | |
3490 | + to: { | |
3491 | + y: to.height / original.height, | |
3492 | + x: to.width / original.width | |
3493 | + } | |
3494 | + }; | |
3495 | + | |
3496 | + // Scale the css box | |
3497 | + if ( scale === "box" || scale === "both" ) { | |
3498 | + | |
3499 | + // Vertical props scaling | |
3500 | + if ( factor.from.y !== factor.to.y ) { | |
3501 | + from = $.effects.setTransition( element, vProps, factor.from.y, from ); | |
3502 | + to = $.effects.setTransition( element, vProps, factor.to.y, to ); | |
3503 | + } | |
3504 | + | |
3505 | + // Horizontal props scaling | |
3506 | + if ( factor.from.x !== factor.to.x ) { | |
3507 | + from = $.effects.setTransition( element, hProps, factor.from.x, from ); | |
3508 | + to = $.effects.setTransition( element, hProps, factor.to.x, to ); | |
3509 | + } | |
3510 | + } | |
3511 | + | |
3512 | + // Scale the content | |
3513 | + if ( scale === "content" || scale === "both" ) { | |
3514 | + | |
3515 | + // Vertical props scaling | |
3516 | + if ( factor.from.y !== factor.to.y ) { | |
3517 | + from = $.effects.setTransition( element, cProps, factor.from.y, from ); | |
3518 | + to = $.effects.setTransition( element, cProps, factor.to.y, to ); | |
3519 | + } | |
3520 | + } | |
3521 | + | |
3522 | + // Adjust the position properties based on the provided origin points | |
3523 | + if ( origin ) { | |
3524 | + baseline = $.effects.getBaseline( origin, original ); | |
3525 | + from.top = ( original.outerHeight - from.outerHeight ) * baseline.y + pos.top; | |
3526 | + from.left = ( original.outerWidth - from.outerWidth ) * baseline.x + pos.left; | |
3527 | + to.top = ( original.outerHeight - to.outerHeight ) * baseline.y + pos.top; | |
3528 | + to.left = ( original.outerWidth - to.outerWidth ) * baseline.x + pos.left; | |
3529 | + } | |
3530 | + element.css( from ); | |
3531 | + | |
3532 | + // Animate the children if desired | |
3533 | + if ( scale === "content" || scale === "both" ) { | |
3534 | + | |
3535 | + vProps = vProps.concat( [ "marginTop", "marginBottom" ] ).concat( cProps ); | |
3536 | + hProps = hProps.concat( [ "marginLeft", "marginRight" ] ); | |
3537 | + | |
3538 | + // Only animate children with width attributes specified | |
3539 | + // TODO: is this right? should we include anything with css width specified as well | |
3540 | + element.find( "*[width]" ).each( function() { | |
3541 | + var child = $( this ), | |
3542 | + childOriginal = $.effects.scaledDimensions( child ), | |
3543 | + childFrom = { | |
3544 | + height: childOriginal.height * factor.from.y, | |
3545 | + width: childOriginal.width * factor.from.x, | |
3546 | + outerHeight: childOriginal.outerHeight * factor.from.y, | |
3547 | + outerWidth: childOriginal.outerWidth * factor.from.x | |
3548 | + }, | |
3549 | + childTo = { | |
3550 | + height: childOriginal.height * factor.to.y, | |
3551 | + width: childOriginal.width * factor.to.x, | |
3552 | + outerHeight: childOriginal.height * factor.to.y, | |
3553 | + outerWidth: childOriginal.width * factor.to.x | |
3554 | + }; | |
3555 | + | |
3556 | + // Vertical props scaling | |
3557 | + if ( factor.from.y !== factor.to.y ) { | |
3558 | + childFrom = $.effects.setTransition( child, vProps, factor.from.y, childFrom ); | |
3559 | + childTo = $.effects.setTransition( child, vProps, factor.to.y, childTo ); | |
3560 | + } | |
3561 | + | |
3562 | + // Horizontal props scaling | |
3563 | + if ( factor.from.x !== factor.to.x ) { | |
3564 | + childFrom = $.effects.setTransition( child, hProps, factor.from.x, childFrom ); | |
3565 | + childTo = $.effects.setTransition( child, hProps, factor.to.x, childTo ); | |
3566 | + } | |
3567 | + | |
3568 | + if ( restore ) { | |
3569 | + $.effects.saveStyle( child ); | |
3570 | + } | |
3571 | + | |
3572 | + // Animate children | |
3573 | + child.css( childFrom ); | |
3574 | + child.animate( childTo, options.duration, options.easing, function() { | |
3575 | + | |
3576 | + // Restore children | |
3577 | + if ( restore ) { | |
3578 | + $.effects.restoreStyle( child ); | |
3579 | + } | |
3580 | + } ); | |
3581 | + } ); | |
3582 | + } | |
3583 | + | |
3584 | + // Animate | |
3585 | + element.animate( to, { | |
3586 | + queue: false, | |
3587 | + duration: options.duration, | |
3588 | + easing: options.easing, | |
3589 | + complete: function() { | |
3590 | + | |
3591 | + var offset = element.offset(); | |
3592 | + | |
3593 | + if ( to.opacity === 0 ) { | |
3594 | + element.css( "opacity", from.opacity ); | |
3595 | + } | |
3596 | + | |
3597 | + if ( !restore ) { | |
3598 | + element | |
3599 | + .css( "position", position === "static" ? "relative" : position ) | |
3600 | + .offset( offset ); | |
3601 | + | |
3602 | + // Need to save style here so that automatic style restoration | |
3603 | + // doesn't restore to the original styles from before the animation. | |
3604 | + $.effects.saveStyle( element ); | |
3605 | + } | |
3606 | + | |
3607 | + done(); | |
3608 | + } | |
3609 | + } ); | |
3610 | + | |
3611 | +} ); | |
3612 | + | |
3613 | + | |
3614 | +/*! | |
3615 | + * jQuery UI Effects Scale 1.12.0-rc.2 | |
3616 | + * http://jqueryui.com | |
3617 | + * | |
3618 | + * Copyright jQuery Foundation and other contributors | |
3619 | + * Released under the MIT license. | |
3620 | + * http://jquery.org/license | |
3621 | + */ | |
3622 | + | |
3623 | +//>>label: Scale Effect | |
3624 | +//>>group: Effects | |
3625 | +//>>description: Grows or shrinks an element and its content. | |
3626 | +//>>docs: http://api.jqueryui.com/scale-effect/ | |
3627 | +//>>demos: http://jqueryui.com/effect/ | |
3628 | + | |
3629 | + | |
3630 | + | |
3631 | +var effectsEffectScale = $.effects.define( "scale", function( options, done ) { | |
3632 | + | |
3633 | + // Create element | |
3634 | + var el = $( this ), | |
3635 | + mode = options.mode, | |
3636 | + percent = parseInt( options.percent, 10 ) || | |
3637 | + ( parseInt( options.percent, 10 ) === 0 ? 0 : ( mode !== "effect" ? 0 : 100 ) ), | |
3638 | + | |
3639 | + newOptions = $.extend( true, { | |
3640 | + from: $.effects.scaledDimensions( el ), | |
3641 | + to: $.effects.scaledDimensions( el, percent, options.direction || "both" ), | |
3642 | + origin: options.origin || [ "middle", "center" ] | |
3643 | + }, options ); | |
3644 | + | |
3645 | + // Fade option to support puff | |
3646 | + if ( options.fade ) { | |
3647 | + newOptions.from.opacity = 1; | |
3648 | + newOptions.to.opacity = 0; | |
3649 | + } | |
3650 | + | |
3651 | + $.effects.effect.size.call( this, newOptions, done ); | |
3652 | +} ); | |
3653 | + | |
3654 | + | |
3655 | +/*! | |
3656 | + * jQuery UI Effects Puff 1.12.0-rc.2 | |
3657 | + * http://jqueryui.com | |
3658 | + * | |
3659 | + * Copyright jQuery Foundation and other contributors | |
3660 | + * Released under the MIT license. | |
3661 | + * http://jquery.org/license | |
3662 | + */ | |
3663 | + | |
3664 | +//>>label: Puff Effect | |
3665 | +//>>group: Effects | |
3666 | +//>>description: Creates a puff effect by scaling the element up and hiding it at the same time. | |
3667 | +//>>docs: http://api.jqueryui.com/puff-effect/ | |
3668 | +//>>demos: http://jqueryui.com/effect/ | |
3669 | + | |
3670 | + | |
3671 | + | |
3672 | +var effectsEffectPuff = $.effects.define( "puff", "hide", function( options, done ) { | |
3673 | + var newOptions = $.extend( true, {}, options, { | |
3674 | + fade: true, | |
3675 | + percent: parseInt( options.percent, 10 ) || 150 | |
3676 | + } ); | |
3677 | + | |
3678 | + $.effects.effect.scale.call( this, newOptions, done ); | |
3679 | +} ); | |
3680 | + | |
3681 | + | |
3682 | +/*! | |
3683 | + * jQuery UI Effects Pulsate 1.12.0-rc.2 | |
3684 | + * http://jqueryui.com | |
3685 | + * | |
3686 | + * Copyright jQuery Foundation and other contributors | |
3687 | + * Released under the MIT license. | |
3688 | + * http://jquery.org/license | |
3689 | + */ | |
3690 | + | |
3691 | +//>>label: Pulsate Effect | |
3692 | +//>>group: Effects | |
3693 | +//>>description: Pulsates an element n times by changing the opacity to zero and back. | |
3694 | +//>>docs: http://api.jqueryui.com/pulsate-effect/ | |
3695 | +//>>demos: http://jqueryui.com/effect/ | |
3696 | + | |
3697 | + | |
3698 | + | |
3699 | +var effectsEffectPulsate = $.effects.define( "pulsate", "show", function( options, done ) { | |
3700 | + var element = $( this ), | |
3701 | + mode = options.mode, | |
3702 | + show = mode === "show", | |
3703 | + hide = mode === "hide", | |
3704 | + showhide = show || hide, | |
3705 | + | |
3706 | + // Showing or hiding leaves off the "last" animation | |
3707 | + anims = ( ( options.times || 5 ) * 2 ) + ( showhide ? 1 : 0 ), | |
3708 | + duration = options.duration / anims, | |
3709 | + animateTo = 0, | |
3710 | + i = 1, | |
3711 | + queuelen = element.queue().length; | |
3712 | + | |
3713 | + if ( show || !element.is( ":visible" ) ) { | |
3714 | + element.css( "opacity", 0 ).show(); | |
3715 | + animateTo = 1; | |
3716 | + } | |
3717 | + | |
3718 | + // Anims - 1 opacity "toggles" | |
3719 | + for ( ; i < anims; i++ ) { | |
3720 | + element.animate( { opacity: animateTo }, duration, options.easing ); | |
3721 | + animateTo = 1 - animateTo; | |
3722 | + } | |
3723 | + | |
3724 | + element.animate( { opacity: animateTo }, duration, options.easing ); | |
3725 | + | |
3726 | + element.queue( done ); | |
3727 | + | |
3728 | + $.effects.unshift( element, queuelen, anims + 1 ); | |
3729 | +} ); | |
3730 | + | |
3731 | + | |
3732 | +/*! | |
3733 | + * jQuery UI Effects Shake 1.12.0-rc.2 | |
3734 | + * http://jqueryui.com | |
3735 | + * | |
3736 | + * Copyright jQuery Foundation and other contributors | |
3737 | + * Released under the MIT license. | |
3738 | + * http://jquery.org/license | |
3739 | + */ | |
3740 | + | |
3741 | +//>>label: Shake Effect | |
3742 | +//>>group: Effects | |
3743 | +//>>description: Shakes an element horizontally or vertically n times. | |
3744 | +//>>docs: http://api.jqueryui.com/shake-effect/ | |
3745 | +//>>demos: http://jqueryui.com/effect/ | |
3746 | + | |
3747 | + | |
3748 | + | |
3749 | +var effectsEffectShake = $.effects.define( "shake", function( options, done ) { | |
3750 | + | |
3751 | + var i = 1, | |
3752 | + element = $( this ), | |
3753 | + direction = options.direction || "left", | |
3754 | + distance = options.distance || 20, | |
3755 | + times = options.times || 3, | |
3756 | + anims = times * 2 + 1, | |
3757 | + speed = Math.round( options.duration / anims ), | |
3758 | + ref = ( direction === "up" || direction === "down" ) ? "top" : "left", | |
3759 | + positiveMotion = ( direction === "up" || direction === "left" ), | |
3760 | + animation = {}, | |
3761 | + animation1 = {}, | |
3762 | + animation2 = {}, | |
3763 | + | |
3764 | + queuelen = element.queue().length; | |
3765 | + | |
3766 | + $.effects.createPlaceholder( element ); | |
3767 | + | |
3768 | + // Animation | |
3769 | + animation[ ref ] = ( positiveMotion ? "-=" : "+=" ) + distance; | |
3770 | + animation1[ ref ] = ( positiveMotion ? "+=" : "-=" ) + distance * 2; | |
3771 | + animation2[ ref ] = ( positiveMotion ? "-=" : "+=" ) + distance * 2; | |
3772 | + | |
3773 | + // Animate | |
3774 | + element.animate( animation, speed, options.easing ); | |
3775 | + | |
3776 | + // Shakes | |
3777 | + for ( ; i < times; i++ ) { | |
3778 | + element | |
3779 | + .animate( animation1, speed, options.easing ) | |
3780 | + .animate( animation2, speed, options.easing ); | |
3781 | + } | |
3782 | + | |
3783 | + element | |
3784 | + .animate( animation1, speed, options.easing ) | |
3785 | + .animate( animation, speed / 2, options.easing ) | |
3786 | + .queue( done ); | |
3787 | + | |
3788 | + $.effects.unshift( element, queuelen, anims + 1 ); | |
3789 | +} ); | |
3790 | + | |
3791 | + | |
3792 | +/*! | |
3793 | + * jQuery UI Effects Slide 1.12.0-rc.2 | |
3794 | + * http://jqueryui.com | |
3795 | + * | |
3796 | + * Copyright jQuery Foundation and other contributors | |
3797 | + * Released under the MIT license. | |
3798 | + * http://jquery.org/license | |
3799 | + */ | |
3800 | + | |
3801 | +//>>label: Slide Effect | |
3802 | +//>>group: Effects | |
3803 | +//>>description: Slides an element in and out of the viewport. | |
3804 | +//>>docs: http://api.jqueryui.com/slide-effect/ | |
3805 | +//>>demos: http://jqueryui.com/effect/ | |
3806 | + | |
3807 | + | |
3808 | + | |
3809 | +var effectsEffectSlide = $.effects.define( "slide", "show", function( options, done ) { | |
3810 | + var startClip, startRef, | |
3811 | + element = $( this ), | |
3812 | + map = { | |
3813 | + up: [ "bottom", "top" ], | |
3814 | + down: [ "top", "bottom" ], | |
3815 | + left: [ "right", "left" ], | |
3816 | + right: [ "left", "right" ] | |
3817 | + }, | |
3818 | + mode = options.mode, | |
3819 | + direction = options.direction || "left", | |
3820 | + ref = ( direction === "up" || direction === "down" ) ? "top" : "left", | |
3821 | + positiveMotion = ( direction === "up" || direction === "left" ), | |
3822 | + distance = options.distance || | |
3823 | + element[ ref === "top" ? "outerHeight" : "outerWidth" ]( true ), | |
3824 | + animation = {}; | |
3825 | + | |
3826 | + $.effects.createPlaceholder( element ); | |
3827 | + | |
3828 | + startClip = element.cssClip(); | |
3829 | + startRef = element.position()[ ref ]; | |
3830 | + | |
3831 | + // Define hide animation | |
3832 | + animation[ ref ] = ( positiveMotion ? -1 : 1 ) * distance + startRef; | |
3833 | + animation.clip = element.cssClip(); | |
3834 | + animation.clip[ map[ direction ][ 1 ] ] = animation.clip[ map[ direction ][ 0 ] ]; | |
3835 | + | |
3836 | + // Reverse the animation if we're showing | |
3837 | + if ( mode === "show" ) { | |
3838 | + element.cssClip( animation.clip ); | |
3839 | + element.css( ref, animation[ ref ] ); | |
3840 | + animation.clip = startClip; | |
3841 | + animation[ ref ] = startRef; | |
3842 | + } | |
3843 | + | |
3844 | + // Actually animate | |
3845 | + element.animate( animation, { | |
3846 | + queue: false, | |
3847 | + duration: options.duration, | |
3848 | + easing: options.easing, | |
3849 | + complete: done | |
3850 | + } ); | |
3851 | +} ); | |
3852 | + | |
3853 | + | |
3854 | +/*! | |
3855 | + * jQuery UI Effects Transfer 1.12.0-rc.2 | |
3856 | + * http://jqueryui.com | |
3857 | + * | |
3858 | + * Copyright jQuery Foundation and other contributors | |
3859 | + * Released under the MIT license. | |
3860 | + * http://jquery.org/license | |
3861 | + */ | |
3862 | + | |
3863 | +//>>label: Transfer Effect | |
3864 | +//>>group: Effects | |
3865 | +//>>description: Displays a transfer effect from one element to another. | |
3866 | +//>>docs: http://api.jqueryui.com/transfer-effect/ | |
3867 | +//>>demos: http://jqueryui.com/effect/ | |
3868 | + | |
3869 | + | |
3870 | + | |
3871 | +var effect; | |
3872 | +if ( $.uiBackCompat !== false ) { | |
3873 | + effect = $.effects.define( "transfer", function( options, done ) { | |
3874 | + $( this ).transfer( options, done ); | |
3875 | + } ); | |
3876 | +} | |
3877 | +var effectsEffectTransfer = effect; | |
3878 | + | |
3879 | + | |
3880 | +/*! | |
3881 | + * jQuery UI Focusable 1.12.0-rc.2 | |
3882 | + * http://jqueryui.com | |
3883 | + * | |
3884 | + * Copyright jQuery Foundation and other contributors | |
3885 | + * Released under the MIT license. | |
3886 | + * http://jquery.org/license | |
3887 | + */ | |
3888 | + | |
3889 | +//>>label: :focusable Selector | |
3890 | +//>>group: Core | |
3891 | +//>>description: Selects elements which can be focused. | |
3892 | +//>>docs: http://api.jqueryui.com/focusable-selector/ | |
3893 | + | |
3894 | + | |
3895 | + | |
3896 | +// Selectors | |
3897 | +$.ui.focusable = function( element, hasTabindex ) { | |
3898 | + var map, mapName, img, | |
3899 | + nodeName = element.nodeName.toLowerCase(); | |
3900 | + if ( "area" === nodeName ) { | |
3901 | + map = element.parentNode; | |
3902 | + mapName = map.name; | |
3903 | + if ( !element.href || !mapName || map.nodeName.toLowerCase() !== "map" ) { | |
3904 | + return false; | |
3905 | + } | |
3906 | + img = $( "img[usemap='#" + mapName + "']" ); | |
3907 | + return img.length > 0 && img.is( ":visible" ); | |
3908 | + } | |
3909 | + return ( /^(input|select|textarea|button|object)$/.test( nodeName ) ? | |
3910 | + !element.disabled : | |
3911 | + "a" === nodeName ? | |
3912 | + element.href || hasTabindex : | |
3913 | + hasTabindex ) && | |
3914 | + $( element ).is( ":visible" ) && visible( $( element ) ); | |
3915 | +}; | |
3916 | + | |
3917 | +// Support: IE 8 only | |
3918 | +// IE 8 doesn't resolve inherit to visible/hidden for computed values | |
3919 | +function visible( element ) { | |
3920 | + var visibility = element.css( "visibility" ); | |
3921 | + while ( visibility === "inherit" ) { | |
3922 | + element = element.parent(); | |
3923 | + visibility = element.css( "visibility" ); | |
3924 | + } | |
3925 | + return visibility !== "hidden"; | |
3926 | +} | |
3927 | + | |
3928 | +$.extend( $.expr[ ":" ], { | |
3929 | + focusable: function( element ) { | |
3930 | + return $.ui.focusable( element, $.attr( element, "tabindex" ) != null ); | |
3931 | + } | |
3932 | +} ); | |
3933 | + | |
3934 | +var focusable = $.ui.focusable; | |
3935 | + | |
3936 | + | |
3937 | + | |
3938 | + | |
3939 | +// Support: IE8 Only | |
3940 | +// IE8 does not support the form attribute and when it is supplied. It overwrites the form prop | |
3941 | +// with a string, so we need to find the proper form. | |
3942 | +var form = $.fn.form = function() { | |
3943 | + return typeof this[ 0 ].form === "string" ? this.closest( "form" ) : $( this[ 0 ].form ); | |
3944 | +}; | |
3945 | + | |
3946 | + | |
3947 | +/*! | |
3948 | + * jQuery UI Form Reset Mixin 1.12.0-rc.2 | |
3949 | + * http://jqueryui.com | |
3950 | + * | |
3951 | + * Copyright jQuery Foundation and other contributors | |
3952 | + * Released under the MIT license. | |
3953 | + * http://jquery.org/license | |
3954 | + */ | |
3955 | + | |
3956 | +//>>label: Form Reset Mixin | |
3957 | +//>>group: Core | |
3958 | +//>>description: Refresh input widgets when their form is reset | |
3959 | +//>>docs: http://api.jqueryui.com/form-reset-mixin/ | |
3960 | + | |
3961 | + | |
3962 | + | |
3963 | +var formResetMixin = $.ui.formResetMixin = { | |
3964 | + _formResetHandler: function() { | |
3965 | + var form = $( this ); | |
3966 | + | |
3967 | + // Wait for the form reset to actually happen before refreshing | |
3968 | + setTimeout( function() { | |
3969 | + var instances = form.data( "ui-form-reset-instances" ); | |
3970 | + $.each( instances, function() { | |
3971 | + this.refresh(); | |
3972 | + } ); | |
3973 | + } ); | |
3974 | + }, | |
3975 | + | |
3976 | + _bindFormResetHandler: function() { | |
3977 | + this.form = this.element.form(); | |
3978 | + if ( !this.form.length ) { | |
3979 | + return; | |
3980 | + } | |
3981 | + | |
3982 | + var instances = this.form.data( "ui-form-reset-instances" ) || []; | |
3983 | + if ( !instances.length ) { | |
3984 | + | |
3985 | + // We don't use _on() here because we use a single event handler per form | |
3986 | + this.form.on( "reset.ui-form-reset", this._formResetHandler ); | |
3987 | + } | |
3988 | + instances.push( this ); | |
3989 | + this.form.data( "ui-form-reset-instances", instances ); | |
3990 | + }, | |
3991 | + | |
3992 | + _unbindFormResetHandler: function() { | |
3993 | + if ( !this.form.length ) { | |
3994 | + return; | |
3995 | + } | |
3996 | + | |
3997 | + var instances = this.form.data( "ui-form-reset-instances" ); | |
3998 | + instances.splice( $.inArray( this, instances ), 1 ); | |
3999 | + if ( instances.length ) { | |
4000 | + this.form.data( "ui-form-reset-instances", instances ); | |
4001 | + } else { | |
4002 | + this.form | |
4003 | + .removeData( "ui-form-reset-instances" ) | |
4004 | + .off( "reset.ui-form-reset" ); | |
4005 | + } | |
4006 | + } | |
4007 | +}; | |
4008 | + | |
4009 | + | |
4010 | +/*! | |
4011 | + * jQuery UI Support for jQuery core 1.7.x 1.12.0-rc.2 | |
4012 | + * http://jqueryui.com | |
4013 | + * | |
4014 | + * Copyright jQuery Foundation and other contributors | |
4015 | + * Released under the MIT license. | |
4016 | + * http://jquery.org/license | |
4017 | + * | |
4018 | + */ | |
4019 | + | |
4020 | +//>>label: jQuery 1.7 Support | |
4021 | +//>>group: Core | |
4022 | +//>>description: Support version 1.7.x of jQuery core | |
4023 | + | |
4024 | + | |
4025 | + | |
4026 | +// Support: jQuery 1.7 only | |
4027 | +// Not a great way to check versions, but since we only support 1.7+ and only | |
4028 | +// need to detect <1.8, this is a simple check that should suffice. Checking | |
4029 | +// for "1.7." would be a bit safer, but the version string is 1.7, not 1.7.0 | |
4030 | +// and we'll never reach 1.70.0 (if we do, we certainly won't be supporting | |
4031 | +// 1.7 anymore). See #11197 for why we're not using feature detection. | |
4032 | +if ( $.fn.jquery.substring( 0, 3 ) === "1.7" ) { | |
4033 | + | |
4034 | + // Setters for .innerWidth(), .innerHeight(), .outerWidth(), .outerHeight() | |
4035 | + // Unlike jQuery Core 1.8+, these only support numeric values to set the | |
4036 | + // dimensions in pixels | |
4037 | + $.each( [ "Width", "Height" ], function( i, name ) { | |
4038 | + var side = name === "Width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ], | |
4039 | + type = name.toLowerCase(), | |
4040 | + orig = { | |
4041 | + innerWidth: $.fn.innerWidth, | |
4042 | + innerHeight: $.fn.innerHeight, | |
4043 | + outerWidth: $.fn.outerWidth, | |
4044 | + outerHeight: $.fn.outerHeight | |
4045 | + }; | |
4046 | + | |
4047 | + function reduce( elem, size, border, margin ) { | |
4048 | + $.each( side, function() { | |
4049 | + size -= parseFloat( $.css( elem, "padding" + this ) ) || 0; | |
4050 | + if ( border ) { | |
4051 | + size -= parseFloat( $.css( elem, "border" + this + "Width" ) ) || 0; | |
4052 | + } | |
4053 | + if ( margin ) { | |
4054 | + size -= parseFloat( $.css( elem, "margin" + this ) ) || 0; | |
4055 | + } | |
4056 | + } ); | |
4057 | + return size; | |
4058 | + } | |
4059 | + | |
4060 | + $.fn[ "inner" + name ] = function( size ) { | |
4061 | + if ( size === undefined ) { | |
4062 | + return orig[ "inner" + name ].call( this ); | |
4063 | + } | |
4064 | + | |
4065 | + return this.each( function() { | |
4066 | + $( this ).css( type, reduce( this, size ) + "px" ); | |
4067 | + } ); | |
4068 | + }; | |
4069 | + | |
4070 | + $.fn[ "outer" + name ] = function( size, margin ) { | |
4071 | + if ( typeof size !== "number" ) { | |
4072 | + return orig[ "outer" + name ].call( this, size ); | |
4073 | + } | |
4074 | + | |
4075 | + return this.each( function() { | |
4076 | + $( this ).css( type, reduce( this, size, true, margin ) + "px" ); | |
4077 | + } ); | |
4078 | + }; | |
4079 | + } ); | |
4080 | + | |
4081 | + $.fn.addBack = function( selector ) { | |
4082 | + return this.add( selector == null ? | |
4083 | + this.prevObject : this.prevObject.filter( selector ) | |
4084 | + ); | |
4085 | + }; | |
4086 | +} | |
4087 | + | |
4088 | +; | |
4089 | +/*! | |
4090 | + * jQuery UI Keycode 1.12.0-rc.2 | |
4091 | + * http://jqueryui.com | |
4092 | + * | |
4093 | + * Copyright jQuery Foundation and other contributors | |
4094 | + * Released under the MIT license. | |
4095 | + * http://jquery.org/license | |
4096 | + */ | |
4097 | + | |
4098 | +//>>label: Keycode | |
4099 | +//>>group: Core | |
4100 | +//>>description: Provide keycodes as keynames | |
4101 | +//>>docs: http://api.jqueryui.com/jQuery.ui.keyCode/ | |
4102 | + | |
4103 | + | |
4104 | +var keycode = $.ui.keyCode = { | |
4105 | + BACKSPACE: 8, | |
4106 | + COMMA: 188, | |
4107 | + DELETE: 46, | |
4108 | + DOWN: 40, | |
4109 | + END: 35, | |
4110 | + ENTER: 13, | |
4111 | + ESCAPE: 27, | |
4112 | + HOME: 36, | |
4113 | + LEFT: 37, | |
4114 | + PAGE_DOWN: 34, | |
4115 | + PAGE_UP: 33, | |
4116 | + PERIOD: 190, | |
4117 | + RIGHT: 39, | |
4118 | + SPACE: 32, | |
4119 | + TAB: 9, | |
4120 | + UP: 38 | |
4121 | +}; | |
4122 | + | |
4123 | + | |
4124 | + | |
4125 | + | |
4126 | +// Internal use only | |
4127 | +var escapeSelector = $.ui.escapeSelector = ( function() { | |
4128 | + var selectorEscape = /([!"#$%&'()*+,./:;<=>?@[\]^`{|}~])/g; | |
4129 | + return function( selector ) { | |
4130 | + return selector.replace( selectorEscape, "\\$1" ); | |
4131 | + }; | |
4132 | +} )(); | |
4133 | + | |
4134 | + | |
4135 | +/*! | |
4136 | + * jQuery UI Labels 1.12.0-rc.2 | |
4137 | + * http://jqueryui.com | |
4138 | + * | |
4139 | + * Copyright jQuery Foundation and other contributors | |
4140 | + * Released under the MIT license. | |
4141 | + * http://jquery.org/license | |
4142 | + */ | |
4143 | + | |
4144 | +//>>label: labels | |
4145 | +//>>group: Core | |
4146 | +//>>description: Find all the labels associated with a given input | |
4147 | +//>>docs: http://api.jqueryui.com/labels/ | |
4148 | + | |
4149 | + | |
4150 | + | |
4151 | +var labels = $.fn.labels = function() { | |
4152 | + var ancestor, selector, id, labels, ancestors; | |
4153 | + | |
4154 | + // Check control.labels first | |
4155 | + if ( this[ 0 ].labels && this[ 0 ].labels.length ) { | |
4156 | + return this.pushStack( this[ 0 ].labels ); | |
4157 | + } | |
4158 | + | |
4159 | + // Support: IE <= 11, FF <= 37, Android <= 2.3 only | |
4160 | + // Above browsers do not support control.labels. Everything below is to support them | |
4161 | + // as well as document fragments. control.labels does not work on document fragments | |
4162 | + labels = this.eq( 0 ).parents( "label" ); | |
4163 | + | |
4164 | + // Look for the label based on the id | |
4165 | + id = this.attr( "id" ); | |
4166 | + if ( id ) { | |
4167 | + | |
4168 | + // We don't search against the document in case the element | |
4169 | + // is disconnected from the DOM | |
4170 | + ancestor = this.eq( 0 ).parents().last(); | |
4171 | + | |
4172 | + // Get a full set of top level ancestors | |
4173 | + ancestors = ancestor.add( ancestor.length ? ancestor.siblings() : this.siblings() ); | |
4174 | + | |
4175 | + // Create a selector for the label based on the id | |
4176 | + selector = "label[for='" + $.ui.escapeSelector( id ) + "']"; | |
4177 | + | |
4178 | + labels = labels.add( ancestors.find( selector ).addBack( selector ) ); | |
4179 | + | |
4180 | + } | |
4181 | + | |
4182 | + // Return whatever we have found for labels | |
4183 | + return this.pushStack( labels ); | |
4184 | +}; | |
4185 | + | |
4186 | + | |
4187 | +/*! | |
4188 | + * jQuery UI Scroll Parent 1.12.0-rc.2 | |
4189 | + * http://jqueryui.com | |
4190 | + * | |
4191 | + * Copyright jQuery Foundation and other contributors | |
4192 | + * Released under the MIT license. | |
4193 | + * http://jquery.org/license | |
4194 | + */ | |
4195 | + | |
4196 | +//>>label: scrollParent | |
4197 | +//>>group: Core | |
4198 | +//>>description: Get the closest ancestor element that is scrollable. | |
4199 | +//>>docs: http://api.jqueryui.com/scrollParent/ | |
4200 | + | |
4201 | + | |
4202 | + | |
4203 | +var scrollParent = $.fn.scrollParent = function( includeHidden ) { | |
4204 | + var position = this.css( "position" ), | |
4205 | + excludeStaticParent = position === "absolute", | |
4206 | + overflowRegex = includeHidden ? /(auto|scroll|hidden)/ : /(auto|scroll)/, | |
4207 | + scrollParent = this.parents().filter( function() { | |
4208 | + var parent = $( this ); | |
4209 | + if ( excludeStaticParent && parent.css( "position" ) === "static" ) { | |
4210 | + return false; | |
4211 | + } | |
4212 | + return overflowRegex.test( parent.css( "overflow" ) + parent.css( "overflow-y" ) + | |
4213 | + parent.css( "overflow-x" ) ); | |
4214 | + } ).eq( 0 ); | |
4215 | + | |
4216 | + return position === "fixed" || !scrollParent.length ? | |
4217 | + $( this[ 0 ].ownerDocument || document ) : | |
4218 | + scrollParent; | |
4219 | +}; | |
4220 | + | |
4221 | + | |
4222 | +/*! | |
4223 | + * jQuery UI Tabbable 1.12.0-rc.2 | |
4224 | + * http://jqueryui.com | |
4225 | + * | |
4226 | + * Copyright jQuery Foundation and other contributors | |
4227 | + * Released under the MIT license. | |
4228 | + * http://jquery.org/license | |
4229 | + */ | |
4230 | + | |
4231 | +//>>label: :tabbable Selector | |
4232 | +//>>group: Core | |
4233 | +//>>description: Selects elements which can be tabbed to. | |
4234 | +//>>docs: http://api.jqueryui.com/tabbable-selector/ | |
4235 | + | |
4236 | + | |
4237 | + | |
4238 | +var tabbable = $.extend( $.expr[ ":" ], { | |
4239 | + tabbable: function( element ) { | |
4240 | + var tabIndex = $.attr( element, "tabindex" ), | |
4241 | + hasTabindex = tabIndex != null; | |
4242 | + return ( !hasTabindex || tabIndex >= 0 ) && $.ui.focusable( element, hasTabindex ); | |
4243 | + } | |
4244 | +} ); | |
4245 | + | |
4246 | + | |
4247 | +/*! | |
4248 | + * jQuery UI Unique ID 1.12.0-rc.2 | |
4249 | + * http://jqueryui.com | |
4250 | + * | |
4251 | + * Copyright jQuery Foundation and other contributors | |
4252 | + * Released under the MIT license. | |
4253 | + * http://jquery.org/license | |
4254 | + */ | |
4255 | + | |
4256 | +//>>label: uniqueId | |
4257 | +//>>group: Core | |
4258 | +//>>description: Functions to generate and remove uniqueId's | |
4259 | +//>>docs: http://api.jqueryui.com/uniqueId/ | |
4260 | + | |
4261 | + | |
4262 | + | |
4263 | +var uniqueId = $.fn.extend( { | |
4264 | + uniqueId: ( function() { | |
4265 | + var uuid = 0; | |
4266 | + | |
4267 | + return function() { | |
4268 | + return this.each( function() { | |
4269 | + if ( !this.id ) { | |
4270 | + this.id = "ui-id-" + ( ++uuid ); | |
4271 | + } | |
4272 | + } ); | |
4273 | + }; | |
4274 | + } )(), | |
4275 | + | |
4276 | + removeUniqueId: function() { | |
4277 | + return this.each( function() { | |
4278 | + if ( /^ui-id-\d+$/.test( this.id ) ) { | |
4279 | + $( this ).removeAttr( "id" ); | |
4280 | + } | |
4281 | + } ); | |
4282 | + } | |
4283 | +} ); | |
4284 | + | |
4285 | + | |
4286 | +/*! | |
4287 | + * jQuery UI Accordion 1.12.0-rc.2 | |
4288 | + * http://jqueryui.com | |
4289 | + * | |
4290 | + * Copyright jQuery Foundation and other contributors | |
4291 | + * Released under the MIT license. | |
4292 | + * http://jquery.org/license | |
4293 | + */ | |
4294 | + | |
4295 | +//>>label: Accordion | |
4296 | +//>>group: Widgets | |
4297 | +// jscs:disable maximumLineLength | |
4298 | +//>>description: Displays collapsible content panels for presenting information in a limited amount of space. | |
4299 | +// jscs:enable maximumLineLength | |
4300 | +//>>docs: http://api.jqueryui.com/accordion/ | |
4301 | +//>>demos: http://jqueryui.com/accordion/ | |
4302 | +//>>css.structure: ../../themes/base/core.css | |
4303 | +//>>css.structure: ../../themes/base/accordion.css | |
4304 | +//>>css.theme: ../../themes/base/theme.css | |
4305 | + | |
4306 | + | |
4307 | + | |
4308 | +var widgetsAccordion = $.widget( "ui.accordion", { | |
4309 | + version: "1.12.0-rc.2", | |
4310 | + options: { | |
4311 | + active: 0, | |
4312 | + animate: {}, | |
4313 | + classes: { | |
4314 | + "ui-accordion-header": "ui-corner-top", | |
4315 | + "ui-accordion-header-collapsed": "ui-corner-all", | |
4316 | + "ui-accordion-content": "ui-corner-bottom" | |
4317 | + }, | |
4318 | + collapsible: false, | |
4319 | + event: "click", | |
4320 | + header: "> li > :first-child, > :not(li):even", | |
4321 | + heightStyle: "auto", | |
4322 | + icons: { | |
4323 | + activeHeader: "ui-icon-triangle-1-s", | |
4324 | + header: "ui-icon-triangle-1-e" | |
4325 | + }, | |
4326 | + | |
4327 | + // Callbacks | |
4328 | + activate: null, | |
4329 | + beforeActivate: null | |
4330 | + }, | |
4331 | + | |
4332 | + hideProps: { | |
4333 | + borderTopWidth: "hide", | |
4334 | + borderBottomWidth: "hide", | |
4335 | + paddingTop: "hide", | |
4336 | + paddingBottom: "hide", | |
4337 | + height: "hide" | |
4338 | + }, | |
4339 | + | |
4340 | + showProps: { | |
4341 | + borderTopWidth: "show", | |
4342 | + borderBottomWidth: "show", | |
4343 | + paddingTop: "show", | |
4344 | + paddingBottom: "show", | |
4345 | + height: "show" | |
4346 | + }, | |
4347 | + | |
4348 | + _create: function() { | |
4349 | + var options = this.options; | |
4350 | + | |
4351 | + this.prevShow = this.prevHide = $(); | |
4352 | + this._addClass( "ui-accordion", "ui-widget ui-helper-reset" ); | |
4353 | + this.element.attr( "role", "tablist" ); | |
4354 | + | |
4355 | + // Don't allow collapsible: false and active: false / null | |
4356 | + if ( !options.collapsible && ( options.active === false || options.active == null ) ) { | |
4357 | + options.active = 0; | |
4358 | + } | |
4359 | + | |
4360 | + this._processPanels(); | |
4361 | + | |
4362 | + // handle negative values | |
4363 | + if ( options.active < 0 ) { | |
4364 | + options.active += this.headers.length; | |
4365 | + } | |
4366 | + this._refresh(); | |
4367 | + }, | |
4368 | + | |
4369 | + _getCreateEventData: function() { | |
4370 | + return { | |
4371 | + header: this.active, | |
4372 | + panel: !this.active.length ? $() : this.active.next() | |
4373 | + }; | |
4374 | + }, | |
4375 | + | |
4376 | + _createIcons: function() { | |
4377 | + var icon, children, | |
4378 | + icons = this.options.icons; | |
4379 | + | |
4380 | + if ( icons ) { | |
4381 | + icon = $( "<span>" ); | |
4382 | + this._addClass( icon, "ui-accordion-header-icon", "ui-icon " + icons.header ); | |
4383 | + icon.prependTo( this.headers ); | |
4384 | + children = this.active.children( ".ui-accordion-header-icon" ); | |
4385 | + this._removeClass( children, icons.header ) | |
4386 | + ._addClass( children, null, icons.activeHeader ) | |
4387 | + ._addClass( this.headers, "ui-accordion-icons" ); | |
4388 | + } | |
4389 | + }, | |
4390 | + | |
4391 | + _destroyIcons: function() { | |
4392 | + this._removeClass( this.headers, "ui-accordion-icons" ); | |
4393 | + this.headers.children( ".ui-accordion-header-icon" ).remove(); | |
4394 | + }, | |
4395 | + | |
4396 | + _destroy: function() { | |
4397 | + var contents; | |
4398 | + | |
4399 | + // Clean up main element | |
4400 | + this.element.removeAttr( "role" ); | |
4401 | + | |
4402 | + // Clean up headers | |
4403 | + this.headers | |
4404 | + .removeAttr( "role aria-expanded aria-selected aria-controls tabIndex" ) | |
4405 | + .removeUniqueId(); | |
4406 | + | |
4407 | + this._destroyIcons(); | |
4408 | + | |
4409 | + // Clean up content panels | |
4410 | + contents = this.headers.next() | |
4411 | + .css( "display", "" ) | |
4412 | + .removeAttr( "role aria-hidden aria-labelledby" ) | |
4413 | + .removeUniqueId(); | |
4414 | + | |
4415 | + if ( this.options.heightStyle !== "content" ) { | |
4416 | + contents.css( "height", "" ); | |
4417 | + } | |
4418 | + }, | |
4419 | + | |
4420 | + _setOption: function( key, value ) { | |
4421 | + if ( key === "active" ) { | |
4422 | + | |
4423 | + // _activate() will handle invalid values and update this.options | |
4424 | + this._activate( value ); | |
4425 | + return; | |
4426 | + } | |
4427 | + | |
4428 | + if ( key === "event" ) { | |
4429 | + if ( this.options.event ) { | |
4430 | + this._off( this.headers, this.options.event ); | |
4431 | + } | |
4432 | + this._setupEvents( value ); | |
4433 | + } | |
4434 | + | |
4435 | + this._super( key, value ); | |
4436 | + | |
4437 | + // Setting collapsible: false while collapsed; open first panel | |
4438 | + if ( key === "collapsible" && !value && this.options.active === false ) { | |
4439 | + this._activate( 0 ); | |
4440 | + } | |
4441 | + | |
4442 | + if ( key === "icons" ) { | |
4443 | + this._destroyIcons(); | |
4444 | + if ( value ) { | |
4445 | + this._createIcons(); | |
4446 | + } | |
4447 | + } | |
4448 | + }, | |
4449 | + | |
4450 | + _setOptionDisabled: function( value ) { | |
4451 | + this._super( value ); | |
4452 | + | |
4453 | + this.element.attr( "aria-disabled", value ); | |
4454 | + | |
4455 | + // Support: IE8 Only | |
4456 | + // #5332 / #6059 - opacity doesn't cascade to positioned elements in IE | |
4457 | + // so we need to add the disabled class to the headers and panels | |
4458 | + this._toggleClass( null, "ui-state-disabled", !!value ); | |
4459 | + this._toggleClass( this.headers.add( this.headers.next() ), null, "ui-state-disabled", | |
4460 | + !!value ); | |
4461 | + }, | |
4462 | + | |
4463 | + _keydown: function( event ) { | |
4464 | + if ( event.altKey || event.ctrlKey ) { | |
4465 | + return; | |
4466 | + } | |
4467 | + | |
4468 | + var keyCode = $.ui.keyCode, | |
4469 | + length = this.headers.length, | |
4470 | + currentIndex = this.headers.index( event.target ), | |
4471 | + toFocus = false; | |
4472 | + | |
4473 | + switch ( event.keyCode ) { | |
4474 | + case keyCode.RIGHT: | |
4475 | + case keyCode.DOWN: | |
4476 | + toFocus = this.headers[ ( currentIndex + 1 ) % length ]; | |
4477 | + break; | |
4478 | + case keyCode.LEFT: | |
4479 | + case keyCode.UP: | |
4480 | + toFocus = this.headers[ ( currentIndex - 1 + length ) % length ]; | |
4481 | + break; | |
4482 | + case keyCode.SPACE: | |
4483 | + case keyCode.ENTER: | |
4484 | + this._eventHandler( event ); | |
4485 | + break; | |
4486 | + case keyCode.HOME: | |
4487 | + toFocus = this.headers[ 0 ]; | |
4488 | + break; | |
4489 | + case keyCode.END: | |
4490 | + toFocus = this.headers[ length - 1 ]; | |
4491 | + break; | |
4492 | + } | |
4493 | + | |
4494 | + if ( toFocus ) { | |
4495 | + $( event.target ).attr( "tabIndex", -1 ); | |
4496 | + $( toFocus ).attr( "tabIndex", 0 ); | |
4497 | + $( toFocus ).trigger( "focus" ); | |
4498 | + event.preventDefault(); | |
4499 | + } | |
4500 | + }, | |
4501 | + | |
4502 | + _panelKeyDown: function( event ) { | |
4503 | + if ( event.keyCode === $.ui.keyCode.UP && event.ctrlKey ) { | |
4504 | + $( event.currentTarget ).prev().trigger( "focus" ); | |
4505 | + } | |
4506 | + }, | |
4507 | + | |
4508 | + refresh: function() { | |
4509 | + var options = this.options; | |
4510 | + this._processPanels(); | |
4511 | + | |
4512 | + // Was collapsed or no panel | |
4513 | + if ( ( options.active === false && options.collapsible === true ) || | |
4514 | + !this.headers.length ) { | |
4515 | + options.active = false; | |
4516 | + this.active = $(); | |
4517 | + | |
4518 | + // active false only when collapsible is true | |
4519 | + } else if ( options.active === false ) { | |
4520 | + this._activate( 0 ); | |
4521 | + | |
4522 | + // was active, but active panel is gone | |
4523 | + } else if ( this.active.length && !$.contains( this.element[ 0 ], this.active[ 0 ] ) ) { | |
4524 | + | |
4525 | + // all remaining panel are disabled | |
4526 | + if ( this.headers.length === this.headers.find( ".ui-state-disabled" ).length ) { | |
4527 | + options.active = false; | |
4528 | + this.active = $(); | |
4529 | + | |
4530 | + // activate previous panel | |
4531 | + } else { | |
4532 | + this._activate( Math.max( 0, options.active - 1 ) ); | |
4533 | + } | |
4534 | + | |
4535 | + // was active, active panel still exists | |
4536 | + } else { | |
4537 | + | |
4538 | + // make sure active index is correct | |
4539 | + options.active = this.headers.index( this.active ); | |
4540 | + } | |
4541 | + | |
4542 | + this._destroyIcons(); | |
4543 | + | |
4544 | + this._refresh(); | |
4545 | + }, | |
4546 | + | |
4547 | + _processPanels: function() { | |
4548 | + var prevHeaders = this.headers, | |
4549 | + prevPanels = this.panels; | |
4550 | + | |
4551 | + this.headers = this.element.find( this.options.header ); | |
4552 | + this._addClass( this.headers, "ui-accordion-header ui-accordion-header-collapsed", | |
4553 | + "ui-state-default" ); | |
4554 | + | |
4555 | + this.panels = this.headers.next().filter( ":not(.ui-accordion-content-active)" ).hide(); | |
4556 | + this._addClass( this.panels, "ui-accordion-content", "ui-helper-reset ui-widget-content" ); | |
4557 | + | |
4558 | + // Avoid memory leaks (#10056) | |
4559 | + if ( prevPanels ) { | |
4560 | + this._off( prevHeaders.not( this.headers ) ); | |
4561 | + this._off( prevPanels.not( this.panels ) ); | |
4562 | + } | |
4563 | + }, | |
4564 | + | |
4565 | + _refresh: function() { | |
4566 | + var maxHeight, | |
4567 | + options = this.options, | |
4568 | + heightStyle = options.heightStyle, | |
4569 | + parent = this.element.parent(); | |
4570 | + | |
4571 | + this.active = this._findActive( options.active ); | |
4572 | + this._addClass( this.active, "ui-accordion-header-active", "ui-state-active" ) | |
4573 | + ._removeClass( this.active, "ui-accordion-header-collapsed" ); | |
4574 | + this._addClass( this.active.next(), "ui-accordion-content-active" ); | |
4575 | + this.active.next().show(); | |
4576 | + | |
4577 | + this.headers | |
4578 | + .attr( "role", "tab" ) | |
4579 | + .each( function() { | |
4580 | + var header = $( this ), | |
4581 | + headerId = header.uniqueId().attr( "id" ), | |
4582 | + panel = header.next(), | |
4583 | + panelId = panel.uniqueId().attr( "id" ); | |
4584 | + header.attr( "aria-controls", panelId ); | |
4585 | + panel.attr( "aria-labelledby", headerId ); | |
4586 | + } ) | |
4587 | + .next() | |
4588 | + .attr( "role", "tabpanel" ); | |
4589 | + | |
4590 | + this.headers | |
4591 | + .not( this.active ) | |
4592 | + .attr( { | |
4593 | + "aria-selected": "false", | |
4594 | + "aria-expanded": "false", | |
4595 | + tabIndex: -1 | |
4596 | + } ) | |
4597 | + .next() | |
4598 | + .attr( { | |
4599 | + "aria-hidden": "true" | |
4600 | + } ) | |
4601 | + .hide(); | |
4602 | + | |
4603 | + // Make sure at least one header is in the tab order | |
4604 | + if ( !this.active.length ) { | |
4605 | + this.headers.eq( 0 ).attr( "tabIndex", 0 ); | |
4606 | + } else { | |
4607 | + this.active.attr( { | |
4608 | + "aria-selected": "true", | |
4609 | + "aria-expanded": "true", | |
4610 | + tabIndex: 0 | |
4611 | + } ) | |
4612 | + .next() | |
4613 | + .attr( { | |
4614 | + "aria-hidden": "false" | |
4615 | + } ); | |
4616 | + } | |
4617 | + | |
4618 | + this._createIcons(); | |
4619 | + | |
4620 | + this._setupEvents( options.event ); | |
4621 | + | |
4622 | + if ( heightStyle === "fill" ) { | |
4623 | + maxHeight = parent.height(); | |
4624 | + this.element.siblings( ":visible" ).each( function() { | |
4625 | + var elem = $( this ), | |
4626 | + position = elem.css( "position" ); | |
4627 | + | |
4628 | + if ( position === "absolute" || position === "fixed" ) { | |
4629 | + return; | |
4630 | + } | |
4631 | + maxHeight -= elem.outerHeight( true ); | |
4632 | + } ); | |
4633 | + | |
4634 | + this.headers.each( function() { | |
4635 | + maxHeight -= $( this ).outerHeight( true ); | |
4636 | + } ); | |
4637 | + | |
4638 | + this.headers.next() | |
4639 | + .each( function() { | |
4640 | + $( this ).height( Math.max( 0, maxHeight - | |
4641 | + $( this ).innerHeight() + $( this ).height() ) ); | |
4642 | + } ) | |
4643 | + .css( "overflow", "auto" ); | |
4644 | + } else if ( heightStyle === "auto" ) { | |
4645 | + maxHeight = 0; | |
4646 | + this.headers.next() | |
4647 | + .each( function() { | |
4648 | + var isVisible = $( this ).is( ":visible" ); | |
4649 | + if ( !isVisible ) { | |
4650 | + $( this ).show(); | |
4651 | + } | |
4652 | + maxHeight = Math.max( maxHeight, $( this ).css( "height", "" ).height() ); | |
4653 | + if ( !isVisible ) { | |
4654 | + $( this ).hide(); | |
4655 | + } | |
4656 | + } ) | |
4657 | + .height( maxHeight ); | |
4658 | + } | |
4659 | + }, | |
4660 | + | |
4661 | + _activate: function( index ) { | |
4662 | + var active = this._findActive( index )[ 0 ]; | |
4663 | + | |
4664 | + // Trying to activate the already active panel | |
4665 | + if ( active === this.active[ 0 ] ) { | |
4666 | + return; | |
4667 | + } | |
4668 | + | |
4669 | + // Trying to collapse, simulate a click on the currently active header | |
4670 | + active = active || this.active[ 0 ]; | |
4671 | + | |
4672 | + this._eventHandler( { | |
4673 | + target: active, | |
4674 | + currentTarget: active, | |
4675 | + preventDefault: $.noop | |
4676 | + } ); | |
4677 | + }, | |
4678 | + | |
4679 | + _findActive: function( selector ) { | |
4680 | + return typeof selector === "number" ? this.headers.eq( selector ) : $(); | |
4681 | + }, | |
4682 | + | |
4683 | + _setupEvents: function( event ) { | |
4684 | + var events = { | |
4685 | + keydown: "_keydown" | |
4686 | + }; | |
4687 | + if ( event ) { | |
4688 | + $.each( event.split( " " ), function( index, eventName ) { | |
4689 | + events[ eventName ] = "_eventHandler"; | |
4690 | + } ); | |
4691 | + } | |
4692 | + | |
4693 | + this._off( this.headers.add( this.headers.next() ) ); | |
4694 | + this._on( this.headers, events ); | |
4695 | + this._on( this.headers.next(), { keydown: "_panelKeyDown" } ); | |
4696 | + this._hoverable( this.headers ); | |
4697 | + this._focusable( this.headers ); | |
4698 | + }, | |
4699 | + | |
4700 | + _eventHandler: function( event ) { | |
4701 | + var activeChildren, clickedChildren, | |
4702 | + options = this.options, | |
4703 | + active = this.active, | |
4704 | + clicked = $( event.currentTarget ), | |
4705 | + clickedIsActive = clicked[ 0 ] === active[ 0 ], | |
4706 | + collapsing = clickedIsActive && options.collapsible, | |
4707 | + toShow = collapsing ? $() : clicked.next(), | |
4708 | + toHide = active.next(), | |
4709 | + eventData = { | |
4710 | + oldHeader: active, | |
4711 | + oldPanel: toHide, | |
4712 | + newHeader: collapsing ? $() : clicked, | |
4713 | + newPanel: toShow | |
4714 | + }; | |
4715 | + | |
4716 | + event.preventDefault(); | |
4717 | + | |
4718 | + if ( | |
4719 | + | |
4720 | + // click on active header, but not collapsible | |
4721 | + ( clickedIsActive && !options.collapsible ) || | |
4722 | + | |
4723 | + // allow canceling activation | |
4724 | + ( this._trigger( "beforeActivate", event, eventData ) === false ) ) { | |
4725 | + return; | |
4726 | + } | |
4727 | + | |
4728 | + options.active = collapsing ? false : this.headers.index( clicked ); | |
4729 | + | |
4730 | + // When the call to ._toggle() comes after the class changes | |
4731 | + // it causes a very odd bug in IE 8 (see #6720) | |
4732 | + this.active = clickedIsActive ? $() : clicked; | |
4733 | + this._toggle( eventData ); | |
4734 | + | |
4735 | + // Switch classes | |
4736 | + // corner classes on the previously active header stay after the animation | |
4737 | + this._removeClass( active, "ui-accordion-header-active", "ui-state-active" ); | |
4738 | + if ( options.icons ) { | |
4739 | + activeChildren = active.children( ".ui-accordion-header-icon" ); | |
4740 | + this._removeClass( activeChildren, null, options.icons.activeHeader ) | |
4741 | + ._addClass( activeChildren, null, options.icons.header ); | |
4742 | + } | |
4743 | + | |
4744 | + if ( !clickedIsActive ) { | |
4745 | + this._removeClass( clicked, "ui-accordion-header-collapsed" ) | |
4746 | + ._addClass( clicked, "ui-accordion-header-active", "ui-state-active" ); | |
4747 | + if ( options.icons ) { | |
4748 | + clickedChildren = clicked.children( ".ui-accordion-header-icon" ); | |
4749 | + this._removeClass( clickedChildren, null, options.icons.header ) | |
4750 | + ._addClass( clickedChildren, null, options.icons.activeHeader ); | |
4751 | + } | |
4752 | + | |
4753 | + this._addClass( clicked.next(), "ui-accordion-content-active" ); | |
4754 | + } | |
4755 | + }, | |
4756 | + | |
4757 | + _toggle: function( data ) { | |
4758 | + var toShow = data.newPanel, | |
4759 | + toHide = this.prevShow.length ? this.prevShow : data.oldPanel; | |
4760 | + | |
4761 | + // Handle activating a panel during the animation for another activation | |
4762 | + this.prevShow.add( this.prevHide ).stop( true, true ); | |
4763 | + this.prevShow = toShow; | |
4764 | + this.prevHide = toHide; | |
4765 | + | |
4766 | + if ( this.options.animate ) { | |
4767 | + this._animate( toShow, toHide, data ); | |
4768 | + } else { | |
4769 | + toHide.hide(); | |
4770 | + toShow.show(); | |
4771 | + this._toggleComplete( data ); | |
4772 | + } | |
4773 | + | |
4774 | + toHide.attr( { | |
4775 | + "aria-hidden": "true" | |
4776 | + } ); | |
4777 | + toHide.prev().attr( { | |
4778 | + "aria-selected": "false", | |
4779 | + "aria-expanded": "false" | |
4780 | + } ); | |
4781 | + | |
4782 | + // if we're switching panels, remove the old header from the tab order | |
4783 | + // if we're opening from collapsed state, remove the previous header from the tab order | |
4784 | + // if we're collapsing, then keep the collapsing header in the tab order | |
4785 | + if ( toShow.length && toHide.length ) { | |
4786 | + toHide.prev().attr( { | |
4787 | + "tabIndex": -1, | |
4788 | + "aria-expanded": "false" | |
4789 | + } ); | |
4790 | + } else if ( toShow.length ) { | |
4791 | + this.headers.filter( function() { | |
4792 | + return parseInt( $( this ).attr( "tabIndex" ), 10 ) === 0; | |
4793 | + } ) | |
4794 | + .attr( "tabIndex", -1 ); | |
4795 | + } | |
4796 | + | |
4797 | + toShow | |
4798 | + .attr( "aria-hidden", "false" ) | |
4799 | + .prev() | |
4800 | + .attr( { | |
4801 | + "aria-selected": "true", | |
4802 | + "aria-expanded": "true", | |
4803 | + tabIndex: 0 | |
4804 | + } ); | |
4805 | + }, | |
4806 | + | |
4807 | + _animate: function( toShow, toHide, data ) { | |
4808 | + var total, easing, duration, | |
4809 | + that = this, | |
4810 | + adjust = 0, | |
4811 | + boxSizing = toShow.css( "box-sizing" ), | |
4812 | + down = toShow.length && | |
4813 | + ( !toHide.length || ( toShow.index() < toHide.index() ) ), | |
4814 | + animate = this.options.animate || {}, | |
4815 | + options = down && animate.down || animate, | |
4816 | + complete = function() { | |
4817 | + that._toggleComplete( data ); | |
4818 | + }; | |
4819 | + | |
4820 | + if ( typeof options === "number" ) { | |
4821 | + duration = options; | |
4822 | + } | |
4823 | + if ( typeof options === "string" ) { | |
4824 | + easing = options; | |
4825 | + } | |
4826 | + | |
4827 | + // fall back from options to animation in case of partial down settings | |
4828 | + easing = easing || options.easing || animate.easing; | |
4829 | + duration = duration || options.duration || animate.duration; | |
4830 | + | |
4831 | + if ( !toHide.length ) { | |
4832 | + return toShow.animate( this.showProps, duration, easing, complete ); | |
4833 | + } | |
4834 | + if ( !toShow.length ) { | |
4835 | + return toHide.animate( this.hideProps, duration, easing, complete ); | |
4836 | + } | |
4837 | + | |
4838 | + total = toShow.show().outerHeight(); | |
4839 | + toHide.animate( this.hideProps, { | |
4840 | + duration: duration, | |
4841 | + easing: easing, | |
4842 | + step: function( now, fx ) { | |
4843 | + fx.now = Math.round( now ); | |
4844 | + } | |
4845 | + } ); | |
4846 | + toShow | |
4847 | + .hide() | |
4848 | + .animate( this.showProps, { | |
4849 | + duration: duration, | |
4850 | + easing: easing, | |
4851 | + complete: complete, | |
4852 | + step: function( now, fx ) { | |
4853 | + fx.now = Math.round( now ); | |
4854 | + if ( fx.prop !== "height" ) { | |
4855 | + if ( boxSizing === "content-box" ) { | |
4856 | + adjust += fx.now; | |
4857 | + } | |
4858 | + } else if ( that.options.heightStyle !== "content" ) { | |
4859 | + fx.now = Math.round( total - toHide.outerHeight() - adjust ); | |
4860 | + adjust = 0; | |
4861 | + } | |
4862 | + } | |
4863 | + } ); | |
4864 | + }, | |
4865 | + | |
4866 | + _toggleComplete: function( data ) { | |
4867 | + var toHide = data.oldPanel, | |
4868 | + prev = toHide.prev(); | |
4869 | + | |
4870 | + this._removeClass( toHide, "ui-accordion-content-active" ); | |
4871 | + this._removeClass( prev, "ui-accordion-header-active" ) | |
4872 | + ._addClass( prev, "ui-accordion-header-collapsed" ); | |
4873 | + | |
4874 | + // Work around for rendering bug in IE (#5421) | |
4875 | + if ( toHide.length ) { | |
4876 | + toHide.parent()[ 0 ].className = toHide.parent()[ 0 ].className; | |
4877 | + } | |
4878 | + this._trigger( "activate", null, data ); | |
4879 | + } | |
4880 | +} ); | |
4881 | + | |
4882 | + | |
4883 | + | |
4884 | +var safeActiveElement = $.ui.safeActiveElement = function( document ) { | |
4885 | + var activeElement; | |
4886 | + | |
4887 | + // Support: IE 9 only | |
4888 | + // IE9 throws an "Unspecified error" accessing document.activeElement from an <iframe> | |
4889 | + try { | |
4890 | + activeElement = document.activeElement; | |
4891 | + } catch ( error ) { | |
4892 | + activeElement = document.body; | |
4893 | + } | |
4894 | + | |
4895 | + // Support: IE 9 - 11 only | |
4896 | + // IE may return null instead of an element | |
4897 | + // Interestingly, this only seems to occur when NOT in an iframe | |
4898 | + if ( !activeElement ) { | |
4899 | + activeElement = document.body; | |
4900 | + } | |
4901 | + | |
4902 | + // Support: IE 11 only | |
4903 | + // IE11 returns a seemingly empty object in some cases when accessing | |
4904 | + // document.activeElement from an <iframe> | |
4905 | + if ( !activeElement.nodeName ) { | |
4906 | + activeElement = document.body; | |
4907 | + } | |
4908 | + | |
4909 | + return activeElement; | |
4910 | +}; | |
4911 | + | |
4912 | + | |
4913 | +/*! | |
4914 | + * jQuery UI Menu 1.12.0-rc.2 | |
4915 | + * http://jqueryui.com | |
4916 | + * | |
4917 | + * Copyright jQuery Foundation and other contributors | |
4918 | + * Released under the MIT license. | |
4919 | + * http://jquery.org/license | |
4920 | + */ | |
4921 | + | |
4922 | +//>>label: Menu | |
4923 | +//>>group: Widgets | |
4924 | +//>>description: Creates nestable menus. | |
4925 | +//>>docs: http://api.jqueryui.com/menu/ | |
4926 | +//>>demos: http://jqueryui.com/menu/ | |
4927 | +//>>css.structure: ../../themes/base/core.css | |
4928 | +//>>css.structure: ../../themes/base/menu.css | |
4929 | +//>>css.theme: ../../themes/base/theme.css | |
4930 | + | |
4931 | + | |
4932 | + | |
4933 | +var widgetsMenu = $.widget( "ui.menu", { | |
4934 | + version: "1.12.0-rc.2", | |
4935 | + defaultElement: "<ul>", | |
4936 | + delay: 300, | |
4937 | + options: { | |
4938 | + icons: { | |
4939 | + submenu: "ui-icon-caret-1-e" | |
4940 | + }, | |
4941 | + items: "> *", | |
4942 | + menus: "ul", | |
4943 | + position: { | |
4944 | + my: "left top", | |
4945 | + at: "right top" | |
4946 | + }, | |
4947 | + role: "menu", | |
4948 | + | |
4949 | + // Callbacks | |
4950 | + blur: null, | |
4951 | + focus: null, | |
4952 | + select: null | |
4953 | + }, | |
4954 | + | |
4955 | + _create: function() { | |
4956 | + this.activeMenu = this.element; | |
4957 | + | |
4958 | + // Flag used to prevent firing of the click handler | |
4959 | + // as the event bubbles up through nested menus | |
4960 | + this.mouseHandled = false; | |
4961 | + this.element | |
4962 | + .uniqueId() | |
4963 | + .attr( { | |
4964 | + role: this.options.role, | |
4965 | + tabIndex: 0 | |
4966 | + } ); | |
4967 | + | |
4968 | + this._addClass( "ui-menu", "ui-widget ui-widget-content" ); | |
4969 | + this._on( { | |
4970 | + | |
4971 | + // Prevent focus from sticking to links inside menu after clicking | |
4972 | + // them (focus should always stay on UL during navigation). | |
4973 | + "mousedown .ui-menu-item": function( event ) { | |
4974 | + event.preventDefault(); | |
4975 | + }, | |
4976 | + "click .ui-menu-item": function( event ) { | |
4977 | + var target = $( event.target ); | |
4978 | + var active = $( $.ui.safeActiveElement( this.document[ 0 ] ) ); | |
4979 | + if ( !this.mouseHandled && target.not( ".ui-state-disabled" ).length ) { | |
4980 | + this.select( event ); | |
4981 | + | |
4982 | + // Only set the mouseHandled flag if the event will bubble, see #9469. | |
4983 | + if ( !event.isPropagationStopped() ) { | |
4984 | + this.mouseHandled = true; | |
4985 | + } | |
4986 | + | |
4987 | + // Open submenu on click | |
4988 | + if ( target.has( ".ui-menu" ).length ) { | |
4989 | + this.expand( event ); | |
4990 | + } else if ( !this.element.is( ":focus" ) && | |
4991 | + active.closest( ".ui-menu" ).length ) { | |
4992 | + | |
4993 | + // Redirect focus to the menu | |
4994 | + this.element.trigger( "focus", [ true ] ); | |
4995 | + | |
4996 | + // If the active item is on the top level, let it stay active. | |
4997 | + // Otherwise, blur the active item since it is no longer visible. | |
4998 | + if ( this.active && this.active.parents( ".ui-menu" ).length === 1 ) { | |
4999 | + clearTimeout( this.timer ); | |
5000 | + } | |
5001 | + } | |
5002 | + } | |
5003 | + }, | |
5004 | + "mouseenter .ui-menu-item": function( event ) { | |
5005 | + | |
5006 | + // Ignore mouse events while typeahead is active, see #10458. | |
5007 | + // Prevents focusing the wrong item when typeahead causes a scroll while the mouse | |
5008 | + // is over an item in the menu | |
5009 | + if ( this.previousFilter ) { | |
5010 | + return; | |
5011 | + } | |
5012 | + | |
5013 | + var actualTarget = $( event.target ).closest( ".ui-menu-item" ), | |
5014 | + target = $( event.currentTarget ); | |
5015 | + | |
5016 | + // Ignore bubbled events on parent items, see #11641 | |
5017 | + if ( actualTarget[ 0 ] !== target[ 0 ] ) { | |
5018 | + return; | |
5019 | + } | |
5020 | + | |
5021 | + // Remove ui-state-active class from siblings of the newly focused menu item | |
5022 | + // to avoid a jump caused by adjacent elements both having a class with a border | |
5023 | + this._removeClass( target.siblings().children( ".ui-state-active" ), | |
5024 | + null, "ui-state-active" ); | |
5025 | + this.focus( event, target ); | |
5026 | + }, | |
5027 | + mouseleave: "collapseAll", | |
5028 | + "mouseleave .ui-menu": "collapseAll", | |
5029 | + focus: function( event, keepActiveItem ) { | |
5030 | + | |
5031 | + // If there's already an active item, keep it active | |
5032 | + // If not, activate the first item | |
5033 | + var item = this.active || this.element.find( this.options.items ).eq( 0 ); | |
5034 | + | |
5035 | + if ( !keepActiveItem ) { | |
5036 | + this.focus( event, item ); | |
5037 | + } | |
5038 | + }, | |
5039 | + blur: function( event ) { | |
5040 | + this._delay( function() { | |
5041 | + var notContained = !$.contains( | |
5042 | + this.element[ 0 ], | |
5043 | + $.ui.safeActiveElement( this.document[ 0 ] ) | |
5044 | + ); | |
5045 | + if ( notContained ) { | |
5046 | + this.collapseAll( event ); | |
5047 | + } | |
5048 | + } ); | |
5049 | + }, | |
5050 | + keydown: "_keydown" | |
5051 | + } ); | |
5052 | + | |
5053 | + this.refresh(); | |
5054 | + | |
5055 | + // Clicks outside of a menu collapse any open menus | |
5056 | + this._on( this.document, { | |
5057 | + click: function( event ) { | |
5058 | + if ( this._closeOnDocumentClick( event ) ) { | |
5059 | + this.collapseAll( event ); | |
5060 | + } | |
5061 | + | |
5062 | + // Reset the mouseHandled flag | |
5063 | + this.mouseHandled = false; | |
5064 | + } | |
5065 | + } ); | |
5066 | + }, | |
5067 | + | |
5068 | + _destroy: function() { | |
5069 | + var items = this.element.find( ".ui-menu-item" ) | |
5070 | + .removeAttr( "role aria-disabled" ), | |
5071 | + submenus = items.children( ".ui-menu-item-wrapper" ) | |
5072 | + .removeUniqueId() | |
5073 | + .removeAttr( "tabIndex role aria-haspopup" ); | |
5074 | + | |
5075 | + // Destroy (sub)menus | |
5076 | + this.element | |
5077 | + .removeAttr( "aria-activedescendant" ) | |
5078 | + .find( ".ui-menu" ).addBack() | |
5079 | + .removeAttr( "role aria-labelledby aria-expanded aria-hidden aria-disabled " + | |
5080 | + "tabIndex" ) | |
5081 | + .removeUniqueId() | |
5082 | + .show(); | |
5083 | + | |
5084 | + submenus.children().each( function() { | |
5085 | + var elem = $( this ); | |
5086 | + if ( elem.data( "ui-menu-submenu-caret" ) ) { | |
5087 | + elem.remove(); | |
5088 | + } | |
5089 | + } ); | |
5090 | + }, | |
5091 | + | |
5092 | + _keydown: function( event ) { | |
5093 | + var match, prev, character, skip, | |
5094 | + preventDefault = true; | |
5095 | + | |
5096 | + switch ( event.keyCode ) { | |
5097 | + case $.ui.keyCode.PAGE_UP: | |
5098 | + this.previousPage( event ); | |
5099 | + break; | |
5100 | + case $.ui.keyCode.PAGE_DOWN: | |
5101 | + this.nextPage( event ); | |
5102 | + break; | |
5103 | + case $.ui.keyCode.HOME: | |
5104 | + this._move( "first", "first", event ); | |
5105 | + break; | |
5106 | + case $.ui.keyCode.END: | |
5107 | + this._move( "last", "last", event ); | |
5108 | + break; | |
5109 | + case $.ui.keyCode.UP: | |
5110 | + this.previous( event ); | |
5111 | + break; | |
5112 | + case $.ui.keyCode.DOWN: | |
5113 | + this.next( event ); | |
5114 | + break; | |
5115 | + case $.ui.keyCode.LEFT: | |
5116 | + this.collapse( event ); | |
5117 | + break; | |
5118 | + case $.ui.keyCode.RIGHT: | |
5119 | + if ( this.active && !this.active.is( ".ui-state-disabled" ) ) { | |
5120 | + this.expand( event ); | |
5121 | + } | |
5122 | + break; | |
5123 | + case $.ui.keyCode.ENTER: | |
5124 | + case $.ui.keyCode.SPACE: | |
5125 | + this._activate( event ); | |
5126 | + break; | |
5127 | + case $.ui.keyCode.ESCAPE: | |
5128 | + this.collapse( event ); | |
5129 | + break; | |
5130 | + default: | |
5131 | + preventDefault = false; | |
5132 | + prev = this.previousFilter || ""; | |
5133 | + character = String.fromCharCode( event.keyCode ); | |
5134 | + skip = false; | |
5135 | + | |
5136 | + clearTimeout( this.filterTimer ); | |
5137 | + | |
5138 | + if ( character === prev ) { | |
5139 | + skip = true; | |
5140 | + } else { | |
5141 | + character = prev + character; | |
5142 | + } | |
5143 | + | |
5144 | + match = this._filterMenuItems( character ); | |
5145 | + match = skip && match.index( this.active.next() ) !== -1 ? | |
5146 | + this.active.nextAll( ".ui-menu-item" ) : | |
5147 | + match; | |
5148 | + | |
5149 | + // If no matches on the current filter, reset to the last character pressed | |
5150 | + // to move down the menu to the first item that starts with that character | |
5151 | + if ( !match.length ) { | |
5152 | + character = String.fromCharCode( event.keyCode ); | |
5153 | + match = this._filterMenuItems( character ); | |
5154 | + } | |
5155 | + | |
5156 | + if ( match.length ) { | |
5157 | + this.focus( event, match ); | |
5158 | + this.previousFilter = character; | |
5159 | + this.filterTimer = this._delay( function() { | |
5160 | + delete this.previousFilter; | |
5161 | + }, 1000 ); | |
5162 | + } else { | |
5163 | + delete this.previousFilter; | |
5164 | + } | |
5165 | + } | |
5166 | + | |
5167 | + if ( preventDefault ) { | |
5168 | + event.preventDefault(); | |
5169 | + } | |
5170 | + }, | |
5171 | + | |
5172 | + _activate: function( event ) { | |
5173 | + if ( this.active && !this.active.is( ".ui-state-disabled" ) ) { | |
5174 | + if ( this.active.children( "[aria-haspopup='true']" ).length ) { | |
5175 | + this.expand( event ); | |
5176 | + } else { | |
5177 | + this.select( event ); | |
5178 | + } | |
5179 | + } | |
5180 | + }, | |
5181 | + | |
5182 | + refresh: function() { | |
5183 | + var menus, items, newSubmenus, newItems, newWrappers, | |
5184 | + that = this, | |
5185 | + icon = this.options.icons.submenu, | |
5186 | + submenus = this.element.find( this.options.menus ); | |
5187 | + | |
5188 | + this._toggleClass( "ui-menu-icons", null, !!this.element.find( ".ui-icon" ).length ); | |
5189 | + | |
5190 | + // Initialize nested menus | |
5191 | + newSubmenus = submenus.filter( ":not(.ui-menu)" ) | |
5192 | + .hide() | |
5193 | + .attr( { | |
5194 | + role: this.options.role, | |
5195 | + "aria-hidden": "true", | |
5196 | + "aria-expanded": "false" | |
5197 | + } ) | |
5198 | + .each( function() { | |
5199 | + var menu = $( this ), | |
5200 | + item = menu.prev(), | |
5201 | + submenuCaret = $( "<span>" ).data( "ui-menu-submenu-caret", true ); | |
5202 | + | |
5203 | + that._addClass( submenuCaret, "ui-menu-icon", "ui-icon " + icon ); | |
5204 | + item | |
5205 | + .attr( "aria-haspopup", "true" ) | |
5206 | + .prepend( submenuCaret ); | |
5207 | + menu.attr( "aria-labelledby", item.attr( "id" ) ); | |
5208 | + } ); | |
5209 | + | |
5210 | + this._addClass( newSubmenus, "ui-menu", "ui-widget ui-widget-content ui-front" ); | |
5211 | + | |
5212 | + menus = submenus.add( this.element ); | |
5213 | + items = menus.find( this.options.items ); | |
5214 | + | |
5215 | + // Initialize menu-items containing spaces and/or dashes only as dividers | |
5216 | + items.not( ".ui-menu-item" ).each( function() { | |
5217 | + var item = $( this ); | |
5218 | + if ( that._isDivider( item ) ) { | |
5219 | + that._addClass( item, "ui-menu-divider", "ui-widget-content" ); | |
5220 | + } | |
5221 | + } ); | |
5222 | + | |
5223 | + // Don't refresh list items that are already adapted | |
5224 | + newItems = items.not( ".ui-menu-item, .ui-menu-divider" ); | |
5225 | + newWrappers = newItems.children() | |
5226 | + .not( ".ui-menu" ) | |
5227 | + .uniqueId() | |
5228 | + .attr( { | |
5229 | + tabIndex: -1, | |
5230 | + role: this._itemRole() | |
5231 | + } ); | |
5232 | + this._addClass( newItems, "ui-menu-item" ) | |
5233 | + ._addClass( newWrappers, "ui-menu-item-wrapper" ); | |
5234 | + | |
5235 | + // Add aria-disabled attribute to any disabled menu item | |
5236 | + items.filter( ".ui-state-disabled" ).attr( "aria-disabled", "true" ); | |
5237 | + | |
5238 | + // If the active item has been removed, blur the menu | |
5239 | + if ( this.active && !$.contains( this.element[ 0 ], this.active[ 0 ] ) ) { | |
5240 | + this.blur(); | |
5241 | + } | |
5242 | + }, | |
5243 | + | |
5244 | + _itemRole: function() { | |
5245 | + return { | |
5246 | + menu: "menuitem", | |
5247 | + listbox: "option" | |
5248 | + }[ this.options.role ]; | |
5249 | + }, | |
5250 | + | |
5251 | + _setOption: function( key, value ) { | |
5252 | + if ( key === "icons" ) { | |
5253 | + var icons = this.element.find( ".ui-menu-icon" ); | |
5254 | + this._removeClass( icons, null, this.options.icons.submenu ) | |
5255 | + ._addClass( icons, null, value.submenu ); | |
5256 | + } | |
5257 | + this._super( key, value ); | |
5258 | + }, | |
5259 | + | |
5260 | + _setOptionDisabled: function( value ) { | |
5261 | + this._super( value ); | |
5262 | + | |
5263 | + this.element.attr( "aria-disabled", String( value ) ); | |
5264 | + this._toggleClass( null, "ui-state-disabled", !!value ); | |
5265 | + }, | |
5266 | + | |
5267 | + focus: function( event, item ) { | |
5268 | + var nested, focused, activeParent; | |
5269 | + this.blur( event, event && event.type === "focus" ); | |
5270 | + | |
5271 | + this._scrollIntoView( item ); | |
5272 | + | |
5273 | + this.active = item.first(); | |
5274 | + | |
5275 | + focused = this.active.children( ".ui-menu-item-wrapper" ); | |
5276 | + this._addClass( focused, null, "ui-state-active" ); | |
5277 | + | |
5278 | + // Only update aria-activedescendant if there's a role | |
5279 | + // otherwise we assume focus is managed elsewhere | |
5280 | + if ( this.options.role ) { | |
5281 | + this.element.attr( "aria-activedescendant", focused.attr( "id" ) ); | |
5282 | + } | |
5283 | + | |
5284 | + // Highlight active parent menu item, if any | |
5285 | + activeParent = this.active | |
5286 | + .parent() | |
5287 | + .closest( ".ui-menu-item" ) | |
5288 | + .children( ".ui-menu-item-wrapper" ); | |
5289 | + this._addClass( activeParent, null, "ui-state-active" ); | |
5290 | + | |
5291 | + if ( event && event.type === "keydown" ) { | |
5292 | + this._close(); | |
5293 | + } else { | |
5294 | + this.timer = this._delay( function() { | |
5295 | + this._close(); | |
5296 | + }, this.delay ); | |
5297 | + } | |
5298 | + | |
5299 | + nested = item.children( ".ui-menu" ); | |
5300 | + if ( nested.length && event && ( /^mouse/.test( event.type ) ) ) { | |
5301 | + this._startOpening( nested ); | |
5302 | + } | |
5303 | + this.activeMenu = item.parent(); | |
5304 | + | |
5305 | + this._trigger( "focus", event, { item: item } ); | |
5306 | + }, | |
5307 | + | |
5308 | + _scrollIntoView: function( item ) { | |
5309 | + var borderTop, paddingTop, offset, scroll, elementHeight, itemHeight; | |
5310 | + if ( this._hasScroll() ) { | |
5311 | + borderTop = parseFloat( $.css( this.activeMenu[ 0 ], "borderTopWidth" ) ) || 0; | |
5312 | + paddingTop = parseFloat( $.css( this.activeMenu[ 0 ], "paddingTop" ) ) || 0; | |
5313 | + offset = item.offset().top - this.activeMenu.offset().top - borderTop - paddingTop; | |
5314 | + scroll = this.activeMenu.scrollTop(); | |
5315 | + elementHeight = this.activeMenu.height(); | |
5316 | + itemHeight = item.outerHeight(); | |
5317 | + | |
5318 | + if ( offset < 0 ) { | |
5319 | + this.activeMenu.scrollTop( scroll + offset ); | |
5320 | + } else if ( offset + itemHeight > elementHeight ) { | |
5321 | + this.activeMenu.scrollTop( scroll + offset - elementHeight + itemHeight ); | |
5322 | + } | |
5323 | + } | |
5324 | + }, | |
5325 | + | |
5326 | + blur: function( event, fromFocus ) { | |
5327 | + if ( !fromFocus ) { | |
5328 | + clearTimeout( this.timer ); | |
5329 | + } | |
5330 | + | |
5331 | + if ( !this.active ) { | |
5332 | + return; | |
5333 | + } | |
5334 | + | |
5335 | + this._removeClass( this.active.children( ".ui-menu-item-wrapper" ), | |
5336 | + null, "ui-state-active" ); | |
5337 | + | |
5338 | + this._trigger( "blur", event, { item: this.active } ); | |
5339 | + this.active = null; | |
5340 | + }, | |
5341 | + | |
5342 | + _startOpening: function( submenu ) { | |
5343 | + clearTimeout( this.timer ); | |
5344 | + | |
5345 | + // Don't open if already open fixes a Firefox bug that caused a .5 pixel | |
5346 | + // shift in the submenu position when mousing over the caret icon | |
5347 | + if ( submenu.attr( "aria-hidden" ) !== "true" ) { | |
5348 | + return; | |
5349 | + } | |
5350 | + | |
5351 | + this.timer = this._delay( function() { | |
5352 | + this._close(); | |
5353 | + this._open( submenu ); | |
5354 | + }, this.delay ); | |
5355 | + }, | |
5356 | + | |
5357 | + _open: function( submenu ) { | |
5358 | + var position = $.extend( { | |
5359 | + of: this.active | |
5360 | + }, this.options.position ); | |
5361 | + | |
5362 | + clearTimeout( this.timer ); | |
5363 | + this.element.find( ".ui-menu" ).not( submenu.parents( ".ui-menu" ) ) | |
5364 | + .hide() | |
5365 | + .attr( "aria-hidden", "true" ); | |
5366 | + | |
5367 | + submenu | |
5368 | + .show() | |
5369 | + .removeAttr( "aria-hidden" ) | |
5370 | + .attr( "aria-expanded", "true" ) | |
5371 | + .position( position ); | |
5372 | + }, | |
5373 | + | |
5374 | + collapseAll: function( event, all ) { | |
5375 | + clearTimeout( this.timer ); | |
5376 | + this.timer = this._delay( function() { | |
5377 | + | |
5378 | + // If we were passed an event, look for the submenu that contains the event | |
5379 | + var currentMenu = all ? this.element : | |
5380 | + $( event && event.target ).closest( this.element.find( ".ui-menu" ) ); | |
5381 | + | |
5382 | + // If we found no valid submenu ancestor, use the main menu to close all | |
5383 | + // sub menus anyway | |
5384 | + if ( !currentMenu.length ) { | |
5385 | + currentMenu = this.element; | |
5386 | + } | |
5387 | + | |
5388 | + this._close( currentMenu ); | |
5389 | + | |
5390 | + this.blur( event ); | |
5391 | + | |
5392 | + // Work around active item staying active after menu is blurred | |
5393 | + this._removeClass( currentMenu.find( ".ui-state-active" ), null, "ui-state-active" ); | |
5394 | + | |
5395 | + this.activeMenu = currentMenu; | |
5396 | + }, this.delay ); | |
5397 | + }, | |
5398 | + | |
5399 | + // With no arguments, closes the currently active menu - if nothing is active | |
5400 | + // it closes all menus. If passed an argument, it will search for menus BELOW | |
5401 | + _close: function( startMenu ) { | |
5402 | + if ( !startMenu ) { | |
5403 | + startMenu = this.active ? this.active.parent() : this.element; | |
5404 | + } | |
5405 | + | |
5406 | + startMenu.find( ".ui-menu" ) | |
5407 | + .hide() | |
5408 | + .attr( "aria-hidden", "true" ) | |
5409 | + .attr( "aria-expanded", "false" ); | |
5410 | + }, | |
5411 | + | |
5412 | + _closeOnDocumentClick: function( event ) { | |
5413 | + return !$( event.target ).closest( ".ui-menu" ).length; | |
5414 | + }, | |
5415 | + | |
5416 | + _isDivider: function( item ) { | |
5417 | + | |
5418 | + // Match hyphen, em dash, en dash | |
5419 | + return !/[^\-\u2014\u2013\s]/.test( item.text() ); | |
5420 | + }, | |
5421 | + | |
5422 | + collapse: function( event ) { | |
5423 | + var newItem = this.active && | |
5424 | + this.active.parent().closest( ".ui-menu-item", this.element ); | |
5425 | + if ( newItem && newItem.length ) { | |
5426 | + this._close(); | |
5427 | + this.focus( event, newItem ); | |
5428 | + } | |
5429 | + }, | |
5430 | + | |
5431 | + expand: function( event ) { | |
5432 | + var newItem = this.active && | |
5433 | + this.active | |
5434 | + .children( ".ui-menu " ) | |
5435 | + .find( this.options.items ) | |
5436 | + .first(); | |
5437 | + | |
5438 | + if ( newItem && newItem.length ) { | |
5439 | + this._open( newItem.parent() ); | |
5440 | + | |
5441 | + // Delay so Firefox will not hide activedescendant change in expanding submenu from AT | |
5442 | + this._delay( function() { | |
5443 | + this.focus( event, newItem ); | |
5444 | + } ); | |
5445 | + } | |
5446 | + }, | |
5447 | + | |
5448 | + next: function( event ) { | |
5449 | + this._move( "next", "first", event ); | |
5450 | + }, | |
5451 | + | |
5452 | + previous: function( event ) { | |
5453 | + this._move( "prev", "last", event ); | |
5454 | + }, | |
5455 | + | |
5456 | + isFirstItem: function() { | |
5457 | + return this.active && !this.active.prevAll( ".ui-menu-item" ).length; | |
5458 | + }, | |
5459 | + | |
5460 | + isLastItem: function() { | |
5461 | + return this.active && !this.active.nextAll( ".ui-menu-item" ).length; | |
5462 | + }, | |
5463 | + | |
5464 | + _move: function( direction, filter, event ) { | |
5465 | + var next; | |
5466 | + if ( this.active ) { | |
5467 | + if ( direction === "first" || direction === "last" ) { | |
5468 | + next = this.active | |
5469 | + [ direction === "first" ? "prevAll" : "nextAll" ]( ".ui-menu-item" ) | |
5470 | + .eq( -1 ); | |
5471 | + } else { | |
5472 | + next = this.active | |
5473 | + [ direction + "All" ]( ".ui-menu-item" ) | |
5474 | + .eq( 0 ); | |
5475 | + } | |
5476 | + } | |
5477 | + if ( !next || !next.length || !this.active ) { | |
5478 | + next = this.activeMenu.find( this.options.items )[ filter ](); | |
5479 | + } | |
5480 | + | |
5481 | + this.focus( event, next ); | |
5482 | + }, | |
5483 | + | |
5484 | + nextPage: function( event ) { | |
5485 | + var item, base, height; | |
5486 | + | |
5487 | + if ( !this.active ) { | |
5488 | + this.next( event ); | |
5489 | + return; | |
5490 | + } | |
5491 | + if ( this.isLastItem() ) { | |
5492 | + return; | |
5493 | + } | |
5494 | + if ( this._hasScroll() ) { | |
5495 | + base = this.active.offset().top; | |
5496 | + height = this.element.height(); | |
5497 | + this.active.nextAll( ".ui-menu-item" ).each( function() { | |
5498 | + item = $( this ); | |
5499 | + return item.offset().top - base - height < 0; | |
5500 | + } ); | |
5501 | + | |
5502 | + this.focus( event, item ); | |
5503 | + } else { | |
5504 | + this.focus( event, this.activeMenu.find( this.options.items ) | |
5505 | + [ !this.active ? "first" : "last" ]() ); | |
5506 | + } | |
5507 | + }, | |
5508 | + | |
5509 | + previousPage: function( event ) { | |
5510 | + var item, base, height; | |
5511 | + if ( !this.active ) { | |
5512 | + this.next( event ); | |
5513 | + return; | |
5514 | + } | |
5515 | + if ( this.isFirstItem() ) { | |
5516 | + return; | |
5517 | + } | |
5518 | + if ( this._hasScroll() ) { | |
5519 | + base = this.active.offset().top; | |
5520 | + height = this.element.height(); | |
5521 | + this.active.prevAll( ".ui-menu-item" ).each( function() { | |
5522 | + item = $( this ); | |
5523 | + return item.offset().top - base + height > 0; | |
5524 | + } ); | |
5525 | + | |
5526 | + this.focus( event, item ); | |
5527 | + } else { | |
5528 | + this.focus( event, this.activeMenu.find( this.options.items ).first() ); | |
5529 | + } | |
5530 | + }, | |
5531 | + | |
5532 | + _hasScroll: function() { | |
5533 | + return this.element.outerHeight() < this.element.prop( "scrollHeight" ); | |
5534 | + }, | |
5535 | + | |
5536 | + select: function( event ) { | |
5537 | + | |
5538 | + // TODO: It should never be possible to not have an active item at this | |
5539 | + // point, but the tests don't trigger mouseenter before click. | |
5540 | + this.active = this.active || $( event.target ).closest( ".ui-menu-item" ); | |
5541 | + var ui = { item: this.active }; | |
5542 | + if ( !this.active.has( ".ui-menu" ).length ) { | |
5543 | + this.collapseAll( event, true ); | |
5544 | + } | |
5545 | + this._trigger( "select", event, ui ); | |
5546 | + }, | |
5547 | + | |
5548 | + _filterMenuItems: function( character ) { | |
5549 | + var escapedCharacter = character.replace( /[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&" ), | |
5550 | + regex = new RegExp( "^" + escapedCharacter, "i" ); | |
5551 | + | |
5552 | + return this.activeMenu | |
5553 | + .find( this.options.items ) | |
5554 | + | |
5555 | + // Only match on items, not dividers or other content (#10571) | |
5556 | + .filter( ".ui-menu-item" ) | |
5557 | + .filter( function() { | |
5558 | + return regex.test( | |
5559 | + $.trim( $( this ).children( ".ui-menu-item-wrapper" ).text() ) ); | |
5560 | + } ); | |
5561 | + } | |
5562 | +} ); | |
5563 | + | |
5564 | + | |
5565 | +/*! | |
5566 | + * jQuery UI Autocomplete 1.12.0-rc.2 | |
5567 | + * http://jqueryui.com | |
5568 | + * | |
5569 | + * Copyright jQuery Foundation and other contributors | |
5570 | + * Released under the MIT license. | |
5571 | + * http://jquery.org/license | |
5572 | + */ | |
5573 | + | |
5574 | +//>>label: Autocomplete | |
5575 | +//>>group: Widgets | |
5576 | +//>>description: Lists suggested words as the user is typing. | |
5577 | +//>>docs: http://api.jqueryui.com/autocomplete/ | |
5578 | +//>>demos: http://jqueryui.com/autocomplete/ | |
5579 | +//>>css.structure: ../../themes/base/core.css | |
5580 | +//>>css.structure: ../../themes/base/autocomplete.css | |
5581 | +//>>css.theme: ../../themes/base/theme.css | |
5582 | + | |
5583 | + | |
5584 | + | |
5585 | +$.widget( "ui.autocomplete", { | |
5586 | + version: "1.12.0-rc.2", | |
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 | + | |
5615 | + // Some browsers only repeat keydown events, not keypress events, | |
5616 | + // so we use the suppressKeyPress flag to determine if we've already | |
5617 | + // handled the keydown event. #7269 | |
5618 | + // Unfortunately the code for & in keypress is the same as the up arrow, | |
5619 | + // so we use the suppressKeyPressRepeat flag to avoid handling keypress | |
5620 | + // events when we know the keydown event was used to modify the | |
5621 | + // search term. #7799 | |
5622 | + var suppressKeyPress, suppressKeyPressRepeat, suppressInput, | |
5623 | + nodeName = this.element[ 0 ].nodeName.toLowerCase(), | |
5624 | + isTextarea = nodeName === "textarea", | |
5625 | + isInput = nodeName === "input"; | |
5626 | + | |
5627 | + // Textareas are always multi-line | |
5628 | + // Inputs are always single-line, even if inside a contentEditable element | |
5629 | + // IE also treats inputs as contentEditable | |
5630 | + // All other element types are determined by whether or not they're contentEditable | |
5631 | + this.isMultiLine = isTextarea || !isInput && this._isContentEditable( this.element ); | |
5632 | + | |
5633 | + this.valueMethod = this.element[ isTextarea || isInput ? "val" : "text" ]; | |
5634 | + this.isNewMenu = true; | |
5635 | + | |
5636 | + this._addClass( "ui-autocomplete-input" ); | |
5637 | + this.element.attr( "autocomplete", "off" ); | |
5638 | + | |
5639 | + this._on( this.element, { | |
5640 | + keydown: function( event ) { | |
5641 | + if ( this.element.prop( "readOnly" ) ) { | |
5642 | + suppressKeyPress = true; | |
5643 | + suppressInput = true; | |
5644 | + suppressKeyPressRepeat = true; | |
5645 | + return; | |
5646 | + } | |
5647 | + | |
5648 | + suppressKeyPress = false; | |
5649 | + suppressInput = false; | |
5650 | + suppressKeyPressRepeat = false; | |
5651 | + var keyCode = $.ui.keyCode; | |
5652 | + switch ( event.keyCode ) { | |
5653 | + case keyCode.PAGE_UP: | |
5654 | + suppressKeyPress = true; | |
5655 | + this._move( "previousPage", event ); | |
5656 | + break; | |
5657 | + case keyCode.PAGE_DOWN: | |
5658 | + suppressKeyPress = true; | |
5659 | + this._move( "nextPage", event ); | |
5660 | + break; | |
5661 | + case keyCode.UP: | |
5662 | + suppressKeyPress = true; | |
5663 | + this._keyEvent( "previous", event ); | |
5664 | + break; | |
5665 | + case keyCode.DOWN: | |
5666 | + suppressKeyPress = true; | |
5667 | + this._keyEvent( "next", event ); | |
5668 | + break; | |
5669 | + case keyCode.ENTER: | |
5670 | + | |
5671 | + // when menu is open and has focus | |
5672 | + if ( this.menu.active ) { | |
5673 | + | |
5674 | + // #6055 - Opera still allows the keypress to occur | |
5675 | + // which causes forms to submit | |
5676 | + suppressKeyPress = true; | |
5677 | + event.preventDefault(); | |
5678 | + this.menu.select( event ); | |
5679 | + } | |
5680 | + break; | |
5681 | + case keyCode.TAB: | |
5682 | + if ( this.menu.active ) { | |
5683 | + this.menu.select( event ); | |
5684 | + } | |
5685 | + break; | |
5686 | + case keyCode.ESCAPE: | |
5687 | + if ( this.menu.element.is( ":visible" ) ) { | |
5688 | + if ( !this.isMultiLine ) { | |
5689 | + this._value( this.term ); | |
5690 | + } | |
5691 | + this.close( event ); | |
5692 | + | |
5693 | + // Different browsers have different default behavior for escape | |
5694 | + // Single press can mean undo or clear | |
5695 | + // Double press in IE means clear the whole form | |
5696 | + event.preventDefault(); | |
5697 | + } | |
5698 | + break; | |
5699 | + default: | |
5700 | + suppressKeyPressRepeat = true; | |
5701 | + | |
5702 | + // search timeout should be triggered before the input value is changed | |
5703 | + this._searchTimeout( event ); | |
5704 | + break; | |
5705 | + } | |
5706 | + }, | |
5707 | + keypress: function( event ) { | |
5708 | + if ( suppressKeyPress ) { | |
5709 | + suppressKeyPress = false; | |
5710 | + if ( !this.isMultiLine || this.menu.element.is( ":visible" ) ) { | |
5711 | + event.preventDefault(); | |
5712 | + } | |
5713 | + return; | |
5714 | + } | |
5715 | + if ( suppressKeyPressRepeat ) { | |
5716 | + return; | |
5717 | + } | |
5718 | + | |
5719 | + // Replicate some key handlers to allow them to repeat in Firefox and Opera | |
5720 | + var keyCode = $.ui.keyCode; | |
5721 | + switch ( event.keyCode ) { | |
5722 | + case keyCode.PAGE_UP: | |
5723 | + this._move( "previousPage", event ); | |
5724 | + break; | |
5725 | + case keyCode.PAGE_DOWN: | |
5726 | + this._move( "nextPage", event ); | |
5727 | + break; | |
5728 | + case keyCode.UP: | |
5729 | + this._keyEvent( "previous", event ); | |
5730 | + break; | |
5731 | + case keyCode.DOWN: | |
5732 | + this._keyEvent( "next", event ); | |
5733 | + break; | |
5734 | + } | |
5735 | + }, | |
5736 | + input: function( event ) { | |
5737 | + if ( suppressInput ) { | |
5738 | + suppressInput = false; | |
5739 | + event.preventDefault(); | |
5740 | + return; | |
5741 | + } | |
5742 | + this._searchTimeout( event ); | |
5743 | + }, | |
5744 | + focus: function() { | |
5745 | + this.selectedItem = null; | |
5746 | + this.previous = this._value(); | |
5747 | + }, | |
5748 | + blur: function( event ) { | |
5749 | + if ( this.cancelBlur ) { | |
5750 | + delete this.cancelBlur; | |
5751 | + return; | |
5752 | + } | |
5753 | + | |
5754 | + clearTimeout( this.searching ); | |
5755 | + this.close( event ); | |
5756 | + this._change( event ); | |
5757 | + } | |
5758 | + } ); | |
5759 | + | |
5760 | + this._initSource(); | |
5761 | + this.menu = $( "<ul>" ) | |
5762 | + .appendTo( this._appendTo() ) | |
5763 | + .menu( { | |
5764 | + | |
5765 | + // disable ARIA support, the live region takes care of that | |
5766 | + role: null | |
5767 | + } ) | |
5768 | + .hide() | |
5769 | + .menu( "instance" ); | |
5770 | + | |
5771 | + this._addClass( this.menu.element, "ui-autocomplete", "ui-front" ); | |
5772 | + this._on( this.menu.element, { | |
5773 | + mousedown: function( event ) { | |
5774 | + | |
5775 | + // prevent moving focus out of the text field | |
5776 | + event.preventDefault(); | |
5777 | + | |
5778 | + // IE doesn't prevent moving focus even with event.preventDefault() | |
5779 | + // so we set a flag to know when we should ignore the blur event | |
5780 | + this.cancelBlur = true; | |
5781 | + this._delay( function() { | |
5782 | + delete this.cancelBlur; | |
5783 | + | |
5784 | + // Support: IE 8 only | |
5785 | + // Right clicking a menu item or selecting text from the menu items will | |
5786 | + // result in focus moving out of the input. However, we've already received | |
5787 | + // and ignored the blur event because of the cancelBlur flag set above. So | |
5788 | + // we restore focus to ensure that the menu closes properly based on the user's | |
5789 | + // next actions. | |
5790 | + if ( this.element[ 0 ] !== $.ui.safeActiveElement( this.document[ 0 ] ) ) { | |
5791 | + this.element.trigger( "focus" ); | |
5792 | + } | |
5793 | + } ); | |
5794 | + }, | |
5795 | + menufocus: function( event, ui ) { | |
5796 | + var label, item; | |
5797 | + | |
5798 | + // support: Firefox | |
5799 | + // Prevent accidental activation of menu items in Firefox (#7024 #9118) | |
5800 | + if ( this.isNewMenu ) { | |
5801 | + this.isNewMenu = false; | |
5802 | + if ( event.originalEvent && /^mouse/.test( event.originalEvent.type ) ) { | |
5803 | + this.menu.blur(); | |
5804 | + | |
5805 | + this.document.one( "mousemove", function() { | |
5806 | + $( event.target ).trigger( event.originalEvent ); | |
5807 | + } ); | |
5808 | + | |
5809 | + return; | |
5810 | + } | |
5811 | + } | |
5812 | + | |
5813 | + item = ui.item.data( "ui-autocomplete-item" ); | |
5814 | + if ( false !== this._trigger( "focus", event, { item: item } ) ) { | |
5815 | + | |
5816 | + // use value to match what will end up in the input, if it was a key event | |
5817 | + if ( event.originalEvent && /^key/.test( event.originalEvent.type ) ) { | |
5818 | + this._value( item.value ); | |
5819 | + } | |
5820 | + } | |
5821 | + | |
5822 | + // Announce the value in the liveRegion | |
5823 | + label = ui.item.attr( "aria-label" ) || item.value; | |
5824 | + if ( label && $.trim( label ).length ) { | |
5825 | + this.liveRegion.children().hide(); | |
5826 | + $( "<div>" ).text( label ).appendTo( this.liveRegion ); | |
5827 | + } | |
5828 | + }, | |
5829 | + menuselect: function( event, ui ) { | |
5830 | + var item = ui.item.data( "ui-autocomplete-item" ), | |
5831 | + previous = this.previous; | |
5832 | + | |
5833 | + // Only trigger when focus was lost (click on menu) | |
5834 | + if ( this.element[ 0 ] !== $.ui.safeActiveElement( this.document[ 0 ] ) ) { | |
5835 | + this.element.trigger( "focus" ); | |
5836 | + this.previous = previous; | |
5837 | + | |
5838 | + // #6109 - IE triggers two focus events and the second | |
5839 | + // is asynchronous, so we need to reset the previous | |
5840 | + // term synchronously and asynchronously :-( | |
5841 | + this._delay( function() { | |
5842 | + this.previous = previous; | |
5843 | + this.selectedItem = item; | |
5844 | + } ); | |
5845 | + } | |
5846 | + | |
5847 | + if ( false !== this._trigger( "select", event, { item: item } ) ) { | |
5848 | + this._value( item.value ); | |
5849 | + } | |
5850 | + | |
5851 | + // reset the term after the select event | |
5852 | + // this allows custom select handling to work properly | |
5853 | + this.term = this._value(); | |
5854 | + | |
5855 | + this.close( event ); | |
5856 | + this.selectedItem = item; | |
5857 | + } | |
5858 | + } ); | |
5859 | + | |
5860 | + this.liveRegion = $( "<div>", { | |
5861 | + role: "status", | |
5862 | + "aria-live": "assertive", | |
5863 | + "aria-relevant": "additions" | |
5864 | + } ) | |
5865 | + .appendTo( this.document[ 0 ].body ); | |
5866 | + | |
5867 | + this._addClass( this.liveRegion, null, "ui-helper-hidden-accessible" ); | |
5868 | + | |
5869 | + // Turning off autocomplete prevents the browser from remembering the | |
5870 | + // value when navigating through history, so we re-enable autocomplete | |
5871 | + // if the page is unloaded before the widget is destroyed. #7790 | |
5872 | + this._on( this.window, { | |
5873 | + beforeunload: function() { | |
5874 | + this.element.removeAttr( "autocomplete" ); | |
5875 | + } | |
5876 | + } ); | |
5877 | + }, | |
5878 | + | |
5879 | + _destroy: function() { | |
5880 | + clearTimeout( this.searching ); | |
5881 | + this.element.removeAttr( "autocomplete" ); | |
5882 | + this.menu.element.remove(); | |
5883 | + this.liveRegion.remove(); | |
5884 | + }, | |
5885 | + | |
5886 | + _setOption: function( key, value ) { | |
5887 | + this._super( key, value ); | |
5888 | + if ( key === "source" ) { | |
5889 | + this._initSource(); | |
5890 | + } | |
5891 | + if ( key === "appendTo" ) { | |
5892 | + this.menu.element.appendTo( this._appendTo() ); | |
5893 | + } | |
5894 | + if ( key === "disabled" && value && this.xhr ) { | |
5895 | + this.xhr.abort(); | |
5896 | + } | |
5897 | + }, | |
5898 | + | |
5899 | + _isEventTargetInWidget: function( event ) { | |
5900 | + var menuElement = this.menu.element[ 0 ]; | |
5901 | + | |
5902 | + return event.target === this.element[ 0 ] || | |
5903 | + event.target === menuElement || | |
5904 | + $.contains( menuElement, event.target ); | |
5905 | + }, | |
5906 | + | |
5907 | + _closeOnClickOutside: function( event ) { | |
5908 | + if ( !this._isEventTargetInWidget( event ) ) { | |
5909 | + this.close(); | |
5910 | + } | |
5911 | + }, | |
5912 | + | |
5913 | + _appendTo: function() { | |
5914 | + var element = this.options.appendTo; | |
5915 | + | |
5916 | + if ( element ) { | |
5917 | + element = element.jquery || element.nodeType ? | |
5918 | + $( element ) : | |
5919 | + this.document.find( element ).eq( 0 ); | |
5920 | + } | |
5921 | + | |
5922 | + if ( !element || !element[ 0 ] ) { | |
5923 | + element = this.element.closest( ".ui-front, dialog" ); | |
5924 | + } | |
5925 | + | |
5926 | + if ( !element.length ) { | |
5927 | + element = this.document[ 0 ].body; | |
5928 | + } | |
5929 | + | |
5930 | + return element; | |
5931 | + }, | |
5932 | + | |
5933 | + _initSource: function() { | |
5934 | + var array, url, | |
5935 | + that = this; | |
5936 | + if ( $.isArray( this.options.source ) ) { | |
5937 | + array = this.options.source; | |
5938 | + this.source = function( request, response ) { | |
5939 | + response( $.ui.autocomplete.filter( array, request.term ) ); | |
5940 | + }; | |
5941 | + } else if ( typeof this.options.source === "string" ) { | |
5942 | + url = this.options.source; | |
5943 | + this.source = function( request, response ) { | |
5944 | + if ( that.xhr ) { | |
5945 | + that.xhr.abort(); | |
5946 | + } | |
5947 | + that.xhr = $.ajax( { | |
5948 | + url: url, | |
5949 | + data: request, | |
5950 | + dataType: "json", | |
5951 | + success: function( data ) { | |
5952 | + response( data ); | |
5953 | + }, | |
5954 | + error: function() { | |
5955 | + response( [] ); | |
5956 | + } | |
5957 | + } ); | |
5958 | + }; | |
5959 | + } else { | |
5960 | + this.source = this.options.source; | |
5961 | + } | |
5962 | + }, | |
5963 | + | |
5964 | + _searchTimeout: function( event ) { | |
5965 | + clearTimeout( this.searching ); | |
5966 | + this.searching = this._delay( function() { | |
5967 | + | |
5968 | + // Search if the value has changed, or if the user retypes the same value (see #7434) | |
5969 | + var equalValues = this.term === this._value(), | |
5970 | + menuVisible = this.menu.element.is( ":visible" ), | |
5971 | + modifierKey = event.altKey || event.ctrlKey || event.metaKey || event.shiftKey; | |
5972 | + | |
5973 | + if ( !equalValues || ( equalValues && !menuVisible && !modifierKey ) ) { | |
5974 | + this.selectedItem = null; | |
5975 | + this.search( null, event ); | |
5976 | + } | |
5977 | + }, this.options.delay ); | |
5978 | + }, | |
5979 | + | |
5980 | + search: function( value, event ) { | |
5981 | + value = value != null ? value : this._value(); | |
5982 | + | |
5983 | + // Always save the actual value, not the one passed as an argument | |
5984 | + this.term = this._value(); | |
5985 | + | |
5986 | + if ( value.length < this.options.minLength ) { | |
5987 | + return this.close( event ); | |
5988 | + } | |
5989 | + | |
5990 | + if ( this._trigger( "search", event ) === false ) { | |
5991 | + return; | |
5992 | + } | |
5993 | + | |
5994 | + return this._search( value ); | |
5995 | + }, | |
5996 | + | |
5997 | + _search: function( value ) { | |
5998 | + this.pending++; | |
5999 | + this._addClass( "ui-autocomplete-loading" ); | |
6000 | + this.cancelSearch = false; | |
6001 | + | |
6002 | + this.source( { term: value }, this._response() ); | |
6003 | + }, | |
6004 | + | |
6005 | + _response: function() { | |
6006 | + var index = ++this.requestIndex; | |
6007 | + | |
6008 | + return $.proxy( function( content ) { | |
6009 | + if ( index === this.requestIndex ) { | |
6010 | + this.__response( content ); | |
6011 | + } | |
6012 | + | |
6013 | + this.pending--; | |
6014 | + if ( !this.pending ) { | |
6015 | + this._removeClass( "ui-autocomplete-loading" ); | |
6016 | + } | |
6017 | + }, this ); | |
6018 | + }, | |
6019 | + | |
6020 | + __response: function( content ) { | |
6021 | + if ( content ) { | |
6022 | + content = this._normalize( content ); | |
6023 | + } | |
6024 | + this._trigger( "response", null, { content: content } ); | |
6025 | + if ( !this.options.disabled && content && content.length && !this.cancelSearch ) { | |
6026 | + this._suggest( content ); | |
6027 | + this._trigger( "open" ); | |
6028 | + } else { | |
6029 | + | |
6030 | + // use ._close() instead of .close() so we don't cancel future searches | |
6031 | + this._close(); | |
6032 | + } | |
6033 | + }, | |
6034 | + | |
6035 | + close: function( event ) { | |
6036 | + this.cancelSearch = true; | |
6037 | + this._close( event ); | |
6038 | + }, | |
6039 | + | |
6040 | + _close: function( event ) { | |
6041 | + | |
6042 | + // Remove the handler that closes the menu on outside clicks | |
6043 | + this._off( this.document, "mousedown" ); | |
6044 | + | |
6045 | + if ( this.menu.element.is( ":visible" ) ) { | |
6046 | + this.menu.element.hide(); | |
6047 | + this.menu.blur(); | |
6048 | + this.isNewMenu = true; | |
6049 | + this._trigger( "close", event ); | |
6050 | + } | |
6051 | + }, | |
6052 | + | |
6053 | + _change: function( event ) { | |
6054 | + if ( this.previous !== this._value() ) { | |
6055 | + this._trigger( "change", event, { item: this.selectedItem } ); | |
6056 | + } | |
6057 | + }, | |
6058 | + | |
6059 | + _normalize: function( items ) { | |
6060 | + | |
6061 | + // assume all items have the right format when the first item is complete | |
6062 | + if ( items.length && items[ 0 ].label && items[ 0 ].value ) { | |
6063 | + return items; | |
6064 | + } | |
6065 | + return $.map( items, function( item ) { | |
6066 | + if ( typeof item === "string" ) { | |
6067 | + return { | |
6068 | + label: item, | |
6069 | + value: item | |
6070 | + }; | |
6071 | + } | |
6072 | + return $.extend( {}, item, { | |
6073 | + label: item.label || item.value, | |
6074 | + value: item.value || item.label | |
6075 | + } ); | |
6076 | + } ); | |
6077 | + }, | |
6078 | + | |
6079 | + _suggest: function( items ) { | |
6080 | + var ul = this.menu.element.empty(); | |
6081 | + this._renderMenu( ul, items ); | |
6082 | + this.isNewMenu = true; | |
6083 | + this.menu.refresh(); | |
6084 | + | |
6085 | + // Size and position menu | |
6086 | + ul.show(); | |
6087 | + this._resizeMenu(); | |
6088 | + ul.position( $.extend( { | |
6089 | + of: this.element | |
6090 | + }, this.options.position ) ); | |
6091 | + | |
6092 | + if ( this.options.autoFocus ) { | |
6093 | + this.menu.next(); | |
6094 | + } | |
6095 | + | |
6096 | + // Listen for interactions outside of the widget (#6642) | |
6097 | + this._on( this.document, { | |
6098 | + mousedown: "_closeOnClickOutside" | |
6099 | + } ); | |
6100 | + }, | |
6101 | + | |
6102 | + _resizeMenu: function() { | |
6103 | + var ul = this.menu.element; | |
6104 | + ul.outerWidth( Math.max( | |
6105 | + | |
6106 | + // Firefox wraps long text (possibly a rounding bug) | |
6107 | + // so we add 1px to avoid the wrapping (#7513) | |
6108 | + ul.width( "" ).outerWidth() + 1, | |
6109 | + this.element.outerWidth() | |
6110 | + ) ); | |
6111 | + }, | |
6112 | + | |
6113 | + _renderMenu: function( ul, items ) { | |
6114 | + var that = this; | |
6115 | + $.each( items, function( index, item ) { | |
6116 | + that._renderItemData( ul, item ); | |
6117 | + } ); | |
6118 | + }, | |
6119 | + | |
6120 | + _renderItemData: function( ul, item ) { | |
6121 | + return this._renderItem( ul, item ).data( "ui-autocomplete-item", item ); | |
6122 | + }, | |
6123 | + | |
6124 | + _renderItem: function( ul, item ) { | |
6125 | + return $( "<li>" ) | |
6126 | + .append( $( "<div>" ).text( item.label ) ) | |
6127 | + .appendTo( ul ); | |
6128 | + }, | |
6129 | + | |
6130 | + _move: function( direction, event ) { | |
6131 | + if ( !this.menu.element.is( ":visible" ) ) { | |
6132 | + this.search( null, event ); | |
6133 | + return; | |
6134 | + } | |
6135 | + if ( this.menu.isFirstItem() && /^previous/.test( direction ) || | |
6136 | + this.menu.isLastItem() && /^next/.test( direction ) ) { | |
6137 | + | |
6138 | + if ( !this.isMultiLine ) { | |
6139 | + this._value( this.term ); | |
6140 | + } | |
6141 | + | |
6142 | + this.menu.blur(); | |
6143 | + return; | |
6144 | + } | |
6145 | + this.menu[ direction ]( event ); | |
6146 | + }, | |
6147 | + | |
6148 | + widget: function() { | |
6149 | + return this.menu.element; | |
6150 | + }, | |
6151 | + | |
6152 | + _value: function() { | |
6153 | + return this.valueMethod.apply( this.element, arguments ); | |
6154 | + }, | |
6155 | + | |
6156 | + _keyEvent: function( keyEvent, event ) { | |
6157 | + if ( !this.isMultiLine || this.menu.element.is( ":visible" ) ) { | |
6158 | + this._move( keyEvent, event ); | |
6159 | + | |
6160 | + // Prevents moving cursor to beginning/end of the text field in some browsers | |
6161 | + event.preventDefault(); | |
6162 | + } | |
6163 | + }, | |
6164 | + | |
6165 | + // Support: Chrome <=50 | |
6166 | + // We should be able to just use this.element.prop( "isContentEditable" ) | |
6167 | + // but hidden elements always report false in Chrome. | |
6168 | + // https://code.google.com/p/chromium/issues/detail?id=313082 | |
6169 | + _isContentEditable: function( element ) { | |
6170 | + if ( !element.length ) { | |
6171 | + return false; | |
6172 | + } | |
6173 | + | |
6174 | + var editable = element.prop( "contentEditable" ); | |
6175 | + | |
6176 | + if ( editable === "inherit" ) { | |
6177 | + return this._isContentEditable( element.parent() ); | |
6178 | + } | |
6179 | + | |
6180 | + return editable === "true"; | |
6181 | + } | |
6182 | +} ); | |
6183 | + | |
6184 | +$.extend( $.ui.autocomplete, { | |
6185 | + escapeRegex: function( value ) { | |
6186 | + return value.replace( /[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&" ); | |
6187 | + }, | |
6188 | + filter: function( array, term ) { | |
6189 | + var matcher = new RegExp( $.ui.autocomplete.escapeRegex( term ), "i" ); | |
6190 | + return $.grep( array, function( value ) { | |
6191 | + return matcher.test( value.label || value.value || value ); | |
6192 | + } ); | |
6193 | + } | |
6194 | +} ); | |
6195 | + | |
6196 | +// Live region extension, adding a `messages` option | |
6197 | +// NOTE: This is an experimental API. We are still investigating | |
6198 | +// a full solution for string manipulation and internationalization. | |
6199 | +$.widget( "ui.autocomplete", $.ui.autocomplete, { | |
6200 | + options: { | |
6201 | + messages: { | |
6202 | + noResults: "No search results.", | |
6203 | + results: function( amount ) { | |
6204 | + return amount + ( amount > 1 ? " results are" : " result is" ) + | |
6205 | + " available, use up and down arrow keys to navigate."; | |
6206 | + } | |
6207 | + } | |
6208 | + }, | |
6209 | + | |
6210 | + __response: function( content ) { | |
6211 | + var message; | |
6212 | + this._superApply( arguments ); | |
6213 | + if ( this.options.disabled || this.cancelSearch ) { | |
6214 | + return; | |
6215 | + } | |
6216 | + if ( content && content.length ) { | |
6217 | + message = this.options.messages.results( content.length ); | |
6218 | + } else { | |
6219 | + message = this.options.messages.noResults; | |
6220 | + } | |
6221 | + this.liveRegion.children().hide(); | |
6222 | + $( "<div>" ).text( message ).appendTo( this.liveRegion ); | |
6223 | + } | |
6224 | +} ); | |
6225 | + | |
6226 | +var widgetsAutocomplete = $.ui.autocomplete; | |
6227 | + | |
6228 | + | |
6229 | +/*! | |
6230 | + * jQuery UI Controlgroup 1.12.0-rc.2 | |
6231 | + * http://jqueryui.com | |
6232 | + * | |
6233 | + * Copyright jQuery Foundation and other contributors | |
6234 | + * Released under the MIT license. | |
6235 | + * http://jquery.org/license | |
6236 | + */ | |
6237 | + | |
6238 | +//>>label: Controlgroup | |
6239 | +//>>group: Widgets | |
6240 | +//>>description: Visually groups form control widgets | |
6241 | +//>>docs: http://api.jqueryui.com/controlgroup/ | |
6242 | +//>>demos: http://jqueryui.com/controlgroup/ | |
6243 | +//>>css.structure: ../../themes/base/core.css | |
6244 | +//>>css.structure: ../../themes/base/controlgroup.css | |
6245 | +//>>css.theme: ../../themes/base/theme.css | |
6246 | + | |
6247 | + | |
6248 | + | |
6249 | +var widgetsControlgroup = $.widget( "ui.controlgroup", { | |
6250 | + version: "1.12.0-rc.2", | |
6251 | + defaultElement: "<div>", | |
6252 | + options: { | |
6253 | + direction: "horizontal", | |
6254 | + disabled: null, | |
6255 | + onlyVisible: true, | |
6256 | + items: { | |
6257 | + "button": "input[type=button], input[type=submit], input[type=reset], button, a", | |
6258 | + "controlgroupLabel": ".ui-controlgroup-label", | |
6259 | + "checkboxradio": "input[type='checkbox'], input[type='radio']", | |
6260 | + "selectmenu": "select", | |
6261 | + "spinner": ".ui-spinner-input" | |
6262 | + } | |
6263 | + }, | |
6264 | + | |
6265 | + _create: function() { | |
6266 | + this._enhance(); | |
6267 | + }, | |
6268 | + | |
6269 | + // To support the enhanced option in jQuery Mobile, we isolate DOM manipulation | |
6270 | + _enhance: function() { | |
6271 | + this.element.attr( "role", "toolbar" ); | |
6272 | + this.refresh(); | |
6273 | + }, | |
6274 | + | |
6275 | + _destroy: function() { | |
6276 | + this._callChildMethod( "destroy" ); | |
6277 | + this.childWidgets.removeData( "ui-controlgroup-data" ); | |
6278 | + this.element.removeAttr( "role" ); | |
6279 | + if ( this.options.items.controlgroupLabel ) { | |
6280 | + this.element | |
6281 | + .find( this.options.items.controlgroupLabel ) | |
6282 | + .find( ".ui-controlgroup-label-contents" ) | |
6283 | + .contents().unwrap(); | |
6284 | + } | |
6285 | + }, | |
6286 | + | |
6287 | + _initWidgets: function() { | |
6288 | + var that = this, | |
6289 | + childWidgets = []; | |
6290 | + | |
6291 | + // First we iterate over each of the items options | |
6292 | + $.each( this.options.items, function( widget, selector ) { | |
6293 | + var labels; | |
6294 | + var options = {}; | |
6295 | + | |
6296 | + // Make sure the widget has a selector set | |
6297 | + if ( !selector ) { | |
6298 | + return; | |
6299 | + } | |
6300 | + | |
6301 | + if ( widget === "controlgroupLabel" ) { | |
6302 | + labels = that.element.find( selector ); | |
6303 | + labels.each( function() { | |
6304 | + $( this ).contents() | |
6305 | + .wrapAll( "<span class='ui-controlgroup-label-contents'></span>" ); | |
6306 | + } ); | |
6307 | + that._addClass( labels, null, "ui-widget ui-widget-content ui-state-default" ); | |
6308 | + childWidgets = childWidgets.concat( labels.get() ); | |
6309 | + return; | |
6310 | + } | |
6311 | + | |
6312 | + // Make sure the widget actually exists | |
6313 | + if ( !$.fn[ widget ] ) { | |
6314 | + return; | |
6315 | + } | |
6316 | + | |
6317 | + // We assume everything is in the middle to start because we can't determine | |
6318 | + // first / last elements until all enhancments are done. | |
6319 | + if ( that[ "_" + widget + "Options" ] ) { | |
6320 | + options = that[ "_" + widget + "Options" ]( "middle" ); | |
6321 | + } | |
6322 | + | |
6323 | + // Find instances of this widget inside controlgroup and init them | |
6324 | + that.element | |
6325 | + .find( selector )[ widget ]( options ) | |
6326 | + .each( function() { | |
6327 | + var element = $( this ); | |
6328 | + | |
6329 | + // Store an instance of the controlgroup to be able to reference | |
6330 | + // from the outermost element for changing options and refresh | |
6331 | + var widgetElement = element[ widget ]( "widget" ); | |
6332 | + $.data( widgetElement[ 0 ], "ui-controlgroup-data", | |
6333 | + element[ widget ]( "instance" ) ); | |
6334 | + | |
6335 | + childWidgets.push( widgetElement[ 0 ] ); | |
6336 | + } ); | |
6337 | + } ); | |
6338 | + | |
6339 | + this.childWidgets = $( $.unique( childWidgets ) ); | |
6340 | + this._addClass( this.childWidgets, "ui-controlgroup-item" ); | |
6341 | + }, | |
6342 | + | |
6343 | + _callChildMethod: function( method ) { | |
6344 | + this.childWidgets.each( function() { | |
6345 | + var element = $( this ), | |
6346 | + data = element.data( "ui-controlgroup-data" ); | |
6347 | + if ( data && data[ method ] ) { | |
6348 | + data[ method ](); | |
6349 | + } | |
6350 | + } ); | |
6351 | + }, | |
6352 | + | |
6353 | + _updateCornerClass: function( element, position ) { | |
6354 | + var remove = "ui-corner-top ui-corner-bottom ui-corner-left ui-corner-right"; | |
6355 | + var add = this._buildSimpleOptions( position, "label" ).classes.label; | |
6356 | + | |
6357 | + this._removeClass( element, null, remove ); | |
6358 | + this._addClass( element, null, add ); | |
6359 | + }, | |
6360 | + | |
6361 | + _buildSimpleOptions: function( position, key ) { | |
6362 | + var direction = this.options.direction === "vertical"; | |
6363 | + var result = { | |
6364 | + classes: {} | |
6365 | + }; | |
6366 | + result.classes[ key ] = { | |
6367 | + "middle": null, | |
6368 | + "first": "ui-corner-" + ( direction ? "top" : "left" ), | |
6369 | + "last": "ui-corner-" + ( direction ? "bottom" : "right" ) | |
6370 | + }[ position ]; | |
6371 | + | |
6372 | + return result; | |
6373 | + }, | |
6374 | + | |
6375 | + _spinnerOptions: function( position ) { | |
6376 | + var options = this._buildSimpleOptions( position, "ui-spinner" ); | |
6377 | + | |
6378 | + options.classes[ "ui-spinner-up" ] = ""; | |
6379 | + options.classes[ "ui-spinner-down" ] = ""; | |
6380 | + | |
6381 | + return options; | |
6382 | + }, | |
6383 | + | |
6384 | + _buttonOptions: function( position ) { | |
6385 | + return this._buildSimpleOptions( position, "ui-button" ); | |
6386 | + }, | |
6387 | + | |
6388 | + _checkboxradioOptions: function( position ) { | |
6389 | + return this._buildSimpleOptions( position, "ui-checkboxradio-label" ); | |
6390 | + }, | |
6391 | + | |
6392 | + _selectmenuOptions: function( position ) { | |
6393 | + var direction = this.options.direction === "vertical"; | |
6394 | + return { | |
6395 | + width: direction ? "auto" : false, | |
6396 | + classes: { | |
6397 | + middle: { | |
6398 | + "ui-selectmenu-button-open": null, | |
6399 | + "ui-selectmenu-button-closed": null | |
6400 | + }, | |
6401 | + first: { | |
6402 | + "ui-selectmenu-button-open": "ui-corner-" + ( direction ? "top" : "tl" ), | |
6403 | + "ui-selectmenu-button-closed": "ui-corner-" + ( direction ? "top" : "left" ) | |
6404 | + }, | |
6405 | + last: { | |
6406 | + "ui-selectmenu-button-open": direction ? null : "ui-corner-tr", | |
6407 | + "ui-selectmenu-button-closed": "ui-corner-" + ( direction ? "bottom" : "right" ) | |
6408 | + } | |
6409 | + | |
6410 | + }[ position ] | |
6411 | + }; | |
6412 | + }, | |
6413 | + | |
6414 | + _setOption: function( key, value ) { | |
6415 | + if ( key === "direction" ) { | |
6416 | + this._removeClass( "ui-controlgroup-" + this.options.direction ); | |
6417 | + } | |
6418 | + | |
6419 | + this._super( key, value ); | |
6420 | + if ( key === "disabled" ) { | |
6421 | + this._callChildMethod( value ? "disable" : "enable" ); | |
6422 | + return; | |
6423 | + } | |
6424 | + | |
6425 | + this.refresh(); | |
6426 | + }, | |
6427 | + | |
6428 | + refresh: function() { | |
6429 | + var children, | |
6430 | + that = this; | |
6431 | + | |
6432 | + this._addClass( "ui-controlgroup ui-controlgroup-" + this.options.direction ); | |
6433 | + | |
6434 | + if ( this.options.direction === "horizontal" ) { | |
6435 | + this._addClass( null, "ui-helper-clearfix" ); | |
6436 | + } | |
6437 | + this._initWidgets(); | |
6438 | + | |
6439 | + children = this.childWidgets; | |
6440 | + | |
6441 | + // We filter here because we need to track all childWidgets not just the visible ones | |
6442 | + if ( this.options.onlyVisible ) { | |
6443 | + children = children.filter( ":visible" ); | |
6444 | + } | |
6445 | + | |
6446 | + if ( children.length ) { | |
6447 | + | |
6448 | + // We do this last because we need to make sure all enhancment is done | |
6449 | + // before determining first and last | |
6450 | + $.each( [ "first", "last" ], function( index, value ) { | |
6451 | + var instance = children[ value ]().data( "ui-controlgroup-data" ); | |
6452 | + | |
6453 | + if ( instance && that[ "_" + instance.widgetName + "Options" ] ) { | |
6454 | + instance.element[ instance.widgetName ]( | |
6455 | + that[ "_" + instance.widgetName + "Options" ]( value ) | |
6456 | + ); | |
6457 | + } else { | |
6458 | + that._updateCornerClass( children[ value ](), value ); | |
6459 | + } | |
6460 | + } ); | |
6461 | + | |
6462 | + // Finally call the refresh method on each of the child widgets. | |
6463 | + this._callChildMethod( "refresh" ); | |
6464 | + } | |
6465 | + } | |
6466 | +} ); | |
6467 | + | |
6468 | +/*! | |
6469 | + * jQuery UI Checkboxradio 1.12.0-rc.2 | |
6470 | + * http://jqueryui.com | |
6471 | + * | |
6472 | + * Copyright jQuery Foundation and other contributors | |
6473 | + * Released under the MIT license. | |
6474 | + * http://jquery.org/license | |
6475 | + */ | |
6476 | + | |
6477 | +//>>label: Checkboxradio | |
6478 | +//>>group: Widgets | |
6479 | +//>>description: Enhances a form with multiple themeable checkboxes or radio buttons. | |
6480 | +//>>docs: http://api.jqueryui.com/checkboxradio/ | |
6481 | +//>>demos: http://jqueryui.com/checkboxradio/ | |
6482 | +//>>css.structure: ../../themes/base/core.css | |
6483 | +//>>css.structure: ../../themes/base/button.css | |
6484 | +//>>css.structure: ../../themes/base/checkboxradio.css | |
6485 | +//>>css.theme: ../../themes/base/theme.css | |
6486 | + | |
6487 | + | |
6488 | + | |
6489 | +$.widget( "ui.checkboxradio", [ $.ui.formResetMixin, { | |
6490 | + version: "1.12.0-rc.2", | |
6491 | + options: { | |
6492 | + disabled: null, | |
6493 | + label: null, | |
6494 | + icon: true, | |
6495 | + classes: { | |
6496 | + "ui-checkboxradio-label": "ui-corner-all", | |
6497 | + "ui-checkboxradio-icon": "ui-corner-all" | |
6498 | + } | |
6499 | + }, | |
6500 | + | |
6501 | + _getCreateOptions: function() { | |
6502 | + var disabled, labels; | |
6503 | + var that = this; | |
6504 | + var options = this._super() || {}; | |
6505 | + | |
6506 | + // We read the type here, because it makes more sense to throw a element type error first, | |
6507 | + // rather then the error for lack of a label. Often if its the wrong type, it | |
6508 | + // won't have a label (e.g. calling on a div, btn, etc) | |
6509 | + this._readType(); | |
6510 | + | |
6511 | + labels = this.element.labels(); | |
6512 | + | |
6513 | + // If there are multiple labels, use the last one | |
6514 | + this.label = $( labels[ labels.length - 1 ] ); | |
6515 | + if ( !this.label.length ) { | |
6516 | + $.error( "No label found for checkboxradio widget" ); | |
6517 | + } | |
6518 | + | |
6519 | + this.originalLabel = ""; | |
6520 | + | |
6521 | + // We need to get the label text but this may also need to make sure it does not contain the | |
6522 | + // input itself. | |
6523 | + this.label.contents().not( this.element ).each( function() { | |
6524 | + | |
6525 | + // The label contents could be text, html, or a mix. We concat each element to get a | |
6526 | + // string representation of the label, without the input as part of it. | |
6527 | + that.originalLabel += this.nodeType === 3 ? $( this ).text() : this.outerHTML; | |
6528 | + } ); | |
6529 | + | |
6530 | + // Set the label option if we found label text | |
6531 | + if ( this.originalLabel ) { | |
6532 | + options.label = this.originalLabel; | |
6533 | + } | |
6534 | + | |
6535 | + disabled = this.element[ 0 ].disabled; | |
6536 | + if ( disabled != null ) { | |
6537 | + options.disabled = disabled; | |
6538 | + } | |
6539 | + return options; | |
6540 | + }, | |
6541 | + | |
6542 | + _create: function() { | |
6543 | + var checked = this.element[ 0 ].checked; | |
6544 | + | |
6545 | + this._bindFormResetHandler(); | |
6546 | + | |
6547 | + if ( this.options.disabled == null ) { | |
6548 | + this.options.disabled = this.element[ 0 ].disabled; | |
6549 | + } | |
6550 | + | |
6551 | + this._setOption( "disabled", this.options.disabled ); | |
6552 | + this._addClass( "ui-checkboxradio", "ui-helper-hidden-accessible" ); | |
6553 | + this._addClass( this.label, "ui-checkboxradio-label", "ui-button ui-widget" ); | |
6554 | + | |
6555 | + if ( this.type === "radio" ) { | |
6556 | + this._addClass( this.label, "ui-checkboxradio-radio-label" ); | |
6557 | + } | |
6558 | + | |
6559 | + if ( this.options.label && this.options.label !== this.originalLabel ) { | |
6560 | + this._updateLabel(); | |
6561 | + } else if ( this.originalLabel ) { | |
6562 | + this.options.label = this.originalLabel; | |
6563 | + } | |
6564 | + | |
6565 | + this._enhance(); | |
6566 | + | |
6567 | + if ( checked ) { | |
6568 | + this._addClass( this.label, "ui-checkboxradio-checked", "ui-state-active" ); | |
6569 | + if ( this.icon ) { | |
6570 | + this._addClass( this.icon, null, "ui-state-hover" ); | |
6571 | + } | |
6572 | + } | |
6573 | + | |
6574 | + this._on( { | |
6575 | + change: "_toggleClasses", | |
6576 | + focus: function() { | |
6577 | + this._addClass( this.label, null, "ui-state-focus ui-visual-focus" ); | |
6578 | + }, | |
6579 | + blur: function() { | |
6580 | + this._removeClass( this.label, null, "ui-state-focus ui-visual-focus" ); | |
6581 | + } | |
6582 | + } ); | |
6583 | + }, | |
6584 | + | |
6585 | + _readType: function() { | |
6586 | + var nodeName = this.element[ 0 ].nodeName.toLowerCase(); | |
6587 | + this.type = this.element[ 0 ].type; | |
6588 | + if ( nodeName !== "input" || !/radio|checkbox/.test( this.type ) ) { | |
6589 | + $.error( "Can't create checkboxradio on element.nodeName=" + nodeName + | |
6590 | + " and element.type=" + this.type ); | |
6591 | + } | |
6592 | + }, | |
6593 | + | |
6594 | + // Support jQuery Mobile enhanced option | |
6595 | + _enhance: function() { | |
6596 | + this._updateIcon( this.element[ 0 ].checked ); | |
6597 | + }, | |
6598 | + | |
6599 | + widget: function() { | |
6600 | + return this.label; | |
6601 | + }, | |
6602 | + | |
6603 | + _getRadioGroup: function() { | |
6604 | + var group; | |
6605 | + var name = this.element[ 0 ].name; | |
6606 | + var nameSelector = "input[name='" + $.ui.escapeSelector( name ) + "']"; | |
6607 | + | |
6608 | + if ( !name ) { | |
6609 | + return $( [] ); | |
6610 | + } | |
6611 | + | |
6612 | + if ( this.form.length ) { | |
6613 | + group = $( this.form[ 0 ].elements ).filter( nameSelector ); | |
6614 | + } else { | |
6615 | + | |
6616 | + // Not inside a form, check all inputs that also are not inside a form | |
6617 | + group = $( nameSelector ).filter( function() { | |
6618 | + return $( this ).form().length === 0; | |
6619 | + } ); | |
6620 | + } | |
6621 | + | |
6622 | + return group.not( this.element ); | |
6623 | + }, | |
6624 | + | |
6625 | + _toggleClasses: function() { | |
6626 | + var checked = this.element[ 0 ].checked; | |
6627 | + this._toggleClass( this.label, "ui-checkboxradio-checked", "ui-state-active", checked ); | |
6628 | + | |
6629 | + if ( this.options.icon && this.type === "checkbox" ) { | |
6630 | + | |
6631 | + // We add ui-state-highlight to change the icon color | |
6632 | + this._toggleClass( this.icon, null, "ui-icon-check ui-state-highlight", checked ) | |
6633 | + ._toggleClass( this.icon, null, "ui-icon-blank", !checked ); | |
6634 | + } | |
6635 | + if ( this.type === "radio" ) { | |
6636 | + this._getRadioGroup() | |
6637 | + .each( function() { | |
6638 | + var instance = $( this ).checkboxradio( "instance" ); | |
6639 | + | |
6640 | + if ( instance ) { | |
6641 | + instance._removeClass( instance.label, | |
6642 | + "ui-checkboxradio-checked", "ui-state-active" ); | |
6643 | + } | |
6644 | + } ); | |
6645 | + } | |
6646 | + }, | |
6647 | + | |
6648 | + _destroy: function() { | |
6649 | + this._unbindFormResetHandler(); | |
6650 | + | |
6651 | + if ( this.icon ) { | |
6652 | + this.icon.remove(); | |
6653 | + this.iconSpace.remove(); | |
6654 | + } | |
6655 | + }, | |
6656 | + | |
6657 | + _setOption: function( key, value ) { | |
6658 | + | |
6659 | + // We don't allow the value to be set to nothing | |
6660 | + if ( key === "label" && !value ) { | |
6661 | + return; | |
6662 | + } | |
6663 | + | |
6664 | + this._super( key, value ); | |
6665 | + | |
6666 | + if ( key === "disabled" ) { | |
6667 | + this._toggleClass( this.label, null, "ui-state-disabled", value ); | |
6668 | + this.element[ 0 ].disabled = value; | |
6669 | + | |
6670 | + // Don't refresh when setting disabled | |
6671 | + return; | |
6672 | + } | |
6673 | + this.refresh(); | |
6674 | + }, | |
6675 | + | |
6676 | + _updateIcon: function( checked ) { | |
6677 | + var toAdd = "ui-icon ui-icon-background "; | |
6678 | + | |
6679 | + if ( this.options.icon ) { | |
6680 | + if ( !this.icon ) { | |
6681 | + this.icon = $( "<span>" ); | |
6682 | + this.iconSpace = $( "<span> </span>" ); | |
6683 | + this._addClass( this.iconSpace, "ui-checkboxradio-icon-space" ); | |
6684 | + } | |
6685 | + | |
6686 | + if ( this.type === "checkbox" ) { | |
6687 | + toAdd += checked ? "ui-icon-check ui-state-highlight" : "ui-icon-blank"; | |
6688 | + this._removeClass( this.icon, null, checked ? "ui-icon-blank" : "ui-icon-check" ); | |
6689 | + } else { | |
6690 | + toAdd += "ui-icon-blank"; | |
6691 | + } | |
6692 | + this._addClass( this.icon, "ui-checkboxradio-icon", toAdd ); | |
6693 | + if ( !checked ) { | |
6694 | + this._removeClass( this.icon, null, "ui-icon-check ui-state-highlight" ); | |
6695 | + } | |
6696 | + this.icon.prependTo( this.label ).after( this.iconSpace ); | |
6697 | + } else if ( this.icon !== undefined ) { | |
6698 | + this.icon.remove(); | |
6699 | + this.iconSpace.remove(); | |
6700 | + delete this.icon; | |
6701 | + } | |
6702 | + }, | |
6703 | + | |
6704 | + _updateLabel: function() { | |
6705 | + | |
6706 | + // Remove the contents of the label ( minus the icon, icon space, and input ) | |
6707 | + this.label.contents().not( this.element.add( this.icon ).add( this.iconSpace ) ).remove(); | |
6708 | + this.label.append( this.options.label ); | |
6709 | + }, | |
6710 | + | |
6711 | + refresh: function() { | |
6712 | + var checked = this.element[ 0 ].checked, | |
6713 | + isDisabled = this.element[ 0 ].disabled; | |
6714 | + | |
6715 | + this._updateIcon( checked ); | |
6716 | + this._toggleClass( this.label, "ui-checkboxradio-checked", "ui-state-active", checked ); | |
6717 | + if ( this.options.label !== null ) { | |
6718 | + this._updateLabel(); | |
6719 | + } | |
6720 | + | |
6721 | + if ( isDisabled !== this.options.disabled ) { | |
6722 | + this._setOptions( { "disabled": isDisabled } ); | |
6723 | + } | |
6724 | + } | |
6725 | + | |
6726 | +} ] ); | |
6727 | + | |
6728 | +var widgetsCheckboxradio = $.ui.checkboxradio; | |
6729 | + | |
6730 | + | |
6731 | +/*! | |
6732 | + * jQuery UI Button 1.12.0-rc.2 | |
6733 | + * http://jqueryui.com | |
6734 | + * | |
6735 | + * Copyright jQuery Foundation and other contributors | |
6736 | + * Released under the MIT license. | |
6737 | + * http://jquery.org/license | |
6738 | + */ | |
6739 | + | |
6740 | +//>>label: Button | |
6741 | +//>>group: Widgets | |
6742 | +//>>description: Enhances a form with themeable buttons. | |
6743 | +//>>docs: http://api.jqueryui.com/button/ | |
6744 | +//>>demos: http://jqueryui.com/button/ | |
6745 | +//>>css.structure: ../../themes/base/core.css | |
6746 | +//>>css.structure: ../../themes/base/button.css | |
6747 | +//>>css.theme: ../../themes/base/theme.css | |
6748 | + | |
6749 | + | |
6750 | + | |
6751 | +$.widget( "ui.button", { | |
6752 | + version: "1.12.0-rc.2", | |
6753 | + defaultElement: "<button>", | |
6754 | + options: { | |
6755 | + classes: { | |
6756 | + "ui-button": "ui-corner-all" | |
6757 | + }, | |
6758 | + disabled: null, | |
6759 | + icon: null, | |
6760 | + iconPosition: "beginning", | |
6761 | + label: null, | |
6762 | + showLabel: true | |
6763 | + }, | |
6764 | + | |
6765 | + _getCreateOptions: function() { | |
6766 | + var disabled, | |
6767 | + | |
6768 | + // This is to support cases like in jQuery Mobile where the base widget does have | |
6769 | + // an implementation of _getCreateOptions | |
6770 | + options = this._super() || {}; | |
6771 | + | |
6772 | + this.isInput = this.element.is( "input" ); | |
6773 | + | |
6774 | + disabled = this.element[ 0 ].disabled; | |
6775 | + if ( disabled != null ) { | |
6776 | + options.disabled = disabled; | |
6777 | + } | |
6778 | + | |
6779 | + this.originalLabel = this.isInput ? this.element.val() : this.element.html(); | |
6780 | + if ( this.originalLabel ) { | |
6781 | + options.label = this.originalLabel; | |
6782 | + } | |
6783 | + | |
6784 | + return options; | |
6785 | + }, | |
6786 | + | |
6787 | + _create: function() { | |
6788 | + if ( !this.option.showLabel & !this.options.icon ) { | |
6789 | + this.options.showLabel = true; | |
6790 | + } | |
6791 | + | |
6792 | + // We have to check the option again here even though we did in _getCreateOptions, | |
6793 | + // because null may have been passed on init which would override what was set in | |
6794 | + // _getCreateOptions | |
6795 | + if ( this.options.disabled == null ) { | |
6796 | + this.options.disabled = this.element[ 0 ].disabled || false; | |
6797 | + } | |
6798 | + | |
6799 | + this.hasTitle = !!this.element.attr( "title" ); | |
6800 | + | |
6801 | + // Check to see if the label needs to be set or if its already correct | |
6802 | + if ( this.options.label && this.options.label !== this.originalLabel ) { | |
6803 | + if ( this.isInput ) { | |
6804 | + this.element.val( this.options.label ); | |
6805 | + } else { | |
6806 | + this.element.html( this.options.label ); | |
6807 | + } | |
6808 | + } | |
6809 | + this._addClass( "ui-button", "ui-widget" ); | |
6810 | + this._setOption( "disabled", this.options.disabled ); | |
6811 | + this._enhance(); | |
6812 | + | |
6813 | + if ( this.element.is( "a" ) ) { | |
6814 | + this._on( { | |
6815 | + "keyup": function( event ) { | |
6816 | + if ( event.keyCode === $.ui.keyCode.SPACE ) { | |
6817 | + event.preventDefault(); | |
6818 | + | |
6819 | + // Support: PhantomJS <= 1.9, IE 8 Only | |
6820 | + // If a native click is available use it so we actually cause navigation | |
6821 | + // otherwise just trigger a click event | |
6822 | + if ( this.element[ 0 ].click ) { | |
6823 | + this.element[ 0 ].click(); | |
6824 | + } else { | |
6825 | + this.element.trigger( "click" ); | |
6826 | + } | |
6827 | + } | |
6828 | + } | |
6829 | + } ); | |
6830 | + } | |
6831 | + }, | |
6832 | + | |
6833 | + _enhance: function() { | |
6834 | + if ( !this.element.is( "button" ) ) { | |
6835 | + this.element.attr( "role", "button" ); | |
6836 | + } | |
6837 | + | |
6838 | + if ( this.options.icon ) { | |
6839 | + this._updateIcon( "icon", this.options.icon ); | |
6840 | + this._updateTooltip(); | |
6841 | + } | |
6842 | + }, | |
6843 | + | |
6844 | + _updateTooltip: function() { | |
6845 | + this.title = this.element.attr( "title" ); | |
6846 | + | |
6847 | + if ( !this.options.showLabel && !this.title ) { | |
6848 | + this.element.attr( "title", this.options.label ); | |
6849 | + } | |
6850 | + }, | |
6851 | + | |
6852 | + _updateIcon: function( option, value ) { | |
6853 | + var icon = option !== "iconPosition", | |
6854 | + position = icon ? this.options.iconPosition : value, | |
6855 | + displayBlock = position === "top" || position === "bottom"; | |
6856 | + | |
6857 | + // Create icon | |
6858 | + if ( !this.icon ) { | |
6859 | + this.icon = $( "<span>" ); | |
6860 | + | |
6861 | + this._addClass( this.icon, "ui-button-icon", "ui-icon" ); | |
6862 | + | |
6863 | + if ( !this.options.showLabel ) { | |
6864 | + this._addClass( "ui-button-icon-only" ); | |
6865 | + } | |
6866 | + } else if ( icon ) { | |
6867 | + | |
6868 | + // If we are updating the icon remove the old icon class | |
6869 | + this._removeClass( this.icon, null, this.options.icon ); | |
6870 | + } | |
6871 | + | |
6872 | + // If we are updating the icon add the new icon class | |
6873 | + if ( icon ) { | |
6874 | + this._addClass( this.icon, null, value ); | |
6875 | + } | |
6876 | + | |
6877 | + this._attachIcon( position ); | |
6878 | + | |
6879 | + // If the icon is on top or bottom we need to add the ui-widget-icon-block class and remove | |
6880 | + // the iconSpace if there is one. | |
6881 | + if ( displayBlock ) { | |
6882 | + this._addClass( this.icon, null, "ui-widget-icon-block" ); | |
6883 | + if ( this.iconSpace ) { | |
6884 | + this.iconSpace.remove(); | |
6885 | + } | |
6886 | + } else { | |
6887 | + | |
6888 | + // Position is beginning or end so remove the ui-widget-icon-block class and add the | |
6889 | + // space if it does not exist | |
6890 | + if ( !this.iconSpace ) { | |
6891 | + this.iconSpace = $( "<span> </span>" ); | |
6892 | + this._addClass( this.iconSpace, "ui-button-icon-space" ); | |
6893 | + } | |
6894 | + this._removeClass( this.icon, null, "ui-wiget-icon-block" ); | |
6895 | + this._attachIconSpace( position ); | |
6896 | + } | |
6897 | + }, | |
6898 | + | |
6899 | + _destroy: function() { | |
6900 | + this.element.removeAttr( "role" ); | |
6901 | + | |
6902 | + if ( this.icon ) { | |
6903 | + this.icon.remove(); | |
6904 | + } | |
6905 | + if ( this.iconSpace ) { | |
6906 | + this.iconSpace.remove(); | |
6907 | + } | |
6908 | + if ( !this.hasTitle ) { | |
6909 | + this.element.removeAttr( "title" ); | |
6910 | + } | |
6911 | + }, | |
6912 | + | |
6913 | + _attachIconSpace: function( iconPosition ) { | |
6914 | + this.icon[ /^(?:end|bottom)/.test( iconPosition ) ? "before" : "after" ]( this.iconSpace ); | |
6915 | + }, | |
6916 | + | |
6917 | + _attachIcon: function( iconPosition ) { | |
6918 | + this.element[ /^(?:end|bottom)/.test( iconPosition ) ? "append" : "prepend" ]( this.icon ); | |
6919 | + }, | |
6920 | + | |
6921 | + _setOptions: function( options ) { | |
6922 | + var newShowLabel = options.showLabel === undefined ? | |
6923 | + this.options.showLabel : | |
6924 | + options.showLabel, | |
6925 | + newIcon = options.icon === undefined ? this.options.icon : options.icon; | |
6926 | + | |
6927 | + if ( !newShowLabel && !newIcon ) { | |
6928 | + options.showLabel = true; | |
6929 | + } | |
6930 | + this._super( options ); | |
6931 | + }, | |
6932 | + | |
6933 | + _setOption: function( key, value ) { | |
6934 | + if ( key === "icon" ) { | |
6935 | + if ( value ) { | |
6936 | + this._updateIcon( key, value ); | |
6937 | + } else if ( this.icon ) { | |
6938 | + this.icon.remove(); | |
6939 | + if ( this.iconSpace ) { | |
6940 | + this.iconSpace.remove(); | |
6941 | + } | |
6942 | + } | |
6943 | + } | |
6944 | + | |
6945 | + if ( key === "iconPosition" ) { | |
6946 | + this._updateIcon( key, value ); | |
6947 | + } | |
6948 | + | |
6949 | + // Make sure we can't end up with a button that has neither text nor icon | |
6950 | + if ( key === "showLabel" ) { | |
6951 | + this._toggleClass( "ui-button-icon-only", null, !value ); | |
6952 | + this._updateTooltip(); | |
6953 | + } | |
6954 | + | |
6955 | + if ( key === "label" ) { | |
6956 | + if ( this.isInput ) { | |
6957 | + this.element.val( value ); | |
6958 | + } else { | |
6959 | + | |
6960 | + // If there is an icon, append it, else nothing then append the value | |
6961 | + // this avoids removal of the icon when setting label text | |
6962 | + this.element.html( value ); | |
6963 | + if ( this.icon ) { | |
6964 | + this._attachIcon( this.options.iconPosition ); | |
6965 | + this._attachIconSpace( this.options.iconPosition ); | |
6966 | + } | |
6967 | + } | |
6968 | + } | |
6969 | + | |
6970 | + this._super( key, value ); | |
6971 | + | |
6972 | + if ( key === "disabled" ) { | |
6973 | + this._toggleClass( null, "ui-state-disabled", value ); | |
6974 | + this.element[ 0 ].disabled = value; | |
6975 | + if ( value ) { | |
6976 | + this.element.blur(); | |
6977 | + } | |
6978 | + } | |
6979 | + }, | |
6980 | + | |
6981 | + refresh: function() { | |
6982 | + | |
6983 | + // Make sure to only check disabled if its an element that supports this otherwise | |
6984 | + // check for the disabled class to determine state | |
6985 | + var isDisabled = this.element.is( "input, button" ) ? | |
6986 | + this.element[ 0 ].disabled : this.element.hasClass( "ui-button-disabled" ); | |
6987 | + | |
6988 | + if ( isDisabled !== this.options.disabled ) { | |
6989 | + this._setOptions( { disabled: isDisabled } ); | |
6990 | + } | |
6991 | + | |
6992 | + this._updateTooltip(); | |
6993 | + } | |
6994 | +} ); | |
6995 | + | |
6996 | +// DEPRECATED | |
6997 | +if ( $.uiBackCompat !== false ) { | |
6998 | + | |
6999 | + // Text and Icons options | |
7000 | + $.widget( "ui.button", $.ui.button, { | |
7001 | + options: { | |
7002 | + text: true, | |
7003 | + icons: { | |
7004 | + primary: null, | |
7005 | + secondary: null | |
7006 | + } | |
7007 | + }, | |
7008 | + | |
7009 | + _create: function() { | |
7010 | + if ( this.options.showLabel && !this.options.text ) { | |
7011 | + this.options.showLabel = this.options.text; | |
7012 | + } | |
7013 | + if ( !this.options.showLabel && this.options.text ) { | |
7014 | + this.options.text = this.options.showLabel; | |
7015 | + } | |
7016 | + if ( !this.options.icon && ( this.options.icons.primary || | |
7017 | + this.options.icons.secondary ) ) { | |
7018 | + if ( this.options.icons.primary ) { | |
7019 | + this.options.icon = this.options.icons.primary; | |
7020 | + } else { | |
7021 | + this.options.icon = this.options.icons.secondary; | |
7022 | + this.options.iconPosition = "end"; | |
7023 | + } | |
7024 | + } else if ( this.options.icon ) { | |
7025 | + this.options.icons.primary = this.options.icon; | |
7026 | + } | |
7027 | + this._super(); | |
7028 | + }, | |
7029 | + | |
7030 | + _setOption: function( key, value ) { | |
7031 | + if ( key === "text" ) { | |
7032 | + this._super( "showLabel", value ); | |
7033 | + return; | |
7034 | + } | |
7035 | + if ( key === "showLabel" ) { | |
7036 | + this.options.text = value; | |
7037 | + } | |
7038 | + if ( key === "icon" ) { | |
7039 | + this.options.icons.primary = value; | |
7040 | + } | |
7041 | + if ( key === "icons" ) { | |
7042 | + if ( value.primary ) { | |
7043 | + this._super( "icon", value.primary ); | |
7044 | + this._super( "iconPosition", "beginning" ); | |
7045 | + } else if ( value.secondary ) { | |
7046 | + this._super( "icon", value.secondary ); | |
7047 | + this._super( "iconPosition", "end" ); | |
7048 | + } | |
7049 | + } | |
7050 | + this._superApply( arguments ); | |
7051 | + } | |
7052 | + } ); | |
7053 | + | |
7054 | + $.fn.button = ( function( orig ) { | |
7055 | + return function() { | |
7056 | + if ( !this.length || ( this.length && this[ 0 ].tagName !== "INPUT" ) || | |
7057 | + ( this.length && this[ 0 ].tagName === "INPUT" && ( | |
7058 | + this.attr( "type" ) !== "checkbox" && this.attr( "type" ) !== "radio" | |
7059 | + ) ) ) { | |
7060 | + return orig.apply( this, arguments ); | |
7061 | + } | |
7062 | + if ( !$.ui.checkboxradio ) { | |
7063 | + $.error( "Checkboxradio widget missing" ); | |
7064 | + } | |
7065 | + if ( arguments.length === 0 ) { | |
7066 | + return this.checkboxradio( { | |
7067 | + "icon": false | |
7068 | + } ); | |
7069 | + } | |
7070 | + return this.checkboxradio.apply( this, arguments ); | |
7071 | + }; | |
7072 | + } )( $.fn.button ); | |
7073 | + | |
7074 | + $.fn.buttonset = function() { | |
7075 | + if ( !$.ui.controlgroup ) { | |
7076 | + $.error( "Controlgroup widget missing" ); | |
7077 | + } | |
7078 | + if ( arguments[ 0 ] === "option" && arguments[ 1 ] === "items" && arguments[ 2 ] ) { | |
7079 | + return this.controlgroup.apply( this, | |
7080 | + [ arguments[ 0 ], "items.button", arguments[ 2 ] ] ); | |
7081 | + } | |
7082 | + if ( arguments[ 0 ] === "option" && arguments[ 1 ] === "items" ) { | |
7083 | + return this.controlgroup.apply( this, [ arguments[ 0 ], "items.button" ] ); | |
7084 | + } | |
7085 | + if ( typeof arguments[ 0 ] === "object" && arguments[ 0 ].items ) { | |
7086 | + arguments[ 0 ].items = { | |
7087 | + button: arguments[ 0 ].items | |
7088 | + }; | |
7089 | + } | |
7090 | + return this.controlgroup.apply( this, arguments ); | |
7091 | + }; | |
7092 | +} | |
7093 | + | |
7094 | +var widgetsButton = $.ui.button; | |
7095 | + | |
7096 | + | |
7097 | +// jscs:disable maximumLineLength | |
7098 | +/* jscs:disable requireCamelCaseOrUpperCaseIdentifiers */ | |
7099 | +/*! | |
7100 | + * jQuery UI Datepicker 1.12.0-rc.2 | |
7101 | + * http://jqueryui.com | |
7102 | + * | |
7103 | + * Copyright jQuery Foundation and other contributors | |
7104 | + * Released under the MIT license. | |
7105 | + * http://jquery.org/license | |
7106 | + */ | |
7107 | + | |
7108 | +//>>label: Datepicker | |
7109 | +//>>group: Widgets | |
7110 | +//>>description: Displays a calendar from an input or inline for selecting dates. | |
7111 | +//>>docs: http://api.jqueryui.com/datepicker/ | |
7112 | +//>>demos: http://jqueryui.com/datepicker/ | |
7113 | +//>>css.structure: ../../themes/base/core.css | |
7114 | +//>>css.structure: ../../themes/base/datepicker.css | |
7115 | +//>>css.theme: ../../themes/base/theme.css | |
7116 | + | |
7117 | + | |
7118 | + | |
7119 | +$.extend( $.ui, { datepicker: { version: "1.12.0-rc.2" } } ); | |
7120 | + | |
7121 | +var datepicker_instActive; | |
7122 | + | |
7123 | +function datepicker_getZindex( elem ) { | |
7124 | + var position, value; | |
7125 | + while ( elem.length && elem[ 0 ] !== document ) { | |
7126 | + | |
7127 | + // Ignore z-index if position is set to a value where z-index is ignored by the browser | |
7128 | + // This makes behavior of this function consistent across browsers | |
7129 | + // WebKit always returns auto if the element is positioned | |
7130 | + position = elem.css( "position" ); | |
7131 | + if ( position === "absolute" || position === "relative" || position === "fixed" ) { | |
7132 | + | |
7133 | + // IE returns 0 when zIndex is not specified | |
7134 | + // other browsers return a string | |
7135 | + // we ignore the case of nested elements with an explicit value of 0 | |
7136 | + // <div style="z-index: -10;"><div style="z-index: 0;"></div></div> | |
7137 | + value = parseInt( elem.css( "zIndex" ), 10 ); | |
7138 | + if ( !isNaN( value ) && value !== 0 ) { | |
7139 | + return value; | |
7140 | + } | |
7141 | + } | |
7142 | + elem = elem.parent(); | |
7143 | + } | |
7144 | + | |
7145 | + return 0; | |
7146 | +} | |
7147 | +/* Date picker manager. | |
7148 | + Use the singleton instance of this class, $.datepicker, to interact with the date picker. | |
7149 | + Settings for (groups of) date pickers are maintained in an instance object, | |
7150 | + allowing multiple different settings on the same page. */ | |
7151 | + | |
7152 | +function Datepicker() { | |
7153 | + this._curInst = null; // The current instance in use | |
7154 | + this._keyEvent = false; // If the last event was a key event | |
7155 | + this._disabledInputs = []; // List of date picker inputs that have been disabled | |
7156 | + this._datepickerShowing = false; // True if the popup picker is showing , false if not | |
7157 | + this._inDialog = false; // True if showing within a "dialog", false if not | |
7158 | + this._mainDivId = "ui-datepicker-div"; // The ID of the main datepicker division | |
7159 | + this._inlineClass = "ui-datepicker-inline"; // The name of the inline marker class | |
7160 | + this._appendClass = "ui-datepicker-append"; // The name of the append marker class | |
7161 | + this._triggerClass = "ui-datepicker-trigger"; // The name of the trigger marker class | |
7162 | + this._dialogClass = "ui-datepicker-dialog"; // The name of the dialog marker class | |
7163 | + this._disableClass = "ui-datepicker-disabled"; // The name of the disabled covering marker class | |
7164 | + this._unselectableClass = "ui-datepicker-unselectable"; // The name of the unselectable cell marker class | |
7165 | + this._currentClass = "ui-datepicker-current-day"; // The name of the current day marker class | |
7166 | + this._dayOverClass = "ui-datepicker-days-cell-over"; // The name of the day hover marker class | |
7167 | + this.regional = []; // Available regional settings, indexed by language code | |
7168 | + this.regional[ "" ] = { // Default regional settings | |
7169 | + closeText: "Done", // Display text for close link | |
7170 | + prevText: "Prev", // Display text for previous month link | |
7171 | + nextText: "Next", // Display text for next month link | |
7172 | + currentText: "Today", // Display text for current month link | |
7173 | + monthNames: [ "January","February","March","April","May","June", | |
7174 | + "July","August","September","October","November","December" ], // Names of months for drop-down and formatting | |
7175 | + monthNamesShort: [ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" ], // For formatting | |
7176 | + dayNames: [ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" ], // For formatting | |
7177 | + dayNamesShort: [ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" ], // For formatting | |
7178 | + dayNamesMin: [ "Su","Mo","Tu","We","Th","Fr","Sa" ], // Column headings for days starting at Sunday | |
7179 | + weekHeader: "Wk", // Column header for week of the year | |
7180 | + dateFormat: "mm/dd/yy", // See format options on parseDate | |
7181 | + firstDay: 0, // The first day of the week, Sun = 0, Mon = 1, ... | |
7182 | + isRTL: false, // True if right-to-left language, false if left-to-right | |
7183 | + showMonthAfterYear: false, // True if the year select precedes month, false for month then year | |
7184 | + yearSuffix: "" // Additional text to append to the year in the month headers | |
7185 | + }; | |
7186 | + this._defaults = { // Global defaults for all the date picker instances | |
7187 | + showOn: "focus", // "focus" for popup on focus, | |
7188 | + // "button" for trigger button, or "both" for either | |
7189 | + showAnim: "fadeIn", // Name of jQuery animation for popup | |
7190 | + showOptions: {}, // Options for enhanced animations | |
7191 | + defaultDate: null, // Used when field is blank: actual date, | |
7192 | + // +/-number for offset from today, null for today | |
7193 | + appendText: "", // Display text following the input box, e.g. showing the format | |
7194 | + buttonText: "...", // Text for trigger button | |
7195 | + buttonImage: "", // URL for trigger button image | |
7196 | + buttonImageOnly: false, // True if the image appears alone, false if it appears on a button | |
7197 | + hideIfNoPrevNext: false, // True to hide next/previous month links | |
7198 | + // if not applicable, false to just disable them | |
7199 | + navigationAsDateFormat: false, // True if date formatting applied to prev/today/next links | |
7200 | + gotoCurrent: false, // True if today link goes back to current selection instead | |
7201 | + changeMonth: false, // True if month can be selected directly, false if only prev/next | |
7202 | + changeYear: false, // True if year can be selected directly, false if only prev/next | |
7203 | + yearRange: "c-10:c+10", // Range of years to display in drop-down, | |
7204 | + // either relative to today's year (-nn:+nn), relative to currently displayed year | |
7205 | + // (c-nn:c+nn), absolute (nnnn:nnnn), or a combination of the above (nnnn:-n) | |
7206 | + showOtherMonths: false, // True to show dates in other months, false to leave blank | |
7207 | + selectOtherMonths: false, // True to allow selection of dates in other months, false for unselectable | |
7208 | + showWeek: false, // True to show week of the year, false to not show it | |
7209 | + calculateWeek: this.iso8601Week, // How to calculate the week of the year, | |
7210 | + // takes a Date and returns the number of the week for it | |
7211 | + shortYearCutoff: "+10", // Short year values < this are in the current century, | |
7212 | + // > this are in the previous century, | |
7213 | + // string value starting with "+" for current year + value | |
7214 | + minDate: null, // The earliest selectable date, or null for no limit | |
7215 | + maxDate: null, // The latest selectable date, or null for no limit | |
7216 | + duration: "fast", // Duration of display/closure | |
7217 | + beforeShowDay: null, // Function that takes a date and returns an array with | |
7218 | + // [0] = true if selectable, false if not, [1] = custom CSS class name(s) or "", | |
7219 | + // [2] = cell title (optional), e.g. $.datepicker.noWeekends | |
7220 | + beforeShow: null, // Function that takes an input field and | |
7221 | + // returns a set of custom settings for the date picker | |
7222 | + onSelect: null, // Define a callback function when a date is selected | |
7223 | + onChangeMonthYear: null, // Define a callback function when the month or year is changed | |
7224 | + onClose: null, // Define a callback function when the datepicker is closed | |
7225 | + numberOfMonths: 1, // Number of months to show at a time | |
7226 | + showCurrentAtPos: 0, // The position in multipe months at which to show the current month (starting at 0) | |
7227 | + stepMonths: 1, // Number of months to step back/forward | |
7228 | + stepBigMonths: 12, // Number of months to step back/forward for the big links | |
7229 | + altField: "", // Selector for an alternate field to store selected dates into | |
7230 | + altFormat: "", // The date format to use for the alternate field | |
7231 | + constrainInput: true, // The input is constrained by the current date format | |
7232 | + showButtonPanel: false, // True to show button panel, false to not show it | |
7233 | + autoSize: false, // True to size the input for the date format, false to leave as is | |
7234 | + disabled: false // The initial disabled state | |
7235 | + }; | |
7236 | + $.extend( this._defaults, this.regional[ "" ] ); | |
7237 | + this.regional.en = $.extend( true, {}, this.regional[ "" ] ); | |
7238 | + this.regional[ "en-US" ] = $.extend( true, {}, this.regional.en ); | |
7239 | + this.dpDiv = datepicker_bindHover( $( "<div id='" + this._mainDivId + "' class='ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all'></div>" ) ); | |
7240 | +} | |
7241 | + | |
7242 | +$.extend( Datepicker.prototype, { | |
7243 | + /* Class name added to elements to indicate already configured with a date picker. */ | |
7244 | + markerClassName: "hasDatepicker", | |
7245 | + | |
7246 | + //Keep track of the maximum number of rows displayed (see #7043) | |
7247 | + maxRows: 4, | |
7248 | + | |
7249 | + // TODO rename to "widget" when switching to widget factory | |
7250 | + _widgetDatepicker: function() { | |
7251 | + return this.dpDiv; | |
7252 | + }, | |
7253 | + | |
7254 | + /* Override the default settings for all instances of the date picker. | |
7255 | + * @param settings object - the new settings to use as defaults (anonymous object) | |
7256 | + * @return the manager object | |
7257 | + */ | |
7258 | + setDefaults: function( settings ) { | |
7259 | + datepicker_extendRemove( this._defaults, settings || {} ); | |
7260 | + return this; | |
7261 | + }, | |
7262 | + | |
7263 | + /* Attach the date picker to a jQuery selection. | |
7264 | + * @param target element - the target input field or division or span | |
7265 | + * @param settings object - the new settings to use for this date picker instance (anonymous) | |
7266 | + */ | |
7267 | + _attachDatepicker: function( target, settings ) { | |
7268 | + var nodeName, inline, inst; | |
7269 | + nodeName = target.nodeName.toLowerCase(); | |
7270 | + inline = ( nodeName === "div" || nodeName === "span" ); | |
7271 | + if ( !target.id ) { | |
7272 | + this.uuid += 1; | |
7273 | + target.id = "dp" + this.uuid; | |
7274 | + } | |
7275 | + inst = this._newInst( $( target ), inline ); | |
7276 | + inst.settings = $.extend( {}, settings || {} ); | |
7277 | + if ( nodeName === "input" ) { | |
7278 | + this._connectDatepicker( target, inst ); | |
7279 | + } else if ( inline ) { | |
7280 | + this._inlineDatepicker( target, inst ); | |
7281 | + } | |
7282 | + }, | |
7283 | + | |
7284 | + /* Create a new instance object. */ | |
7285 | + _newInst: function( target, inline ) { | |
7286 | + var id = target[ 0 ].id.replace( /([^A-Za-z0-9_\-])/g, "\\\\$1" ); // escape jQuery meta chars | |
7287 | + return { id: id, input: target, // associated target | |
7288 | + selectedDay: 0, selectedMonth: 0, selectedYear: 0, // current selection | |
7289 | + drawMonth: 0, drawYear: 0, // month being drawn | |
7290 | + inline: inline, // is datepicker inline or not | |
7291 | + dpDiv: ( !inline ? this.dpDiv : // presentation div | |
7292 | + datepicker_bindHover( $( "<div class='" + this._inlineClass + " ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all'></div>" ) ) ) }; | |
7293 | + }, | |
7294 | + | |
7295 | + /* Attach the date picker to an input field. */ | |
7296 | + _connectDatepicker: function( target, inst ) { | |
7297 | + var input = $( target ); | |
7298 | + inst.append = $( [] ); | |
7299 | + inst.trigger = $( [] ); | |
7300 | + if ( input.hasClass( this.markerClassName ) ) { | |
7301 | + return; | |
7302 | + } | |
7303 | + this._attachments( input, inst ); | |
7304 | + input.addClass( this.markerClassName ).on( "keydown", this._doKeyDown ). | |
7305 | + on( "keypress", this._doKeyPress ).on( "keyup", this._doKeyUp ); | |
7306 | + this._autoSize( inst ); | |
7307 | + $.data( target, "datepicker", inst ); | |
7308 | + | |
7309 | + //If disabled option is true, disable the datepicker once it has been attached to the input (see ticket #5665) | |
7310 | + if ( inst.settings.disabled ) { | |
7311 | + this._disableDatepicker( target ); | |
7312 | + } | |
7313 | + }, | |
7314 | + | |
7315 | + /* Make attachments based on settings. */ | |
7316 | + _attachments: function( input, inst ) { | |
7317 | + var showOn, buttonText, buttonImage, | |
7318 | + appendText = this._get( inst, "appendText" ), | |
7319 | + isRTL = this._get( inst, "isRTL" ); | |
7320 | + | |
7321 | + if ( inst.append ) { | |
7322 | + inst.append.remove(); | |
7323 | + } | |
7324 | + if ( appendText ) { | |
7325 | + inst.append = $( "<span class='" + this._appendClass + "'>" + appendText + "</span>" ); | |
7326 | + input[ isRTL ? "before" : "after" ]( inst.append ); | |
7327 | + } | |
7328 | + | |
7329 | + input.off( "focus", this._showDatepicker ); | |
7330 | + | |
7331 | + if ( inst.trigger ) { | |
7332 | + inst.trigger.remove(); | |
7333 | + } | |
7334 | + | |
7335 | + showOn = this._get( inst, "showOn" ); | |
7336 | + if ( showOn === "focus" || showOn === "both" ) { // pop-up date picker when in the marked field | |
7337 | + input.on( "focus", this._showDatepicker ); | |
7338 | + } | |
7339 | + if ( showOn === "button" || showOn === "both" ) { // pop-up date picker when button clicked | |
7340 | + buttonText = this._get( inst, "buttonText" ); | |
7341 | + buttonImage = this._get( inst, "buttonImage" ); | |
7342 | + inst.trigger = $( this._get( inst, "buttonImageOnly" ) ? | |
7343 | + $( "<img/>" ).addClass( this._triggerClass ). | |
7344 | + attr( { src: buttonImage, alt: buttonText, title: buttonText } ) : | |
7345 | + $( "<button type='button'></button>" ).addClass( this._triggerClass ). | |
7346 | + html( !buttonImage ? buttonText : $( "<img/>" ).attr( | |
7347 | + { src:buttonImage, alt:buttonText, title:buttonText } ) ) ); | |
7348 | + input[ isRTL ? "before" : "after" ]( inst.trigger ); | |
7349 | + inst.trigger.on( "click", function() { | |
7350 | + if ( $.datepicker._datepickerShowing && $.datepicker._lastInput === input[ 0 ] ) { | |
7351 | + $.datepicker._hideDatepicker(); | |
7352 | + } else if ( $.datepicker._datepickerShowing && $.datepicker._lastInput !== input[ 0 ] ) { | |
7353 | + $.datepicker._hideDatepicker(); | |
7354 | + $.datepicker._showDatepicker( input[ 0 ] ); | |
7355 | + } else { | |
7356 | + $.datepicker._showDatepicker( input[ 0 ] ); | |
7357 | + } | |
7358 | + return false; | |
7359 | + } ); | |
7360 | + } | |
7361 | + }, | |
7362 | + | |
7363 | + /* Apply the maximum length for the date format. */ | |
7364 | + _autoSize: function( inst ) { | |
7365 | + if ( this._get( inst, "autoSize" ) && !inst.inline ) { | |
7366 | + var findMax, max, maxI, i, | |
7367 | + date = new Date( 2009, 12 - 1, 20 ), // Ensure double digits | |
7368 | + dateFormat = this._get( inst, "dateFormat" ); | |
7369 | + | |
7370 | + if ( dateFormat.match( /[DM]/ ) ) { | |
7371 | + findMax = function( names ) { | |
7372 | + max = 0; | |
7373 | + maxI = 0; | |
7374 | + for ( i = 0; i < names.length; i++ ) { | |
7375 | + if ( names[ i ].length > max ) { | |
7376 | + max = names[ i ].length; | |
7377 | + maxI = i; | |
7378 | + } | |
7379 | + } | |
7380 | + return maxI; | |
7381 | + }; | |
7382 | + date.setMonth( findMax( this._get( inst, ( dateFormat.match( /MM/ ) ? | |
7383 | + "monthNames" : "monthNamesShort" ) ) ) ); | |
7384 | + date.setDate( findMax( this._get( inst, ( dateFormat.match( /DD/ ) ? | |
7385 | + "dayNames" : "dayNamesShort" ) ) ) + 20 - date.getDay() ); | |
7386 | + } | |
7387 | + inst.input.attr( "size", this._formatDate( inst, date ).length ); | |
7388 | + } | |
7389 | + }, | |
7390 | + | |
7391 | + /* Attach an inline date picker to a div. */ | |
7392 | + _inlineDatepicker: function( target, inst ) { | |
7393 | + var divSpan = $( target ); | |
7394 | + if ( divSpan.hasClass( this.markerClassName ) ) { | |
7395 | + return; | |
7396 | + } | |
7397 | + divSpan.addClass( this.markerClassName ).append( inst.dpDiv ); | |
7398 | + $.data( target, "datepicker", inst ); | |
7399 | + this._setDate( inst, this._getDefaultDate( inst ), true ); | |
7400 | + this._updateDatepicker( inst ); | |
7401 | + this._updateAlternate( inst ); | |
7402 | + | |
7403 | + //If disabled option is true, disable the datepicker before showing it (see ticket #5665) | |
7404 | + if ( inst.settings.disabled ) { | |
7405 | + this._disableDatepicker( target ); | |
7406 | + } | |
7407 | + | |
7408 | + // Set display:block in place of inst.dpDiv.show() which won't work on disconnected elements | |
7409 | + // http://bugs.jqueryui.com/ticket/7552 - A Datepicker created on a detached div has zero height | |
7410 | + inst.dpDiv.css( "display", "block" ); | |
7411 | + }, | |
7412 | + | |
7413 | + /* Pop-up the date picker in a "dialog" box. | |
7414 | + * @param input element - ignored | |
7415 | + * @param date string or Date - the initial date to display | |
7416 | + * @param onSelect function - the function to call when a date is selected | |
7417 | + * @param settings object - update the dialog date picker instance's settings (anonymous object) | |
7418 | + * @param pos int[2] - coordinates for the dialog's position within the screen or | |
7419 | + * event - with x/y coordinates or | |
7420 | + * leave empty for default (screen centre) | |
7421 | + * @return the manager object | |
7422 | + */ | |
7423 | + _dialogDatepicker: function( input, date, onSelect, settings, pos ) { | |
7424 | + var id, browserWidth, browserHeight, scrollX, scrollY, | |
7425 | + inst = this._dialogInst; // internal instance | |
7426 | + | |
7427 | + if ( !inst ) { | |
7428 | + this.uuid += 1; | |
7429 | + id = "dp" + this.uuid; | |
7430 | + this._dialogInput = $( "<input type='text' id='" + id + | |
7431 | + "' style='position: absolute; top: -100px; width: 0px;'/>" ); | |
7432 | + this._dialogInput.on( "keydown", this._doKeyDown ); | |
7433 | + $( "body" ).append( this._dialogInput ); | |
7434 | + inst = this._dialogInst = this._newInst( this._dialogInput, false ); | |
7435 | + inst.settings = {}; | |
7436 | + $.data( this._dialogInput[ 0 ], "datepicker", inst ); | |
7437 | + } | |
7438 | + datepicker_extendRemove( inst.settings, settings || {} ); | |
7439 | + date = ( date && date.constructor === Date ? this._formatDate( inst, date ) : date ); | |
7440 | + this._dialogInput.val( date ); | |
7441 | + | |
7442 | + this._pos = ( pos ? ( pos.length ? pos : [ pos.pageX, pos.pageY ] ) : null ); | |
7443 | + if ( !this._pos ) { | |
7444 | + browserWidth = document.documentElement.clientWidth; | |
7445 | + browserHeight = document.documentElement.clientHeight; | |
7446 | + scrollX = document.documentElement.scrollLeft || document.body.scrollLeft; | |
7447 | + scrollY = document.documentElement.scrollTop || document.body.scrollTop; | |
7448 | + this._pos = // should use actual width/height below | |
7449 | + [ ( browserWidth / 2 ) - 100 + scrollX, ( browserHeight / 2 ) - 150 + scrollY ]; | |
7450 | + } | |
7451 | + | |
7452 | + // Move input on screen for focus, but hidden behind dialog | |
7453 | + this._dialogInput.css( "left", ( this._pos[ 0 ] + 20 ) + "px" ).css( "top", this._pos[ 1 ] + "px" ); | |
7454 | + inst.settings.onSelect = onSelect; | |
7455 | + this._inDialog = true; | |
7456 | + this.dpDiv.addClass( this._dialogClass ); | |
7457 | + this._showDatepicker( this._dialogInput[ 0 ] ); | |
7458 | + if ( $.blockUI ) { | |
7459 | + $.blockUI( this.dpDiv ); | |
7460 | + } | |
7461 | + $.data( this._dialogInput[ 0 ], "datepicker", inst ); | |
7462 | + return this; | |
7463 | + }, | |
7464 | + | |
7465 | + /* Detach a datepicker from its control. | |
7466 | + * @param target element - the target input field or division or span | |
7467 | + */ | |
7468 | + _destroyDatepicker: function( target ) { | |
7469 | + var nodeName, | |
7470 | + $target = $( target ), | |
7471 | + inst = $.data( target, "datepicker" ); | |
7472 | + | |
7473 | + if ( !$target.hasClass( this.markerClassName ) ) { | |
7474 | + return; | |
7475 | + } | |
7476 | + | |
7477 | + nodeName = target.nodeName.toLowerCase(); | |
7478 | + $.removeData( target, "datepicker" ); | |
7479 | + if ( nodeName === "input" ) { | |
7480 | + inst.append.remove(); | |
7481 | + inst.trigger.remove(); | |
7482 | + $target.removeClass( this.markerClassName ). | |
7483 | + off( "focus", this._showDatepicker ). | |
7484 | + off( "keydown", this._doKeyDown ). | |
7485 | + off( "keypress", this._doKeyPress ). | |
7486 | + off( "keyup", this._doKeyUp ); | |
7487 | + } else if ( nodeName === "div" || nodeName === "span" ) { | |
7488 | + $target.removeClass( this.markerClassName ).empty(); | |
7489 | + } | |
7490 | + | |
7491 | + if ( datepicker_instActive === inst ) { | |
7492 | + datepicker_instActive = null; | |
7493 | + } | |
7494 | + }, | |
7495 | + | |
7496 | + /* Enable the date picker to a jQuery selection. | |
7497 | + * @param target element - the target input field or division or span | |
7498 | + */ | |
7499 | + _enableDatepicker: function( target ) { | |
7500 | + var nodeName, inline, | |
7501 | + $target = $( target ), | |
7502 | + inst = $.data( target, "datepicker" ); | |
7503 | + | |
7504 | + if ( !$target.hasClass( this.markerClassName ) ) { | |
7505 | + return; | |
7506 | + } | |
7507 | + | |
7508 | + nodeName = target.nodeName.toLowerCase(); | |
7509 | + if ( nodeName === "input" ) { | |
7510 | + target.disabled = false; | |
7511 | + inst.trigger.filter( "button" ). | |
7512 | + each( function() { this.disabled = false; } ).end(). | |
7513 | + filter( "img" ).css( { opacity: "1.0", cursor: "" } ); | |
7514 | + } else if ( nodeName === "div" || nodeName === "span" ) { | |
7515 | + inline = $target.children( "." + this._inlineClass ); | |
7516 | + inline.children().removeClass( "ui-state-disabled" ); | |
7517 | + inline.find( "select.ui-datepicker-month, select.ui-datepicker-year" ). | |
7518 | + prop( "disabled", false ); | |
7519 | + } | |
7520 | + this._disabledInputs = $.map( this._disabledInputs, | |
7521 | + function( value ) { return ( value === target ? null : value ); } ); // delete entry | |
7522 | + }, | |
7523 | + | |
7524 | + /* Disable the date picker to a jQuery selection. | |
7525 | + * @param target element - the target input field or division or span | |
7526 | + */ | |
7527 | + _disableDatepicker: function( target ) { | |
7528 | + var nodeName, inline, | |
7529 | + $target = $( target ), | |
7530 | + inst = $.data( target, "datepicker" ); | |
7531 | + | |
7532 | + if ( !$target.hasClass( this.markerClassName ) ) { | |
7533 | + return; | |
7534 | + } | |
7535 | + | |
7536 | + nodeName = target.nodeName.toLowerCase(); | |
7537 | + if ( nodeName === "input" ) { | |
7538 | + target.disabled = true; | |
7539 | + inst.trigger.filter( "button" ). | |
7540 | + each( function() { this.disabled = true; } ).end(). | |
7541 | + filter( "img" ).css( { opacity: "0.5", cursor: "default" } ); | |
7542 | + } else if ( nodeName === "div" || nodeName === "span" ) { | |
7543 | + inline = $target.children( "." + this._inlineClass ); | |
7544 | + inline.children().addClass( "ui-state-disabled" ); | |
7545 | + inline.find( "select.ui-datepicker-month, select.ui-datepicker-year" ). | |
7546 | + prop( "disabled", true ); | |
7547 | + } | |
7548 | + this._disabledInputs = $.map( this._disabledInputs, | |
7549 | + function( value ) { return ( value === target ? null : value ); } ); // delete entry | |
7550 | + this._disabledInputs[ this._disabledInputs.length ] = target; | |
7551 | + }, | |
7552 | + | |
7553 | + /* Is the first field in a jQuery collection disabled as a datepicker? | |
7554 | + * @param target element - the target input field or division or span | |
7555 | + * @return boolean - true if disabled, false if enabled | |
7556 | + */ | |
7557 | + _isDisabledDatepicker: function( target ) { | |
7558 | + if ( !target ) { | |
7559 | + return false; | |
7560 | + } | |
7561 | + for ( var i = 0; i < this._disabledInputs.length; i++ ) { | |
7562 | + if ( this._disabledInputs[ i ] === target ) { | |
7563 | + return true; | |
7564 | + } | |
7565 | + } | |
7566 | + return false; | |
7567 | + }, | |
7568 | + | |
7569 | + /* Retrieve the instance data for the target control. | |
7570 | + * @param target element - the target input field or division or span | |
7571 | + * @return object - the associated instance data | |
7572 | + * @throws error if a jQuery problem getting data | |
7573 | + */ | |
7574 | + _getInst: function( target ) { | |
7575 | + try { | |
7576 | + return $.data( target, "datepicker" ); | |
7577 | + } | |
7578 | + catch ( err ) { | |
7579 | + throw "Missing instance data for this datepicker"; | |
7580 | + } | |
7581 | + }, | |
7582 | + | |
7583 | + /* Update or retrieve the settings for a date picker attached to an input field or division. | |
7584 | + * @param target element - the target input field or division or span | |
7585 | + * @param name object - the new settings to update or | |
7586 | + * string - the name of the setting to change or retrieve, | |
7587 | + * when retrieving also "all" for all instance settings or | |
7588 | + * "defaults" for all global defaults | |
7589 | + * @param value any - the new value for the setting | |
7590 | + * (omit if above is an object or to retrieve a value) | |
7591 | + */ | |
7592 | + _optionDatepicker: function( target, name, value ) { | |
7593 | + var settings, date, minDate, maxDate, | |
7594 | + inst = this._getInst( target ); | |
7595 | + | |
7596 | + if ( arguments.length === 2 && typeof name === "string" ) { | |
7597 | + return ( name === "defaults" ? $.extend( {}, $.datepicker._defaults ) : | |
7598 | + ( inst ? ( name === "all" ? $.extend( {}, inst.settings ) : | |
7599 | + this._get( inst, name ) ) : null ) ); | |
7600 | + } | |
7601 | + | |
7602 | + settings = name || {}; | |
7603 | + if ( typeof name === "string" ) { | |
7604 | + settings = {}; | |
7605 | + settings[ name ] = value; | |
7606 | + } | |
7607 | + | |
7608 | + if ( inst ) { | |
7609 | + if ( this._curInst === inst ) { | |
7610 | + this._hideDatepicker(); | |
7611 | + } | |
7612 | + | |
7613 | + date = this._getDateDatepicker( target, true ); | |
7614 | + minDate = this._getMinMaxDate( inst, "min" ); | |
7615 | + maxDate = this._getMinMaxDate( inst, "max" ); | |
7616 | + datepicker_extendRemove( inst.settings, settings ); | |
7617 | + | |
7618 | + // reformat the old minDate/maxDate values if dateFormat changes and a new minDate/maxDate isn't provided | |
7619 | + if ( minDate !== null && settings.dateFormat !== undefined && settings.minDate === undefined ) { | |
7620 | + inst.settings.minDate = this._formatDate( inst, minDate ); | |
7621 | + } | |
7622 | + if ( maxDate !== null && settings.dateFormat !== undefined && settings.maxDate === undefined ) { | |
7623 | + inst.settings.maxDate = this._formatDate( inst, maxDate ); | |
7624 | + } | |
7625 | + if ( "disabled" in settings ) { | |
7626 | + if ( settings.disabled ) { | |
7627 | + this._disableDatepicker( target ); | |
7628 | + } else { | |
7629 | + this._enableDatepicker( target ); | |
7630 | + } | |
7631 | + } | |
7632 | + this._attachments( $( target ), inst ); | |
7633 | + this._autoSize( inst ); | |
7634 | + this._setDate( inst, date ); | |
7635 | + this._updateAlternate( inst ); | |
7636 | + this._updateDatepicker( inst ); | |
7637 | + } | |
7638 | + }, | |
7639 | + | |
7640 | + // Change method deprecated | |
7641 | + _changeDatepicker: function( target, name, value ) { | |
7642 | + this._optionDatepicker( target, name, value ); | |
7643 | + }, | |
7644 | + | |
7645 | + /* Redraw the date picker attached to an input field or division. | |
7646 | + * @param target element - the target input field or division or span | |
7647 | + */ | |
7648 | + _refreshDatepicker: function( target ) { | |
7649 | + var inst = this._getInst( target ); | |
7650 | + if ( inst ) { | |
7651 | + this._updateDatepicker( inst ); | |
7652 | + } | |
7653 | + }, | |
7654 | + | |
7655 | + /* Set the dates for a jQuery selection. | |
7656 | + * @param target element - the target input field or division or span | |
7657 | + * @param date Date - the new date | |
7658 | + */ | |
7659 | + _setDateDatepicker: function( target, date ) { | |
7660 | + var inst = this._getInst( target ); | |
7661 | + if ( inst ) { | |
7662 | + this._setDate( inst, date ); | |
7663 | + this._updateDatepicker( inst ); | |
7664 | + this._updateAlternate( inst ); | |
7665 | + } | |
7666 | + }, | |
7667 | + | |
7668 | + /* Get the date(s) for the first entry in a jQuery selection. | |
7669 | + * @param target element - the target input field or division or span | |
7670 | + * @param noDefault boolean - true if no default date is to be used | |
7671 | + * @return Date - the current date | |
7672 | + */ | |
7673 | + _getDateDatepicker: function( target, noDefault ) { | |
7674 | + var inst = this._getInst( target ); | |
7675 | + if ( inst && !inst.inline ) { | |
7676 | + this._setDateFromField( inst, noDefault ); | |
7677 | + } | |
7678 | + return ( inst ? this._getDate( inst ) : null ); | |
7679 | + }, | |
7680 | + | |
7681 | + /* Handle keystrokes. */ | |
7682 | + _doKeyDown: function( event ) { | |
7683 | + var onSelect, dateStr, sel, | |
7684 | + inst = $.datepicker._getInst( event.target ), | |
7685 | + handled = true, | |
7686 | + isRTL = inst.dpDiv.is( ".ui-datepicker-rtl" ); | |
7687 | + | |
7688 | + inst._keyEvent = true; | |
7689 | + if ( $.datepicker._datepickerShowing ) { | |
7690 | + switch ( event.keyCode ) { | |
7691 | + case 9: $.datepicker._hideDatepicker(); | |
7692 | + handled = false; | |
7693 | + break; // hide on tab out | |
7694 | + case 13: sel = $( "td." + $.datepicker._dayOverClass + ":not(." + | |
7695 | + $.datepicker._currentClass + ")", inst.dpDiv ); | |
7696 | + if ( sel[ 0 ] ) { | |
7697 | + $.datepicker._selectDay( event.target, inst.selectedMonth, inst.selectedYear, sel[ 0 ] ); | |
7698 | + } | |
7699 | + | |
7700 | + onSelect = $.datepicker._get( inst, "onSelect" ); | |
7701 | + if ( onSelect ) { | |
7702 | + dateStr = $.datepicker._formatDate( inst ); | |
7703 | + | |
7704 | + // Trigger custom callback | |
7705 | + onSelect.apply( ( inst.input ? inst.input[ 0 ] : null ), [ dateStr, inst ] ); | |
7706 | + } else { | |
7707 | + $.datepicker._hideDatepicker(); | |
7708 | + } | |
7709 | + | |
7710 | + return false; // don't submit the form | |
7711 | + case 27: $.datepicker._hideDatepicker(); | |
7712 | + break; // hide on escape | |
7713 | + case 33: $.datepicker._adjustDate( event.target, ( event.ctrlKey ? | |
7714 | + -$.datepicker._get( inst, "stepBigMonths" ) : | |
7715 | + -$.datepicker._get( inst, "stepMonths" ) ), "M" ); | |
7716 | + break; // previous month/year on page up/+ ctrl | |
7717 | + case 34: $.datepicker._adjustDate( event.target, ( event.ctrlKey ? | |
7718 | + +$.datepicker._get( inst, "stepBigMonths" ) : | |
7719 | + +$.datepicker._get( inst, "stepMonths" ) ), "M" ); | |
7720 | + break; // next month/year on page down/+ ctrl | |
7721 | + case 35: if ( event.ctrlKey || event.metaKey ) { | |
7722 | + $.datepicker._clearDate( event.target ); | |
7723 | + } | |
7724 | + handled = event.ctrlKey || event.metaKey; | |
7725 | + break; // clear on ctrl or command +end | |
7726 | + case 36: if ( event.ctrlKey || event.metaKey ) { | |
7727 | + $.datepicker._gotoToday( event.target ); | |
7728 | + } | |
7729 | + handled = event.ctrlKey || event.metaKey; | |
7730 | + break; // current on ctrl or command +home | |
7731 | + case 37: if ( event.ctrlKey || event.metaKey ) { | |
7732 | + $.datepicker._adjustDate( event.target, ( isRTL ? +1 : -1 ), "D" ); | |
7733 | + } | |
7734 | + handled = event.ctrlKey || event.metaKey; | |
7735 | + | |
7736 | + // -1 day on ctrl or command +left | |
7737 | + if ( event.originalEvent.altKey ) { | |
7738 | + $.datepicker._adjustDate( event.target, ( event.ctrlKey ? | |
7739 | + -$.datepicker._get( inst, "stepBigMonths" ) : | |
7740 | + -$.datepicker._get( inst, "stepMonths" ) ), "M" ); | |
7741 | + } | |
7742 | + | |
7743 | + // next month/year on alt +left on Mac | |
7744 | + break; | |
7745 | + case 38: if ( event.ctrlKey || event.metaKey ) { | |
7746 | + $.datepicker._adjustDate( event.target, -7, "D" ); | |
7747 | + } | |
7748 | + handled = event.ctrlKey || event.metaKey; | |
7749 | + break; // -1 week on ctrl or command +up | |
7750 | + case 39: if ( event.ctrlKey || event.metaKey ) { | |
7751 | + $.datepicker._adjustDate( event.target, ( isRTL ? -1 : +1 ), "D" ); | |
7752 | + } | |
7753 | + handled = event.ctrlKey || event.metaKey; | |
7754 | + | |
7755 | + // +1 day on ctrl or command +right | |
7756 | + if ( event.originalEvent.altKey ) { | |
7757 | + $.datepicker._adjustDate( event.target, ( event.ctrlKey ? | |
7758 | + +$.datepicker._get( inst, "stepBigMonths" ) : | |
7759 | + +$.datepicker._get( inst, "stepMonths" ) ), "M" ); | |
7760 | + } | |
7761 | + | |
7762 | + // next month/year on alt +right | |
7763 | + break; | |
7764 | + case 40: if ( event.ctrlKey || event.metaKey ) { | |
7765 | + $.datepicker._adjustDate( event.target, +7, "D" ); | |
7766 | + } | |
7767 | + handled = event.ctrlKey || event.metaKey; | |
7768 | + break; // +1 week on ctrl or command +down | |
7769 | + default: handled = false; | |
7770 | + } | |
7771 | + } else if ( event.keyCode === 36 && event.ctrlKey ) { // display the date picker on ctrl+home | |
7772 | + $.datepicker._showDatepicker( this ); | |
7773 | + } else { | |
7774 | + handled = false; | |
7775 | + } | |
7776 | + | |
7777 | + if ( handled ) { | |
7778 | + event.preventDefault(); | |
7779 | + event.stopPropagation(); | |
7780 | + } | |
7781 | + }, | |
7782 | + | |
7783 | + /* Filter entered characters - based on date format. */ | |
7784 | + _doKeyPress: function( event ) { | |
7785 | + var chars, chr, | |
7786 | + inst = $.datepicker._getInst( event.target ); | |
7787 | + | |
7788 | + if ( $.datepicker._get( inst, "constrainInput" ) ) { | |
7789 | + chars = $.datepicker._possibleChars( $.datepicker._get( inst, "dateFormat" ) ); | |
7790 | + chr = String.fromCharCode( event.charCode == null ? event.keyCode : event.charCode ); | |
7791 | + return event.ctrlKey || event.metaKey || ( chr < " " || !chars || chars.indexOf( chr ) > -1 ); | |
7792 | + } | |
7793 | + }, | |
7794 | + | |
7795 | + /* Synchronise manual entry and field/alternate field. */ | |
7796 | + _doKeyUp: function( event ) { | |
7797 | + var date, | |
7798 | + inst = $.datepicker._getInst( event.target ); | |
7799 | + | |
7800 | + if ( inst.input.val() !== inst.lastVal ) { | |
7801 | + try { | |
7802 | + date = $.datepicker.parseDate( $.datepicker._get( inst, "dateFormat" ), | |
7803 | + ( inst.input ? inst.input.val() : null ), | |
7804 | + $.datepicker._getFormatConfig( inst ) ); | |
7805 | + | |
7806 | + if ( date ) { // only if valid | |
7807 | + $.datepicker._setDateFromField( inst ); | |
7808 | + $.datepicker._updateAlternate( inst ); | |
7809 | + $.datepicker._updateDatepicker( inst ); | |
7810 | + } | |
7811 | + } | |
7812 | + catch ( err ) { | |
7813 | + } | |
7814 | + } | |
7815 | + return true; | |
7816 | + }, | |
7817 | + | |
7818 | + /* Pop-up the date picker for a given input field. | |
7819 | + * If false returned from beforeShow event handler do not show. | |
7820 | + * @param input element - the input field attached to the date picker or | |
7821 | + * event - if triggered by focus | |
7822 | + */ | |
7823 | + _showDatepicker: function( input ) { | |
7824 | + input = input.target || input; | |
7825 | + if ( input.nodeName.toLowerCase() !== "input" ) { // find from button/image trigger | |
7826 | + input = $( "input", input.parentNode )[ 0 ]; | |
7827 | + } | |
7828 | + | |
7829 | + if ( $.datepicker._isDisabledDatepicker( input ) || $.datepicker._lastInput === input ) { // already here | |
7830 | + return; | |
7831 | + } | |
7832 | + | |
7833 | + var inst, beforeShow, beforeShowSettings, isFixed, | |
7834 | + offset, showAnim, duration; | |
7835 | + | |
7836 | + inst = $.datepicker._getInst( input ); | |
7837 | + if ( $.datepicker._curInst && $.datepicker._curInst !== inst ) { | |
7838 | + $.datepicker._curInst.dpDiv.stop( true, true ); | |
7839 | + if ( inst && $.datepicker._datepickerShowing ) { | |
7840 | + $.datepicker._hideDatepicker( $.datepicker._curInst.input[ 0 ] ); | |
7841 | + } | |
7842 | + } | |
7843 | + | |
7844 | + beforeShow = $.datepicker._get( inst, "beforeShow" ); | |
7845 | + beforeShowSettings = beforeShow ? beforeShow.apply( input, [ input, inst ] ) : {}; | |
7846 | + if ( beforeShowSettings === false ) { | |
7847 | + return; | |
7848 | + } | |
7849 | + datepicker_extendRemove( inst.settings, beforeShowSettings ); | |
7850 | + | |
7851 | + inst.lastVal = null; | |
7852 | + $.datepicker._lastInput = input; | |
7853 | + $.datepicker._setDateFromField( inst ); | |
7854 | + | |
7855 | + if ( $.datepicker._inDialog ) { // hide cursor | |
7856 | + input.value = ""; | |
7857 | + } | |
7858 | + if ( !$.datepicker._pos ) { // position below input | |
7859 | + $.datepicker._pos = $.datepicker._findPos( input ); | |
7860 | + $.datepicker._pos[ 1 ] += input.offsetHeight; // add the height | |
7861 | + } | |
7862 | + | |
7863 | + isFixed = false; | |
7864 | + $( input ).parents().each( function() { | |
7865 | + isFixed |= $( this ).css( "position" ) === "fixed"; | |
7866 | + return !isFixed; | |
7867 | + } ); | |
7868 | + | |
7869 | + offset = { left: $.datepicker._pos[ 0 ], top: $.datepicker._pos[ 1 ] }; | |
7870 | + $.datepicker._pos = null; | |
7871 | + | |
7872 | + //to avoid flashes on Firefox | |
7873 | + inst.dpDiv.empty(); | |
7874 | + | |
7875 | + // determine sizing offscreen | |
7876 | + inst.dpDiv.css( { position: "absolute", display: "block", top: "-1000px" } ); | |
7877 | + $.datepicker._updateDatepicker( inst ); | |
7878 | + | |
7879 | + // fix width for dynamic number of date pickers | |
7880 | + // and adjust position before showing | |
7881 | + offset = $.datepicker._checkOffset( inst, offset, isFixed ); | |
7882 | + inst.dpDiv.css( { position: ( $.datepicker._inDialog && $.blockUI ? | |
7883 | + "static" : ( isFixed ? "fixed" : "absolute" ) ), display: "none", | |
7884 | + left: offset.left + "px", top: offset.top + "px" } ); | |
7885 | + | |
7886 | + if ( !inst.inline ) { | |
7887 | + showAnim = $.datepicker._get( inst, "showAnim" ); | |
7888 | + duration = $.datepicker._get( inst, "duration" ); | |
7889 | + inst.dpDiv.css( "z-index", datepicker_getZindex( $( input ) ) + 1 ); | |
7890 | + $.datepicker._datepickerShowing = true; | |
7891 | + | |
7892 | + if ( $.effects && $.effects.effect[ showAnim ] ) { | |
7893 | + inst.dpDiv.show( showAnim, $.datepicker._get( inst, "showOptions" ), duration ); | |
7894 | + } else { | |
7895 | + inst.dpDiv[ showAnim || "show" ]( showAnim ? duration : null ); | |
7896 | + } | |
7897 | + | |
7898 | + if ( $.datepicker._shouldFocusInput( inst ) ) { | |
7899 | + inst.input.trigger( "focus" ); | |
7900 | + } | |
7901 | + | |
7902 | + $.datepicker._curInst = inst; | |
7903 | + } | |
7904 | + }, | |
7905 | + | |
7906 | + /* Generate the date picker content. */ | |
7907 | + _updateDatepicker: function( inst ) { | |
7908 | + this.maxRows = 4; //Reset the max number of rows being displayed (see #7043) | |
7909 | + datepicker_instActive = inst; // for delegate hover events | |
7910 | + inst.dpDiv.empty().append( this._generateHTML( inst ) ); | |
7911 | + this._attachHandlers( inst ); | |
7912 | + | |
7913 | + var origyearshtml, | |
7914 | + numMonths = this._getNumberOfMonths( inst ), | |
7915 | + cols = numMonths[ 1 ], | |
7916 | + width = 17, | |
7917 | + activeCell = inst.dpDiv.find( "." + this._dayOverClass + " a" ); | |
7918 | + | |
7919 | + if ( activeCell.length > 0 ) { | |
7920 | + datepicker_handleMouseover.apply( activeCell.get( 0 ) ); | |
7921 | + } | |
7922 | + | |
7923 | + inst.dpDiv.removeClass( "ui-datepicker-multi-2 ui-datepicker-multi-3 ui-datepicker-multi-4" ).width( "" ); | |
7924 | + if ( cols > 1 ) { | |
7925 | + inst.dpDiv.addClass( "ui-datepicker-multi-" + cols ).css( "width", ( width * cols ) + "em" ); | |
7926 | + } | |
7927 | + inst.dpDiv[ ( numMonths[ 0 ] !== 1 || numMonths[ 1 ] !== 1 ? "add" : "remove" ) + | |
7928 | + "Class" ]( "ui-datepicker-multi" ); | |
7929 | + inst.dpDiv[ ( this._get( inst, "isRTL" ) ? "add" : "remove" ) + | |
7930 | + "Class" ]( "ui-datepicker-rtl" ); | |
7931 | + | |
7932 | + if ( inst === $.datepicker._curInst && $.datepicker._datepickerShowing && $.datepicker._shouldFocusInput( inst ) ) { | |
7933 | + inst.input.trigger( "focus" ); | |
7934 | + } | |
7935 | + | |
7936 | + // Deffered render of the years select (to avoid flashes on Firefox) | |
7937 | + if ( inst.yearshtml ) { | |
7938 | + origyearshtml = inst.yearshtml; | |
7939 | + setTimeout( function() { | |
7940 | + | |
7941 | + //assure that inst.yearshtml didn't change. | |
7942 | + if ( origyearshtml === inst.yearshtml && inst.yearshtml ) { | |
7943 | + inst.dpDiv.find( "select.ui-datepicker-year:first" ).replaceWith( inst.yearshtml ); | |
7944 | + } | |
7945 | + origyearshtml = inst.yearshtml = null; | |
7946 | + }, 0 ); | |
7947 | + } | |
7948 | + }, | |
7949 | + | |
7950 | + // #6694 - don't focus the input if it's already focused | |
7951 | + // this breaks the change event in IE | |
7952 | + // Support: IE and jQuery <1.9 | |
7953 | + _shouldFocusInput: function( inst ) { | |
7954 | + return inst.input && inst.input.is( ":visible" ) && !inst.input.is( ":disabled" ) && !inst.input.is( ":focus" ); | |
7955 | + }, | |
7956 | + | |
7957 | + /* Check positioning to remain on screen. */ | |
7958 | + _checkOffset: function( inst, offset, isFixed ) { | |
7959 | + var dpWidth = inst.dpDiv.outerWidth(), | |
7960 | + dpHeight = inst.dpDiv.outerHeight(), | |
7961 | + inputWidth = inst.input ? inst.input.outerWidth() : 0, | |
7962 | + inputHeight = inst.input ? inst.input.outerHeight() : 0, | |
7963 | + viewWidth = document.documentElement.clientWidth + ( isFixed ? 0 : $( document ).scrollLeft() ), | |
7964 | + viewHeight = document.documentElement.clientHeight + ( isFixed ? 0 : $( document ).scrollTop() ); | |
7965 | + | |
7966 | + offset.left -= ( this._get( inst, "isRTL" ) ? ( dpWidth - inputWidth ) : 0 ); | |
7967 | + offset.left -= ( isFixed && offset.left === inst.input.offset().left ) ? $( document ).scrollLeft() : 0; | |
7968 | + offset.top -= ( isFixed && offset.top === ( inst.input.offset().top + inputHeight ) ) ? $( document ).scrollTop() : 0; | |
7969 | + | |
7970 | + // Now check if datepicker is showing outside window viewport - move to a better place if so. | |
7971 | + offset.left -= Math.min( offset.left, ( offset.left + dpWidth > viewWidth && viewWidth > dpWidth ) ? | |
7972 | + Math.abs( offset.left + dpWidth - viewWidth ) : 0 ); | |
7973 | + offset.top -= Math.min( offset.top, ( offset.top + dpHeight > viewHeight && viewHeight > dpHeight ) ? | |
7974 | + Math.abs( dpHeight + inputHeight ) : 0 ); | |
7975 | + | |
7976 | + return offset; | |
7977 | + }, | |
7978 | + | |
7979 | + /* Find an object's position on the screen. */ | |
7980 | + _findPos: function( obj ) { | |
7981 | + var position, | |
7982 | + inst = this._getInst( obj ), | |
7983 | + isRTL = this._get( inst, "isRTL" ); | |
7984 | + | |
7985 | + while ( obj && ( obj.type === "hidden" || obj.nodeType !== 1 || $.expr.filters.hidden( obj ) ) ) { | |
7986 | + obj = obj[ isRTL ? "previousSibling" : "nextSibling" ]; | |
7987 | + } | |
7988 | + | |
7989 | + position = $( obj ).offset(); | |
7990 | + return [ position.left, position.top ]; | |
7991 | + }, | |
7992 | + | |
7993 | + /* Hide the date picker from view. | |
7994 | + * @param input element - the input field attached to the date picker | |
7995 | + */ | |
7996 | + _hideDatepicker: function( input ) { | |
7997 | + var showAnim, duration, postProcess, onClose, | |
7998 | + inst = this._curInst; | |
7999 | + | |
8000 | + if ( !inst || ( input && inst !== $.data( input, "datepicker" ) ) ) { | |
8001 | + return; | |
8002 | + } | |
8003 | + | |
8004 | + if ( this._datepickerShowing ) { | |
8005 | + showAnim = this._get( inst, "showAnim" ); | |
8006 | + duration = this._get( inst, "duration" ); | |
8007 | + postProcess = function() { | |
8008 | + $.datepicker._tidyDialog( inst ); | |
8009 | + }; | |
8010 | + | |
8011 | + // DEPRECATED: after BC for 1.8.x $.effects[ showAnim ] is not needed | |
8012 | + if ( $.effects && ( $.effects.effect[ showAnim ] || $.effects[ showAnim ] ) ) { | |
8013 | + inst.dpDiv.hide( showAnim, $.datepicker._get( inst, "showOptions" ), duration, postProcess ); | |
8014 | + } else { | |
8015 | + inst.dpDiv[ ( showAnim === "slideDown" ? "slideUp" : | |
8016 | + ( showAnim === "fadeIn" ? "fadeOut" : "hide" ) ) ]( ( showAnim ? duration : null ), postProcess ); | |
8017 | + } | |
8018 | + | |
8019 | + if ( !showAnim ) { | |
8020 | + postProcess(); | |
8021 | + } | |
8022 | + this._datepickerShowing = false; | |
8023 | + | |
8024 | + onClose = this._get( inst, "onClose" ); | |
8025 | + if ( onClose ) { | |
8026 | + onClose.apply( ( inst.input ? inst.input[ 0 ] : null ), [ ( inst.input ? inst.input.val() : "" ), inst ] ); | |
8027 | + } | |
8028 | + | |
8029 | + this._lastInput = null; | |
8030 | + if ( this._inDialog ) { | |
8031 | + this._dialogInput.css( { position: "absolute", left: "0", top: "-100px" } ); | |
8032 | + if ( $.blockUI ) { | |
8033 | + $.unblockUI(); | |
8034 | + $( "body" ).append( this.dpDiv ); | |
8035 | + } | |
8036 | + } | |
8037 | + this._inDialog = false; | |
8038 | + } | |
8039 | + }, | |
8040 | + | |
8041 | + /* Tidy up after a dialog display. */ | |
8042 | + _tidyDialog: function( inst ) { | |
8043 | + inst.dpDiv.removeClass( this._dialogClass ).off( ".ui-datepicker-calendar" ); | |
8044 | + }, | |
8045 | + | |
8046 | + /* Close date picker if clicked elsewhere. */ | |
8047 | + _checkExternalClick: function( event ) { | |
8048 | + if ( !$.datepicker._curInst ) { | |
8049 | + return; | |
8050 | + } | |
8051 | + | |
8052 | + var $target = $( event.target ), | |
8053 | + inst = $.datepicker._getInst( $target[ 0 ] ); | |
8054 | + | |
8055 | + if ( ( ( $target[ 0 ].id !== $.datepicker._mainDivId && | |
8056 | + $target.parents( "#" + $.datepicker._mainDivId ).length === 0 && | |
8057 | + !$target.hasClass( $.datepicker.markerClassName ) && | |
8058 | + !$target.closest( "." + $.datepicker._triggerClass ).length && | |
8059 | + $.datepicker._datepickerShowing && !( $.datepicker._inDialog && $.blockUI ) ) ) || | |
8060 | + ( $target.hasClass( $.datepicker.markerClassName ) && $.datepicker._curInst !== inst ) ) { | |
8061 | + $.datepicker._hideDatepicker(); | |
8062 | + } | |
8063 | + }, | |
8064 | + | |
8065 | + /* Adjust one of the date sub-fields. */ | |
8066 | + _adjustDate: function( id, offset, period ) { | |
8067 | + var target = $( id ), | |
8068 | + inst = this._getInst( target[ 0 ] ); | |
8069 | + | |
8070 | + if ( this._isDisabledDatepicker( target[ 0 ] ) ) { | |
8071 | + return; | |
8072 | + } | |
8073 | + this._adjustInstDate( inst, offset + | |
8074 | + ( period === "M" ? this._get( inst, "showCurrentAtPos" ) : 0 ), // undo positioning | |
8075 | + period ); | |
8076 | + this._updateDatepicker( inst ); | |
8077 | + }, | |
8078 | + | |
8079 | + /* Action for current link. */ | |
8080 | + _gotoToday: function( id ) { | |
8081 | + var date, | |
8082 | + target = $( id ), | |
8083 | + inst = this._getInst( target[ 0 ] ); | |
8084 | + | |
8085 | + if ( this._get( inst, "gotoCurrent" ) && inst.currentDay ) { | |
8086 | + inst.selectedDay = inst.currentDay; | |
8087 | + inst.drawMonth = inst.selectedMonth = inst.currentMonth; | |
8088 | + inst.drawYear = inst.selectedYear = inst.currentYear; | |
8089 | + } else { | |
8090 | + date = new Date(); | |
8091 | + inst.selectedDay = date.getDate(); | |
8092 | + inst.drawMonth = inst.selectedMonth = date.getMonth(); | |
8093 | + inst.drawYear = inst.selectedYear = date.getFullYear(); | |
8094 | + } | |
8095 | + this._notifyChange( inst ); | |
8096 | + this._adjustDate( target ); | |
8097 | + }, | |
8098 | + | |
8099 | + /* Action for selecting a new month/year. */ | |
8100 | + _selectMonthYear: function( id, select, period ) { | |
8101 | + var target = $( id ), | |
8102 | + inst = this._getInst( target[ 0 ] ); | |
8103 | + | |
8104 | + inst[ "selected" + ( period === "M" ? "Month" : "Year" ) ] = | |
8105 | + inst[ "draw" + ( period === "M" ? "Month" : "Year" ) ] = | |
8106 | + parseInt( select.options[ select.selectedIndex ].value, 10 ); | |
8107 | + | |
8108 | + this._notifyChange( inst ); | |
8109 | + this._adjustDate( target ); | |
8110 | + }, | |
8111 | + | |
8112 | + /* Action for selecting a day. */ | |
8113 | + _selectDay: function( id, month, year, td ) { | |
8114 | + var inst, | |
8115 | + target = $( id ); | |
8116 | + | |
8117 | + if ( $( td ).hasClass( this._unselectableClass ) || this._isDisabledDatepicker( target[ 0 ] ) ) { | |
8118 | + return; | |
8119 | + } | |
8120 | + | |
8121 | + inst = this._getInst( target[ 0 ] ); | |
8122 | + inst.selectedDay = inst.currentDay = $( "a", td ).html(); | |
8123 | + inst.selectedMonth = inst.currentMonth = month; | |
8124 | + inst.selectedYear = inst.currentYear = year; | |
8125 | + this._selectDate( id, this._formatDate( inst, | |
8126 | + inst.currentDay, inst.currentMonth, inst.currentYear ) ); | |
8127 | + }, | |
8128 | + | |
8129 | + /* Erase the input field and hide the date picker. */ | |
8130 | + _clearDate: function( id ) { | |
8131 | + var target = $( id ); | |
8132 | + this._selectDate( target, "" ); | |
8133 | + }, | |
8134 | + | |
8135 | + /* Update the input field with the selected date. */ | |
8136 | + _selectDate: function( id, dateStr ) { | |
8137 | + var onSelect, | |
8138 | + target = $( id ), | |
8139 | + inst = this._getInst( target[ 0 ] ); | |
8140 | + | |
8141 | + dateStr = ( dateStr != null ? dateStr : this._formatDate( inst ) ); | |
8142 | + if ( inst.input ) { | |
8143 | + inst.input.val( dateStr ); | |
8144 | + } | |
8145 | + this._updateAlternate( inst ); | |
8146 | + | |
8147 | + onSelect = this._get( inst, "onSelect" ); | |
8148 | + if ( onSelect ) { | |
8149 | + onSelect.apply( ( inst.input ? inst.input[ 0 ] : null ), [ dateStr, inst ] ); // trigger custom callback | |
8150 | + } else if ( inst.input ) { | |
8151 | + inst.input.trigger( "change" ); // fire the change event | |
8152 | + } | |
8153 | + | |
8154 | + if ( inst.inline ) { | |
8155 | + this._updateDatepicker( inst ); | |
8156 | + } else { | |
8157 | + this._hideDatepicker(); | |
8158 | + this._lastInput = inst.input[ 0 ]; | |
8159 | + if ( typeof( inst.input[ 0 ] ) !== "object" ) { | |
8160 | + inst.input.trigger( "focus" ); // restore focus | |
8161 | + } | |
8162 | + this._lastInput = null; | |
8163 | + } | |
8164 | + }, | |
8165 | + | |
8166 | + /* Update any alternate field to synchronise with the main field. */ | |
8167 | + _updateAlternate: function( inst ) { | |
8168 | + var altFormat, date, dateStr, | |
8169 | + altField = this._get( inst, "altField" ); | |
8170 | + | |
8171 | + if ( altField ) { // update alternate field too | |
8172 | + altFormat = this._get( inst, "altFormat" ) || this._get( inst, "dateFormat" ); | |
8173 | + date = this._getDate( inst ); | |
8174 | + dateStr = this.formatDate( altFormat, date, this._getFormatConfig( inst ) ); | |
8175 | + $( altField ).val( dateStr ); | |
8176 | + } | |
8177 | + }, | |
8178 | + | |
8179 | + /* Set as beforeShowDay function to prevent selection of weekends. | |
8180 | + * @param date Date - the date to customise | |
8181 | + * @return [boolean, string] - is this date selectable?, what is its CSS class? | |
8182 | + */ | |
8183 | + noWeekends: function( date ) { | |
8184 | + var day = date.getDay(); | |
8185 | + return [ ( day > 0 && day < 6 ), "" ]; | |
8186 | + }, | |
8187 | + | |
8188 | + /* Set as calculateWeek to determine the week of the year based on the ISO 8601 definition. | |
8189 | + * @param date Date - the date to get the week for | |
8190 | + * @return number - the number of the week within the year that contains this date | |
8191 | + */ | |
8192 | + iso8601Week: function( date ) { | |
8193 | + var time, | |
8194 | + checkDate = new Date( date.getTime() ); | |
8195 | + | |
8196 | + // Find Thursday of this week starting on Monday | |
8197 | + checkDate.setDate( checkDate.getDate() + 4 - ( checkDate.getDay() || 7 ) ); | |
8198 | + | |
8199 | + time = checkDate.getTime(); | |
8200 | + checkDate.setMonth( 0 ); // Compare with Jan 1 | |
8201 | + checkDate.setDate( 1 ); | |
8202 | + return Math.floor( Math.round( ( time - checkDate ) / 86400000 ) / 7 ) + 1; | |
8203 | + }, | |
8204 | + | |
8205 | + /* Parse a string value into a date object. | |
8206 | + * See formatDate below for the possible formats. | |
8207 | + * | |
8208 | + * @param format string - the expected format of the date | |
8209 | + * @param value string - the date in the above format | |
8210 | + * @param settings Object - attributes include: | |
8211 | + * shortYearCutoff number - the cutoff year for determining the century (optional) | |
8212 | + * dayNamesShort string[7] - abbreviated names of the days from Sunday (optional) | |
8213 | + * dayNames string[7] - names of the days from Sunday (optional) | |
8214 | + * monthNamesShort string[12] - abbreviated names of the months (optional) | |
8215 | + * monthNames string[12] - names of the months (optional) | |
8216 | + * @return Date - the extracted date value or null if value is blank | |
8217 | + */ | |
8218 | + parseDate: function( format, value, settings ) { | |
8219 | + if ( format == null || value == null ) { | |
8220 | + throw "Invalid arguments"; | |
8221 | + } | |
8222 | + | |
8223 | + value = ( typeof value === "object" ? value.toString() : value + "" ); | |
8224 | + if ( value === "" ) { | |
8225 | + return null; | |
8226 | + } | |
8227 | + | |
8228 | + var iFormat, dim, extra, | |
8229 | + iValue = 0, | |
8230 | + shortYearCutoffTemp = ( settings ? settings.shortYearCutoff : null ) || this._defaults.shortYearCutoff, | |
8231 | + shortYearCutoff = ( typeof shortYearCutoffTemp !== "string" ? shortYearCutoffTemp : | |
8232 | + new Date().getFullYear() % 100 + parseInt( shortYearCutoffTemp, 10 ) ), | |
8233 | + dayNamesShort = ( settings ? settings.dayNamesShort : null ) || this._defaults.dayNamesShort, | |
8234 | + dayNames = ( settings ? settings.dayNames : null ) || this._defaults.dayNames, | |
8235 | + monthNamesShort = ( settings ? settings.monthNamesShort : null ) || this._defaults.monthNamesShort, | |
8236 | + monthNames = ( settings ? settings.monthNames : null ) || this._defaults.monthNames, | |
8237 | + year = -1, | |
8238 | + month = -1, | |
8239 | + day = -1, | |
8240 | + doy = -1, | |
8241 | + literal = false, | |
8242 | + date, | |
8243 | + | |
8244 | + // Check whether a format character is doubled | |
8245 | + lookAhead = function( match ) { | |
8246 | + var matches = ( iFormat + 1 < format.length && format.charAt( iFormat + 1 ) === match ); | |
8247 | + if ( matches ) { | |
8248 | + iFormat++; | |
8249 | + } | |
8250 | + return matches; | |
8251 | + }, | |
8252 | + | |
8253 | + // Extract a number from the string value | |
8254 | + getNumber = function( match ) { | |
8255 | + var isDoubled = lookAhead( match ), | |
8256 | + size = ( match === "@" ? 14 : ( match === "!" ? 20 : | |
8257 | + ( match === "y" && isDoubled ? 4 : ( match === "o" ? 3 : 2 ) ) ) ), | |
8258 | + minSize = ( match === "y" ? size : 1 ), | |
8259 | + digits = new RegExp( "^\\d{" + minSize + "," + size + "}" ), | |
8260 | + num = value.substring( iValue ).match( digits ); | |
8261 | + if ( !num ) { | |
8262 | + throw "Missing number at position " + iValue; | |
8263 | + } | |
8264 | + iValue += num[ 0 ].length; | |
8265 | + return parseInt( num[ 0 ], 10 ); | |
8266 | + }, | |
8267 | + | |
8268 | + // Extract a name from the string value and convert to an index | |
8269 | + getName = function( match, shortNames, longNames ) { | |
8270 | + var index = -1, | |
8271 | + names = $.map( lookAhead( match ) ? longNames : shortNames, function( v, k ) { | |
8272 | + return [ [ k, v ] ]; | |
8273 | + } ).sort( function( a, b ) { | |
8274 | + return -( a[ 1 ].length - b[ 1 ].length ); | |
8275 | + } ); | |
8276 | + | |
8277 | + $.each( names, function( i, pair ) { | |
8278 | + var name = pair[ 1 ]; | |
8279 | + if ( value.substr( iValue, name.length ).toLowerCase() === name.toLowerCase() ) { | |
8280 | + index = pair[ 0 ]; | |
8281 | + iValue += name.length; | |
8282 | + return false; | |
8283 | + } | |
8284 | + } ); | |
8285 | + if ( index !== -1 ) { | |
8286 | + return index + 1; | |
8287 | + } else { | |
8288 | + throw "Unknown name at position " + iValue; | |
8289 | + } | |
8290 | + }, | |
8291 | + | |
8292 | + // Confirm that a literal character matches the string value | |
8293 | + checkLiteral = function() { | |
8294 | + if ( value.charAt( iValue ) !== format.charAt( iFormat ) ) { | |
8295 | + throw "Unexpected literal at position " + iValue; | |
8296 | + } | |
8297 | + iValue++; | |
8298 | + }; | |
8299 | + | |
8300 | + for ( iFormat = 0; iFormat < format.length; iFormat++ ) { | |
8301 | + if ( literal ) { | |
8302 | + if ( format.charAt( iFormat ) === "'" && !lookAhead( "'" ) ) { | |
8303 | + literal = false; | |
8304 | + } else { | |
8305 | + checkLiteral(); | |
8306 | + } | |
8307 | + } else { | |
8308 | + switch ( format.charAt( iFormat ) ) { | |
8309 | + case "d": | |
8310 | + day = getNumber( "d" ); | |
8311 | + break; | |
8312 | + case "D": | |
8313 | + getName( "D", dayNamesShort, dayNames ); | |
8314 | + break; | |
8315 | + case "o": | |
8316 | + doy = getNumber( "o" ); | |
8317 | + break; | |
8318 | + case "m": | |
8319 | + month = getNumber( "m" ); | |
8320 | + break; | |
8321 | + case "M": | |
8322 | + month = getName( "M", monthNamesShort, monthNames ); | |
8323 | + break; | |
8324 | + case "y": | |
8325 | + year = getNumber( "y" ); | |
8326 | + break; | |
8327 | + case "@": | |
8328 | + date = new Date( getNumber( "@" ) ); | |
8329 | + year = date.getFullYear(); | |
8330 | + month = date.getMonth() + 1; | |
8331 | + day = date.getDate(); | |
8332 | + break; | |
8333 | + case "!": | |
8334 | + date = new Date( ( getNumber( "!" ) - this._ticksTo1970 ) / 10000 ); | |
8335 | + year = date.getFullYear(); | |
8336 | + month = date.getMonth() + 1; | |
8337 | + day = date.getDate(); | |
8338 | + break; | |
8339 | + case "'": | |
8340 | + if ( lookAhead( "'" ) ) { | |
8341 | + checkLiteral(); | |
8342 | + } else { | |
8343 | + literal = true; | |
8344 | + } | |
8345 | + break; | |
8346 | + default: | |
8347 | + checkLiteral(); | |
8348 | + } | |
8349 | + } | |
8350 | + } | |
8351 | + | |
8352 | + if ( iValue < value.length ) { | |
8353 | + extra = value.substr( iValue ); | |
8354 | + if ( !/^\s+/.test( extra ) ) { | |
8355 | + throw "Extra/unparsed characters found in date: " + extra; | |
8356 | + } | |
8357 | + } | |
8358 | + | |
8359 | + if ( year === -1 ) { | |
8360 | + year = new Date().getFullYear(); | |
8361 | + } else if ( year < 100 ) { | |
8362 | + year += new Date().getFullYear() - new Date().getFullYear() % 100 + | |
8363 | + ( year <= shortYearCutoff ? 0 : -100 ); | |
8364 | + } | |
8365 | + | |
8366 | + if ( doy > -1 ) { | |
8367 | + month = 1; | |
8368 | + day = doy; | |
8369 | + do { | |
8370 | + dim = this._getDaysInMonth( year, month - 1 ); | |
8371 | + if ( day <= dim ) { | |
8372 | + break; | |
8373 | + } | |
8374 | + month++; | |
8375 | + day -= dim; | |
8376 | + } while ( true ); | |
8377 | + } | |
8378 | + | |
8379 | + date = this._daylightSavingAdjust( new Date( year, month - 1, day ) ); | |
8380 | + if ( date.getFullYear() !== year || date.getMonth() + 1 !== month || date.getDate() !== day ) { | |
8381 | + throw "Invalid date"; // E.g. 31/02/00 | |
8382 | + } | |
8383 | + return date; | |
8384 | + }, | |
8385 | + | |
8386 | + /* Standard date formats. */ | |
8387 | + ATOM: "yy-mm-dd", // RFC 3339 (ISO 8601) | |
8388 | + COOKIE: "D, dd M yy", | |
8389 | + ISO_8601: "yy-mm-dd", | |
8390 | + RFC_822: "D, d M y", | |
8391 | + RFC_850: "DD, dd-M-y", | |
8392 | + RFC_1036: "D, d M y", | |
8393 | + RFC_1123: "D, d M yy", | |
8394 | + RFC_2822: "D, d M yy", | |
8395 | + RSS: "D, d M y", // RFC 822 | |
8396 | + TICKS: "!", | |
8397 | + TIMESTAMP: "@", | |
8398 | + W3C: "yy-mm-dd", // ISO 8601 | |
8399 | + | |
8400 | + _ticksTo1970: ( ( ( 1970 - 1 ) * 365 + Math.floor( 1970 / 4 ) - Math.floor( 1970 / 100 ) + | |
8401 | + Math.floor( 1970 / 400 ) ) * 24 * 60 * 60 * 10000000 ), | |
8402 | + | |
8403 | + /* Format a date object into a string value. | |
8404 | + * The format can be combinations of the following: | |
8405 | + * d - day of month (no leading zero) | |
8406 | + * dd - day of month (two digit) | |
8407 | + * o - day of year (no leading zeros) | |
8408 | + * oo - day of year (three digit) | |
8409 | + * D - day name short | |
8410 | + * DD - day name long | |
8411 | + * m - month of year (no leading zero) | |
8412 | + * mm - month of year (two digit) | |
8413 | + * M - month name short | |
8414 | + * MM - month name long | |
8415 | + * y - year (two digit) | |
8416 | + * yy - year (four digit) | |
8417 | + * @ - Unix timestamp (ms since 01/01/1970) | |
8418 | + * ! - Windows ticks (100ns since 01/01/0001) | |
8419 | + * "..." - literal text | |
8420 | + * '' - single quote | |
8421 | + * | |
8422 | + * @param format string - the desired format of the date | |
8423 | + * @param date Date - the date value to format | |
8424 | + * @param settings Object - attributes include: | |
8425 | + * dayNamesShort string[7] - abbreviated names of the days from Sunday (optional) | |
8426 | + * dayNames string[7] - names of the days from Sunday (optional) | |
8427 | + * monthNamesShort string[12] - abbreviated names of the months (optional) | |
8428 | + * monthNames string[12] - names of the months (optional) | |
8429 | + * @return string - the date in the above format | |
8430 | + */ | |
8431 | + formatDate: function( format, date, settings ) { | |
8432 | + if ( !date ) { | |
8433 | + return ""; | |
8434 | + } | |
8435 | + | |
8436 | + var iFormat, | |
8437 | + dayNamesShort = ( settings ? settings.dayNamesShort : null ) || this._defaults.dayNamesShort, | |
8438 | + dayNames = ( settings ? settings.dayNames : null ) || this._defaults.dayNames, | |
8439 | + monthNamesShort = ( settings ? settings.monthNamesShort : null ) || this._defaults.monthNamesShort, | |
8440 | + monthNames = ( settings ? settings.monthNames : null ) || this._defaults.monthNames, | |
8441 | + | |
8442 | + // Check whether a format character is doubled | |
8443 | + lookAhead = function( match ) { | |
8444 | + var matches = ( iFormat + 1 < format.length && format.charAt( iFormat + 1 ) === match ); | |
8445 | + if ( matches ) { | |
8446 | + iFormat++; | |
8447 | + } | |
8448 | + return matches; | |
8449 | + }, | |
8450 | + | |
8451 | + // Format a number, with leading zero if necessary | |
8452 | + formatNumber = function( match, value, len ) { | |
8453 | + var num = "" + value; | |
8454 | + if ( lookAhead( match ) ) { | |
8455 | + while ( num.length < len ) { | |
8456 | + num = "0" + num; | |
8457 | + } | |
8458 | + } | |
8459 | + return num; | |
8460 | + }, | |
8461 | + | |
8462 | + // Format a name, short or long as requested | |
8463 | + formatName = function( match, value, shortNames, longNames ) { | |
8464 | + return ( lookAhead( match ) ? longNames[ value ] : shortNames[ value ] ); | |
8465 | + }, | |
8466 | + output = "", | |
8467 | + literal = false; | |
8468 | + | |
8469 | + if ( date ) { | |
8470 | + for ( iFormat = 0; iFormat < format.length; iFormat++ ) { | |
8471 | + if ( literal ) { | |
8472 | + if ( format.charAt( iFormat ) === "'" && !lookAhead( "'" ) ) { | |
8473 | + literal = false; | |
8474 | + } else { | |
8475 | + output += format.charAt( iFormat ); | |
8476 | + } | |
8477 | + } else { | |
8478 | + switch ( format.charAt( iFormat ) ) { | |
8479 | + case "d": | |
8480 | + output += formatNumber( "d", date.getDate(), 2 ); | |
8481 | + break; | |
8482 | + case "D": | |
8483 | + output += formatName( "D", date.getDay(), dayNamesShort, dayNames ); | |
8484 | + break; | |
8485 | + case "o": | |
8486 | + output += formatNumber( "o", | |
8487 | + Math.round( ( new Date( date.getFullYear(), date.getMonth(), date.getDate() ).getTime() - new Date( date.getFullYear(), 0, 0 ).getTime() ) / 86400000 ), 3 ); | |
8488 | + break; | |
8489 | + case "m": | |
8490 | + output += formatNumber( "m", date.getMonth() + 1, 2 ); | |
8491 | + break; | |
8492 | + case "M": | |
8493 | + output += formatName( "M", date.getMonth(), monthNamesShort, monthNames ); | |
8494 | + break; | |
8495 | + case "y": | |
8496 | + output += ( lookAhead( "y" ) ? date.getFullYear() : | |
8497 | + ( date.getFullYear() % 100 < 10 ? "0" : "" ) + date.getFullYear() % 100 ); | |
8498 | + break; | |
8499 | + case "@": | |
8500 | + output += date.getTime(); | |
8501 | + break; | |
8502 | + case "!": | |
8503 | + output += date.getTime() * 10000 + this._ticksTo1970; | |
8504 | + break; | |
8505 | + case "'": | |
8506 | + if ( lookAhead( "'" ) ) { | |
8507 | + output += "'"; | |
8508 | + } else { | |
8509 | + literal = true; | |
8510 | + } | |
8511 | + break; | |
8512 | + default: | |
8513 | + output += format.charAt( iFormat ); | |
8514 | + } | |
8515 | + } | |
8516 | + } | |
8517 | + } | |
8518 | + return output; | |
8519 | + }, | |
8520 | + | |
8521 | + /* Extract all possible characters from the date format. */ | |
8522 | + _possibleChars: function( format ) { | |
8523 | + var iFormat, | |
8524 | + chars = "", | |
8525 | + literal = false, | |
8526 | + | |
8527 | + // Check whether a format character is doubled | |
8528 | + lookAhead = function( match ) { | |
8529 | + var matches = ( iFormat + 1 < format.length && format.charAt( iFormat + 1 ) === match ); | |
8530 | + if ( matches ) { | |
8531 | + iFormat++; | |
8532 | + } | |
8533 | + return matches; | |
8534 | + }; | |
8535 | + | |
8536 | + for ( iFormat = 0; iFormat < format.length; iFormat++ ) { | |
8537 | + if ( literal ) { | |
8538 | + if ( format.charAt( iFormat ) === "'" && !lookAhead( "'" ) ) { | |
8539 | + literal = false; | |
8540 | + } else { | |
8541 | + chars += format.charAt( iFormat ); | |
8542 | + } | |
8543 | + } else { | |
8544 | + switch ( format.charAt( iFormat ) ) { | |
8545 | + case "d": case "m": case "y": case "@": | |
8546 | + chars += "0123456789"; | |
8547 | + break; | |
8548 | + case "D": case "M": | |
8549 | + return null; // Accept anything | |
8550 | + case "'": | |
8551 | + if ( lookAhead( "'" ) ) { | |
8552 | + chars += "'"; | |
8553 | + } else { | |
8554 | + literal = true; | |
8555 | + } | |
8556 | + break; | |
8557 | + default: | |
8558 | + chars += format.charAt( iFormat ); | |
8559 | + } | |
8560 | + } | |
8561 | + } | |
8562 | + return chars; | |
8563 | + }, | |
8564 | + | |
8565 | + /* Get a setting value, defaulting if necessary. */ | |
8566 | + _get: function( inst, name ) { | |
8567 | + return inst.settings[ name ] !== undefined ? | |
8568 | + inst.settings[ name ] : this._defaults[ name ]; | |
8569 | + }, | |
8570 | + | |
8571 | + /* Parse existing date and initialise date picker. */ | |
8572 | + _setDateFromField: function( inst, noDefault ) { | |
8573 | + if ( inst.input.val() === inst.lastVal ) { | |
8574 | + return; | |
8575 | + } | |
8576 | + | |
8577 | + var dateFormat = this._get( inst, "dateFormat" ), | |
8578 | + dates = inst.lastVal = inst.input ? inst.input.val() : null, | |
8579 | + defaultDate = this._getDefaultDate( inst ), | |
8580 | + date = defaultDate, | |
8581 | + settings = this._getFormatConfig( inst ); | |
8582 | + | |
8583 | + try { | |
8584 | + date = this.parseDate( dateFormat, dates, settings ) || defaultDate; | |
8585 | + } catch ( event ) { | |
8586 | + dates = ( noDefault ? "" : dates ); | |
8587 | + } | |
8588 | + inst.selectedDay = date.getDate(); | |
8589 | + inst.drawMonth = inst.selectedMonth = date.getMonth(); | |
8590 | + inst.drawYear = inst.selectedYear = date.getFullYear(); | |
8591 | + inst.currentDay = ( dates ? date.getDate() : 0 ); | |
8592 | + inst.currentMonth = ( dates ? date.getMonth() : 0 ); | |
8593 | + inst.currentYear = ( dates ? date.getFullYear() : 0 ); | |
8594 | + this._adjustInstDate( inst ); | |
8595 | + }, | |
8596 | + | |
8597 | + /* Retrieve the default date shown on opening. */ | |
8598 | + _getDefaultDate: function( inst ) { | |
8599 | + return this._restrictMinMax( inst, | |
8600 | + this._determineDate( inst, this._get( inst, "defaultDate" ), new Date() ) ); | |
8601 | + }, | |
8602 | + | |
8603 | + /* A date may be specified as an exact value or a relative one. */ | |
8604 | + _determineDate: function( inst, date, defaultDate ) { | |
8605 | + var offsetNumeric = function( offset ) { | |
8606 | + var date = new Date(); | |
8607 | + date.setDate( date.getDate() + offset ); | |
8608 | + return date; | |
8609 | + }, | |
8610 | + offsetString = function( offset ) { | |
8611 | + try { | |
8612 | + return $.datepicker.parseDate( $.datepicker._get( inst, "dateFormat" ), | |
8613 | + offset, $.datepicker._getFormatConfig( inst ) ); | |
8614 | + } | |
8615 | + catch ( e ) { | |
8616 | + | |
8617 | + // Ignore | |
8618 | + } | |
8619 | + | |
8620 | + var date = ( offset.toLowerCase().match( /^c/ ) ? | |
8621 | + $.datepicker._getDate( inst ) : null ) || new Date(), | |
8622 | + year = date.getFullYear(), | |
8623 | + month = date.getMonth(), | |
8624 | + day = date.getDate(), | |
8625 | + pattern = /([+\-]?[0-9]+)\s*(d|D|w|W|m|M|y|Y)?/g, | |
8626 | + matches = pattern.exec( offset ); | |
8627 | + | |
8628 | + while ( matches ) { | |
8629 | + switch ( matches[ 2 ] || "d" ) { | |
8630 | + case "d" : case "D" : | |
8631 | + day += parseInt( matches[ 1 ], 10 ); break; | |
8632 | + case "w" : case "W" : | |
8633 | + day += parseInt( matches[ 1 ], 10 ) * 7; break; | |
8634 | + case "m" : case "M" : | |
8635 | + month += parseInt( matches[ 1 ], 10 ); | |
8636 | + day = Math.min( day, $.datepicker._getDaysInMonth( year, month ) ); | |
8637 | + break; | |
8638 | + case "y": case "Y" : | |
8639 | + year += parseInt( matches[ 1 ], 10 ); | |
8640 | + day = Math.min( day, $.datepicker._getDaysInMonth( year, month ) ); | |
8641 | + break; | |
8642 | + } | |
8643 | + matches = pattern.exec( offset ); | |
8644 | + } | |
8645 | + return new Date( year, month, day ); | |
8646 | + }, | |
8647 | + newDate = ( date == null || date === "" ? defaultDate : ( typeof date === "string" ? offsetString( date ) : | |
8648 | + ( typeof date === "number" ? ( isNaN( date ) ? defaultDate : offsetNumeric( date ) ) : new Date( date.getTime() ) ) ) ); | |
8649 | + | |
8650 | + newDate = ( newDate && newDate.toString() === "Invalid Date" ? defaultDate : newDate ); | |
8651 | + if ( newDate ) { | |
8652 | + newDate.setHours( 0 ); | |
8653 | + newDate.setMinutes( 0 ); | |
8654 | + newDate.setSeconds( 0 ); | |
8655 | + newDate.setMilliseconds( 0 ); | |
8656 | + } | |
8657 | + return this._daylightSavingAdjust( newDate ); | |
8658 | + }, | |
8659 | + | |
8660 | + /* Handle switch to/from daylight saving. | |
8661 | + * Hours may be non-zero on daylight saving cut-over: | |
8662 | + * > 12 when midnight changeover, but then cannot generate | |
8663 | + * midnight datetime, so jump to 1AM, otherwise reset. | |
8664 | + * @param date (Date) the date to check | |
8665 | + * @return (Date) the corrected date | |
8666 | + */ | |
8667 | + _daylightSavingAdjust: function( date ) { | |
8668 | + if ( !date ) { | |
8669 | + return null; | |
8670 | + } | |
8671 | + date.setHours( date.getHours() > 12 ? date.getHours() + 2 : 0 ); | |
8672 | + return date; | |
8673 | + }, | |
8674 | + | |
8675 | + /* Set the date(s) directly. */ | |
8676 | + _setDate: function( inst, date, noChange ) { | |
8677 | + var clear = !date, | |
8678 | + origMonth = inst.selectedMonth, | |
8679 | + origYear = inst.selectedYear, | |
8680 | + newDate = this._restrictMinMax( inst, this._determineDate( inst, date, new Date() ) ); | |
8681 | + | |
8682 | + inst.selectedDay = inst.currentDay = newDate.getDate(); | |
8683 | + inst.drawMonth = inst.selectedMonth = inst.currentMonth = newDate.getMonth(); | |
8684 | + inst.drawYear = inst.selectedYear = inst.currentYear = newDate.getFullYear(); | |
8685 | + if ( ( origMonth !== inst.selectedMonth || origYear !== inst.selectedYear ) && !noChange ) { | |
8686 | + this._notifyChange( inst ); | |
8687 | + } | |
8688 | + this._adjustInstDate( inst ); | |
8689 | + if ( inst.input ) { | |
8690 | + inst.input.val( clear ? "" : this._formatDate( inst ) ); | |
8691 | + } | |
8692 | + }, | |
8693 | + | |
8694 | + /* Retrieve the date(s) directly. */ | |
8695 | + _getDate: function( inst ) { | |
8696 | + var startDate = ( !inst.currentYear || ( inst.input && inst.input.val() === "" ) ? null : | |
8697 | + this._daylightSavingAdjust( new Date( | |
8698 | + inst.currentYear, inst.currentMonth, inst.currentDay ) ) ); | |
8699 | + return startDate; | |
8700 | + }, | |
8701 | + | |
8702 | + /* Attach the onxxx handlers. These are declared statically so | |
8703 | + * they work with static code transformers like Caja. | |
8704 | + */ | |
8705 | + _attachHandlers: function( inst ) { | |
8706 | + var stepMonths = this._get( inst, "stepMonths" ), | |
8707 | + id = "#" + inst.id.replace( /\\\\/g, "\\" ); | |
8708 | + inst.dpDiv.find( "[data-handler]" ).map( function() { | |
8709 | + var handler = { | |
8710 | + prev: function() { | |
8711 | + $.datepicker._adjustDate( id, -stepMonths, "M" ); | |
8712 | + }, | |
8713 | + next: function() { | |
8714 | + $.datepicker._adjustDate( id, +stepMonths, "M" ); | |
8715 | + }, | |
8716 | + hide: function() { | |
8717 | + $.datepicker._hideDatepicker(); | |
8718 | + }, | |
8719 | + today: function() { | |
8720 | + $.datepicker._gotoToday( id ); | |
8721 | + }, | |
8722 | + selectDay: function() { | |
8723 | + $.datepicker._selectDay( id, +this.getAttribute( "data-month" ), +this.getAttribute( "data-year" ), this ); | |
8724 | + return false; | |
8725 | + }, | |
8726 | + selectMonth: function() { | |
8727 | + $.datepicker._selectMonthYear( id, this, "M" ); | |
8728 | + return false; | |
8729 | + }, | |
8730 | + selectYear: function() { | |
8731 | + $.datepicker._selectMonthYear( id, this, "Y" ); | |
8732 | + return false; | |
8733 | + } | |
8734 | + }; | |
8735 | + $( this ).on( this.getAttribute( "data-event" ), handler[ this.getAttribute( "data-handler" ) ] ); | |
8736 | + } ); | |
8737 | + }, | |
8738 | + | |
8739 | + /* Generate the HTML for the current state of the date picker. */ | |
8740 | + _generateHTML: function( inst ) { | |
8741 | + var maxDraw, prevText, prev, nextText, next, currentText, gotoDate, | |
8742 | + controls, buttonPanel, firstDay, showWeek, dayNames, dayNamesMin, | |
8743 | + monthNames, monthNamesShort, beforeShowDay, showOtherMonths, | |
8744 | + selectOtherMonths, defaultDate, html, dow, row, group, col, selectedDate, | |
8745 | + cornerClass, calender, thead, day, daysInMonth, leadDays, curRows, numRows, | |
8746 | + printDate, dRow, tbody, daySettings, otherMonth, unselectable, | |
8747 | + tempDate = new Date(), | |
8748 | + today = this._daylightSavingAdjust( | |
8749 | + new Date( tempDate.getFullYear(), tempDate.getMonth(), tempDate.getDate() ) ), // clear time | |
8750 | + isRTL = this._get( inst, "isRTL" ), | |
8751 | + showButtonPanel = this._get( inst, "showButtonPanel" ), | |
8752 | + hideIfNoPrevNext = this._get( inst, "hideIfNoPrevNext" ), | |
8753 | + navigationAsDateFormat = this._get( inst, "navigationAsDateFormat" ), | |
8754 | + numMonths = this._getNumberOfMonths( inst ), | |
8755 | + showCurrentAtPos = this._get( inst, "showCurrentAtPos" ), | |
8756 | + stepMonths = this._get( inst, "stepMonths" ), | |
8757 | + isMultiMonth = ( numMonths[ 0 ] !== 1 || numMonths[ 1 ] !== 1 ), | |
8758 | + currentDate = this._daylightSavingAdjust( ( !inst.currentDay ? new Date( 9999, 9, 9 ) : | |
8759 | + new Date( inst.currentYear, inst.currentMonth, inst.currentDay ) ) ), | |
8760 | + minDate = this._getMinMaxDate( inst, "min" ), | |
8761 | + maxDate = this._getMinMaxDate( inst, "max" ), | |
8762 | + drawMonth = inst.drawMonth - showCurrentAtPos, | |
8763 | + drawYear = inst.drawYear; | |
8764 | + | |
8765 | + if ( drawMonth < 0 ) { | |
8766 | + drawMonth += 12; | |
8767 | + drawYear--; | |
8768 | + } | |
8769 | + if ( maxDate ) { | |
8770 | + maxDraw = this._daylightSavingAdjust( new Date( maxDate.getFullYear(), | |
8771 | + maxDate.getMonth() - ( numMonths[ 0 ] * numMonths[ 1 ] ) + 1, maxDate.getDate() ) ); | |
8772 | + maxDraw = ( minDate && maxDraw < minDate ? minDate : maxDraw ); | |
8773 | + while ( this._daylightSavingAdjust( new Date( drawYear, drawMonth, 1 ) ) > maxDraw ) { | |
8774 | + drawMonth--; | |
8775 | + if ( drawMonth < 0 ) { | |
8776 | + drawMonth = 11; | |
8777 | + drawYear--; | |
8778 | + } | |
8779 | + } | |
8780 | + } | |
8781 | + inst.drawMonth = drawMonth; | |
8782 | + inst.drawYear = drawYear; | |
8783 | + | |
8784 | + prevText = this._get( inst, "prevText" ); | |
8785 | + prevText = ( !navigationAsDateFormat ? prevText : this.formatDate( prevText, | |
8786 | + this._daylightSavingAdjust( new Date( drawYear, drawMonth - stepMonths, 1 ) ), | |
8787 | + this._getFormatConfig( inst ) ) ); | |
8788 | + | |
8789 | + prev = ( this._canAdjustMonth( inst, -1, drawYear, drawMonth ) ? | |
8790 | + "<a class='ui-datepicker-prev ui-corner-all' data-handler='prev' data-event='click'" + | |
8791 | + " title='" + prevText + "'><span class='ui-icon ui-icon-circle-triangle-" + ( isRTL ? "e" : "w" ) + "'>" + prevText + "</span></a>" : | |
8792 | + ( hideIfNoPrevNext ? "" : "<a class='ui-datepicker-prev ui-corner-all ui-state-disabled' title='" + prevText + "'><span class='ui-icon ui-icon-circle-triangle-" + ( isRTL ? "e" : "w" ) + "'>" + prevText + "</span></a>" ) ); | |
8793 | + | |
8794 | + nextText = this._get( inst, "nextText" ); | |
8795 | + nextText = ( !navigationAsDateFormat ? nextText : this.formatDate( nextText, | |
8796 | + this._daylightSavingAdjust( new Date( drawYear, drawMonth + stepMonths, 1 ) ), | |
8797 | + this._getFormatConfig( inst ) ) ); | |
8798 | + | |
8799 | + next = ( this._canAdjustMonth( inst, +1, drawYear, drawMonth ) ? | |
8800 | + "<a class='ui-datepicker-next ui-corner-all' data-handler='next' data-event='click'" + | |
8801 | + " title='" + nextText + "'><span class='ui-icon ui-icon-circle-triangle-" + ( isRTL ? "w" : "e" ) + "'>" + nextText + "</span></a>" : | |
8802 | + ( hideIfNoPrevNext ? "" : "<a class='ui-datepicker-next ui-corner-all ui-state-disabled' title='" + nextText + "'><span class='ui-icon ui-icon-circle-triangle-" + ( isRTL ? "w" : "e" ) + "'>" + nextText + "</span></a>" ) ); | |
8803 | + | |
8804 | + currentText = this._get( inst, "currentText" ); | |
8805 | + gotoDate = ( this._get( inst, "gotoCurrent" ) && inst.currentDay ? currentDate : today ); | |
8806 | + currentText = ( !navigationAsDateFormat ? currentText : | |
8807 | + this.formatDate( currentText, gotoDate, this._getFormatConfig( inst ) ) ); | |
8808 | + | |
8809 | + controls = ( !inst.inline ? "<button type='button' class='ui-datepicker-close ui-state-default ui-priority-primary ui-corner-all' data-handler='hide' data-event='click'>" + | |
8810 | + this._get( inst, "closeText" ) + "</button>" : "" ); | |
8811 | + | |
8812 | + buttonPanel = ( showButtonPanel ) ? "<div class='ui-datepicker-buttonpane ui-widget-content'>" + ( isRTL ? controls : "" ) + | |
8813 | + ( this._isInRange( inst, gotoDate ) ? "<button type='button' class='ui-datepicker-current ui-state-default ui-priority-secondary ui-corner-all' data-handler='today' data-event='click'" + | |
8814 | + ">" + currentText + "</button>" : "" ) + ( isRTL ? "" : controls ) + "</div>" : ""; | |
8815 | + | |
8816 | + firstDay = parseInt( this._get( inst, "firstDay" ), 10 ); | |
8817 | + firstDay = ( isNaN( firstDay ) ? 0 : firstDay ); | |
8818 | + | |
8819 | + showWeek = this._get( inst, "showWeek" ); | |
8820 | + dayNames = this._get( inst, "dayNames" ); | |
8821 | + dayNamesMin = this._get( inst, "dayNamesMin" ); | |
8822 | + monthNames = this._get( inst, "monthNames" ); | |
8823 | + monthNamesShort = this._get( inst, "monthNamesShort" ); | |
8824 | + beforeShowDay = this._get( inst, "beforeShowDay" ); | |
8825 | + showOtherMonths = this._get( inst, "showOtherMonths" ); | |
8826 | + selectOtherMonths = this._get( inst, "selectOtherMonths" ); | |
8827 | + defaultDate = this._getDefaultDate( inst ); | |
8828 | + html = ""; | |
8829 | + | |
8830 | + for ( row = 0; row < numMonths[ 0 ]; row++ ) { | |
8831 | + group = ""; | |
8832 | + this.maxRows = 4; | |
8833 | + for ( col = 0; col < numMonths[ 1 ]; col++ ) { | |
8834 | + selectedDate = this._daylightSavingAdjust( new Date( drawYear, drawMonth, inst.selectedDay ) ); | |
8835 | + cornerClass = " ui-corner-all"; | |
8836 | + calender = ""; | |
8837 | + if ( isMultiMonth ) { | |
8838 | + calender += "<div class='ui-datepicker-group"; | |
8839 | + if ( numMonths[ 1 ] > 1 ) { | |
8840 | + switch ( col ) { | |
8841 | + case 0: calender += " ui-datepicker-group-first"; | |
8842 | + cornerClass = " ui-corner-" + ( isRTL ? "right" : "left" ); break; | |
8843 | + case numMonths[ 1 ] - 1: calender += " ui-datepicker-group-last"; | |
8844 | + cornerClass = " ui-corner-" + ( isRTL ? "left" : "right" ); break; | |
8845 | + default: calender += " ui-datepicker-group-middle"; cornerClass = ""; break; | |
8846 | + } | |
8847 | + } | |
8848 | + calender += "'>"; | |
8849 | + } | |
8850 | + calender += "<div class='ui-datepicker-header ui-widget-header ui-helper-clearfix" + cornerClass + "'>" + | |
8851 | + ( /all|left/.test( cornerClass ) && row === 0 ? ( isRTL ? next : prev ) : "" ) + | |
8852 | + ( /all|right/.test( cornerClass ) && row === 0 ? ( isRTL ? prev : next ) : "" ) + | |
8853 | + this._generateMonthYearHeader( inst, drawMonth, drawYear, minDate, maxDate, | |
8854 | + row > 0 || col > 0, monthNames, monthNamesShort ) + // draw month headers | |
8855 | + "</div><table class='ui-datepicker-calendar'><thead>" + | |
8856 | + "<tr>"; | |
8857 | + thead = ( showWeek ? "<th class='ui-datepicker-week-col'>" + this._get( inst, "weekHeader" ) + "</th>" : "" ); | |
8858 | + for ( dow = 0; dow < 7; dow++ ) { // days of the week | |
8859 | + day = ( dow + firstDay ) % 7; | |
8860 | + thead += "<th scope='col'" + ( ( dow + firstDay + 6 ) % 7 >= 5 ? " class='ui-datepicker-week-end'" : "" ) + ">" + | |
8861 | + "<span title='" + dayNames[ day ] + "'>" + dayNamesMin[ day ] + "</span></th>"; | |
8862 | + } | |
8863 | + calender += thead + "</tr></thead><tbody>"; | |
8864 | + daysInMonth = this._getDaysInMonth( drawYear, drawMonth ); | |
8865 | + if ( drawYear === inst.selectedYear && drawMonth === inst.selectedMonth ) { | |
8866 | + inst.selectedDay = Math.min( inst.selectedDay, daysInMonth ); | |
8867 | + } | |
8868 | + leadDays = ( this._getFirstDayOfMonth( drawYear, drawMonth ) - firstDay + 7 ) % 7; | |
8869 | + curRows = Math.ceil( ( leadDays + daysInMonth ) / 7 ); // calculate the number of rows to generate | |
8870 | + numRows = ( isMultiMonth ? this.maxRows > curRows ? this.maxRows : curRows : curRows ); //If multiple months, use the higher number of rows (see #7043) | |
8871 | + this.maxRows = numRows; | |
8872 | + printDate = this._daylightSavingAdjust( new Date( drawYear, drawMonth, 1 - leadDays ) ); | |
8873 | + for ( dRow = 0; dRow < numRows; dRow++ ) { // create date picker rows | |
8874 | + calender += "<tr>"; | |
8875 | + tbody = ( !showWeek ? "" : "<td class='ui-datepicker-week-col'>" + | |
8876 | + this._get( inst, "calculateWeek" )( printDate ) + "</td>" ); | |
8877 | + for ( dow = 0; dow < 7; dow++ ) { // create date picker days | |
8878 | + daySettings = ( beforeShowDay ? | |
8879 | + beforeShowDay.apply( ( inst.input ? inst.input[ 0 ] : null ), [ printDate ] ) : [ true, "" ] ); | |
8880 | + otherMonth = ( printDate.getMonth() !== drawMonth ); | |
8881 | + unselectable = ( otherMonth && !selectOtherMonths ) || !daySettings[ 0 ] || | |
8882 | + ( minDate && printDate < minDate ) || ( maxDate && printDate > maxDate ); | |
8883 | + tbody += "<td class='" + | |
8884 | + ( ( dow + firstDay + 6 ) % 7 >= 5 ? " ui-datepicker-week-end" : "" ) + // highlight weekends | |
8885 | + ( otherMonth ? " ui-datepicker-other-month" : "" ) + // highlight days from other months | |
8886 | + ( ( printDate.getTime() === selectedDate.getTime() && drawMonth === inst.selectedMonth && inst._keyEvent ) || // user pressed key | |
8887 | + ( defaultDate.getTime() === printDate.getTime() && defaultDate.getTime() === selectedDate.getTime() ) ? | |
8888 | + | |
8889 | + // or defaultDate is current printedDate and defaultDate is selectedDate | |
8890 | + " " + this._dayOverClass : "" ) + // highlight selected day | |
8891 | + ( unselectable ? " " + this._unselectableClass + " ui-state-disabled" : "" ) + // highlight unselectable days | |
8892 | + ( otherMonth && !showOtherMonths ? "" : " " + daySettings[ 1 ] + // highlight custom dates | |
8893 | + ( printDate.getTime() === currentDate.getTime() ? " " + this._currentClass : "" ) + // highlight selected day | |
8894 | + ( printDate.getTime() === today.getTime() ? " ui-datepicker-today" : "" ) ) + "'" + // highlight today (if different) | |
8895 | + ( ( !otherMonth || showOtherMonths ) && daySettings[ 2 ] ? " title='" + daySettings[ 2 ].replace( /'/g, "'" ) + "'" : "" ) + // cell title | |
8896 | + ( unselectable ? "" : " data-handler='selectDay' data-event='click' data-month='" + printDate.getMonth() + "' data-year='" + printDate.getFullYear() + "'" ) + ">" + // actions | |
8897 | + ( otherMonth && !showOtherMonths ? " " : // display for other months | |
8898 | + ( unselectable ? "<span class='ui-state-default'>" + printDate.getDate() + "</span>" : "<a class='ui-state-default" + | |
8899 | + ( printDate.getTime() === today.getTime() ? " ui-state-highlight" : "" ) + | |
8900 | + ( printDate.getTime() === currentDate.getTime() ? " ui-state-active" : "" ) + // highlight selected day | |
8901 | + ( otherMonth ? " ui-priority-secondary" : "" ) + // distinguish dates from other months | |
8902 | + "' href='#'>" + printDate.getDate() + "</a>" ) ) + "</td>"; // display selectable date | |
8903 | + printDate.setDate( printDate.getDate() + 1 ); | |
8904 | + printDate = this._daylightSavingAdjust( printDate ); | |
8905 | + } | |
8906 | + calender += tbody + "</tr>"; | |
8907 | + } | |
8908 | + drawMonth++; | |
8909 | + if ( drawMonth > 11 ) { | |
8910 | + drawMonth = 0; | |
8911 | + drawYear++; | |
8912 | + } | |
8913 | + calender += "</tbody></table>" + ( isMultiMonth ? "</div>" + | |
8914 | + ( ( numMonths[ 0 ] > 0 && col === numMonths[ 1 ] - 1 ) ? "<div class='ui-datepicker-row-break'></div>" : "" ) : "" ); | |
8915 | + group += calender; | |
8916 | + } | |
8917 | + html += group; | |
8918 | + } | |
8919 | + html += buttonPanel; | |
8920 | + inst._keyEvent = false; | |
8921 | + return html; | |
8922 | + }, | |
8923 | + | |
8924 | + /* Generate the month and year header. */ | |
8925 | + _generateMonthYearHeader: function( inst, drawMonth, drawYear, minDate, maxDate, | |
8926 | + secondary, monthNames, monthNamesShort ) { | |
8927 | + | |
8928 | + var inMinYear, inMaxYear, month, years, thisYear, determineYear, year, endYear, | |
8929 | + changeMonth = this._get( inst, "changeMonth" ), | |
8930 | + changeYear = this._get( inst, "changeYear" ), | |
8931 | + showMonthAfterYear = this._get( inst, "showMonthAfterYear" ), | |
8932 | + html = "<div class='ui-datepicker-title'>", | |
8933 | + monthHtml = ""; | |
8934 | + | |
8935 | + // Month selection | |
8936 | + if ( secondary || !changeMonth ) { | |
8937 | + monthHtml += "<span class='ui-datepicker-month'>" + monthNames[ drawMonth ] + "</span>"; | |
8938 | + } else { | |
8939 | + inMinYear = ( minDate && minDate.getFullYear() === drawYear ); | |
8940 | + inMaxYear = ( maxDate && maxDate.getFullYear() === drawYear ); | |
8941 | + monthHtml += "<select class='ui-datepicker-month' data-handler='selectMonth' data-event='change'>"; | |
8942 | + for ( month = 0; month < 12; month++ ) { | |
8943 | + if ( ( !inMinYear || month >= minDate.getMonth() ) && ( !inMaxYear || month <= maxDate.getMonth() ) ) { | |
8944 | + monthHtml += "<option value='" + month + "'" + | |
8945 | + ( month === drawMonth ? " selected='selected'" : "" ) + | |
8946 | + ">" + monthNamesShort[ month ] + "</option>"; | |
8947 | + } | |
8948 | + } | |
8949 | + monthHtml += "</select>"; | |
8950 | + } | |
8951 | + | |
8952 | + if ( !showMonthAfterYear ) { | |
8953 | + html += monthHtml + ( secondary || !( changeMonth && changeYear ) ? " " : "" ); | |
8954 | + } | |
8955 | + | |
8956 | + // Year selection | |
8957 | + if ( !inst.yearshtml ) { | |
8958 | + inst.yearshtml = ""; | |
8959 | + if ( secondary || !changeYear ) { | |
8960 | + html += "<span class='ui-datepicker-year'>" + drawYear + "</span>"; | |
8961 | + } else { | |
8962 | + | |
8963 | + // determine range of years to display | |
8964 | + years = this._get( inst, "yearRange" ).split( ":" ); | |
8965 | + thisYear = new Date().getFullYear(); | |
8966 | + determineYear = function( value ) { | |
8967 | + var year = ( value.match( /c[+\-].*/ ) ? drawYear + parseInt( value.substring( 1 ), 10 ) : | |
8968 | + ( value.match( /[+\-].*/ ) ? thisYear + parseInt( value, 10 ) : | |
8969 | + parseInt( value, 10 ) ) ); | |
8970 | + return ( isNaN( year ) ? thisYear : year ); | |
8971 | + }; | |
8972 | + year = determineYear( years[ 0 ] ); | |
8973 | + endYear = Math.max( year, determineYear( years[ 1 ] || "" ) ); | |
8974 | + year = ( minDate ? Math.max( year, minDate.getFullYear() ) : year ); | |
8975 | + endYear = ( maxDate ? Math.min( endYear, maxDate.getFullYear() ) : endYear ); | |
8976 | + inst.yearshtml += "<select class='ui-datepicker-year' data-handler='selectYear' data-event='change'>"; | |
8977 | + for ( ; year <= endYear; year++ ) { | |
8978 | + inst.yearshtml += "<option value='" + year + "'" + | |
8979 | + ( year === drawYear ? " selected='selected'" : "" ) + | |
8980 | + ">" + year + "</option>"; | |
8981 | + } | |
8982 | + inst.yearshtml += "</select>"; | |
8983 | + | |
8984 | + html += inst.yearshtml; | |
8985 | + inst.yearshtml = null; | |
8986 | + } | |
8987 | + } | |
8988 | + | |
8989 | + html += this._get( inst, "yearSuffix" ); | |
8990 | + if ( showMonthAfterYear ) { | |
8991 | + html += ( secondary || !( changeMonth && changeYear ) ? " " : "" ) + monthHtml; | |
8992 | + } | |
8993 | + html += "</div>"; // Close datepicker_header | |
8994 | + return html; | |
8995 | + }, | |
8996 | + | |
8997 | + /* Adjust one of the date sub-fields. */ | |
8998 | + _adjustInstDate: function( inst, offset, period ) { | |
8999 | + var year = inst.selectedYear + ( period === "Y" ? offset : 0 ), | |
9000 | + month = inst.selectedMonth + ( period === "M" ? offset : 0 ), | |
9001 | + day = Math.min( inst.selectedDay, this._getDaysInMonth( year, month ) ) + ( period === "D" ? offset : 0 ), | |
9002 | + date = this._restrictMinMax( inst, this._daylightSavingAdjust( new Date( year, month, day ) ) ); | |
9003 | + | |
9004 | + inst.selectedDay = date.getDate(); | |
9005 | + inst.drawMonth = inst.selectedMonth = date.getMonth(); | |
9006 | + inst.drawYear = inst.selectedYear = date.getFullYear(); | |
9007 | + if ( period === "M" || period === "Y" ) { | |
9008 | + this._notifyChange( inst ); | |
9009 | + } | |
9010 | + }, | |
9011 | + | |
9012 | + /* Ensure a date is within any min/max bounds. */ | |
9013 | + _restrictMinMax: function( inst, date ) { | |
9014 | + var minDate = this._getMinMaxDate( inst, "min" ), | |
9015 | + maxDate = this._getMinMaxDate( inst, "max" ), | |
9016 | + newDate = ( minDate && date < minDate ? minDate : date ); | |
9017 | + return ( maxDate && newDate > maxDate ? maxDate : newDate ); | |
9018 | + }, | |
9019 | + | |
9020 | + /* Notify change of month/year. */ | |
9021 | + _notifyChange: function( inst ) { | |
9022 | + var onChange = this._get( inst, "onChangeMonthYear" ); | |
9023 | + if ( onChange ) { | |
9024 | + onChange.apply( ( inst.input ? inst.input[ 0 ] : null ), | |
9025 | + [ inst.selectedYear, inst.selectedMonth + 1, inst ] ); | |
9026 | + } | |
9027 | + }, | |
9028 | + | |
9029 | + /* Determine the number of months to show. */ | |
9030 | + _getNumberOfMonths: function( inst ) { | |
9031 | + var numMonths = this._get( inst, "numberOfMonths" ); | |
9032 | + return ( numMonths == null ? [ 1, 1 ] : ( typeof numMonths === "number" ? [ 1, numMonths ] : numMonths ) ); | |
9033 | + }, | |
9034 | + | |
9035 | + /* Determine the current maximum date - ensure no time components are set. */ | |
9036 | + _getMinMaxDate: function( inst, minMax ) { | |
9037 | + return this._determineDate( inst, this._get( inst, minMax + "Date" ), null ); | |
9038 | + }, | |
9039 | + | |
9040 | + /* Find the number of days in a given month. */ | |
9041 | + _getDaysInMonth: function( year, month ) { | |
9042 | + return 32 - this._daylightSavingAdjust( new Date( year, month, 32 ) ).getDate(); | |
9043 | + }, | |
9044 | + | |
9045 | + /* Find the day of the week of the first of a month. */ | |
9046 | + _getFirstDayOfMonth: function( year, month ) { | |
9047 | + return new Date( year, month, 1 ).getDay(); | |
9048 | + }, | |
9049 | + | |
9050 | + /* Determines if we should allow a "next/prev" month display change. */ | |
9051 | + _canAdjustMonth: function( inst, offset, curYear, curMonth ) { | |
9052 | + var numMonths = this._getNumberOfMonths( inst ), | |
9053 | + date = this._daylightSavingAdjust( new Date( curYear, | |
9054 | + curMonth + ( offset < 0 ? offset : numMonths[ 0 ] * numMonths[ 1 ] ), 1 ) ); | |
9055 | + | |
9056 | + if ( offset < 0 ) { | |
9057 | + date.setDate( this._getDaysInMonth( date.getFullYear(), date.getMonth() ) ); | |
9058 | + } | |
9059 | + return this._isInRange( inst, date ); | |
9060 | + }, | |
9061 | + | |
9062 | + /* Is the given date in the accepted range? */ | |
9063 | + _isInRange: function( inst, date ) { | |
9064 | + var yearSplit, currentYear, | |
9065 | + minDate = this._getMinMaxDate( inst, "min" ), | |
9066 | + maxDate = this._getMinMaxDate( inst, "max" ), | |
9067 | + minYear = null, | |
9068 | + maxYear = null, | |
9069 | + years = this._get( inst, "yearRange" ); | |
9070 | + if ( years ) { | |
9071 | + yearSplit = years.split( ":" ); | |
9072 | + currentYear = new Date().getFullYear(); | |
9073 | + minYear = parseInt( yearSplit[ 0 ], 10 ); | |
9074 | + maxYear = parseInt( yearSplit[ 1 ], 10 ); | |
9075 | + if ( yearSplit[ 0 ].match( /[+\-].*/ ) ) { | |
9076 | + minYear += currentYear; | |
9077 | + } | |
9078 | + if ( yearSplit[ 1 ].match( /[+\-].*/ ) ) { | |
9079 | + maxYear += currentYear; | |
9080 | + } | |
9081 | + } | |
9082 | + | |
9083 | + return ( ( !minDate || date.getTime() >= minDate.getTime() ) && | |
9084 | + ( !maxDate || date.getTime() <= maxDate.getTime() ) && | |
9085 | + ( !minYear || date.getFullYear() >= minYear ) && | |
9086 | + ( !maxYear || date.getFullYear() <= maxYear ) ); | |
9087 | + }, | |
9088 | + | |
9089 | + /* Provide the configuration settings for formatting/parsing. */ | |
9090 | + _getFormatConfig: function( inst ) { | |
9091 | + var shortYearCutoff = this._get( inst, "shortYearCutoff" ); | |
9092 | + shortYearCutoff = ( typeof shortYearCutoff !== "string" ? shortYearCutoff : | |
9093 | + new Date().getFullYear() % 100 + parseInt( shortYearCutoff, 10 ) ); | |
9094 | + return { shortYearCutoff: shortYearCutoff, | |
9095 | + dayNamesShort: this._get( inst, "dayNamesShort" ), dayNames: this._get( inst, "dayNames" ), | |
9096 | + monthNamesShort: this._get( inst, "monthNamesShort" ), monthNames: this._get( inst, "monthNames" ) }; | |
9097 | + }, | |
9098 | + | |
9099 | + /* Format the given date for display. */ | |
9100 | + _formatDate: function( inst, day, month, year ) { | |
9101 | + if ( !day ) { | |
9102 | + inst.currentDay = inst.selectedDay; | |
9103 | + inst.currentMonth = inst.selectedMonth; | |
9104 | + inst.currentYear = inst.selectedYear; | |
9105 | + } | |
9106 | + var date = ( day ? ( typeof day === "object" ? day : | |
9107 | + this._daylightSavingAdjust( new Date( year, month, day ) ) ) : | |
9108 | + this._daylightSavingAdjust( new Date( inst.currentYear, inst.currentMonth, inst.currentDay ) ) ); | |
9109 | + return this.formatDate( this._get( inst, "dateFormat" ), date, this._getFormatConfig( inst ) ); | |
9110 | + } | |
9111 | +} ); | |
9112 | + | |
9113 | +/* | |
9114 | + * Bind hover events for datepicker elements. | |
9115 | + * Done via delegate so the binding only occurs once in the lifetime of the parent div. | |
9116 | + * Global datepicker_instActive, set by _updateDatepicker allows the handlers to find their way back to the active picker. | |
9117 | + */ | |
9118 | +function datepicker_bindHover( dpDiv ) { | |
9119 | + var selector = "button, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-calendar td a"; | |
9120 | + return dpDiv.on( "mouseout", selector, function() { | |
9121 | + $( this ).removeClass( "ui-state-hover" ); | |
9122 | + if ( this.className.indexOf( "ui-datepicker-prev" ) !== -1 ) { | |
9123 | + $( this ).removeClass( "ui-datepicker-prev-hover" ); | |
9124 | + } | |
9125 | + if ( this.className.indexOf( "ui-datepicker-next" ) !== -1 ) { | |
9126 | + $( this ).removeClass( "ui-datepicker-next-hover" ); | |
9127 | + } | |
9128 | + } ) | |
9129 | + .on( "mouseover", selector, datepicker_handleMouseover ); | |
9130 | +} | |
9131 | + | |
9132 | +function datepicker_handleMouseover() { | |
9133 | + if ( !$.datepicker._isDisabledDatepicker( datepicker_instActive.inline ? datepicker_instActive.dpDiv.parent()[ 0 ] : datepicker_instActive.input[ 0 ] ) ) { | |
9134 | + $( this ).parents( ".ui-datepicker-calendar" ).find( "a" ).removeClass( "ui-state-hover" ); | |
9135 | + $( this ).addClass( "ui-state-hover" ); | |
9136 | + if ( this.className.indexOf( "ui-datepicker-prev" ) !== -1 ) { | |
9137 | + $( this ).addClass( "ui-datepicker-prev-hover" ); | |
9138 | + } | |
9139 | + if ( this.className.indexOf( "ui-datepicker-next" ) !== -1 ) { | |
9140 | + $( this ).addClass( "ui-datepicker-next-hover" ); | |
9141 | + } | |
9142 | + } | |
9143 | +} | |
9144 | + | |
9145 | +/* jQuery extend now ignores nulls! */ | |
9146 | +function datepicker_extendRemove( target, props ) { | |
9147 | + $.extend( target, props ); | |
9148 | + for ( var name in props ) { | |
9149 | + if ( props[ name ] == null ) { | |
9150 | + target[ name ] = props[ name ]; | |
9151 | + } | |
9152 | + } | |
9153 | + return target; | |
9154 | +} | |
9155 | + | |
9156 | +/* Invoke the datepicker functionality. | |
9157 | + @param options string - a command, optionally followed by additional parameters or | |
9158 | + Object - settings for attaching new datepicker functionality | |
9159 | + @return jQuery object */ | |
9160 | +$.fn.datepicker = function( options ) { | |
9161 | + | |
9162 | + /* Verify an empty collection wasn't passed - Fixes #6976 */ | |
9163 | + if ( !this.length ) { | |
9164 | + return this; | |
9165 | + } | |
9166 | + | |
9167 | + /* Initialise the date picker. */ | |
9168 | + if ( !$.datepicker.initialized ) { | |
9169 | + $( document ).on( "mousedown", $.datepicker._checkExternalClick ); | |
9170 | + $.datepicker.initialized = true; | |
9171 | + } | |
9172 | + | |
9173 | + /* Append datepicker main container to body if not exist. */ | |
9174 | + if ( $( "#" + $.datepicker._mainDivId ).length === 0 ) { | |
9175 | + $( "body" ).append( $.datepicker.dpDiv ); | |
9176 | + } | |
9177 | + | |
9178 | + var otherArgs = Array.prototype.slice.call( arguments, 1 ); | |
9179 | + if ( typeof options === "string" && ( options === "isDisabled" || options === "getDate" || options === "widget" ) ) { | |
9180 | + return $.datepicker[ "_" + options + "Datepicker" ]. | |
9181 | + apply( $.datepicker, [ this[ 0 ] ].concat( otherArgs ) ); | |
9182 | + } | |
9183 | + if ( options === "option" && arguments.length === 2 && typeof arguments[ 1 ] === "string" ) { | |
9184 | + return $.datepicker[ "_" + options + "Datepicker" ]. | |
9185 | + apply( $.datepicker, [ this[ 0 ] ].concat( otherArgs ) ); | |
9186 | + } | |
9187 | + return this.each( function() { | |
9188 | + typeof options === "string" ? | |
9189 | + $.datepicker[ "_" + options + "Datepicker" ]. | |
9190 | + apply( $.datepicker, [ this ].concat( otherArgs ) ) : | |
9191 | + $.datepicker._attachDatepicker( this, options ); | |
9192 | + } ); | |
9193 | +}; | |
9194 | + | |
9195 | +$.datepicker = new Datepicker(); // singleton instance | |
9196 | +$.datepicker.initialized = false; | |
9197 | +$.datepicker.uuid = new Date().getTime(); | |
9198 | +$.datepicker.version = "1.12.0-rc.2"; | |
9199 | + | |
9200 | +var widgetsDatepicker = $.datepicker; | |
9201 | + | |
9202 | + | |
9203 | + | |
9204 | + | |
9205 | +// This file is deprecated | |
9206 | +var ie = $.ui.ie = !!/msie [\w.]+/.exec( navigator.userAgent.toLowerCase() ); | |
9207 | + | |
9208 | +/*! | |
9209 | + * jQuery UI Mouse 1.12.0-rc.2 | |
9210 | + * http://jqueryui.com | |
9211 | + * | |
9212 | + * Copyright jQuery Foundation and other contributors | |
9213 | + * Released under the MIT license. | |
9214 | + * http://jquery.org/license | |
9215 | + */ | |
9216 | + | |
9217 | +//>>label: Mouse | |
9218 | +//>>group: Widgets | |
9219 | +//>>description: Abstracts mouse-based interactions to assist in creating certain widgets. | |
9220 | +//>>docs: http://api.jqueryui.com/mouse/ | |
9221 | + | |
9222 | + | |
9223 | + | |
9224 | +var mouseHandled = false; | |
9225 | +$( document ).on( "mouseup", function() { | |
9226 | + mouseHandled = false; | |
9227 | +} ); | |
9228 | + | |
9229 | +var widgetsMouse = $.widget( "ui.mouse", { | |
9230 | + version: "1.12.0-rc.2", | |
9231 | + options: { | |
9232 | + cancel: "input, textarea, button, select, option", | |
9233 | + distance: 1, | |
9234 | + delay: 0 | |
9235 | + }, | |
9236 | + _mouseInit: function() { | |
9237 | + var that = this; | |
9238 | + | |
9239 | + this.element | |
9240 | + .on( "mousedown." + this.widgetName, function( event ) { | |
9241 | + return that._mouseDown( event ); | |
9242 | + } ) | |
9243 | + .on( "click." + this.widgetName, function( event ) { | |
9244 | + if ( true === $.data( event.target, that.widgetName + ".preventClickEvent" ) ) { | |
9245 | + $.removeData( event.target, that.widgetName + ".preventClickEvent" ); | |
9246 | + event.stopImmediatePropagation(); | |
9247 | + return false; | |
9248 | + } | |
9249 | + } ); | |
9250 | + | |
9251 | + this.started = false; | |
9252 | + }, | |
9253 | + | |
9254 | + // TODO: make sure destroying one instance of mouse doesn't mess with | |
9255 | + // other instances of mouse | |
9256 | + _mouseDestroy: function() { | |
9257 | + this.element.off( "." + this.widgetName ); | |
9258 | + if ( this._mouseMoveDelegate ) { | |
9259 | + this.document | |
9260 | + .off( "mousemove." + this.widgetName, this._mouseMoveDelegate ) | |
9261 | + .off( "mouseup." + this.widgetName, this._mouseUpDelegate ); | |
9262 | + } | |
9263 | + }, | |
9264 | + | |
9265 | + _mouseDown: function( event ) { | |
9266 | + | |
9267 | + // don't let more than one widget handle mouseStart | |
9268 | + if ( mouseHandled ) { | |
9269 | + return; | |
9270 | + } | |
9271 | + | |
9272 | + this._mouseMoved = false; | |
9273 | + | |
9274 | + // We may have missed mouseup (out of window) | |
9275 | + ( this._mouseStarted && this._mouseUp( event ) ); | |
9276 | + | |
9277 | + this._mouseDownEvent = event; | |
9278 | + | |
9279 | + var that = this, | |
9280 | + btnIsLeft = ( event.which === 1 ), | |
9281 | + | |
9282 | + // event.target.nodeName works around a bug in IE 8 with | |
9283 | + // disabled inputs (#7620) | |
9284 | + elIsCancel = ( typeof this.options.cancel === "string" && event.target.nodeName ? | |
9285 | + $( event.target ).closest( this.options.cancel ).length : false ); | |
9286 | + if ( !btnIsLeft || elIsCancel || !this._mouseCapture( event ) ) { | |
9287 | + return true; | |
9288 | + } | |
9289 | + | |
9290 | + this.mouseDelayMet = !this.options.delay; | |
9291 | + if ( !this.mouseDelayMet ) { | |
9292 | + this._mouseDelayTimer = setTimeout( function() { | |
9293 | + that.mouseDelayMet = true; | |
9294 | + }, this.options.delay ); | |
9295 | + } | |
9296 | + | |
9297 | + if ( this._mouseDistanceMet( event ) && this._mouseDelayMet( event ) ) { | |
9298 | + this._mouseStarted = ( this._mouseStart( event ) !== false ); | |
9299 | + if ( !this._mouseStarted ) { | |
9300 | + event.preventDefault(); | |
9301 | + return true; | |
9302 | + } | |
9303 | + } | |
9304 | + | |
9305 | + // Click event may never have fired (Gecko & Opera) | |
9306 | + if ( true === $.data( event.target, this.widgetName + ".preventClickEvent" ) ) { | |
9307 | + $.removeData( event.target, this.widgetName + ".preventClickEvent" ); | |
9308 | + } | |
9309 | + | |
9310 | + // These delegates are required to keep context | |
9311 | + this._mouseMoveDelegate = function( event ) { | |
9312 | + return that._mouseMove( event ); | |
9313 | + }; | |
9314 | + this._mouseUpDelegate = function( event ) { | |
9315 | + return that._mouseUp( event ); | |
9316 | + }; | |
9317 | + | |
9318 | + this.document | |
9319 | + .on( "mousemove." + this.widgetName, this._mouseMoveDelegate ) | |
9320 | + .on( "mouseup." + this.widgetName, this._mouseUpDelegate ); | |
9321 | + | |
9322 | + event.preventDefault(); | |
9323 | + | |
9324 | + mouseHandled = true; | |
9325 | + return true; | |
9326 | + }, | |
9327 | + | |
9328 | + _mouseMove: function( event ) { | |
9329 | + | |
9330 | + // Only check for mouseups outside the document if you've moved inside the document | |
9331 | + // at least once. This prevents the firing of mouseup in the case of IE<9, which will | |
9332 | + // fire a mousemove event if content is placed under the cursor. See #7778 | |
9333 | + // Support: IE <9 | |
9334 | + if ( this._mouseMoved ) { | |
9335 | + | |
9336 | + // IE mouseup check - mouseup happened when mouse was out of window | |
9337 | + if ( $.ui.ie && ( !document.documentMode || document.documentMode < 9 ) && | |
9338 | + !event.button ) { | |
9339 | + return this._mouseUp( event ); | |
9340 | + | |
9341 | + // Iframe mouseup check - mouseup occurred in another document | |
9342 | + } else if ( !event.which ) { | |
9343 | + | |
9344 | + // Support: Safari <=8 - 9 | |
9345 | + // Safari sets which to 0 if you press any of the following keys | |
9346 | + // during a drag (#14461) | |
9347 | + if ( event.originalEvent.altKey || event.originalEvent.ctrlKey || | |
9348 | + event.originalEvent.metaKey || event.originalEvent.shiftKey ) { | |
9349 | + this.ignoreMissingWhich = true; | |
9350 | + } else if ( !this.ignoreMissingWhich ) { | |
9351 | + return this._mouseUp( event ); | |
9352 | + } | |
9353 | + } | |
9354 | + } | |
9355 | + | |
9356 | + if ( event.which || event.button ) { | |
9357 | + this._mouseMoved = true; | |
9358 | + } | |
9359 | + | |
9360 | + if ( this._mouseStarted ) { | |
9361 | + this._mouseDrag( event ); | |
9362 | + return event.preventDefault(); | |
9363 | + } | |
9364 | + | |
9365 | + if ( this._mouseDistanceMet( event ) && this._mouseDelayMet( event ) ) { | |
9366 | + this._mouseStarted = | |
9367 | + ( this._mouseStart( this._mouseDownEvent, event ) !== false ); | |
9368 | + ( this._mouseStarted ? this._mouseDrag( event ) : this._mouseUp( event ) ); | |
9369 | + } | |
9370 | + | |
9371 | + return !this._mouseStarted; | |
9372 | + }, | |
9373 | + | |
9374 | + _mouseUp: function( event ) { | |
9375 | + this.document | |
9376 | + .off( "mousemove." + this.widgetName, this._mouseMoveDelegate ) | |
9377 | + .off( "mouseup." + this.widgetName, this._mouseUpDelegate ); | |
9378 | + | |
9379 | + if ( this._mouseStarted ) { | |
9380 | + this._mouseStarted = false; | |
9381 | + | |
9382 | + if ( event.target === this._mouseDownEvent.target ) { | |
9383 | + $.data( event.target, this.widgetName + ".preventClickEvent", true ); | |
9384 | + } | |
9385 | + | |
9386 | + this._mouseStop( event ); | |
9387 | + } | |
9388 | + | |
9389 | + if ( this._mouseDelayTimer ) { | |
9390 | + clearTimeout( this._mouseDelayTimer ); | |
9391 | + delete this._mouseDelayTimer; | |
9392 | + } | |
9393 | + | |
9394 | + this.ignoreMissingWhich = false; | |
9395 | + mouseHandled = false; | |
9396 | + event.preventDefault(); | |
9397 | + }, | |
9398 | + | |
9399 | + _mouseDistanceMet: function( event ) { | |
9400 | + return ( Math.max( | |
9401 | + Math.abs( this._mouseDownEvent.pageX - event.pageX ), | |
9402 | + Math.abs( this._mouseDownEvent.pageY - event.pageY ) | |
9403 | + ) >= this.options.distance | |
9404 | + ); | |
9405 | + }, | |
9406 | + | |
9407 | + _mouseDelayMet: function( /* event */ ) { | |
9408 | + return this.mouseDelayMet; | |
9409 | + }, | |
9410 | + | |
9411 | + // These are placeholder methods, to be overriden by extending plugin | |
9412 | + _mouseStart: function( /* event */ ) {}, | |
9413 | + _mouseDrag: function( /* event */ ) {}, | |
9414 | + _mouseStop: function( /* event */ ) {}, | |
9415 | + _mouseCapture: function( /* event */ ) { return true; } | |
9416 | +} ); | |
9417 | + | |
9418 | + | |
9419 | + | |
9420 | + | |
9421 | +// $.ui.plugin is deprecated. Use $.widget() extensions instead. | |
9422 | +var plugin = $.ui.plugin = { | |
9423 | + add: function( module, option, set ) { | |
9424 | + var i, | |
9425 | + proto = $.ui[ module ].prototype; | |
9426 | + for ( i in set ) { | |
9427 | + proto.plugins[ i ] = proto.plugins[ i ] || []; | |
9428 | + proto.plugins[ i ].push( [ option, set[ i ] ] ); | |
9429 | + } | |
9430 | + }, | |
9431 | + call: function( instance, name, args, allowDisconnected ) { | |
9432 | + var i, | |
9433 | + set = instance.plugins[ name ]; | |
9434 | + | |
9435 | + if ( !set ) { | |
9436 | + return; | |
9437 | + } | |
9438 | + | |
9439 | + if ( !allowDisconnected && ( !instance.element[ 0 ].parentNode || | |
9440 | + instance.element[ 0 ].parentNode.nodeType === 11 ) ) { | |
9441 | + return; | |
9442 | + } | |
9443 | + | |
9444 | + for ( i = 0; i < set.length; i++ ) { | |
9445 | + if ( instance.options[ set[ i ][ 0 ] ] ) { | |
9446 | + set[ i ][ 1 ].apply( instance.element, args ); | |
9447 | + } | |
9448 | + } | |
9449 | + } | |
9450 | +}; | |
9451 | + | |
9452 | + | |
9453 | + | |
9454 | +var safeBlur = $.ui.safeBlur = function( element ) { | |
9455 | + | |
9456 | + // Support: IE9 - 10 only | |
9457 | + // If the <body> is blurred, IE will switch windows, see #9420 | |
9458 | + if ( element && element.nodeName.toLowerCase() !== "body" ) { | |
9459 | + $( element ).trigger( "blur" ); | |
9460 | + } | |
9461 | +}; | |
9462 | + | |
9463 | + | |
9464 | +/*! | |
9465 | + * jQuery UI Draggable 1.12.0-rc.2 | |
9466 | + * http://jqueryui.com | |
9467 | + * | |
9468 | + * Copyright jQuery Foundation and other contributors | |
9469 | + * Released under the MIT license. | |
9470 | + * http://jquery.org/license | |
9471 | + */ | |
9472 | + | |
9473 | +//>>label: Draggable | |
9474 | +//>>group: Interactions | |
9475 | +//>>description: Enables dragging functionality for any element. | |
9476 | +//>>docs: http://api.jqueryui.com/draggable/ | |
9477 | +//>>demos: http://jqueryui.com/draggable/ | |
9478 | +//>>css.structure: ../../themes/base/draggable.css | |
9479 | + | |
9480 | + | |
9481 | + | |
9482 | +$.widget( "ui.draggable", $.ui.mouse, { | |
9483 | + version: "1.12.0-rc.2", | |
9484 | + widgetEventPrefix: "drag", | |
9485 | + options: { | |
9486 | + addClasses: true, | |
9487 | + appendTo: "parent", | |
9488 | + axis: false, | |
9489 | + connectToSortable: false, | |
9490 | + containment: false, | |
9491 | + cursor: "auto", | |
9492 | + cursorAt: false, | |
9493 | + grid: false, | |
9494 | + handle: false, | |
9495 | + helper: "original", | |
9496 | + iframeFix: false, | |
9497 | + opacity: false, | |
9498 | + refreshPositions: false, | |
9499 | + revert: false, | |
9500 | + revertDuration: 500, | |
9501 | + scope: "default", | |
9502 | + scroll: true, | |
9503 | + scrollSensitivity: 20, | |
9504 | + scrollSpeed: 20, | |
9505 | + snap: false, | |
9506 | + snapMode: "both", | |
9507 | + snapTolerance: 20, | |
9508 | + stack: false, | |
9509 | + zIndex: false, | |
9510 | + | |
9511 | + // Callbacks | |
9512 | + drag: null, | |
9513 | + start: null, | |
9514 | + stop: null | |
9515 | + }, | |
9516 | + _create: function() { | |
9517 | + | |
9518 | + if ( this.options.helper === "original" ) { | |
9519 | + this._setPositionRelative(); | |
9520 | + } | |
9521 | + if ( this.options.addClasses ) { | |
9522 | + this._addClass( "ui-draggable" ); | |
9523 | + } | |
9524 | + this._setHandleClassName(); | |
9525 | + | |
9526 | + this._mouseInit(); | |
9527 | + }, | |
9528 | + | |
9529 | + _setOption: function( key, value ) { | |
9530 | + this._super( key, value ); | |
9531 | + if ( key === "handle" ) { | |
9532 | + this._removeHandleClassName(); | |
9533 | + this._setHandleClassName(); | |
9534 | + } | |
9535 | + }, | |
9536 | + | |
9537 | + _destroy: function() { | |
9538 | + if ( ( this.helper || this.element ).is( ".ui-draggable-dragging" ) ) { | |
9539 | + this.destroyOnClear = true; | |
9540 | + return; | |
9541 | + } | |
9542 | + this._removeHandleClassName(); | |
9543 | + this._mouseDestroy(); | |
9544 | + }, | |
9545 | + | |
9546 | + _mouseCapture: function( event ) { | |
9547 | + var o = this.options; | |
9548 | + | |
9549 | + this._blurActiveElement( event ); | |
9550 | + | |
9551 | + // Among others, prevent a drag on a resizable-handle | |
9552 | + if ( this.helper || o.disabled || | |
9553 | + $( event.target ).closest( ".ui-resizable-handle" ).length > 0 ) { | |
9554 | + return false; | |
9555 | + } | |
9556 | + | |
9557 | + //Quit if we're not on a valid handle | |
9558 | + this.handle = this._getHandle( event ); | |
9559 | + if ( !this.handle ) { | |
9560 | + return false; | |
9561 | + } | |
9562 | + | |
9563 | + this._blockFrames( o.iframeFix === true ? "iframe" : o.iframeFix ); | |
9564 | + | |
9565 | + return true; | |
9566 | + | |
9567 | + }, | |
9568 | + | |
9569 | + _blockFrames: function( selector ) { | |
9570 | + this.iframeBlocks = this.document.find( selector ).map( function() { | |
9571 | + var iframe = $( this ); | |
9572 | + | |
9573 | + return $( "<div>" ) | |
9574 | + .css( "position", "absolute" ) | |
9575 | + .appendTo( iframe.parent() ) | |
9576 | + .outerWidth( iframe.outerWidth() ) | |
9577 | + .outerHeight( iframe.outerHeight() ) | |
9578 | + .offset( iframe.offset() )[ 0 ]; | |
9579 | + } ); | |
9580 | + }, | |
9581 | + | |
9582 | + _unblockFrames: function() { | |
9583 | + if ( this.iframeBlocks ) { | |
9584 | + this.iframeBlocks.remove(); | |
9585 | + delete this.iframeBlocks; | |
9586 | + } | |
9587 | + }, | |
9588 | + | |
9589 | + _blurActiveElement: function( event ) { | |
9590 | + var activeElement = $.ui.safeActiveElement( this.document[ 0 ] ), | |
9591 | + target = $( event.target ); | |
9592 | + | |
9593 | + // Only blur if the event occurred on an element that is: | |
9594 | + // 1) within the draggable handle | |
9595 | + // 2) but not within the currently focused element | |
9596 | + // See #10527, #12472 | |
9597 | + if ( this._getHandle( event ) && target.closest( activeElement ).length ) { | |
9598 | + return; | |
9599 | + } | |
9600 | + | |
9601 | + // Blur any element that currently has focus, see #4261 | |
9602 | + $.ui.safeBlur( activeElement ); | |
9603 | + }, | |
9604 | + | |
9605 | + _mouseStart: function( event ) { | |
9606 | + | |
9607 | + var o = this.options; | |
9608 | + | |
9609 | + //Create and append the visible helper | |
9610 | + this.helper = this._createHelper( event ); | |
9611 | + | |
9612 | + this._addClass( this.helper, "ui-draggable-dragging" ); | |
9613 | + | |
9614 | + //Cache the helper size | |
9615 | + this._cacheHelperProportions(); | |
9616 | + | |
9617 | + //If ddmanager is used for droppables, set the global draggable | |
9618 | + if ( $.ui.ddmanager ) { | |
9619 | + $.ui.ddmanager.current = this; | |
9620 | + } | |
9621 | + | |
9622 | + /* | |
9623 | + * - Position generation - | |
9624 | + * This block generates everything position related - it's the core of draggables. | |
9625 | + */ | |
9626 | + | |
9627 | + //Cache the margins of the original element | |
9628 | + this._cacheMargins(); | |
9629 | + | |
9630 | + //Store the helper's css position | |
9631 | + this.cssPosition = this.helper.css( "position" ); | |
9632 | + this.scrollParent = this.helper.scrollParent( true ); | |
9633 | + this.offsetParent = this.helper.offsetParent(); | |
9634 | + this.hasFixedAncestor = this.helper.parents().filter( function() { | |
9635 | + return $( this ).css( "position" ) === "fixed"; | |
9636 | + } ).length > 0; | |
9637 | + | |
9638 | + //The element's absolute position on the page minus margins | |
9639 | + this.positionAbs = this.element.offset(); | |
9640 | + this._refreshOffsets( event ); | |
9641 | + | |
9642 | + //Generate the original position | |
9643 | + this.originalPosition = this.position = this._generatePosition( event, false ); | |
9644 | + this.originalPageX = event.pageX; | |
9645 | + this.originalPageY = event.pageY; | |
9646 | + | |
9647 | + //Adjust the mouse offset relative to the helper if "cursorAt" is supplied | |
9648 | + ( o.cursorAt && this._adjustOffsetFromHelper( o.cursorAt ) ); | |
9649 | + | |
9650 | + //Set a containment if given in the options | |
9651 | + this._setContainment(); | |
9652 | + | |
9653 | + //Trigger event + callbacks | |
9654 | + if ( this._trigger( "start", event ) === false ) { | |
9655 | + this._clear(); | |
9656 | + return false; | |
9657 | + } | |
9658 | + | |
9659 | + //Recache the helper size | |
9660 | + this._cacheHelperProportions(); | |
9661 | + | |
9662 | + //Prepare the droppable offsets | |
9663 | + if ( $.ui.ddmanager && !o.dropBehaviour ) { | |
9664 | + $.ui.ddmanager.prepareOffsets( this, event ); | |
9665 | + } | |
9666 | + | |
9667 | + // Execute the drag once - this causes the helper not to be visible before getting its | |
9668 | + // correct position | |
9669 | + this._mouseDrag( event, true ); | |
9670 | + | |
9671 | + // If the ddmanager is used for droppables, inform the manager that dragging has started | |
9672 | + // (see #5003) | |
9673 | + if ( $.ui.ddmanager ) { | |
9674 | + $.ui.ddmanager.dragStart( this, event ); | |
9675 | + } | |
9676 | + | |
9677 | + return true; | |
9678 | + }, | |
9679 | + | |
9680 | + _refreshOffsets: function( event ) { | |
9681 | + this.offset = { | |
9682 | + top: this.positionAbs.top - this.margins.top, | |
9683 | + left: this.positionAbs.left - this.margins.left, | |
9684 | + scroll: false, | |
9685 | + parent: this._getParentOffset(), | |
9686 | + relative: this._getRelativeOffset() | |
9687 | + }; | |
9688 | + | |
9689 | + this.offset.click = { | |
9690 | + left: event.pageX - this.offset.left, | |
9691 | + top: event.pageY - this.offset.top | |
9692 | + }; | |
9693 | + }, | |
9694 | + | |
9695 | + _mouseDrag: function( event, noPropagation ) { | |
9696 | + | |
9697 | + // reset any necessary cached properties (see #5009) | |
9698 | + if ( this.hasFixedAncestor ) { | |
9699 | + this.offset.parent = this._getParentOffset(); | |
9700 | + } | |
9701 | + | |
9702 | + //Compute the helpers position | |
9703 | + this.position = this._generatePosition( event, true ); | |
9704 | + this.positionAbs = this._convertPositionTo( "absolute" ); | |
9705 | + | |
9706 | + //Call plugins and callbacks and use the resulting position if something is returned | |
9707 | + if ( !noPropagation ) { | |
9708 | + var ui = this._uiHash(); | |
9709 | + if ( this._trigger( "drag", event, ui ) === false ) { | |
9710 | + this._mouseUp( new $.Event( "mouseup", event ) ); | |
9711 | + return false; | |
9712 | + } | |
9713 | + this.position = ui.position; | |
9714 | + } | |
9715 | + | |
9716 | + this.helper[ 0 ].style.left = this.position.left + "px"; | |
9717 | + this.helper[ 0 ].style.top = this.position.top + "px"; | |
9718 | + | |
9719 | + if ( $.ui.ddmanager ) { | |
9720 | + $.ui.ddmanager.drag( this, event ); | |
9721 | + } | |
9722 | + | |
9723 | + return false; | |
9724 | + }, | |
9725 | + | |
9726 | + _mouseStop: function( event ) { | |
9727 | + | |
9728 | + //If we are using droppables, inform the manager about the drop | |
9729 | + var that = this, | |
9730 | + dropped = false; | |
9731 | + if ( $.ui.ddmanager && !this.options.dropBehaviour ) { | |
9732 | + dropped = $.ui.ddmanager.drop( this, event ); | |
9733 | + } | |
9734 | + | |
9735 | + //if a drop comes from outside (a sortable) | |
9736 | + if ( this.dropped ) { | |
9737 | + dropped = this.dropped; | |
9738 | + this.dropped = false; | |
9739 | + } | |
9740 | + | |
9741 | + if ( ( this.options.revert === "invalid" && !dropped ) || | |
9742 | + ( this.options.revert === "valid" && dropped ) || | |
9743 | + this.options.revert === true || ( $.isFunction( this.options.revert ) && | |
9744 | + this.options.revert.call( this.element, dropped ) ) | |
9745 | + ) { | |
9746 | + $( this.helper ).animate( | |
9747 | + this.originalPosition, | |
9748 | + parseInt( this.options.revertDuration, 10 ), | |
9749 | + function() { | |
9750 | + if ( that._trigger( "stop", event ) !== false ) { | |
9751 | + that._clear(); | |
9752 | + } | |
9753 | + } | |
9754 | + ); | |
9755 | + } else { | |
9756 | + if ( this._trigger( "stop", event ) !== false ) { | |
9757 | + this._clear(); | |
9758 | + } | |
9759 | + } | |
9760 | + | |
9761 | + return false; | |
9762 | + }, | |
9763 | + | |
9764 | + _mouseUp: function( event ) { | |
9765 | + this._unblockFrames(); | |
9766 | + | |
9767 | + // If the ddmanager is used for droppables, inform the manager that dragging has stopped | |
9768 | + // (see #5003) | |
9769 | + if ( $.ui.ddmanager ) { | |
9770 | + $.ui.ddmanager.dragStop( this, event ); | |
9771 | + } | |
9772 | + | |
9773 | + // Only need to focus if the event occurred on the draggable itself, see #10527 | |
9774 | + if ( this.handleElement.is( event.target ) ) { | |
9775 | + | |
9776 | + // The interaction is over; whether or not the click resulted in a drag, | |
9777 | + // focus the element | |
9778 | + this.element.trigger( "focus" ); | |
9779 | + } | |
9780 | + | |
9781 | + return $.ui.mouse.prototype._mouseUp.call( this, event ); | |
9782 | + }, | |
9783 | + | |
9784 | + cancel: function() { | |
9785 | + | |
9786 | + if ( this.helper.is( ".ui-draggable-dragging" ) ) { | |
9787 | + this._mouseUp( new $.Event( "mouseup", { target: this.element[ 0 ] } ) ); | |
9788 | + } else { | |
9789 | + this._clear(); | |
9790 | + } | |
9791 | + | |
9792 | + return this; | |
9793 | + | |
9794 | + }, | |
9795 | + | |
9796 | + _getHandle: function( event ) { | |
9797 | + return this.options.handle ? | |
9798 | + !!$( event.target ).closest( this.element.find( this.options.handle ) ).length : | |
9799 | + true; | |
9800 | + }, | |
9801 | + | |
9802 | + _setHandleClassName: function() { | |
9803 | + this.handleElement = this.options.handle ? | |
9804 | + this.element.find( this.options.handle ) : this.element; | |
9805 | + this._addClass( this.handleElement, "ui-draggable-handle" ); | |
9806 | + }, | |
9807 | + | |
9808 | + _removeHandleClassName: function() { | |
9809 | + this._removeClass( this.handleElement, "ui-draggable-handle" ); | |
9810 | + }, | |
9811 | + | |
9812 | + _createHelper: function( event ) { | |
9813 | + | |
9814 | + var o = this.options, | |
9815 | + helperIsFunction = $.isFunction( o.helper ), | |
9816 | + helper = helperIsFunction ? | |
9817 | + $( o.helper.apply( this.element[ 0 ], [ event ] ) ) : | |
9818 | + ( o.helper === "clone" ? | |
9819 | + this.element.clone().removeAttr( "id" ) : | |
9820 | + this.element ); | |
9821 | + | |
9822 | + if ( !helper.parents( "body" ).length ) { | |
9823 | + helper.appendTo( ( o.appendTo === "parent" ? | |
9824 | + this.element[ 0 ].parentNode : | |
9825 | + o.appendTo ) ); | |
9826 | + } | |
9827 | + | |
9828 | + // Http://bugs.jqueryui.com/ticket/9446 | |
9829 | + // a helper function can return the original element | |
9830 | + // which wouldn't have been set to relative in _create | |
9831 | + if ( helperIsFunction && helper[ 0 ] === this.element[ 0 ] ) { | |
9832 | + this._setPositionRelative(); | |
9833 | + } | |
9834 | + | |
9835 | + if ( helper[ 0 ] !== this.element[ 0 ] && | |
9836 | + !( /(fixed|absolute)/ ).test( helper.css( "position" ) ) ) { | |
9837 | + helper.css( "position", "absolute" ); | |
9838 | + } | |
9839 | + | |
9840 | + return helper; | |
9841 | + | |
9842 | + }, | |
9843 | + | |
9844 | + _setPositionRelative: function() { | |
9845 | + if ( !( /^(?:r|a|f)/ ).test( this.element.css( "position" ) ) ) { | |
9846 | + this.element[ 0 ].style.position = "relative"; | |
9847 | + } | |
9848 | + }, | |
9849 | + | |
9850 | + _adjustOffsetFromHelper: function( obj ) { | |
9851 | + if ( typeof obj === "string" ) { | |
9852 | + obj = obj.split( " " ); | |
9853 | + } | |
9854 | + if ( $.isArray( obj ) ) { | |
9855 | + obj = { left: +obj[ 0 ], top: +obj[ 1 ] || 0 }; | |
9856 | + } | |
9857 | + if ( "left" in obj ) { | |
9858 | + this.offset.click.left = obj.left + this.margins.left; | |
9859 | + } | |
9860 | + if ( "right" in obj ) { | |
9861 | + this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left; | |
9862 | + } | |
9863 | + if ( "top" in obj ) { | |
9864 | + this.offset.click.top = obj.top + this.margins.top; | |
9865 | + } | |
9866 | + if ( "bottom" in obj ) { | |
9867 | + this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top; | |
9868 | + } | |
9869 | + }, | |
9870 | + | |
9871 | + _isRootNode: function( element ) { | |
9872 | + return ( /(html|body)/i ).test( element.tagName ) || element === this.document[ 0 ]; | |
9873 | + }, | |
9874 | + | |
9875 | + _getParentOffset: function() { | |
9876 | + | |
9877 | + //Get the offsetParent and cache its position | |
9878 | + var po = this.offsetParent.offset(), | |
9879 | + document = this.document[ 0 ]; | |
9880 | + | |
9881 | + // This is a special case where we need to modify a offset calculated on start, since the | |
9882 | + // following happened: | |
9883 | + // 1. The position of the helper is absolute, so it's position is calculated based on the | |
9884 | + // next positioned parent | |
9885 | + // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't | |
9886 | + // the document, which means that the scroll is included in the initial calculation of the | |
9887 | + // offset of the parent, and never recalculated upon drag | |
9888 | + if ( this.cssPosition === "absolute" && this.scrollParent[ 0 ] !== document && | |
9889 | + $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) { | |
9890 | + po.left += this.scrollParent.scrollLeft(); | |
9891 | + po.top += this.scrollParent.scrollTop(); | |
9892 | + } | |
9893 | + | |
9894 | + if ( this._isRootNode( this.offsetParent[ 0 ] ) ) { | |
9895 | + po = { top: 0, left: 0 }; | |
9896 | + } | |
9897 | + | |
9898 | + return { | |
9899 | + top: po.top + ( parseInt( this.offsetParent.css( "borderTopWidth" ), 10 ) || 0 ), | |
9900 | + left: po.left + ( parseInt( this.offsetParent.css( "borderLeftWidth" ), 10 ) || 0 ) | |
9901 | + }; | |
9902 | + | |
9903 | + }, | |
9904 | + | |
9905 | + _getRelativeOffset: function() { | |
9906 | + if ( this.cssPosition !== "relative" ) { | |
9907 | + return { top: 0, left: 0 }; | |
9908 | + } | |
9909 | + | |
9910 | + var p = this.element.position(), | |
9911 | + scrollIsRootNode = this._isRootNode( this.scrollParent[ 0 ] ); | |
9912 | + | |
9913 | + return { | |
9914 | + top: p.top - ( parseInt( this.helper.css( "top" ), 10 ) || 0 ) + | |
9915 | + ( !scrollIsRootNode ? this.scrollParent.scrollTop() : 0 ), | |
9916 | + left: p.left - ( parseInt( this.helper.css( "left" ), 10 ) || 0 ) + | |
9917 | + ( !scrollIsRootNode ? this.scrollParent.scrollLeft() : 0 ) | |
9918 | + }; | |
9919 | + | |
9920 | + }, | |
9921 | + | |
9922 | + _cacheMargins: function() { | |
9923 | + this.margins = { | |
9924 | + left: ( parseInt( this.element.css( "marginLeft" ), 10 ) || 0 ), | |
9925 | + top: ( parseInt( this.element.css( "marginTop" ), 10 ) || 0 ), | |
9926 | + right: ( parseInt( this.element.css( "marginRight" ), 10 ) || 0 ), | |
9927 | + bottom: ( parseInt( this.element.css( "marginBottom" ), 10 ) || 0 ) | |
9928 | + }; | |
9929 | + }, | |
9930 | + | |
9931 | + _cacheHelperProportions: function() { | |
9932 | + this.helperProportions = { | |
9933 | + width: this.helper.outerWidth(), | |
9934 | + height: this.helper.outerHeight() | |
9935 | + }; | |
9936 | + }, | |
9937 | + | |
9938 | + _setContainment: function() { | |
9939 | + | |
9940 | + var isUserScrollable, c, ce, | |
9941 | + o = this.options, | |
9942 | + document = this.document[ 0 ]; | |
9943 | + | |
9944 | + this.relativeContainer = null; | |
9945 | + | |
9946 | + if ( !o.containment ) { | |
9947 | + this.containment = null; | |
9948 | + return; | |
9949 | + } | |
9950 | + | |
9951 | + if ( o.containment === "window" ) { | |
9952 | + this.containment = [ | |
9953 | + $( window ).scrollLeft() - this.offset.relative.left - this.offset.parent.left, | |
9954 | + $( window ).scrollTop() - this.offset.relative.top - this.offset.parent.top, | |
9955 | + $( window ).scrollLeft() + $( window ).width() - | |
9956 | + this.helperProportions.width - this.margins.left, | |
9957 | + $( window ).scrollTop() + | |
9958 | + ( $( window ).height() || document.body.parentNode.scrollHeight ) - | |
9959 | + this.helperProportions.height - this.margins.top | |
9960 | + ]; | |
9961 | + return; | |
9962 | + } | |
9963 | + | |
9964 | + if ( o.containment === "document" ) { | |
9965 | + this.containment = [ | |
9966 | + 0, | |
9967 | + 0, | |
9968 | + $( document ).width() - this.helperProportions.width - this.margins.left, | |
9969 | + ( $( document ).height() || document.body.parentNode.scrollHeight ) - | |
9970 | + this.helperProportions.height - this.margins.top | |
9971 | + ]; | |
9972 | + return; | |
9973 | + } | |
9974 | + | |
9975 | + if ( o.containment.constructor === Array ) { | |
9976 | + this.containment = o.containment; | |
9977 | + return; | |
9978 | + } | |
9979 | + | |
9980 | + if ( o.containment === "parent" ) { | |
9981 | + o.containment = this.helper[ 0 ].parentNode; | |
9982 | + } | |
9983 | + | |
9984 | + c = $( o.containment ); | |
9985 | + ce = c[ 0 ]; | |
9986 | + | |
9987 | + if ( !ce ) { | |
9988 | + return; | |
9989 | + } | |
9990 | + | |
9991 | + isUserScrollable = /(scroll|auto)/.test( c.css( "overflow" ) ); | |
9992 | + | |
9993 | + this.containment = [ | |
9994 | + ( parseInt( c.css( "borderLeftWidth" ), 10 ) || 0 ) + | |
9995 | + ( parseInt( c.css( "paddingLeft" ), 10 ) || 0 ), | |
9996 | + ( parseInt( c.css( "borderTopWidth" ), 10 ) || 0 ) + | |
9997 | + ( parseInt( c.css( "paddingTop" ), 10 ) || 0 ), | |
9998 | + ( isUserScrollable ? Math.max( ce.scrollWidth, ce.offsetWidth ) : ce.offsetWidth ) - | |
9999 | + ( parseInt( c.css( "borderRightWidth" ), 10 ) || 0 ) - | |
10000 | + ( parseInt( c.css( "paddingRight" ), 10 ) || 0 ) - | |
10001 | + this.helperProportions.width - | |
10002 | + this.margins.left - | |
10003 | + this.margins.right, | |
10004 | + ( isUserScrollable ? Math.max( ce.scrollHeight, ce.offsetHeight ) : ce.offsetHeight ) - | |
10005 | + ( parseInt( c.css( "borderBottomWidth" ), 10 ) || 0 ) - | |
10006 | + ( parseInt( c.css( "paddingBottom" ), 10 ) || 0 ) - | |
10007 | + this.helperProportions.height - | |
10008 | + this.margins.top - | |
10009 | + this.margins.bottom | |
10010 | + ]; | |
10011 | + this.relativeContainer = c; | |
10012 | + }, | |
10013 | + | |
10014 | + _convertPositionTo: function( d, pos ) { | |
10015 | + | |
10016 | + if ( !pos ) { | |
10017 | + pos = this.position; | |
10018 | + } | |
10019 | + | |
10020 | + var mod = d === "absolute" ? 1 : -1, | |
10021 | + scrollIsRootNode = this._isRootNode( this.scrollParent[ 0 ] ); | |
10022 | + | |
10023 | + return { | |
10024 | + top: ( | |
10025 | + | |
10026 | + // The absolute mouse position | |
10027 | + pos.top + | |
10028 | + | |
10029 | + // Only for relative positioned nodes: Relative offset from element to offset parent | |
10030 | + this.offset.relative.top * mod + | |
10031 | + | |
10032 | + // The offsetParent's offset without borders (offset + border) | |
10033 | + this.offset.parent.top * mod - | |
10034 | + ( ( this.cssPosition === "fixed" ? | |
10035 | + -this.offset.scroll.top : | |
10036 | + ( scrollIsRootNode ? 0 : this.offset.scroll.top ) ) * mod ) | |
10037 | + ), | |
10038 | + left: ( | |
10039 | + | |
10040 | + // The absolute mouse position | |
10041 | + pos.left + | |
10042 | + | |
10043 | + // Only for relative positioned nodes: Relative offset from element to offset parent | |
10044 | + this.offset.relative.left * mod + | |
10045 | + | |
10046 | + // The offsetParent's offset without borders (offset + border) | |
10047 | + this.offset.parent.left * mod - | |
10048 | + ( ( this.cssPosition === "fixed" ? | |
10049 | + -this.offset.scroll.left : | |
10050 | + ( scrollIsRootNode ? 0 : this.offset.scroll.left ) ) * mod ) | |
10051 | + ) | |
10052 | + }; | |
10053 | + | |
10054 | + }, | |
10055 | + | |
10056 | + _generatePosition: function( event, constrainPosition ) { | |
10057 | + | |
10058 | + var containment, co, top, left, | |
10059 | + o = this.options, | |
10060 | + scrollIsRootNode = this._isRootNode( this.scrollParent[ 0 ] ), | |
10061 | + pageX = event.pageX, | |
10062 | + pageY = event.pageY; | |
10063 | + | |
10064 | + // Cache the scroll | |
10065 | + if ( !scrollIsRootNode || !this.offset.scroll ) { | |
10066 | + this.offset.scroll = { | |
10067 | + top: this.scrollParent.scrollTop(), | |
10068 | + left: this.scrollParent.scrollLeft() | |
10069 | + }; | |
10070 | + } | |
10071 | + | |
10072 | + /* | |
10073 | + * - Position constraining - | |
10074 | + * Constrain the position to a mix of grid, containment. | |
10075 | + */ | |
10076 | + | |
10077 | + // If we are not dragging yet, we won't check for options | |
10078 | + if ( constrainPosition ) { | |
10079 | + if ( this.containment ) { | |
10080 | + if ( this.relativeContainer ) { | |
10081 | + co = this.relativeContainer.offset(); | |
10082 | + containment = [ | |
10083 | + this.containment[ 0 ] + co.left, | |
10084 | + this.containment[ 1 ] + co.top, | |
10085 | + this.containment[ 2 ] + co.left, | |
10086 | + this.containment[ 3 ] + co.top | |
10087 | + ]; | |
10088 | + } else { | |
10089 | + containment = this.containment; | |
10090 | + } | |
10091 | + | |
10092 | + if ( event.pageX - this.offset.click.left < containment[ 0 ] ) { | |
10093 | + pageX = containment[ 0 ] + this.offset.click.left; | |
10094 | + } | |
10095 | + if ( event.pageY - this.offset.click.top < containment[ 1 ] ) { | |
10096 | + pageY = containment[ 1 ] + this.offset.click.top; | |
10097 | + } | |
10098 | + if ( event.pageX - this.offset.click.left > containment[ 2 ] ) { | |
10099 | + pageX = containment[ 2 ] + this.offset.click.left; | |
10100 | + } | |
10101 | + if ( event.pageY - this.offset.click.top > containment[ 3 ] ) { | |
10102 | + pageY = containment[ 3 ] + this.offset.click.top; | |
10103 | + } | |
10104 | + } | |
10105 | + | |
10106 | + if ( o.grid ) { | |
10107 | + | |
10108 | + //Check for grid elements set to 0 to prevent divide by 0 error causing invalid | |
10109 | + // argument errors in IE (see ticket #6950) | |
10110 | + top = o.grid[ 1 ] ? this.originalPageY + Math.round( ( pageY - | |
10111 | + this.originalPageY ) / o.grid[ 1 ] ) * o.grid[ 1 ] : this.originalPageY; | |
10112 | + pageY = containment ? ( ( top - this.offset.click.top >= containment[ 1 ] || | |
10113 | + top - this.offset.click.top > containment[ 3 ] ) ? | |
10114 | + top : | |
10115 | + ( ( top - this.offset.click.top >= containment[ 1 ] ) ? | |
10116 | + top - o.grid[ 1 ] : top + o.grid[ 1 ] ) ) : top; | |
10117 | + | |
10118 | + left = o.grid[ 0 ] ? this.originalPageX + | |
10119 | + Math.round( ( pageX - this.originalPageX ) / o.grid[ 0 ] ) * o.grid[ 0 ] : | |
10120 | + this.originalPageX; | |
10121 | + pageX = containment ? ( ( left - this.offset.click.left >= containment[ 0 ] || | |
10122 | + left - this.offset.click.left > containment[ 2 ] ) ? | |
10123 | + left : | |
10124 | + ( ( left - this.offset.click.left >= containment[ 0 ] ) ? | |
10125 | + left - o.grid[ 0 ] : left + o.grid[ 0 ] ) ) : left; | |
10126 | + } | |
10127 | + | |
10128 | + if ( o.axis === "y" ) { | |
10129 | + pageX = this.originalPageX; | |
10130 | + } | |
10131 | + | |
10132 | + if ( o.axis === "x" ) { | |
10133 | + pageY = this.originalPageY; | |
10134 | + } | |
10135 | + } | |
10136 | + | |
10137 | + return { | |
10138 | + top: ( | |
10139 | + | |
10140 | + // The absolute mouse position | |
10141 | + pageY - | |
10142 | + | |
10143 | + // Click offset (relative to the element) | |
10144 | + this.offset.click.top - | |
10145 | + | |
10146 | + // Only for relative positioned nodes: Relative offset from element to offset parent | |
10147 | + this.offset.relative.top - | |
10148 | + | |
10149 | + // The offsetParent's offset without borders (offset + border) | |
10150 | + this.offset.parent.top + | |
10151 | + ( this.cssPosition === "fixed" ? | |
10152 | + -this.offset.scroll.top : | |
10153 | + ( scrollIsRootNode ? 0 : this.offset.scroll.top ) ) | |
10154 | + ), | |
10155 | + left: ( | |
10156 | + | |
10157 | + // The absolute mouse position | |
10158 | + pageX - | |
10159 | + | |
10160 | + // Click offset (relative to the element) | |
10161 | + this.offset.click.left - | |
10162 | + | |
10163 | + // Only for relative positioned nodes: Relative offset from element to offset parent | |
10164 | + this.offset.relative.left - | |
10165 | + | |
10166 | + // The offsetParent's offset without borders (offset + border) | |
10167 | + this.offset.parent.left + | |
10168 | + ( this.cssPosition === "fixed" ? | |
10169 | + -this.offset.scroll.left : | |
10170 | + ( scrollIsRootNode ? 0 : this.offset.scroll.left ) ) | |
10171 | + ) | |
10172 | + }; | |
10173 | + | |
10174 | + }, | |
10175 | + | |
10176 | + _clear: function() { | |
10177 | + this._removeClass( this.helper, "ui-draggable-dragging" ); | |
10178 | + if ( this.helper[ 0 ] !== this.element[ 0 ] && !this.cancelHelperRemoval ) { | |
10179 | + this.helper.remove(); | |
10180 | + } | |
10181 | + this.helper = null; | |
10182 | + this.cancelHelperRemoval = false; | |
10183 | + if ( this.destroyOnClear ) { | |
10184 | + this.destroy(); | |
10185 | + } | |
10186 | + }, | |
10187 | + | |
10188 | + // From now on bulk stuff - mainly helpers | |
10189 | + | |
10190 | + _trigger: function( type, event, ui ) { | |
10191 | + ui = ui || this._uiHash(); | |
10192 | + $.ui.plugin.call( this, type, [ event, ui, this ], true ); | |
10193 | + | |
10194 | + // Absolute position and offset (see #6884 ) have to be recalculated after plugins | |
10195 | + if ( /^(drag|start|stop)/.test( type ) ) { | |
10196 | + this.positionAbs = this._convertPositionTo( "absolute" ); | |
10197 | + ui.offset = this.positionAbs; | |
10198 | + } | |
10199 | + return $.Widget.prototype._trigger.call( this, type, event, ui ); | |
10200 | + }, | |
10201 | + | |
10202 | + plugins: {}, | |
10203 | + | |
10204 | + _uiHash: function() { | |
10205 | + return { | |
10206 | + helper: this.helper, | |
10207 | + position: this.position, | |
10208 | + originalPosition: this.originalPosition, | |
10209 | + offset: this.positionAbs | |
10210 | + }; | |
10211 | + } | |
10212 | + | |
10213 | +} ); | |
10214 | + | |
10215 | +$.ui.plugin.add( "draggable", "connectToSortable", { | |
10216 | + start: function( event, ui, draggable ) { | |
10217 | + var uiSortable = $.extend( {}, ui, { | |
10218 | + item: draggable.element | |
10219 | + } ); | |
10220 | + | |
10221 | + draggable.sortables = []; | |
10222 | + $( draggable.options.connectToSortable ).each( function() { | |
10223 | + var sortable = $( this ).sortable( "instance" ); | |
10224 | + | |
10225 | + if ( sortable && !sortable.options.disabled ) { | |
10226 | + draggable.sortables.push( sortable ); | |
10227 | + | |
10228 | + // RefreshPositions is called at drag start to refresh the containerCache | |
10229 | + // which is used in drag. This ensures it's initialized and synchronized | |
10230 | + // with any changes that might have happened on the page since initialization. | |
10231 | + sortable.refreshPositions(); | |
10232 | + sortable._trigger( "activate", event, uiSortable ); | |
10233 | + } | |
10234 | + } ); | |
10235 | + }, | |
10236 | + stop: function( event, ui, draggable ) { | |
10237 | + var uiSortable = $.extend( {}, ui, { | |
10238 | + item: draggable.element | |
10239 | + } ); | |
10240 | + | |
10241 | + draggable.cancelHelperRemoval = false; | |
10242 | + | |
10243 | + $.each( draggable.sortables, function() { | |
10244 | + var sortable = this; | |
10245 | + | |
10246 | + if ( sortable.isOver ) { | |
10247 | + sortable.isOver = 0; | |
10248 | + | |
10249 | + // Allow this sortable to handle removing the helper | |
10250 | + draggable.cancelHelperRemoval = true; | |
10251 | + sortable.cancelHelperRemoval = false; | |
10252 | + | |
10253 | + // Use _storedCSS To restore properties in the sortable, | |
10254 | + // as this also handles revert (#9675) since the draggable | |
10255 | + // may have modified them in unexpected ways (#8809) | |
10256 | + sortable._storedCSS = { | |
10257 | + position: sortable.placeholder.css( "position" ), | |
10258 | + top: sortable.placeholder.css( "top" ), | |
10259 | + left: sortable.placeholder.css( "left" ) | |
10260 | + }; | |
10261 | + | |
10262 | + sortable._mouseStop( event ); | |
10263 | + | |
10264 | + // Once drag has ended, the sortable should return to using | |
10265 | + // its original helper, not the shared helper from draggable | |
10266 | + sortable.options.helper = sortable.options._helper; | |
10267 | + } else { | |
10268 | + | |
10269 | + // Prevent this Sortable from removing the helper. | |
10270 | + // However, don't set the draggable to remove the helper | |
10271 | + // either as another connected Sortable may yet handle the removal. | |
10272 | + sortable.cancelHelperRemoval = true; | |
10273 | + | |
10274 | + sortable._trigger( "deactivate", event, uiSortable ); | |
10275 | + } | |
10276 | + } ); | |
10277 | + }, | |
10278 | + drag: function( event, ui, draggable ) { | |
10279 | + $.each( draggable.sortables, function() { | |
10280 | + var innermostIntersecting = false, | |
10281 | + sortable = this; | |
10282 | + | |
10283 | + // Copy over variables that sortable's _intersectsWith uses | |
10284 | + sortable.positionAbs = draggable.positionAbs; | |
10285 | + sortable.helperProportions = draggable.helperProportions; | |
10286 | + sortable.offset.click = draggable.offset.click; | |
10287 | + | |
10288 | + if ( sortable._intersectsWith( sortable.containerCache ) ) { | |
10289 | + innermostIntersecting = true; | |
10290 | + | |
10291 | + $.each( draggable.sortables, function() { | |
10292 | + | |
10293 | + // Copy over variables that sortable's _intersectsWith uses | |
10294 | + this.positionAbs = draggable.positionAbs; | |
10295 | + this.helperProportions = draggable.helperProportions; | |
10296 | + this.offset.click = draggable.offset.click; | |
10297 | + | |
10298 | + if ( this !== sortable && | |
10299 | + this._intersectsWith( this.containerCache ) && | |
10300 | + $.contains( sortable.element[ 0 ], this.element[ 0 ] ) ) { | |
10301 | + innermostIntersecting = false; | |
10302 | + } | |
10303 | + | |
10304 | + return innermostIntersecting; | |
10305 | + } ); | |
10306 | + } | |
10307 | + | |
10308 | + if ( innermostIntersecting ) { | |
10309 | + | |
10310 | + // If it intersects, we use a little isOver variable and set it once, | |
10311 | + // so that the move-in stuff gets fired only once. | |
10312 | + if ( !sortable.isOver ) { | |
10313 | + sortable.isOver = 1; | |
10314 | + | |
10315 | + // Store draggable's parent in case we need to reappend to it later. | |
10316 | + draggable._parent = ui.helper.parent(); | |
10317 | + | |
10318 | + sortable.currentItem = ui.helper | |
10319 | + .appendTo( sortable.element ) | |
10320 | + .data( "ui-sortable-item", true ); | |
10321 | + | |
10322 | + // Store helper option to later restore it | |
10323 | + sortable.options._helper = sortable.options.helper; | |
10324 | + | |
10325 | + sortable.options.helper = function() { | |
10326 | + return ui.helper[ 0 ]; | |
10327 | + }; | |
10328 | + | |
10329 | + // Fire the start events of the sortable with our passed browser event, | |
10330 | + // and our own helper (so it doesn't create a new one) | |
10331 | + event.target = sortable.currentItem[ 0 ]; | |
10332 | + sortable._mouseCapture( event, true ); | |
10333 | + sortable._mouseStart( event, true, true ); | |
10334 | + | |
10335 | + // Because the browser event is way off the new appended portlet, | |
10336 | + // modify necessary variables to reflect the changes | |
10337 | + sortable.offset.click.top = draggable.offset.click.top; | |
10338 | + sortable.offset.click.left = draggable.offset.click.left; | |
10339 | + sortable.offset.parent.left -= draggable.offset.parent.left - | |
10340 | + sortable.offset.parent.left; | |
10341 | + sortable.offset.parent.top -= draggable.offset.parent.top - | |
10342 | + sortable.offset.parent.top; | |
10343 | + | |
10344 | + draggable._trigger( "toSortable", event ); | |
10345 | + | |
10346 | + // Inform draggable that the helper is in a valid drop zone, | |
10347 | + // used solely in the revert option to handle "valid/invalid". | |
10348 | + draggable.dropped = sortable.element; | |
10349 | + | |
10350 | + // Need to refreshPositions of all sortables in the case that | |
10351 | + // adding to one sortable changes the location of the other sortables (#9675) | |
10352 | + $.each( draggable.sortables, function() { | |
10353 | + this.refreshPositions(); | |
10354 | + } ); | |
10355 | + | |
10356 | + // Hack so receive/update callbacks work (mostly) | |
10357 | + draggable.currentItem = draggable.element; | |
10358 | + sortable.fromOutside = draggable; | |
10359 | + } | |
10360 | + | |
10361 | + if ( sortable.currentItem ) { | |
10362 | + sortable._mouseDrag( event ); | |
10363 | + | |
10364 | + // Copy the sortable's position because the draggable's can potentially reflect | |
10365 | + // a relative position, while sortable is always absolute, which the dragged | |
10366 | + // element has now become. (#8809) | |
10367 | + ui.position = sortable.position; | |
10368 | + } | |
10369 | + } else { | |
10370 | + | |
10371 | + // If it doesn't intersect with the sortable, and it intersected before, | |
10372 | + // we fake the drag stop of the sortable, but make sure it doesn't remove | |
10373 | + // the helper by using cancelHelperRemoval. | |
10374 | + if ( sortable.isOver ) { | |
10375 | + | |
10376 | + sortable.isOver = 0; | |
10377 | + sortable.cancelHelperRemoval = true; | |
10378 | + | |
10379 | + // Calling sortable's mouseStop would trigger a revert, | |
10380 | + // so revert must be temporarily false until after mouseStop is called. | |
10381 | + sortable.options._revert = sortable.options.revert; | |
10382 | + sortable.options.revert = false; | |
10383 | + | |
10384 | + sortable._trigger( "out", event, sortable._uiHash( sortable ) ); | |
10385 | + sortable._mouseStop( event, true ); | |
10386 | + | |
10387 | + // Restore sortable behaviors that were modfied | |
10388 | + // when the draggable entered the sortable area (#9481) | |
10389 | + sortable.options.revert = sortable.options._revert; | |
10390 | + sortable.options.helper = sortable.options._helper; | |
10391 | + | |
10392 | + if ( sortable.placeholder ) { | |
10393 | + sortable.placeholder.remove(); | |
10394 | + } | |
10395 | + | |
10396 | + // Restore and recalculate the draggable's offset considering the sortable | |
10397 | + // may have modified them in unexpected ways. (#8809, #10669) | |
10398 | + ui.helper.appendTo( draggable._parent ); | |
10399 | + draggable._refreshOffsets( event ); | |
10400 | + ui.position = draggable._generatePosition( event, true ); | |
10401 | + | |
10402 | + draggable._trigger( "fromSortable", event ); | |
10403 | + | |
10404 | + // Inform draggable that the helper is no longer in a valid drop zone | |
10405 | + draggable.dropped = false; | |
10406 | + | |
10407 | + // Need to refreshPositions of all sortables just in case removing | |
10408 | + // from one sortable changes the location of other sortables (#9675) | |
10409 | + $.each( draggable.sortables, function() { | |
10410 | + this.refreshPositions(); | |
10411 | + } ); | |
10412 | + } | |
10413 | + } | |
10414 | + } ); | |
10415 | + } | |
10416 | +} ); | |
10417 | + | |
10418 | +$.ui.plugin.add( "draggable", "cursor", { | |
10419 | + start: function( event, ui, instance ) { | |
10420 | + var t = $( "body" ), | |
10421 | + o = instance.options; | |
10422 | + | |
10423 | + if ( t.css( "cursor" ) ) { | |
10424 | + o._cursor = t.css( "cursor" ); | |
10425 | + } | |
10426 | + t.css( "cursor", o.cursor ); | |
10427 | + }, | |
10428 | + stop: function( event, ui, instance ) { | |
10429 | + var o = instance.options; | |
10430 | + if ( o._cursor ) { | |
10431 | + $( "body" ).css( "cursor", o._cursor ); | |
10432 | + } | |
10433 | + } | |
10434 | +} ); | |
10435 | + | |
10436 | +$.ui.plugin.add( "draggable", "opacity", { | |
10437 | + start: function( event, ui, instance ) { | |
10438 | + var t = $( ui.helper ), | |
10439 | + o = instance.options; | |
10440 | + if ( t.css( "opacity" ) ) { | |
10441 | + o._opacity = t.css( "opacity" ); | |
10442 | + } | |
10443 | + t.css( "opacity", o.opacity ); | |
10444 | + }, | |
10445 | + stop: function( event, ui, instance ) { | |
10446 | + var o = instance.options; | |
10447 | + if ( o._opacity ) { | |
10448 | + $( ui.helper ).css( "opacity", o._opacity ); | |
10449 | + } | |
10450 | + } | |
10451 | +} ); | |
10452 | + | |
10453 | +$.ui.plugin.add( "draggable", "scroll", { | |
10454 | + start: function( event, ui, i ) { | |
10455 | + if ( !i.scrollParentNotHidden ) { | |
10456 | + i.scrollParentNotHidden = i.helper.scrollParent( false ); | |
10457 | + } | |
10458 | + | |
10459 | + if ( i.scrollParentNotHidden[ 0 ] !== i.document[ 0 ] && | |
10460 | + i.scrollParentNotHidden[ 0 ].tagName !== "HTML" ) { | |
10461 | + i.overflowOffset = i.scrollParentNotHidden.offset(); | |
10462 | + } | |
10463 | + }, | |
10464 | + drag: function( event, ui, i ) { | |
10465 | + | |
10466 | + var o = i.options, | |
10467 | + scrolled = false, | |
10468 | + scrollParent = i.scrollParentNotHidden[ 0 ], | |
10469 | + document = i.document[ 0 ]; | |
10470 | + | |
10471 | + if ( scrollParent !== document && scrollParent.tagName !== "HTML" ) { | |
10472 | + if ( !o.axis || o.axis !== "x" ) { | |
10473 | + if ( ( i.overflowOffset.top + scrollParent.offsetHeight ) - event.pageY < | |
10474 | + o.scrollSensitivity ) { | |
10475 | + scrollParent.scrollTop = scrolled = scrollParent.scrollTop + o.scrollSpeed; | |
10476 | + } else if ( event.pageY - i.overflowOffset.top < o.scrollSensitivity ) { | |
10477 | + scrollParent.scrollTop = scrolled = scrollParent.scrollTop - o.scrollSpeed; | |
10478 | + } | |
10479 | + } | |
10480 | + | |
10481 | + if ( !o.axis || o.axis !== "y" ) { | |
10482 | + if ( ( i.overflowOffset.left + scrollParent.offsetWidth ) - event.pageX < | |
10483 | + o.scrollSensitivity ) { | |
10484 | + scrollParent.scrollLeft = scrolled = scrollParent.scrollLeft + o.scrollSpeed; | |
10485 | + } else if ( event.pageX - i.overflowOffset.left < o.scrollSensitivity ) { | |
10486 | + scrollParent.scrollLeft = scrolled = scrollParent.scrollLeft - o.scrollSpeed; | |
10487 | + } | |
10488 | + } | |
10489 | + | |
10490 | + } else { | |
10491 | + | |
10492 | + if ( !o.axis || o.axis !== "x" ) { | |
10493 | + if ( event.pageY - $( document ).scrollTop() < o.scrollSensitivity ) { | |
10494 | + scrolled = $( document ).scrollTop( $( document ).scrollTop() - o.scrollSpeed ); | |
10495 | + } else if ( $( window ).height() - ( event.pageY - $( document ).scrollTop() ) < | |
10496 | + o.scrollSensitivity ) { | |
10497 | + scrolled = $( document ).scrollTop( $( document ).scrollTop() + o.scrollSpeed ); | |
10498 | + } | |
10499 | + } | |
10500 | + | |
10501 | + if ( !o.axis || o.axis !== "y" ) { | |
10502 | + if ( event.pageX - $( document ).scrollLeft() < o.scrollSensitivity ) { | |
10503 | + scrolled = $( document ).scrollLeft( | |
10504 | + $( document ).scrollLeft() - o.scrollSpeed | |
10505 | + ); | |
10506 | + } else if ( $( window ).width() - ( event.pageX - $( document ).scrollLeft() ) < | |
10507 | + o.scrollSensitivity ) { | |
10508 | + scrolled = $( document ).scrollLeft( | |
10509 | + $( document ).scrollLeft() + o.scrollSpeed | |
10510 | + ); | |
10511 | + } | |
10512 | + } | |
10513 | + | |
10514 | + } | |
10515 | + | |
10516 | + if ( scrolled !== false && $.ui.ddmanager && !o.dropBehaviour ) { | |
10517 | + $.ui.ddmanager.prepareOffsets( i, event ); | |
10518 | + } | |
10519 | + | |
10520 | + } | |
10521 | +} ); | |
10522 | + | |
10523 | +$.ui.plugin.add( "draggable", "snap", { | |
10524 | + start: function( event, ui, i ) { | |
10525 | + | |
10526 | + var o = i.options; | |
10527 | + | |
10528 | + i.snapElements = []; | |
10529 | + | |
10530 | + $( o.snap.constructor !== String ? ( o.snap.items || ":data(ui-draggable)" ) : o.snap ) | |
10531 | + .each( function() { | |
10532 | + var $t = $( this ), | |
10533 | + $o = $t.offset(); | |
10534 | + if ( this !== i.element[ 0 ] ) { | |
10535 | + i.snapElements.push( { | |
10536 | + item: this, | |
10537 | + width: $t.outerWidth(), height: $t.outerHeight(), | |
10538 | + top: $o.top, left: $o.left | |
10539 | + } ); | |
10540 | + } | |
10541 | + } ); | |
10542 | + | |
10543 | + }, | |
10544 | + drag: function( event, ui, inst ) { | |
10545 | + | |
10546 | + var ts, bs, ls, rs, l, r, t, b, i, first, | |
10547 | + o = inst.options, | |
10548 | + d = o.snapTolerance, | |
10549 | + x1 = ui.offset.left, x2 = x1 + inst.helperProportions.width, | |
10550 | + y1 = ui.offset.top, y2 = y1 + inst.helperProportions.height; | |
10551 | + | |
10552 | + for ( i = inst.snapElements.length - 1; i >= 0; i-- ) { | |
10553 | + | |
10554 | + l = inst.snapElements[ i ].left - inst.margins.left; | |
10555 | + r = l + inst.snapElements[ i ].width; | |
10556 | + t = inst.snapElements[ i ].top - inst.margins.top; | |
10557 | + b = t + inst.snapElements[ i ].height; | |
10558 | + | |
10559 | + if ( x2 < l - d || x1 > r + d || y2 < t - d || y1 > b + d || | |
10560 | + !$.contains( inst.snapElements[ i ].item.ownerDocument, | |
10561 | + inst.snapElements[ i ].item ) ) { | |
10562 | + if ( inst.snapElements[ i ].snapping ) { | |
10563 | + ( inst.options.snap.release && | |
10564 | + inst.options.snap.release.call( | |
10565 | + inst.element, | |
10566 | + event, | |
10567 | + $.extend( inst._uiHash(), { snapItem: inst.snapElements[ i ].item } ) | |
10568 | + ) ); | |
10569 | + } | |
10570 | + inst.snapElements[ i ].snapping = false; | |
10571 | + continue; | |
10572 | + } | |
10573 | + | |
10574 | + if ( o.snapMode !== "inner" ) { | |
10575 | + ts = Math.abs( t - y2 ) <= d; | |
10576 | + bs = Math.abs( b - y1 ) <= d; | |
10577 | + ls = Math.abs( l - x2 ) <= d; | |
10578 | + rs = Math.abs( r - x1 ) <= d; | |
10579 | + if ( ts ) { | |
10580 | + ui.position.top = inst._convertPositionTo( "relative", { | |
10581 | + top: t - inst.helperProportions.height, | |
10582 | + left: 0 | |
10583 | + } ).top; | |
10584 | + } | |
10585 | + if ( bs ) { | |
10586 | + ui.position.top = inst._convertPositionTo( "relative", { | |
10587 | + top: b, | |
10588 | + left: 0 | |
10589 | + } ).top; | |
10590 | + } | |
10591 | + if ( ls ) { | |
10592 | + ui.position.left = inst._convertPositionTo( "relative", { | |
10593 | + top: 0, | |
10594 | + left: l - inst.helperProportions.width | |
10595 | + } ).left; | |
10596 | + } | |
10597 | + if ( rs ) { | |
10598 | + ui.position.left = inst._convertPositionTo( "relative", { | |
10599 | + top: 0, | |
10600 | + left: r | |
10601 | + } ).left; | |
10602 | + } | |
10603 | + } | |
10604 | + | |
10605 | + first = ( ts || bs || ls || rs ); | |
10606 | + | |
10607 | + if ( o.snapMode !== "outer" ) { | |
10608 | + ts = Math.abs( t - y1 ) <= d; | |
10609 | + bs = Math.abs( b - y2 ) <= d; | |
10610 | + ls = Math.abs( l - x1 ) <= d; | |
10611 | + rs = Math.abs( r - x2 ) <= d; | |
10612 | + if ( ts ) { | |
10613 | + ui.position.top = inst._convertPositionTo( "relative", { | |
10614 | + top: t, | |
10615 | + left: 0 | |
10616 | + } ).top; | |
10617 | + } | |
10618 | + if ( bs ) { | |
10619 | + ui.position.top = inst._convertPositionTo( "relative", { | |
10620 | + top: b - inst.helperProportions.height, | |
10621 | + left: 0 | |
10622 | + } ).top; | |
10623 | + } | |
10624 | + if ( ls ) { | |
10625 | + ui.position.left = inst._convertPositionTo( "relative", { | |
10626 | + top: 0, | |
10627 | + left: l | |
10628 | + } ).left; | |
10629 | + } | |
10630 | + if ( rs ) { | |
10631 | + ui.position.left = inst._convertPositionTo( "relative", { | |
10632 | + top: 0, | |
10633 | + left: r - inst.helperProportions.width | |
10634 | + } ).left; | |
10635 | + } | |
10636 | + } | |
10637 | + | |
10638 | + if ( !inst.snapElements[ i ].snapping && ( ts || bs || ls || rs || first ) ) { | |
10639 | + ( inst.options.snap.snap && | |
10640 | + inst.options.snap.snap.call( | |
10641 | + inst.element, | |
10642 | + event, | |
10643 | + $.extend( inst._uiHash(), { | |
10644 | + snapItem: inst.snapElements[ i ].item | |
10645 | + } ) ) ); | |
10646 | + } | |
10647 | + inst.snapElements[ i ].snapping = ( ts || bs || ls || rs || first ); | |
10648 | + | |
10649 | + } | |
10650 | + | |
10651 | + } | |
10652 | +} ); | |
10653 | + | |
10654 | +$.ui.plugin.add( "draggable", "stack", { | |
10655 | + start: function( event, ui, instance ) { | |
10656 | + var min, | |
10657 | + o = instance.options, | |
10658 | + group = $.makeArray( $( o.stack ) ).sort( function( a, b ) { | |
10659 | + return ( parseInt( $( a ).css( "zIndex" ), 10 ) || 0 ) - | |
10660 | + ( parseInt( $( b ).css( "zIndex" ), 10 ) || 0 ); | |
10661 | + } ); | |
10662 | + | |
10663 | + if ( !group.length ) { return; } | |
10664 | + | |
10665 | + min = parseInt( $( group[ 0 ] ).css( "zIndex" ), 10 ) || 0; | |
10666 | + $( group ).each( function( i ) { | |
10667 | + $( this ).css( "zIndex", min + i ); | |
10668 | + } ); | |
10669 | + this.css( "zIndex", ( min + group.length ) ); | |
10670 | + } | |
10671 | +} ); | |
10672 | + | |
10673 | +$.ui.plugin.add( "draggable", "zIndex", { | |
10674 | + start: function( event, ui, instance ) { | |
10675 | + var t = $( ui.helper ), | |
10676 | + o = instance.options; | |
10677 | + | |
10678 | + if ( t.css( "zIndex" ) ) { | |
10679 | + o._zIndex = t.css( "zIndex" ); | |
10680 | + } | |
10681 | + t.css( "zIndex", o.zIndex ); | |
10682 | + }, | |
10683 | + stop: function( event, ui, instance ) { | |
10684 | + var o = instance.options; | |
10685 | + | |
10686 | + if ( o._zIndex ) { | |
10687 | + $( ui.helper ).css( "zIndex", o._zIndex ); | |
10688 | + } | |
10689 | + } | |
10690 | +} ); | |
10691 | + | |
10692 | +var widgetsDraggable = $.ui.draggable; | |
10693 | + | |
10694 | + | |
10695 | +/*! | |
10696 | + * jQuery UI Resizable 1.12.0-rc.2 | |
10697 | + * http://jqueryui.com | |
10698 | + * | |
10699 | + * Copyright jQuery Foundation and other contributors | |
10700 | + * Released under the MIT license. | |
10701 | + * http://jquery.org/license | |
10702 | + */ | |
10703 | + | |
10704 | +//>>label: Resizable | |
10705 | +//>>group: Interactions | |
10706 | +//>>description: Enables resize functionality for any element. | |
10707 | +//>>docs: http://api.jqueryui.com/resizable/ | |
10708 | +//>>demos: http://jqueryui.com/resizable/ | |
10709 | +//>>css.structure: ../../themes/base/core.css | |
10710 | +//>>css.structure: ../../themes/base/resizable.css | |
10711 | +//>>css.theme: ../../themes/base/theme.css | |
10712 | + | |
10713 | + | |
10714 | + | |
10715 | +$.widget( "ui.resizable", $.ui.mouse, { | |
10716 | + version: "1.12.0-rc.2", | |
10717 | + widgetEventPrefix: "resize", | |
10718 | + options: { | |
10719 | + alsoResize: false, | |
10720 | + animate: false, | |
10721 | + animateDuration: "slow", | |
10722 | + animateEasing: "swing", | |
10723 | + aspectRatio: false, | |
10724 | + autoHide: false, | |
10725 | + classes: { | |
10726 | + "ui-resizable-se": "ui-icon ui-icon-gripsmall-diagonal-se" | |
10727 | + }, | |
10728 | + containment: false, | |
10729 | + ghost: false, | |
10730 | + grid: false, | |
10731 | + handles: "e,s,se", | |
10732 | + helper: false, | |
10733 | + maxHeight: null, | |
10734 | + maxWidth: null, | |
10735 | + minHeight: 10, | |
10736 | + minWidth: 10, | |
10737 | + | |
10738 | + // See #7960 | |
10739 | + zIndex: 90, | |
10740 | + | |
10741 | + // Callbacks | |
10742 | + resize: null, | |
10743 | + start: null, | |
10744 | + stop: null | |
10745 | + }, | |
10746 | + | |
10747 | + _num: function( value ) { | |
10748 | + return parseFloat( value ) || 0; | |
10749 | + }, | |
10750 | + | |
10751 | + _isNumber: function( value ) { | |
10752 | + return !isNaN( parseFloat( value ) ); | |
10753 | + }, | |
10754 | + | |
10755 | + _hasScroll: function( el, a ) { | |
10756 | + | |
10757 | + if ( $( el ).css( "overflow" ) === "hidden" ) { | |
10758 | + return false; | |
10759 | + } | |
10760 | + | |
10761 | + var scroll = ( a && a === "left" ) ? "scrollLeft" : "scrollTop", | |
10762 | + has = false; | |
10763 | + | |
10764 | + if ( el[ scroll ] > 0 ) { | |
10765 | + return true; | |
10766 | + } | |
10767 | + | |
10768 | + // TODO: determine which cases actually cause this to happen | |
10769 | + // if the element doesn't have the scroll set, see if it's possible to | |
10770 | + // set the scroll | |
10771 | + el[ scroll ] = 1; | |
10772 | + has = ( el[ scroll ] > 0 ); | |
10773 | + el[ scroll ] = 0; | |
10774 | + return has; | |
10775 | + }, | |
10776 | + | |
10777 | + _create: function() { | |
10778 | + | |
10779 | + var margins, | |
10780 | + o = this.options, | |
10781 | + that = this; | |
10782 | + this._addClass( "ui-resizable" ); | |
10783 | + | |
10784 | + $.extend( this, { | |
10785 | + _aspectRatio: !!( o.aspectRatio ), | |
10786 | + aspectRatio: o.aspectRatio, | |
10787 | + originalElement: this.element, | |
10788 | + _proportionallyResizeElements: [], | |
10789 | + _helper: o.helper || o.ghost || o.animate ? o.helper || "ui-resizable-helper" : null | |
10790 | + } ); | |
10791 | + | |
10792 | + // Wrap the element if it cannot hold child nodes | |
10793 | + if ( this.element[ 0 ].nodeName.match( /^(canvas|textarea|input|select|button|img)$/i ) ) { | |
10794 | + | |
10795 | + this.element.wrap( | |
10796 | + $( "<div class='ui-wrapper' style='overflow: hidden;'></div>" ).css( { | |
10797 | + position: this.element.css( "position" ), | |
10798 | + width: this.element.outerWidth(), | |
10799 | + height: this.element.outerHeight(), | |
10800 | + top: this.element.css( "top" ), | |
10801 | + left: this.element.css( "left" ) | |
10802 | + } ) | |
10803 | + ); | |
10804 | + | |
10805 | + this.element = this.element.parent().data( | |
10806 | + "ui-resizable", this.element.resizable( "instance" ) | |
10807 | + ); | |
10808 | + | |
10809 | + this.elementIsWrapper = true; | |
10810 | + | |
10811 | + margins = { | |
10812 | + marginTop: this.originalElement.css( "marginTop" ), | |
10813 | + marginRight: this.originalElement.css( "marginRight" ), | |
10814 | + marginBottom: this.originalElement.css( "marginBottom" ), | |
10815 | + marginLeft: this.originalElement.css( "marginLeft" ) | |
10816 | + }; | |
10817 | + | |
10818 | + this.element.css( margins ); | |
10819 | + this.originalElement.css( "margin", 0 ); | |
10820 | + | |
10821 | + // support: Safari | |
10822 | + // Prevent Safari textarea resize | |
10823 | + this.originalResizeStyle = this.originalElement.css( "resize" ); | |
10824 | + this.originalElement.css( "resize", "none" ); | |
10825 | + | |
10826 | + this._proportionallyResizeElements.push( this.originalElement.css( { | |
10827 | + position: "static", | |
10828 | + zoom: 1, | |
10829 | + display: "block" | |
10830 | + } ) ); | |
10831 | + | |
10832 | + // Support: IE9 | |
10833 | + // avoid IE jump (hard set the margin) | |
10834 | + this.originalElement.css( margins ); | |
10835 | + | |
10836 | + this._proportionallyResize(); | |
10837 | + } | |
10838 | + | |
10839 | + this._setupHandles(); | |
10840 | + | |
10841 | + if ( o.autoHide ) { | |
10842 | + $( this.element ) | |
10843 | + .on( "mouseenter", function() { | |
10844 | + if ( o.disabled ) { | |
10845 | + return; | |
10846 | + } | |
10847 | + that._removeClass( "ui-resizable-autohide" ); | |
10848 | + that._handles.show(); | |
10849 | + } ) | |
10850 | + .on( "mouseleave", function() { | |
10851 | + if ( o.disabled ) { | |
10852 | + return; | |
10853 | + } | |
10854 | + if ( !that.resizing ) { | |
10855 | + that._addClass( "ui-resizable-autohide" ); | |
10856 | + that._handles.hide(); | |
10857 | + } | |
10858 | + } ); | |
10859 | + } | |
10860 | + | |
10861 | + this._mouseInit(); | |
10862 | + }, | |
10863 | + | |
10864 | + _destroy: function() { | |
10865 | + | |
10866 | + this._mouseDestroy(); | |
10867 | + | |
10868 | + var wrapper, | |
10869 | + _destroy = function( exp ) { | |
10870 | + $( exp ) | |
10871 | + .removeData( "resizable" ) | |
10872 | + .removeData( "ui-resizable" ) | |
10873 | + .off( ".resizable" ) | |
10874 | + .find( ".ui-resizable-handle" ) | |
10875 | + .remove(); | |
10876 | + }; | |
10877 | + | |
10878 | + // TODO: Unwrap at same DOM position | |
10879 | + if ( this.elementIsWrapper ) { | |
10880 | + _destroy( this.element ); | |
10881 | + wrapper = this.element; | |
10882 | + this.originalElement.css( { | |
10883 | + position: wrapper.css( "position" ), | |
10884 | + width: wrapper.outerWidth(), | |
10885 | + height: wrapper.outerHeight(), | |
10886 | + top: wrapper.css( "top" ), | |
10887 | + left: wrapper.css( "left" ) | |
10888 | + } ).insertAfter( wrapper ); | |
10889 | + wrapper.remove(); | |
10890 | + } | |
10891 | + | |
10892 | + this.originalElement.css( "resize", this.originalResizeStyle ); | |
10893 | + _destroy( this.originalElement ); | |
10894 | + | |
10895 | + return this; | |
10896 | + }, | |
10897 | + | |
10898 | + _setOption: function( key, value ) { | |
10899 | + this._super( key, value ); | |
10900 | + | |
10901 | + switch ( key ) { | |
10902 | + case "handles": | |
10903 | + this._removeHandles(); | |
10904 | + this._setupHandles(); | |
10905 | + break; | |
10906 | + default: | |
10907 | + break; | |
10908 | + } | |
10909 | + }, | |
10910 | + | |
10911 | + _setupHandles: function() { | |
10912 | + var o = this.options, handle, i, n, hname, axis, that = this; | |
10913 | + this.handles = o.handles || | |
10914 | + ( !$( ".ui-resizable-handle", this.element ).length ? | |
10915 | + "e,s,se" : { | |
10916 | + n: ".ui-resizable-n", | |
10917 | + e: ".ui-resizable-e", | |
10918 | + s: ".ui-resizable-s", | |
10919 | + w: ".ui-resizable-w", | |
10920 | + se: ".ui-resizable-se", | |
10921 | + sw: ".ui-resizable-sw", | |
10922 | + ne: ".ui-resizable-ne", | |
10923 | + nw: ".ui-resizable-nw" | |
10924 | + } ); | |
10925 | + | |
10926 | + this._handles = $(); | |
10927 | + if ( this.handles.constructor === String ) { | |
10928 | + | |
10929 | + if ( this.handles === "all" ) { | |
10930 | + this.handles = "n,e,s,w,se,sw,ne,nw"; | |
10931 | + } | |
10932 | + | |
10933 | + n = this.handles.split( "," ); | |
10934 | + this.handles = {}; | |
10935 | + | |
10936 | + for ( i = 0; i < n.length; i++ ) { | |
10937 | + | |
10938 | + handle = $.trim( n[ i ] ); | |
10939 | + hname = "ui-resizable-" + handle; | |
10940 | + axis = $( "<div>" ); | |
10941 | + this._addClass( axis, "ui-resizable-handle " + hname ); | |
10942 | + | |
10943 | + axis.css( { zIndex: o.zIndex } ); | |
10944 | + | |
10945 | + this.handles[ handle ] = ".ui-resizable-" + handle; | |
10946 | + this.element.append( axis ); | |
10947 | + } | |
10948 | + | |
10949 | + } | |
10950 | + | |
10951 | + this._renderAxis = function( target ) { | |
10952 | + | |
10953 | + var i, axis, padPos, padWrapper; | |
10954 | + | |
10955 | + target = target || this.element; | |
10956 | + | |
10957 | + for ( i in this.handles ) { | |
10958 | + | |
10959 | + if ( this.handles[ i ].constructor === String ) { | |
10960 | + this.handles[ i ] = this.element.children( this.handles[ i ] ).first().show(); | |
10961 | + } else if ( this.handles[ i ].jquery || this.handles[ i ].nodeType ) { | |
10962 | + this.handles[ i ] = $( this.handles[ i ] ); | |
10963 | + this._on( this.handles[ i ], { "mousedown": that._mouseDown } ); | |
10964 | + } | |
10965 | + | |
10966 | + if ( this.elementIsWrapper && | |
10967 | + this.originalElement[ 0 ] | |
10968 | + .nodeName | |
10969 | + .match( /^(textarea|input|select|button)$/i ) ) { | |
10970 | + axis = $( this.handles[ i ], this.element ); | |
10971 | + | |
10972 | + padWrapper = /sw|ne|nw|se|n|s/.test( i ) ? | |
10973 | + axis.outerHeight() : | |
10974 | + axis.outerWidth(); | |
10975 | + | |
10976 | + padPos = [ "padding", | |
10977 | + /ne|nw|n/.test( i ) ? "Top" : | |
10978 | + /se|sw|s/.test( i ) ? "Bottom" : | |
10979 | + /^e$/.test( i ) ? "Right" : "Left" ].join( "" ); | |
10980 | + | |
10981 | + target.css( padPos, padWrapper ); | |
10982 | + | |
10983 | + this._proportionallyResize(); | |
10984 | + } | |
10985 | + | |
10986 | + this._handles = this._handles.add( this.handles[ i ] ); | |
10987 | + } | |
10988 | + }; | |
10989 | + | |
10990 | + // TODO: make renderAxis a prototype function | |
10991 | + this._renderAxis( this.element ); | |
10992 | + | |
10993 | + this._handles = this._handles.add( this.element.find( ".ui-resizable-handle" ) ); | |
10994 | + this._handles.disableSelection(); | |
10995 | + | |
10996 | + this._handles.on( "mouseover", function() { | |
10997 | + if ( !that.resizing ) { | |
10998 | + if ( this.className ) { | |
10999 | + axis = this.className.match( /ui-resizable-(se|sw|ne|nw|n|e|s|w)/i ); | |
11000 | + } | |
11001 | + that.axis = axis && axis[ 1 ] ? axis[ 1 ] : "se"; | |
11002 | + } | |
11003 | + } ); | |
11004 | + | |
11005 | + if ( o.autoHide ) { | |
11006 | + this._handles.hide(); | |
11007 | + this._addClass( "ui-resizable-autohide" ); | |
11008 | + } | |
11009 | + }, | |
11010 | + | |
11011 | + _removeHandles: function() { | |
11012 | + this._handles.remove(); | |
11013 | + }, | |
11014 | + | |
11015 | + _mouseCapture: function( event ) { | |
11016 | + var i, handle, | |
11017 | + capture = false; | |
11018 | + | |
11019 | + for ( i in this.handles ) { | |
11020 | + handle = $( this.handles[ i ] )[ 0 ]; | |
11021 | + if ( handle === event.target || $.contains( handle, event.target ) ) { | |
11022 | + capture = true; | |
11023 | + } | |
11024 | + } | |
11025 | + | |
11026 | + return !this.options.disabled && capture; | |
11027 | + }, | |
11028 | + | |
11029 | + _mouseStart: function( event ) { | |
11030 | + | |
11031 | + var curleft, curtop, cursor, | |
11032 | + o = this.options, | |
11033 | + el = this.element; | |
11034 | + | |
11035 | + this.resizing = true; | |
11036 | + | |
11037 | + this._renderProxy(); | |
11038 | + | |
11039 | + curleft = this._num( this.helper.css( "left" ) ); | |
11040 | + curtop = this._num( this.helper.css( "top" ) ); | |
11041 | + | |
11042 | + if ( o.containment ) { | |
11043 | + curleft += $( o.containment ).scrollLeft() || 0; | |
11044 | + curtop += $( o.containment ).scrollTop() || 0; | |
11045 | + } | |
11046 | + | |
11047 | + this.offset = this.helper.offset(); | |
11048 | + this.position = { left: curleft, top: curtop }; | |
11049 | + | |
11050 | + this.size = this._helper ? { | |
11051 | + width: this.helper.width(), | |
11052 | + height: this.helper.height() | |
11053 | + } : { | |
11054 | + width: el.width(), | |
11055 | + height: el.height() | |
11056 | + }; | |
11057 | + | |
11058 | + this.originalSize = this._helper ? { | |
11059 | + width: el.outerWidth(), | |
11060 | + height: el.outerHeight() | |
11061 | + } : { | |
11062 | + width: el.width(), | |
11063 | + height: el.height() | |
11064 | + }; | |
11065 | + | |
11066 | + this.sizeDiff = { | |
11067 | + width: el.outerWidth() - el.width(), | |
11068 | + height: el.outerHeight() - el.height() | |
11069 | + }; | |
11070 | + | |
11071 | + this.originalPosition = { left: curleft, top: curtop }; | |
11072 | + this.originalMousePosition = { left: event.pageX, top: event.pageY }; | |
11073 | + | |
11074 | + this.aspectRatio = ( typeof o.aspectRatio === "number" ) ? | |
11075 | + o.aspectRatio : | |
11076 | + ( ( this.originalSize.width / this.originalSize.height ) || 1 ); | |
11077 | + | |
11078 | + cursor = $( ".ui-resizable-" + this.axis ).css( "cursor" ); | |
11079 | + $( "body" ).css( "cursor", cursor === "auto" ? this.axis + "-resize" : cursor ); | |
11080 | + | |
11081 | + this._addClass( "ui-resizable-resizing" ); | |
11082 | + this._propagate( "start", event ); | |
11083 | + return true; | |
11084 | + }, | |
11085 | + | |
11086 | + _mouseDrag: function( event ) { | |
11087 | + | |
11088 | + var data, props, | |
11089 | + smp = this.originalMousePosition, | |
11090 | + a = this.axis, | |
11091 | + dx = ( event.pageX - smp.left ) || 0, | |
11092 | + dy = ( event.pageY - smp.top ) || 0, | |
11093 | + trigger = this._change[ a ]; | |
11094 | + | |
11095 | + this._updatePrevProperties(); | |
11096 | + | |
11097 | + if ( !trigger ) { | |
11098 | + return false; | |
11099 | + } | |
11100 | + | |
11101 | + data = trigger.apply( this, [ event, dx, dy ] ); | |
11102 | + | |
11103 | + this._updateVirtualBoundaries( event.shiftKey ); | |
11104 | + if ( this._aspectRatio || event.shiftKey ) { | |
11105 | + data = this._updateRatio( data, event ); | |
11106 | + } | |
11107 | + | |
11108 | + data = this._respectSize( data, event ); | |
11109 | + | |
11110 | + this._updateCache( data ); | |
11111 | + | |
11112 | + this._propagate( "resize", event ); | |
11113 | + | |
11114 | + props = this._applyChanges(); | |
11115 | + | |
11116 | + if ( !this._helper && this._proportionallyResizeElements.length ) { | |
11117 | + this._proportionallyResize(); | |
11118 | + } | |
11119 | + | |
11120 | + if ( !$.isEmptyObject( props ) ) { | |
11121 | + this._updatePrevProperties(); | |
11122 | + this._trigger( "resize", event, this.ui() ); | |
11123 | + this._applyChanges(); | |
11124 | + } | |
11125 | + | |
11126 | + return false; | |
11127 | + }, | |
11128 | + | |
11129 | + _mouseStop: function( event ) { | |
11130 | + | |
11131 | + this.resizing = false; | |
11132 | + var pr, ista, soffseth, soffsetw, s, left, top, | |
11133 | + o = this.options, that = this; | |
11134 | + | |
11135 | + if ( this._helper ) { | |
11136 | + | |
11137 | + pr = this._proportionallyResizeElements; | |
11138 | + ista = pr.length && ( /textarea/i ).test( pr[ 0 ].nodeName ); | |
11139 | + soffseth = ista && this._hasScroll( pr[ 0 ], "left" ) ? 0 : that.sizeDiff.height; | |
11140 | + soffsetw = ista ? 0 : that.sizeDiff.width; | |
11141 | + | |
11142 | + s = { | |
11143 | + width: ( that.helper.width() - soffsetw ), | |
11144 | + height: ( that.helper.height() - soffseth ) | |
11145 | + }; | |
11146 | + left = ( parseFloat( that.element.css( "left" ) ) + | |
11147 | + ( that.position.left - that.originalPosition.left ) ) || null; | |
11148 | + top = ( parseFloat( that.element.css( "top" ) ) + | |
11149 | + ( that.position.top - that.originalPosition.top ) ) || null; | |
11150 | + | |
11151 | + if ( !o.animate ) { | |
11152 | + this.element.css( $.extend( s, { top: top, left: left } ) ); | |
11153 | + } | |
11154 | + | |
11155 | + that.helper.height( that.size.height ); | |
11156 | + that.helper.width( that.size.width ); | |
11157 | + | |
11158 | + if ( this._helper && !o.animate ) { | |
11159 | + this._proportionallyResize(); | |
11160 | + } | |
11161 | + } | |
11162 | + | |
11163 | + $( "body" ).css( "cursor", "auto" ); | |
11164 | + | |
11165 | + this._removeClass( "ui-resizable-resizing" ); | |
11166 | + | |
11167 | + this._propagate( "stop", event ); | |
11168 | + | |
11169 | + if ( this._helper ) { | |
11170 | + this.helper.remove(); | |
11171 | + } | |
11172 | + | |
11173 | + return false; | |
11174 | + | |
11175 | + }, | |
11176 | + | |
11177 | + _updatePrevProperties: function() { | |
11178 | + this.prevPosition = { | |
11179 | + top: this.position.top, | |
11180 | + left: this.position.left | |
11181 | + }; | |
11182 | + this.prevSize = { | |
11183 | + width: this.size.width, | |
11184 | + height: this.size.height | |
11185 | + }; | |
11186 | + }, | |
11187 | + | |
11188 | + _applyChanges: function() { | |
11189 | + var props = {}; | |
11190 | + | |
11191 | + if ( this.position.top !== this.prevPosition.top ) { | |
11192 | + props.top = this.position.top + "px"; | |
11193 | + } | |
11194 | + if ( this.position.left !== this.prevPosition.left ) { | |
11195 | + props.left = this.position.left + "px"; | |
11196 | + } | |
11197 | + if ( this.size.width !== this.prevSize.width ) { | |
11198 | + props.width = this.size.width + "px"; | |
11199 | + } | |
11200 | + if ( this.size.height !== this.prevSize.height ) { | |
11201 | + props.height = this.size.height + "px"; | |
11202 | + } | |
11203 | + | |
11204 | + this.helper.css( props ); | |
11205 | + | |
11206 | + return props; | |
11207 | + }, | |
11208 | + | |
11209 | + _updateVirtualBoundaries: function( forceAspectRatio ) { | |
11210 | + var pMinWidth, pMaxWidth, pMinHeight, pMaxHeight, b, | |
11211 | + o = this.options; | |
11212 | + | |
11213 | + b = { | |
11214 | + minWidth: this._isNumber( o.minWidth ) ? o.minWidth : 0, | |
11215 | + maxWidth: this._isNumber( o.maxWidth ) ? o.maxWidth : Infinity, | |
11216 | + minHeight: this._isNumber( o.minHeight ) ? o.minHeight : 0, | |
11217 | + maxHeight: this._isNumber( o.maxHeight ) ? o.maxHeight : Infinity | |
11218 | + }; | |
11219 | + | |
11220 | + if ( this._aspectRatio || forceAspectRatio ) { | |
11221 | + pMinWidth = b.minHeight * this.aspectRatio; | |
11222 | + pMinHeight = b.minWidth / this.aspectRatio; | |
11223 | + pMaxWidth = b.maxHeight * this.aspectRatio; | |
11224 | + pMaxHeight = b.maxWidth / this.aspectRatio; | |
11225 | + | |
11226 | + if ( pMinWidth > b.minWidth ) { | |
11227 | + b.minWidth = pMinWidth; | |
11228 | + } | |
11229 | + if ( pMinHeight > b.minHeight ) { | |
11230 | + b.minHeight = pMinHeight; | |
11231 | + } | |
11232 | + if ( pMaxWidth < b.maxWidth ) { | |
11233 | + b.maxWidth = pMaxWidth; | |
11234 | + } | |
11235 | + if ( pMaxHeight < b.maxHeight ) { | |
11236 | + b.maxHeight = pMaxHeight; | |
11237 | + } | |
11238 | + } | |
11239 | + this._vBoundaries = b; | |
11240 | + }, | |
11241 | + | |
11242 | + _updateCache: function( data ) { | |
11243 | + this.offset = this.helper.offset(); | |
11244 | + if ( this._isNumber( data.left ) ) { | |
11245 | + this.position.left = data.left; | |
11246 | + } | |
11247 | + if ( this._isNumber( data.top ) ) { | |
11248 | + this.position.top = data.top; | |
11249 | + } | |
11250 | + if ( this._isNumber( data.height ) ) { | |
11251 | + this.size.height = data.height; | |
11252 | + } | |
11253 | + if ( this._isNumber( data.width ) ) { | |
11254 | + this.size.width = data.width; | |
11255 | + } | |
11256 | + }, | |
11257 | + | |
11258 | + _updateRatio: function( data ) { | |
11259 | + | |
11260 | + var cpos = this.position, | |
11261 | + csize = this.size, | |
11262 | + a = this.axis; | |
11263 | + | |
11264 | + if ( this._isNumber( data.height ) ) { | |
11265 | + data.width = ( data.height * this.aspectRatio ); | |
11266 | + } else if ( this._isNumber( data.width ) ) { | |
11267 | + data.height = ( data.width / this.aspectRatio ); | |
11268 | + } | |
11269 | + | |
11270 | + if ( a === "sw" ) { | |
11271 | + data.left = cpos.left + ( csize.width - data.width ); | |
11272 | + data.top = null; | |
11273 | + } | |
11274 | + if ( a === "nw" ) { | |
11275 | + data.top = cpos.top + ( csize.height - data.height ); | |
11276 | + data.left = cpos.left + ( csize.width - data.width ); | |
11277 | + } | |
11278 | + | |
11279 | + return data; | |
11280 | + }, | |
11281 | + | |
11282 | + _respectSize: function( data ) { | |
11283 | + | |
11284 | + var o = this._vBoundaries, | |
11285 | + a = this.axis, | |
11286 | + ismaxw = this._isNumber( data.width ) && o.maxWidth && ( o.maxWidth < data.width ), | |
11287 | + ismaxh = this._isNumber( data.height ) && o.maxHeight && ( o.maxHeight < data.height ), | |
11288 | + isminw = this._isNumber( data.width ) && o.minWidth && ( o.minWidth > data.width ), | |
11289 | + isminh = this._isNumber( data.height ) && o.minHeight && ( o.minHeight > data.height ), | |
11290 | + dw = this.originalPosition.left + this.originalSize.width, | |
11291 | + dh = this.originalPosition.top + this.originalSize.height, | |
11292 | + cw = /sw|nw|w/.test( a ), ch = /nw|ne|n/.test( a ); | |
11293 | + if ( isminw ) { | |
11294 | + data.width = o.minWidth; | |
11295 | + } | |
11296 | + if ( isminh ) { | |
11297 | + data.height = o.minHeight; | |
11298 | + } | |
11299 | + if ( ismaxw ) { | |
11300 | + data.width = o.maxWidth; | |
11301 | + } | |
11302 | + if ( ismaxh ) { | |
11303 | + data.height = o.maxHeight; | |
11304 | + } | |
11305 | + | |
11306 | + if ( isminw && cw ) { | |
11307 | + data.left = dw - o.minWidth; | |
11308 | + } | |
11309 | + if ( ismaxw && cw ) { | |
11310 | + data.left = dw - o.maxWidth; | |
11311 | + } | |
11312 | + if ( isminh && ch ) { | |
11313 | + data.top = dh - o.minHeight; | |
11314 | + } | |
11315 | + if ( ismaxh && ch ) { | |
11316 | + data.top = dh - o.maxHeight; | |
11317 | + } | |
11318 | + | |
11319 | + // Fixing jump error on top/left - bug #2330 | |
11320 | + if ( !data.width && !data.height && !data.left && data.top ) { | |
11321 | + data.top = null; | |
11322 | + } else if ( !data.width && !data.height && !data.top && data.left ) { | |
11323 | + data.left = null; | |
11324 | + } | |
11325 | + | |
11326 | + return data; | |
11327 | + }, | |
11328 | + | |
11329 | + _getPaddingPlusBorderDimensions: function( element ) { | |
11330 | + var i = 0, | |
11331 | + widths = [], | |
11332 | + borders = [ | |
11333 | + element.css( "borderTopWidth" ), | |
11334 | + element.css( "borderRightWidth" ), | |
11335 | + element.css( "borderBottomWidth" ), | |
11336 | + element.css( "borderLeftWidth" ) | |
11337 | + ], | |
11338 | + paddings = [ | |
11339 | + element.css( "paddingTop" ), | |
11340 | + element.css( "paddingRight" ), | |
11341 | + element.css( "paddingBottom" ), | |
11342 | + element.css( "paddingLeft" ) | |
11343 | + ]; | |
11344 | + | |
11345 | + for ( ; i < 4; i++ ) { | |
11346 | + widths[ i ] = ( parseFloat( borders[ i ] ) || 0 ); | |
11347 | + widths[ i ] += ( parseFloat( paddings[ i ] ) || 0 ); | |
11348 | + } | |
11349 | + | |
11350 | + return { | |
11351 | + height: widths[ 0 ] + widths[ 2 ], | |
11352 | + width: widths[ 1 ] + widths[ 3 ] | |
11353 | + }; | |
11354 | + }, | |
11355 | + | |
11356 | + _proportionallyResize: function() { | |
11357 | + | |
11358 | + if ( !this._proportionallyResizeElements.length ) { | |
11359 | + return; | |
11360 | + } | |
11361 | + | |
11362 | + var prel, | |
11363 | + i = 0, | |
11364 | + element = this.helper || this.element; | |
11365 | + | |
11366 | + for ( ; i < this._proportionallyResizeElements.length; i++ ) { | |
11367 | + | |
11368 | + prel = this._proportionallyResizeElements[ i ]; | |
11369 | + | |
11370 | + // TODO: Seems like a bug to cache this.outerDimensions | |
11371 | + // considering that we are in a loop. | |
11372 | + if ( !this.outerDimensions ) { | |
11373 | + this.outerDimensions = this._getPaddingPlusBorderDimensions( prel ); | |
11374 | + } | |
11375 | + | |
11376 | + prel.css( { | |
11377 | + height: ( element.height() - this.outerDimensions.height ) || 0, | |
11378 | + width: ( element.width() - this.outerDimensions.width ) || 0 | |
11379 | + } ); | |
11380 | + | |
11381 | + } | |
11382 | + | |
11383 | + }, | |
11384 | + | |
11385 | + _renderProxy: function() { | |
11386 | + | |
11387 | + var el = this.element, o = this.options; | |
11388 | + this.elementOffset = el.offset(); | |
11389 | + | |
11390 | + if ( this._helper ) { | |
11391 | + | |
11392 | + this.helper = this.helper || $( "<div style='overflow:hidden;'></div>" ); | |
11393 | + | |
11394 | + this._addClass( this.helper, this._helper ); | |
11395 | + this.helper.css( { | |
11396 | + width: this.element.outerWidth(), | |
11397 | + height: this.element.outerHeight(), | |
11398 | + position: "absolute", | |
11399 | + left: this.elementOffset.left + "px", | |
11400 | + top: this.elementOffset.top + "px", | |
11401 | + zIndex: ++o.zIndex //TODO: Don't modify option | |
11402 | + } ); | |
11403 | + | |
11404 | + this.helper | |
11405 | + .appendTo( "body" ) | |
11406 | + .disableSelection(); | |
11407 | + | |
11408 | + } else { | |
11409 | + this.helper = this.element; | |
11410 | + } | |
11411 | + | |
11412 | + }, | |
11413 | + | |
11414 | + _change: { | |
11415 | + e: function( event, dx ) { | |
11416 | + return { width: this.originalSize.width + dx }; | |
11417 | + }, | |
11418 | + w: function( event, dx ) { | |
11419 | + var cs = this.originalSize, sp = this.originalPosition; | |
11420 | + return { left: sp.left + dx, width: cs.width - dx }; | |
11421 | + }, | |
11422 | + n: function( event, dx, dy ) { | |
11423 | + var cs = this.originalSize, sp = this.originalPosition; | |
11424 | + return { top: sp.top + dy, height: cs.height - dy }; | |
11425 | + }, | |
11426 | + s: function( event, dx, dy ) { | |
11427 | + return { height: this.originalSize.height + dy }; | |
11428 | + }, | |
11429 | + se: function( event, dx, dy ) { | |
11430 | + return $.extend( this._change.s.apply( this, arguments ), | |
11431 | + this._change.e.apply( this, [ event, dx, dy ] ) ); | |
11432 | + }, | |
11433 | + sw: function( event, dx, dy ) { | |
11434 | + return $.extend( this._change.s.apply( this, arguments ), | |
11435 | + this._change.w.apply( this, [ event, dx, dy ] ) ); | |
11436 | + }, | |
11437 | + ne: function( event, dx, dy ) { | |
11438 | + return $.extend( this._change.n.apply( this, arguments ), | |
11439 | + this._change.e.apply( this, [ event, dx, dy ] ) ); | |
11440 | + }, | |
11441 | + nw: function( event, dx, dy ) { | |
11442 | + return $.extend( this._change.n.apply( this, arguments ), | |
11443 | + this._change.w.apply( this, [ event, dx, dy ] ) ); | |
11444 | + } | |
11445 | + }, | |
11446 | + | |
11447 | + _propagate: function( n, event ) { | |
11448 | + $.ui.plugin.call( this, n, [ event, this.ui() ] ); | |
11449 | + ( n !== "resize" && this._trigger( n, event, this.ui() ) ); | |
11450 | + }, | |
11451 | + | |
11452 | + plugins: {}, | |
11453 | + | |
11454 | + ui: function() { | |
11455 | + return { | |
11456 | + originalElement: this.originalElement, | |
11457 | + element: this.element, | |
11458 | + helper: this.helper, | |
11459 | + position: this.position, | |
11460 | + size: this.size, | |
11461 | + originalSize: this.originalSize, | |
11462 | + originalPosition: this.originalPosition | |
11463 | + }; | |
11464 | + } | |
11465 | + | |
11466 | +} ); | |
11467 | + | |
11468 | +/* | |
11469 | + * Resizable Extensions | |
11470 | + */ | |
11471 | + | |
11472 | +$.ui.plugin.add( "resizable", "animate", { | |
11473 | + | |
11474 | + stop: function( event ) { | |
11475 | + var that = $( this ).resizable( "instance" ), | |
11476 | + o = that.options, | |
11477 | + pr = that._proportionallyResizeElements, | |
11478 | + ista = pr.length && ( /textarea/i ).test( pr[ 0 ].nodeName ), | |
11479 | + soffseth = ista && that._hasScroll( pr[ 0 ], "left" ) ? 0 : that.sizeDiff.height, | |
11480 | + soffsetw = ista ? 0 : that.sizeDiff.width, | |
11481 | + style = { | |
11482 | + width: ( that.size.width - soffsetw ), | |
11483 | + height: ( that.size.height - soffseth ) | |
11484 | + }, | |
11485 | + left = ( parseFloat( that.element.css( "left" ) ) + | |
11486 | + ( that.position.left - that.originalPosition.left ) ) || null, | |
11487 | + top = ( parseFloat( that.element.css( "top" ) ) + | |
11488 | + ( that.position.top - that.originalPosition.top ) ) || null; | |
11489 | + | |
11490 | + that.element.animate( | |
11491 | + $.extend( style, top && left ? { top: top, left: left } : {} ), { | |
11492 | + duration: o.animateDuration, | |
11493 | + easing: o.animateEasing, | |
11494 | + step: function() { | |
11495 | + | |
11496 | + var data = { | |
11497 | + width: parseFloat( that.element.css( "width" ) ), | |
11498 | + height: parseFloat( that.element.css( "height" ) ), | |
11499 | + top: parseFloat( that.element.css( "top" ) ), | |
11500 | + left: parseFloat( that.element.css( "left" ) ) | |
11501 | + }; | |
11502 | + | |
11503 | + if ( pr && pr.length ) { | |
11504 | + $( pr[ 0 ] ).css( { width: data.width, height: data.height } ); | |
11505 | + } | |
11506 | + | |
11507 | + // Propagating resize, and updating values for each animation step | |
11508 | + that._updateCache( data ); | |
11509 | + that._propagate( "resize", event ); | |
11510 | + | |
11511 | + } | |
11512 | + } | |
11513 | + ); | |
11514 | + } | |
11515 | + | |
11516 | +} ); | |
11517 | + | |
11518 | +$.ui.plugin.add( "resizable", "containment", { | |
11519 | + | |
11520 | + start: function() { | |
11521 | + var element, p, co, ch, cw, width, height, | |
11522 | + that = $( this ).resizable( "instance" ), | |
11523 | + o = that.options, | |
11524 | + el = that.element, | |
11525 | + oc = o.containment, | |
11526 | + ce = ( oc instanceof $ ) ? | |
11527 | + oc.get( 0 ) : | |
11528 | + ( /parent/.test( oc ) ) ? el.parent().get( 0 ) : oc; | |
11529 | + | |
11530 | + if ( !ce ) { | |
11531 | + return; | |
11532 | + } | |
11533 | + | |
11534 | + that.containerElement = $( ce ); | |
11535 | + | |
11536 | + if ( /document/.test( oc ) || oc === document ) { | |
11537 | + that.containerOffset = { | |
11538 | + left: 0, | |
11539 | + top: 0 | |
11540 | + }; | |
11541 | + that.containerPosition = { | |
11542 | + left: 0, | |
11543 | + top: 0 | |
11544 | + }; | |
11545 | + | |
11546 | + that.parentData = { | |
11547 | + element: $( document ), | |
11548 | + left: 0, | |
11549 | + top: 0, | |
11550 | + width: $( document ).width(), | |
11551 | + height: $( document ).height() || document.body.parentNode.scrollHeight | |
11552 | + }; | |
11553 | + } else { | |
11554 | + element = $( ce ); | |
11555 | + p = []; | |
11556 | + $( [ "Top", "Right", "Left", "Bottom" ] ).each( function( i, name ) { | |
11557 | + p[ i ] = that._num( element.css( "padding" + name ) ); | |
11558 | + } ); | |
11559 | + | |
11560 | + that.containerOffset = element.offset(); | |
11561 | + that.containerPosition = element.position(); | |
11562 | + that.containerSize = { | |
11563 | + height: ( element.innerHeight() - p[ 3 ] ), | |
11564 | + width: ( element.innerWidth() - p[ 1 ] ) | |
11565 | + }; | |
11566 | + | |
11567 | + co = that.containerOffset; | |
11568 | + ch = that.containerSize.height; | |
11569 | + cw = that.containerSize.width; | |
11570 | + width = ( that._hasScroll ( ce, "left" ) ? ce.scrollWidth : cw ); | |
11571 | + height = ( that._hasScroll ( ce ) ? ce.scrollHeight : ch ) ; | |
11572 | + | |
11573 | + that.parentData = { | |
11574 | + element: ce, | |
11575 | + left: co.left, | |
11576 | + top: co.top, | |
11577 | + width: width, | |
11578 | + height: height | |
11579 | + }; | |
11580 | + } | |
11581 | + }, | |
11582 | + | |
11583 | + resize: function( event ) { | |
11584 | + var woset, hoset, isParent, isOffsetRelative, | |
11585 | + that = $( this ).resizable( "instance" ), | |
11586 | + o = that.options, | |
11587 | + co = that.containerOffset, | |
11588 | + cp = that.position, | |
11589 | + pRatio = that._aspectRatio || event.shiftKey, | |
11590 | + cop = { | |
11591 | + top: 0, | |
11592 | + left: 0 | |
11593 | + }, | |
11594 | + ce = that.containerElement, | |
11595 | + continueResize = true; | |
11596 | + | |
11597 | + if ( ce[ 0 ] !== document && ( /static/ ).test( ce.css( "position" ) ) ) { | |
11598 | + cop = co; | |
11599 | + } | |
11600 | + | |
11601 | + if ( cp.left < ( that._helper ? co.left : 0 ) ) { | |
11602 | + that.size.width = that.size.width + | |
11603 | + ( that._helper ? | |
11604 | + ( that.position.left - co.left ) : | |
11605 | + ( that.position.left - cop.left ) ); | |
11606 | + | |
11607 | + if ( pRatio ) { | |
11608 | + that.size.height = that.size.width / that.aspectRatio; | |
11609 | + continueResize = false; | |
11610 | + } | |
11611 | + that.position.left = o.helper ? co.left : 0; | |
11612 | + } | |
11613 | + | |
11614 | + if ( cp.top < ( that._helper ? co.top : 0 ) ) { | |
11615 | + that.size.height = that.size.height + | |
11616 | + ( that._helper ? | |
11617 | + ( that.position.top - co.top ) : | |
11618 | + that.position.top ); | |
11619 | + | |
11620 | + if ( pRatio ) { | |
11621 | + that.size.width = that.size.height * that.aspectRatio; | |
11622 | + continueResize = false; | |
11623 | + } | |
11624 | + that.position.top = that._helper ? co.top : 0; | |
11625 | + } | |
11626 | + | |
11627 | + isParent = that.containerElement.get( 0 ) === that.element.parent().get( 0 ); | |
11628 | + isOffsetRelative = /relative|absolute/.test( that.containerElement.css( "position" ) ); | |
11629 | + | |
11630 | + if ( isParent && isOffsetRelative ) { | |
11631 | + that.offset.left = that.parentData.left + that.position.left; | |
11632 | + that.offset.top = that.parentData.top + that.position.top; | |
11633 | + } else { | |
11634 | + that.offset.left = that.element.offset().left; | |
11635 | + that.offset.top = that.element.offset().top; | |
11636 | + } | |
11637 | + | |
11638 | + woset = Math.abs( that.sizeDiff.width + | |
11639 | + ( that._helper ? | |
11640 | + that.offset.left - cop.left : | |
11641 | + ( that.offset.left - co.left ) ) ); | |
11642 | + | |
11643 | + hoset = Math.abs( that.sizeDiff.height + | |
11644 | + ( that._helper ? | |
11645 | + that.offset.top - cop.top : | |
11646 | + ( that.offset.top - co.top ) ) ); | |
11647 | + | |
11648 | + if ( woset + that.size.width >= that.parentData.width ) { | |
11649 | + that.size.width = that.parentData.width - woset; | |
11650 | + if ( pRatio ) { | |
11651 | + that.size.height = that.size.width / that.aspectRatio; | |
11652 | + continueResize = false; | |
11653 | + } | |
11654 | + } | |
11655 | + | |
11656 | + if ( hoset + that.size.height >= that.parentData.height ) { | |
11657 | + that.size.height = that.parentData.height - hoset; | |
11658 | + if ( pRatio ) { | |
11659 | + that.size.width = that.size.height * that.aspectRatio; | |
11660 | + continueResize = false; | |
11661 | + } | |
11662 | + } | |
11663 | + | |
11664 | + if ( !continueResize ) { | |
11665 | + that.position.left = that.prevPosition.left; | |
11666 | + that.position.top = that.prevPosition.top; | |
11667 | + that.size.width = that.prevSize.width; | |
11668 | + that.size.height = that.prevSize.height; | |
11669 | + } | |
11670 | + }, | |
11671 | + | |
11672 | + stop: function() { | |
11673 | + var that = $( this ).resizable( "instance" ), | |
11674 | + o = that.options, | |
11675 | + co = that.containerOffset, | |
11676 | + cop = that.containerPosition, | |
11677 | + ce = that.containerElement, | |
11678 | + helper = $( that.helper ), | |
11679 | + ho = helper.offset(), | |
11680 | + w = helper.outerWidth() - that.sizeDiff.width, | |
11681 | + h = helper.outerHeight() - that.sizeDiff.height; | |
11682 | + | |
11683 | + if ( that._helper && !o.animate && ( /relative/ ).test( ce.css( "position" ) ) ) { | |
11684 | + $( this ).css( { | |
11685 | + left: ho.left - cop.left - co.left, | |
11686 | + width: w, | |
11687 | + height: h | |
11688 | + } ); | |
11689 | + } | |
11690 | + | |
11691 | + if ( that._helper && !o.animate && ( /static/ ).test( ce.css( "position" ) ) ) { | |
11692 | + $( this ).css( { | |
11693 | + left: ho.left - cop.left - co.left, | |
11694 | + width: w, | |
11695 | + height: h | |
11696 | + } ); | |
11697 | + } | |
11698 | + } | |
11699 | +} ); | |
11700 | + | |
11701 | +$.ui.plugin.add( "resizable", "alsoResize", { | |
11702 | + | |
11703 | + start: function() { | |
11704 | + var that = $( this ).resizable( "instance" ), | |
11705 | + o = that.options; | |
11706 | + | |
11707 | + $( o.alsoResize ).each( function() { | |
11708 | + var el = $( this ); | |
11709 | + el.data( "ui-resizable-alsoresize", { | |
11710 | + width: parseFloat( el.width() ), height: parseFloat( el.height() ), | |
11711 | + left: parseFloat( el.css( "left" ) ), top: parseFloat( el.css( "top" ) ) | |
11712 | + } ); | |
11713 | + } ); | |
11714 | + }, | |
11715 | + | |
11716 | + resize: function( event, ui ) { | |
11717 | + var that = $( this ).resizable( "instance" ), | |
11718 | + o = that.options, | |
11719 | + os = that.originalSize, | |
11720 | + op = that.originalPosition, | |
11721 | + delta = { | |
11722 | + height: ( that.size.height - os.height ) || 0, | |
11723 | + width: ( that.size.width - os.width ) || 0, | |
11724 | + top: ( that.position.top - op.top ) || 0, | |
11725 | + left: ( that.position.left - op.left ) || 0 | |
11726 | + }; | |
11727 | + | |
11728 | + $( o.alsoResize ).each( function() { | |
11729 | + var el = $( this ), start = $( this ).data( "ui-resizable-alsoresize" ), style = {}, | |
11730 | + css = el.parents( ui.originalElement[ 0 ] ).length ? | |
11731 | + [ "width", "height" ] : | |
11732 | + [ "width", "height", "top", "left" ]; | |
11733 | + | |
11734 | + $.each( css, function( i, prop ) { | |
11735 | + var sum = ( start[ prop ] || 0 ) + ( delta[ prop ] || 0 ); | |
11736 | + if ( sum && sum >= 0 ) { | |
11737 | + style[ prop ] = sum || null; | |
11738 | + } | |
11739 | + } ); | |
11740 | + | |
11741 | + el.css( style ); | |
11742 | + } ); | |
11743 | + }, | |
11744 | + | |
11745 | + stop: function() { | |
11746 | + $( this ).removeData( "ui-resizable-alsoresize" ); | |
11747 | + } | |
11748 | +} ); | |
11749 | + | |
11750 | +$.ui.plugin.add( "resizable", "ghost", { | |
11751 | + | |
11752 | + start: function() { | |
11753 | + | |
11754 | + var that = $( this ).resizable( "instance" ), cs = that.size; | |
11755 | + | |
11756 | + that.ghost = that.originalElement.clone(); | |
11757 | + that.ghost.css( { | |
11758 | + opacity: 0.25, | |
11759 | + display: "block", | |
11760 | + position: "relative", | |
11761 | + height: cs.height, | |
11762 | + width: cs.width, | |
11763 | + margin: 0, | |
11764 | + left: 0, | |
11765 | + top: 0 | |
11766 | + } ); | |
11767 | + | |
11768 | + that._addClass( that.ghost, "ui-resizable-ghost" ); | |
11769 | + | |
11770 | + // DEPRECATED | |
11771 | + // TODO: remove after 1.12 | |
11772 | + if ( $.uiBackCompat !== false && typeof that.options.ghost === "string" ) { | |
11773 | + | |
11774 | + // Ghost option | |
11775 | + that.ghost.addClass( this.options.ghost ); | |
11776 | + } | |
11777 | + | |
11778 | + that.ghost.appendTo( that.helper ); | |
11779 | + | |
11780 | + }, | |
11781 | + | |
11782 | + resize: function() { | |
11783 | + var that = $( this ).resizable( "instance" ); | |
11784 | + if ( that.ghost ) { | |
11785 | + that.ghost.css( { | |
11786 | + position: "relative", | |
11787 | + height: that.size.height, | |
11788 | + width: that.size.width | |
11789 | + } ); | |
11790 | + } | |
11791 | + }, | |
11792 | + | |
11793 | + stop: function() { | |
11794 | + var that = $( this ).resizable( "instance" ); | |
11795 | + if ( that.ghost && that.helper ) { | |
11796 | + that.helper.get( 0 ).removeChild( that.ghost.get( 0 ) ); | |
11797 | + } | |
11798 | + } | |
11799 | + | |
11800 | +} ); | |
11801 | + | |
11802 | +$.ui.plugin.add( "resizable", "grid", { | |
11803 | + | |
11804 | + resize: function() { | |
11805 | + var outerDimensions, | |
11806 | + that = $( this ).resizable( "instance" ), | |
11807 | + o = that.options, | |
11808 | + cs = that.size, | |
11809 | + os = that.originalSize, | |
11810 | + op = that.originalPosition, | |
11811 | + a = that.axis, | |
11812 | + grid = typeof o.grid === "number" ? [ o.grid, o.grid ] : o.grid, | |
11813 | + gridX = ( grid[ 0 ] || 1 ), | |
11814 | + gridY = ( grid[ 1 ] || 1 ), | |
11815 | + ox = Math.round( ( cs.width - os.width ) / gridX ) * gridX, | |
11816 | + oy = Math.round( ( cs.height - os.height ) / gridY ) * gridY, | |
11817 | + newWidth = os.width + ox, | |
11818 | + newHeight = os.height + oy, | |
11819 | + isMaxWidth = o.maxWidth && ( o.maxWidth < newWidth ), | |
11820 | + isMaxHeight = o.maxHeight && ( o.maxHeight < newHeight ), | |
11821 | + isMinWidth = o.minWidth && ( o.minWidth > newWidth ), | |
11822 | + isMinHeight = o.minHeight && ( o.minHeight > newHeight ); | |
11823 | + | |
11824 | + o.grid = grid; | |
11825 | + | |
11826 | + if ( isMinWidth ) { | |
11827 | + newWidth += gridX; | |
11828 | + } | |
11829 | + if ( isMinHeight ) { | |
11830 | + newHeight += gridY; | |
11831 | + } | |
11832 | + if ( isMaxWidth ) { | |
11833 | + newWidth -= gridX; | |
11834 | + } | |
11835 | + if ( isMaxHeight ) { | |
11836 | + newHeight -= gridY; | |
11837 | + } | |
11838 | + | |
11839 | + if ( /^(se|s|e)$/.test( a ) ) { | |
11840 | + that.size.width = newWidth; | |
11841 | + that.size.height = newHeight; | |
11842 | + } else if ( /^(ne)$/.test( a ) ) { | |
11843 | + that.size.width = newWidth; | |
11844 | + that.size.height = newHeight; | |
11845 | + that.position.top = op.top - oy; | |
11846 | + } else if ( /^(sw)$/.test( a ) ) { | |
11847 | + that.size.width = newWidth; | |
11848 | + that.size.height = newHeight; | |
11849 | + that.position.left = op.left - ox; | |
11850 | + } else { | |
11851 | + if ( newHeight - gridY <= 0 || newWidth - gridX <= 0 ) { | |
11852 | + outerDimensions = that._getPaddingPlusBorderDimensions( this ); | |
11853 | + } | |
11854 | + | |
11855 | + if ( newHeight - gridY > 0 ) { | |
11856 | + that.size.height = newHeight; | |
11857 | + that.position.top = op.top - oy; | |
11858 | + } else { | |
11859 | + newHeight = gridY - outerDimensions.height; | |
11860 | + that.size.height = newHeight; | |
11861 | + that.position.top = op.top + os.height - newHeight; | |
11862 | + } | |
11863 | + if ( newWidth - gridX > 0 ) { | |
11864 | + that.size.width = newWidth; | |
11865 | + that.position.left = op.left - ox; | |
11866 | + } else { | |
11867 | + newWidth = gridX - outerDimensions.width; | |
11868 | + that.size.width = newWidth; | |
11869 | + that.position.left = op.left + os.width - newWidth; | |
11870 | + } | |
11871 | + } | |
11872 | + } | |
11873 | + | |
11874 | +} ); | |
11875 | + | |
11876 | +var widgetsResizable = $.ui.resizable; | |
11877 | + | |
11878 | + | |
11879 | +/*! | |
11880 | + * jQuery UI Dialog 1.12.0-rc.2 | |
11881 | + * http://jqueryui.com | |
11882 | + * | |
11883 | + * Copyright jQuery Foundation and other contributors | |
11884 | + * Released under the MIT license. | |
11885 | + * http://jquery.org/license | |
11886 | + */ | |
11887 | + | |
11888 | +//>>label: Dialog | |
11889 | +//>>group: Widgets | |
11890 | +//>>description: Displays customizable dialog windows. | |
11891 | +//>>docs: http://api.jqueryui.com/dialog/ | |
11892 | +//>>demos: http://jqueryui.com/dialog/ | |
11893 | +//>>css.structure: ../../themes/base/core.css | |
11894 | +//>>css.structure: ../../themes/base/dialog.css | |
11895 | +//>>css.theme: ../../themes/base/theme.css | |
11896 | + | |
11897 | + | |
11898 | + | |
11899 | +$.widget( "ui.dialog", { | |
11900 | + version: "1.12.0-rc.2", | |
11901 | + options: { | |
11902 | + appendTo: "body", | |
11903 | + autoOpen: true, | |
11904 | + buttons: [], | |
11905 | + classes: { | |
11906 | + "ui-dialog": "ui-corner-all", | |
11907 | + "ui-dialog-titlebar": "ui-corner-all" | |
11908 | + }, | |
11909 | + closeOnEscape: true, | |
11910 | + closeText: "Close", | |
11911 | + draggable: true, | |
11912 | + hide: null, | |
11913 | + height: "auto", | |
11914 | + maxHeight: null, | |
11915 | + maxWidth: null, | |
11916 | + minHeight: 150, | |
11917 | + minWidth: 150, | |
11918 | + modal: false, | |
11919 | + position: { | |
11920 | + my: "center", | |
11921 | + at: "center", | |
11922 | + of: window, | |
11923 | + collision: "fit", | |
11924 | + | |
11925 | + // Ensure the titlebar is always visible | |
11926 | + using: function( pos ) { | |
11927 | + var topOffset = $( this ).css( pos ).offset().top; | |
11928 | + if ( topOffset < 0 ) { | |
11929 | + $( this ).css( "top", pos.top - topOffset ); | |
11930 | + } | |
11931 | + } | |
11932 | + }, | |
11933 | + resizable: true, | |
11934 | + show: null, | |
11935 | + title: null, | |
11936 | + width: 300, | |
11937 | + | |
11938 | + // Callbacks | |
11939 | + beforeClose: null, | |
11940 | + close: null, | |
11941 | + drag: null, | |
11942 | + dragStart: null, | |
11943 | + dragStop: null, | |
11944 | + focus: null, | |
11945 | + open: null, | |
11946 | + resize: null, | |
11947 | + resizeStart: null, | |
11948 | + resizeStop: null | |
11949 | + }, | |
11950 | + | |
11951 | + sizeRelatedOptions: { | |
11952 | + buttons: true, | |
11953 | + height: true, | |
11954 | + maxHeight: true, | |
11955 | + maxWidth: true, | |
11956 | + minHeight: true, | |
11957 | + minWidth: true, | |
11958 | + width: true | |
11959 | + }, | |
11960 | + | |
11961 | + resizableRelatedOptions: { | |
11962 | + maxHeight: true, | |
11963 | + maxWidth: true, | |
11964 | + minHeight: true, | |
11965 | + minWidth: true | |
11966 | + }, | |
11967 | + | |
11968 | + _create: function() { | |
11969 | + this.originalCss = { | |
11970 | + display: this.element[ 0 ].style.display, | |
11971 | + width: this.element[ 0 ].style.width, | |
11972 | + minHeight: this.element[ 0 ].style.minHeight, | |
11973 | + maxHeight: this.element[ 0 ].style.maxHeight, | |
11974 | + height: this.element[ 0 ].style.height | |
11975 | + }; | |
11976 | + this.originalPosition = { | |
11977 | + parent: this.element.parent(), | |
11978 | + index: this.element.parent().children().index( this.element ) | |
11979 | + }; | |
11980 | + this.originalTitle = this.element.attr( "title" ); | |
11981 | + if ( this.options.title == null && this.originalTitle != null ) { | |
11982 | + this.options.title = this.originalTitle; | |
11983 | + } | |
11984 | + | |
11985 | + // Dialogs can't be disabled | |
11986 | + if ( this.options.disabled ) { | |
11987 | + this.options.disabled = false; | |
11988 | + } | |
11989 | + | |
11990 | + this._createWrapper(); | |
11991 | + | |
11992 | + this.element | |
11993 | + .show() | |
11994 | + .removeAttr( "title" ) | |
11995 | + .appendTo( this.uiDialog ); | |
11996 | + | |
11997 | + this._addClass( "ui-dialog-content", "ui-widget-content" ); | |
11998 | + | |
11999 | + this._createTitlebar(); | |
12000 | + this._createButtonPane(); | |
12001 | + | |
12002 | + if ( this.options.draggable && $.fn.draggable ) { | |
12003 | + this._makeDraggable(); | |
12004 | + } | |
12005 | + if ( this.options.resizable && $.fn.resizable ) { | |
12006 | + this._makeResizable(); | |
12007 | + } | |
12008 | + | |
12009 | + this._isOpen = false; | |
12010 | + | |
12011 | + this._trackFocus(); | |
12012 | + }, | |
12013 | + | |
12014 | + _init: function() { | |
12015 | + if ( this.options.autoOpen ) { | |
12016 | + this.open(); | |
12017 | + } | |
12018 | + }, | |
12019 | + | |
12020 | + _appendTo: function() { | |
12021 | + var element = this.options.appendTo; | |
12022 | + if ( element && ( element.jquery || element.nodeType ) ) { | |
12023 | + return $( element ); | |
12024 | + } | |
12025 | + return this.document.find( element || "body" ).eq( 0 ); | |
12026 | + }, | |
12027 | + | |
12028 | + _destroy: function() { | |
12029 | + var next, | |
12030 | + originalPosition = this.originalPosition; | |
12031 | + | |
12032 | + this._untrackInstance(); | |
12033 | + this._destroyOverlay(); | |
12034 | + | |
12035 | + this.element | |
12036 | + .removeUniqueId() | |
12037 | + .css( this.originalCss ) | |
12038 | + | |
12039 | + // Without detaching first, the following becomes really slow | |
12040 | + .detach(); | |
12041 | + | |
12042 | + this.uiDialog.remove(); | |
12043 | + | |
12044 | + if ( this.originalTitle ) { | |
12045 | + this.element.attr( "title", this.originalTitle ); | |
12046 | + } | |
12047 | + | |
12048 | + next = originalPosition.parent.children().eq( originalPosition.index ); | |
12049 | + | |
12050 | + // Don't try to place the dialog next to itself (#8613) | |
12051 | + if ( next.length && next[ 0 ] !== this.element[ 0 ] ) { | |
12052 | + next.before( this.element ); | |
12053 | + } else { | |
12054 | + originalPosition.parent.append( this.element ); | |
12055 | + } | |
12056 | + }, | |
12057 | + | |
12058 | + widget: function() { | |
12059 | + return this.uiDialog; | |
12060 | + }, | |
12061 | + | |
12062 | + disable: $.noop, | |
12063 | + enable: $.noop, | |
12064 | + | |
12065 | + close: function( event ) { | |
12066 | + var that = this; | |
12067 | + | |
12068 | + if ( !this._isOpen || this._trigger( "beforeClose", event ) === false ) { | |
12069 | + return; | |
12070 | + } | |
12071 | + | |
12072 | + this._isOpen = false; | |
12073 | + this._focusedElement = null; | |
12074 | + this._destroyOverlay(); | |
12075 | + this._untrackInstance(); | |
12076 | + | |
12077 | + if ( !this.opener.filter( ":focusable" ).trigger( "focus" ).length ) { | |
12078 | + | |
12079 | + // Hiding a focused element doesn't trigger blur in WebKit | |
12080 | + // so in case we have nothing to focus on, explicitly blur the active element | |
12081 | + // https://bugs.webkit.org/show_bug.cgi?id=47182 | |
12082 | + $.ui.safeBlur( $.ui.safeActiveElement( this.document[ 0 ] ) ); | |
12083 | + } | |
12084 | + | |
12085 | + this._hide( this.uiDialog, this.options.hide, function() { | |
12086 | + that._trigger( "close", event ); | |
12087 | + } ); | |
12088 | + }, | |
12089 | + | |
12090 | + isOpen: function() { | |
12091 | + return this._isOpen; | |
12092 | + }, | |
12093 | + | |
12094 | + moveToTop: function() { | |
12095 | + this._moveToTop(); | |
12096 | + }, | |
12097 | + | |
12098 | + _moveToTop: function( event, silent ) { | |
12099 | + var moved = false, | |
12100 | + zIndices = this.uiDialog.siblings( ".ui-front:visible" ).map( function() { | |
12101 | + return +$( this ).css( "z-index" ); | |
12102 | + } ).get(), | |
12103 | + zIndexMax = Math.max.apply( null, zIndices ); | |
12104 | + | |
12105 | + if ( zIndexMax >= +this.uiDialog.css( "z-index" ) ) { | |
12106 | + this.uiDialog.css( "z-index", zIndexMax + 1 ); | |
12107 | + moved = true; | |
12108 | + } | |
12109 | + | |
12110 | + if ( moved && !silent ) { | |
12111 | + this._trigger( "focus", event ); | |
12112 | + } | |
12113 | + return moved; | |
12114 | + }, | |
12115 | + | |
12116 | + open: function() { | |
12117 | + var that = this; | |
12118 | + if ( this._isOpen ) { | |
12119 | + if ( this._moveToTop() ) { | |
12120 | + this._focusTabbable(); | |
12121 | + } | |
12122 | + return; | |
12123 | + } | |
12124 | + | |
12125 | + this._isOpen = true; | |
12126 | + this.opener = $( $.ui.safeActiveElement( this.document[ 0 ] ) ); | |
12127 | + | |
12128 | + this._size(); | |
12129 | + this._position(); | |
12130 | + this._createOverlay(); | |
12131 | + this._moveToTop( null, true ); | |
12132 | + | |
12133 | + // Ensure the overlay is moved to the top with the dialog, but only when | |
12134 | + // opening. The overlay shouldn't move after the dialog is open so that | |
12135 | + // modeless dialogs opened after the modal dialog stack properly. | |
12136 | + if ( this.overlay ) { | |
12137 | + this.overlay.css( "z-index", this.uiDialog.css( "z-index" ) - 1 ); | |
12138 | + } | |
12139 | + | |
12140 | + this._show( this.uiDialog, this.options.show, function() { | |
12141 | + that._focusTabbable(); | |
12142 | + that._trigger( "focus" ); | |
12143 | + } ); | |
12144 | + | |
12145 | + // Track the dialog immediately upon openening in case a focus event | |
12146 | + // somehow occurs outside of the dialog before an element inside the | |
12147 | + // dialog is focused (#10152) | |
12148 | + this._makeFocusTarget(); | |
12149 | + | |
12150 | + this._trigger( "open" ); | |
12151 | + }, | |
12152 | + | |
12153 | + _focusTabbable: function() { | |
12154 | + | |
12155 | + // Set focus to the first match: | |
12156 | + // 1. An element that was focused previously | |
12157 | + // 2. First element inside the dialog matching [autofocus] | |
12158 | + // 3. Tabbable element inside the content element | |
12159 | + // 4. Tabbable element inside the buttonpane | |
12160 | + // 5. The close button | |
12161 | + // 6. The dialog itself | |
12162 | + var hasFocus = this._focusedElement; | |
12163 | + if ( !hasFocus ) { | |
12164 | + hasFocus = this.element.find( "[autofocus]" ); | |
12165 | + } | |
12166 | + if ( !hasFocus.length ) { | |
12167 | + hasFocus = this.element.find( ":tabbable" ); | |
12168 | + } | |
12169 | + if ( !hasFocus.length ) { | |
12170 | + hasFocus = this.uiDialogButtonPane.find( ":tabbable" ); | |
12171 | + } | |
12172 | + if ( !hasFocus.length ) { | |
12173 | + hasFocus = this.uiDialogTitlebarClose.filter( ":tabbable" ); | |
12174 | + } | |
12175 | + if ( !hasFocus.length ) { | |
12176 | + hasFocus = this.uiDialog; | |
12177 | + } | |
12178 | + hasFocus.eq( 0 ).trigger( "focus" ); | |
12179 | + }, | |
12180 | + | |
12181 | + _keepFocus: function( event ) { | |
12182 | + function checkFocus() { | |
12183 | + var activeElement = $.ui.safeActiveElement( this.document[ 0 ] ), | |
12184 | + isActive = this.uiDialog[ 0 ] === activeElement || | |
12185 | + $.contains( this.uiDialog[ 0 ], activeElement ); | |
12186 | + if ( !isActive ) { | |
12187 | + this._focusTabbable(); | |
12188 | + } | |
12189 | + } | |
12190 | + event.preventDefault(); | |
12191 | + checkFocus.call( this ); | |
12192 | + | |
12193 | + // support: IE | |
12194 | + // IE <= 8 doesn't prevent moving focus even with event.preventDefault() | |
12195 | + // so we check again later | |
12196 | + this._delay( checkFocus ); | |
12197 | + }, | |
12198 | + | |
12199 | + _createWrapper: function() { | |
12200 | + this.uiDialog = $( "<div>" ) | |
12201 | + .hide() | |
12202 | + .attr( { | |
12203 | + | |
12204 | + // Setting tabIndex makes the div focusable | |
12205 | + tabIndex: -1, | |
12206 | + role: "dialog" | |
12207 | + } ) | |
12208 | + .appendTo( this._appendTo() ); | |
12209 | + | |
12210 | + this._addClass( this.uiDialog, "ui-dialog", "ui-widget ui-widget-content ui-front" ); | |
12211 | + this._on( this.uiDialog, { | |
12212 | + keydown: function( event ) { | |
12213 | + if ( this.options.closeOnEscape && !event.isDefaultPrevented() && event.keyCode && | |
12214 | + event.keyCode === $.ui.keyCode.ESCAPE ) { | |
12215 | + event.preventDefault(); | |
12216 | + this.close( event ); | |
12217 | + return; | |
12218 | + } | |
12219 | + | |
12220 | + // Prevent tabbing out of dialogs | |
12221 | + if ( event.keyCode !== $.ui.keyCode.TAB || event.isDefaultPrevented() ) { | |
12222 | + return; | |
12223 | + } | |
12224 | + var tabbables = this.uiDialog.find( ":tabbable" ), | |
12225 | + first = tabbables.filter( ":first" ), | |
12226 | + last = tabbables.filter( ":last" ); | |
12227 | + | |
12228 | + if ( ( event.target === last[ 0 ] || event.target === this.uiDialog[ 0 ] ) && | |
12229 | + !event.shiftKey ) { | |
12230 | + this._delay( function() { | |
12231 | + first.trigger( "focus" ); | |
12232 | + } ); | |
12233 | + event.preventDefault(); | |
12234 | + } else if ( ( event.target === first[ 0 ] || | |
12235 | + event.target === this.uiDialog[ 0 ] ) && event.shiftKey ) { | |
12236 | + this._delay( function() { | |
12237 | + last.trigger( "focus" ); | |
12238 | + } ); | |
12239 | + event.preventDefault(); | |
12240 | + } | |
12241 | + }, | |
12242 | + mousedown: function( event ) { | |
12243 | + if ( this._moveToTop( event ) ) { | |
12244 | + this._focusTabbable(); | |
12245 | + } | |
12246 | + } | |
12247 | + } ); | |
12248 | + | |
12249 | + // We assume that any existing aria-describedby attribute means | |
12250 | + // that the dialog content is marked up properly | |
12251 | + // otherwise we brute force the content as the description | |
12252 | + if ( !this.element.find( "[aria-describedby]" ).length ) { | |
12253 | + this.uiDialog.attr( { | |
12254 | + "aria-describedby": this.element.uniqueId().attr( "id" ) | |
12255 | + } ); | |
12256 | + } | |
12257 | + }, | |
12258 | + | |
12259 | + _createTitlebar: function() { | |
12260 | + var uiDialogTitle; | |
12261 | + | |
12262 | + this.uiDialogTitlebar = $( "<div>" ); | |
12263 | + this._addClass( this.uiDialogTitlebar, | |
12264 | + "ui-dialog-titlebar", "ui-widget-header ui-helper-clearfix" ); | |
12265 | + this._on( this.uiDialogTitlebar, { | |
12266 | + mousedown: function( event ) { | |
12267 | + | |
12268 | + // Don't prevent click on close button (#8838) | |
12269 | + // Focusing a dialog that is partially scrolled out of view | |
12270 | + // causes the browser to scroll it into view, preventing the click event | |
12271 | + if ( !$( event.target ).closest( ".ui-dialog-titlebar-close" ) ) { | |
12272 | + | |
12273 | + // Dialog isn't getting focus when dragging (#8063) | |
12274 | + this.uiDialog.trigger( "focus" ); | |
12275 | + } | |
12276 | + } | |
12277 | + } ); | |
12278 | + | |
12279 | + // Support: IE | |
12280 | + // Use type="button" to prevent enter keypresses in textboxes from closing the | |
12281 | + // dialog in IE (#9312) | |
12282 | + this.uiDialogTitlebarClose = $( "<button type='button'></button>" ) | |
12283 | + .button( { | |
12284 | + label: $( "<a>" ).text( this.options.closeText ).html(), | |
12285 | + icon: "ui-icon-closethick", | |
12286 | + showLabel: false | |
12287 | + } ) | |
12288 | + .appendTo( this.uiDialogTitlebar ); | |
12289 | + | |
12290 | + this._addClass( this.uiDialogTitlebarClose, "ui-dialog-titlebar-close" ); | |
12291 | + this._on( this.uiDialogTitlebarClose, { | |
12292 | + click: function( event ) { | |
12293 | + event.preventDefault(); | |
12294 | + this.close( event ); | |
12295 | + } | |
12296 | + } ); | |
12297 | + | |
12298 | + uiDialogTitle = $( "<span>" ).uniqueId().prependTo( this.uiDialogTitlebar ); | |
12299 | + this._addClass( uiDialogTitle, "ui-dialog-title" ); | |
12300 | + this._title( uiDialogTitle ); | |
12301 | + | |
12302 | + this.uiDialogTitlebar.prependTo( this.uiDialog ); | |
12303 | + | |
12304 | + this.uiDialog.attr( { | |
12305 | + "aria-labelledby": uiDialogTitle.attr( "id" ) | |
12306 | + } ); | |
12307 | + }, | |
12308 | + | |
12309 | + _title: function( title ) { | |
12310 | + if ( this.options.title ) { | |
12311 | + title.text( this.options.title ); | |
12312 | + } else { | |
12313 | + title.html( " " ); | |
12314 | + } | |
12315 | + }, | |
12316 | + | |
12317 | + _createButtonPane: function() { | |
12318 | + this.uiDialogButtonPane = $( "<div>" ); | |
12319 | + this._addClass( this.uiDialogButtonPane, "ui-dialog-buttonpane", | |
12320 | + "ui-widget-content ui-helper-clearfix" ); | |
12321 | + | |
12322 | + this.uiButtonSet = $( "<div>" ) | |
12323 | + .appendTo( this.uiDialogButtonPane ); | |
12324 | + this._addClass( this.uiButtonSet, "ui-dialog-buttonset" ); | |
12325 | + | |
12326 | + this._createButtons(); | |
12327 | + }, | |
12328 | + | |
12329 | + _createButtons: function() { | |
12330 | + var that = this, | |
12331 | + buttons = this.options.buttons; | |
12332 | + | |
12333 | + // If we already have a button pane, remove it | |
12334 | + this.uiDialogButtonPane.remove(); | |
12335 | + this.uiButtonSet.empty(); | |
12336 | + | |
12337 | + if ( $.isEmptyObject( buttons ) || ( $.isArray( buttons ) && !buttons.length ) ) { | |
12338 | + this._removeClass( this.uiDialog, "ui-dialog-buttons" ); | |
12339 | + return; | |
12340 | + } | |
12341 | + | |
12342 | + $.each( buttons, function( name, props ) { | |
12343 | + var click, buttonOptions; | |
12344 | + props = $.isFunction( props ) ? | |
12345 | + { click: props, text: name } : | |
12346 | + props; | |
12347 | + | |
12348 | + // Default to a non-submitting button | |
12349 | + props = $.extend( { type: "button" }, props ); | |
12350 | + | |
12351 | + // Change the context for the click callback to be the main element | |
12352 | + click = props.click; | |
12353 | + buttonOptions = { | |
12354 | + icon: props.icon, | |
12355 | + iconPosition: props.iconPosition, | |
12356 | + showLabel: props.showLabel | |
12357 | + }; | |
12358 | + | |
12359 | + delete props.click; | |
12360 | + delete props.icon; | |
12361 | + delete props.iconPosition; | |
12362 | + delete props.showLabel; | |
12363 | + | |
12364 | + $( "<button></button>", props ) | |
12365 | + .button( buttonOptions ) | |
12366 | + .appendTo( that.uiButtonSet ) | |
12367 | + .on( "click", function() { | |
12368 | + click.apply( that.element[ 0 ], arguments ); | |
12369 | + } ); | |
12370 | + } ); | |
12371 | + this._addClass( this.uiDialog, "ui-dialog-buttons" ); | |
12372 | + this.uiDialogButtonPane.appendTo( this.uiDialog ); | |
12373 | + }, | |
12374 | + | |
12375 | + _makeDraggable: function() { | |
12376 | + var that = this, | |
12377 | + options = this.options; | |
12378 | + | |
12379 | + function filteredUi( ui ) { | |
12380 | + return { | |
12381 | + position: ui.position, | |
12382 | + offset: ui.offset | |
12383 | + }; | |
12384 | + } | |
12385 | + | |
12386 | + this.uiDialog.draggable( { | |
12387 | + cancel: ".ui-dialog-content, .ui-dialog-titlebar-close", | |
12388 | + handle: ".ui-dialog-titlebar", | |
12389 | + containment: "document", | |
12390 | + start: function( event, ui ) { | |
12391 | + that._addClass( $( this ), "ui-dialog-dragging" ); | |
12392 | + that._blockFrames(); | |
12393 | + that._trigger( "dragStart", event, filteredUi( ui ) ); | |
12394 | + }, | |
12395 | + drag: function( event, ui ) { | |
12396 | + that._trigger( "drag", event, filteredUi( ui ) ); | |
12397 | + }, | |
12398 | + stop: function( event, ui ) { | |
12399 | + var left = ui.offset.left - that.document.scrollLeft(), | |
12400 | + top = ui.offset.top - that.document.scrollTop(); | |
12401 | + | |
12402 | + options.position = { | |
12403 | + my: "left top", | |
12404 | + at: "left" + ( left >= 0 ? "+" : "" ) + left + " " + | |
12405 | + "top" + ( top >= 0 ? "+" : "" ) + top, | |
12406 | + of: that.window | |
12407 | + }; | |
12408 | + that._removeClass( $( this ), "ui-dialog-dragging" ); | |
12409 | + that._unblockFrames(); | |
12410 | + that._trigger( "dragStop", event, filteredUi( ui ) ); | |
12411 | + } | |
12412 | + } ); | |
12413 | + }, | |
12414 | + | |
12415 | + _makeResizable: function() { | |
12416 | + var that = this, | |
12417 | + options = this.options, | |
12418 | + handles = options.resizable, | |
12419 | + | |
12420 | + // .ui-resizable has position: relative defined in the stylesheet | |
12421 | + // but dialogs have to use absolute or fixed positioning | |
12422 | + position = this.uiDialog.css( "position" ), | |
12423 | + resizeHandles = typeof handles === "string" ? | |
12424 | + handles : | |
12425 | + "n,e,s,w,se,sw,ne,nw"; | |
12426 | + | |
12427 | + function filteredUi( ui ) { | |
12428 | + return { | |
12429 | + originalPosition: ui.originalPosition, | |
12430 | + originalSize: ui.originalSize, | |
12431 | + position: ui.position, | |
12432 | + size: ui.size | |
12433 | + }; | |
12434 | + } | |
12435 | + | |
12436 | + this.uiDialog.resizable( { | |
12437 | + cancel: ".ui-dialog-content", | |
12438 | + containment: "document", | |
12439 | + alsoResize: this.element, | |
12440 | + maxWidth: options.maxWidth, | |
12441 | + maxHeight: options.maxHeight, | |
12442 | + minWidth: options.minWidth, | |
12443 | + minHeight: this._minHeight(), | |
12444 | + handles: resizeHandles, | |
12445 | + start: function( event, ui ) { | |
12446 | + that._addClass( $( this ), "ui-dialog-resizing" ); | |
12447 | + that._blockFrames(); | |
12448 | + that._trigger( "resizeStart", event, filteredUi( ui ) ); | |
12449 | + }, | |
12450 | + resize: function( event, ui ) { | |
12451 | + that._trigger( "resize", event, filteredUi( ui ) ); | |
12452 | + }, | |
12453 | + stop: function( event, ui ) { | |
12454 | + var offset = that.uiDialog.offset(), | |
12455 | + left = offset.left - that.document.scrollLeft(), | |
12456 | + top = offset.top - that.document.scrollTop(); | |
12457 | + | |
12458 | + options.height = that.uiDialog.height(); | |
12459 | + options.width = that.uiDialog.width(); | |
12460 | + options.position = { | |
12461 | + my: "left top", | |
12462 | + at: "left" + ( left >= 0 ? "+" : "" ) + left + " " + | |
12463 | + "top" + ( top >= 0 ? "+" : "" ) + top, | |
12464 | + of: that.window | |
12465 | + }; | |
12466 | + that._removeClass( $( this ), "ui-dialog-resizing" ); | |
12467 | + that._unblockFrames(); | |
12468 | + that._trigger( "resizeStop", event, filteredUi( ui ) ); | |
12469 | + } | |
12470 | + } ) | |
12471 | + .css( "position", position ); | |
12472 | + }, | |
12473 | + | |
12474 | + _trackFocus: function() { | |
12475 | + this._on( this.widget(), { | |
12476 | + focusin: function( event ) { | |
12477 | + this._makeFocusTarget(); | |
12478 | + this._focusedElement = $( event.target ); | |
12479 | + } | |
12480 | + } ); | |
12481 | + }, | |
12482 | + | |
12483 | + _makeFocusTarget: function() { | |
12484 | + this._untrackInstance(); | |
12485 | + this._trackingInstances().unshift( this ); | |
12486 | + }, | |
12487 | + | |
12488 | + _untrackInstance: function() { | |
12489 | + var instances = this._trackingInstances(), | |
12490 | + exists = $.inArray( this, instances ); | |
12491 | + if ( exists !== -1 ) { | |
12492 | + instances.splice( exists, 1 ); | |
12493 | + } | |
12494 | + }, | |
12495 | + | |
12496 | + _trackingInstances: function() { | |
12497 | + var instances = this.document.data( "ui-dialog-instances" ); | |
12498 | + if ( !instances ) { | |
12499 | + instances = []; | |
12500 | + this.document.data( "ui-dialog-instances", instances ); | |
12501 | + } | |
12502 | + return instances; | |
12503 | + }, | |
12504 | + | |
12505 | + _minHeight: function() { | |
12506 | + var options = this.options; | |
12507 | + | |
12508 | + return options.height === "auto" ? | |
12509 | + options.minHeight : | |
12510 | + Math.min( options.minHeight, options.height ); | |
12511 | + }, | |
12512 | + | |
12513 | + _position: function() { | |
12514 | + | |
12515 | + // Need to show the dialog to get the actual offset in the position plugin | |
12516 | + var isVisible = this.uiDialog.is( ":visible" ); | |
12517 | + if ( !isVisible ) { | |
12518 | + this.uiDialog.show(); | |
12519 | + } | |
12520 | + this.uiDialog.position( this.options.position ); | |
12521 | + if ( !isVisible ) { | |
12522 | + this.uiDialog.hide(); | |
12523 | + } | |
12524 | + }, | |
12525 | + | |
12526 | + _setOptions: function( options ) { | |
12527 | + var that = this, | |
12528 | + resize = false, | |
12529 | + resizableOptions = {}; | |
12530 | + | |
12531 | + $.each( options, function( key, value ) { | |
12532 | + that._setOption( key, value ); | |
12533 | + | |
12534 | + if ( key in that.sizeRelatedOptions ) { | |
12535 | + resize = true; | |
12536 | + } | |
12537 | + if ( key in that.resizableRelatedOptions ) { | |
12538 | + resizableOptions[ key ] = value; | |
12539 | + } | |
12540 | + } ); | |
12541 | + | |
12542 | + if ( resize ) { | |
12543 | + this._size(); | |
12544 | + this._position(); | |
12545 | + } | |
12546 | + if ( this.uiDialog.is( ":data(ui-resizable)" ) ) { | |
12547 | + this.uiDialog.resizable( "option", resizableOptions ); | |
12548 | + } | |
12549 | + }, | |
12550 | + | |
12551 | + _setOption: function( key, value ) { | |
12552 | + var isDraggable, isResizable, | |
12553 | + uiDialog = this.uiDialog; | |
12554 | + | |
12555 | + if ( key === "disabled" ) { | |
12556 | + return; | |
12557 | + } | |
12558 | + | |
12559 | + this._super( key, value ); | |
12560 | + | |
12561 | + if ( key === "appendTo" ) { | |
12562 | + this.uiDialog.appendTo( this._appendTo() ); | |
12563 | + } | |
12564 | + | |
12565 | + if ( key === "buttons" ) { | |
12566 | + this._createButtons(); | |
12567 | + } | |
12568 | + | |
12569 | + if ( key === "closeText" ) { | |
12570 | + this.uiDialogTitlebarClose.button( { | |
12571 | + | |
12572 | + // Ensure that we always pass a string | |
12573 | + label: $( "<a>" ).text( "" + this.options.closeText ).html() | |
12574 | + } ); | |
12575 | + } | |
12576 | + | |
12577 | + if ( key === "draggable" ) { | |
12578 | + isDraggable = uiDialog.is( ":data(ui-draggable)" ); | |
12579 | + if ( isDraggable && !value ) { | |
12580 | + uiDialog.draggable( "destroy" ); | |
12581 | + } | |
12582 | + | |
12583 | + if ( !isDraggable && value ) { | |
12584 | + this._makeDraggable(); | |
12585 | + } | |
12586 | + } | |
12587 | + | |
12588 | + if ( key === "position" ) { | |
12589 | + this._position(); | |
12590 | + } | |
12591 | + | |
12592 | + if ( key === "resizable" ) { | |
12593 | + | |
12594 | + // currently resizable, becoming non-resizable | |
12595 | + isResizable = uiDialog.is( ":data(ui-resizable)" ); | |
12596 | + if ( isResizable && !value ) { | |
12597 | + uiDialog.resizable( "destroy" ); | |
12598 | + } | |
12599 | + | |
12600 | + // Currently resizable, changing handles | |
12601 | + if ( isResizable && typeof value === "string" ) { | |
12602 | + uiDialog.resizable( "option", "handles", value ); | |
12603 | + } | |
12604 | + | |
12605 | + // Currently non-resizable, becoming resizable | |
12606 | + if ( !isResizable && value !== false ) { | |
12607 | + this._makeResizable(); | |
12608 | + } | |
12609 | + } | |
12610 | + | |
12611 | + if ( key === "title" ) { | |
12612 | + this._title( this.uiDialogTitlebar.find( ".ui-dialog-title" ) ); | |
12613 | + } | |
12614 | + }, | |
12615 | + | |
12616 | + _size: function() { | |
12617 | + | |
12618 | + // If the user has resized the dialog, the .ui-dialog and .ui-dialog-content | |
12619 | + // divs will both have width and height set, so we need to reset them | |
12620 | + var nonContentHeight, minContentHeight, maxContentHeight, | |
12621 | + options = this.options; | |
12622 | + | |
12623 | + // Reset content sizing | |
12624 | + this.element.show().css( { | |
12625 | + width: "auto", | |
12626 | + minHeight: 0, | |
12627 | + maxHeight: "none", | |
12628 | + height: 0 | |
12629 | + } ); | |
12630 | + | |
12631 | + if ( options.minWidth > options.width ) { | |
12632 | + options.width = options.minWidth; | |
12633 | + } | |
12634 | + | |
12635 | + // Reset wrapper sizing | |
12636 | + // determine the height of all the non-content elements | |
12637 | + nonContentHeight = this.uiDialog.css( { | |
12638 | + height: "auto", | |
12639 | + width: options.width | |
12640 | + } ) | |
12641 | + .outerHeight(); | |
12642 | + minContentHeight = Math.max( 0, options.minHeight - nonContentHeight ); | |
12643 | + maxContentHeight = typeof options.maxHeight === "number" ? | |
12644 | + Math.max( 0, options.maxHeight - nonContentHeight ) : | |
12645 | + "none"; | |
12646 | + | |
12647 | + if ( options.height === "auto" ) { | |
12648 | + this.element.css( { | |
12649 | + minHeight: minContentHeight, | |
12650 | + maxHeight: maxContentHeight, | |
12651 | + height: "auto" | |
12652 | + } ); | |
12653 | + } else { | |
12654 | + this.element.height( Math.max( 0, options.height - nonContentHeight ) ); | |
12655 | + } | |
12656 | + | |
12657 | + if ( this.uiDialog.is( ":data(ui-resizable)" ) ) { | |
12658 | + this.uiDialog.resizable( "option", "minHeight", this._minHeight() ); | |
12659 | + } | |
12660 | + }, | |
12661 | + | |
12662 | + _blockFrames: function() { | |
12663 | + this.iframeBlocks = this.document.find( "iframe" ).map( function() { | |
12664 | + var iframe = $( this ); | |
12665 | + | |
12666 | + return $( "<div>" ) | |
12667 | + .css( { | |
12668 | + position: "absolute", | |
12669 | + width: iframe.outerWidth(), | |
12670 | + height: iframe.outerHeight() | |
12671 | + } ) | |
12672 | + .appendTo( iframe.parent() ) | |
12673 | + .offset( iframe.offset() )[ 0 ]; | |
12674 | + } ); | |
12675 | + }, | |
12676 | + | |
12677 | + _unblockFrames: function() { | |
12678 | + if ( this.iframeBlocks ) { | |
12679 | + this.iframeBlocks.remove(); | |
12680 | + delete this.iframeBlocks; | |
12681 | + } | |
12682 | + }, | |
12683 | + | |
12684 | + _allowInteraction: function( event ) { | |
12685 | + if ( $( event.target ).closest( ".ui-dialog" ).length ) { | |
12686 | + return true; | |
12687 | + } | |
12688 | + | |
12689 | + // TODO: Remove hack when datepicker implements | |
12690 | + // the .ui-front logic (#8989) | |
12691 | + return !!$( event.target ).closest( ".ui-datepicker" ).length; | |
12692 | + }, | |
12693 | + | |
12694 | + _createOverlay: function() { | |
12695 | + if ( !this.options.modal ) { | |
12696 | + return; | |
12697 | + } | |
12698 | + | |
12699 | + // We use a delay in case the overlay is created from an | |
12700 | + // event that we're going to be cancelling (#2804) | |
12701 | + var isOpening = true; | |
12702 | + this._delay( function() { | |
12703 | + isOpening = false; | |
12704 | + } ); | |
12705 | + | |
12706 | + if ( !this.document.data( "ui-dialog-overlays" ) ) { | |
12707 | + | |
12708 | + // Prevent use of anchors and inputs | |
12709 | + // Using _on() for an event handler shared across many instances is | |
12710 | + // safe because the dialogs stack and must be closed in reverse order | |
12711 | + this._on( this.document, { | |
12712 | + focusin: function( event ) { | |
12713 | + if ( isOpening ) { | |
12714 | + return; | |
12715 | + } | |
12716 | + | |
12717 | + if ( !this._allowInteraction( event ) ) { | |
12718 | + event.preventDefault(); | |
12719 | + this._trackingInstances()[ 0 ]._focusTabbable(); | |
12720 | + } | |
12721 | + } | |
12722 | + } ); | |
12723 | + } | |
12724 | + | |
12725 | + this.overlay = $( "<div>" ) | |
12726 | + .appendTo( this._appendTo() ); | |
12727 | + | |
12728 | + this._addClass( this.overlay, null, "ui-widget-overlay ui-front" ); | |
12729 | + this._on( this.overlay, { | |
12730 | + mousedown: "_keepFocus" | |
12731 | + } ); | |
12732 | + this.document.data( "ui-dialog-overlays", | |
12733 | + ( this.document.data( "ui-dialog-overlays" ) || 0 ) + 1 ); | |
12734 | + }, | |
12735 | + | |
12736 | + _destroyOverlay: function() { | |
12737 | + if ( !this.options.modal ) { | |
12738 | + return; | |
12739 | + } | |
12740 | + | |
12741 | + if ( this.overlay ) { | |
12742 | + var overlays = this.document.data( "ui-dialog-overlays" ) - 1; | |
12743 | + | |
12744 | + if ( !overlays ) { | |
12745 | + this._off( this.document, "focusin" ); | |
12746 | + this.document.removeData( "ui-dialog-overlays" ); | |
12747 | + } else { | |
12748 | + this.document.data( "ui-dialog-overlays", overlays ); | |
12749 | + } | |
12750 | + | |
12751 | + this.overlay.remove(); | |
12752 | + this.overlay = null; | |
12753 | + } | |
12754 | + } | |
12755 | +} ); | |
12756 | + | |
12757 | +// DEPRECATED | |
12758 | +// TODO: switch return back to widget declaration at top of file when this is removed | |
12759 | +if ( $.uiBackCompat !== false ) { | |
12760 | + | |
12761 | + // Backcompat for dialogClass option | |
12762 | + $.widget( "ui.dialog", $.ui.dialog, { | |
12763 | + options: { | |
12764 | + dialogClass: "" | |
12765 | + }, | |
12766 | + _createWrapper: function() { | |
12767 | + this._super(); | |
12768 | + this.uiDialog.addClass( this.options.dialogClass ); | |
12769 | + }, | |
12770 | + _setOption: function( key, value ) { | |
12771 | + if ( key === "dialogClass" ) { | |
12772 | + this.uiDialog | |
12773 | + .removeClass( this.options.dialogClass ) | |
12774 | + .addClass( value ); | |
12775 | + } | |
12776 | + this._superApply( arguments ); | |
12777 | + } | |
12778 | + } ); | |
12779 | +} | |
12780 | + | |
12781 | +var widgetsDialog = $.ui.dialog; | |
12782 | + | |
12783 | + | |
12784 | +/*! | |
12785 | + * jQuery UI Droppable 1.12.0-rc.2 | |
12786 | + * http://jqueryui.com | |
12787 | + * | |
12788 | + * Copyright jQuery Foundation and other contributors | |
12789 | + * Released under the MIT license. | |
12790 | + * http://jquery.org/license | |
12791 | + */ | |
12792 | + | |
12793 | +//>>label: Droppable | |
12794 | +//>>group: Interactions | |
12795 | +//>>description: Enables drop targets for draggable elements. | |
12796 | +//>>docs: http://api.jqueryui.com/droppable/ | |
12797 | +//>>demos: http://jqueryui.com/droppable/ | |
12798 | + | |
12799 | + | |
12800 | + | |
12801 | +$.widget( "ui.droppable", { | |
12802 | + version: "1.12.0-rc.2", | |
12803 | + widgetEventPrefix: "drop", | |
12804 | + options: { | |
12805 | + accept: "*", | |
12806 | + addClasses: true, | |
12807 | + greedy: false, | |
12808 | + scope: "default", | |
12809 | + tolerance: "intersect", | |
12810 | + | |
12811 | + // Callbacks | |
12812 | + activate: null, | |
12813 | + deactivate: null, | |
12814 | + drop: null, | |
12815 | + out: null, | |
12816 | + over: null | |
12817 | + }, | |
12818 | + _create: function() { | |
12819 | + | |
12820 | + var proportions, | |
12821 | + o = this.options, | |
12822 | + accept = o.accept; | |
12823 | + | |
12824 | + this.isover = false; | |
12825 | + this.isout = true; | |
12826 | + | |
12827 | + this.accept = $.isFunction( accept ) ? accept : function( d ) { | |
12828 | + return d.is( accept ); | |
12829 | + }; | |
12830 | + | |
12831 | + this.proportions = function( /* valueToWrite */ ) { | |
12832 | + if ( arguments.length ) { | |
12833 | + | |
12834 | + // Store the droppable's proportions | |
12835 | + proportions = arguments[ 0 ]; | |
12836 | + } else { | |
12837 | + | |
12838 | + // Retrieve or derive the droppable's proportions | |
12839 | + return proportions ? | |
12840 | + proportions : | |
12841 | + proportions = { | |
12842 | + width: this.element[ 0 ].offsetWidth, | |
12843 | + height: this.element[ 0 ].offsetHeight | |
12844 | + }; | |
12845 | + } | |
12846 | + }; | |
12847 | + | |
12848 | + this._addToManager( o.scope ); | |
12849 | + | |
12850 | + o.addClasses && this._addClass( "ui-droppable" ); | |
12851 | + | |
12852 | + }, | |
12853 | + | |
12854 | + _addToManager: function( scope ) { | |
12855 | + | |
12856 | + // Add the reference and positions to the manager | |
12857 | + $.ui.ddmanager.droppables[ scope ] = $.ui.ddmanager.droppables[ scope ] || []; | |
12858 | + $.ui.ddmanager.droppables[ scope ].push( this ); | |
12859 | + }, | |
12860 | + | |
12861 | + _splice: function( drop ) { | |
12862 | + var i = 0; | |
12863 | + for ( ; i < drop.length; i++ ) { | |
12864 | + if ( drop[ i ] === this ) { | |
12865 | + drop.splice( i, 1 ); | |
12866 | + } | |
12867 | + } | |
12868 | + }, | |
12869 | + | |
12870 | + _destroy: function() { | |
12871 | + var drop = $.ui.ddmanager.droppables[ this.options.scope ]; | |
12872 | + | |
12873 | + this._splice( drop ); | |
12874 | + }, | |
12875 | + | |
12876 | + _setOption: function( key, value ) { | |
12877 | + | |
12878 | + if ( key === "accept" ) { | |
12879 | + this.accept = $.isFunction( value ) ? value : function( d ) { | |
12880 | + return d.is( value ); | |
12881 | + }; | |
12882 | + } else if ( key === "scope" ) { | |
12883 | + var drop = $.ui.ddmanager.droppables[ this.options.scope ]; | |
12884 | + | |
12885 | + this._splice( drop ); | |
12886 | + this._addToManager( value ); | |
12887 | + } | |
12888 | + | |
12889 | + this._super( key, value ); | |
12890 | + }, | |
12891 | + | |
12892 | + _activate: function( event ) { | |
12893 | + var draggable = $.ui.ddmanager.current; | |
12894 | + | |
12895 | + this._addActiveClass(); | |
12896 | + if ( draggable ) { | |
12897 | + this._trigger( "activate", event, this.ui( draggable ) ); | |
12898 | + } | |
12899 | + }, | |
12900 | + | |
12901 | + _deactivate: function( event ) { | |
12902 | + var draggable = $.ui.ddmanager.current; | |
12903 | + | |
12904 | + this._removeActiveClass(); | |
12905 | + if ( draggable ) { | |
12906 | + this._trigger( "deactivate", event, this.ui( draggable ) ); | |
12907 | + } | |
12908 | + }, | |
12909 | + | |
12910 | + _over: function( event ) { | |
12911 | + | |
12912 | + var draggable = $.ui.ddmanager.current; | |
12913 | + | |
12914 | + // Bail if draggable and droppable are same element | |
12915 | + if ( !draggable || ( draggable.currentItem || | |
12916 | + draggable.element )[ 0 ] === this.element[ 0 ] ) { | |
12917 | + return; | |
12918 | + } | |
12919 | + | |
12920 | + if ( this.accept.call( this.element[ 0 ], ( draggable.currentItem || | |
12921 | + draggable.element ) ) ) { | |
12922 | + this._addHoverClass(); | |
12923 | + this._trigger( "over", event, this.ui( draggable ) ); | |
12924 | + } | |
12925 | + | |
12926 | + }, | |
12927 | + | |
12928 | + _out: function( event ) { | |
12929 | + | |
12930 | + var draggable = $.ui.ddmanager.current; | |
12931 | + | |
12932 | + // Bail if draggable and droppable are same element | |
12933 | + if ( !draggable || ( draggable.currentItem || | |
12934 | + draggable.element )[ 0 ] === this.element[ 0 ] ) { | |
12935 | + return; | |
12936 | + } | |
12937 | + | |
12938 | + if ( this.accept.call( this.element[ 0 ], ( draggable.currentItem || | |
12939 | + draggable.element ) ) ) { | |
12940 | + this._removeHoverClass(); | |
12941 | + this._trigger( "out", event, this.ui( draggable ) ); | |
12942 | + } | |
12943 | + | |
12944 | + }, | |
12945 | + | |
12946 | + _drop: function( event, custom ) { | |
12947 | + | |
12948 | + var draggable = custom || $.ui.ddmanager.current, | |
12949 | + childrenIntersection = false; | |
12950 | + | |
12951 | + // Bail if draggable and droppable are same element | |
12952 | + if ( !draggable || ( draggable.currentItem || | |
12953 | + draggable.element )[ 0 ] === this.element[ 0 ] ) { | |
12954 | + return false; | |
12955 | + } | |
12956 | + | |
12957 | + this.element | |
12958 | + .find( ":data(ui-droppable)" ) | |
12959 | + .not( ".ui-draggable-dragging" ) | |
12960 | + .each( function() { | |
12961 | + var inst = $( this ).droppable( "instance" ); | |
12962 | + if ( | |
12963 | + inst.options.greedy && | |
12964 | + !inst.options.disabled && | |
12965 | + inst.options.scope === draggable.options.scope && | |
12966 | + inst.accept.call( | |
12967 | + inst.element[ 0 ], ( draggable.currentItem || draggable.element ) | |
12968 | + ) && | |
12969 | + intersect( | |
12970 | + draggable, | |
12971 | + $.extend( inst, { offset: inst.element.offset() } ), | |
12972 | + inst.options.tolerance, event | |
12973 | + ) | |
12974 | + ) { | |
12975 | + childrenIntersection = true; | |
12976 | + return false; } | |
12977 | + } ); | |
12978 | + if ( childrenIntersection ) { | |
12979 | + return false; | |
12980 | + } | |
12981 | + | |
12982 | + if ( this.accept.call( this.element[ 0 ], | |
12983 | + ( draggable.currentItem || draggable.element ) ) ) { | |
12984 | + this._removeActiveClass(); | |
12985 | + this._removeHoverClass(); | |
12986 | + | |
12987 | + this._trigger( "drop", event, this.ui( draggable ) ); | |
12988 | + return this.element; | |
12989 | + } | |
12990 | + | |
12991 | + return false; | |
12992 | + | |
12993 | + }, | |
12994 | + | |
12995 | + ui: function( c ) { | |
12996 | + return { | |
12997 | + draggable: ( c.currentItem || c.element ), | |
12998 | + helper: c.helper, | |
12999 | + position: c.position, | |
13000 | + offset: c.positionAbs | |
13001 | + }; | |
13002 | + }, | |
13003 | + | |
13004 | + // Extension points just to make backcompat sane and avoid duplicating logic | |
13005 | + // TODO: Remove in 1.13 along with call to it below | |
13006 | + _addHoverClass: function() { | |
13007 | + this._addClass( "ui-droppable-hover" ); | |
13008 | + }, | |
13009 | + | |
13010 | + _removeHoverClass: function() { | |
13011 | + this._removeClass( "ui-droppable-hover" ); | |
13012 | + }, | |
13013 | + | |
13014 | + _addActiveClass: function() { | |
13015 | + this._addClass( "ui-droppable-active" ); | |
13016 | + }, | |
13017 | + | |
13018 | + _removeActiveClass: function() { | |
13019 | + this._removeClass( "ui-droppable-active" ); | |
13020 | + } | |
13021 | +} ); | |
13022 | + | |
13023 | +var intersect = ( function() { | |
13024 | + function isOverAxis( x, reference, size ) { | |
13025 | + return ( x >= reference ) && ( x < ( reference + size ) ); | |
13026 | + } | |
13027 | + | |
13028 | + return function( draggable, droppable, toleranceMode, event ) { | |
13029 | + | |
13030 | + if ( !droppable.offset ) { | |
13031 | + return false; | |
13032 | + } | |
13033 | + | |
13034 | + var x1 = ( draggable.positionAbs || | |
13035 | + draggable.position.absolute ).left + draggable.margins.left, | |
13036 | + y1 = ( draggable.positionAbs || | |
13037 | + draggable.position.absolute ).top + draggable.margins.top, | |
13038 | + x2 = x1 + draggable.helperProportions.width, | |
13039 | + y2 = y1 + draggable.helperProportions.height, | |
13040 | + l = droppable.offset.left, | |
13041 | + t = droppable.offset.top, | |
13042 | + r = l + droppable.proportions().width, | |
13043 | + b = t + droppable.proportions().height; | |
13044 | + | |
13045 | + switch ( toleranceMode ) { | |
13046 | + case "fit": | |
13047 | + return ( l <= x1 && x2 <= r && t <= y1 && y2 <= b ); | |
13048 | + case "intersect": | |
13049 | + return ( l < x1 + ( draggable.helperProportions.width / 2 ) && // Right Half | |
13050 | + x2 - ( draggable.helperProportions.width / 2 ) < r && // Left Half | |
13051 | + t < y1 + ( draggable.helperProportions.height / 2 ) && // Bottom Half | |
13052 | + y2 - ( draggable.helperProportions.height / 2 ) < b ); // Top Half | |
13053 | + case "pointer": | |
13054 | + return isOverAxis( event.pageY, t, droppable.proportions().height ) && | |
13055 | + isOverAxis( event.pageX, l, droppable.proportions().width ); | |
13056 | + case "touch": | |
13057 | + return ( | |
13058 | + ( y1 >= t && y1 <= b ) || // Top edge touching | |
13059 | + ( y2 >= t && y2 <= b ) || // Bottom edge touching | |
13060 | + ( y1 < t && y2 > b ) // Surrounded vertically | |
13061 | + ) && ( | |
13062 | + ( x1 >= l && x1 <= r ) || // Left edge touching | |
13063 | + ( x2 >= l && x2 <= r ) || // Right edge touching | |
13064 | + ( x1 < l && x2 > r ) // Surrounded horizontally | |
13065 | + ); | |
13066 | + default: | |
13067 | + return false; | |
13068 | + } | |
13069 | + }; | |
13070 | +} )(); | |
13071 | + | |
13072 | +/* | |
13073 | + This manager tracks offsets of draggables and droppables | |
13074 | +*/ | |
13075 | +$.ui.ddmanager = { | |
13076 | + current: null, | |
13077 | + droppables: { "default": [] }, | |
13078 | + prepareOffsets: function( t, event ) { | |
13079 | + | |
13080 | + var i, j, | |
13081 | + m = $.ui.ddmanager.droppables[ t.options.scope ] || [], | |
13082 | + type = event ? event.type : null, // workaround for #2317 | |
13083 | + list = ( t.currentItem || t.element ).find( ":data(ui-droppable)" ).addBack(); | |
13084 | + | |
13085 | + droppablesLoop: for ( i = 0; i < m.length; i++ ) { | |
13086 | + | |
13087 | + // No disabled and non-accepted | |
13088 | + if ( m[ i ].options.disabled || ( t && !m[ i ].accept.call( m[ i ].element[ 0 ], | |
13089 | + ( t.currentItem || t.element ) ) ) ) { | |
13090 | + continue; | |
13091 | + } | |
13092 | + | |
13093 | + // Filter out elements in the current dragged item | |
13094 | + for ( j = 0; j < list.length; j++ ) { | |
13095 | + if ( list[ j ] === m[ i ].element[ 0 ] ) { | |
13096 | + m[ i ].proportions().height = 0; | |
13097 | + continue droppablesLoop; | |
13098 | + } | |
13099 | + } | |
13100 | + | |
13101 | + m[ i ].visible = m[ i ].element.css( "display" ) !== "none"; | |
13102 | + if ( !m[ i ].visible ) { | |
13103 | + continue; | |
13104 | + } | |
13105 | + | |
13106 | + // Activate the droppable if used directly from draggables | |
13107 | + if ( type === "mousedown" ) { | |
13108 | + m[ i ]._activate.call( m[ i ], event ); | |
13109 | + } | |
13110 | + | |
13111 | + m[ i ].offset = m[ i ].element.offset(); | |
13112 | + m[ i ].proportions( { | |
13113 | + width: m[ i ].element[ 0 ].offsetWidth, | |
13114 | + height: m[ i ].element[ 0 ].offsetHeight | |
13115 | + } ); | |
13116 | + | |
13117 | + } | |
13118 | + | |
13119 | + }, | |
13120 | + drop: function( draggable, event ) { | |
13121 | + | |
13122 | + var dropped = false; | |
13123 | + | |
13124 | + // Create a copy of the droppables in case the list changes during the drop (#9116) | |
13125 | + $.each( ( $.ui.ddmanager.droppables[ draggable.options.scope ] || [] ).slice(), function() { | |
13126 | + | |
13127 | + if ( !this.options ) { | |
13128 | + return; | |
13129 | + } | |
13130 | + if ( !this.options.disabled && this.visible && | |
13131 | + intersect( draggable, this, this.options.tolerance, event ) ) { | |
13132 | + dropped = this._drop.call( this, event ) || dropped; | |
13133 | + } | |
13134 | + | |
13135 | + if ( !this.options.disabled && this.visible && this.accept.call( this.element[ 0 ], | |
13136 | + ( draggable.currentItem || draggable.element ) ) ) { | |
13137 | + this.isout = true; | |
13138 | + this.isover = false; | |
13139 | + this._deactivate.call( this, event ); | |
13140 | + } | |
13141 | + | |
13142 | + } ); | |
13143 | + return dropped; | |
13144 | + | |
13145 | + }, | |
13146 | + dragStart: function( draggable, event ) { | |
13147 | + | |
13148 | + // Listen for scrolling so that if the dragging causes scrolling the position of the | |
13149 | + // droppables can be recalculated (see #5003) | |
13150 | + draggable.element.parentsUntil( "body" ).on( "scroll.droppable", function() { | |
13151 | + if ( !draggable.options.refreshPositions ) { | |
13152 | + $.ui.ddmanager.prepareOffsets( draggable, event ); | |
13153 | + } | |
13154 | + } ); | |
13155 | + }, | |
13156 | + drag: function( draggable, event ) { | |
13157 | + | |
13158 | + // If you have a highly dynamic page, you might try this option. It renders positions | |
13159 | + // every time you move the mouse. | |
13160 | + if ( draggable.options.refreshPositions ) { | |
13161 | + $.ui.ddmanager.prepareOffsets( draggable, event ); | |
13162 | + } | |
13163 | + | |
13164 | + // Run through all droppables and check their positions based on specific tolerance options | |
13165 | + $.each( $.ui.ddmanager.droppables[ draggable.options.scope ] || [], function() { | |
13166 | + | |
13167 | + if ( this.options.disabled || this.greedyChild || !this.visible ) { | |
13168 | + return; | |
13169 | + } | |
13170 | + | |
13171 | + var parentInstance, scope, parent, | |
13172 | + intersects = intersect( draggable, this, this.options.tolerance, event ), | |
13173 | + c = !intersects && this.isover ? | |
13174 | + "isout" : | |
13175 | + ( intersects && !this.isover ? "isover" : null ); | |
13176 | + if ( !c ) { | |
13177 | + return; | |
13178 | + } | |
13179 | + | |
13180 | + if ( this.options.greedy ) { | |
13181 | + | |
13182 | + // find droppable parents with same scope | |
13183 | + scope = this.options.scope; | |
13184 | + parent = this.element.parents( ":data(ui-droppable)" ).filter( function() { | |
13185 | + return $( this ).droppable( "instance" ).options.scope === scope; | |
13186 | + } ); | |
13187 | + | |
13188 | + if ( parent.length ) { | |
13189 | + parentInstance = $( parent[ 0 ] ).droppable( "instance" ); | |
13190 | + parentInstance.greedyChild = ( c === "isover" ); | |
13191 | + } | |
13192 | + } | |
13193 | + | |
13194 | + // We just moved into a greedy child | |
13195 | + if ( parentInstance && c === "isover" ) { | |
13196 | + parentInstance.isover = false; | |
13197 | + parentInstance.isout = true; | |
13198 | + parentInstance._out.call( parentInstance, event ); | |
13199 | + } | |
13200 | + | |
13201 | + this[ c ] = true; | |
13202 | + this[ c === "isout" ? "isover" : "isout" ] = false; | |
13203 | + this[ c === "isover" ? "_over" : "_out" ].call( this, event ); | |
13204 | + | |
13205 | + // We just moved out of a greedy child | |
13206 | + if ( parentInstance && c === "isout" ) { | |
13207 | + parentInstance.isout = false; | |
13208 | + parentInstance.isover = true; | |
13209 | + parentInstance._over.call( parentInstance, event ); | |
13210 | + } | |
13211 | + } ); | |
13212 | + | |
13213 | + }, | |
13214 | + dragStop: function( draggable, event ) { | |
13215 | + draggable.element.parentsUntil( "body" ).off( "scroll.droppable" ); | |
13216 | + | |
13217 | + // Call prepareOffsets one final time since IE does not fire return scroll events when | |
13218 | + // overflow was caused by drag (see #5003) | |
13219 | + if ( !draggable.options.refreshPositions ) { | |
13220 | + $.ui.ddmanager.prepareOffsets( draggable, event ); | |
13221 | + } | |
13222 | + } | |
13223 | +}; | |
13224 | + | |
13225 | +// DEPRECATED | |
13226 | +// TODO: switch return back to widget declaration at top of file when this is removed | |
13227 | +if ( $.uiBackCompat !== false ) { | |
13228 | + | |
13229 | + // Backcompat for activeClass and hoverClass options | |
13230 | + $.widget( "ui.droppable", $.ui.droppable, { | |
13231 | + options: { | |
13232 | + hoverClass: false, | |
13233 | + activeClass: false | |
13234 | + }, | |
13235 | + _addActiveClass: function() { | |
13236 | + this._super(); | |
13237 | + if ( this.options.activeClass ) { | |
13238 | + this.element.addClass( this.options.activeClass ); | |
13239 | + } | |
13240 | + }, | |
13241 | + _removeActiveClass: function() { | |
13242 | + this._super(); | |
13243 | + if ( this.options.activeClass ) { | |
13244 | + this.element.removeClass( this.options.activeClass ); | |
13245 | + } | |
13246 | + }, | |
13247 | + _addHoverClass: function() { | |
13248 | + this._super(); | |
13249 | + if ( this.options.hoverClass ) { | |
13250 | + this.element.addClass( this.options.hoverClass ); | |
13251 | + } | |
13252 | + }, | |
13253 | + _removeHoverClass: function() { | |
13254 | + this._super(); | |
13255 | + if ( this.options.hoverClass ) { | |
13256 | + this.element.removeClass( this.options.hoverClass ); | |
13257 | + } | |
13258 | + } | |
13259 | + } ); | |
13260 | +} | |
13261 | + | |
13262 | +var widgetsDroppable = $.ui.droppable; | |
13263 | + | |
13264 | + | |
13265 | +/*! | |
13266 | + * jQuery UI Progressbar 1.12.0-rc.2 | |
13267 | + * http://jqueryui.com | |
13268 | + * | |
13269 | + * Copyright jQuery Foundation and other contributors | |
13270 | + * Released under the MIT license. | |
13271 | + * http://jquery.org/license | |
13272 | + */ | |
13273 | + | |
13274 | +//>>label: Progressbar | |
13275 | +//>>group: Widgets | |
13276 | +// jscs:disable maximumLineLength | |
13277 | +//>>description: Displays a status indicator for loading state, standard percentage, and other progress indicators. | |
13278 | +// jscs:enable maximumLineLength | |
13279 | +//>>docs: http://api.jqueryui.com/progressbar/ | |
13280 | +//>>demos: http://jqueryui.com/progressbar/ | |
13281 | +//>>css.structure: ../../themes/base/core.css | |
13282 | +//>>css.structure: ../../themes/base/progressbar.css | |
13283 | +//>>css.theme: ../../themes/base/theme.css | |
13284 | + | |
13285 | + | |
13286 | + | |
13287 | +var widgetsProgressbar = $.widget( "ui.progressbar", { | |
13288 | + version: "1.12.0-rc.2", | |
13289 | + options: { | |
13290 | + classes: { | |
13291 | + "ui-progressbar": "ui-corner-all", | |
13292 | + "ui-progressbar-value": "ui-corner-left", | |
13293 | + "ui-progressbar-complete": "ui-corner-right" | |
13294 | + }, | |
13295 | + max: 100, | |
13296 | + value: 0, | |
13297 | + | |
13298 | + change: null, | |
13299 | + complete: null | |
13300 | + }, | |
13301 | + | |
13302 | + min: 0, | |
13303 | + | |
13304 | + _create: function() { | |
13305 | + | |
13306 | + // Constrain initial value | |
13307 | + this.oldValue = this.options.value = this._constrainedValue(); | |
13308 | + | |
13309 | + this.element.attr( { | |
13310 | + | |
13311 | + // Only set static values; aria-valuenow and aria-valuemax are | |
13312 | + // set inside _refreshValue() | |
13313 | + role: "progressbar", | |
13314 | + "aria-valuemin": this.min | |
13315 | + } ); | |
13316 | + this._addClass( "ui-progressbar", "ui-widget ui-widget-content" ); | |
13317 | + | |
13318 | + this.valueDiv = $( "<div>" ).appendTo( this.element ); | |
13319 | + this._addClass( this.valueDiv, "ui-progressbar-value", "ui-widget-header" ); | |
13320 | + this._refreshValue(); | |
13321 | + }, | |
13322 | + | |
13323 | + _destroy: function() { | |
13324 | + this.element.removeAttr( "role aria-valuemin aria-valuemax aria-valuenow" ); | |
13325 | + | |
13326 | + this.valueDiv.remove(); | |
13327 | + }, | |
13328 | + | |
13329 | + value: function( newValue ) { | |
13330 | + if ( newValue === undefined ) { | |
13331 | + return this.options.value; | |
13332 | + } | |
13333 | + | |
13334 | + this.options.value = this._constrainedValue( newValue ); | |
13335 | + this._refreshValue(); | |
13336 | + }, | |
13337 | + | |
13338 | + _constrainedValue: function( newValue ) { | |
13339 | + if ( newValue === undefined ) { | |
13340 | + newValue = this.options.value; | |
13341 | + } | |
13342 | + | |
13343 | + this.indeterminate = newValue === false; | |
13344 | + | |
13345 | + // Sanitize value | |
13346 | + if ( typeof newValue !== "number" ) { | |
13347 | + newValue = 0; | |
13348 | + } | |
13349 | + | |
13350 | + return this.indeterminate ? false : | |
13351 | + Math.min( this.options.max, Math.max( this.min, newValue ) ); | |
13352 | + }, | |
13353 | + | |
13354 | + _setOptions: function( options ) { | |
13355 | + | |
13356 | + // Ensure "value" option is set after other values (like max) | |
13357 | + var value = options.value; | |
13358 | + delete options.value; | |
13359 | + | |
13360 | + this._super( options ); | |
13361 | + | |
13362 | + this.options.value = this._constrainedValue( value ); | |
13363 | + this._refreshValue(); | |
13364 | + }, | |
13365 | + | |
13366 | + _setOption: function( key, value ) { | |
13367 | + if ( key === "max" ) { | |
13368 | + | |
13369 | + // Don't allow a max less than min | |
13370 | + value = Math.max( this.min, value ); | |
13371 | + } | |
13372 | + this._super( key, value ); | |
13373 | + }, | |
13374 | + | |
13375 | + _setOptionDisabled: function( value ) { | |
13376 | + this._super( value ); | |
13377 | + | |
13378 | + this.element.attr( "aria-disabled", value ); | |
13379 | + this._toggleClass( null, "ui-state-disabled", !!value ); | |
13380 | + }, | |
13381 | + | |
13382 | + _percentage: function() { | |
13383 | + return this.indeterminate ? | |
13384 | + 100 : | |
13385 | + 100 * ( this.options.value - this.min ) / ( this.options.max - this.min ); | |
13386 | + }, | |
13387 | + | |
13388 | + _refreshValue: function() { | |
13389 | + var value = this.options.value, | |
13390 | + percentage = this._percentage(); | |
13391 | + | |
13392 | + this.valueDiv | |
13393 | + .toggle( this.indeterminate || value > this.min ) | |
13394 | + .width( percentage.toFixed( 0 ) + "%" ); | |
13395 | + | |
13396 | + this | |
13397 | + ._toggleClass( this.valueDiv, "ui-progressbar-complete", null, | |
13398 | + value === this.options.max ) | |
13399 | + ._toggleClass( "ui-progressbar-indeterminate", null, this.indeterminate ); | |
13400 | + | |
13401 | + if ( this.indeterminate ) { | |
13402 | + this.element.removeAttr( "aria-valuenow" ); | |
13403 | + if ( !this.overlayDiv ) { | |
13404 | + this.overlayDiv = $( "<div>" ).appendTo( this.valueDiv ); | |
13405 | + this._addClass( this.overlayDiv, "ui-progressbar-overlay" ); | |
13406 | + } | |
13407 | + } else { | |
13408 | + this.element.attr( { | |
13409 | + "aria-valuemax": this.options.max, | |
13410 | + "aria-valuenow": value | |
13411 | + } ); | |
13412 | + if ( this.overlayDiv ) { | |
13413 | + this.overlayDiv.remove(); | |
13414 | + this.overlayDiv = null; | |
13415 | + } | |
13416 | + } | |
13417 | + | |
13418 | + if ( this.oldValue !== value ) { | |
13419 | + this.oldValue = value; | |
13420 | + this._trigger( "change" ); | |
13421 | + } | |
13422 | + if ( value === this.options.max ) { | |
13423 | + this._trigger( "complete" ); | |
13424 | + } | |
13425 | + } | |
13426 | +} ); | |
13427 | + | |
13428 | + | |
13429 | +/*! | |
13430 | + * jQuery UI Selectable 1.12.0-rc.2 | |
13431 | + * http://jqueryui.com | |
13432 | + * | |
13433 | + * Copyright jQuery Foundation and other contributors | |
13434 | + * Released under the MIT license. | |
13435 | + * http://jquery.org/license | |
13436 | + */ | |
13437 | + | |
13438 | +//>>label: Selectable | |
13439 | +//>>group: Interactions | |
13440 | +//>>description: Allows groups of elements to be selected with the mouse. | |
13441 | +//>>docs: http://api.jqueryui.com/selectable/ | |
13442 | +//>>demos: http://jqueryui.com/selectable/ | |
13443 | +//>>css.structure: ../../themes/base/selectable.css | |
13444 | + | |
13445 | + | |
13446 | + | |
13447 | +var widgetsSelectable = $.widget( "ui.selectable", $.ui.mouse, { | |
13448 | + version: "1.12.0-rc.2", | |
13449 | + options: { | |
13450 | + appendTo: "body", | |
13451 | + autoRefresh: true, | |
13452 | + distance: 0, | |
13453 | + filter: "*", | |
13454 | + tolerance: "touch", | |
13455 | + | |
13456 | + // Callbacks | |
13457 | + selected: null, | |
13458 | + selecting: null, | |
13459 | + start: null, | |
13460 | + stop: null, | |
13461 | + unselected: null, | |
13462 | + unselecting: null | |
13463 | + }, | |
13464 | + _create: function() { | |
13465 | + var that = this; | |
13466 | + | |
13467 | + this._addClass( "ui-selectable" ); | |
13468 | + | |
13469 | + this.dragged = false; | |
13470 | + | |
13471 | + // Cache selectee children based on filter | |
13472 | + this.refresh = function() { | |
13473 | + that.elementPos = $( that.element[ 0 ] ).offset(); | |
13474 | + that.selectees = $( that.options.filter, that.element[ 0 ] ); | |
13475 | + that._addClass( that.selectees, "ui-selectee" ); | |
13476 | + that.selectees.each( function() { | |
13477 | + var $this = $( this ), | |
13478 | + selecteeOffset = $this.offset(), | |
13479 | + pos = { | |
13480 | + left: selecteeOffset.left - that.elementPos.left, | |
13481 | + top: selecteeOffset.top - that.elementPos.top | |
13482 | + }; | |
13483 | + $.data( this, "selectable-item", { | |
13484 | + element: this, | |
13485 | + $element: $this, | |
13486 | + left: pos.left, | |
13487 | + top: pos.top, | |
13488 | + right: pos.left + $this.outerWidth(), | |
13489 | + bottom: pos.top + $this.outerHeight(), | |
13490 | + startselected: false, | |
13491 | + selected: $this.hasClass( "ui-selected" ), | |
13492 | + selecting: $this.hasClass( "ui-selecting" ), | |
13493 | + unselecting: $this.hasClass( "ui-unselecting" ) | |
13494 | + } ); | |
13495 | + } ); | |
13496 | + }; | |
13497 | + this.refresh(); | |
13498 | + | |
13499 | + this._mouseInit(); | |
13500 | + | |
13501 | + this.helper = $( "<div>" ); | |
13502 | + this._addClass( this.helper, "ui-selectable-helper" ); | |
13503 | + }, | |
13504 | + | |
13505 | + _destroy: function() { | |
13506 | + this.selectees.removeData( "selectable-item" ); | |
13507 | + this._mouseDestroy(); | |
13508 | + }, | |
13509 | + | |
13510 | + _mouseStart: function( event ) { | |
13511 | + var that = this, | |
13512 | + options = this.options; | |
13513 | + | |
13514 | + this.opos = [ event.pageX, event.pageY ]; | |
13515 | + this.elementPos = $( this.element[ 0 ] ).offset(); | |
13516 | + | |
13517 | + if ( this.options.disabled ) { | |
13518 | + return; | |
13519 | + } | |
13520 | + | |
13521 | + this.selectees = $( options.filter, this.element[ 0 ] ); | |
13522 | + | |
13523 | + this._trigger( "start", event ); | |
13524 | + | |
13525 | + $( options.appendTo ).append( this.helper ); | |
13526 | + | |
13527 | + // position helper (lasso) | |
13528 | + this.helper.css( { | |
13529 | + "left": event.pageX, | |
13530 | + "top": event.pageY, | |
13531 | + "width": 0, | |
13532 | + "height": 0 | |
13533 | + } ); | |
13534 | + | |
13535 | + if ( options.autoRefresh ) { | |
13536 | + this.refresh(); | |
13537 | + } | |
13538 | + | |
13539 | + this.selectees.filter( ".ui-selected" ).each( function() { | |
13540 | + var selectee = $.data( this, "selectable-item" ); | |
13541 | + selectee.startselected = true; | |
13542 | + if ( !event.metaKey && !event.ctrlKey ) { | |
13543 | + that._removeClass( selectee.$element, "ui-selected" ); | |
13544 | + selectee.selected = false; | |
13545 | + that._addClass( selectee.$element, "ui-unselecting" ); | |
13546 | + selectee.unselecting = true; | |
13547 | + | |
13548 | + // selectable UNSELECTING callback | |
13549 | + that._trigger( "unselecting", event, { | |
13550 | + unselecting: selectee.element | |
13551 | + } ); | |
13552 | + } | |
13553 | + } ); | |
13554 | + | |
13555 | + $( event.target ).parents().addBack().each( function() { | |
13556 | + var doSelect, | |
13557 | + selectee = $.data( this, "selectable-item" ); | |
13558 | + if ( selectee ) { | |
13559 | + doSelect = ( !event.metaKey && !event.ctrlKey ) || | |
13560 | + !selectee.$element.hasClass( "ui-selected" ); | |
13561 | + that._removeClass( selectee.$element, doSelect ? "ui-unselecting" : "ui-selected" ) | |
13562 | + ._addClass( selectee.$element, doSelect ? "ui-selecting" : "ui-unselecting" ); | |
13563 | + selectee.unselecting = !doSelect; | |
13564 | + selectee.selecting = doSelect; | |
13565 | + selectee.selected = doSelect; | |
13566 | + | |
13567 | + // selectable (UN)SELECTING callback | |
13568 | + if ( doSelect ) { | |
13569 | + that._trigger( "selecting", event, { | |
13570 | + selecting: selectee.element | |
13571 | + } ); | |
13572 | + } else { | |
13573 | + that._trigger( "unselecting", event, { | |
13574 | + unselecting: selectee.element | |
13575 | + } ); | |
13576 | + } | |
13577 | + return false; | |
13578 | + } | |
13579 | + } ); | |
13580 | + | |
13581 | + }, | |
13582 | + | |
13583 | + _mouseDrag: function( event ) { | |
13584 | + | |
13585 | + this.dragged = true; | |
13586 | + | |
13587 | + if ( this.options.disabled ) { | |
13588 | + return; | |
13589 | + } | |
13590 | + | |
13591 | + var tmp, | |
13592 | + that = this, | |
13593 | + options = this.options, | |
13594 | + x1 = this.opos[ 0 ], | |
13595 | + y1 = this.opos[ 1 ], | |
13596 | + x2 = event.pageX, | |
13597 | + y2 = event.pageY; | |
13598 | + | |
13599 | + if ( x1 > x2 ) { tmp = x2; x2 = x1; x1 = tmp; } | |
13600 | + if ( y1 > y2 ) { tmp = y2; y2 = y1; y1 = tmp; } | |
13601 | + this.helper.css( { left: x1, top: y1, width: x2 - x1, height: y2 - y1 } ); | |
13602 | + | |
13603 | + this.selectees.each( function() { | |
13604 | + var selectee = $.data( this, "selectable-item" ), | |
13605 | + hit = false, | |
13606 | + offset = {}; | |
13607 | + | |
13608 | + //prevent helper from being selected if appendTo: selectable | |
13609 | + if ( !selectee || selectee.element === that.element[ 0 ] ) { | |
13610 | + return; | |
13611 | + } | |
13612 | + | |
13613 | + offset.left = selectee.left + that.elementPos.left; | |
13614 | + offset.right = selectee.right + that.elementPos.left; | |
13615 | + offset.top = selectee.top + that.elementPos.top; | |
13616 | + offset.bottom = selectee.bottom + that.elementPos.top; | |
13617 | + | |
13618 | + if ( options.tolerance === "touch" ) { | |
13619 | + hit = ( !( offset.left > x2 || offset.right < x1 || offset.top > y2 || | |
13620 | + offset.bottom < y1 ) ); | |
13621 | + } else if ( options.tolerance === "fit" ) { | |
13622 | + hit = ( offset.left > x1 && offset.right < x2 && offset.top > y1 && | |
13623 | + offset.bottom < y2 ); | |
13624 | + } | |
13625 | + | |
13626 | + if ( hit ) { | |
13627 | + | |
13628 | + // SELECT | |
13629 | + if ( selectee.selected ) { | |
13630 | + that._removeClass( selectee.$element, "ui-selected" ); | |
13631 | + selectee.selected = false; | |
13632 | + } | |
13633 | + if ( selectee.unselecting ) { | |
13634 | + that._removeClass( selectee.$element, "ui-unselecting" ); | |
13635 | + selectee.unselecting = false; | |
13636 | + } | |
13637 | + if ( !selectee.selecting ) { | |
13638 | + that._addClass( selectee.$element, "ui-selecting" ); | |
13639 | + selectee.selecting = true; | |
13640 | + | |
13641 | + // selectable SELECTING callback | |
13642 | + that._trigger( "selecting", event, { | |
13643 | + selecting: selectee.element | |
13644 | + } ); | |
13645 | + } | |
13646 | + } else { | |
13647 | + | |
13648 | + // UNSELECT | |
13649 | + if ( selectee.selecting ) { | |
13650 | + if ( ( event.metaKey || event.ctrlKey ) && selectee.startselected ) { | |
13651 | + that._removeClass( selectee.$element, "ui-selecting" ); | |
13652 | + selectee.selecting = false; | |
13653 | + that._addClass( selectee.$element, "ui-selected" ); | |
13654 | + selectee.selected = true; | |
13655 | + } else { | |
13656 | + that._removeClass( selectee.$element, "ui-selecting" ); | |
13657 | + selectee.selecting = false; | |
13658 | + if ( selectee.startselected ) { | |
13659 | + that._addClass( selectee.$element, "ui-unselecting" ); | |
13660 | + selectee.unselecting = true; | |
13661 | + } | |
13662 | + | |
13663 | + // selectable UNSELECTING callback | |
13664 | + that._trigger( "unselecting", event, { | |
13665 | + unselecting: selectee.element | |
13666 | + } ); | |
13667 | + } | |
13668 | + } | |
13669 | + if ( selectee.selected ) { | |
13670 | + if ( !event.metaKey && !event.ctrlKey && !selectee.startselected ) { | |
13671 | + that._removeClass( selectee.$element, "ui-selected" ); | |
13672 | + selectee.selected = false; | |
13673 | + | |
13674 | + that._addClass( selectee.$element, "ui-unselecting" ); | |
13675 | + selectee.unselecting = true; | |
13676 | + | |
13677 | + // selectable UNSELECTING callback | |
13678 | + that._trigger( "unselecting", event, { | |
13679 | + unselecting: selectee.element | |
13680 | + } ); | |
13681 | + } | |
13682 | + } | |
13683 | + } | |
13684 | + } ); | |
13685 | + | |
13686 | + return false; | |
13687 | + }, | |
13688 | + | |
13689 | + _mouseStop: function( event ) { | |
13690 | + var that = this; | |
13691 | + | |
13692 | + this.dragged = false; | |
13693 | + | |
13694 | + $( ".ui-unselecting", this.element[ 0 ] ).each( function() { | |
13695 | + var selectee = $.data( this, "selectable-item" ); | |
13696 | + that._removeClass( selectee.$element, "ui-unselecting" ); | |
13697 | + selectee.unselecting = false; | |
13698 | + selectee.startselected = false; | |
13699 | + that._trigger( "unselected", event, { | |
13700 | + unselected: selectee.element | |
13701 | + } ); | |
13702 | + } ); | |
13703 | + $( ".ui-selecting", this.element[ 0 ] ).each( function() { | |
13704 | + var selectee = $.data( this, "selectable-item" ); | |
13705 | + that._removeClass( selectee.$element, "ui-selecting" ) | |
13706 | + ._addClass( selectee.$element, "ui-selected" ); | |
13707 | + selectee.selecting = false; | |
13708 | + selectee.selected = true; | |
13709 | + selectee.startselected = true; | |
13710 | + that._trigger( "selected", event, { | |
13711 | + selected: selectee.element | |
13712 | + } ); | |
13713 | + } ); | |
13714 | + this._trigger( "stop", event ); | |
13715 | + | |
13716 | + this.helper.remove(); | |
13717 | + | |
13718 | + return false; | |
13719 | + } | |
13720 | + | |
13721 | +} ); | |
13722 | + | |
13723 | + | |
13724 | +/*! | |
13725 | + * jQuery UI Selectmenu 1.12.0-rc.2 | |
13726 | + * http://jqueryui.com | |
13727 | + * | |
13728 | + * Copyright jQuery Foundation and other contributors | |
13729 | + * Released under the MIT license. | |
13730 | + * http://jquery.org/license | |
13731 | + */ | |
13732 | + | |
13733 | +//>>label: Selectmenu | |
13734 | +//>>group: Widgets | |
13735 | +// jscs:disable maximumLineLength | |
13736 | +//>>description: Duplicates and extends the functionality of a native HTML select element, allowing it to be customizable in behavior and appearance far beyond the limitations of a native select. | |
13737 | +// jscs:enable maximumLineLength | |
13738 | +//>>docs: http://api.jqueryui.com/selectmenu/ | |
13739 | +//>>demos: http://jqueryui.com/selectmenu/ | |
13740 | +//>>css.structure: ../../themes/base/core.css | |
13741 | +//>>css.structure: ../../themes/base/selectmenu.css, ../../themes/base/button.css | |
13742 | +//>>css.theme: ../../themes/base/theme.css | |
13743 | + | |
13744 | + | |
13745 | + | |
13746 | +var widgetsSelectmenu = $.widget( "ui.selectmenu", [ $.ui.formResetMixin, { | |
13747 | + version: "1.12.0-rc.2", | |
13748 | + defaultElement: "<select>", | |
13749 | + options: { | |
13750 | + appendTo: null, | |
13751 | + classes: { | |
13752 | + "ui-selectmenu-button-open": "ui-corner-top", | |
13753 | + "ui-selectmenu-button-closed": "ui-corner-all" | |
13754 | + }, | |
13755 | + disabled: null, | |
13756 | + icons: { | |
13757 | + button: "ui-icon-triangle-1-s" | |
13758 | + }, | |
13759 | + position: { | |
13760 | + my: "left top", | |
13761 | + at: "left bottom", | |
13762 | + collision: "none" | |
13763 | + }, | |
13764 | + width: false, | |
13765 | + | |
13766 | + // Callbacks | |
13767 | + change: null, | |
13768 | + close: null, | |
13769 | + focus: null, | |
13770 | + open: null, | |
13771 | + select: null | |
13772 | + }, | |
13773 | + | |
13774 | + _create: function() { | |
13775 | + var selectmenuId = this.element.uniqueId().attr( "id" ); | |
13776 | + this.ids = { | |
13777 | + element: selectmenuId, | |
13778 | + button: selectmenuId + "-button", | |
13779 | + menu: selectmenuId + "-menu" | |
13780 | + }; | |
13781 | + | |
13782 | + this._drawButton(); | |
13783 | + this._drawMenu(); | |
13784 | + this._bindFormResetHandler(); | |
13785 | + | |
13786 | + this._rendered = false; | |
13787 | + this.menuItems = $(); | |
13788 | + }, | |
13789 | + | |
13790 | + _drawButton: function() { | |
13791 | + var icon, | |
13792 | + that = this, | |
13793 | + item = this._parseOption( | |
13794 | + this.element.find( "option:selected" ), | |
13795 | + this.element[ 0 ].selectedIndex | |
13796 | + ); | |
13797 | + | |
13798 | + // Associate existing label with the new button | |
13799 | + this.labels = this.element.labels().attr( "for", this.ids.button ); | |
13800 | + this._on( this.labels, { | |
13801 | + click: function( event ) { | |
13802 | + this.button.focus(); | |
13803 | + event.preventDefault(); | |
13804 | + } | |
13805 | + } ); | |
13806 | + | |
13807 | + // Hide original select element | |
13808 | + this.element.hide(); | |
13809 | + | |
13810 | + // Create button | |
13811 | + this.button = $( "<span>", { | |
13812 | + tabindex: this.options.disabled ? -1 : 0, | |
13813 | + id: this.ids.button, | |
13814 | + role: "combobox", | |
13815 | + "aria-expanded": "false", | |
13816 | + "aria-autocomplete": "list", | |
13817 | + "aria-owns": this.ids.menu, | |
13818 | + "aria-haspopup": "true", | |
13819 | + title: this.element.attr( "title" ) | |
13820 | + } ) | |
13821 | + .insertAfter( this.element ); | |
13822 | + | |
13823 | + this._addClass( this.button, "ui-selectmenu-button ui-selectmenu-button-closed", | |
13824 | + "ui-button ui-widget" ); | |
13825 | + | |
13826 | + icon = $( "<span>" ).appendTo( this.button ); | |
13827 | + this._addClass( icon, "ui-selectmenu-icon", "ui-icon " + this.options.icons.button ); | |
13828 | + this.buttonItem = this._renderButtonItem( item ) | |
13829 | + .appendTo( this.button ); | |
13830 | + | |
13831 | + if ( this.options.width !== false ) { | |
13832 | + this._resizeButton(); | |
13833 | + } | |
13834 | + | |
13835 | + this._on( this.button, this._buttonEvents ); | |
13836 | + this.button.one( "focusin", function() { | |
13837 | + | |
13838 | + // Delay rendering the menu items until the button receives focus. | |
13839 | + // The menu may have already been rendered via a programmatic open. | |
13840 | + if ( !that._rendered ) { | |
13841 | + that._refreshMenu(); | |
13842 | + } | |
13843 | + } ); | |
13844 | + }, | |
13845 | + | |
13846 | + _drawMenu: function() { | |
13847 | + var that = this; | |
13848 | + | |
13849 | + // Create menu | |
13850 | + this.menu = $( "<ul>", { | |
13851 | + "aria-hidden": "true", | |
13852 | + "aria-labelledby": this.ids.button, | |
13853 | + id: this.ids.menu | |
13854 | + } ); | |
13855 | + | |
13856 | + // Wrap menu | |
13857 | + this.menuWrap = $( "<div>" ).append( this.menu ); | |
13858 | + this._addClass( this.menuWrap, "ui-selectmenu-menu", "ui-front" ); | |
13859 | + this.menuWrap.appendTo( this._appendTo() ); | |
13860 | + | |
13861 | + // Initialize menu widget | |
13862 | + this.menuInstance = this.menu | |
13863 | + .menu( { | |
13864 | + classes: { | |
13865 | + "ui-menu": "ui-corner-bottom" | |
13866 | + }, | |
13867 | + role: "listbox", | |
13868 | + select: function( event, ui ) { | |
13869 | + event.preventDefault(); | |
13870 | + | |
13871 | + // Support: IE8 | |
13872 | + // If the item was selected via a click, the text selection | |
13873 | + // will be destroyed in IE | |
13874 | + that._setSelection(); | |
13875 | + | |
13876 | + that._select( ui.item.data( "ui-selectmenu-item" ), event ); | |
13877 | + }, | |
13878 | + focus: function( event, ui ) { | |
13879 | + var item = ui.item.data( "ui-selectmenu-item" ); | |
13880 | + | |
13881 | + // Prevent inital focus from firing and check if its a newly focused item | |
13882 | + if ( that.focusIndex != null && item.index !== that.focusIndex ) { | |
13883 | + that._trigger( "focus", event, { item: item } ); | |
13884 | + if ( !that.isOpen ) { | |
13885 | + that._select( item, event ); | |
13886 | + } | |
13887 | + } | |
13888 | + that.focusIndex = item.index; | |
13889 | + | |
13890 | + that.button.attr( "aria-activedescendant", | |
13891 | + that.menuItems.eq( item.index ).attr( "id" ) ); | |
13892 | + } | |
13893 | + } ) | |
13894 | + .menu( "instance" ); | |
13895 | + | |
13896 | + // Don't close the menu on mouseleave | |
13897 | + this.menuInstance._off( this.menu, "mouseleave" ); | |
13898 | + | |
13899 | + // Cancel the menu's collapseAll on document click | |
13900 | + this.menuInstance._closeOnDocumentClick = function() { | |
13901 | + return false; | |
13902 | + }; | |
13903 | + | |
13904 | + // Selects often contain empty items, but never contain dividers | |
13905 | + this.menuInstance._isDivider = function() { | |
13906 | + return false; | |
13907 | + }; | |
13908 | + }, | |
13909 | + | |
13910 | + refresh: function() { | |
13911 | + this._refreshMenu(); | |
13912 | + this.buttonItem.replaceWith( | |
13913 | + this.buttonItem = this._renderButtonItem( | |
13914 | + | |
13915 | + // Fall back to an empty object in case there are no options | |
13916 | + this._getSelectedItem().data( "ui-selectmenu-item" ) || {} | |
13917 | + ) | |
13918 | + ); | |
13919 | + if ( this.options.width === null ) { | |
13920 | + this._resizeButton(); | |
13921 | + } | |
13922 | + }, | |
13923 | + | |
13924 | + _refreshMenu: function() { | |
13925 | + var item, | |
13926 | + options = this.element.find( "option" ); | |
13927 | + | |
13928 | + this.menu.empty(); | |
13929 | + | |
13930 | + this._parseOptions( options ); | |
13931 | + this._renderMenu( this.menu, this.items ); | |
13932 | + | |
13933 | + this.menuInstance.refresh(); | |
13934 | + this.menuItems = this.menu.find( "li" ) | |
13935 | + .not( ".ui-selectmenu-optgroup" ) | |
13936 | + .find( ".ui-menu-item-wrapper" ); | |
13937 | + | |
13938 | + this._rendered = true; | |
13939 | + | |
13940 | + if ( !options.length ) { | |
13941 | + return; | |
13942 | + } | |
13943 | + | |
13944 | + item = this._getSelectedItem(); | |
13945 | + | |
13946 | + // Update the menu to have the correct item focused | |
13947 | + this.menuInstance.focus( null, item ); | |
13948 | + this._setAria( item.data( "ui-selectmenu-item" ) ); | |
13949 | + | |
13950 | + // Set disabled state | |
13951 | + this._setOption( "disabled", this.element.prop( "disabled" ) ); | |
13952 | + }, | |
13953 | + | |
13954 | + open: function( event ) { | |
13955 | + if ( this.options.disabled ) { | |
13956 | + return; | |
13957 | + } | |
13958 | + | |
13959 | + // If this is the first time the menu is being opened, render the items | |
13960 | + if ( !this._rendered ) { | |
13961 | + this._refreshMenu(); | |
13962 | + } else { | |
13963 | + | |
13964 | + // Menu clears focus on close, reset focus to selected item | |
13965 | + this._removeClass( this.menu.find( ".ui-state-active" ), null, "ui-state-active" ); | |
13966 | + this.menuInstance.focus( null, this._getSelectedItem() ); | |
13967 | + } | |
13968 | + | |
13969 | + // If there are no options, don't open the menu | |
13970 | + if ( !this.menuItems.length ) { | |
13971 | + return; | |
13972 | + } | |
13973 | + | |
13974 | + this.isOpen = true; | |
13975 | + this._toggleAttr(); | |
13976 | + this._resizeMenu(); | |
13977 | + this._position(); | |
13978 | + | |
13979 | + this._on( this.document, this._documentClick ); | |
13980 | + | |
13981 | + this._trigger( "open", event ); | |
13982 | + }, | |
13983 | + | |
13984 | + _position: function() { | |
13985 | + this.menuWrap.position( $.extend( { of: this.button }, this.options.position ) ); | |
13986 | + }, | |
13987 | + | |
13988 | + close: function( event ) { | |
13989 | + if ( !this.isOpen ) { | |
13990 | + return; | |
13991 | + } | |
13992 | + | |
13993 | + this.isOpen = false; | |
13994 | + this._toggleAttr(); | |
13995 | + | |
13996 | + this.range = null; | |
13997 | + this._off( this.document ); | |
13998 | + | |
13999 | + this._trigger( "close", event ); | |
14000 | + }, | |
14001 | + | |
14002 | + widget: function() { | |
14003 | + return this.button; | |
14004 | + }, | |
14005 | + | |
14006 | + menuWidget: function() { | |
14007 | + return this.menu; | |
14008 | + }, | |
14009 | + | |
14010 | + _renderButtonItem: function( item ) { | |
14011 | + var buttonItem = $( "<span>" ); | |
14012 | + | |
14013 | + this._setText( buttonItem, item.label ); | |
14014 | + this._addClass( buttonItem, "ui-selectmenu-text" ); | |
14015 | + | |
14016 | + return buttonItem; | |
14017 | + }, | |
14018 | + | |
14019 | + _renderMenu: function( ul, items ) { | |
14020 | + var that = this, | |
14021 | + currentOptgroup = ""; | |
14022 | + | |
14023 | + $.each( items, function( index, item ) { | |
14024 | + var li; | |
14025 | + | |
14026 | + if ( item.optgroup !== currentOptgroup ) { | |
14027 | + li = $( "<li>", { | |
14028 | + text: item.optgroup | |
14029 | + } ); | |
14030 | + that._addClass( li, "ui-selectmenu-optgroup", "ui-menu-divider" + | |
14031 | + ( item.element.parent( "optgroup" ).prop( "disabled" ) ? | |
14032 | + " ui-state-disabled" : | |
14033 | + "" ) ); | |
14034 | + | |
14035 | + li.appendTo( ul ); | |
14036 | + | |
14037 | + currentOptgroup = item.optgroup; | |
14038 | + } | |
14039 | + | |
14040 | + that._renderItemData( ul, item ); | |
14041 | + } ); | |
14042 | + }, | |
14043 | + | |
14044 | + _renderItemData: function( ul, item ) { | |
14045 | + return this._renderItem( ul, item ).data( "ui-selectmenu-item", item ); | |
14046 | + }, | |
14047 | + | |
14048 | + _renderItem: function( ul, item ) { | |
14049 | + var li = $( "<li>" ), | |
14050 | + wrapper = $( "<div>", { | |
14051 | + title: item.element.attr( "title" ) | |
14052 | + } ); | |
14053 | + | |
14054 | + if ( item.disabled ) { | |
14055 | + this._addClass( li, null, "ui-state-disabled" ); | |
14056 | + } | |
14057 | + this._setText( wrapper, item.label ); | |
14058 | + | |
14059 | + return li.append( wrapper ).appendTo( ul ); | |
14060 | + }, | |
14061 | + | |
14062 | + _setText: function( element, value ) { | |
14063 | + if ( value ) { | |
14064 | + element.text( value ); | |
14065 | + } else { | |
14066 | + element.html( " " ); | |
14067 | + } | |
14068 | + }, | |
14069 | + | |
14070 | + _move: function( direction, event ) { | |
14071 | + var item, next, | |
14072 | + filter = ".ui-menu-item"; | |
14073 | + | |
14074 | + if ( this.isOpen ) { | |
14075 | + item = this.menuItems.eq( this.focusIndex ).parent( "li" ); | |
14076 | + } else { | |
14077 | + item = this.menuItems.eq( this.element[ 0 ].selectedIndex ).parent( "li" ); | |
14078 | + filter += ":not(.ui-state-disabled)"; | |
14079 | + } | |
14080 | + | |
14081 | + if ( direction === "first" || direction === "last" ) { | |
14082 | + next = item[ direction === "first" ? "prevAll" : "nextAll" ]( filter ).eq( -1 ); | |
14083 | + } else { | |
14084 | + next = item[ direction + "All" ]( filter ).eq( 0 ); | |
14085 | + } | |
14086 | + | |
14087 | + if ( next.length ) { | |
14088 | + this.menuInstance.focus( event, next ); | |
14089 | + } | |
14090 | + }, | |
14091 | + | |
14092 | + _getSelectedItem: function() { | |
14093 | + return this.menuItems.eq( this.element[ 0 ].selectedIndex ).parent( "li" ); | |
14094 | + }, | |
14095 | + | |
14096 | + _toggle: function( event ) { | |
14097 | + this[ this.isOpen ? "close" : "open" ]( event ); | |
14098 | + }, | |
14099 | + | |
14100 | + _setSelection: function() { | |
14101 | + var selection; | |
14102 | + | |
14103 | + if ( !this.range ) { | |
14104 | + return; | |
14105 | + } | |
14106 | + | |
14107 | + if ( window.getSelection ) { | |
14108 | + selection = window.getSelection(); | |
14109 | + selection.removeAllRanges(); | |
14110 | + selection.addRange( this.range ); | |
14111 | + | |
14112 | + // Support: IE8 | |
14113 | + } else { | |
14114 | + this.range.select(); | |
14115 | + } | |
14116 | + | |
14117 | + // Support: IE | |
14118 | + // Setting the text selection kills the button focus in IE, but | |
14119 | + // restoring the focus doesn't kill the selection. | |
14120 | + this.button.focus(); | |
14121 | + }, | |
14122 | + | |
14123 | + _documentClick: { | |
14124 | + mousedown: function( event ) { | |
14125 | + if ( !this.isOpen ) { | |
14126 | + return; | |
14127 | + } | |
14128 | + | |
14129 | + if ( !$( event.target ).closest( ".ui-selectmenu-menu, #" + | |
14130 | + $.ui.escapeSelector( this.ids.button ) ).length ) { | |
14131 | + this.close( event ); | |
14132 | + } | |
14133 | + } | |
14134 | + }, | |
14135 | + | |
14136 | + _buttonEvents: { | |
14137 | + | |
14138 | + // Prevent text selection from being reset when interacting with the selectmenu (#10144) | |
14139 | + mousedown: function() { | |
14140 | + var selection; | |
14141 | + | |
14142 | + if ( window.getSelection ) { | |
14143 | + selection = window.getSelection(); | |
14144 | + if ( selection.rangeCount ) { | |
14145 | + this.range = selection.getRangeAt( 0 ); | |
14146 | + } | |
14147 | + | |
14148 | + // Support: IE8 | |
14149 | + } else { | |
14150 | + this.range = document.selection.createRange(); | |
14151 | + } | |
14152 | + }, | |
14153 | + | |
14154 | + click: function( event ) { | |
14155 | + this._setSelection(); | |
14156 | + this._toggle( event ); | |
14157 | + }, | |
14158 | + | |
14159 | + keydown: function( event ) { | |
14160 | + var preventDefault = true; | |
14161 | + switch ( event.keyCode ) { | |
14162 | + case $.ui.keyCode.TAB: | |
14163 | + case $.ui.keyCode.ESCAPE: | |
14164 | + this.close( event ); | |
14165 | + preventDefault = false; | |
14166 | + break; | |
14167 | + case $.ui.keyCode.ENTER: | |
14168 | + if ( this.isOpen ) { | |
14169 | + this._selectFocusedItem( event ); | |
14170 | + } | |
14171 | + break; | |
14172 | + case $.ui.keyCode.UP: | |
14173 | + if ( event.altKey ) { | |
14174 | + this._toggle( event ); | |
14175 | + } else { | |
14176 | + this._move( "prev", event ); | |
14177 | + } | |
14178 | + break; | |
14179 | + case $.ui.keyCode.DOWN: | |
14180 | + if ( event.altKey ) { | |
14181 | + this._toggle( event ); | |
14182 | + } else { | |
14183 | + this._move( "next", event ); | |
14184 | + } | |
14185 | + break; | |
14186 | + case $.ui.keyCode.SPACE: | |
14187 | + if ( this.isOpen ) { | |
14188 | + this._selectFocusedItem( event ); | |
14189 | + } else { | |
14190 | + this._toggle( event ); | |
14191 | + } | |
14192 | + break; | |
14193 | + case $.ui.keyCode.LEFT: | |
14194 | + this._move( "prev", event ); | |
14195 | + break; | |
14196 | + case $.ui.keyCode.RIGHT: | |
14197 | + this._move( "next", event ); | |
14198 | + break; | |
14199 | + case $.ui.keyCode.HOME: | |
14200 | + case $.ui.keyCode.PAGE_UP: | |
14201 | + this._move( "first", event ); | |
14202 | + break; | |
14203 | + case $.ui.keyCode.END: | |
14204 | + case $.ui.keyCode.PAGE_DOWN: | |
14205 | + this._move( "last", event ); | |
14206 | + break; | |
14207 | + default: | |
14208 | + this.menu.trigger( event ); | |
14209 | + preventDefault = false; | |
14210 | + } | |
14211 | + | |
14212 | + if ( preventDefault ) { | |
14213 | + event.preventDefault(); | |
14214 | + } | |
14215 | + } | |
14216 | + }, | |
14217 | + | |
14218 | + _selectFocusedItem: function( event ) { | |
14219 | + var item = this.menuItems.eq( this.focusIndex ).parent( "li" ); | |
14220 | + if ( !item.hasClass( "ui-state-disabled" ) ) { | |
14221 | + this._select( item.data( "ui-selectmenu-item" ), event ); | |
14222 | + } | |
14223 | + }, | |
14224 | + | |
14225 | + _select: function( item, event ) { | |
14226 | + var oldIndex = this.element[ 0 ].selectedIndex; | |
14227 | + | |
14228 | + // Change native select element | |
14229 | + this.element[ 0 ].selectedIndex = item.index; | |
14230 | + this.buttonItem.replaceWith( this.buttonItem = this._renderButtonItem( item ) ); | |
14231 | + this._setAria( item ); | |
14232 | + this._trigger( "select", event, { item: item } ); | |
14233 | + | |
14234 | + if ( item.index !== oldIndex ) { | |
14235 | + this._trigger( "change", event, { item: item } ); | |
14236 | + } | |
14237 | + | |
14238 | + this.close( event ); | |
14239 | + }, | |
14240 | + | |
14241 | + _setAria: function( item ) { | |
14242 | + var id = this.menuItems.eq( item.index ).attr( "id" ); | |
14243 | + | |
14244 | + this.button.attr( { | |
14245 | + "aria-labelledby": id, | |
14246 | + "aria-activedescendant": id | |
14247 | + } ); | |
14248 | + this.menu.attr( "aria-activedescendant", id ); | |
14249 | + }, | |
14250 | + | |
14251 | + _setOption: function( key, value ) { | |
14252 | + if ( key === "icons" ) { | |
14253 | + var icon = this.button.find( "span.ui-icon" ); | |
14254 | + this._removeClass( icon, null, this.options.icons.button ) | |
14255 | + ._addClass( icon, null, value.button ); | |
14256 | + } | |
14257 | + | |
14258 | + this._super( key, value ); | |
14259 | + | |
14260 | + if ( key === "appendTo" ) { | |
14261 | + this.menuWrap.appendTo( this._appendTo() ); | |
14262 | + } | |
14263 | + | |
14264 | + if ( key === "width" ) { | |
14265 | + this._resizeButton(); | |
14266 | + } | |
14267 | + }, | |
14268 | + | |
14269 | + _setOptionDisabled: function( value ) { | |
14270 | + this._super( value ); | |
14271 | + | |
14272 | + this.menuInstance.option( "disabled", value ); | |
14273 | + this.button.attr( "aria-disabled", value ); | |
14274 | + this._toggleClass( this.button, null, "ui-state-disabled", value ); | |
14275 | + | |
14276 | + this.element.prop( "disabled", value ); | |
14277 | + if ( value ) { | |
14278 | + this.button.attr( "tabindex", -1 ); | |
14279 | + this.close(); | |
14280 | + } else { | |
14281 | + this.button.attr( "tabindex", 0 ); | |
14282 | + } | |
14283 | + }, | |
14284 | + | |
14285 | + _appendTo: function() { | |
14286 | + var element = this.options.appendTo; | |
14287 | + | |
14288 | + if ( element ) { | |
14289 | + element = element.jquery || element.nodeType ? | |
14290 | + $( element ) : | |
14291 | + this.document.find( element ).eq( 0 ); | |
14292 | + } | |
14293 | + | |
14294 | + if ( !element || !element[ 0 ] ) { | |
14295 | + element = this.element.closest( ".ui-front, dialog" ); | |
14296 | + } | |
14297 | + | |
14298 | + if ( !element.length ) { | |
14299 | + element = this.document[ 0 ].body; | |
14300 | + } | |
14301 | + | |
14302 | + return element; | |
14303 | + }, | |
14304 | + | |
14305 | + _toggleAttr: function() { | |
14306 | + this.button.attr( "aria-expanded", this.isOpen ); | |
14307 | + | |
14308 | + // We can't use two _toggleClass() calls here, because we need to make sure | |
14309 | + // we always remove classes first and add them second, otherwise if both classes have the | |
14310 | + // same theme class, it will be removed after we add it. | |
14311 | + this._removeClass( this.button, "ui-selectmenu-button-" + | |
14312 | + ( this.isOpen ? "closed" : "open" ) ) | |
14313 | + ._addClass( this.button, "ui-selectmenu-button-" + | |
14314 | + ( this.isOpen ? "open" : "closed" ) ) | |
14315 | + ._toggleClass( this.menuWrap, "ui-selectmenu-open", null, this.isOpen ); | |
14316 | + | |
14317 | + this.menu.attr( "aria-hidden", !this.isOpen ); | |
14318 | + }, | |
14319 | + | |
14320 | + _resizeButton: function() { | |
14321 | + var width = this.options.width; | |
14322 | + | |
14323 | + // For `width: false`, just remove inline style and stop | |
14324 | + if ( width === false ) { | |
14325 | + this.button.css( "width", "" ); | |
14326 | + return; | |
14327 | + } | |
14328 | + | |
14329 | + // For `width: null`, match the width of the original element | |
14330 | + if ( width === null ) { | |
14331 | + width = this.element.show().outerWidth(); | |
14332 | + this.element.hide(); | |
14333 | + } | |
14334 | + | |
14335 | + this.button.outerWidth( width ); | |
14336 | + }, | |
14337 | + | |
14338 | + _resizeMenu: function() { | |
14339 | + this.menu.outerWidth( Math.max( | |
14340 | + this.button.outerWidth(), | |
14341 | + | |
14342 | + // Support: IE10 | |
14343 | + // IE10 wraps long text (possibly a rounding bug) | |
14344 | + // so we add 1px to avoid the wrapping | |
14345 | + this.menu.width( "" ).outerWidth() + 1 | |
14346 | + ) ); | |
14347 | + }, | |
14348 | + | |
14349 | + _getCreateOptions: function() { | |
14350 | + var options = this._super(); | |
14351 | + | |
14352 | + options.disabled = this.element.prop( "disabled" ); | |
14353 | + | |
14354 | + return options; | |
14355 | + }, | |
14356 | + | |
14357 | + _parseOptions: function( options ) { | |
14358 | + var that = this, | |
14359 | + data = []; | |
14360 | + options.each( function( index, item ) { | |
14361 | + data.push( that._parseOption( $( item ), index ) ); | |
14362 | + } ); | |
14363 | + this.items = data; | |
14364 | + }, | |
14365 | + | |
14366 | + _parseOption: function( option, index ) { | |
14367 | + var optgroup = option.parent( "optgroup" ); | |
14368 | + | |
14369 | + return { | |
14370 | + element: option, | |
14371 | + index: index, | |
14372 | + value: option.val(), | |
14373 | + label: option.text(), | |
14374 | + optgroup: optgroup.attr( "label" ) || "", | |
14375 | + disabled: optgroup.prop( "disabled" ) || option.prop( "disabled" ) | |
14376 | + }; | |
14377 | + }, | |
14378 | + | |
14379 | + _destroy: function() { | |
14380 | + this._unbindFormResetHandler(); | |
14381 | + this.menuWrap.remove(); | |
14382 | + this.button.remove(); | |
14383 | + this.element.show(); | |
14384 | + this.element.removeUniqueId(); | |
14385 | + this.labels.attr( "for", this.ids.element ); | |
14386 | + } | |
14387 | +} ] ); | |
14388 | + | |
14389 | + | |
14390 | +/*! | |
14391 | + * jQuery UI Slider 1.12.0-rc.2 | |
14392 | + * http://jqueryui.com | |
14393 | + * | |
14394 | + * Copyright jQuery Foundation and other contributors | |
14395 | + * Released under the MIT license. | |
14396 | + * http://jquery.org/license | |
14397 | + */ | |
14398 | + | |
14399 | +//>>label: Slider | |
14400 | +//>>group: Widgets | |
14401 | +//>>description: Displays a flexible slider with ranges and accessibility via keyboard. | |
14402 | +//>>docs: http://api.jqueryui.com/slider/ | |
14403 | +//>>demos: http://jqueryui.com/slider/ | |
14404 | +//>>css.structure: ../../themes/base/core.css | |
14405 | +//>>css.structure: ../../themes/base/slider.css | |
14406 | +//>>css.theme: ../../themes/base/theme.css | |
14407 | + | |
14408 | + | |
14409 | + | |
14410 | +var widgetsSlider = $.widget( "ui.slider", $.ui.mouse, { | |
14411 | + version: "1.12.0-rc.2", | |
14412 | + widgetEventPrefix: "slide", | |
14413 | + | |
14414 | + options: { | |
14415 | + animate: false, | |
14416 | + classes: { | |
14417 | + "ui-slider": "ui-corner-all", | |
14418 | + "ui-slider-handle": "ui-corner-all", | |
14419 | + | |
14420 | + // Note: ui-widget-header isn't the most fittingly semantic framework class for this | |
14421 | + // element, but worked best visually with a variety of themes | |
14422 | + "ui-slider-range": "ui-corner-all ui-widget-header" | |
14423 | + }, | |
14424 | + distance: 0, | |
14425 | + max: 100, | |
14426 | + min: 0, | |
14427 | + orientation: "horizontal", | |
14428 | + range: false, | |
14429 | + step: 1, | |
14430 | + value: 0, | |
14431 | + values: null, | |
14432 | + | |
14433 | + // Callbacks | |
14434 | + change: null, | |
14435 | + slide: null, | |
14436 | + start: null, | |
14437 | + stop: null | |
14438 | + }, | |
14439 | + | |
14440 | + // Number of pages in a slider | |
14441 | + // (how many times can you page up/down to go through the whole range) | |
14442 | + numPages: 5, | |
14443 | + | |
14444 | + _create: function() { | |
14445 | + this._keySliding = false; | |
14446 | + this._mouseSliding = false; | |
14447 | + this._animateOff = true; | |
14448 | + this._handleIndex = null; | |
14449 | + this._detectOrientation(); | |
14450 | + this._mouseInit(); | |
14451 | + this._calculateNewMax(); | |
14452 | + | |
14453 | + this._addClass( "ui-slider ui-slider-" + this.orientation, | |
14454 | + "ui-widget ui-widget-content" ); | |
14455 | + | |
14456 | + this._refresh(); | |
14457 | + | |
14458 | + this._animateOff = false; | |
14459 | + }, | |
14460 | + | |
14461 | + _refresh: function() { | |
14462 | + this._createRange(); | |
14463 | + this._createHandles(); | |
14464 | + this._setupEvents(); | |
14465 | + this._refreshValue(); | |
14466 | + }, | |
14467 | + | |
14468 | + _createHandles: function() { | |
14469 | + var i, handleCount, | |
14470 | + options = this.options, | |
14471 | + existingHandles = this.element.find( ".ui-slider-handle" ), | |
14472 | + handle = "<span tabindex='0'></span>", | |
14473 | + handles = []; | |
14474 | + | |
14475 | + handleCount = ( options.values && options.values.length ) || 1; | |
14476 | + | |
14477 | + if ( existingHandles.length > handleCount ) { | |
14478 | + existingHandles.slice( handleCount ).remove(); | |
14479 | + existingHandles = existingHandles.slice( 0, handleCount ); | |
14480 | + } | |
14481 | + | |
14482 | + for ( i = existingHandles.length; i < handleCount; i++ ) { | |
14483 | + handles.push( handle ); | |
14484 | + } | |
14485 | + | |
14486 | + this.handles = existingHandles.add( $( handles.join( "" ) ).appendTo( this.element ) ); | |
14487 | + | |
14488 | + this._addClass( this.handles, "ui-slider-handle", "ui-state-default" ); | |
14489 | + | |
14490 | + this.handle = this.handles.eq( 0 ); | |
14491 | + | |
14492 | + this.handles.each( function( i ) { | |
14493 | + $( this ).data( "ui-slider-handle-index", i ); | |
14494 | + } ); | |
14495 | + }, | |
14496 | + | |
14497 | + _createRange: function() { | |
14498 | + var options = this.options; | |
14499 | + | |
14500 | + if ( options.range ) { | |
14501 | + if ( options.range === true ) { | |
14502 | + if ( !options.values ) { | |
14503 | + options.values = [ this._valueMin(), this._valueMin() ]; | |
14504 | + } else if ( options.values.length && options.values.length !== 2 ) { | |
14505 | + options.values = [ options.values[ 0 ], options.values[ 0 ] ]; | |
14506 | + } else if ( $.isArray( options.values ) ) { | |
14507 | + options.values = options.values.slice( 0 ); | |
14508 | + } | |
14509 | + } | |
14510 | + | |
14511 | + if ( !this.range || !this.range.length ) { | |
14512 | + this.range = $( "<div>" ) | |
14513 | + .appendTo( this.element ); | |
14514 | + | |
14515 | + this._addClass( this.range, "ui-slider-range" ); | |
14516 | + } else { | |
14517 | + this._removeClass( this.range, "ui-slider-range-min ui-slider-range-max" ); | |
14518 | + | |
14519 | + // Handle range switching from true to min/max | |
14520 | + this.range.css( { | |
14521 | + "left": "", | |
14522 | + "bottom": "" | |
14523 | + } ); | |
14524 | + } | |
14525 | + if ( options.range === "min" || options.range === "max" ) { | |
14526 | + this._addClass( this.range, "ui-slider-range-" + options.range ); | |
14527 | + } | |
14528 | + } else { | |
14529 | + if ( this.range ) { | |
14530 | + this.range.remove(); | |
14531 | + } | |
14532 | + this.range = null; | |
14533 | + } | |
14534 | + }, | |
14535 | + | |
14536 | + _setupEvents: function() { | |
14537 | + this._off( this.handles ); | |
14538 | + this._on( this.handles, this._handleEvents ); | |
14539 | + this._hoverable( this.handles ); | |
14540 | + this._focusable( this.handles ); | |
14541 | + }, | |
14542 | + | |
14543 | + _destroy: function() { | |
14544 | + this.handles.remove(); | |
14545 | + if ( this.range ) { | |
14546 | + this.range.remove(); | |
14547 | + } | |
14548 | + | |
14549 | + this._mouseDestroy(); | |
14550 | + }, | |
14551 | + | |
14552 | + _mouseCapture: function( event ) { | |
14553 | + var position, normValue, distance, closestHandle, index, allowed, offset, mouseOverHandle, | |
14554 | + that = this, | |
14555 | + o = this.options; | |
14556 | + | |
14557 | + if ( o.disabled ) { | |
14558 | + return false; | |
14559 | + } | |
14560 | + | |
14561 | + this.elementSize = { | |
14562 | + width: this.element.outerWidth(), | |
14563 | + height: this.element.outerHeight() | |
14564 | + }; | |
14565 | + this.elementOffset = this.element.offset(); | |
14566 | + | |
14567 | + position = { x: event.pageX, y: event.pageY }; | |
14568 | + normValue = this._normValueFromMouse( position ); | |
14569 | + distance = this._valueMax() - this._valueMin() + 1; | |
14570 | + this.handles.each( function( i ) { | |
14571 | + var thisDistance = Math.abs( normValue - that.values( i ) ); | |
14572 | + if ( ( distance > thisDistance ) || | |
14573 | + ( distance === thisDistance && | |
14574 | + ( i === that._lastChangedValue || that.values( i ) === o.min ) ) ) { | |
14575 | + distance = thisDistance; | |
14576 | + closestHandle = $( this ); | |
14577 | + index = i; | |
14578 | + } | |
14579 | + } ); | |
14580 | + | |
14581 | + allowed = this._start( event, index ); | |
14582 | + if ( allowed === false ) { | |
14583 | + return false; | |
14584 | + } | |
14585 | + this._mouseSliding = true; | |
14586 | + | |
14587 | + this._handleIndex = index; | |
14588 | + | |
14589 | + this._addClass( closestHandle, null, "ui-state-active" ); | |
14590 | + closestHandle.trigger( "focus" ); | |
14591 | + | |
14592 | + offset = closestHandle.offset(); | |
14593 | + mouseOverHandle = !$( event.target ).parents().addBack().is( ".ui-slider-handle" ); | |
14594 | + this._clickOffset = mouseOverHandle ? { left: 0, top: 0 } : { | |
14595 | + left: event.pageX - offset.left - ( closestHandle.width() / 2 ), | |
14596 | + top: event.pageY - offset.top - | |
14597 | + ( closestHandle.height() / 2 ) - | |
14598 | + ( parseInt( closestHandle.css( "borderTopWidth" ), 10 ) || 0 ) - | |
14599 | + ( parseInt( closestHandle.css( "borderBottomWidth" ), 10 ) || 0 ) + | |
14600 | + ( parseInt( closestHandle.css( "marginTop" ), 10 ) || 0 ) | |
14601 | + }; | |
14602 | + | |
14603 | + if ( !this.handles.hasClass( "ui-state-hover" ) ) { | |
14604 | + this._slide( event, index, normValue ); | |
14605 | + } | |
14606 | + this._animateOff = true; | |
14607 | + return true; | |
14608 | + }, | |
14609 | + | |
14610 | + _mouseStart: function() { | |
14611 | + return true; | |
14612 | + }, | |
14613 | + | |
14614 | + _mouseDrag: function( event ) { | |
14615 | + var position = { x: event.pageX, y: event.pageY }, | |
14616 | + normValue = this._normValueFromMouse( position ); | |
14617 | + | |
14618 | + this._slide( event, this._handleIndex, normValue ); | |
14619 | + | |
14620 | + return false; | |
14621 | + }, | |
14622 | + | |
14623 | + _mouseStop: function( event ) { | |
14624 | + this._removeClass( this.handles, null, "ui-state-active" ); | |
14625 | + this._mouseSliding = false; | |
14626 | + | |
14627 | + this._stop( event, this._handleIndex ); | |
14628 | + this._change( event, this._handleIndex ); | |
14629 | + | |
14630 | + this._handleIndex = null; | |
14631 | + this._clickOffset = null; | |
14632 | + this._animateOff = false; | |
14633 | + | |
14634 | + return false; | |
14635 | + }, | |
14636 | + | |
14637 | + _detectOrientation: function() { | |
14638 | + this.orientation = ( this.options.orientation === "vertical" ) ? "vertical" : "horizontal"; | |
14639 | + }, | |
14640 | + | |
14641 | + _normValueFromMouse: function( position ) { | |
14642 | + var pixelTotal, | |
14643 | + pixelMouse, | |
14644 | + percentMouse, | |
14645 | + valueTotal, | |
14646 | + valueMouse; | |
14647 | + | |
14648 | + if ( this.orientation === "horizontal" ) { | |
14649 | + pixelTotal = this.elementSize.width; | |
14650 | + pixelMouse = position.x - this.elementOffset.left - | |
14651 | + ( this._clickOffset ? this._clickOffset.left : 0 ); | |
14652 | + } else { | |
14653 | + pixelTotal = this.elementSize.height; | |
14654 | + pixelMouse = position.y - this.elementOffset.top - | |
14655 | + ( this._clickOffset ? this._clickOffset.top : 0 ); | |
14656 | + } | |
14657 | + | |
14658 | + percentMouse = ( pixelMouse / pixelTotal ); | |
14659 | + if ( percentMouse > 1 ) { | |
14660 | + percentMouse = 1; | |
14661 | + } | |
14662 | + if ( percentMouse < 0 ) { | |
14663 | + percentMouse = 0; | |
14664 | + } | |
14665 | + if ( this.orientation === "vertical" ) { | |
14666 | + percentMouse = 1 - percentMouse; | |
14667 | + } | |
14668 | + | |
14669 | + valueTotal = this._valueMax() - this._valueMin(); | |
14670 | + valueMouse = this._valueMin() + percentMouse * valueTotal; | |
14671 | + | |
14672 | + return this._trimAlignValue( valueMouse ); | |
14673 | + }, | |
14674 | + | |
14675 | + _uiHash: function( index, value, values ) { | |
14676 | + var uiHash = { | |
14677 | + handle: this.handles[ index ], | |
14678 | + handleIndex: index, | |
14679 | + value: value !== undefined ? value : this.value() | |
14680 | + }; | |
14681 | + | |
14682 | + if ( this._hasMultipleValues() ) { | |
14683 | + uiHash.value = value !== undefined ? value : this.values( index ); | |
14684 | + uiHash.values = values || this.values(); | |
14685 | + } | |
14686 | + | |
14687 | + return uiHash; | |
14688 | + }, | |
14689 | + | |
14690 | + _hasMultipleValues: function() { | |
14691 | + return this.options.values && this.options.values.length; | |
14692 | + }, | |
14693 | + | |
14694 | + _start: function( event, index ) { | |
14695 | + return this._trigger( "start", event, this._uiHash( index ) ); | |
14696 | + }, | |
14697 | + | |
14698 | + _slide: function( event, index, newVal ) { | |
14699 | + var allowed, otherVal, | |
14700 | + currentValue = this.value(), | |
14701 | + newValues = this.values(); | |
14702 | + | |
14703 | + if ( this._hasMultipleValues() ) { | |
14704 | + otherVal = this.values( index ? 0 : 1 ); | |
14705 | + currentValue = this.values( index ); | |
14706 | + | |
14707 | + if ( this.options.values.length === 2 && this.options.range === true ) { | |
14708 | + newVal = index === 0 ? Math.min( otherVal, newVal ) : Math.max( otherVal, newVal ); | |
14709 | + } | |
14710 | + | |
14711 | + newValues[ index ] = newVal; | |
14712 | + } | |
14713 | + | |
14714 | + if ( newVal === currentValue ) { | |
14715 | + return; | |
14716 | + } | |
14717 | + | |
14718 | + allowed = this._trigger( "slide", event, this._uiHash( index, newVal, newValues ) ); | |
14719 | + | |
14720 | + // A slide can be canceled by returning false from the slide callback | |
14721 | + if ( allowed === false ) { | |
14722 | + return; | |
14723 | + } | |
14724 | + | |
14725 | + if ( this._hasMultipleValues() ) { | |
14726 | + this.values( index, newVal ); | |
14727 | + } else { | |
14728 | + this.value( newVal ); | |
14729 | + } | |
14730 | + }, | |
14731 | + | |
14732 | + _stop: function( event, index ) { | |
14733 | + this._trigger( "stop", event, this._uiHash( index ) ); | |
14734 | + }, | |
14735 | + | |
14736 | + _change: function( event, index ) { | |
14737 | + if ( !this._keySliding && !this._mouseSliding ) { | |
14738 | + | |
14739 | + //store the last changed value index for reference when handles overlap | |
14740 | + this._lastChangedValue = index; | |
14741 | + this._trigger( "change", event, this._uiHash( index ) ); | |
14742 | + } | |
14743 | + }, | |
14744 | + | |
14745 | + value: function( newValue ) { | |
14746 | + if ( arguments.length ) { | |
14747 | + this.options.value = this._trimAlignValue( newValue ); | |
14748 | + this._refreshValue(); | |
14749 | + this._change( null, 0 ); | |
14750 | + return; | |
14751 | + } | |
14752 | + | |
14753 | + return this._value(); | |
14754 | + }, | |
14755 | + | |
14756 | + values: function( index, newValue ) { | |
14757 | + var vals, | |
14758 | + newValues, | |
14759 | + i; | |
14760 | + | |
14761 | + if ( arguments.length > 1 ) { | |
14762 | + this.options.values[ index ] = this._trimAlignValue( newValue ); | |
14763 | + this._refreshValue(); | |
14764 | + this._change( null, index ); | |
14765 | + return; | |
14766 | + } | |
14767 | + | |
14768 | + if ( arguments.length ) { | |
14769 | + if ( $.isArray( arguments[ 0 ] ) ) { | |
14770 | + vals = this.options.values; | |
14771 | + newValues = arguments[ 0 ]; | |
14772 | + for ( i = 0; i < vals.length; i += 1 ) { | |
14773 | + vals[ i ] = this._trimAlignValue( newValues[ i ] ); | |
14774 | + this._change( null, i ); | |
14775 | + } | |
14776 | + this._refreshValue(); | |
14777 | + } else { | |
14778 | + if ( this._hasMultipleValues() ) { | |
14779 | + return this._values( index ); | |
14780 | + } else { | |
14781 | + return this.value(); | |
14782 | + } | |
14783 | + } | |
14784 | + } else { | |
14785 | + return this._values(); | |
14786 | + } | |
14787 | + }, | |
14788 | + | |
14789 | + _setOption: function( key, value ) { | |
14790 | + var i, | |
14791 | + valsLength = 0; | |
14792 | + | |
14793 | + if ( key === "range" && this.options.range === true ) { | |
14794 | + if ( value === "min" ) { | |
14795 | + this.options.value = this._values( 0 ); | |
14796 | + this.options.values = null; | |
14797 | + } else if ( value === "max" ) { | |
14798 | + this.options.value = this._values( this.options.values.length - 1 ); | |
14799 | + this.options.values = null; | |
14800 | + } | |
14801 | + } | |
14802 | + | |
14803 | + if ( $.isArray( this.options.values ) ) { | |
14804 | + valsLength = this.options.values.length; | |
14805 | + } | |
14806 | + | |
14807 | + this._super( key, value ); | |
14808 | + | |
14809 | + switch ( key ) { | |
14810 | + case "orientation": | |
14811 | + this._detectOrientation(); | |
14812 | + this._removeClass( "ui-slider-horizontal ui-slider-vertical" ) | |
14813 | + ._addClass( "ui-slider-" + this.orientation ); | |
14814 | + this._refreshValue(); | |
14815 | + if ( this.options.range ) { | |
14816 | + this._refreshRange( value ); | |
14817 | + } | |
14818 | + | |
14819 | + // Reset positioning from previous orientation | |
14820 | + this.handles.css( value === "horizontal" ? "bottom" : "left", "" ); | |
14821 | + break; | |
14822 | + case "value": | |
14823 | + this._animateOff = true; | |
14824 | + this._refreshValue(); | |
14825 | + this._change( null, 0 ); | |
14826 | + this._animateOff = false; | |
14827 | + break; | |
14828 | + case "values": | |
14829 | + this._animateOff = true; | |
14830 | + this._refreshValue(); | |
14831 | + | |
14832 | + // Start from the last handle to prevent unreachable handles (#9046) | |
14833 | + for ( i = valsLength - 1; i >= 0; i-- ) { | |
14834 | + this._change( null, i ); | |
14835 | + } | |
14836 | + this._animateOff = false; | |
14837 | + break; | |
14838 | + case "step": | |
14839 | + case "min": | |
14840 | + case "max": | |
14841 | + this._animateOff = true; | |
14842 | + this._calculateNewMax(); | |
14843 | + this._refreshValue(); | |
14844 | + this._animateOff = false; | |
14845 | + break; | |
14846 | + case "range": | |
14847 | + this._animateOff = true; | |
14848 | + this._refresh(); | |
14849 | + this._animateOff = false; | |
14850 | + break; | |
14851 | + } | |
14852 | + }, | |
14853 | + | |
14854 | + _setOptionDisabled: function( value ) { | |
14855 | + this._super( value ); | |
14856 | + | |
14857 | + this._toggleClass( null, "ui-state-disabled", !!value ); | |
14858 | + }, | |
14859 | + | |
14860 | + //internal value getter | |
14861 | + // _value() returns value trimmed by min and max, aligned by step | |
14862 | + _value: function() { | |
14863 | + var val = this.options.value; | |
14864 | + val = this._trimAlignValue( val ); | |
14865 | + | |
14866 | + return val; | |
14867 | + }, | |
14868 | + | |
14869 | + //internal values getter | |
14870 | + // _values() returns array of values trimmed by min and max, aligned by step | |
14871 | + // _values( index ) returns single value trimmed by min and max, aligned by step | |
14872 | + _values: function( index ) { | |
14873 | + var val, | |
14874 | + vals, | |
14875 | + i; | |
14876 | + | |
14877 | + if ( arguments.length ) { | |
14878 | + val = this.options.values[ index ]; | |
14879 | + val = this._trimAlignValue( val ); | |
14880 | + | |
14881 | + return val; | |
14882 | + } else if ( this._hasMultipleValues() ) { | |
14883 | + | |
14884 | + // .slice() creates a copy of the array | |
14885 | + // this copy gets trimmed by min and max and then returned | |
14886 | + vals = this.options.values.slice(); | |
14887 | + for ( i = 0; i < vals.length; i += 1 ) { | |
14888 | + vals[ i ] = this._trimAlignValue( vals[ i ] ); | |
14889 | + } | |
14890 | + | |
14891 | + return vals; | |
14892 | + } else { | |
14893 | + return []; | |
14894 | + } | |
14895 | + }, | |
14896 | + | |
14897 | + // Returns the step-aligned value that val is closest to, between (inclusive) min and max | |
14898 | + _trimAlignValue: function( val ) { | |
14899 | + if ( val <= this._valueMin() ) { | |
14900 | + return this._valueMin(); | |
14901 | + } | |
14902 | + if ( val >= this._valueMax() ) { | |
14903 | + return this._valueMax(); | |
14904 | + } | |
14905 | + var step = ( this.options.step > 0 ) ? this.options.step : 1, | |
14906 | + valModStep = ( val - this._valueMin() ) % step, | |
14907 | + alignValue = val - valModStep; | |
14908 | + | |
14909 | + if ( Math.abs( valModStep ) * 2 >= step ) { | |
14910 | + alignValue += ( valModStep > 0 ) ? step : ( -step ); | |
14911 | + } | |
14912 | + | |
14913 | + // Since JavaScript has problems with large floats, round | |
14914 | + // the final value to 5 digits after the decimal point (see #4124) | |
14915 | + return parseFloat( alignValue.toFixed( 5 ) ); | |
14916 | + }, | |
14917 | + | |
14918 | + _calculateNewMax: function() { | |
14919 | + var max = this.options.max, | |
14920 | + min = this._valueMin(), | |
14921 | + step = this.options.step, | |
14922 | + aboveMin = Math.round( ( max - min ) / step ) * step; | |
14923 | + max = aboveMin + min; | |
14924 | + if ( max > this.options.max ) { | |
14925 | + | |
14926 | + //If max is not divisible by step, rounding off may increase its value | |
14927 | + max -= step; | |
14928 | + } | |
14929 | + this.max = parseFloat( max.toFixed( this._precision() ) ); | |
14930 | + }, | |
14931 | + | |
14932 | + _precision: function() { | |
14933 | + var precision = this._precisionOf( this.options.step ); | |
14934 | + if ( this.options.min !== null ) { | |
14935 | + precision = Math.max( precision, this._precisionOf( this.options.min ) ); | |
14936 | + } | |
14937 | + return precision; | |
14938 | + }, | |
14939 | + | |
14940 | + _precisionOf: function( num ) { | |
14941 | + var str = num.toString(), | |
14942 | + decimal = str.indexOf( "." ); | |
14943 | + return decimal === -1 ? 0 : str.length - decimal - 1; | |
14944 | + }, | |
14945 | + | |
14946 | + _valueMin: function() { | |
14947 | + return this.options.min; | |
14948 | + }, | |
14949 | + | |
14950 | + _valueMax: function() { | |
14951 | + return this.max; | |
14952 | + }, | |
14953 | + | |
14954 | + _refreshRange: function( orientation ) { | |
14955 | + if ( orientation === "vertical" ) { | |
14956 | + this.range.css( { "width": "", "left": "" } ); | |
14957 | + } | |
14958 | + if ( orientation === "horizontal" ) { | |
14959 | + this.range.css( { "height": "", "bottom": "" } ); | |
14960 | + } | |
14961 | + }, | |
14962 | + | |
14963 | + _refreshValue: function() { | |
14964 | + var lastValPercent, valPercent, value, valueMin, valueMax, | |
14965 | + oRange = this.options.range, | |
14966 | + o = this.options, | |
14967 | + that = this, | |
14968 | + animate = ( !this._animateOff ) ? o.animate : false, | |
14969 | + _set = {}; | |
14970 | + | |
14971 | + if ( this._hasMultipleValues() ) { | |
14972 | + this.handles.each( function( i ) { | |
14973 | + valPercent = ( that.values( i ) - that._valueMin() ) / ( that._valueMax() - | |
14974 | + that._valueMin() ) * 100; | |
14975 | + _set[ that.orientation === "horizontal" ? "left" : "bottom" ] = valPercent + "%"; | |
14976 | + $( this ).stop( 1, 1 )[ animate ? "animate" : "css" ]( _set, o.animate ); | |
14977 | + if ( that.options.range === true ) { | |
14978 | + if ( that.orientation === "horizontal" ) { | |
14979 | + if ( i === 0 ) { | |
14980 | + that.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { | |
14981 | + left: valPercent + "%" | |
14982 | + }, o.animate ); | |
14983 | + } | |
14984 | + if ( i === 1 ) { | |
14985 | + that.range[ animate ? "animate" : "css" ]( { | |
14986 | + width: ( valPercent - lastValPercent ) + "%" | |
14987 | + }, { | |
14988 | + queue: false, | |
14989 | + duration: o.animate | |
14990 | + } ); | |
14991 | + } | |
14992 | + } else { | |
14993 | + if ( i === 0 ) { | |
14994 | + that.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { | |
14995 | + bottom: ( valPercent ) + "%" | |
14996 | + }, o.animate ); | |
14997 | + } | |
14998 | + if ( i === 1 ) { | |
14999 | + that.range[ animate ? "animate" : "css" ]( { | |
15000 | + height: ( valPercent - lastValPercent ) + "%" | |
15001 | + }, { | |
15002 | + queue: false, | |
15003 | + duration: o.animate | |
15004 | + } ); | |
15005 | + } | |
15006 | + } | |
15007 | + } | |
15008 | + lastValPercent = valPercent; | |
15009 | + } ); | |
15010 | + } else { | |
15011 | + value = this.value(); | |
15012 | + valueMin = this._valueMin(); | |
15013 | + valueMax = this._valueMax(); | |
15014 | + valPercent = ( valueMax !== valueMin ) ? | |
15015 | + ( value - valueMin ) / ( valueMax - valueMin ) * 100 : | |
15016 | + 0; | |
15017 | + _set[ this.orientation === "horizontal" ? "left" : "bottom" ] = valPercent + "%"; | |
15018 | + this.handle.stop( 1, 1 )[ animate ? "animate" : "css" ]( _set, o.animate ); | |
15019 | + | |
15020 | + if ( oRange === "min" && this.orientation === "horizontal" ) { | |
15021 | + this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { | |
15022 | + width: valPercent + "%" | |
15023 | + }, o.animate ); | |
15024 | + } | |
15025 | + if ( oRange === "max" && this.orientation === "horizontal" ) { | |
15026 | + this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { | |
15027 | + width: ( 100 - valPercent ) + "%" | |
15028 | + }, o.animate ); | |
15029 | + } | |
15030 | + if ( oRange === "min" && this.orientation === "vertical" ) { | |
15031 | + this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { | |
15032 | + height: valPercent + "%" | |
15033 | + }, o.animate ); | |
15034 | + } | |
15035 | + if ( oRange === "max" && this.orientation === "vertical" ) { | |
15036 | + this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { | |
15037 | + height: ( 100 - valPercent ) + "%" | |
15038 | + }, o.animate ); | |
15039 | + } | |
15040 | + } | |
15041 | + }, | |
15042 | + | |
15043 | + _handleEvents: { | |
15044 | + keydown: function( event ) { | |
15045 | + var allowed, curVal, newVal, step, | |
15046 | + index = $( event.target ).data( "ui-slider-handle-index" ); | |
15047 | + | |
15048 | + switch ( event.keyCode ) { | |
15049 | + case $.ui.keyCode.HOME: | |
15050 | + case $.ui.keyCode.END: | |
15051 | + case $.ui.keyCode.PAGE_UP: | |
15052 | + case $.ui.keyCode.PAGE_DOWN: | |
15053 | + case $.ui.keyCode.UP: | |
15054 | + case $.ui.keyCode.RIGHT: | |
15055 | + case $.ui.keyCode.DOWN: | |
15056 | + case $.ui.keyCode.LEFT: | |
15057 | + event.preventDefault(); | |
15058 | + if ( !this._keySliding ) { | |
15059 | + this._keySliding = true; | |
15060 | + this._addClass( $( event.target ), null, "ui-state-active" ); | |
15061 | + allowed = this._start( event, index ); | |
15062 | + if ( allowed === false ) { | |
15063 | + return; | |
15064 | + } | |
15065 | + } | |
15066 | + break; | |
15067 | + } | |
15068 | + | |
15069 | + step = this.options.step; | |
15070 | + if ( this._hasMultipleValues() ) { | |
15071 | + curVal = newVal = this.values( index ); | |
15072 | + } else { | |
15073 | + curVal = newVal = this.value(); | |
15074 | + } | |
15075 | + | |
15076 | + switch ( event.keyCode ) { | |
15077 | + case $.ui.keyCode.HOME: | |
15078 | + newVal = this._valueMin(); | |
15079 | + break; | |
15080 | + case $.ui.keyCode.END: | |
15081 | + newVal = this._valueMax(); | |
15082 | + break; | |
15083 | + case $.ui.keyCode.PAGE_UP: | |
15084 | + newVal = this._trimAlignValue( | |
15085 | + curVal + ( ( this._valueMax() - this._valueMin() ) / this.numPages ) | |
15086 | + ); | |
15087 | + break; | |
15088 | + case $.ui.keyCode.PAGE_DOWN: | |
15089 | + newVal = this._trimAlignValue( | |
15090 | + curVal - ( ( this._valueMax() - this._valueMin() ) / this.numPages ) ); | |
15091 | + break; | |
15092 | + case $.ui.keyCode.UP: | |
15093 | + case $.ui.keyCode.RIGHT: | |
15094 | + if ( curVal === this._valueMax() ) { | |
15095 | + return; | |
15096 | + } | |
15097 | + newVal = this._trimAlignValue( curVal + step ); | |
15098 | + break; | |
15099 | + case $.ui.keyCode.DOWN: | |
15100 | + case $.ui.keyCode.LEFT: | |
15101 | + if ( curVal === this._valueMin() ) { | |
15102 | + return; | |
15103 | + } | |
15104 | + newVal = this._trimAlignValue( curVal - step ); | |
15105 | + break; | |
15106 | + } | |
15107 | + | |
15108 | + this._slide( event, index, newVal ); | |
15109 | + }, | |
15110 | + keyup: function( event ) { | |
15111 | + var index = $( event.target ).data( "ui-slider-handle-index" ); | |
15112 | + | |
15113 | + if ( this._keySliding ) { | |
15114 | + this._keySliding = false; | |
15115 | + this._stop( event, index ); | |
15116 | + this._change( event, index ); | |
15117 | + this._removeClass( $( event.target ), null, "ui-state-active" ); | |
15118 | + } | |
15119 | + } | |
15120 | + } | |
15121 | +} ); | |
15122 | + | |
15123 | + | |
15124 | +/*! | |
15125 | + * jQuery UI Sortable 1.12.0-rc.2 | |
15126 | + * http://jqueryui.com | |
15127 | + * | |
15128 | + * Copyright jQuery Foundation and other contributors | |
15129 | + * Released under the MIT license. | |
15130 | + * http://jquery.org/license | |
15131 | + */ | |
15132 | + | |
15133 | +//>>label: Sortable | |
15134 | +//>>group: Interactions | |
15135 | +//>>description: Enables items in a list to be sorted using the mouse. | |
15136 | +//>>docs: http://api.jqueryui.com/sortable/ | |
15137 | +//>>demos: http://jqueryui.com/sortable/ | |
15138 | +//>>css.structure: ../../themes/base/sortable.css | |
15139 | + | |
15140 | + | |
15141 | + | |
15142 | +var widgetsSortable = $.widget( "ui.sortable", $.ui.mouse, { | |
15143 | + version: "1.12.0-rc.2", | |
15144 | + widgetEventPrefix: "sort", | |
15145 | + ready: false, | |
15146 | + options: { | |
15147 | + appendTo: "parent", | |
15148 | + axis: false, | |
15149 | + connectWith: false, | |
15150 | + containment: false, | |
15151 | + cursor: "auto", | |
15152 | + cursorAt: false, | |
15153 | + dropOnEmpty: true, | |
15154 | + forcePlaceholderSize: false, | |
15155 | + forceHelperSize: false, | |
15156 | + grid: false, | |
15157 | + handle: false, | |
15158 | + helper: "original", | |
15159 | + items: "> *", | |
15160 | + opacity: false, | |
15161 | + placeholder: false, | |
15162 | + revert: false, | |
15163 | + scroll: true, | |
15164 | + scrollSensitivity: 20, | |
15165 | + scrollSpeed: 20, | |
15166 | + scope: "default", | |
15167 | + tolerance: "intersect", | |
15168 | + zIndex: 1000, | |
15169 | + | |
15170 | + // Callbacks | |
15171 | + activate: null, | |
15172 | + beforeStop: null, | |
15173 | + change: null, | |
15174 | + deactivate: null, | |
15175 | + out: null, | |
15176 | + over: null, | |
15177 | + receive: null, | |
15178 | + remove: null, | |
15179 | + sort: null, | |
15180 | + start: null, | |
15181 | + stop: null, | |
15182 | + update: null | |
15183 | + }, | |
15184 | + | |
15185 | + _isOverAxis: function( x, reference, size ) { | |
15186 | + return ( x >= reference ) && ( x < ( reference + size ) ); | |
15187 | + }, | |
15188 | + | |
15189 | + _isFloating: function( item ) { | |
15190 | + return ( /left|right/ ).test( item.css( "float" ) ) || | |
15191 | + ( /inline|table-cell/ ).test( item.css( "display" ) ); | |
15192 | + }, | |
15193 | + | |
15194 | + _create: function() { | |
15195 | + this.containerCache = {}; | |
15196 | + this._addClass( "ui-sortable" ); | |
15197 | + | |
15198 | + //Get the items | |
15199 | + this.refresh(); | |
15200 | + | |
15201 | + //Let's determine the parent's offset | |
15202 | + this.offset = this.element.offset(); | |
15203 | + | |
15204 | + //Initialize mouse events for interaction | |
15205 | + this._mouseInit(); | |
15206 | + | |
15207 | + this._setHandleClassName(); | |
15208 | + | |
15209 | + //We're ready to go | |
15210 | + this.ready = true; | |
15211 | + | |
15212 | + }, | |
15213 | + | |
15214 | + _setOption: function( key, value ) { | |
15215 | + this._super( key, value ); | |
15216 | + | |
15217 | + if ( key === "handle" ) { | |
15218 | + this._setHandleClassName(); | |
15219 | + } | |
15220 | + }, | |
15221 | + | |
15222 | + _setHandleClassName: function() { | |
15223 | + var that = this; | |
15224 | + this._removeClass( this.element.find( ".ui-sortable-handle" ), "ui-sortable-handle" ); | |
15225 | + $.each( this.items, function() { | |
15226 | + that._addClass( | |
15227 | + this.instance.options.handle ? | |
15228 | + this.item.find( this.instance.options.handle ) : | |
15229 | + this.item, | |
15230 | + "ui-sortable-handle" | |
15231 | + ); | |
15232 | + } ); | |
15233 | + }, | |
15234 | + | |
15235 | + _destroy: function() { | |
15236 | + this._mouseDestroy(); | |
15237 | + | |
15238 | + for ( var i = this.items.length - 1; i >= 0; i-- ) { | |
15239 | + this.items[ i ].item.removeData( this.widgetName + "-item" ); | |
15240 | + } | |
15241 | + | |
15242 | + return this; | |
15243 | + }, | |
15244 | + | |
15245 | + _mouseCapture: function( event, overrideHandle ) { | |
15246 | + var currentItem = null, | |
15247 | + validHandle = false, | |
15248 | + that = this; | |
15249 | + | |
15250 | + if ( this.reverting ) { | |
15251 | + return false; | |
15252 | + } | |
15253 | + | |
15254 | + if ( this.options.disabled || this.options.type === "static" ) { | |
15255 | + return false; | |
15256 | + } | |
15257 | + | |
15258 | + //We have to refresh the items data once first | |
15259 | + this._refreshItems( event ); | |
15260 | + | |
15261 | + //Find out if the clicked node (or one of its parents) is a actual item in this.items | |
15262 | + $( event.target ).parents().each( function() { | |
15263 | + if ( $.data( this, that.widgetName + "-item" ) === that ) { | |
15264 | + currentItem = $( this ); | |
15265 | + return false; | |
15266 | + } | |
15267 | + } ); | |
15268 | + if ( $.data( event.target, that.widgetName + "-item" ) === that ) { | |
15269 | + currentItem = $( event.target ); | |
15270 | + } | |
15271 | + | |
15272 | + if ( !currentItem ) { | |
15273 | + return false; | |
15274 | + } | |
15275 | + if ( this.options.handle && !overrideHandle ) { | |
15276 | + $( this.options.handle, currentItem ).find( "*" ).addBack().each( function() { | |
15277 | + if ( this === event.target ) { | |
15278 | + validHandle = true; | |
15279 | + } | |
15280 | + } ); | |
15281 | + if ( !validHandle ) { | |
15282 | + return false; | |
15283 | + } | |
15284 | + } | |
15285 | + | |
15286 | + this.currentItem = currentItem; | |
15287 | + this._removeCurrentsFromItems(); | |
15288 | + return true; | |
15289 | + | |
15290 | + }, | |
15291 | + | |
15292 | + _mouseStart: function( event, overrideHandle, noActivation ) { | |
15293 | + | |
15294 | + var i, body, | |
15295 | + o = this.options; | |
15296 | + | |
15297 | + this.currentContainer = this; | |
15298 | + | |
15299 | + //We only need to call refreshPositions, because the refreshItems call has been moved to | |
15300 | + // mouseCapture | |
15301 | + this.refreshPositions(); | |
15302 | + | |
15303 | + //Create and append the visible helper | |
15304 | + this.helper = this._createHelper( event ); | |
15305 | + | |
15306 | + //Cache the helper size | |
15307 | + this._cacheHelperProportions(); | |
15308 | + | |
15309 | + /* | |
15310 | + * - Position generation - | |
15311 | + * This block generates everything position related - it's the core of draggables. | |
15312 | + */ | |
15313 | + | |
15314 | + //Cache the margins of the original element | |
15315 | + this._cacheMargins(); | |
15316 | + | |
15317 | + //Get the next scrolling parent | |
15318 | + this.scrollParent = this.helper.scrollParent(); | |
15319 | + | |
15320 | + //The element's absolute position on the page minus margins | |
15321 | + this.offset = this.currentItem.offset(); | |
15322 | + this.offset = { | |
15323 | + top: this.offset.top - this.margins.top, | |
15324 | + left: this.offset.left - this.margins.left | |
15325 | + }; | |
15326 | + | |
15327 | + $.extend( this.offset, { | |
15328 | + click: { //Where the click happened, relative to the element | |
15329 | + left: event.pageX - this.offset.left, | |
15330 | + top: event.pageY - this.offset.top | |
15331 | + }, | |
15332 | + parent: this._getParentOffset(), | |
15333 | + | |
15334 | + // This is a relative to absolute position minus the actual position calculation - | |
15335 | + // only used for relative positioned helper | |
15336 | + relative: this._getRelativeOffset() | |
15337 | + } ); | |
15338 | + | |
15339 | + // Only after we got the offset, we can change the helper's position to absolute | |
15340 | + // TODO: Still need to figure out a way to make relative sorting possible | |
15341 | + this.helper.css( "position", "absolute" ); | |
15342 | + this.cssPosition = this.helper.css( "position" ); | |
15343 | + | |
15344 | + //Generate the original position | |
15345 | + this.originalPosition = this._generatePosition( event ); | |
15346 | + this.originalPageX = event.pageX; | |
15347 | + this.originalPageY = event.pageY; | |
15348 | + | |
15349 | + //Adjust the mouse offset relative to the helper if "cursorAt" is supplied | |
15350 | + ( o.cursorAt && this._adjustOffsetFromHelper( o.cursorAt ) ); | |
15351 | + | |
15352 | + //Cache the former DOM position | |
15353 | + this.domPosition = { | |
15354 | + prev: this.currentItem.prev()[ 0 ], | |
15355 | + parent: this.currentItem.parent()[ 0 ] | |
15356 | + }; | |
15357 | + | |
15358 | + // If the helper is not the original, hide the original so it's not playing any role during | |
15359 | + // the drag, won't cause anything bad this way | |
15360 | + if ( this.helper[ 0 ] !== this.currentItem[ 0 ] ) { | |
15361 | + this.currentItem.hide(); | |
15362 | + } | |
15363 | + | |
15364 | + //Create the placeholder | |
15365 | + this._createPlaceholder(); | |
15366 | + | |
15367 | + //Set a containment if given in the options | |
15368 | + if ( o.containment ) { | |
15369 | + this._setContainment(); | |
15370 | + } | |
15371 | + | |
15372 | + if ( o.cursor && o.cursor !== "auto" ) { // cursor option | |
15373 | + body = this.document.find( "body" ); | |
15374 | + | |
15375 | + // Support: IE | |
15376 | + this.storedCursor = body.css( "cursor" ); | |
15377 | + body.css( "cursor", o.cursor ); | |
15378 | + | |
15379 | + this.storedStylesheet = | |
15380 | + $( "<style>*{ cursor: " + o.cursor + " !important; }</style>" ).appendTo( body ); | |
15381 | + } | |
15382 | + | |
15383 | + if ( o.opacity ) { // opacity option | |
15384 | + if ( this.helper.css( "opacity" ) ) { | |
15385 | + this._storedOpacity = this.helper.css( "opacity" ); | |
15386 | + } | |
15387 | + this.helper.css( "opacity", o.opacity ); | |
15388 | + } | |
15389 | + | |
15390 | + if ( o.zIndex ) { // zIndex option | |
15391 | + if ( this.helper.css( "zIndex" ) ) { | |
15392 | + this._storedZIndex = this.helper.css( "zIndex" ); | |
15393 | + } | |
15394 | + this.helper.css( "zIndex", o.zIndex ); | |
15395 | + } | |
15396 | + | |
15397 | + //Prepare scrolling | |
15398 | + if ( this.scrollParent[ 0 ] !== this.document[ 0 ] && | |
15399 | + this.scrollParent[ 0 ].tagName !== "HTML" ) { | |
15400 | + this.overflowOffset = this.scrollParent.offset(); | |
15401 | + } | |
15402 | + | |
15403 | + //Call callbacks | |
15404 | + this._trigger( "start", event, this._uiHash() ); | |
15405 | + | |
15406 | + //Recache the helper size | |
15407 | + if ( !this._preserveHelperProportions ) { | |
15408 | + this._cacheHelperProportions(); | |
15409 | + } | |
15410 | + | |
15411 | + //Post "activate" events to possible containers | |
15412 | + if ( !noActivation ) { | |
15413 | + for ( i = this.containers.length - 1; i >= 0; i-- ) { | |
15414 | + this.containers[ i ]._trigger( "activate", event, this._uiHash( this ) ); | |
15415 | + } | |
15416 | + } | |
15417 | + | |
15418 | + //Prepare possible droppables | |
15419 | + if ( $.ui.ddmanager ) { | |
15420 | + $.ui.ddmanager.current = this; | |
15421 | + } | |
15422 | + | |
15423 | + if ( $.ui.ddmanager && !o.dropBehaviour ) { | |
15424 | + $.ui.ddmanager.prepareOffsets( this, event ); | |
15425 | + } | |
15426 | + | |
15427 | + this.dragging = true; | |
15428 | + | |
15429 | + this._addClass( this.helper, "ui-sortable-helper" ); | |
15430 | + | |
15431 | + // Execute the drag once - this causes the helper not to be visiblebefore getting its | |
15432 | + // correct position | |
15433 | + this._mouseDrag( event ); | |
15434 | + return true; | |
15435 | + | |
15436 | + }, | |
15437 | + | |
15438 | + _mouseDrag: function( event ) { | |
15439 | + var i, item, itemElement, intersection, | |
15440 | + o = this.options, | |
15441 | + scrolled = false; | |
15442 | + | |
15443 | + //Compute the helpers position | |
15444 | + this.position = this._generatePosition( event ); | |
15445 | + this.positionAbs = this._convertPositionTo( "absolute" ); | |
15446 | + | |
15447 | + if ( !this.lastPositionAbs ) { | |
15448 | + this.lastPositionAbs = this.positionAbs; | |
15449 | + } | |
15450 | + | |
15451 | + //Do scrolling | |
15452 | + if ( this.options.scroll ) { | |
15453 | + if ( this.scrollParent[ 0 ] !== this.document[ 0 ] && | |
15454 | + this.scrollParent[ 0 ].tagName !== "HTML" ) { | |
15455 | + | |
15456 | + if ( ( this.overflowOffset.top + this.scrollParent[ 0 ].offsetHeight ) - | |
15457 | + event.pageY < o.scrollSensitivity ) { | |
15458 | + this.scrollParent[ 0 ].scrollTop = | |
15459 | + scrolled = this.scrollParent[ 0 ].scrollTop + o.scrollSpeed; | |
15460 | + } else if ( event.pageY - this.overflowOffset.top < o.scrollSensitivity ) { | |
15461 | + this.scrollParent[ 0 ].scrollTop = | |
15462 | + scrolled = this.scrollParent[ 0 ].scrollTop - o.scrollSpeed; | |
15463 | + } | |
15464 | + | |
15465 | + if ( ( this.overflowOffset.left + this.scrollParent[ 0 ].offsetWidth ) - | |
15466 | + event.pageX < o.scrollSensitivity ) { | |
15467 | + this.scrollParent[ 0 ].scrollLeft = scrolled = | |
15468 | + this.scrollParent[ 0 ].scrollLeft + o.scrollSpeed; | |
15469 | + } else if ( event.pageX - this.overflowOffset.left < o.scrollSensitivity ) { | |
15470 | + this.scrollParent[ 0 ].scrollLeft = scrolled = | |
15471 | + this.scrollParent[ 0 ].scrollLeft - o.scrollSpeed; | |
15472 | + } | |
15473 | + | |
15474 | + } else { | |
15475 | + | |
15476 | + if ( event.pageY - this.document.scrollTop() < o.scrollSensitivity ) { | |
15477 | + scrolled = this.document.scrollTop( this.document.scrollTop() - o.scrollSpeed ); | |
15478 | + } else if ( this.window.height() - ( event.pageY - this.document.scrollTop() ) < | |
15479 | + o.scrollSensitivity ) { | |
15480 | + scrolled = this.document.scrollTop( this.document.scrollTop() + o.scrollSpeed ); | |
15481 | + } | |
15482 | + | |
15483 | + if ( event.pageX - this.document.scrollLeft() < o.scrollSensitivity ) { | |
15484 | + scrolled = this.document.scrollLeft( | |
15485 | + this.document.scrollLeft() - o.scrollSpeed | |
15486 | + ); | |
15487 | + } else if ( this.window.width() - ( event.pageX - this.document.scrollLeft() ) < | |
15488 | + o.scrollSensitivity ) { | |
15489 | + scrolled = this.document.scrollLeft( | |
15490 | + this.document.scrollLeft() + o.scrollSpeed | |
15491 | + ); | |
15492 | + } | |
15493 | + | |
15494 | + } | |
15495 | + | |
15496 | + if ( scrolled !== false && $.ui.ddmanager && !o.dropBehaviour ) { | |
15497 | + $.ui.ddmanager.prepareOffsets( this, event ); | |
15498 | + } | |
15499 | + } | |
15500 | + | |
15501 | + //Regenerate the absolute position used for position checks | |
15502 | + this.positionAbs = this._convertPositionTo( "absolute" ); | |
15503 | + | |
15504 | + //Set the helper position | |
15505 | + if ( !this.options.axis || this.options.axis !== "y" ) { | |
15506 | + this.helper[ 0 ].style.left = this.position.left + "px"; | |
15507 | + } | |
15508 | + if ( !this.options.axis || this.options.axis !== "x" ) { | |
15509 | + this.helper[ 0 ].style.top = this.position.top + "px"; | |
15510 | + } | |
15511 | + | |
15512 | + //Rearrange | |
15513 | + for ( i = this.items.length - 1; i >= 0; i-- ) { | |
15514 | + | |
15515 | + //Cache variables and intersection, continue if no intersection | |
15516 | + item = this.items[ i ]; | |
15517 | + itemElement = item.item[ 0 ]; | |
15518 | + intersection = this._intersectsWithPointer( item ); | |
15519 | + if ( !intersection ) { | |
15520 | + continue; | |
15521 | + } | |
15522 | + | |
15523 | + // Only put the placeholder inside the current Container, skip all | |
15524 | + // items from other containers. This works because when moving | |
15525 | + // an item from one container to another the | |
15526 | + // currentContainer is switched before the placeholder is moved. | |
15527 | + // | |
15528 | + // Without this, moving items in "sub-sortables" can cause | |
15529 | + // the placeholder to jitter between the outer and inner container. | |
15530 | + if ( item.instance !== this.currentContainer ) { | |
15531 | + continue; | |
15532 | + } | |
15533 | + | |
15534 | + // Cannot intersect with itself | |
15535 | + // no useless actions that have been done before | |
15536 | + // no action if the item moved is the parent of the item checked | |
15537 | + if ( itemElement !== this.currentItem[ 0 ] && | |
15538 | + this.placeholder[ intersection === 1 ? "next" : "prev" ]()[ 0 ] !== itemElement && | |
15539 | + !$.contains( this.placeholder[ 0 ], itemElement ) && | |
15540 | + ( this.options.type === "semi-dynamic" ? | |
15541 | + !$.contains( this.element[ 0 ], itemElement ) : | |
15542 | + true | |
15543 | + ) | |
15544 | + ) { | |
15545 | + | |
15546 | + this.direction = intersection === 1 ? "down" : "up"; | |
15547 | + | |
15548 | + if ( this.options.tolerance === "pointer" || this._intersectsWithSides( item ) ) { | |
15549 | + this._rearrange( event, item ); | |
15550 | + } else { | |
15551 | + break; | |
15552 | + } | |
15553 | + | |
15554 | + this._trigger( "change", event, this._uiHash() ); | |
15555 | + break; | |
15556 | + } | |
15557 | + } | |
15558 | + | |
15559 | + //Post events to containers | |
15560 | + this._contactContainers( event ); | |
15561 | + | |
15562 | + //Interconnect with droppables | |
15563 | + if ( $.ui.ddmanager ) { | |
15564 | + $.ui.ddmanager.drag( this, event ); | |
15565 | + } | |
15566 | + | |
15567 | + //Call callbacks | |
15568 | + this._trigger( "sort", event, this._uiHash() ); | |
15569 | + | |
15570 | + this.lastPositionAbs = this.positionAbs; | |
15571 | + return false; | |
15572 | + | |
15573 | + }, | |
15574 | + | |
15575 | + _mouseStop: function( event, noPropagation ) { | |
15576 | + | |
15577 | + if ( !event ) { | |
15578 | + return; | |
15579 | + } | |
15580 | + | |
15581 | + //If we are using droppables, inform the manager about the drop | |
15582 | + if ( $.ui.ddmanager && !this.options.dropBehaviour ) { | |
15583 | + $.ui.ddmanager.drop( this, event ); | |
15584 | + } | |
15585 | + | |
15586 | + if ( this.options.revert ) { | |
15587 | + var that = this, | |
15588 | + cur = this.placeholder.offset(), | |
15589 | + axis = this.options.axis, | |
15590 | + animation = {}; | |
15591 | + | |
15592 | + if ( !axis || axis === "x" ) { | |
15593 | + animation.left = cur.left - this.offset.parent.left - this.margins.left + | |
15594 | + ( this.offsetParent[ 0 ] === this.document[ 0 ].body ? | |
15595 | + 0 : | |
15596 | + this.offsetParent[ 0 ].scrollLeft | |
15597 | + ); | |
15598 | + } | |
15599 | + if ( !axis || axis === "y" ) { | |
15600 | + animation.top = cur.top - this.offset.parent.top - this.margins.top + | |
15601 | + ( this.offsetParent[ 0 ] === this.document[ 0 ].body ? | |
15602 | + 0 : | |
15603 | + this.offsetParent[ 0 ].scrollTop | |
15604 | + ); | |
15605 | + } | |
15606 | + this.reverting = true; | |
15607 | + $( this.helper ).animate( | |
15608 | + animation, | |
15609 | + parseInt( this.options.revert, 10 ) || 500, | |
15610 | + function() { | |
15611 | + that._clear( event ); | |
15612 | + } | |
15613 | + ); | |
15614 | + } else { | |
15615 | + this._clear( event, noPropagation ); | |
15616 | + } | |
15617 | + | |
15618 | + return false; | |
15619 | + | |
15620 | + }, | |
15621 | + | |
15622 | + cancel: function() { | |
15623 | + | |
15624 | + if ( this.dragging ) { | |
15625 | + | |
15626 | + this._mouseUp( { target: null } ); | |
15627 | + | |
15628 | + if ( this.options.helper === "original" ) { | |
15629 | + this.currentItem.css( this._storedCSS ); | |
15630 | + this._removeClass( this.currentItem, "ui-sortable-helper" ); | |
15631 | + } else { | |
15632 | + this.currentItem.show(); | |
15633 | + } | |
15634 | + | |
15635 | + //Post deactivating events to containers | |
15636 | + for ( var i = this.containers.length - 1; i >= 0; i-- ) { | |
15637 | + this.containers[ i ]._trigger( "deactivate", null, this._uiHash( this ) ); | |
15638 | + if ( this.containers[ i ].containerCache.over ) { | |
15639 | + this.containers[ i ]._trigger( "out", null, this._uiHash( this ) ); | |
15640 | + this.containers[ i ].containerCache.over = 0; | |
15641 | + } | |
15642 | + } | |
15643 | + | |
15644 | + } | |
15645 | + | |
15646 | + if ( this.placeholder ) { | |
15647 | + | |
15648 | + //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, | |
15649 | + // it unbinds ALL events from the original node! | |
15650 | + if ( this.placeholder[ 0 ].parentNode ) { | |
15651 | + this.placeholder[ 0 ].parentNode.removeChild( this.placeholder[ 0 ] ); | |
15652 | + } | |
15653 | + if ( this.options.helper !== "original" && this.helper && | |
15654 | + this.helper[ 0 ].parentNode ) { | |
15655 | + this.helper.remove(); | |
15656 | + } | |
15657 | + | |
15658 | + $.extend( this, { | |
15659 | + helper: null, | |
15660 | + dragging: false, | |
15661 | + reverting: false, | |
15662 | + _noFinalSort: null | |
15663 | + } ); | |
15664 | + | |
15665 | + if ( this.domPosition.prev ) { | |
15666 | + $( this.domPosition.prev ).after( this.currentItem ); | |
15667 | + } else { | |
15668 | + $( this.domPosition.parent ).prepend( this.currentItem ); | |
15669 | + } | |
15670 | + } | |
15671 | + | |
15672 | + return this; | |
15673 | + | |
15674 | + }, | |
15675 | + | |
15676 | + serialize: function( o ) { | |
15677 | + | |
15678 | + var items = this._getItemsAsjQuery( o && o.connected ), | |
15679 | + str = []; | |
15680 | + o = o || {}; | |
15681 | + | |
15682 | + $( items ).each( function() { | |
15683 | + var res = ( $( o.item || this ).attr( o.attribute || "id" ) || "" ) | |
15684 | + .match( o.expression || ( /(.+)[\-=_](.+)/ ) ); | |
15685 | + if ( res ) { | |
15686 | + str.push( | |
15687 | + ( o.key || res[ 1 ] + "[]" ) + | |
15688 | + "=" + ( o.key && o.expression ? res[ 1 ] : res[ 2 ] ) ); | |
15689 | + } | |
15690 | + } ); | |
15691 | + | |
15692 | + if ( !str.length && o.key ) { | |
15693 | + str.push( o.key + "=" ); | |
15694 | + } | |
15695 | + | |
15696 | + return str.join( "&" ); | |
15697 | + | |
15698 | + }, | |
15699 | + | |
15700 | + toArray: function( o ) { | |
15701 | + | |
15702 | + var items = this._getItemsAsjQuery( o && o.connected ), | |
15703 | + ret = []; | |
15704 | + | |
15705 | + o = o || {}; | |
15706 | + | |
15707 | + items.each( function() { | |
15708 | + ret.push( $( o.item || this ).attr( o.attribute || "id" ) || "" ); | |
15709 | + } ); | |
15710 | + return ret; | |
15711 | + | |
15712 | + }, | |
15713 | + | |
15714 | + /* Be careful with the following core functions */ | |
15715 | + _intersectsWith: function( item ) { | |
15716 | + | |
15717 | + var x1 = this.positionAbs.left, | |
15718 | + x2 = x1 + this.helperProportions.width, | |
15719 | + y1 = this.positionAbs.top, | |
15720 | + y2 = y1 + this.helperProportions.height, | |
15721 | + l = item.left, | |
15722 | + r = l + item.width, | |
15723 | + t = item.top, | |
15724 | + b = t + item.height, | |
15725 | + dyClick = this.offset.click.top, | |
15726 | + dxClick = this.offset.click.left, | |
15727 | + isOverElementHeight = ( this.options.axis === "x" ) || ( ( y1 + dyClick ) > t && | |
15728 | + ( y1 + dyClick ) < b ), | |
15729 | + isOverElementWidth = ( this.options.axis === "y" ) || ( ( x1 + dxClick ) > l && | |
15730 | + ( x1 + dxClick ) < r ), | |
15731 | + isOverElement = isOverElementHeight && isOverElementWidth; | |
15732 | + | |
15733 | + if ( this.options.tolerance === "pointer" || | |
15734 | + this.options.forcePointerForContainers || | |
15735 | + ( this.options.tolerance !== "pointer" && | |
15736 | + this.helperProportions[ this.floating ? "width" : "height" ] > | |
15737 | + item[ this.floating ? "width" : "height" ] ) | |
15738 | + ) { | |
15739 | + return isOverElement; | |
15740 | + } else { | |
15741 | + | |
15742 | + return ( l < x1 + ( this.helperProportions.width / 2 ) && // Right Half | |
15743 | + x2 - ( this.helperProportions.width / 2 ) < r && // Left Half | |
15744 | + t < y1 + ( this.helperProportions.height / 2 ) && // Bottom Half | |
15745 | + y2 - ( this.helperProportions.height / 2 ) < b ); // Top Half | |
15746 | + | |
15747 | + } | |
15748 | + }, | |
15749 | + | |
15750 | + _intersectsWithPointer: function( item ) { | |
15751 | + var verticalDirection, horizontalDirection, | |
15752 | + isOverElementHeight = ( this.options.axis === "x" ) || | |
15753 | + this._isOverAxis( | |
15754 | + this.positionAbs.top + this.offset.click.top, item.top, item.height ), | |
15755 | + isOverElementWidth = ( this.options.axis === "y" ) || | |
15756 | + this._isOverAxis( | |
15757 | + this.positionAbs.left + this.offset.click.left, item.left, item.width ), | |
15758 | + isOverElement = isOverElementHeight && isOverElementWidth; | |
15759 | + | |
15760 | + if ( !isOverElement ) { | |
15761 | + return false; | |
15762 | + } | |
15763 | + | |
15764 | + verticalDirection = this._getDragVerticalDirection(); | |
15765 | + horizontalDirection = this._getDragHorizontalDirection(); | |
15766 | + | |
15767 | + return this.floating ? | |
15768 | + ( ( horizontalDirection === "right" || verticalDirection === "down" ) ? 2 : 1 ) | |
15769 | + : ( verticalDirection && ( verticalDirection === "down" ? 2 : 1 ) ); | |
15770 | + | |
15771 | + }, | |
15772 | + | |
15773 | + _intersectsWithSides: function( item ) { | |
15774 | + | |
15775 | + var isOverBottomHalf = this._isOverAxis( this.positionAbs.top + | |
15776 | + this.offset.click.top, item.top + ( item.height / 2 ), item.height ), | |
15777 | + isOverRightHalf = this._isOverAxis( this.positionAbs.left + | |
15778 | + this.offset.click.left, item.left + ( item.width / 2 ), item.width ), | |
15779 | + verticalDirection = this._getDragVerticalDirection(), | |
15780 | + horizontalDirection = this._getDragHorizontalDirection(); | |
15781 | + | |
15782 | + if ( this.floating && horizontalDirection ) { | |
15783 | + return ( ( horizontalDirection === "right" && isOverRightHalf ) || | |
15784 | + ( horizontalDirection === "left" && !isOverRightHalf ) ); | |
15785 | + } else { | |
15786 | + return verticalDirection && ( ( verticalDirection === "down" && isOverBottomHalf ) || | |
15787 | + ( verticalDirection === "up" && !isOverBottomHalf ) ); | |
15788 | + } | |
15789 | + | |
15790 | + }, | |
15791 | + | |
15792 | + _getDragVerticalDirection: function() { | |
15793 | + var delta = this.positionAbs.top - this.lastPositionAbs.top; | |
15794 | + return delta !== 0 && ( delta > 0 ? "down" : "up" ); | |
15795 | + }, | |
15796 | + | |
15797 | + _getDragHorizontalDirection: function() { | |
15798 | + var delta = this.positionAbs.left - this.lastPositionAbs.left; | |
15799 | + return delta !== 0 && ( delta > 0 ? "right" : "left" ); | |
15800 | + }, | |
15801 | + | |
15802 | + refresh: function( event ) { | |
15803 | + this._refreshItems( event ); | |
15804 | + this._setHandleClassName(); | |
15805 | + this.refreshPositions(); | |
15806 | + return this; | |
15807 | + }, | |
15808 | + | |
15809 | + _connectWith: function() { | |
15810 | + var options = this.options; | |
15811 | + return options.connectWith.constructor === String ? | |
15812 | + [ options.connectWith ] : | |
15813 | + options.connectWith; | |
15814 | + }, | |
15815 | + | |
15816 | + _getItemsAsjQuery: function( connected ) { | |
15817 | + | |
15818 | + var i, j, cur, inst, | |
15819 | + items = [], | |
15820 | + queries = [], | |
15821 | + connectWith = this._connectWith(); | |
15822 | + | |
15823 | + if ( connectWith && connected ) { | |
15824 | + for ( i = connectWith.length - 1; i >= 0; i-- ) { | |
15825 | + cur = $( connectWith[ i ], this.document[ 0 ] ); | |
15826 | + for ( j = cur.length - 1; j >= 0; j-- ) { | |
15827 | + inst = $.data( cur[ j ], this.widgetFullName ); | |
15828 | + if ( inst && inst !== this && !inst.options.disabled ) { | |
15829 | + queries.push( [ $.isFunction( inst.options.items ) ? | |
15830 | + inst.options.items.call( inst.element ) : | |
15831 | + $( inst.options.items, inst.element ) | |
15832 | + .not( ".ui-sortable-helper" ) | |
15833 | + .not( ".ui-sortable-placeholder" ), inst ] ); | |
15834 | + } | |
15835 | + } | |
15836 | + } | |
15837 | + } | |
15838 | + | |
15839 | + queries.push( [ $.isFunction( this.options.items ) ? | |
15840 | + this.options.items | |
15841 | + .call( this.element, null, { options: this.options, item: this.currentItem } ) : | |
15842 | + $( this.options.items, this.element ) | |
15843 | + .not( ".ui-sortable-helper" ) | |
15844 | + .not( ".ui-sortable-placeholder" ), this ] ); | |
15845 | + | |
15846 | + function addItems() { | |
15847 | + items.push( this ); | |
15848 | + } | |
15849 | + for ( i = queries.length - 1; i >= 0; i-- ) { | |
15850 | + queries[ i ][ 0 ].each( addItems ); | |
15851 | + } | |
15852 | + | |
15853 | + return $( items ); | |
15854 | + | |
15855 | + }, | |
15856 | + | |
15857 | + _removeCurrentsFromItems: function() { | |
15858 | + | |
15859 | + var list = this.currentItem.find( ":data(" + this.widgetName + "-item)" ); | |
15860 | + | |
15861 | + this.items = $.grep( this.items, function( item ) { | |
15862 | + for ( var j = 0; j < list.length; j++ ) { | |
15863 | + if ( list[ j ] === item.item[ 0 ] ) { | |
15864 | + return false; | |
15865 | + } | |
15866 | + } | |
15867 | + return true; | |
15868 | + } ); | |
15869 | + | |
15870 | + }, | |
15871 | + | |
15872 | + _refreshItems: function( event ) { | |
15873 | + | |
15874 | + this.items = []; | |
15875 | + this.containers = [ this ]; | |
15876 | + | |
15877 | + var i, j, cur, inst, targetData, _queries, item, queriesLength, | |
15878 | + items = this.items, | |
15879 | + queries = [ [ $.isFunction( this.options.items ) ? | |
15880 | + this.options.items.call( this.element[ 0 ], event, { item: this.currentItem } ) : | |
15881 | + $( this.options.items, this.element ), this ] ], | |
15882 | + connectWith = this._connectWith(); | |
15883 | + | |
15884 | + //Shouldn't be run the first time through due to massive slow-down | |
15885 | + if ( connectWith && this.ready ) { | |
15886 | + for ( i = connectWith.length - 1; i >= 0; i-- ) { | |
15887 | + cur = $( connectWith[ i ], this.document[ 0 ] ); | |
15888 | + for ( j = cur.length - 1; j >= 0; j-- ) { | |
15889 | + inst = $.data( cur[ j ], this.widgetFullName ); | |
15890 | + if ( inst && inst !== this && !inst.options.disabled ) { | |
15891 | + queries.push( [ $.isFunction( inst.options.items ) ? | |
15892 | + inst.options.items | |
15893 | + .call( inst.element[ 0 ], event, { item: this.currentItem } ) : | |
15894 | + $( inst.options.items, inst.element ), inst ] ); | |
15895 | + this.containers.push( inst ); | |
15896 | + } | |
15897 | + } | |
15898 | + } | |
15899 | + } | |
15900 | + | |
15901 | + for ( i = queries.length - 1; i >= 0; i-- ) { | |
15902 | + targetData = queries[ i ][ 1 ]; | |
15903 | + _queries = queries[ i ][ 0 ]; | |
15904 | + | |
15905 | + for ( j = 0, queriesLength = _queries.length; j < queriesLength; j++ ) { | |
15906 | + item = $( _queries[ j ] ); | |
15907 | + | |
15908 | + // Data for target checking (mouse manager) | |
15909 | + item.data( this.widgetName + "-item", targetData ); | |
15910 | + | |
15911 | + items.push( { | |
15912 | + item: item, | |
15913 | + instance: targetData, | |
15914 | + width: 0, height: 0, | |
15915 | + left: 0, top: 0 | |
15916 | + } ); | |
15917 | + } | |
15918 | + } | |
15919 | + | |
15920 | + }, | |
15921 | + | |
15922 | + refreshPositions: function( fast ) { | |
15923 | + | |
15924 | + // Determine whether items are being displayed horizontally | |
15925 | + this.floating = this.items.length ? | |
15926 | + this.options.axis === "x" || this._isFloating( this.items[ 0 ].item ) : | |
15927 | + false; | |
15928 | + | |
15929 | + //This has to be redone because due to the item being moved out/into the offsetParent, | |
15930 | + // the offsetParent's position will change | |
15931 | + if ( this.offsetParent && this.helper ) { | |
15932 | + this.offset.parent = this._getParentOffset(); | |
15933 | + } | |
15934 | + | |
15935 | + var i, item, t, p; | |
15936 | + | |
15937 | + for ( i = this.items.length - 1; i >= 0; i-- ) { | |
15938 | + item = this.items[ i ]; | |
15939 | + | |
15940 | + //We ignore calculating positions of all connected containers when we're not over them | |
15941 | + if ( item.instance !== this.currentContainer && this.currentContainer && | |
15942 | + item.item[ 0 ] !== this.currentItem[ 0 ] ) { | |
15943 | + continue; | |
15944 | + } | |
15945 | + | |
15946 | + t = this.options.toleranceElement ? | |
15947 | + $( this.options.toleranceElement, item.item ) : | |
15948 | + item.item; | |
15949 | + | |
15950 | + if ( !fast ) { | |
15951 | + item.width = t.outerWidth(); | |
15952 | + item.height = t.outerHeight(); | |
15953 | + } | |
15954 | + | |
15955 | + p = t.offset(); | |
15956 | + item.left = p.left; | |
15957 | + item.top = p.top; | |
15958 | + } | |
15959 | + | |
15960 | + if ( this.options.custom && this.options.custom.refreshContainers ) { | |
15961 | + this.options.custom.refreshContainers.call( this ); | |
15962 | + } else { | |
15963 | + for ( i = this.containers.length - 1; i >= 0; i-- ) { | |
15964 | + p = this.containers[ i ].element.offset(); | |
15965 | + this.containers[ i ].containerCache.left = p.left; | |
15966 | + this.containers[ i ].containerCache.top = p.top; | |
15967 | + this.containers[ i ].containerCache.width = | |
15968 | + this.containers[ i ].element.outerWidth(); | |
15969 | + this.containers[ i ].containerCache.height = | |
15970 | + this.containers[ i ].element.outerHeight(); | |
15971 | + } | |
15972 | + } | |
15973 | + | |
15974 | + return this; | |
15975 | + }, | |
15976 | + | |
15977 | + _createPlaceholder: function( that ) { | |
15978 | + that = that || this; | |
15979 | + var className, | |
15980 | + o = that.options; | |
15981 | + | |
15982 | + if ( !o.placeholder || o.placeholder.constructor === String ) { | |
15983 | + className = o.placeholder; | |
15984 | + o.placeholder = { | |
15985 | + element: function() { | |
15986 | + | |
15987 | + var nodeName = that.currentItem[ 0 ].nodeName.toLowerCase(), | |
15988 | + element = $( "<" + nodeName + ">", that.document[ 0 ] ); | |
15989 | + | |
15990 | + that._addClass( element, "ui-sortable-placeholder", | |
15991 | + className || that.currentItem[ 0 ].className ) | |
15992 | + ._removeClass( element, "ui-sortable-helper" ); | |
15993 | + | |
15994 | + if ( nodeName === "tbody" ) { | |
15995 | + that._createTrPlaceholder( | |
15996 | + that.currentItem.find( "tr" ).eq( 0 ), | |
15997 | + $( "<tr>", that.document[ 0 ] ).appendTo( element ) | |
15998 | + ); | |
15999 | + } else if ( nodeName === "tr" ) { | |
16000 | + that._createTrPlaceholder( that.currentItem, element ); | |
16001 | + } else if ( nodeName === "img" ) { | |
16002 | + element.attr( "src", that.currentItem.attr( "src" ) ); | |
16003 | + } | |
16004 | + | |
16005 | + if ( !className ) { | |
16006 | + element.css( "visibility", "hidden" ); | |
16007 | + } | |
16008 | + | |
16009 | + return element; | |
16010 | + }, | |
16011 | + update: function( container, p ) { | |
16012 | + | |
16013 | + // 1. If a className is set as 'placeholder option, we don't force sizes - | |
16014 | + // the class is responsible for that | |
16015 | + // 2. The option 'forcePlaceholderSize can be enabled to force it even if a | |
16016 | + // class name is specified | |
16017 | + if ( className && !o.forcePlaceholderSize ) { | |
16018 | + return; | |
16019 | + } | |
16020 | + | |
16021 | + //If the element doesn't have a actual height by itself (without styles coming | |
16022 | + // from a stylesheet), it receives the inline height from the dragged item | |
16023 | + if ( !p.height() ) { | |
16024 | + p.height( | |
16025 | + that.currentItem.innerHeight() - | |
16026 | + parseInt( that.currentItem.css( "paddingTop" ) || 0, 10 ) - | |
16027 | + parseInt( that.currentItem.css( "paddingBottom" ) || 0, 10 ) ); | |
16028 | + } | |
16029 | + if ( !p.width() ) { | |
16030 | + p.width( | |
16031 | + that.currentItem.innerWidth() - | |
16032 | + parseInt( that.currentItem.css( "paddingLeft" ) || 0, 10 ) - | |
16033 | + parseInt( that.currentItem.css( "paddingRight" ) || 0, 10 ) ); | |
16034 | + } | |
16035 | + } | |
16036 | + }; | |
16037 | + } | |
16038 | + | |
16039 | + //Create the placeholder | |
16040 | + that.placeholder = $( o.placeholder.element.call( that.element, that.currentItem ) ); | |
16041 | + | |
16042 | + //Append it after the actual current item | |
16043 | + that.currentItem.after( that.placeholder ); | |
16044 | + | |
16045 | + //Update the size of the placeholder (TODO: Logic to fuzzy, see line 316/317) | |
16046 | + o.placeholder.update( that, that.placeholder ); | |
16047 | + | |
16048 | + }, | |
16049 | + | |
16050 | + _createTrPlaceholder: function( sourceTr, targetTr ) { | |
16051 | + var that = this; | |
16052 | + | |
16053 | + sourceTr.children().each( function() { | |
16054 | + $( "<td> </td>", that.document[ 0 ] ) | |
16055 | + .attr( "colspan", $( this ).attr( "colspan" ) || 1 ) | |
16056 | + .appendTo( targetTr ); | |
16057 | + } ); | |
16058 | + }, | |
16059 | + | |
16060 | + _contactContainers: function( event ) { | |
16061 | + var i, j, dist, itemWithLeastDistance, posProperty, sizeProperty, cur, nearBottom, | |
16062 | + floating, axis, | |
16063 | + innermostContainer = null, | |
16064 | + innermostIndex = null; | |
16065 | + | |
16066 | + // Get innermost container that intersects with item | |
16067 | + for ( i = this.containers.length - 1; i >= 0; i-- ) { | |
16068 | + | |
16069 | + // Never consider a container that's located within the item itself | |
16070 | + if ( $.contains( this.currentItem[ 0 ], this.containers[ i ].element[ 0 ] ) ) { | |
16071 | + continue; | |
16072 | + } | |
16073 | + | |
16074 | + if ( this._intersectsWith( this.containers[ i ].containerCache ) ) { | |
16075 | + | |
16076 | + // If we've already found a container and it's more "inner" than this, then continue | |
16077 | + if ( innermostContainer && | |
16078 | + $.contains( | |
16079 | + this.containers[ i ].element[ 0 ], | |
16080 | + innermostContainer.element[ 0 ] ) ) { | |
16081 | + continue; | |
16082 | + } | |
16083 | + | |
16084 | + innermostContainer = this.containers[ i ]; | |
16085 | + innermostIndex = i; | |
16086 | + | |
16087 | + } else { | |
16088 | + | |
16089 | + // container doesn't intersect. trigger "out" event if necessary | |
16090 | + if ( this.containers[ i ].containerCache.over ) { | |
16091 | + this.containers[ i ]._trigger( "out", event, this._uiHash( this ) ); | |
16092 | + this.containers[ i ].containerCache.over = 0; | |
16093 | + } | |
16094 | + } | |
16095 | + | |
16096 | + } | |
16097 | + | |
16098 | + // If no intersecting containers found, return | |
16099 | + if ( !innermostContainer ) { | |
16100 | + return; | |
16101 | + } | |
16102 | + | |
16103 | + // Move the item into the container if it's not there already | |
16104 | + if ( this.containers.length === 1 ) { | |
16105 | + if ( !this.containers[ innermostIndex ].containerCache.over ) { | |
16106 | + this.containers[ innermostIndex ]._trigger( "over", event, this._uiHash( this ) ); | |
16107 | + this.containers[ innermostIndex ].containerCache.over = 1; | |
16108 | + } | |
16109 | + } else { | |
16110 | + | |
16111 | + // When entering a new container, we will find the item with the least distance and | |
16112 | + // append our item near it | |
16113 | + dist = 10000; | |
16114 | + itemWithLeastDistance = null; | |
16115 | + floating = innermostContainer.floating || this._isFloating( this.currentItem ); | |
16116 | + posProperty = floating ? "left" : "top"; | |
16117 | + sizeProperty = floating ? "width" : "height"; | |
16118 | + axis = floating ? "pageX" : "pageY"; | |
16119 | + | |
16120 | + for ( j = this.items.length - 1; j >= 0; j-- ) { | |
16121 | + if ( !$.contains( | |
16122 | + this.containers[ innermostIndex ].element[ 0 ], this.items[ j ].item[ 0 ] ) | |
16123 | + ) { | |
16124 | + continue; | |
16125 | + } | |
16126 | + if ( this.items[ j ].item[ 0 ] === this.currentItem[ 0 ] ) { | |
16127 | + continue; | |
16128 | + } | |
16129 | + | |
16130 | + cur = this.items[ j ].item.offset()[ posProperty ]; | |
16131 | + nearBottom = false; | |
16132 | + if ( event[ axis ] - cur > this.items[ j ][ sizeProperty ] / 2 ) { | |
16133 | + nearBottom = true; | |
16134 | + } | |
16135 | + | |
16136 | + if ( Math.abs( event[ axis ] - cur ) < dist ) { | |
16137 | + dist = Math.abs( event[ axis ] - cur ); | |
16138 | + itemWithLeastDistance = this.items[ j ]; | |
16139 | + this.direction = nearBottom ? "up" : "down"; | |
16140 | + } | |
16141 | + } | |
16142 | + | |
16143 | + //Check if dropOnEmpty is enabled | |
16144 | + if ( !itemWithLeastDistance && !this.options.dropOnEmpty ) { | |
16145 | + return; | |
16146 | + } | |
16147 | + | |
16148 | + if ( this.currentContainer === this.containers[ innermostIndex ] ) { | |
16149 | + if ( !this.currentContainer.containerCache.over ) { | |
16150 | + this.containers[ innermostIndex ]._trigger( "over", event, this._uiHash() ); | |
16151 | + this.currentContainer.containerCache.over = 1; | |
16152 | + } | |
16153 | + return; | |
16154 | + } | |
16155 | + | |
16156 | + itemWithLeastDistance ? | |
16157 | + this._rearrange( event, itemWithLeastDistance, null, true ) : | |
16158 | + this._rearrange( event, null, this.containers[ innermostIndex ].element, true ); | |
16159 | + this._trigger( "change", event, this._uiHash() ); | |
16160 | + this.containers[ innermostIndex ]._trigger( "change", event, this._uiHash( this ) ); | |
16161 | + this.currentContainer = this.containers[ innermostIndex ]; | |
16162 | + | |
16163 | + //Update the placeholder | |
16164 | + this.options.placeholder.update( this.currentContainer, this.placeholder ); | |
16165 | + | |
16166 | + this.containers[ innermostIndex ]._trigger( "over", event, this._uiHash( this ) ); | |
16167 | + this.containers[ innermostIndex ].containerCache.over = 1; | |
16168 | + } | |
16169 | + | |
16170 | + }, | |
16171 | + | |
16172 | + _createHelper: function( event ) { | |
16173 | + | |
16174 | + var o = this.options, | |
16175 | + helper = $.isFunction( o.helper ) ? | |
16176 | + $( o.helper.apply( this.element[ 0 ], [ event, this.currentItem ] ) ) : | |
16177 | + ( o.helper === "clone" ? this.currentItem.clone() : this.currentItem ); | |
16178 | + | |
16179 | + //Add the helper to the DOM if that didn't happen already | |
16180 | + if ( !helper.parents( "body" ).length ) { | |
16181 | + $( o.appendTo !== "parent" ? | |
16182 | + o.appendTo : | |
16183 | + this.currentItem[ 0 ].parentNode )[ 0 ].appendChild( helper[ 0 ] ); | |
16184 | + } | |
16185 | + | |
16186 | + if ( helper[ 0 ] === this.currentItem[ 0 ] ) { | |
16187 | + this._storedCSS = { | |
16188 | + width: this.currentItem[ 0 ].style.width, | |
16189 | + height: this.currentItem[ 0 ].style.height, | |
16190 | + position: this.currentItem.css( "position" ), | |
16191 | + top: this.currentItem.css( "top" ), | |
16192 | + left: this.currentItem.css( "left" ) | |
16193 | + }; | |
16194 | + } | |
16195 | + | |
16196 | + if ( !helper[ 0 ].style.width || o.forceHelperSize ) { | |
16197 | + helper.width( this.currentItem.width() ); | |
16198 | + } | |
16199 | + if ( !helper[ 0 ].style.height || o.forceHelperSize ) { | |
16200 | + helper.height( this.currentItem.height() ); | |
16201 | + } | |
16202 | + | |
16203 | + return helper; | |
16204 | + | |
16205 | + }, | |
16206 | + | |
16207 | + _adjustOffsetFromHelper: function( obj ) { | |
16208 | + if ( typeof obj === "string" ) { | |
16209 | + obj = obj.split( " " ); | |
16210 | + } | |
16211 | + if ( $.isArray( obj ) ) { | |
16212 | + obj = { left: +obj[ 0 ], top: +obj[ 1 ] || 0 }; | |
16213 | + } | |
16214 | + if ( "left" in obj ) { | |
16215 | + this.offset.click.left = obj.left + this.margins.left; | |
16216 | + } | |
16217 | + if ( "right" in obj ) { | |
16218 | + this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left; | |
16219 | + } | |
16220 | + if ( "top" in obj ) { | |
16221 | + this.offset.click.top = obj.top + this.margins.top; | |
16222 | + } | |
16223 | + if ( "bottom" in obj ) { | |
16224 | + this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top; | |
16225 | + } | |
16226 | + }, | |
16227 | + | |
16228 | + _getParentOffset: function() { | |
16229 | + | |
16230 | + //Get the offsetParent and cache its position | |
16231 | + this.offsetParent = this.helper.offsetParent(); | |
16232 | + var po = this.offsetParent.offset(); | |
16233 | + | |
16234 | + // This is a special case where we need to modify a offset calculated on start, since the | |
16235 | + // following happened: | |
16236 | + // 1. The position of the helper is absolute, so it's position is calculated based on the | |
16237 | + // next positioned parent | |
16238 | + // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't | |
16239 | + // the document, which means that the scroll is included in the initial calculation of the | |
16240 | + // offset of the parent, and never recalculated upon drag | |
16241 | + if ( this.cssPosition === "absolute" && this.scrollParent[ 0 ] !== this.document[ 0 ] && | |
16242 | + $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) { | |
16243 | + po.left += this.scrollParent.scrollLeft(); | |
16244 | + po.top += this.scrollParent.scrollTop(); | |
16245 | + } | |
16246 | + | |
16247 | + // This needs to be actually done for all browsers, since pageX/pageY includes this | |
16248 | + // information with an ugly IE fix | |
16249 | + if ( this.offsetParent[ 0 ] === this.document[ 0 ].body || | |
16250 | + ( this.offsetParent[ 0 ].tagName && | |
16251 | + this.offsetParent[ 0 ].tagName.toLowerCase() === "html" && $.ui.ie ) ) { | |
16252 | + po = { top: 0, left: 0 }; | |
16253 | + } | |
16254 | + | |
16255 | + return { | |
16256 | + top: po.top + ( parseInt( this.offsetParent.css( "borderTopWidth" ), 10 ) || 0 ), | |
16257 | + left: po.left + ( parseInt( this.offsetParent.css( "borderLeftWidth" ), 10 ) || 0 ) | |
16258 | + }; | |
16259 | + | |
16260 | + }, | |
16261 | + | |
16262 | + _getRelativeOffset: function() { | |
16263 | + | |
16264 | + if ( this.cssPosition === "relative" ) { | |
16265 | + var p = this.currentItem.position(); | |
16266 | + return { | |
16267 | + top: p.top - ( parseInt( this.helper.css( "top" ), 10 ) || 0 ) + | |
16268 | + this.scrollParent.scrollTop(), | |
16269 | + left: p.left - ( parseInt( this.helper.css( "left" ), 10 ) || 0 ) + | |
16270 | + this.scrollParent.scrollLeft() | |
16271 | + }; | |
16272 | + } else { | |
16273 | + return { top: 0, left: 0 }; | |
16274 | + } | |
16275 | + | |
16276 | + }, | |
16277 | + | |
16278 | + _cacheMargins: function() { | |
16279 | + this.margins = { | |
16280 | + left: ( parseInt( this.currentItem.css( "marginLeft" ), 10 ) || 0 ), | |
16281 | + top: ( parseInt( this.currentItem.css( "marginTop" ), 10 ) || 0 ) | |
16282 | + }; | |
16283 | + }, | |
16284 | + | |
16285 | + _cacheHelperProportions: function() { | |
16286 | + this.helperProportions = { | |
16287 | + width: this.helper.outerWidth(), | |
16288 | + height: this.helper.outerHeight() | |
16289 | + }; | |
16290 | + }, | |
16291 | + | |
16292 | + _setContainment: function() { | |
16293 | + | |
16294 | + var ce, co, over, | |
16295 | + o = this.options; | |
16296 | + if ( o.containment === "parent" ) { | |
16297 | + o.containment = this.helper[ 0 ].parentNode; | |
16298 | + } | |
16299 | + if ( o.containment === "document" || o.containment === "window" ) { | |
16300 | + this.containment = [ | |
16301 | + 0 - this.offset.relative.left - this.offset.parent.left, | |
16302 | + 0 - this.offset.relative.top - this.offset.parent.top, | |
16303 | + o.containment === "document" ? | |
16304 | + this.document.width() : | |
16305 | + this.window.width() - this.helperProportions.width - this.margins.left, | |
16306 | + ( o.containment === "document" ? | |
16307 | + ( this.document.height() || document.body.parentNode.scrollHeight ) : | |
16308 | + this.window.height() || this.document[ 0 ].body.parentNode.scrollHeight | |
16309 | + ) - this.helperProportions.height - this.margins.top | |
16310 | + ]; | |
16311 | + } | |
16312 | + | |
16313 | + if ( !( /^(document|window|parent)$/ ).test( o.containment ) ) { | |
16314 | + ce = $( o.containment )[ 0 ]; | |
16315 | + co = $( o.containment ).offset(); | |
16316 | + over = ( $( ce ).css( "overflow" ) !== "hidden" ); | |
16317 | + | |
16318 | + this.containment = [ | |
16319 | + co.left + ( parseInt( $( ce ).css( "borderLeftWidth" ), 10 ) || 0 ) + | |
16320 | + ( parseInt( $( ce ).css( "paddingLeft" ), 10 ) || 0 ) - this.margins.left, | |
16321 | + co.top + ( parseInt( $( ce ).css( "borderTopWidth" ), 10 ) || 0 ) + | |
16322 | + ( parseInt( $( ce ).css( "paddingTop" ), 10 ) || 0 ) - this.margins.top, | |
16323 | + co.left + ( over ? Math.max( ce.scrollWidth, ce.offsetWidth ) : ce.offsetWidth ) - | |
16324 | + ( parseInt( $( ce ).css( "borderLeftWidth" ), 10 ) || 0 ) - | |
16325 | + ( parseInt( $( ce ).css( "paddingRight" ), 10 ) || 0 ) - | |
16326 | + this.helperProportions.width - this.margins.left, | |
16327 | + co.top + ( over ? Math.max( ce.scrollHeight, ce.offsetHeight ) : ce.offsetHeight ) - | |
16328 | + ( parseInt( $( ce ).css( "borderTopWidth" ), 10 ) || 0 ) - | |
16329 | + ( parseInt( $( ce ).css( "paddingBottom" ), 10 ) || 0 ) - | |
16330 | + this.helperProportions.height - this.margins.top | |
16331 | + ]; | |
16332 | + } | |
16333 | + | |
16334 | + }, | |
16335 | + | |
16336 | + _convertPositionTo: function( d, pos ) { | |
16337 | + | |
16338 | + if ( !pos ) { | |
16339 | + pos = this.position; | |
16340 | + } | |
16341 | + var mod = d === "absolute" ? 1 : -1, | |
16342 | + scroll = this.cssPosition === "absolute" && | |
16343 | + !( this.scrollParent[ 0 ] !== this.document[ 0 ] && | |
16344 | + $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) ? | |
16345 | + this.offsetParent : | |
16346 | + this.scrollParent, | |
16347 | + scrollIsRootNode = ( /(html|body)/i ).test( scroll[ 0 ].tagName ); | |
16348 | + | |
16349 | + return { | |
16350 | + top: ( | |
16351 | + | |
16352 | + // The absolute mouse position | |
16353 | + pos.top + | |
16354 | + | |
16355 | + // Only for relative positioned nodes: Relative offset from element to offset parent | |
16356 | + this.offset.relative.top * mod + | |
16357 | + | |
16358 | + // The offsetParent's offset without borders (offset + border) | |
16359 | + this.offset.parent.top * mod - | |
16360 | + ( ( this.cssPosition === "fixed" ? | |
16361 | + -this.scrollParent.scrollTop() : | |
16362 | + ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod ) | |
16363 | + ), | |
16364 | + left: ( | |
16365 | + | |
16366 | + // The absolute mouse position | |
16367 | + pos.left + | |
16368 | + | |
16369 | + // Only for relative positioned nodes: Relative offset from element to offset parent | |
16370 | + this.offset.relative.left * mod + | |
16371 | + | |
16372 | + // The offsetParent's offset without borders (offset + border) | |
16373 | + this.offset.parent.left * mod - | |
16374 | + ( ( this.cssPosition === "fixed" ? | |
16375 | + -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : | |
16376 | + scroll.scrollLeft() ) * mod ) | |
16377 | + ) | |
16378 | + }; | |
16379 | + | |
16380 | + }, | |
16381 | + | |
16382 | + _generatePosition: function( event ) { | |
16383 | + | |
16384 | + var top, left, | |
16385 | + o = this.options, | |
16386 | + pageX = event.pageX, | |
16387 | + pageY = event.pageY, | |
16388 | + scroll = this.cssPosition === "absolute" && | |
16389 | + !( this.scrollParent[ 0 ] !== this.document[ 0 ] && | |
16390 | + $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) ? | |
16391 | + this.offsetParent : | |
16392 | + this.scrollParent, | |
16393 | + scrollIsRootNode = ( /(html|body)/i ).test( scroll[ 0 ].tagName ); | |
16394 | + | |
16395 | + // This is another very weird special case that only happens for relative elements: | |
16396 | + // 1. If the css position is relative | |
16397 | + // 2. and the scroll parent is the document or similar to the offset parent | |
16398 | + // we have to refresh the relative offset during the scroll so there are no jumps | |
16399 | + if ( this.cssPosition === "relative" && !( this.scrollParent[ 0 ] !== this.document[ 0 ] && | |
16400 | + this.scrollParent[ 0 ] !== this.offsetParent[ 0 ] ) ) { | |
16401 | + this.offset.relative = this._getRelativeOffset(); | |
16402 | + } | |
16403 | + | |
16404 | + /* | |
16405 | + * - Position constraining - | |
16406 | + * Constrain the position to a mix of grid, containment. | |
16407 | + */ | |
16408 | + | |
16409 | + if ( this.originalPosition ) { //If we are not dragging yet, we won't check for options | |
16410 | + | |
16411 | + if ( this.containment ) { | |
16412 | + if ( event.pageX - this.offset.click.left < this.containment[ 0 ] ) { | |
16413 | + pageX = this.containment[ 0 ] + this.offset.click.left; | |
16414 | + } | |
16415 | + if ( event.pageY - this.offset.click.top < this.containment[ 1 ] ) { | |
16416 | + pageY = this.containment[ 1 ] + this.offset.click.top; | |
16417 | + } | |
16418 | + if ( event.pageX - this.offset.click.left > this.containment[ 2 ] ) { | |
16419 | + pageX = this.containment[ 2 ] + this.offset.click.left; | |
16420 | + } | |
16421 | + if ( event.pageY - this.offset.click.top > this.containment[ 3 ] ) { | |
16422 | + pageY = this.containment[ 3 ] + this.offset.click.top; | |
16423 | + } | |
16424 | + } | |
16425 | + | |
16426 | + if ( o.grid ) { | |
16427 | + top = this.originalPageY + Math.round( ( pageY - this.originalPageY ) / | |
16428 | + o.grid[ 1 ] ) * o.grid[ 1 ]; | |
16429 | + pageY = this.containment ? | |
16430 | + ( ( top - this.offset.click.top >= this.containment[ 1 ] && | |
16431 | + top - this.offset.click.top <= this.containment[ 3 ] ) ? | |
16432 | + top : | |
16433 | + ( ( top - this.offset.click.top >= this.containment[ 1 ] ) ? | |
16434 | + top - o.grid[ 1 ] : top + o.grid[ 1 ] ) ) : | |
16435 | + top; | |
16436 | + | |
16437 | + left = this.originalPageX + Math.round( ( pageX - this.originalPageX ) / | |
16438 | + o.grid[ 0 ] ) * o.grid[ 0 ]; | |
16439 | + pageX = this.containment ? | |
16440 | + ( ( left - this.offset.click.left >= this.containment[ 0 ] && | |
16441 | + left - this.offset.click.left <= this.containment[ 2 ] ) ? | |
16442 | + left : | |
16443 | + ( ( left - this.offset.click.left >= this.containment[ 0 ] ) ? | |
16444 | + left - o.grid[ 0 ] : left + o.grid[ 0 ] ) ) : | |
16445 | + left; | |
16446 | + } | |
16447 | + | |
16448 | + } | |
16449 | + | |
16450 | + return { | |
16451 | + top: ( | |
16452 | + | |
16453 | + // The absolute mouse position | |
16454 | + pageY - | |
16455 | + | |
16456 | + // Click offset (relative to the element) | |
16457 | + this.offset.click.top - | |
16458 | + | |
16459 | + // Only for relative positioned nodes: Relative offset from element to offset parent | |
16460 | + this.offset.relative.top - | |
16461 | + | |
16462 | + // The offsetParent's offset without borders (offset + border) | |
16463 | + this.offset.parent.top + | |
16464 | + ( ( this.cssPosition === "fixed" ? | |
16465 | + -this.scrollParent.scrollTop() : | |
16466 | + ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) ) | |
16467 | + ), | |
16468 | + left: ( | |
16469 | + | |
16470 | + // The absolute mouse position | |
16471 | + pageX - | |
16472 | + | |
16473 | + // Click offset (relative to the element) | |
16474 | + this.offset.click.left - | |
16475 | + | |
16476 | + // Only for relative positioned nodes: Relative offset from element to offset parent | |
16477 | + this.offset.relative.left - | |
16478 | + | |
16479 | + // The offsetParent's offset without borders (offset + border) | |
16480 | + this.offset.parent.left + | |
16481 | + ( ( this.cssPosition === "fixed" ? | |
16482 | + -this.scrollParent.scrollLeft() : | |
16483 | + scrollIsRootNode ? 0 : scroll.scrollLeft() ) ) | |
16484 | + ) | |
16485 | + }; | |
16486 | + | |
16487 | + }, | |
16488 | + | |
16489 | + _rearrange: function( event, i, a, hardRefresh ) { | |
16490 | + | |
16491 | + a ? a[ 0 ].appendChild( this.placeholder[ 0 ] ) : | |
16492 | + i.item[ 0 ].parentNode.insertBefore( this.placeholder[ 0 ], | |
16493 | + ( this.direction === "down" ? i.item[ 0 ] : i.item[ 0 ].nextSibling ) ); | |
16494 | + | |
16495 | + //Various things done here to improve the performance: | |
16496 | + // 1. we create a setTimeout, that calls refreshPositions | |
16497 | + // 2. on the instance, we have a counter variable, that get's higher after every append | |
16498 | + // 3. on the local scope, we copy the counter variable, and check in the timeout, | |
16499 | + // if it's still the same | |
16500 | + // 4. this lets only the last addition to the timeout stack through | |
16501 | + this.counter = this.counter ? ++this.counter : 1; | |
16502 | + var counter = this.counter; | |
16503 | + | |
16504 | + this._delay( function() { | |
16505 | + if ( counter === this.counter ) { | |
16506 | + | |
16507 | + //Precompute after each DOM insertion, NOT on mousemove | |
16508 | + this.refreshPositions( !hardRefresh ); | |
16509 | + } | |
16510 | + } ); | |
16511 | + | |
16512 | + }, | |
16513 | + | |
16514 | + _clear: function( event, noPropagation ) { | |
16515 | + | |
16516 | + this.reverting = false; | |
16517 | + | |
16518 | + // We delay all events that have to be triggered to after the point where the placeholder | |
16519 | + // has been removed and everything else normalized again | |
16520 | + var i, | |
16521 | + delayedTriggers = []; | |
16522 | + | |
16523 | + // We first have to update the dom position of the actual currentItem | |
16524 | + // Note: don't do it if the current item is already removed (by a user), or it gets | |
16525 | + // reappended (see #4088) | |
16526 | + if ( !this._noFinalSort && this.currentItem.parent().length ) { | |
16527 | + this.placeholder.before( this.currentItem ); | |
16528 | + } | |
16529 | + this._noFinalSort = null; | |
16530 | + | |
16531 | + if ( this.helper[ 0 ] === this.currentItem[ 0 ] ) { | |
16532 | + for ( i in this._storedCSS ) { | |
16533 | + if ( this._storedCSS[ i ] === "auto" || this._storedCSS[ i ] === "static" ) { | |
16534 | + this._storedCSS[ i ] = ""; | |
16535 | + } | |
16536 | + } | |
16537 | + this.currentItem.css( this._storedCSS ); | |
16538 | + this._removeClass( this.currentItem, "ui-sortable-helper" ); | |
16539 | + } else { | |
16540 | + this.currentItem.show(); | |
16541 | + } | |
16542 | + | |
16543 | + if ( this.fromOutside && !noPropagation ) { | |
16544 | + delayedTriggers.push( function( event ) { | |
16545 | + this._trigger( "receive", event, this._uiHash( this.fromOutside ) ); | |
16546 | + } ); | |
16547 | + } | |
16548 | + if ( ( this.fromOutside || | |
16549 | + this.domPosition.prev !== | |
16550 | + this.currentItem.prev().not( ".ui-sortable-helper" )[ 0 ] || | |
16551 | + this.domPosition.parent !== this.currentItem.parent()[ 0 ] ) && !noPropagation ) { | |
16552 | + | |
16553 | + // Trigger update callback if the DOM position has changed | |
16554 | + delayedTriggers.push( function( event ) { | |
16555 | + this._trigger( "update", event, this._uiHash() ); | |
16556 | + } ); | |
16557 | + } | |
16558 | + | |
16559 | + // Check if the items Container has Changed and trigger appropriate | |
16560 | + // events. | |
16561 | + if ( this !== this.currentContainer ) { | |
16562 | + if ( !noPropagation ) { | |
16563 | + delayedTriggers.push( function( event ) { | |
16564 | + this._trigger( "remove", event, this._uiHash() ); | |
16565 | + } ); | |
16566 | + delayedTriggers.push( ( function( c ) { | |
16567 | + return function( event ) { | |
16568 | + c._trigger( "receive", event, this._uiHash( this ) ); | |
16569 | + }; | |
16570 | + } ).call( this, this.currentContainer ) ); | |
16571 | + delayedTriggers.push( ( function( c ) { | |
16572 | + return function( event ) { | |
16573 | + c._trigger( "update", event, this._uiHash( this ) ); | |
16574 | + }; | |
16575 | + } ).call( this, this.currentContainer ) ); | |
16576 | + } | |
16577 | + } | |
16578 | + | |
16579 | + //Post events to containers | |
16580 | + function delayEvent( type, instance, container ) { | |
16581 | + return function( event ) { | |
16582 | + container._trigger( type, event, instance._uiHash( instance ) ); | |
16583 | + }; | |
16584 | + } | |
16585 | + for ( i = this.containers.length - 1; i >= 0; i-- ) { | |
16586 | + if ( !noPropagation ) { | |
16587 | + delayedTriggers.push( delayEvent( "deactivate", this, this.containers[ i ] ) ); | |
16588 | + } | |
16589 | + if ( this.containers[ i ].containerCache.over ) { | |
16590 | + delayedTriggers.push( delayEvent( "out", this, this.containers[ i ] ) ); | |
16591 | + this.containers[ i ].containerCache.over = 0; | |
16592 | + } | |
16593 | + } | |
16594 | + | |
16595 | + //Do what was originally in plugins | |
16596 | + if ( this.storedCursor ) { | |
16597 | + this.document.find( "body" ).css( "cursor", this.storedCursor ); | |
16598 | + this.storedStylesheet.remove(); | |
16599 | + } | |
16600 | + if ( this._storedOpacity ) { | |
16601 | + this.helper.css( "opacity", this._storedOpacity ); | |
16602 | + } | |
16603 | + if ( this._storedZIndex ) { | |
16604 | + this.helper.css( "zIndex", this._storedZIndex === "auto" ? "" : this._storedZIndex ); | |
16605 | + } | |
16606 | + | |
16607 | + this.dragging = false; | |
16608 | + | |
16609 | + if ( !noPropagation ) { | |
16610 | + this._trigger( "beforeStop", event, this._uiHash() ); | |
16611 | + } | |
16612 | + | |
16613 | + //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, | |
16614 | + // it unbinds ALL events from the original node! | |
16615 | + this.placeholder[ 0 ].parentNode.removeChild( this.placeholder[ 0 ] ); | |
16616 | + | |
16617 | + if ( !this.cancelHelperRemoval ) { | |
16618 | + if ( this.helper[ 0 ] !== this.currentItem[ 0 ] ) { | |
16619 | + this.helper.remove(); | |
16620 | + } | |
16621 | + this.helper = null; | |
16622 | + } | |
16623 | + | |
16624 | + if ( !noPropagation ) { | |
16625 | + for ( i = 0; i < delayedTriggers.length; i++ ) { | |
16626 | + | |
16627 | + // Trigger all delayed events | |
16628 | + delayedTriggers[ i ].call( this, event ); | |
16629 | + } | |
16630 | + this._trigger( "stop", event, this._uiHash() ); | |
16631 | + } | |
16632 | + | |
16633 | + this.fromOutside = false; | |
16634 | + return !this.cancelHelperRemoval; | |
16635 | + | |
16636 | + }, | |
16637 | + | |
16638 | + _trigger: function() { | |
16639 | + if ( $.Widget.prototype._trigger.apply( this, arguments ) === false ) { | |
16640 | + this.cancel(); | |
16641 | + } | |
16642 | + }, | |
16643 | + | |
16644 | + _uiHash: function( _inst ) { | |
16645 | + var inst = _inst || this; | |
16646 | + return { | |
16647 | + helper: inst.helper, | |
16648 | + placeholder: inst.placeholder || $( [] ), | |
16649 | + position: inst.position, | |
16650 | + originalPosition: inst.originalPosition, | |
16651 | + offset: inst.positionAbs, | |
16652 | + item: inst.currentItem, | |
16653 | + sender: _inst ? _inst.element : null | |
16654 | + }; | |
16655 | + } | |
16656 | + | |
16657 | +} ); | |
16658 | + | |
16659 | + | |
16660 | +/*! | |
16661 | + * jQuery UI Spinner 1.12.0-rc.2 | |
16662 | + * http://jqueryui.com | |
16663 | + * | |
16664 | + * Copyright jQuery Foundation and other contributors | |
16665 | + * Released under the MIT license. | |
16666 | + * http://jquery.org/license | |
16667 | + */ | |
16668 | + | |
16669 | +//>>label: Spinner | |
16670 | +//>>group: Widgets | |
16671 | +//>>description: Displays buttons to easily input numbers via the keyboard or mouse. | |
16672 | +//>>docs: http://api.jqueryui.com/spinner/ | |
16673 | +//>>demos: http://jqueryui.com/spinner/ | |
16674 | +//>>css.structure: ../../themes/base/core.css | |
16675 | +//>>css.structure: ../../themes/base/spinner.css | |
16676 | +//>>css.theme: ../../themes/base/theme.css | |
16677 | + | |
16678 | + | |
16679 | + | |
16680 | +function spinnerModifer( fn ) { | |
16681 | + return function() { | |
16682 | + var previous = this.element.val(); | |
16683 | + fn.apply( this, arguments ); | |
16684 | + this._refresh(); | |
16685 | + if ( previous !== this.element.val() ) { | |
16686 | + this._trigger( "change" ); | |
16687 | + } | |
16688 | + }; | |
16689 | +} | |
16690 | + | |
16691 | +$.widget( "ui.spinner", { | |
16692 | + version: "1.12.0-rc.2", | |
16693 | + defaultElement: "<input>", | |
16694 | + widgetEventPrefix: "spin", | |
16695 | + options: { | |
16696 | + classes: { | |
16697 | + "ui-spinner": "ui-corner-all", | |
16698 | + "ui-spinner-down": "ui-corner-br", | |
16699 | + "ui-spinner-up": "ui-corner-tr" | |
16700 | + }, | |
16701 | + culture: null, | |
16702 | + icons: { | |
16703 | + down: "ui-icon-triangle-1-s", | |
16704 | + up: "ui-icon-triangle-1-n" | |
16705 | + }, | |
16706 | + incremental: true, | |
16707 | + max: null, | |
16708 | + min: null, | |
16709 | + numberFormat: null, | |
16710 | + page: 10, | |
16711 | + step: 1, | |
16712 | + | |
16713 | + change: null, | |
16714 | + spin: null, | |
16715 | + start: null, | |
16716 | + stop: null | |
16717 | + }, | |
16718 | + | |
16719 | + _create: function() { | |
16720 | + | |
16721 | + // handle string values that need to be parsed | |
16722 | + this._setOption( "max", this.options.max ); | |
16723 | + this._setOption( "min", this.options.min ); | |
16724 | + this._setOption( "step", this.options.step ); | |
16725 | + | |
16726 | + // Only format if there is a value, prevents the field from being marked | |
16727 | + // as invalid in Firefox, see #9573. | |
16728 | + if ( this.value() !== "" ) { | |
16729 | + | |
16730 | + // Format the value, but don't constrain. | |
16731 | + this._value( this.element.val(), true ); | |
16732 | + } | |
16733 | + | |
16734 | + this._draw(); | |
16735 | + this._on( this._events ); | |
16736 | + this._refresh(); | |
16737 | + | |
16738 | + // Turning off autocomplete prevents the browser from remembering the | |
16739 | + // value when navigating through history, so we re-enable autocomplete | |
16740 | + // if the page is unloaded before the widget is destroyed. #7790 | |
16741 | + this._on( this.window, { | |
16742 | + beforeunload: function() { | |
16743 | + this.element.removeAttr( "autocomplete" ); | |
16744 | + } | |
16745 | + } ); | |
16746 | + }, | |
16747 | + | |
16748 | + _getCreateOptions: function() { | |
16749 | + var options = this._super(); | |
16750 | + var element = this.element; | |
16751 | + | |
16752 | + $.each( [ "min", "max", "step" ], function( i, option ) { | |
16753 | + var value = element.attr( option ); | |
16754 | + if ( value != null && value.length ) { | |
16755 | + options[ option ] = value; | |
16756 | + } | |
16757 | + } ); | |
16758 | + | |
16759 | + return options; | |
16760 | + }, | |
16761 | + | |
16762 | + _events: { | |
16763 | + keydown: function( event ) { | |
16764 | + if ( this._start( event ) && this._keydown( event ) ) { | |
16765 | + event.preventDefault(); | |
16766 | + } | |
16767 | + }, | |
16768 | + keyup: "_stop", | |
16769 | + focus: function() { | |
16770 | + this.previous = this.element.val(); | |
16771 | + }, | |
16772 | + blur: function( event ) { | |
16773 | + if ( this.cancelBlur ) { | |
16774 | + delete this.cancelBlur; | |
16775 | + return; | |
16776 | + } | |
16777 | + | |
16778 | + this._stop(); | |
16779 | + this._refresh(); | |
16780 | + if ( this.previous !== this.element.val() ) { | |
16781 | + this._trigger( "change", event ); | |
16782 | + } | |
16783 | + }, | |
16784 | + mousewheel: function( event, delta ) { | |
16785 | + if ( !delta ) { | |
16786 | + return; | |
16787 | + } | |
16788 | + if ( !this.spinning && !this._start( event ) ) { | |
16789 | + return false; | |
16790 | + } | |
16791 | + | |
16792 | + this._spin( ( delta > 0 ? 1 : -1 ) * this.options.step, event ); | |
16793 | + clearTimeout( this.mousewheelTimer ); | |
16794 | + this.mousewheelTimer = this._delay( function() { | |
16795 | + if ( this.spinning ) { | |
16796 | + this._stop( event ); | |
16797 | + } | |
16798 | + }, 100 ); | |
16799 | + event.preventDefault(); | |
16800 | + }, | |
16801 | + "mousedown .ui-spinner-button": function( event ) { | |
16802 | + var previous; | |
16803 | + | |
16804 | + // We never want the buttons to have focus; whenever the user is | |
16805 | + // interacting with the spinner, the focus should be on the input. | |
16806 | + // If the input is focused then this.previous is properly set from | |
16807 | + // when the input first received focus. If the input is not focused | |
16808 | + // then we need to set this.previous based on the value before spinning. | |
16809 | + previous = this.element[ 0 ] === $.ui.safeActiveElement( this.document[ 0 ] ) ? | |
16810 | + this.previous : this.element.val(); | |
16811 | + function checkFocus() { | |
16812 | + var isActive = this.element[ 0 ] === $.ui.safeActiveElement( this.document[ 0 ] ); | |
16813 | + if ( !isActive ) { | |
16814 | + this.element.trigger( "focus" ); | |
16815 | + this.previous = previous; | |
16816 | + | |
16817 | + // support: IE | |
16818 | + // IE sets focus asynchronously, so we need to check if focus | |
16819 | + // moved off of the input because the user clicked on the button. | |
16820 | + this._delay( function() { | |
16821 | + this.previous = previous; | |
16822 | + } ); | |
16823 | + } | |
16824 | + } | |
16825 | + | |
16826 | + // Ensure focus is on (or stays on) the text field | |
16827 | + event.preventDefault(); | |
16828 | + checkFocus.call( this ); | |
16829 | + | |
16830 | + // Support: IE | |
16831 | + // IE doesn't prevent moving focus even with event.preventDefault() | |
16832 | + // so we set a flag to know when we should ignore the blur event | |
16833 | + // and check (again) if focus moved off of the input. | |
16834 | + this.cancelBlur = true; | |
16835 | + this._delay( function() { | |
16836 | + delete this.cancelBlur; | |
16837 | + checkFocus.call( this ); | |
16838 | + } ); | |
16839 | + | |
16840 | + if ( this._start( event ) === false ) { | |
16841 | + return; | |
16842 | + } | |
16843 | + | |
16844 | + this._repeat( null, $( event.currentTarget ) | |
16845 | + .hasClass( "ui-spinner-up" ) ? 1 : -1, event ); | |
16846 | + }, | |
16847 | + "mouseup .ui-spinner-button": "_stop", | |
16848 | + "mouseenter .ui-spinner-button": function( event ) { | |
16849 | + | |
16850 | + // button will add ui-state-active if mouse was down while mouseleave and kept down | |
16851 | + if ( !$( event.currentTarget ).hasClass( "ui-state-active" ) ) { | |
16852 | + return; | |
16853 | + } | |
16854 | + | |
16855 | + if ( this._start( event ) === false ) { | |
16856 | + return false; | |
16857 | + } | |
16858 | + this._repeat( null, $( event.currentTarget ) | |
16859 | + .hasClass( "ui-spinner-up" ) ? 1 : -1, event ); | |
16860 | + }, | |
16861 | + | |
16862 | + // TODO: do we really want to consider this a stop? | |
16863 | + // shouldn't we just stop the repeater and wait until mouseup before | |
16864 | + // we trigger the stop event? | |
16865 | + "mouseleave .ui-spinner-button": "_stop" | |
16866 | + }, | |
16867 | + | |
16868 | + // Support mobile enhanced option and make backcompat more sane | |
16869 | + _enhance: function() { | |
16870 | + this.uiSpinner = this.element | |
16871 | + .attr( "autocomplete", "off" ) | |
16872 | + .wrap( "<span>" ) | |
16873 | + .parent() | |
16874 | + | |
16875 | + // Add buttons | |
16876 | + .append( | |
16877 | + "<a></a><a></a>" | |
16878 | + ); | |
16879 | + }, | |
16880 | + | |
16881 | + _draw: function() { | |
16882 | + this._enhance(); | |
16883 | + | |
16884 | + this._addClass( this.uiSpinner, "ui-spinner", "ui-widget ui-widget-content" ); | |
16885 | + this._addClass( "ui-spinner-input" ); | |
16886 | + | |
16887 | + this.element.attr( "role", "spinbutton" ); | |
16888 | + | |
16889 | + // Button bindings | |
16890 | + this.buttons = this.uiSpinner.children( "a" ) | |
16891 | + .attr( "tabIndex", -1 ) | |
16892 | + .attr( "aria-hidden", true ) | |
16893 | + .button( { | |
16894 | + classes: { | |
16895 | + "ui-button": "" | |
16896 | + } | |
16897 | + } ); | |
16898 | + | |
16899 | + // TODO: Right now button does not support classes this is already updated in button PR | |
16900 | + this._removeClass( this.buttons, "ui-corner-all" ); | |
16901 | + | |
16902 | + this._addClass( this.buttons.first(), "ui-spinner-button ui-spinner-up" ); | |
16903 | + this._addClass( this.buttons.last(), "ui-spinner-button ui-spinner-down" ); | |
16904 | + this.buttons.first().button( { | |
16905 | + "icon": this.options.icons.up, | |
16906 | + "showLabel": false | |
16907 | + } ); | |
16908 | + this.buttons.last().button( { | |
16909 | + "icon": this.options.icons.down, | |
16910 | + "showLabel": false | |
16911 | + } ); | |
16912 | + | |
16913 | + // IE 6 doesn't understand height: 50% for the buttons | |
16914 | + // unless the wrapper has an explicit height | |
16915 | + if ( this.buttons.height() > Math.ceil( this.uiSpinner.height() * 0.5 ) && | |
16916 | + this.uiSpinner.height() > 0 ) { | |
16917 | + this.uiSpinner.height( this.uiSpinner.height() ); | |
16918 | + } | |
16919 | + }, | |
16920 | + | |
16921 | + _keydown: function( event ) { | |
16922 | + var options = this.options, | |
16923 | + keyCode = $.ui.keyCode; | |
16924 | + | |
16925 | + switch ( event.keyCode ) { | |
16926 | + case keyCode.UP: | |
16927 | + this._repeat( null, 1, event ); | |
16928 | + return true; | |
16929 | + case keyCode.DOWN: | |
16930 | + this._repeat( null, -1, event ); | |
16931 | + return true; | |
16932 | + case keyCode.PAGE_UP: | |
16933 | + this._repeat( null, options.page, event ); | |
16934 | + return true; | |
16935 | + case keyCode.PAGE_DOWN: | |
16936 | + this._repeat( null, -options.page, event ); | |
16937 | + return true; | |
16938 | + } | |
16939 | + | |
16940 | + return false; | |
16941 | + }, | |
16942 | + | |
16943 | + _start: function( event ) { | |
16944 | + if ( !this.spinning && this._trigger( "start", event ) === false ) { | |
16945 | + return false; | |
16946 | + } | |
16947 | + | |
16948 | + if ( !this.counter ) { | |
16949 | + this.counter = 1; | |
16950 | + } | |
16951 | + this.spinning = true; | |
16952 | + return true; | |
16953 | + }, | |
16954 | + | |
16955 | + _repeat: function( i, steps, event ) { | |
16956 | + i = i || 500; | |
16957 | + | |
16958 | + clearTimeout( this.timer ); | |
16959 | + this.timer = this._delay( function() { | |
16960 | + this._repeat( 40, steps, event ); | |
16961 | + }, i ); | |
16962 | + | |
16963 | + this._spin( steps * this.options.step, event ); | |
16964 | + }, | |
16965 | + | |
16966 | + _spin: function( step, event ) { | |
16967 | + var value = this.value() || 0; | |
16968 | + | |
16969 | + if ( !this.counter ) { | |
16970 | + this.counter = 1; | |
16971 | + } | |
16972 | + | |
16973 | + value = this._adjustValue( value + step * this._increment( this.counter ) ); | |
16974 | + | |
16975 | + if ( !this.spinning || this._trigger( "spin", event, { value: value } ) !== false ) { | |
16976 | + this._value( value ); | |
16977 | + this.counter++; | |
16978 | + } | |
16979 | + }, | |
16980 | + | |
16981 | + _increment: function( i ) { | |
16982 | + var incremental = this.options.incremental; | |
16983 | + | |
16984 | + if ( incremental ) { | |
16985 | + return $.isFunction( incremental ) ? | |
16986 | + incremental( i ) : | |
16987 | + Math.floor( i * i * i / 50000 - i * i / 500 + 17 * i / 200 + 1 ); | |
16988 | + } | |
16989 | + | |
16990 | + return 1; | |
16991 | + }, | |
16992 | + | |
16993 | + _precision: function() { | |
16994 | + var precision = this._precisionOf( this.options.step ); | |
16995 | + if ( this.options.min !== null ) { | |
16996 | + precision = Math.max( precision, this._precisionOf( this.options.min ) ); | |
16997 | + } | |
16998 | + return precision; | |
16999 | + }, | |
17000 | + | |
17001 | + _precisionOf: function( num ) { | |
17002 | + var str = num.toString(), | |
17003 | + decimal = str.indexOf( "." ); | |
17004 | + return decimal === -1 ? 0 : str.length - decimal - 1; | |
17005 | + }, | |
17006 | + | |
17007 | + _adjustValue: function( value ) { | |
17008 | + var base, aboveMin, | |
17009 | + options = this.options; | |
17010 | + | |
17011 | + // Make sure we're at a valid step | |
17012 | + // - find out where we are relative to the base (min or 0) | |
17013 | + base = options.min !== null ? options.min : 0; | |
17014 | + aboveMin = value - base; | |
17015 | + | |
17016 | + // - round to the nearest step | |
17017 | + aboveMin = Math.round( aboveMin / options.step ) * options.step; | |
17018 | + | |
17019 | + // - rounding is based on 0, so adjust back to our base | |
17020 | + value = base + aboveMin; | |
17021 | + | |
17022 | + // Fix precision from bad JS floating point math | |
17023 | + value = parseFloat( value.toFixed( this._precision() ) ); | |
17024 | + | |
17025 | + // Clamp the value | |
17026 | + if ( options.max !== null && value > options.max ) { | |
17027 | + return options.max; | |
17028 | + } | |
17029 | + if ( options.min !== null && value < options.min ) { | |
17030 | + return options.min; | |
17031 | + } | |
17032 | + | |
17033 | + return value; | |
17034 | + }, | |
17035 | + | |
17036 | + _stop: function( event ) { | |
17037 | + if ( !this.spinning ) { | |
17038 | + return; | |
17039 | + } | |
17040 | + | |
17041 | + clearTimeout( this.timer ); | |
17042 | + clearTimeout( this.mousewheelTimer ); | |
17043 | + this.counter = 0; | |
17044 | + this.spinning = false; | |
17045 | + this._trigger( "stop", event ); | |
17046 | + }, | |
17047 | + | |
17048 | + _setOption: function( key, value ) { | |
17049 | + var prevValue, first, last; | |
17050 | + | |
17051 | + if ( key === "culture" || key === "numberFormat" ) { | |
17052 | + prevValue = this._parse( this.element.val() ); | |
17053 | + this.options[ key ] = value; | |
17054 | + this.element.val( this._format( prevValue ) ); | |
17055 | + return; | |
17056 | + } | |
17057 | + | |
17058 | + if ( key === "max" || key === "min" || key === "step" ) { | |
17059 | + if ( typeof value === "string" ) { | |
17060 | + value = this._parse( value ); | |
17061 | + } | |
17062 | + } | |
17063 | + if ( key === "icons" ) { | |
17064 | + first = this.buttons.first().find( ".ui-icon" ); | |
17065 | + this._removeClass( first, null, this.options.icons.up ); | |
17066 | + this._addClass( first, null, value.up ); | |
17067 | + last = this.buttons.last().find( ".ui-icon" ); | |
17068 | + this._removeClass( last, null, this.options.icons.down ); | |
17069 | + this._addClass( last, null, value.down ); | |
17070 | + } | |
17071 | + | |
17072 | + this._super( key, value ); | |
17073 | + }, | |
17074 | + | |
17075 | + _setOptionDisabled: function( value ) { | |
17076 | + this._super( value ); | |
17077 | + | |
17078 | + this._toggleClass( this.uiSpinner, null, "ui-state-disabled", !!value ); | |
17079 | + this.element.prop( "disabled", !!value ); | |
17080 | + this.buttons.button( value ? "disable" : "enable" ); | |
17081 | + }, | |
17082 | + | |
17083 | + _setOptions: spinnerModifer( function( options ) { | |
17084 | + this._super( options ); | |
17085 | + } ), | |
17086 | + | |
17087 | + _parse: function( val ) { | |
17088 | + if ( typeof val === "string" && val !== "" ) { | |
17089 | + val = window.Globalize && this.options.numberFormat ? | |
17090 | + Globalize.parseFloat( val, 10, this.options.culture ) : +val; | |
17091 | + } | |
17092 | + return val === "" || isNaN( val ) ? null : val; | |
17093 | + }, | |
17094 | + | |
17095 | + _format: function( value ) { | |
17096 | + if ( value === "" ) { | |
17097 | + return ""; | |
17098 | + } | |
17099 | + return window.Globalize && this.options.numberFormat ? | |
17100 | + Globalize.format( value, this.options.numberFormat, this.options.culture ) : | |
17101 | + value; | |
17102 | + }, | |
17103 | + | |
17104 | + _refresh: function() { | |
17105 | + this.element.attr( { | |
17106 | + "aria-valuemin": this.options.min, | |
17107 | + "aria-valuemax": this.options.max, | |
17108 | + | |
17109 | + // TODO: what should we do with values that can't be parsed? | |
17110 | + "aria-valuenow": this._parse( this.element.val() ) | |
17111 | + } ); | |
17112 | + }, | |
17113 | + | |
17114 | + isValid: function() { | |
17115 | + var value = this.value(); | |
17116 | + | |
17117 | + // Null is invalid | |
17118 | + if ( value === null ) { | |
17119 | + return false; | |
17120 | + } | |
17121 | + | |
17122 | + // If value gets adjusted, it's invalid | |
17123 | + return value === this._adjustValue( value ); | |
17124 | + }, | |
17125 | + | |
17126 | + // Update the value without triggering change | |
17127 | + _value: function( value, allowAny ) { | |
17128 | + var parsed; | |
17129 | + if ( value !== "" ) { | |
17130 | + parsed = this._parse( value ); | |
17131 | + if ( parsed !== null ) { | |
17132 | + if ( !allowAny ) { | |
17133 | + parsed = this._adjustValue( parsed ); | |
17134 | + } | |
17135 | + value = this._format( parsed ); | |
17136 | + } | |
17137 | + } | |
17138 | + this.element.val( value ); | |
17139 | + this._refresh(); | |
17140 | + }, | |
17141 | + | |
17142 | + _destroy: function() { | |
17143 | + this.element | |
17144 | + .prop( "disabled", false ) | |
17145 | + .removeAttr( "autocomplete role aria-valuemin aria-valuemax aria-valuenow" ); | |
17146 | + | |
17147 | + this.uiSpinner.replaceWith( this.element ); | |
17148 | + }, | |
17149 | + | |
17150 | + stepUp: spinnerModifer( function( steps ) { | |
17151 | + this._stepUp( steps ); | |
17152 | + } ), | |
17153 | + _stepUp: function( steps ) { | |
17154 | + if ( this._start() ) { | |
17155 | + this._spin( ( steps || 1 ) * this.options.step ); | |
17156 | + this._stop(); | |
17157 | + } | |
17158 | + }, | |
17159 | + | |
17160 | + stepDown: spinnerModifer( function( steps ) { | |
17161 | + this._stepDown( steps ); | |
17162 | + } ), | |
17163 | + _stepDown: function( steps ) { | |
17164 | + if ( this._start() ) { | |
17165 | + this._spin( ( steps || 1 ) * -this.options.step ); | |
17166 | + this._stop(); | |
17167 | + } | |
17168 | + }, | |
17169 | + | |
17170 | + pageUp: spinnerModifer( function( pages ) { | |
17171 | + this._stepUp( ( pages || 1 ) * this.options.page ); | |
17172 | + } ), | |
17173 | + | |
17174 | + pageDown: spinnerModifer( function( pages ) { | |
17175 | + this._stepDown( ( pages || 1 ) * this.options.page ); | |
17176 | + } ), | |
17177 | + | |
17178 | + value: function( newVal ) { | |
17179 | + if ( !arguments.length ) { | |
17180 | + return this._parse( this.element.val() ); | |
17181 | + } | |
17182 | + spinnerModifer( this._value ).call( this, newVal ); | |
17183 | + }, | |
17184 | + | |
17185 | + widget: function() { | |
17186 | + return this.uiSpinner; | |
17187 | + } | |
17188 | +} ); | |
17189 | + | |
17190 | +// DEPRECATED | |
17191 | +// TODO: switch return back to widget declaration at top of file when this is removed | |
17192 | +if ( $.uiBackCompat !== false ) { | |
17193 | + | |
17194 | + // Backcompat for spinner html extension points | |
17195 | + $.widget( "ui.spinner", $.ui.spinner, { | |
17196 | + _enhance: function() { | |
17197 | + this.uiSpinner = this.element | |
17198 | + .attr( "autocomplete", "off" ) | |
17199 | + .wrap( this._uiSpinnerHtml() ) | |
17200 | + .parent() | |
17201 | + | |
17202 | + // Add buttons | |
17203 | + .append( this._buttonHtml() ); | |
17204 | + }, | |
17205 | + _uiSpinnerHtml: function() { | |
17206 | + return "<span>"; | |
17207 | + }, | |
17208 | + | |
17209 | + _buttonHtml: function() { | |
17210 | + return "<a></a><a></a>"; | |
17211 | + } | |
17212 | + } ); | |
17213 | +} | |
17214 | + | |
17215 | +var widgetsSpinner = $.ui.spinner; | |
17216 | + | |
17217 | + | |
17218 | +/*! | |
17219 | + * jQuery UI Tabs 1.12.0-rc.2 | |
17220 | + * http://jqueryui.com | |
17221 | + * | |
17222 | + * Copyright jQuery Foundation and other contributors | |
17223 | + * Released under the MIT license. | |
17224 | + * http://jquery.org/license | |
17225 | + */ | |
17226 | + | |
17227 | +//>>label: Tabs | |
17228 | +//>>group: Widgets | |
17229 | +//>>description: Transforms a set of container elements into a tab structure. | |
17230 | +//>>docs: http://api.jqueryui.com/tabs/ | |
17231 | +//>>demos: http://jqueryui.com/tabs/ | |
17232 | +//>>css.structure: ../../themes/base/core.css | |
17233 | +//>>css.structure: ../../themes/base/tabs.css | |
17234 | +//>>css.theme: ../../themes/base/theme.css | |
17235 | + | |
17236 | + | |
17237 | + | |
17238 | +$.widget( "ui.tabs", { | |
17239 | + version: "1.12.0-rc.2", | |
17240 | + delay: 300, | |
17241 | + options: { | |
17242 | + active: null, | |
17243 | + classes: { | |
17244 | + "ui-tabs": "ui-corner-all", | |
17245 | + "ui-tabs-nav": "ui-corner-all", | |
17246 | + "ui-tab": "ui-corner-top", | |
17247 | + "ui-tabs-panel": "ui-corner-bottom" | |
17248 | + }, | |
17249 | + collapsible: false, | |
17250 | + event: "click", | |
17251 | + heightStyle: "content", | |
17252 | + hide: null, | |
17253 | + show: null, | |
17254 | + | |
17255 | + // Callbacks | |
17256 | + activate: null, | |
17257 | + beforeActivate: null, | |
17258 | + beforeLoad: null, | |
17259 | + load: null | |
17260 | + }, | |
17261 | + | |
17262 | + _isLocal: ( function() { | |
17263 | + var rhash = /#.*$/; | |
17264 | + | |
17265 | + return function( anchor ) { | |
17266 | + var anchorUrl, locationUrl; | |
17267 | + | |
17268 | + anchorUrl = anchor.href.replace( rhash, "" ); | |
17269 | + locationUrl = location.href.replace( rhash, "" ); | |
17270 | + | |
17271 | + // Decoding may throw an error if the URL isn't UTF-8 (#9518) | |
17272 | + try { | |
17273 | + anchorUrl = decodeURIComponent( anchorUrl ); | |
17274 | + } catch ( error ) {} | |
17275 | + try { | |
17276 | + locationUrl = decodeURIComponent( locationUrl ); | |
17277 | + } catch ( error ) {} | |
17278 | + | |
17279 | + return anchor.hash.length > 1 && anchorUrl === locationUrl; | |
17280 | + }; | |
17281 | + } )(), | |
17282 | + | |
17283 | + _create: function() { | |
17284 | + var that = this, | |
17285 | + options = this.options; | |
17286 | + | |
17287 | + this.running = false; | |
17288 | + | |
17289 | + this._addClass( "ui-tabs", "ui-widget ui-widget-content" ); | |
17290 | + this._toggleClass( "ui-tabs-collapsible", null, options.collapsible ); | |
17291 | + | |
17292 | + this._processTabs(); | |
17293 | + options.active = this._initialActive(); | |
17294 | + | |
17295 | + // Take disabling tabs via class attribute from HTML | |
17296 | + // into account and update option properly. | |
17297 | + if ( $.isArray( options.disabled ) ) { | |
17298 | + options.disabled = $.unique( options.disabled.concat( | |
17299 | + $.map( this.tabs.filter( ".ui-state-disabled" ), function( li ) { | |
17300 | + return that.tabs.index( li ); | |
17301 | + } ) | |
17302 | + ) ).sort(); | |
17303 | + } | |
17304 | + | |
17305 | + // Check for length avoids error when initializing empty list | |
17306 | + if ( this.options.active !== false && this.anchors.length ) { | |
17307 | + this.active = this._findActive( options.active ); | |
17308 | + } else { | |
17309 | + this.active = $(); | |
17310 | + } | |
17311 | + | |
17312 | + this._refresh(); | |
17313 | + | |
17314 | + if ( this.active.length ) { | |
17315 | + this.load( options.active ); | |
17316 | + } | |
17317 | + }, | |
17318 | + | |
17319 | + _initialActive: function() { | |
17320 | + var active = this.options.active, | |
17321 | + collapsible = this.options.collapsible, | |
17322 | + locationHash = location.hash.substring( 1 ); | |
17323 | + | |
17324 | + if ( active === null ) { | |
17325 | + | |
17326 | + // check the fragment identifier in the URL | |
17327 | + if ( locationHash ) { | |
17328 | + this.tabs.each( function( i, tab ) { | |
17329 | + if ( $( tab ).attr( "aria-controls" ) === locationHash ) { | |
17330 | + active = i; | |
17331 | + return false; | |
17332 | + } | |
17333 | + } ); | |
17334 | + } | |
17335 | + | |
17336 | + // Check for a tab marked active via a class | |
17337 | + if ( active === null ) { | |
17338 | + active = this.tabs.index( this.tabs.filter( ".ui-tabs-active" ) ); | |
17339 | + } | |
17340 | + | |
17341 | + // No active tab, set to false | |
17342 | + if ( active === null || active === -1 ) { | |
17343 | + active = this.tabs.length ? 0 : false; | |
17344 | + } | |
17345 | + } | |
17346 | + | |
17347 | + // Handle numbers: negative, out of range | |
17348 | + if ( active !== false ) { | |
17349 | + active = this.tabs.index( this.tabs.eq( active ) ); | |
17350 | + if ( active === -1 ) { | |
17351 | + active = collapsible ? false : 0; | |
17352 | + } | |
17353 | + } | |
17354 | + | |
17355 | + // Don't allow collapsible: false and active: false | |
17356 | + if ( !collapsible && active === false && this.anchors.length ) { | |
17357 | + active = 0; | |
17358 | + } | |
17359 | + | |
17360 | + return active; | |
17361 | + }, | |
17362 | + | |
17363 | + _getCreateEventData: function() { | |
17364 | + return { | |
17365 | + tab: this.active, | |
17366 | + panel: !this.active.length ? $() : this._getPanelForTab( this.active ) | |
17367 | + }; | |
17368 | + }, | |
17369 | + | |
17370 | + _tabKeydown: function( event ) { | |
17371 | + var focusedTab = $( $.ui.safeActiveElement( this.document[ 0 ] ) ).closest( "li" ), | |
17372 | + selectedIndex = this.tabs.index( focusedTab ), | |
17373 | + goingForward = true; | |
17374 | + | |
17375 | + if ( this._handlePageNav( event ) ) { | |
17376 | + return; | |
17377 | + } | |
17378 | + | |
17379 | + switch ( event.keyCode ) { | |
17380 | + case $.ui.keyCode.RIGHT: | |
17381 | + case $.ui.keyCode.DOWN: | |
17382 | + selectedIndex++; | |
17383 | + break; | |
17384 | + case $.ui.keyCode.UP: | |
17385 | + case $.ui.keyCode.LEFT: | |
17386 | + goingForward = false; | |
17387 | + selectedIndex--; | |
17388 | + break; | |
17389 | + case $.ui.keyCode.END: | |
17390 | + selectedIndex = this.anchors.length - 1; | |
17391 | + break; | |
17392 | + case $.ui.keyCode.HOME: | |
17393 | + selectedIndex = 0; | |
17394 | + break; | |
17395 | + case $.ui.keyCode.SPACE: | |
17396 | + | |
17397 | + // Activate only, no collapsing | |
17398 | + event.preventDefault(); | |
17399 | + clearTimeout( this.activating ); | |
17400 | + this._activate( selectedIndex ); | |
17401 | + return; | |
17402 | + case $.ui.keyCode.ENTER: | |
17403 | + | |
17404 | + // Toggle (cancel delayed activation, allow collapsing) | |
17405 | + event.preventDefault(); | |
17406 | + clearTimeout( this.activating ); | |
17407 | + | |
17408 | + // Determine if we should collapse or activate | |
17409 | + this._activate( selectedIndex === this.options.active ? false : selectedIndex ); | |
17410 | + return; | |
17411 | + default: | |
17412 | + return; | |
17413 | + } | |
17414 | + | |
17415 | + // Focus the appropriate tab, based on which key was pressed | |
17416 | + event.preventDefault(); | |
17417 | + clearTimeout( this.activating ); | |
17418 | + selectedIndex = this._focusNextTab( selectedIndex, goingForward ); | |
17419 | + | |
17420 | + // Navigating with control/command key will prevent automatic activation | |
17421 | + if ( !event.ctrlKey && !event.metaKey ) { | |
17422 | + | |
17423 | + // Update aria-selected immediately so that AT think the tab is already selected. | |
17424 | + // Otherwise AT may confuse the user by stating that they need to activate the tab, | |
17425 | + // but the tab will already be activated by the time the announcement finishes. | |
17426 | + focusedTab.attr( "aria-selected", "false" ); | |
17427 | + this.tabs.eq( selectedIndex ).attr( "aria-selected", "true" ); | |
17428 | + | |
17429 | + this.activating = this._delay( function() { | |
17430 | + this.option( "active", selectedIndex ); | |
17431 | + }, this.delay ); | |
17432 | + } | |
17433 | + }, | |
17434 | + | |
17435 | + _panelKeydown: function( event ) { | |
17436 | + if ( this._handlePageNav( event ) ) { | |
17437 | + return; | |
17438 | + } | |
17439 | + | |
17440 | + // Ctrl+up moves focus to the current tab | |
17441 | + if ( event.ctrlKey && event.keyCode === $.ui.keyCode.UP ) { | |
17442 | + event.preventDefault(); | |
17443 | + this.active.trigger( "focus" ); | |
17444 | + } | |
17445 | + }, | |
17446 | + | |
17447 | + // Alt+page up/down moves focus to the previous/next tab (and activates) | |
17448 | + _handlePageNav: function( event ) { | |
17449 | + if ( event.altKey && event.keyCode === $.ui.keyCode.PAGE_UP ) { | |
17450 | + this._activate( this._focusNextTab( this.options.active - 1, false ) ); | |
17451 | + return true; | |
17452 | + } | |
17453 | + if ( event.altKey && event.keyCode === $.ui.keyCode.PAGE_DOWN ) { | |
17454 | + this._activate( this._focusNextTab( this.options.active + 1, true ) ); | |
17455 | + return true; | |
17456 | + } | |
17457 | + }, | |
17458 | + | |
17459 | + _findNextTab: function( index, goingForward ) { | |
17460 | + var lastTabIndex = this.tabs.length - 1; | |
17461 | + | |
17462 | + function constrain() { | |
17463 | + if ( index > lastTabIndex ) { | |
17464 | + index = 0; | |
17465 | + } | |
17466 | + if ( index < 0 ) { | |
17467 | + index = lastTabIndex; | |
17468 | + } | |
17469 | + return index; | |
17470 | + } | |
17471 | + | |
17472 | + while ( $.inArray( constrain(), this.options.disabled ) !== -1 ) { | |
17473 | + index = goingForward ? index + 1 : index - 1; | |
17474 | + } | |
17475 | + | |
17476 | + return index; | |
17477 | + }, | |
17478 | + | |
17479 | + _focusNextTab: function( index, goingForward ) { | |
17480 | + index = this._findNextTab( index, goingForward ); | |
17481 | + this.tabs.eq( index ).trigger( "focus" ); | |
17482 | + return index; | |
17483 | + }, | |
17484 | + | |
17485 | + _setOption: function( key, value ) { | |
17486 | + if ( key === "active" ) { | |
17487 | + | |
17488 | + // _activate() will handle invalid values and update this.options | |
17489 | + this._activate( value ); | |
17490 | + return; | |
17491 | + } | |
17492 | + | |
17493 | + this._super( key, value ); | |
17494 | + | |
17495 | + if ( key === "collapsible" ) { | |
17496 | + this._toggleClass( "ui-tabs-collapsible", null, value ); | |
17497 | + | |
17498 | + // Setting collapsible: false while collapsed; open first panel | |
17499 | + if ( !value && this.options.active === false ) { | |
17500 | + this._activate( 0 ); | |
17501 | + } | |
17502 | + } | |
17503 | + | |
17504 | + if ( key === "event" ) { | |
17505 | + this._setupEvents( value ); | |
17506 | + } | |
17507 | + | |
17508 | + if ( key === "heightStyle" ) { | |
17509 | + this._setupHeightStyle( value ); | |
17510 | + } | |
17511 | + }, | |
17512 | + | |
17513 | + _sanitizeSelector: function( hash ) { | |
17514 | + return hash ? hash.replace( /[!"$%&'()*+,.\/:;<=>?@\[\]\^`{|}~]/g, "\\$&" ) : ""; | |
17515 | + }, | |
17516 | + | |
17517 | + refresh: function() { | |
17518 | + var options = this.options, | |
17519 | + lis = this.tablist.children( ":has(a[href])" ); | |
17520 | + | |
17521 | + // Get disabled tabs from class attribute from HTML | |
17522 | + // this will get converted to a boolean if needed in _refresh() | |
17523 | + options.disabled = $.map( lis.filter( ".ui-state-disabled" ), function( tab ) { | |
17524 | + return lis.index( tab ); | |
17525 | + } ); | |
17526 | + | |
17527 | + this._processTabs(); | |
17528 | + | |
17529 | + // Was collapsed or no tabs | |
17530 | + if ( options.active === false || !this.anchors.length ) { | |
17531 | + options.active = false; | |
17532 | + this.active = $(); | |
17533 | + | |
17534 | + // was active, but active tab is gone | |
17535 | + } else if ( this.active.length && !$.contains( this.tablist[ 0 ], this.active[ 0 ] ) ) { | |
17536 | + | |
17537 | + // all remaining tabs are disabled | |
17538 | + if ( this.tabs.length === options.disabled.length ) { | |
17539 | + options.active = false; | |
17540 | + this.active = $(); | |
17541 | + | |
17542 | + // activate previous tab | |
17543 | + } else { | |
17544 | + this._activate( this._findNextTab( Math.max( 0, options.active - 1 ), false ) ); | |
17545 | + } | |
17546 | + | |
17547 | + // was active, active tab still exists | |
17548 | + } else { | |
17549 | + | |
17550 | + // make sure active index is correct | |
17551 | + options.active = this.tabs.index( this.active ); | |
17552 | + } | |
17553 | + | |
17554 | + this._refresh(); | |
17555 | + }, | |
17556 | + | |
17557 | + _refresh: function() { | |
17558 | + this._setOptionDisabled( this.options.disabled ); | |
17559 | + this._setupEvents( this.options.event ); | |
17560 | + this._setupHeightStyle( this.options.heightStyle ); | |
17561 | + | |
17562 | + this.tabs.not( this.active ).attr( { | |
17563 | + "aria-selected": "false", | |
17564 | + "aria-expanded": "false", | |
17565 | + tabIndex: -1 | |
17566 | + } ); | |
17567 | + this.panels.not( this._getPanelForTab( this.active ) ) | |
17568 | + .hide() | |
17569 | + .attr( { | |
17570 | + "aria-hidden": "true" | |
17571 | + } ); | |
17572 | + | |
17573 | + // Make sure one tab is in the tab order | |
17574 | + if ( !this.active.length ) { | |
17575 | + this.tabs.eq( 0 ).attr( "tabIndex", 0 ); | |
17576 | + } else { | |
17577 | + this.active | |
17578 | + .attr( { | |
17579 | + "aria-selected": "true", | |
17580 | + "aria-expanded": "true", | |
17581 | + tabIndex: 0 | |
17582 | + } ); | |
17583 | + this._addClass( this.active, "ui-tabs-active", "ui-state-active" ); | |
17584 | + this._getPanelForTab( this.active ) | |
17585 | + .show() | |
17586 | + .attr( { | |
17587 | + "aria-hidden": "false" | |
17588 | + } ); | |
17589 | + } | |
17590 | + }, | |
17591 | + | |
17592 | + _processTabs: function() { | |
17593 | + var that = this, | |
17594 | + prevTabs = this.tabs, | |
17595 | + prevAnchors = this.anchors, | |
17596 | + prevPanels = this.panels; | |
17597 | + | |
17598 | + this.tablist = this._getList().attr( "role", "tablist" ); | |
17599 | + this._addClass( this.tablist, "ui-tabs-nav", | |
17600 | + "ui-helper-reset ui-helper-clearfix ui-widget-header" ); | |
17601 | + | |
17602 | + // Prevent users from focusing disabled tabs via click | |
17603 | + this.tablist | |
17604 | + .on( "mousedown" + this.eventNamespace, "> li", function( event ) { | |
17605 | + if ( $( this ).is( ".ui-state-disabled" ) ) { | |
17606 | + event.preventDefault(); | |
17607 | + } | |
17608 | + } ) | |
17609 | + | |
17610 | + // Support: IE <9 | |
17611 | + // Preventing the default action in mousedown doesn't prevent IE | |
17612 | + // from focusing the element, so if the anchor gets focused, blur. | |
17613 | + // We don't have to worry about focusing the previously focused | |
17614 | + // element since clicking on a non-focusable element should focus | |
17615 | + // the body anyway. | |
17616 | + .on( "focus" + this.eventNamespace, ".ui-tabs-anchor", function() { | |
17617 | + if ( $( this ).closest( "li" ).is( ".ui-state-disabled" ) ) { | |
17618 | + this.blur(); | |
17619 | + } | |
17620 | + } ); | |
17621 | + | |
17622 | + this.tabs = this.tablist.find( "> li:has(a[href])" ) | |
17623 | + .attr( { | |
17624 | + role: "tab", | |
17625 | + tabIndex: -1 | |
17626 | + } ); | |
17627 | + this._addClass( this.tabs, "ui-tabs-tab", "ui-state-default" ); | |
17628 | + | |
17629 | + this.anchors = this.tabs.map( function() { | |
17630 | + return $( "a", this )[ 0 ]; | |
17631 | + } ) | |
17632 | + .attr( { | |
17633 | + role: "presentation", | |
17634 | + tabIndex: -1 | |
17635 | + } ); | |
17636 | + this._addClass( this.anchors, "ui-tabs-anchor" ); | |
17637 | + | |
17638 | + this.panels = $(); | |
17639 | + | |
17640 | + this.anchors.each( function( i, anchor ) { | |
17641 | + var selector, panel, panelId, | |
17642 | + anchorId = $( anchor ).uniqueId().attr( "id" ), | |
17643 | + tab = $( anchor ).closest( "li" ), | |
17644 | + originalAriaControls = tab.attr( "aria-controls" ); | |
17645 | + | |
17646 | + // Inline tab | |
17647 | + if ( that._isLocal( anchor ) ) { | |
17648 | + selector = anchor.hash; | |
17649 | + panelId = selector.substring( 1 ); | |
17650 | + panel = that.element.find( that._sanitizeSelector( selector ) ); | |
17651 | + | |
17652 | + // remote tab | |
17653 | + } else { | |
17654 | + | |
17655 | + // If the tab doesn't already have aria-controls, | |
17656 | + // generate an id by using a throw-away element | |
17657 | + panelId = tab.attr( "aria-controls" ) || $( {} ).uniqueId()[ 0 ].id; | |
17658 | + selector = "#" + panelId; | |
17659 | + panel = that.element.find( selector ); | |
17660 | + if ( !panel.length ) { | |
17661 | + panel = that._createPanel( panelId ); | |
17662 | + panel.insertAfter( that.panels[ i - 1 ] || that.tablist ); | |
17663 | + } | |
17664 | + panel.attr( "aria-live", "polite" ); | |
17665 | + } | |
17666 | + | |
17667 | + if ( panel.length ) { | |
17668 | + that.panels = that.panels.add( panel ); | |
17669 | + } | |
17670 | + if ( originalAriaControls ) { | |
17671 | + tab.data( "ui-tabs-aria-controls", originalAriaControls ); | |
17672 | + } | |
17673 | + tab.attr( { | |
17674 | + "aria-controls": panelId, | |
17675 | + "aria-labelledby": anchorId | |
17676 | + } ); | |
17677 | + panel.attr( "aria-labelledby", anchorId ); | |
17678 | + } ); | |
17679 | + | |
17680 | + this.panels.attr( "role", "tabpanel" ); | |
17681 | + this._addClass( this.panels, "ui-tabs-panel", "ui-widget-content" ); | |
17682 | + | |
17683 | + // Avoid memory leaks (#10056) | |
17684 | + if ( prevTabs ) { | |
17685 | + this._off( prevTabs.not( this.tabs ) ); | |
17686 | + this._off( prevAnchors.not( this.anchors ) ); | |
17687 | + this._off( prevPanels.not( this.panels ) ); | |
17688 | + } | |
17689 | + }, | |
17690 | + | |
17691 | + // Allow overriding how to find the list for rare usage scenarios (#7715) | |
17692 | + _getList: function() { | |
17693 | + return this.tablist || this.element.find( "ol, ul" ).eq( 0 ); | |
17694 | + }, | |
17695 | + | |
17696 | + _createPanel: function( id ) { | |
17697 | + return $( "<div>" ) | |
17698 | + .attr( "id", id ) | |
17699 | + .data( "ui-tabs-destroy", true ); | |
17700 | + }, | |
17701 | + | |
17702 | + _setOptionDisabled: function( disabled ) { | |
17703 | + var currentItem, li, i; | |
17704 | + | |
17705 | + if ( $.isArray( disabled ) ) { | |
17706 | + if ( !disabled.length ) { | |
17707 | + disabled = false; | |
17708 | + } else if ( disabled.length === this.anchors.length ) { | |
17709 | + disabled = true; | |
17710 | + } | |
17711 | + } | |
17712 | + | |
17713 | + // Disable tabs | |
17714 | + for ( i = 0; ( li = this.tabs[ i ] ); i++ ) { | |
17715 | + currentItem = $( li ); | |
17716 | + if ( disabled === true || $.inArray( i, disabled ) !== -1 ) { | |
17717 | + currentItem.attr( "aria-disabled", "true" ); | |
17718 | + this._addClass( currentItem, null, "ui-state-disabled" ); | |
17719 | + } else { | |
17720 | + currentItem.removeAttr( "aria-disabled" ); | |
17721 | + this._removeClass( currentItem, null, "ui-state-disabled" ); | |
17722 | + } | |
17723 | + } | |
17724 | + | |
17725 | + this.options.disabled = disabled; | |
17726 | + | |
17727 | + this._toggleClass( this.widget(), this.widgetFullName + "-disabled", null, | |
17728 | + disabled === true ); | |
17729 | + }, | |
17730 | + | |
17731 | + _setupEvents: function( event ) { | |
17732 | + var events = {}; | |
17733 | + if ( event ) { | |
17734 | + $.each( event.split( " " ), function( index, eventName ) { | |
17735 | + events[ eventName ] = "_eventHandler"; | |
17736 | + } ); | |
17737 | + } | |
17738 | + | |
17739 | + this._off( this.anchors.add( this.tabs ).add( this.panels ) ); | |
17740 | + | |
17741 | + // Always prevent the default action, even when disabled | |
17742 | + this._on( true, this.anchors, { | |
17743 | + click: function( event ) { | |
17744 | + event.preventDefault(); | |
17745 | + } | |
17746 | + } ); | |
17747 | + this._on( this.anchors, events ); | |
17748 | + this._on( this.tabs, { keydown: "_tabKeydown" } ); | |
17749 | + this._on( this.panels, { keydown: "_panelKeydown" } ); | |
17750 | + | |
17751 | + this._focusable( this.tabs ); | |
17752 | + this._hoverable( this.tabs ); | |
17753 | + }, | |
17754 | + | |
17755 | + _setupHeightStyle: function( heightStyle ) { | |
17756 | + var maxHeight, | |
17757 | + parent = this.element.parent(); | |
17758 | + | |
17759 | + if ( heightStyle === "fill" ) { | |
17760 | + maxHeight = parent.height(); | |
17761 | + maxHeight -= this.element.outerHeight() - this.element.height(); | |
17762 | + | |
17763 | + this.element.siblings( ":visible" ).each( function() { | |
17764 | + var elem = $( this ), | |
17765 | + position = elem.css( "position" ); | |
17766 | + | |
17767 | + if ( position === "absolute" || position === "fixed" ) { | |
17768 | + return; | |
17769 | + } | |
17770 | + maxHeight -= elem.outerHeight( true ); | |
17771 | + } ); | |
17772 | + | |
17773 | + this.element.children().not( this.panels ).each( function() { | |
17774 | + maxHeight -= $( this ).outerHeight( true ); | |
17775 | + } ); | |
17776 | + | |
17777 | + this.panels.each( function() { | |
17778 | + $( this ).height( Math.max( 0, maxHeight - | |
17779 | + $( this ).innerHeight() + $( this ).height() ) ); | |
17780 | + } ) | |
17781 | + .css( "overflow", "auto" ); | |
17782 | + } else if ( heightStyle === "auto" ) { | |
17783 | + maxHeight = 0; | |
17784 | + this.panels.each( function() { | |
17785 | + maxHeight = Math.max( maxHeight, $( this ).height( "" ).height() ); | |
17786 | + } ).height( maxHeight ); | |
17787 | + } | |
17788 | + }, | |
17789 | + | |
17790 | + _eventHandler: function( event ) { | |
17791 | + var options = this.options, | |
17792 | + active = this.active, | |
17793 | + anchor = $( event.currentTarget ), | |
17794 | + tab = anchor.closest( "li" ), | |
17795 | + clickedIsActive = tab[ 0 ] === active[ 0 ], | |
17796 | + collapsing = clickedIsActive && options.collapsible, | |
17797 | + toShow = collapsing ? $() : this._getPanelForTab( tab ), | |
17798 | + toHide = !active.length ? $() : this._getPanelForTab( active ), | |
17799 | + eventData = { | |
17800 | + oldTab: active, | |
17801 | + oldPanel: toHide, | |
17802 | + newTab: collapsing ? $() : tab, | |
17803 | + newPanel: toShow | |
17804 | + }; | |
17805 | + | |
17806 | + event.preventDefault(); | |
17807 | + | |
17808 | + if ( tab.hasClass( "ui-state-disabled" ) || | |
17809 | + | |
17810 | + // tab is already loading | |
17811 | + tab.hasClass( "ui-tabs-loading" ) || | |
17812 | + | |
17813 | + // can't switch durning an animation | |
17814 | + this.running || | |
17815 | + | |
17816 | + // click on active header, but not collapsible | |
17817 | + ( clickedIsActive && !options.collapsible ) || | |
17818 | + | |
17819 | + // allow canceling activation | |
17820 | + ( this._trigger( "beforeActivate", event, eventData ) === false ) ) { | |
17821 | + return; | |
17822 | + } | |
17823 | + | |
17824 | + options.active = collapsing ? false : this.tabs.index( tab ); | |
17825 | + | |
17826 | + this.active = clickedIsActive ? $() : tab; | |
17827 | + if ( this.xhr ) { | |
17828 | + this.xhr.abort(); | |
17829 | + } | |
17830 | + | |
17831 | + if ( !toHide.length && !toShow.length ) { | |
17832 | + $.error( "jQuery UI Tabs: Mismatching fragment identifier." ); | |
17833 | + } | |
17834 | + | |
17835 | + if ( toShow.length ) { | |
17836 | + this.load( this.tabs.index( tab ), event ); | |
17837 | + } | |
17838 | + this._toggle( event, eventData ); | |
17839 | + }, | |
17840 | + | |
17841 | + // Handles show/hide for selecting tabs | |
17842 | + _toggle: function( event, eventData ) { | |
17843 | + var that = this, | |
17844 | + toShow = eventData.newPanel, | |
17845 | + toHide = eventData.oldPanel; | |
17846 | + | |
17847 | + this.running = true; | |
17848 | + | |
17849 | + function complete() { | |
17850 | + that.running = false; | |
17851 | + that._trigger( "activate", event, eventData ); | |
17852 | + } | |
17853 | + | |
17854 | + function show() { | |
17855 | + that._addClass( eventData.newTab.closest( "li" ), "ui-tabs-active", "ui-state-active" ); | |
17856 | + | |
17857 | + if ( toShow.length && that.options.show ) { | |
17858 | + that._show( toShow, that.options.show, complete ); | |
17859 | + } else { | |
17860 | + toShow.show(); | |
17861 | + complete(); | |
17862 | + } | |
17863 | + } | |
17864 | + | |
17865 | + // Start out by hiding, then showing, then completing | |
17866 | + if ( toHide.length && this.options.hide ) { | |
17867 | + this._hide( toHide, this.options.hide, function() { | |
17868 | + that._removeClass( eventData.oldTab.closest( "li" ), | |
17869 | + "ui-tabs-active", "ui-state-active" ); | |
17870 | + show(); | |
17871 | + } ); | |
17872 | + } else { | |
17873 | + this._removeClass( eventData.oldTab.closest( "li" ), | |
17874 | + "ui-tabs-active", "ui-state-active" ); | |
17875 | + toHide.hide(); | |
17876 | + show(); | |
17877 | + } | |
17878 | + | |
17879 | + toHide.attr( "aria-hidden", "true" ); | |
17880 | + eventData.oldTab.attr( { | |
17881 | + "aria-selected": "false", | |
17882 | + "aria-expanded": "false" | |
17883 | + } ); | |
17884 | + | |
17885 | + // If we're switching tabs, remove the old tab from the tab order. | |
17886 | + // If we're opening from collapsed state, remove the previous tab from the tab order. | |
17887 | + // If we're collapsing, then keep the collapsing tab in the tab order. | |
17888 | + if ( toShow.length && toHide.length ) { | |
17889 | + eventData.oldTab.attr( "tabIndex", -1 ); | |
17890 | + } else if ( toShow.length ) { | |
17891 | + this.tabs.filter( function() { | |
17892 | + return $( this ).attr( "tabIndex" ) === 0; | |
17893 | + } ) | |
17894 | + .attr( "tabIndex", -1 ); | |
17895 | + } | |
17896 | + | |
17897 | + toShow.attr( "aria-hidden", "false" ); | |
17898 | + eventData.newTab.attr( { | |
17899 | + "aria-selected": "true", | |
17900 | + "aria-expanded": "true", | |
17901 | + tabIndex: 0 | |
17902 | + } ); | |
17903 | + }, | |
17904 | + | |
17905 | + _activate: function( index ) { | |
17906 | + var anchor, | |
17907 | + active = this._findActive( index ); | |
17908 | + | |
17909 | + // Trying to activate the already active panel | |
17910 | + if ( active[ 0 ] === this.active[ 0 ] ) { | |
17911 | + return; | |
17912 | + } | |
17913 | + | |
17914 | + // Trying to collapse, simulate a click on the current active header | |
17915 | + if ( !active.length ) { | |
17916 | + active = this.active; | |
17917 | + } | |
17918 | + | |
17919 | + anchor = active.find( ".ui-tabs-anchor" )[ 0 ]; | |
17920 | + this._eventHandler( { | |
17921 | + target: anchor, | |
17922 | + currentTarget: anchor, | |
17923 | + preventDefault: $.noop | |
17924 | + } ); | |
17925 | + }, | |
17926 | + | |
17927 | + _findActive: function( index ) { | |
17928 | + return index === false ? $() : this.tabs.eq( index ); | |
17929 | + }, | |
17930 | + | |
17931 | + _getIndex: function( index ) { | |
17932 | + | |
17933 | + // meta-function to give users option to provide a href string instead of a numerical index. | |
17934 | + if ( typeof index === "string" ) { | |
17935 | + index = this.anchors.index( this.anchors.filter( "[href$='" + | |
17936 | + $.ui.escapeSelector( index ) + "']" ) ); | |
17937 | + } | |
17938 | + | |
17939 | + return index; | |
17940 | + }, | |
17941 | + | |
17942 | + _destroy: function() { | |
17943 | + if ( this.xhr ) { | |
17944 | + this.xhr.abort(); | |
17945 | + } | |
17946 | + | |
17947 | + this.tablist | |
17948 | + .removeAttr( "role" ) | |
17949 | + .off( this.eventNamespace ); | |
17950 | + | |
17951 | + this.anchors | |
17952 | + .removeAttr( "role tabIndex" ) | |
17953 | + .removeUniqueId(); | |
17954 | + | |
17955 | + this.tabs.add( this.panels ).each( function() { | |
17956 | + if ( $.data( this, "ui-tabs-destroy" ) ) { | |
17957 | + $( this ).remove(); | |
17958 | + } else { | |
17959 | + $( this ).removeAttr( "role tabIndex " + | |
17960 | + "aria-live aria-busy aria-selected aria-labelledby aria-hidden aria-expanded" ); | |
17961 | + } | |
17962 | + } ); | |
17963 | + | |
17964 | + this.tabs.each( function() { | |
17965 | + var li = $( this ), | |
17966 | + prev = li.data( "ui-tabs-aria-controls" ); | |
17967 | + if ( prev ) { | |
17968 | + li | |
17969 | + .attr( "aria-controls", prev ) | |
17970 | + .removeData( "ui-tabs-aria-controls" ); | |
17971 | + } else { | |
17972 | + li.removeAttr( "aria-controls" ); | |
17973 | + } | |
17974 | + } ); | |
17975 | + | |
17976 | + this.panels.show(); | |
17977 | + | |
17978 | + if ( this.options.heightStyle !== "content" ) { | |
17979 | + this.panels.css( "height", "" ); | |
17980 | + } | |
17981 | + }, | |
17982 | + | |
17983 | + enable: function( index ) { | |
17984 | + var disabled = this.options.disabled; | |
17985 | + if ( disabled === false ) { | |
17986 | + return; | |
17987 | + } | |
17988 | + | |
17989 | + if ( index === undefined ) { | |
17990 | + disabled = false; | |
17991 | + } else { | |
17992 | + index = this._getIndex( index ); | |
17993 | + if ( $.isArray( disabled ) ) { | |
17994 | + disabled = $.map( disabled, function( num ) { | |
17995 | + return num !== index ? num : null; | |
17996 | + } ); | |
17997 | + } else { | |
17998 | + disabled = $.map( this.tabs, function( li, num ) { | |
17999 | + return num !== index ? num : null; | |
18000 | + } ); | |
18001 | + } | |
18002 | + } | |
18003 | + this._setOptionDisabled( disabled ); | |
18004 | + }, | |
18005 | + | |
18006 | + disable: function( index ) { | |
18007 | + var disabled = this.options.disabled; | |
18008 | + if ( disabled === true ) { | |
18009 | + return; | |
18010 | + } | |
18011 | + | |
18012 | + if ( index === undefined ) { | |
18013 | + disabled = true; | |
18014 | + } else { | |
18015 | + index = this._getIndex( index ); | |
18016 | + if ( $.inArray( index, disabled ) !== -1 ) { | |
18017 | + return; | |
18018 | + } | |
18019 | + if ( $.isArray( disabled ) ) { | |
18020 | + disabled = $.merge( [ index ], disabled ).sort(); | |
18021 | + } else { | |
18022 | + disabled = [ index ]; | |
18023 | + } | |
18024 | + } | |
18025 | + this._setOptionDisabled( disabled ); | |
18026 | + }, | |
18027 | + | |
18028 | + load: function( index, event ) { | |
18029 | + index = this._getIndex( index ); | |
18030 | + var that = this, | |
18031 | + tab = this.tabs.eq( index ), | |
18032 | + anchor = tab.find( ".ui-tabs-anchor" ), | |
18033 | + panel = this._getPanelForTab( tab ), | |
18034 | + eventData = { | |
18035 | + tab: tab, | |
18036 | + panel: panel | |
18037 | + }, | |
18038 | + complete = function( jqXHR, status ) { | |
18039 | + if ( status === "abort" ) { | |
18040 | + that.panels.stop( false, true ); | |
18041 | + } | |
18042 | + | |
18043 | + that._removeClass( tab, "ui-tabs-loading" ); | |
18044 | + panel.removeAttr( "aria-busy" ); | |
18045 | + | |
18046 | + if ( jqXHR === that.xhr ) { | |
18047 | + delete that.xhr; | |
18048 | + } | |
18049 | + }; | |
18050 | + | |
18051 | + // Not remote | |
18052 | + if ( this._isLocal( anchor[ 0 ] ) ) { | |
18053 | + return; | |
18054 | + } | |
18055 | + | |
18056 | + this.xhr = $.ajax( this._ajaxSettings( anchor, event, eventData ) ); | |
18057 | + | |
18058 | + // Support: jQuery <1.8 | |
18059 | + // jQuery <1.8 returns false if the request is canceled in beforeSend, | |
18060 | + // but as of 1.8, $.ajax() always returns a jqXHR object. | |
18061 | + if ( this.xhr && this.xhr.statusText !== "canceled" ) { | |
18062 | + this._addClass( tab, "ui-tabs-loading" ); | |
18063 | + panel.attr( "aria-busy", "true" ); | |
18064 | + | |
18065 | + this.xhr | |
18066 | + .done( function( response, status, jqXHR ) { | |
18067 | + | |
18068 | + // support: jQuery <1.8 | |
18069 | + // http://bugs.jquery.com/ticket/11778 | |
18070 | + setTimeout( function() { | |
18071 | + panel.html( response ); | |
18072 | + that._trigger( "load", event, eventData ); | |
18073 | + | |
18074 | + complete( jqXHR, status ); | |
18075 | + }, 1 ); | |
18076 | + } ) | |
18077 | + .fail( function( jqXHR, status ) { | |
18078 | + | |
18079 | + // support: jQuery <1.8 | |
18080 | + // http://bugs.jquery.com/ticket/11778 | |
18081 | + setTimeout( function() { | |
18082 | + complete( jqXHR, status ); | |
18083 | + }, 1 ); | |
18084 | + } ); | |
18085 | + } | |
18086 | + }, | |
18087 | + | |
18088 | + _ajaxSettings: function( anchor, event, eventData ) { | |
18089 | + var that = this; | |
18090 | + return { | |
18091 | + url: anchor.attr( "href" ), | |
18092 | + beforeSend: function( jqXHR, settings ) { | |
18093 | + return that._trigger( "beforeLoad", event, | |
18094 | + $.extend( { jqXHR: jqXHR, ajaxSettings: settings }, eventData ) ); | |
18095 | + } | |
18096 | + }; | |
18097 | + }, | |
18098 | + | |
18099 | + _getPanelForTab: function( tab ) { | |
18100 | + var id = $( tab ).attr( "aria-controls" ); | |
18101 | + return this.element.find( this._sanitizeSelector( "#" + id ) ); | |
18102 | + } | |
18103 | +} ); | |
18104 | + | |
18105 | +// DEPRECATED | |
18106 | +// TODO: Switch return back to widget declaration at top of file when this is removed | |
18107 | +if ( $.uiBackCompat !== false ) { | |
18108 | + | |
18109 | + // Backcompat for ui-tab class (now ui-tabs-tab) | |
18110 | + $.widget( "ui.tabs", $.ui.tabs, { | |
18111 | + _processTabs: function() { | |
18112 | + this._superApply( arguments ); | |
18113 | + this._addClass( this.tabs, "ui-tab" ); | |
18114 | + } | |
18115 | + } ); | |
18116 | +} | |
18117 | + | |
18118 | +var widgetsTabs = $.ui.tabs; | |
18119 | + | |
18120 | + | |
18121 | +/*! | |
18122 | + * jQuery UI Tooltip 1.12.0-rc.2 | |
18123 | + * http://jqueryui.com | |
18124 | + * | |
18125 | + * Copyright jQuery Foundation and other contributors | |
18126 | + * Released under the MIT license. | |
18127 | + * http://jquery.org/license | |
18128 | + */ | |
18129 | + | |
18130 | +//>>label: Tooltip | |
18131 | +//>>group: Widgets | |
18132 | +//>>description: Shows additional information for any element on hover or focus. | |
18133 | +//>>docs: http://api.jqueryui.com/tooltip/ | |
18134 | +//>>demos: http://jqueryui.com/tooltip/ | |
18135 | +//>>css.structure: ../../themes/base/core.css | |
18136 | +//>>css.structure: ../../themes/base/tooltip.css | |
18137 | +//>>css.theme: ../../themes/base/theme.css | |
18138 | + | |
18139 | + | |
18140 | + | |
18141 | +$.widget( "ui.tooltip", { | |
18142 | + version: "1.12.0-rc.2", | |
18143 | + options: { | |
18144 | + classes: { | |
18145 | + "ui-tooltip": "ui-corner-all ui-widget-shadow" | |
18146 | + }, | |
18147 | + content: function() { | |
18148 | + | |
18149 | + // support: IE<9, Opera in jQuery <1.7 | |
18150 | + // .text() can't accept undefined, so coerce to a string | |
18151 | + var title = $( this ).attr( "title" ) || ""; | |
18152 | + | |
18153 | + // Escape title, since we're going from an attribute to raw HTML | |
18154 | + return $( "<a>" ).text( title ).html(); | |
18155 | + }, | |
18156 | + hide: true, | |
18157 | + | |
18158 | + // Disabled elements have inconsistent behavior across browsers (#8661) | |
18159 | + items: "[title]:not([disabled])", | |
18160 | + position: { | |
18161 | + my: "left top+15", | |
18162 | + at: "left bottom", | |
18163 | + collision: "flipfit flip" | |
18164 | + }, | |
18165 | + show: true, | |
18166 | + track: false, | |
18167 | + | |
18168 | + // Callbacks | |
18169 | + close: null, | |
18170 | + open: null | |
18171 | + }, | |
18172 | + | |
18173 | + _addDescribedBy: function( elem, id ) { | |
18174 | + var describedby = ( elem.attr( "aria-describedby" ) || "" ).split( /\s+/ ); | |
18175 | + describedby.push( id ); | |
18176 | + elem | |
18177 | + .data( "ui-tooltip-id", id ) | |
18178 | + .attr( "aria-describedby", $.trim( describedby.join( " " ) ) ); | |
18179 | + }, | |
18180 | + | |
18181 | + _removeDescribedBy: function( elem ) { | |
18182 | + var id = elem.data( "ui-tooltip-id" ), | |
18183 | + describedby = ( elem.attr( "aria-describedby" ) || "" ).split( /\s+/ ), | |
18184 | + in |
Part of diff was cut off due to size limit. Use your local client to view the full diff.