7 if ( typeof define ===
"function" && define.amd ) {
10 define([
"jquery" ], factory );
57 scrollParent:
function( includeHidden ) {
58 var position = this.css(
"position" ),
59 excludeStaticParent = position ===
"absolute",
60 overflowRegex = includeHidden ? /(
auto|scroll|hidden)/ : /(
auto|scroll)/,
61 scrollParent = this.parents().filter(
function() {
62 var parent = $( this );
63 if ( excludeStaticParent && parent.css(
"position" ) ===
"static" ) {
66 return overflowRegex.test( parent.css(
"overflow" ) + parent.css(
"overflow-y" ) + parent.css(
"overflow-x" ) );
69 return position ===
"fixed" || !scrollParent.length ? $(
this[ 0 ].ownerDocument || document ) : scrollParent;
72 uniqueId: (
function() {
76 return this.
each(
function() {
78 this.
id =
"ui-id-" + ( ++uuid );
84 removeUniqueId:
function() {
85 return this.
each(
function() {
86 if ( /^ui-
id-\
d+$/.test( this.
id ) ) {
87 $( this ).removeAttr(
"id" );
94 function focusable( element, isTabIndexNotNaN ) {
95 var map, mapName, img,
96 nodeName = element.nodeName.toLowerCase();
97 if (
"area" === nodeName ) {
98 map = element.parentNode;
100 if ( !element.href || !mapName || map.nodeName.toLowerCase() !==
"map" ) {
103 img = $(
"img[usemap='#" + mapName +
"']" )[ 0 ];
104 return !!img && visible( img );
106 return ( /input|select|textarea|button|
object/.test( nodeName ) ?
109 element.href || isTabIndexNotNaN :
115 function visible( element ) {
116 return $.expr.filters.visible( element ) &&
117 !$( element ).parents().addBack().filter(
function() {
118 return $.css(
this,
"visibility" ) ===
"hidden";
122 $.extend( $.expr[
":" ], {
123 data: $.expr.createPseudo ?
124 $.expr.createPseudo(
function( dataName ) {
125 return function( elem ) {
126 return !!$.data( elem, dataName );
130 function( elem, i, match ) {
131 return !!$.data( elem, match[ 3 ] );
134 focusable:
function( element ) {
135 return focusable( element, !isNaN( $.attr( element,
"tabindex" ) ) );
138 tabbable:
function( element ) {
139 var tabIndex = $.attr( element,
"tabindex" ),
140 isTabIndexNaN = isNaN( tabIndex );
141 return ( isTabIndexNaN || tabIndex >= 0 ) && focusable( element, !isTabIndexNaN );
146 if ( !$(
"<a>" ).outerWidth( 1 ).jquery ) {
147 $.each( [
"Width",
"Height" ],
function( i,
name ) {
148 var side =
name ===
"Width" ? [
"Left",
"Right" ] : [
"Top",
"Bottom" ],
149 type =
name.toLowerCase(),
151 innerWidth: $.fn.innerWidth,
152 innerHeight: $.fn.innerHeight,
153 outerWidth: $.fn.outerWidth,
154 outerHeight: $.fn.outerHeight
157 function reduce( elem,
size, border, margin ) {
158 $.each( side,
function() {
159 size -= parseFloat( $.css( elem,
"padding" +
this ) ) || 0;
161 size -= parseFloat( $.css( elem,
"border" +
this +
"Width" ) ) || 0;
164 size -= parseFloat( $.css( elem,
"margin" +
this ) ) || 0;
170 $.fn[
"inner" +
name ] =
function(
size ) {
172 return orig[
"inner" +
name ].call(
this );
175 return this.
each(
function() {
176 $( this ).css( type, reduce(
this,
size ) +
"px" );
180 $.fn[
"outer" +
name] =
function(
size, margin ) {
181 if ( typeof
size !==
"number" ) {
182 return orig[
"outer" +
name ].call(
this,
size );
185 return this.
each(
function() {
186 $(
this).css( type, reduce(
this,
size,
true, margin ) +
"px" );
193 if ( !$.fn.addBack ) {
194 $.fn.addBack =
function( selector ) {
195 return this.add( selector == null ?
196 this.prevObject : this.prevObject.filter( selector )
202 if ( $(
"<a>" ).data(
"a-b",
"a" ).removeData(
"a-b" ).data(
"a-b" ) ) {
203 $.fn.removeData = (
function( removeData ) {
204 return function( key ) {
205 if ( arguments.length ) {
206 return removeData.call(
this, $.camelCase( key ) );
208 return removeData.call(
this );
211 })( $.fn.removeData );
215 $.ui.ie = !!/msie [
\w.]+/.exec( navigator.userAgent.toLowerCase() );
218 focus: (
function( orig ) {
219 return function( delay, fn ) {
220 return typeof delay ===
"number" ?
221 this.
each(
function() {
223 setTimeout(
function() {
230 orig.apply(
this, arguments );
234 disableSelection: (
function() {
235 var eventType =
"onselectstart" in document.createElement(
"div" ) ?
240 return this.bind( eventType +
".ui-disableSelection",
function( event ) {
241 event.preventDefault();
246 enableSelection:
function() {
247 return this.unbind(
".ui-disableSelection" );
250 zIndex:
function( zIndex ) {
252 return this.css(
"zIndex", zIndex );
256 var elem = $(
this[ 0 ] ), position, value;
257 while ( elem.length && elem[ 0 ] !== document ) {
261 position = elem.css(
"position" );
262 if ( position ===
"absolute" || position ===
"relative" || position ===
"fixed" ) {
267 value = parseInt( elem.css(
"zIndex" ), 10 );
268 if ( !isNaN( value ) && value !== 0 ) {
272 elem = elem.parent();
282 add:
function(
module, option, set ) {
284 proto = $.ui[
module ].prototype;
286 proto.plugins[ i ] = proto.plugins[ i ] || [];
287 proto.plugins[ i ].push( [ option,
set[ i ] ] );
290 call:
function( instance,
name, args, allowDisconnected ) {
292 set = instance.plugins[
name ];
298 if ( !allowDisconnected && ( !instance.element[ 0 ].parentNode || instance.element[ 0 ].parentNode.nodeType === 11 ) ) {
302 for ( i = 0; i <
set.length; i++ ) {
303 if ( instance.options[
set[ i ][ 0 ] ] ) {
304 set[ i ][ 1 ].apply( instance.element, args );
324 widget_slice = Array.prototype.slice;
326 $.cleanData = (
function( orig ) {
327 return function( elems ) {
329 for ( i = 0; (elem = elems[i]) != null; i++ ) {
333 events = $._data( elem,
"events" );
334 if ( events && events.remove ) {
335 $( elem ).triggerHandler(
"remove" );
346 var fullName, existingConstructor, constructor, basePrototype,
349 proxiedPrototype = {},
350 namespace = name.split( "." )[ 0 ];
352 name = name.split(
"." )[ 1 ];
353 fullName =
namespace + "-" + name;
361 $.expr[
":" ][ fullName.toLowerCase() ] =
function( elem ) {
362 return !!$.data( elem, fullName );
365 $[ namespace ] = $[ namespace ] || {};
366 existingConstructor = $[ namespace ][
name ];
367 constructor = $[ namespace ][
name ] =
function( options, element ) {
369 if ( !this._createWidget ) {
370 return new constructor( options, element );
375 if ( arguments.length ) {
376 this._createWidget( options, element );
380 $.extend( constructor, existingConstructor, {
387 _childConstructors: []
390 basePrototype =
new base();
394 basePrototype.options = $.widget.extend( {}, basePrototype.options );
395 $.each(
prototype,
function( prop, value ) {
396 if ( !$.isFunction( value ) ) {
397 proxiedPrototype[ prop ] = value;
400 proxiedPrototype[ prop ] = (
function() {
401 var _super =
function() {
402 return base.prototype[ prop ].apply(
this, arguments );
404 _superApply =
function( args ) {
405 return base.prototype[ prop ].apply(
this, args );
408 var
__super = this._super,
409 __superApply = this._superApply,
412 this._super = _super;
413 this._superApply = _superApply;
415 returnValue = value.apply(
this, arguments );
417 this._super =
__super;
418 this._superApply = __superApply;
424 constructor.prototype = $.widget.extend( basePrototype, {
428 widgetEventPrefix: existingConstructor ? (basePrototype.widgetEventPrefix ||
name) : name
429 }, proxiedPrototype, {
430 constructor: constructor,
431 namespace:
namespace,
433 widgetFullName: fullName
440 if ( existingConstructor ) {
441 $.each( existingConstructor._childConstructors,
function( i, child ) {
442 var childPrototype = child.prototype;
446 $.widget( childPrototype.namespace +
"." + childPrototype.widgetName, constructor, child._proto );
450 delete existingConstructor._childConstructors;
452 base._childConstructors.push( constructor );
455 $.widget.bridge( name, constructor );
460 $.widget.extend =
function( target ) {
461 var input = widget_slice.call( arguments, 1 ),
463 inputLength = input.length,
466 for ( ; inputIndex < inputLength; inputIndex++ ) {
467 for ( key in input[ inputIndex ] ) {
468 value = input[ inputIndex ][ key ];
469 if ( input[ inputIndex ].hasOwnProperty( key ) && value !==
undefined ) {
471 if ( $.isPlainObject( value ) ) {
472 target[ key ] = $.isPlainObject( target[ key ] ) ?
473 $.widget.extend( {}, target[ key ], value ) :
475 $.widget.extend( {}, value );
478 target[ key ] = value;
487 var fullName =
object.prototype.widgetFullName ||
name;
488 $.fn[
name ] =
function( options ) {
489 var isMethodCall = typeof options ===
"string",
490 args = widget_slice.call( arguments, 1 ),
494 options = !isMethodCall && args.length ?
495 $.widget.extend.apply( null, [ options ].concat(args) ) :
498 if ( isMethodCall ) {
499 this.
each(
function() {
501 instance = $.data(
this, fullName );
502 if ( options ===
"instance" ) {
503 returnValue = instance;
507 return $.error(
"cannot call methods on " + name +
" prior to initialization; " +
508 "attempted to call method '" + options +
"'" );
510 if ( !$.isFunction( instance[options] ) || options.charAt( 0 ) ===
"_" ) {
511 return $.error(
"no such method '" + options +
"' for " + name +
" widget instance" );
513 methodValue = instance[ options ].apply( instance, args );
514 if ( methodValue !== instance && methodValue !==
undefined ) {
515 returnValue = methodValue && methodValue.jquery ?
516 returnValue.pushStack( methodValue.get() ) :
522 this.
each(
function() {
523 var instance = $.data(
this, fullName );
525 instance.option( options || {} );
526 if ( instance._init ) {
530 $.data(
this, fullName,
new object( options,
this ) );
539 $.Widget =
function( ) {};
540 $.Widget._childConstructors = [];
542 $.Widget.prototype = {
543 widgetName:
"widget",
544 widgetEventPrefix:
"",
545 defaultElement:
"<div>",
552 _createWidget:
function( options, element ) {
553 element = $( element || this.defaultElement || this )[ 0 ];
554 this.element = $( element );
555 this.uuid = widget_uuid++;
556 this.eventNamespace =
"." + this.widgetName + this.uuid;
559 this.hoverable = $();
560 this.focusable = $();
562 if ( element !==
this ) {
563 $.data( element, this.widgetFullName,
this );
564 this._on(
true, this.element, {
565 remove:
function( event ) {
566 if ( event.target === element ) {
571 this.document = $( element.style ?
573 element.ownerDocument :
575 element.document || element );
576 this.
window = $( this.document[0].defaultView || this.document[0].parentWindow );
579 this.options = $.widget.extend( {},
581 this._getCreateOptions(),
585 this._trigger(
"create", null, this._getCreateEventData() );
588 _getCreateOptions: $.noop,
589 _getCreateEventData: $.noop,
593 destroy:
function() {
598 .unbind( this.eventNamespace )
599 .removeData( this.widgetFullName )
602 .removeData( $.camelCase( this.widgetFullName ) );
604 .unbind( this.eventNamespace )
605 .removeAttr(
"aria-disabled" )
607 this.widgetFullName +
"-disabled " +
608 "ui-state-disabled" );
611 this.bindings.unbind( this.eventNamespace );
612 this.hoverable.removeClass(
"ui-state-hover" );
613 this.focusable.removeClass(
"ui-state-focus" );
621 option:
function( key, value ) {
627 if ( arguments.length === 0 ) {
629 return $.widget.extend( {}, this.options );
632 if ( typeof key ===
"string" ) {
635 parts = key.split(
"." );
637 if ( parts.length ) {
638 curOption = options[ key ] = $.widget.extend( {}, this.options[ key ] );
639 for ( i = 0; i < parts.length - 1; i++ ) {
640 curOption[ parts[ i ] ] = curOption[ parts[ i ] ] || {};
641 curOption = curOption[ parts[ i ] ];
644 if ( arguments.length === 1 ) {
645 return curOption[ key ] ===
undefined ? null : curOption[ key ];
647 curOption[ key ] = value;
649 if ( arguments.length === 1 ) {
650 return this.options[ key ] ===
undefined ? null : this.options[ key ];
652 options[ key ] = value;
656 this._setOptions( options );
660 _setOptions:
function( options ) {
663 for ( key in options ) {
664 this._setOption( key, options[ key ] );
669 _setOption:
function( key, value ) {
670 this.options[ key ] = value;
672 if ( key ===
"disabled" ) {
674 .toggleClass( this.widgetFullName +
"-disabled", !!value );
678 this.hoverable.removeClass(
"ui-state-hover" );
679 this.focusable.removeClass(
"ui-state-focus" );
687 return this._setOptions({ disabled:
false });
689 disable:
function() {
690 return this._setOptions({ disabled:
true });
693 _on:
function( suppressDisabledCheck, element, handlers ) {
698 if ( typeof suppressDisabledCheck !==
"boolean" ) {
700 element = suppressDisabledCheck;
701 suppressDisabledCheck =
false;
707 element = this.element;
708 delegateElement = this.widget();
710 element = delegateElement = $( element );
711 this.bindings = this.bindings.add( element );
714 $.each( handlers,
function( event, handler ) {
715 function handlerProxy() {
719 if ( !suppressDisabledCheck &&
720 ( instance.options.disabled ===
true ||
721 $(
this ).hasClass(
"ui-state-disabled" ) ) ) {
724 return ( typeof handler ===
"string" ? instance[ handler ] : handler )
725 .apply( instance, arguments );
729 if ( typeof handler !==
"string" ) {
730 handlerProxy.guid = handler.guid =
731 handler.guid || handlerProxy.guid || $.guid++;
734 var match =
event.match( /^([\
w:-]*)\
s*(.*)$/ ),
735 eventName = match[1] + instance.eventNamespace,
738 delegateElement.delegate( selector, eventName, handlerProxy );
740 element.bind( eventName, handlerProxy );
745 _off:
function( element, eventName ) {
746 eventName = (eventName ||
"").split(
" " ).join( this.eventNamespace +
" " ) +
748 element.unbind( eventName ).undelegate( eventName );
751 this.bindings = $( this.bindings.not( element ).get() );
752 this.focusable = $( this.focusable.not( element ).get() );
753 this.hoverable = $( this.hoverable.not( element ).get() );
756 _delay:
function( handler, delay ) {
757 function handlerProxy() {
758 return ( typeof handler ===
"string" ? instance[ handler ] : handler )
759 .apply( instance, arguments );
762 return setTimeout( handlerProxy, delay || 0 );
765 _hoverable:
function( element ) {
766 this.hoverable = this.hoverable.add( element );
768 mouseenter:
function( event ) {
769 $(
event.currentTarget ).
addClass(
"ui-state-hover" );
771 mouseleave:
function( event ) {
772 $(
event.currentTarget ).removeClass(
"ui-state-hover" );
777 _focusable:
function( element ) {
778 this.focusable = this.focusable.add( element );
780 focusin:
function( event ) {
781 $(
event.currentTarget ).
addClass(
"ui-state-focus" );
783 focusout:
function( event ) {
784 $(
event.currentTarget ).removeClass(
"ui-state-focus" );
789 _trigger:
function( type, event, data ) {
791 callback = this.options[ type ];
794 event = $.Event( event );
795 event.type = ( type === this.widgetEventPrefix ?
797 this.widgetEventPrefix + type ).toLowerCase();
800 event.target = this.element[ 0 ];
803 orig =
event.originalEvent;
805 for ( prop in orig ) {
806 if ( !( prop in event ) ) {
807 event[ prop ] = orig[ prop ];
812 this.element.trigger( event, data );
813 return !( $.isFunction( callback ) &&
814 callback.apply( this.element[0], [ event ].concat( data ) ) ===
false ||
815 event.isDefaultPrevented() );
819 $.each( { show:
"fadeIn", hide:
"fadeOut" },
function( method, defaultEffect ) {
820 $.Widget.prototype[
"_" + method ] =
function( element, options, callback ) {
821 if ( typeof options ===
"string" ) {
822 options = {
effect: options };
825 effectName = !options ?
827 options ===
true || typeof options ===
"number" ?
829 options.
effect || defaultEffect;
830 options = options || {};
831 if ( typeof options ===
"number" ) {
832 options = { duration: options };
834 hasOptions = !$.isEmptyObject( options );
835 options.complete = callback;
836 if ( options.delay ) {
837 element.delay( options.delay );
839 if ( hasOptions && $.effects && $.effects.effect[ effectName ] ) {
840 element[ method ]( options );
841 }
else if ( effectName !== method && element[ effectName ] ) {
842 element[ effectName ]( options.duration, options.easing, callback );
844 element.queue(
function( next ) {
845 $( this )[ method ]();
847 callback.call( element[ 0 ] );
855 var widget = $.widget;
870 var mouseHandled =
false;
871 $( document ).mouseup(
function() {
872 mouseHandled =
false;
875 var mouse = $.widget(
"ui.mouse", {
878 cancel:
"input,textarea,button,select,option",
882 _mouseInit:
function() {
886 .bind(
"mousedown." + this.widgetName,
function(event) {
887 return that._mouseDown(event);
889 .bind(
"click." + this.widgetName,
function(event) {
890 if (
true === $.data(event.target, that.widgetName +
".preventClickEvent")) {
891 $.removeData(event.target, that.widgetName +
".preventClickEvent");
892 event.stopImmediatePropagation();
897 this.started =
false;
902 _mouseDestroy:
function() {
903 this.element.unbind(
"." + this.widgetName);
904 if ( this._mouseMoveDelegate ) {
906 .unbind(
"mousemove." + this.widgetName, this._mouseMoveDelegate)
907 .unbind(
"mouseup." + this.widgetName, this._mouseUpDelegate);
911 _mouseDown:
function(event) {
913 if ( mouseHandled ) {
917 this._mouseMoved =
false;
920 (this._mouseStarted && this._mouseUp(event));
922 this._mouseDownEvent = event;
925 btnIsLeft = (
event.which === 1),
928 elIsCancel = (typeof this.options.cancel ===
"string" && event.target.nodeName ? $(event.target).closest(this.options.cancel).length :
false);
929 if (!btnIsLeft || elIsCancel || !this._mouseCapture(event)) {
933 this.mouseDelayMet = !this.options.delay;
934 if (!this.mouseDelayMet) {
935 this._mouseDelayTimer = setTimeout(
function() {
936 that.mouseDelayMet =
true;
937 }, this.options.delay);
940 if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
941 this._mouseStarted = (this._mouseStart(event) !==
false);
942 if (!this._mouseStarted) {
943 event.preventDefault();
949 if (
true === $.data(event.target,
this.widgetName +
".preventClickEvent")) {
950 $.removeData(event.target,
this.widgetName +
".preventClickEvent");
954 this._mouseMoveDelegate =
function(event) {
955 return that._mouseMove(event);
957 this._mouseUpDelegate =
function(event) {
958 return that._mouseUp(event);
962 .bind(
"mousemove." + this.widgetName, this._mouseMoveDelegate )
963 .bind(
"mouseup." + this.widgetName, this._mouseUpDelegate );
965 event.preventDefault();
971 _mouseMove:
function(event) {
976 if ( this._mouseMoved ) {
978 if ($.ui.ie && ( !document.documentMode || document.documentMode < 9 ) && !
event.button) {
979 return this._mouseUp(event);
982 }
else if ( !event.which ) {
983 return this._mouseUp( event );
987 if ( event.which || event.button ) {
988 this._mouseMoved =
true;
991 if (this._mouseStarted) {
992 this._mouseDrag(event);
993 return event.preventDefault();
996 if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
998 (this._mouseStart(this._mouseDownEvent, event) !==
false);
999 (this._mouseStarted ? this._mouseDrag(event) : this._mouseUp(event));
1002 return !this._mouseStarted;
1005 _mouseUp:
function(event) {
1007 .unbind(
"mousemove." + this.widgetName, this._mouseMoveDelegate )
1008 .unbind(
"mouseup." + this.widgetName, this._mouseUpDelegate );
1010 if (this._mouseStarted) {
1011 this._mouseStarted =
false;
1013 if (event.target ===
this._mouseDownEvent.target) {
1014 $.data(event.target,
this.widgetName +
".preventClickEvent",
true);
1017 this._mouseStop(event);
1020 mouseHandled =
false;
1024 _mouseDistanceMet:
function(event) {
1026 Math.abs(
this._mouseDownEvent.pageX - event.pageX),
1027 Math.abs(this._mouseDownEvent.pageY - event.pageY)
1028 ) >= this.options.distance
1032 _mouseDelayMet:
function() {
1033 return this.mouseDelayMet;
1037 _mouseStart:
function() {},
1038 _mouseDrag:
function() {},
1039 _mouseStop:
function() {},
1040 _mouseCapture:
function() {
return true; }
1059 var cachedScrollbarWidth, supportsOffsetFractions,
1063 rhorizontal = /left|center|right/,
1064 rvertical = /top|center|bottom/,
1065 roffset = /[\+\-]
\d+(\.[
\d]+)?%?/,
1068 _position = $.fn.position;
1072 parseFloat( offsets[ 0 ] ) * ( rpercent.test( offsets[ 0 ] ) ?
width / 100 : 1 ),
1073 parseFloat( offsets[ 1 ] ) * ( rpercent.test( offsets[ 1 ] ) ?
height / 100 : 1 )
1077 function parseCss( element, property ) {
1078 return parseInt( $.css( element, property ), 10 ) || 0;
1081 function getDimensions( elem ) {
1083 if ( raw.nodeType === 9 ) {
1085 width: elem.width(),
1087 offset: { top: 0, left: 0 }
1090 if ( $.isWindow( raw ) ) {
1092 width: elem.width(),
1094 offset: { top: elem.scrollTop(), left: elem.scrollLeft() }
1097 if ( raw.preventDefault ) {
1101 offset: { top: raw.pageY, left: raw.pageX }
1105 width: elem.outerWidth(),
1106 height: elem.outerHeight(),
1112 scrollbarWidth:
function() {
1113 if ( cachedScrollbarWidth !==
undefined ) {
1114 return cachedScrollbarWidth;
1117 div = $(
"<div style='display:block;position:absolute;width:50px;height:50px;overflow:hidden;'><div style='height:100px;width:auto;'></div></div>" ),
1118 innerDiv = div.children()[0];
1120 $(
"body" ).append( div );
1121 w1 = innerDiv.offsetWidth;
1122 div.css(
"overflow",
"scroll" );
1124 w2 = innerDiv.offsetWidth;
1127 w2 = div[0].clientWidth;
1132 return (cachedScrollbarWidth = w1 - w2);
1134 getScrollInfo:
function( within ) {
1135 var overflowX = within.isWindow || within.isDocument ?
"" :
1136 within.element.css(
"overflow-x" ),
1137 overflowY = within.isWindow || within.isDocument ?
"" :
1138 within.element.css(
"overflow-y" ),
1139 hasOverflowX = overflowX ===
"scroll" ||
1140 ( overflowX ===
"auto" && within.width < within.element[0].scrollWidth ),
1141 hasOverflowY = overflowY ===
"scroll" ||
1142 ( overflowY ===
"auto" && within.height < within.element[0].scrollHeight );
1144 width: hasOverflowY ? $.position.scrollbarWidth() : 0,
1145 height: hasOverflowX ? $.position.scrollbarWidth() : 0
1148 getWithinInfo:
function( element ) {
1149 var withinElement = $( element ||
window ),
1150 isWindow = $.isWindow( withinElement[0] ),
1151 isDocument = !!withinElement[ 0 ] && withinElement[ 0 ].nodeType === 9;
1153 element: withinElement,
1155 isDocument: isDocument,
1156 offset: withinElement.offset() || { left: 0, top: 0 },
1157 scrollLeft: withinElement.scrollLeft(),
1162 width: isWindow || isDocument ? withinElement.width() : withinElement.outerWidth(),
1163 height: isWindow || isDocument ? withinElement.height() : withinElement.outerHeight()
1168 $.fn.position =
function( options ) {
1169 if ( !options || !options.of ) {
1170 return _position.apply(
this, arguments );
1174 options = $.extend( {}, options );
1176 var atOffset, targetWidth, targetHeight, targetOffset, basePosition, dimensions,
1177 target = $( options.of ),
1178 within = $.position.getWithinInfo( options.within ),
1179 scrollInfo = $.position.getScrollInfo( within ),
1180 collision = ( options.collision ||
"flip" ).split(
" " ),
1183 dimensions = getDimensions( target );
1184 if ( target[0].preventDefault ) {
1186 options.at =
"left top";
1188 targetWidth = dimensions.width;
1189 targetHeight = dimensions.height;
1190 targetOffset = dimensions.offset;
1192 basePosition = $.extend( {}, targetOffset );
1196 $.each( [
"my",
"at" ],
function() {
1197 var pos = ( options[ this ] ||
"" ).split(
" " ),
1201 if ( pos.length === 1) {
1202 pos = rhorizontal.test( pos[ 0 ] ) ?
1203 pos.concat( [
"center" ] ) :
1204 rvertical.test( pos[ 0 ] ) ?
1205 [
"center" ].concat( pos ) :
1206 [
"center",
"center" ];
1208 pos[ 0 ] = rhorizontal.test( pos[ 0 ] ) ? pos[ 0 ] :
"center";
1209 pos[ 1 ] = rvertical.test( pos[ 1 ] ) ? pos[ 1 ] :
"center";
1212 horizontalOffset = roffset.exec( pos[ 0 ] );
1213 verticalOffset = roffset.exec( pos[ 1 ] );
1215 horizontalOffset ? horizontalOffset[ 0 ] : 0,
1216 verticalOffset ? verticalOffset[ 0 ] : 0
1221 rposition.exec( pos[ 0 ] )[ 0 ],
1222 rposition.exec( pos[ 1 ] )[ 0 ]
1227 if ( collision.length === 1 ) {
1228 collision[ 1 ] = collision[ 0 ];
1231 if ( options.at[ 0 ] ===
"right" ) {
1232 basePosition.left += targetWidth;
1233 }
else if ( options.at[ 0 ] ===
"center" ) {
1234 basePosition.left += targetWidth / 2;
1237 if ( options.at[ 1 ] ===
"bottom" ) {
1238 basePosition.top += targetHeight;
1239 }
else if ( options.at[ 1 ] ===
"center" ) {
1240 basePosition.top += targetHeight / 2;
1243 atOffset = getOffsets( offsets.at, targetWidth, targetHeight );
1244 basePosition.left += atOffset[ 0 ];
1245 basePosition.top += atOffset[ 1 ];
1247 return this.
each(
function() {
1248 var collisionPosition,
using,
1250 elemWidth = elem.outerWidth(),
1251 elemHeight = elem.outerHeight(),
1252 marginLeft = parseCss(
this,
"marginLeft" ),
1253 marginTop = parseCss(
this,
"marginTop" ),
1254 collisionWidth = elemWidth + marginLeft + parseCss(
this,
"marginRight" ) + scrollInfo.width,
1255 collisionHeight = elemHeight + marginTop + parseCss(
this,
"marginBottom" ) + scrollInfo.height,
1256 position = $.extend( {}, basePosition ),
1257 myOffset = getOffsets( offsets.my, elem.outerWidth(), elem.outerHeight() );
1259 if ( options.my[ 0 ] ===
"right" ) {
1260 position.left -= elemWidth;
1261 }
else if ( options.my[ 0 ] ===
"center" ) {
1262 position.left -= elemWidth / 2;
1265 if ( options.my[ 1 ] ===
"bottom" ) {
1266 position.top -= elemHeight;
1267 }
else if ( options.my[ 1 ] ===
"center" ) {
1268 position.top -= elemHeight / 2;
1271 position.left += myOffset[ 0 ];
1272 position.top += myOffset[ 1 ];
1275 if ( !supportsOffsetFractions ) {
1276 position.left = round( position.left );
1277 position.top = round( position.top );
1280 collisionPosition = {
1281 marginLeft: marginLeft,
1282 marginTop: marginTop
1285 $.each( [
"left",
"top" ],
function( i, dir ) {
1286 if ( $.ui.position[ collision[ i ] ] ) {
1287 $.ui.position[ collision[ i ] ][ dir ]( position, {
1288 targetWidth: targetWidth,
1289 targetHeight: targetHeight,
1290 elemWidth: elemWidth,
1291 elemHeight: elemHeight,
1292 collisionPosition: collisionPosition,
1293 collisionWidth: collisionWidth,
1294 collisionHeight: collisionHeight,
1295 offset: [ atOffset[ 0 ] + myOffset[ 0 ], atOffset [ 1 ] + myOffset[ 1 ] ],
1304 if ( options.using ) {
1306 using =
function(
props ) {
1307 var left = targetOffset.left - position.left,
1308 right = left + targetWidth - elemWidth,
1309 top = targetOffset.top - position.top,
1310 bottom = top + targetHeight - elemHeight,
1314 left: targetOffset.left,
1315 top: targetOffset.top,
1321 left: position.left,
1326 horizontal: right < 0 ?
"left" : left > 0 ?
"right" :
"center",
1327 vertical: bottom < 0 ?
"top" : top > 0 ?
"bottom" :
"middle" 1329 if ( targetWidth < elemWidth && abs( left + right ) < targetWidth ) {
1330 feedback.horizontal =
"center";
1332 if ( targetHeight < elemHeight && abs( top + bottom ) < targetHeight ) {
1333 feedback.vertical =
"middle";
1335 if ( max( abs( left ), abs( right ) ) > max( abs( top ), abs( bottom ) ) ) {
1336 feedback.important =
"horizontal";
1338 feedback.important =
"vertical";
1340 options.using.call(
this,
props, feedback );
1344 elem.offset( $.
extend( position, {
using:
using } ) );
1350 left:
function( position, data ) {
1351 var within = data.within,
1352 withinOffset = within.isWindow ? within.scrollLeft : within.offset.left,
1353 outerWidth = within.width,
1354 collisionPosLeft = position.left - data.collisionPosition.marginLeft,
1355 overLeft = withinOffset - collisionPosLeft,
1356 overRight = collisionPosLeft + data.collisionWidth - outerWidth - withinOffset,
1360 if ( data.collisionWidth > outerWidth ) {
1362 if ( overLeft > 0 && overRight <= 0 ) {
1363 newOverRight = position.left + overLeft + data.collisionWidth - outerWidth - withinOffset;
1364 position.left += overLeft - newOverRight;
1366 }
else if ( overRight > 0 && overLeft <= 0 ) {
1367 position.left = withinOffset;
1370 if ( overLeft > overRight ) {
1371 position.left = withinOffset + outerWidth - data.collisionWidth;
1373 position.left = withinOffset;
1377 }
else if ( overLeft > 0 ) {
1378 position.left += overLeft;
1380 }
else if ( overRight > 0 ) {
1381 position.left -= overRight;
1384 position.left = max( position.left - collisionPosLeft, position.left );
1387 top:
function( position, data ) {
1388 var within = data.within,
1389 withinOffset = within.isWindow ? within.scrollTop : within.offset.top,
1390 outerHeight = data.within.height,
1391 collisionPosTop = position.top - data.collisionPosition.marginTop,
1392 overTop = withinOffset - collisionPosTop,
1393 overBottom = collisionPosTop + data.collisionHeight - outerHeight - withinOffset,
1397 if ( data.collisionHeight > outerHeight ) {
1399 if ( overTop > 0 && overBottom <= 0 ) {
1400 newOverBottom = position.top + overTop + data.collisionHeight - outerHeight - withinOffset;
1401 position.top += overTop - newOverBottom;
1403 }
else if ( overBottom > 0 && overTop <= 0 ) {
1404 position.top = withinOffset;
1407 if ( overTop > overBottom ) {
1408 position.top = withinOffset + outerHeight - data.collisionHeight;
1410 position.top = withinOffset;
1414 }
else if ( overTop > 0 ) {
1415 position.top += overTop;
1417 }
else if ( overBottom > 0 ) {
1418 position.top -= overBottom;
1421 position.top = max( position.top - collisionPosTop, position.top );
1426 left:
function( position, data ) {
1427 var within = data.within,
1428 withinOffset = within.offset.left + within.scrollLeft,
1429 outerWidth = within.width,
1430 offsetLeft = within.isWindow ? within.scrollLeft : within.offset.left,
1431 collisionPosLeft = position.left - data.collisionPosition.marginLeft,
1432 overLeft = collisionPosLeft - offsetLeft,
1433 overRight = collisionPosLeft + data.collisionWidth - outerWidth - offsetLeft,
1434 myOffset = data.my[ 0 ] ===
"left" ?
1436 data.my[ 0 ] ===
"right" ?
1439 atOffset = data.at[ 0 ] ===
"left" ?
1441 data.at[ 0 ] ===
"right" ?
1444 offset = -2 * data.offset[ 0 ],
1448 if ( overLeft < 0 ) {
1449 newOverRight = position.left + myOffset + atOffset +
offset + data.collisionWidth - outerWidth - withinOffset;
1450 if ( newOverRight < 0 || newOverRight < abs( overLeft ) ) {
1451 position.left += myOffset + atOffset +
offset;
1453 }
else if ( overRight > 0 ) {
1454 newOverLeft = position.left - data.collisionPosition.marginLeft + myOffset + atOffset +
offset - offsetLeft;
1455 if ( newOverLeft > 0 || abs( newOverLeft ) < overRight ) {
1456 position.left += myOffset + atOffset +
offset;
1460 top:
function( position, data ) {
1461 var within = data.within,
1462 withinOffset = within.offset.top + within.scrollTop,
1463 outerHeight = within.height,
1464 offsetTop = within.isWindow ? within.scrollTop : within.offset.top,
1465 collisionPosTop = position.top - data.collisionPosition.marginTop,
1466 overTop = collisionPosTop - offsetTop,
1467 overBottom = collisionPosTop + data.collisionHeight - outerHeight - offsetTop,
1468 top = data.my[ 1 ] ===
"top",
1471 data.my[ 1 ] ===
"bottom" ?
1474 atOffset = data.at[ 1 ] ===
"top" ?
1476 data.at[ 1 ] ===
"bottom" ?
1477 -data.targetHeight :
1479 offset = -2 * data.offset[ 1 ],
1482 if ( overTop < 0 ) {
1483 newOverBottom = position.top + myOffset + atOffset +
offset + data.collisionHeight - outerHeight - withinOffset;
1484 if ( ( position.top + myOffset + atOffset +
offset) > overTop && ( newOverBottom < 0 || newOverBottom < abs( overTop ) ) ) {
1485 position.top += myOffset + atOffset +
offset;
1487 }
else if ( overBottom > 0 ) {
1488 newOverTop = position.top - data.collisionPosition.marginTop + myOffset + atOffset +
offset - offsetTop;
1489 if ( ( position.top + myOffset + atOffset +
offset) > overBottom && ( newOverTop > 0 || abs( newOverTop ) < overBottom ) ) {
1490 position.top += myOffset + atOffset +
offset;
1497 $.ui.position.flip.left.apply(
this, arguments );
1498 $.ui.position.fit.left.apply(
this, arguments );
1501 $.ui.position.flip.top.apply(
this, arguments );
1502 $.ui.position.fit.top.apply(
this, arguments );
1509 var testElement, testElementParent, testElementStyle, offsetLeft, i,
1510 body = document.getElementsByTagName(
"body" )[ 0 ],
1511 div = document.createElement(
"div" );
1514 testElement = document.createElement( body ?
"div" :
"body" );
1515 testElementStyle = {
1516 visibility:
"hidden",
1524 $.extend( testElementStyle, {
1525 position:
"absolute",
1530 for ( i in testElementStyle ) {
1531 testElement.style[ i ] = testElementStyle[ i ];
1533 testElement.appendChild( div );
1534 testElementParent = body || document.documentElement;
1535 testElementParent.insertBefore( testElement, testElementParent.firstChild );
1537 div.style.cssText =
"position: absolute; left: 10.7432222px;";
1539 offsetLeft = $( div ).
offset().left;
1540 supportsOffsetFractions = offsetLeft > 10 && offsetLeft < 11;
1542 testElement.innerHTML =
"";
1543 testElementParent.removeChild( testElement );
1548 var position = $.ui.position;
1563 $.widget(
"ui.draggable", $.ui.mouse, {
1565 widgetEventPrefix:
"drag",
1570 connectToSortable: false,
1579 refreshPositions: false,
1581 revertDuration: 500,
1584 scrollSensitivity: 20,
1597 _create:
function() {
1599 if ( this.options.helper ===
"original" ) {
1600 this._setPositionRelative();
1602 if (this.options.addClasses){
1603 this.element.addClass(
"ui-draggable");
1605 if (this.options.disabled){
1606 this.element.addClass(
"ui-draggable-disabled");
1608 this._setHandleClassName();
1613 _setOption:
function( key, value ) {
1614 this._super( key, value );
1615 if ( key ===
"handle" ) {
1616 this._removeHandleClassName();
1617 this._setHandleClassName();
1621 _destroy:
function() {
1622 if ( ( this.helper || this.element ).is(
".ui-draggable-dragging" ) ) {
1623 this.destroyOnClear =
true;
1626 this.element.removeClass(
"ui-draggable ui-draggable-dragging ui-draggable-disabled" );
1627 this._removeHandleClassName();
1628 this._mouseDestroy();
1631 _mouseCapture:
function(event) {
1632 var o = this.options;
1634 this._blurActiveElement( event );
1637 if (this.helper || o.disabled || $(event.target).closest(
".ui-resizable-handle").length > 0) {
1642 this.handle = this._getHandle(event);
1647 this._blockFrames( o.iframeFix ===
true ?
"iframe" : o.iframeFix );
1653 _blockFrames:
function( selector ) {
1654 this.iframeBlocks = this.document.find( selector ).map(
function() {
1655 var iframe = $( this );
1658 .css(
"position",
"absolute" )
1659 .appendTo( iframe.parent() )
1660 .outerWidth( iframe.outerWidth() )
1661 .outerHeight( iframe.outerHeight() )
1662 .
offset( iframe.offset() )[ 0 ];
1666 _unblockFrames:
function() {
1667 if ( this.iframeBlocks ) {
1668 this.iframeBlocks.remove();
1669 delete this.iframeBlocks;
1673 _blurActiveElement:
function( event ) {
1674 var document = this.document[ 0 ];
1677 if ( !this.handleElement.is( event.target ) ) {
1687 if ( document.activeElement && document.activeElement.nodeName.toLowerCase() !==
"body" ) {
1690 $( document.activeElement ).blur();
1692 }
catch ( error ) {}
1695 _mouseStart:
function(event) {
1697 var o = this.options;
1700 this.helper = this._createHelper(event);
1702 this.helper.addClass(
"ui-draggable-dragging");
1705 this._cacheHelperProportions();
1708 if ($.ui.ddmanager) {
1709 $.ui.ddmanager.current =
this;
1718 this._cacheMargins();
1721 this.cssPosition = this.helper.css(
"position" );
1722 this.scrollParent = this.helper.scrollParent(
true );
1723 this.offsetParent = this.helper.offsetParent();
1724 this.hasFixedAncestor = this.helper.parents().filter(
function() {
1725 return $( this ).css(
"position" ) ===
"fixed";
1729 this.positionAbs = this.element.offset();
1730 this._refreshOffsets( event );
1733 this.originalPosition = this.position = this._generatePosition( event,
false );
1734 this.originalPageX =
event.pageX;
1735 this.originalPageY =
event.pageY;
1738 (o.cursorAt && this._adjustOffsetFromHelper(o.cursorAt));
1741 this._setContainment();
1744 if (this._trigger(
"start", event) ===
false) {
1750 this._cacheHelperProportions();
1753 if ($.ui.ddmanager && !o.dropBehaviour) {
1754 $.ui.ddmanager.prepareOffsets(
this, event);
1759 this._normalizeRightBottom();
1761 this._mouseDrag(event,
true);
1764 if ( $.ui.ddmanager ) {
1765 $.ui.ddmanager.dragStart(
this, event);
1771 _refreshOffsets:
function( event ) {
1773 top: this.positionAbs.top - this.margins.top,
1774 left: this.positionAbs.left - this.margins.left,
1776 parent: this._getParentOffset(),
1777 relative: this._getRelativeOffset()
1781 left:
event.pageX - this.
offset.left,
1782 top:
event.pageY - this.
offset.top
1786 _mouseDrag:
function(event, noPropagation) {
1788 if ( this.hasFixedAncestor ) {
1789 this.
offset.parent = this._getParentOffset();
1793 this.position = this._generatePosition( event,
true );
1794 this.positionAbs = this._convertPositionTo(
"absolute");
1797 if (!noPropagation) {
1798 var ui = this._uiHash();
1799 if (this._trigger(
"drag", event, ui) ===
false) {
1803 this.position = ui.position;
1806 this.helper[ 0 ].style.left = this.position.left +
"px";
1807 this.helper[ 0 ].style.top = this.position.top +
"px";
1809 if ($.ui.ddmanager) {
1810 $.ui.ddmanager.drag(
this, event);
1816 _mouseStop:
function(event) {
1821 if ($.ui.ddmanager && !
this.options.dropBehaviour) {
1822 dropped = $.ui.ddmanager.drop(
this, event);
1827 dropped = this.dropped;
1828 this.dropped =
false;
1831 if ((this.options.revert ===
"invalid" && !dropped) || (
this.options.revert ===
"valid" && dropped) ||
this.options.revert ===
true || ($.isFunction(
this.options.revert) && this.options.revert.call(this.element, dropped))) {
1832 $(this.helper).animate(this.originalPosition, parseInt(this.options.revertDuration, 10),
function() {
1833 if (that._trigger(
"stop", event) !==
false) {
1838 if (this._trigger(
"stop", event) !==
false) {
1846 _mouseUp:
function( event ) {
1847 this._unblockFrames();
1850 if ( $.ui.ddmanager ) {
1851 $.ui.ddmanager.dragStop(
this, event);
1855 if ( this.handleElement.is( event.target ) ) {
1857 this.element.focus();
1860 return $.ui.mouse.prototype._mouseUp.call(
this, event);
1863 cancel:
function() {
1865 if (this.helper.is(
".ui-draggable-dragging")) {
1875 _getHandle:
function(event) {
1876 return this.options.handle ?
1877 !!$(
event.target ).closest( this.element.find(
this.options.handle ) ).length :
1881 _setHandleClassName:
function() {
1882 this.handleElement = this.options.handle ?
1883 this.element.find( this.options.handle ) : this.element;
1884 this.handleElement.addClass(
"ui-draggable-handle" );
1887 _removeHandleClassName:
function() {
1888 this.handleElement.removeClass(
"ui-draggable-handle" );
1891 _createHelper:
function(event) {
1893 var o = this.options,
1894 helperIsFunction = $.isFunction( o.helper ),
1895 helper = helperIsFunction ?
1896 $( o.helper.apply( this.element[ 0 ], [ event ] ) ) :
1897 ( o.helper ===
"clone" ?
1898 this.element.clone().removeAttr(
"id" ) :
1901 if (!helper.parents(
"body").length) {
1902 helper.appendTo((o.appendTo ===
"parent" ?
this.element[0].parentNode : o.appendTo));
1908 if ( helperIsFunction && helper[ 0 ] === this.element[ 0 ] ) {
1909 this._setPositionRelative();
1912 if (helper[0] !== this.element[0] && !(/(fixed|absolute)/).test(helper.css(
"position"))) {
1913 helper.css(
"position",
"absolute");
1920 _setPositionRelative:
function() {
1921 if ( !( /^(?:r|a|
f)/ ).test( this.element.css(
"position" ) ) ) {
1922 this.element[ 0 ].style.position =
"relative";
1926 _adjustOffsetFromHelper:
function(obj) {
1927 if (typeof obj ===
"string") {
1928 obj = obj.split(
" ");
1930 if ($.isArray(obj)) {
1931 obj = { left: +obj[0], top: +obj[1] || 0 };
1933 if (
"left" in obj) {
1934 this.
offset.click.left = obj.left + this.margins.left;
1936 if (
"right" in obj) {
1937 this.
offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
1940 this.
offset.click.top = obj.top + this.margins.top;
1942 if (
"bottom" in obj) {
1943 this.
offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
1947 _isRootNode:
function( element ) {
1948 return ( /(html|body)/i ).test( element.tagName ) || element === this.document[ 0 ];
1951 _getParentOffset:
function() {
1954 var po = this.offsetParent.offset(),
1955 document = this.document[ 0 ];
1961 if (this.cssPosition ===
"absolute" && this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) {
1962 po.left += this.scrollParent.scrollLeft();
1963 po.top += this.scrollParent.scrollTop();
1966 if ( this._isRootNode( this.offsetParent[ 0 ] ) ) {
1967 po = { top: 0, left: 0 };
1971 top: po.top + (parseInt(this.offsetParent.css(
"borderTopWidth"), 10) || 0),
1972 left: po.left + (parseInt(this.offsetParent.css(
"borderLeftWidth"), 10) || 0)
1977 _getRelativeOffset:
function() {
1978 if ( this.cssPosition !==
"relative" ) {
1979 return { top: 0, left: 0 };
1982 var p = this.element.position(),
1983 scrollIsRootNode = this._isRootNode( this.scrollParent[ 0 ] );
1986 top: p.top - ( parseInt(this.helper.css(
"top" ), 10) || 0 ) + ( !scrollIsRootNode ? this.scrollParent.scrollTop() : 0 ),
1987 left: p.left - ( parseInt(this.helper.css(
"left" ), 10) || 0 ) + ( !scrollIsRootNode ? this.scrollParent.scrollLeft() : 0 )
1992 _cacheMargins:
function() {
1994 left: (parseInt(this.element.css(
"marginLeft"), 10) || 0),
1995 top: (parseInt(this.element.css(
"marginTop"), 10) || 0),
1996 right: (parseInt(this.element.css(
"marginRight"), 10) || 0),
1997 bottom: (parseInt(this.element.css(
"marginBottom"), 10) || 0)
2001 _cacheHelperProportions:
function() {
2002 this.helperProportions = {
2003 width: this.helper.outerWidth(),
2004 height: this.helper.outerHeight()
2008 _setContainment:
function() {
2010 var isUserScrollable, c, ce,
2012 document = this.document[ 0 ];
2014 this.relativeContainer = null;
2016 if ( !o.containment ) {
2017 this.containment = null;
2021 if ( o.containment ===
"window" ) {
2022 this.containment = [
2025 $(
window ).scrollLeft() + $(
window ).
width() - this.helperProportions.width - this.margins.left,
2026 $(
window ).
scrollTop() + ( $(
window ).
height() || document.body.parentNode.scrollHeight ) - this.helperProportions.height -
this.margins.top
2031 if ( o.containment ===
"document") {
2032 this.containment = [
2035 $( document ).
width() - this.helperProportions.width - this.margins.left,
2036 ( $( document ).
height() || document.body.parentNode.scrollHeight ) - this.helperProportions.height -
this.margins.top
2041 if ( o.containment.constructor === Array ) {
2042 this.containment = o.containment;
2046 if ( o.containment ===
"parent" ) {
2047 o.containment = this.helper[ 0 ].parentNode;
2050 c = $( o.containment );
2057 isUserScrollable = /(scroll|
auto)/.test( c.css(
"overflow" ) );
2059 this.containment = [
2060 ( parseInt( c.css(
"borderLeftWidth" ), 10 ) || 0 ) + ( parseInt( c.css(
"paddingLeft" ), 10 ) || 0 ),
2061 ( parseInt( c.css(
"borderTopWidth" ), 10 ) || 0 ) + ( parseInt( c.css(
"paddingTop" ), 10 ) || 0 ),
2062 ( isUserScrollable ? Math.max( ce.scrollWidth, ce.offsetWidth ) : ce.offsetWidth ) -
2063 ( parseInt( c.css(
"borderRightWidth" ), 10 ) || 0 ) -
2064 ( parseInt( c.css(
"paddingRight" ), 10 ) || 0 ) -
2065 this.helperProportions.width -
2068 ( isUserScrollable ? Math.max( ce.scrollHeight, ce.offsetHeight ) : ce.offsetHeight ) -
2069 ( parseInt( c.css(
"borderBottomWidth" ), 10 ) || 0 ) -
2070 ( parseInt( c.css(
"paddingBottom" ), 10 ) || 0 ) -
2071 this.helperProportions.height -
2075 this.relativeContainer = c;
2078 _convertPositionTo:
function(
d, pos) {
2081 pos = this.position;
2084 var mod =
d ===
"absolute" ? 1 : -1,
2085 scrollIsRootNode = this._isRootNode( this.scrollParent[ 0 ] );
2090 this.
offset.relative.top * mod +
2091 this.
offset.parent.top * mod -
2092 ( ( this.cssPosition ===
"fixed" ? -this.
offset.scroll.top : ( scrollIsRootNode ? 0 : this.
offset.scroll.top ) ) * mod)
2096 this.
offset.relative.left * mod +
2097 this.
offset.parent.left * mod -
2098 ( ( this.cssPosition ===
"fixed" ? -this.
offset.scroll.left : ( scrollIsRootNode ? 0 : this.
offset.scroll.left ) ) * mod)
2104 _generatePosition:
function( event, constrainPosition ) {
2106 var containment, co, top, left,
2108 scrollIsRootNode = this._isRootNode( this.scrollParent[ 0 ] ),
2109 pageX =
event.pageX,
2110 pageY =
event.pageY;
2113 if ( !scrollIsRootNode || !this.
offset.scroll ) {
2115 top: this.scrollParent.scrollTop(),
2116 left: this.scrollParent.scrollLeft()
2126 if ( constrainPosition ) {
2127 if ( this.containment ) {
2128 if ( this.relativeContainer ){
2129 co = this.relativeContainer.offset();
2131 this.containment[ 0 ] + co.left,
2132 this.containment[ 1 ] + co.top,
2133 this.containment[ 2 ] + co.left,
2134 this.containment[ 3 ] + co.top
2137 containment = this.containment;
2140 if (event.pageX -
this.offset.click.left < containment[0]) {
2141 pageX = containment[0] + this.
offset.click.left;
2143 if (event.pageY -
this.offset.click.top < containment[1]) {
2144 pageY = containment[1] + this.
offset.click.top;
2146 if (event.pageX -
this.offset.click.left > containment[2]) {
2147 pageX = containment[2] + this.
offset.click.left;
2149 if (event.pageY -
this.offset.click.top > containment[3]) {
2150 pageY = containment[3] + this.
offset.click.top;
2156 top = o.grid[1] ? this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1] : this.originalPageY;
2157 pageY = containment ? ((top - this.
offset.click.top >= containment[1] || top - this.
offset.click.top > containment[3]) ? top : ((top - this.
offset.click.top >= containment[1]) ? top - o.grid[1] : top + o.grid[1])) : top;
2159 left = o.grid[0] ? this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0] : this.originalPageX;
2160 pageX = containment ? ((left - this.
offset.click.left >= containment[0] || left - this.
offset.click.left > containment[2]) ? left : ((left - this.
offset.click.left >= containment[0]) ? left - o.grid[0] : left + o.grid[0])) : left;
2163 if ( o.axis ===
"y" ) {
2164 pageX = this.originalPageX;
2167 if ( o.axis ===
"x" ) {
2168 pageY = this.originalPageY;
2176 this.
offset.relative.top -
2178 ( this.cssPosition ===
"fixed" ? -this.
offset.scroll.top : ( scrollIsRootNode ? 0 : this.
offset.scroll.top ) )
2183 this.offset.relative.left -
2184 this.offset.parent.left +
2185 (
this.cssPosition ===
"fixed" ? -
this.offset.scroll.left : ( scrollIsRootNode ? 0 :
this.offset.scroll.left ) )
2191 _clear:
function() {
2192 this.helper.removeClass(
"ui-draggable-dragging");
2193 if (this.helper[0] !== this.element[0] && !this.cancelHelperRemoval) {
2194 this.helper.remove();
2197 this.cancelHelperRemoval =
false;
2198 if ( this.destroyOnClear ) {
2203 _normalizeRightBottom:
function() {
2204 if ( this.options.axis !==
"y" &&
this.helper.css(
"right" ) !==
"auto" ) {
2205 this.helper.width( this.helper.width() );
2206 this.helper.css(
"right",
"auto" );
2208 if ( this.options.axis !==
"x" &&
this.helper.css(
"bottom" ) !==
"auto" ) {
2209 this.helper.height( this.helper.height() );
2210 this.helper.css(
"bottom",
"auto" );
2216 _trigger:
function( type, event, ui ) {
2217 ui = ui || this._uiHash();
2218 $.ui.plugin.call(
this, type, [ event, ui,
this ],
true );
2221 if ( /^(drag|
start|
stop)/.test( type ) ) {
2222 this.positionAbs = this._convertPositionTo(
"absolute" );
2223 ui.offset = this.positionAbs;
2225 return $.Widget.prototype._trigger.call(
this, type, event, ui );
2230 _uiHash:
function() {
2232 helper: this.helper,
2233 position: this.position,
2234 originalPosition: this.originalPosition,
2241 $.ui.plugin.add(
"draggable",
"connectToSortable", {
2242 start:
function( event, ui, draggable ) {
2243 var uiSortable = $.extend( {}, ui, {
2244 item: draggable.element
2247 draggable.sortables = [];
2248 $( draggable.options.connectToSortable ).
each(
function() {
2249 var sortable = $( this ).sortable(
"instance" );
2251 if ( sortable && !sortable.options.disabled ) {
2252 draggable.sortables.push( sortable );
2257 sortable.refreshPositions();
2258 sortable._trigger(
"activate", event, uiSortable);
2262 stop:
function( event, ui, draggable ) {
2263 var uiSortable = $.extend( {}, ui, {
2264 item: draggable.element
2267 draggable.cancelHelperRemoval =
false;
2269 $.each( draggable.sortables,
function() {
2270 var sortable = this;
2272 if ( sortable.isOver ) {
2273 sortable.isOver = 0;
2276 draggable.cancelHelperRemoval = true;
2277 sortable.cancelHelperRemoval = false;
2282 sortable._storedCSS = {
2283 position: sortable.placeholder.css(
"position" ),
2284 top: sortable.placeholder.css(
"top" ),
2285 left: sortable.placeholder.css(
"left" )
2288 sortable._mouseStop(event);
2292 sortable.options.helper = sortable.options._helper;
2297 sortable.cancelHelperRemoval = true;
2299 sortable._trigger(
"deactivate", event, uiSortable );
2303 drag:
function( event, ui, draggable ) {
2304 $.each( draggable.sortables,
function() {
2305 var innermostIntersecting = false,
2309 sortable.positionAbs = draggable.positionAbs;
2310 sortable.helperProportions = draggable.helperProportions;
2311 sortable.offset.click = draggable.offset.click;
2313 if ( sortable._intersectsWith( sortable.containerCache ) ) {
2314 innermostIntersecting = true;
2316 $.each( draggable.sortables, function() {
2318 this.positionAbs = draggable.positionAbs;
2319 this.helperProportions = draggable.helperProportions;
2320 this.offset.click = draggable.offset.click;
2322 if ( this !== sortable &&
2323 this._intersectsWith( this.containerCache ) &&
2324 $.contains( sortable.element[ 0 ], this.element[ 0 ] ) ) {
2325 innermostIntersecting = false;
2328 return innermostIntersecting;
2332 if ( innermostIntersecting ) {
2335 if ( !sortable.isOver ) {
2336 sortable.isOver = 1;
2338 sortable.currentItem = ui.helper
2339 .appendTo( sortable.element )
2340 .data(
"ui-sortable-item", true );
2343 sortable.options._helper = sortable.options.helper;
2345 sortable.options.helper = function() {
2346 return ui.helper[ 0 ];
2351 event.target = sortable.currentItem[ 0 ];
2352 sortable._mouseCapture( event,
true );
2353 sortable._mouseStart( event,
true,
true );
2357 sortable.offset.click.top = draggable.offset.click.top;
2358 sortable.offset.click.left = draggable.offset.click.left;
2359 sortable.offset.parent.left -= draggable.offset.parent.left -
2360 sortable.offset.parent.left;
2361 sortable.offset.parent.top -= draggable.offset.parent.top -
2362 sortable.offset.parent.top;
2364 draggable._trigger(
"toSortable", event );
2368 draggable.dropped = sortable.element;
2372 $.each( draggable.sortables,
function() {
2373 this.refreshPositions();
2377 draggable.currentItem = draggable.element;
2378 sortable.fromOutside = draggable;
2381 if ( sortable.currentItem ) {
2382 sortable._mouseDrag( event );
2386 ui.position = sortable.position;
2392 if ( sortable.isOver ) {
2394 sortable.isOver = 0;
2395 sortable.cancelHelperRemoval =
true;
2399 sortable.options._revert = sortable.options.revert;
2400 sortable.options.revert =
false;
2402 sortable._trigger(
"out", event, sortable._uiHash( sortable ) );
2403 sortable._mouseStop( event,
true );
2407 sortable.options.revert = sortable.options._revert;
2408 sortable.options.helper = sortable.options._helper;
2410 if ( sortable.placeholder ) {
2411 sortable.placeholder.remove();
2416 draggable._refreshOffsets( event );
2417 ui.position = draggable._generatePosition( event,
true );
2419 draggable._trigger(
"fromSortable", event );
2422 draggable.dropped =
false;
2426 $.each( draggable.sortables,
function() {
2427 this.refreshPositions();
2435 $.ui.plugin.add(
"draggable",
"cursor", {
2436 start:
function( event, ui, instance ) {
2437 var t = $(
"body" ),
2438 o = instance.options;
2440 if (t.css(
"cursor")) {
2441 o._cursor = t.css(
"cursor");
2443 t.css(
"cursor", o.cursor);
2445 stop:
function( event, ui, instance ) {
2446 var o = instance.options;
2448 $(
"body").css(
"cursor", o._cursor);
2453 $.ui.plugin.add(
"draggable",
"opacity", {
2454 start:
function( event, ui, instance ) {
2455 var t = $( ui.helper ),
2456 o = instance.options;
2457 if (t.css(
"opacity")) {
2458 o._opacity = t.css(
"opacity");
2460 t.css(
"opacity", o.opacity);
2462 stop:
function( event, ui, instance ) {
2463 var o = instance.options;
2465 $(ui.helper).css(
"opacity", o._opacity);
2470 $.ui.plugin.add(
"draggable",
"scroll", {
2471 start:
function( event, ui, i ) {
2472 if ( !i.scrollParentNotHidden ) {
2473 i.scrollParentNotHidden = i.helper.scrollParent(
false );
2476 if ( i.scrollParentNotHidden[ 0 ] !== i.document[ 0 ] && i.scrollParentNotHidden[ 0 ].tagName !==
"HTML" ) {
2477 i.overflowOffset = i.scrollParentNotHidden.offset();
2480 drag:
function( event, ui, i ) {
2484 scrollParent = i.scrollParentNotHidden[ 0 ],
2485 document = i.document[ 0 ];
2487 if ( scrollParent !== document && scrollParent.tagName !==
"HTML" ) {
2488 if ( !o.axis || o.axis !==
"x" ) {
2489 if ( ( i.overflowOffset.top + scrollParent.offsetHeight ) -
event.pageY < o.scrollSensitivity ) {
2490 scrollParent.scrollTop = scrolled = scrollParent.scrollTop + o.scrollSpeed;
2491 }
else if ( event.pageY - i.overflowOffset.top < o.scrollSensitivity ) {
2492 scrollParent.scrollTop = scrolled = scrollParent.scrollTop - o.scrollSpeed;
2496 if ( !o.axis || o.axis !==
"y" ) {
2497 if ( ( i.overflowOffset.left + scrollParent.offsetWidth ) -
event.pageX < o.scrollSensitivity ) {
2498 scrollParent.scrollLeft = scrolled = scrollParent.scrollLeft + o.scrollSpeed;
2499 }
else if ( event.pageX - i.overflowOffset.left < o.scrollSensitivity ) {
2500 scrollParent.scrollLeft = scrolled = scrollParent.scrollLeft - o.scrollSpeed;
2506 if (!o.axis || o.axis !==
"x") {
2507 if (event.pageY - $(document).scrollTop() < o.scrollSensitivity) {
2508 scrolled = $(document).
scrollTop($(document).scrollTop() - o.scrollSpeed);
2509 }
else if ($(
window).height() - (
event.pageY - $(document).
scrollTop()) < o.scrollSensitivity) {
2510 scrolled = $(document).
scrollTop($(document).scrollTop() + o.scrollSpeed);
2514 if (!o.axis || o.axis !==
"y") {
2515 if (event.pageX - $(document).scrollLeft() < o.scrollSensitivity) {
2516 scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed);
2517 }
else if ($(
window).width() - (
event.pageX - $(document).scrollLeft()) < o.scrollSensitivity) {
2518 scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);
2524 if (scrolled !==
false && $.ui.ddmanager && !o.dropBehaviour) {
2525 $.ui.ddmanager.prepareOffsets(i, event);
2531 $.ui.plugin.add(
"draggable",
"snap", {
2532 start:
function( event, ui, i ) {
2536 i.snapElements = [];
2538 $(o.snap.constructor !== String ? ( o.snap.items ||
":data(ui-draggable)" ) : o.snap).each(
function() {
2541 if (
this !== i.element[0]) {
2542 i.snapElements.push({
2545 top: $o.top, left: $o.left
2551 drag:
function( event, ui, inst ) {
2553 var ts, bs, ls, rs, l, r, t, b, i, first,
2555 d = o.snapTolerance,
2556 x1 = ui.offset.left, x2 = x1 + inst.helperProportions.width,
2557 y1 = ui.offset.top, y2 = y1 + inst.helperProportions.height;
2559 for (i = inst.snapElements.length - 1; i >= 0; i--){
2561 l = inst.snapElements[i].left - inst.margins.left;
2562 r = l + inst.snapElements[i].width;
2563 t = inst.snapElements[i].top - inst.margins.top;
2564 b = t + inst.snapElements[i].height;
2566 if ( x2 < l - d || x1 > r +
d || y2 < t - d || y1 > b +
d || !$.contains( inst.snapElements[ i ].item.ownerDocument, inst.snapElements[ i ].item ) ) {
2567 if (inst.snapElements[i].snapping) {
2568 (inst.options.snap.release && inst.options.snap.release.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item })));
2570 inst.snapElements[i].snapping =
false;
2574 if (o.snapMode !==
"inner") {
2575 ts = Math.abs(t - y2) <=
d;
2576 bs = Math.abs(b - y1) <=
d;
2577 ls = Math.abs(l - x2) <=
d;
2578 rs = Math.abs(r - x1) <=
d;
2580 ui.position.top = inst._convertPositionTo(
"relative", { top: t - inst.helperProportions.height, left: 0 }).top;
2583 ui.position.top = inst._convertPositionTo(
"relative", { top: b, left: 0 }).top;
2586 ui.position.left = inst._convertPositionTo(
"relative", { top: 0, left: l - inst.helperProportions.width }).left;
2589 ui.position.left = inst._convertPositionTo(
"relative", { top: 0, left: r }).left;
2593 first = (ts || bs || ls || rs);
2595 if (o.snapMode !==
"outer") {
2596 ts = Math.abs(t - y1) <=
d;
2597 bs = Math.abs(b - y2) <=
d;
2598 ls = Math.abs(l - x1) <=
d;
2599 rs = Math.abs(r - x2) <=
d;
2601 ui.position.top = inst._convertPositionTo(
"relative", { top: t, left: 0 }).top;
2604 ui.position.top = inst._convertPositionTo(
"relative", { top: b - inst.helperProportions.height, left: 0 }).top;
2607 ui.position.left = inst._convertPositionTo(
"relative", { top: 0, left: l }).left;
2610 ui.position.left = inst._convertPositionTo(
"relative", { top: 0, left: r - inst.helperProportions.width }).left;
2614 if (!inst.snapElements[i].snapping && (ts || bs || ls || rs || first)) {
2615 (inst.options.snap.snap && inst.options.snap.snap.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item })));
2617 inst.snapElements[i].snapping = (ts || bs || ls || rs || first);
2624 $.ui.plugin.add(
"draggable",
"stack", {
2625 start:
function( event, ui, instance ) {
2627 o = instance.options,
2628 group = $.makeArray($(o.stack)).sort(
function(a, b) {
2629 return (parseInt($(a).css(
"zIndex"), 10) || 0) - (parseInt($(b).css(
"zIndex"), 10) || 0);
2632 if (!group.length) {
return; }
2634 min = parseInt($(group[0]).css(
"zIndex"), 10) || 0;
2635 $(group).
each(
function(i) {
2636 $(
this).css(
"zIndex", min + i);
2638 this.css(
"zIndex", (min + group.length));
2642 $.ui.plugin.add(
"draggable",
"zIndex", {
2643 start:
function( event, ui, instance ) {
2644 var t = $( ui.helper ),
2645 o = instance.options;
2647 if (t.css(
"zIndex")) {
2648 o._zIndex = t.css(
"zIndex");
2650 t.css(
"zIndex", o.zIndex);
2652 stop:
function( event, ui, instance ) {
2653 var o = instance.options;
2656 $(ui.helper).css(
"zIndex", o._zIndex);
2661 var draggable = $.ui.draggable;
2676 $.widget(
"ui.droppable", {
2678 widgetEventPrefix:
"drop",
2686 tolerance:
"intersect",
2695 _create:
function() {
2701 this.isover =
false;
2704 this.accept = $.isFunction( accept ) ? accept :
function(
d ) {
2705 return d.is( accept );
2708 this.proportions =
function( ) {
2709 if ( arguments.length ) {
2711 proportions = arguments[ 0 ];
2714 return proportions ?
2717 width: this.element[ 0 ].offsetWidth,
2718 height: this.element[ 0 ].offsetHeight
2723 this._addToManager( o.scope );
2725 o.addClasses && this.element.addClass(
"ui-droppable" );
2729 _addToManager:
function( scope ) {
2731 $.ui.ddmanager.droppables[ scope ] = $.ui.ddmanager.droppables[ scope ] || [];
2732 $.ui.ddmanager.droppables[ scope ].push(
this );
2735 _splice:
function( drop ) {
2737 for ( ; i < drop.length; i++ ) {
2738 if ( drop[ i ] ===
this ) {
2739 drop.splice( i, 1 );
2744 _destroy:
function() {
2745 var drop = $.ui.ddmanager.droppables[ this.options.scope ];
2747 this._splice( drop );
2749 this.element.removeClass(
"ui-droppable ui-droppable-disabled" );
2752 _setOption:
function( key, value ) {
2754 if ( key ===
"accept" ) {
2755 this.accept = $.isFunction( value ) ? value :
function(
d ) {
2756 return d.is( value );
2758 }
else if ( key ===
"scope" ) {
2759 var drop = $.ui.ddmanager.droppables[ this.options.scope ];
2761 this._splice( drop );
2762 this._addToManager( value );
2765 this._super( key, value );
2768 _activate:
function( event ) {
2769 var draggable = $.ui.ddmanager.current;
2770 if ( this.options.activeClass ) {
2771 this.element.addClass( this.options.activeClass );
2774 this._trigger(
"activate", event, this.ui( draggable ) );
2778 _deactivate:
function( event ) {
2779 var draggable = $.ui.ddmanager.current;
2780 if ( this.options.activeClass ) {
2781 this.element.removeClass( this.options.activeClass );
2784 this._trigger(
"deactivate", event, this.ui( draggable ) );
2788 _over:
function( event ) {
2790 var draggable = $.ui.ddmanager.current;
2793 if ( !draggable || ( draggable.currentItem || draggable.element )[ 0 ] === this.element[ 0 ] ) {
2797 if ( this.accept.call(
this.element[ 0 ], ( draggable.currentItem || draggable.element ) ) ) {
2798 if ( this.options.hoverClass ) {
2799 this.element.addClass( this.options.hoverClass );
2801 this._trigger(
"over", event, this.ui( draggable ) );
2806 _out:
function( event ) {
2808 var draggable = $.ui.ddmanager.current;
2811 if ( !draggable || ( draggable.currentItem || draggable.element )[ 0 ] === this.element[ 0 ] ) {
2815 if ( this.accept.call(
this.element[ 0 ], ( draggable.currentItem || draggable.element ) ) ) {
2816 if ( this.options.hoverClass ) {
2817 this.element.removeClass( this.options.hoverClass );
2819 this._trigger(
"out", event, this.ui( draggable ) );
2824 _drop:
function( event, custom ) {
2826 var draggable = custom || $.ui.ddmanager.current,
2827 childrenIntersection =
false;
2830 if ( !draggable || ( draggable.currentItem || draggable.element )[ 0 ] === this.element[ 0 ] ) {
2834 this.element.find(
":data(ui-droppable)" ).not(
".ui-draggable-dragging" ).each(
function() {
2835 var inst = $( this ).droppable(
"instance" );
2837 inst.options.greedy &&
2838 !inst.options.disabled &&
2839 inst.options.scope === draggable.options.scope &&
2840 inst.accept.call( inst.element[ 0 ], ( draggable.currentItem || draggable.element ) ) &&
2841 $.ui.intersect( draggable, $.
extend( inst, {
offset: inst.element.offset() } ), inst.options.tolerance, event )
2842 ) { childrenIntersection =
true;
return false; }
2844 if ( childrenIntersection ) {
2848 if ( this.accept.call(
this.element[ 0 ], ( draggable.currentItem || draggable.element ) ) ) {
2849 if ( this.options.activeClass ) {
2850 this.element.removeClass( this.options.activeClass );
2852 if ( this.options.hoverClass ) {
2853 this.element.removeClass( this.options.hoverClass );
2855 this._trigger(
"drop", event, this.ui( draggable ) );
2856 return this.element;
2865 draggable: ( c.currentItem || c.element ),
2867 position: c.position,
2874 $.ui.intersect = (
function() {
2875 function isOverAxis( x, reference,
size ) {
2876 return ( x >= reference ) && ( x < ( reference +
size ) );
2879 return function( draggable, droppable, toleranceMode, event ) {
2881 if ( !droppable.offset ) {
2885 var x1 = ( draggable.positionAbs || draggable.position.absolute ).left + draggable.margins.left,
2886 y1 = ( draggable.positionAbs || draggable.position.absolute ).top + draggable.margins.top,
2887 x2 = x1 + draggable.helperProportions.width,
2888 y2 = y1 + draggable.helperProportions.height,
2889 l = droppable.offset.left,
2890 t = droppable.offset.top,
2891 r = l + droppable.proportions().width,
2892 b = t + droppable.proportions().height;
2894 switch ( toleranceMode ) {
2896 return ( l <= x1 && x2 <= r && t <= y1 && y2 <= b );
2898 return ( l < x1 + ( draggable.helperProportions.width / 2 ) &&
2899 x2 - ( draggable.helperProportions.width / 2 ) < r &&
2900 t < y1 + ( draggable.helperProportions.height / 2 ) &&
2901 y2 - ( draggable.helperProportions.height / 2 ) < b );
2903 return isOverAxis( event.pageY, t, droppable.proportions().height ) && isOverAxis( event.pageX, l, droppable.proportions().width );
2906 ( y1 >= t && y1 <= b ) ||
2907 ( y2 >= t && y2 <= b ) ||
2908 ( y1 < t && y2 > b )
2910 ( x1 >= l && x1 <= r ) ||
2911 ( x2 >= l && x2 <= r ) ||
2912 ( x1 < l && x2 > r )
2925 droppables: {
"default": [] },
2926 prepareOffsets:
function( t, event ) {
2929 m = $.ui.ddmanager.droppables[ t.options.scope ] || [],
2930 type =
event ?
event.type : null,
2931 list = ( t.currentItem || t.element ).find(
":data(ui-droppable)" ).addBack();
2933 droppablesLoop:
for ( i = 0; i < m.length; i++ ) {
2936 if ( m[ i ].options.disabled || ( t && !m[ i ].accept.call( m[ i ].element[ 0 ], ( t.currentItem || t.element ) ) ) ) {
2941 for ( j = 0; j < list.length; j++ ) {
2942 if ( list[ j ] === m[ i ].element[ 0 ] ) {
2943 m[ i ].proportions().height = 0;
2944 continue droppablesLoop;
2948 m[ i ].visible = m[ i ].element.css(
"display" ) !==
"none";
2949 if ( !m[ i ].visible ) {
2954 if ( type ===
"mousedown" ) {
2955 m[ i ]._activate.call( m[ i ], event );
2958 m[ i ].offset = m[ i ].element.offset();
2959 m[ i ].proportions({
width: m[ i ].element[ 0 ].offsetWidth,
height: m[ i ].element[ 0 ].offsetHeight });
2964 drop:
function( draggable, event ) {
2966 var dropped =
false;
2968 $.each( ( $.ui.ddmanager.droppables[ draggable.options.scope ] || [] ).slice(),
function() {
2970 if ( !this.options ) {
2973 if ( !this.options.disabled &&
this.visible && $.ui.intersect( draggable,
this,
this.options.tolerance, event ) ) {
2974 dropped = this._drop.call(
this, event ) || dropped;
2977 if ( !this.options.disabled &&
this.visible &&
this.accept.call(
this.element[ 0 ], ( draggable.currentItem || draggable.element ) ) ) {
2979 this.isover =
false;
2980 this._deactivate.call(
this, event );
2987 dragStart:
function( draggable, event ) {
2989 draggable.element.parentsUntil(
"body" ).bind(
"scroll.droppable",
function() {
2990 if ( !draggable.options.refreshPositions ) {
2991 $.ui.ddmanager.prepareOffsets( draggable, event );
2995 drag:
function( draggable, event ) {
2998 if ( draggable.options.refreshPositions ) {
2999 $.ui.ddmanager.prepareOffsets( draggable, event );
3003 $.each( $.ui.ddmanager.droppables[ draggable.options.scope ] || [],
function() {
3005 if ( this.options.disabled || this.greedyChild || !this.visible ) {
3009 var parentInstance, scope, parent,
3010 intersects = $.ui.intersect( draggable,
this,
this.options.tolerance, event ),
3011 c = !intersects && this.isover ?
"isout" : ( intersects && !this.isover ?
"isover" : null );
3016 if ( this.options.greedy ) {
3018 scope = this.options.scope;
3019 parent = this.element.parents(
":data(ui-droppable)" ).filter(
function() {
3020 return $( this ).droppable(
"instance" ).options.scope === scope;
3023 if ( parent.length ) {
3024 parentInstance = $( parent[ 0 ] ).droppable(
"instance" );
3025 parentInstance.greedyChild = ( c ===
"isover" );
3030 if ( parentInstance && c ===
"isover" ) {
3031 parentInstance.isover =
false;
3032 parentInstance.isout =
true;
3033 parentInstance._out.call( parentInstance, event );
3037 this[c ===
"isout" ?
"isover" :
"isout"] =
false;
3038 this[c ===
"isover" ?
"_over" :
"_out"].call(
this, event );
3041 if ( parentInstance && c ===
"isout" ) {
3042 parentInstance.isout =
false;
3043 parentInstance.isover =
true;
3044 parentInstance._over.call( parentInstance, event );
3049 dragStop:
function( draggable, event ) {
3050 draggable.element.parentsUntil(
"body" ).unbind(
"scroll.droppable" );
3052 if ( !draggable.options.refreshPositions ) {
3053 $.ui.ddmanager.prepareOffsets( draggable, event );
3058 var droppable = $.ui.droppable;
3073 $.widget(
"ui.resizable", $.ui.mouse, {
3075 widgetEventPrefix:
"resize",
3079 animateDuration:
"slow",
3080 animateEasing:
"swing",
3101 _num:
function( value ) {
3102 return parseInt( value, 10 ) || 0;
3105 _isNumber:
function( value ) {
3106 return !isNaN( parseInt( value, 10 ) );
3109 _hasScroll:
function( el, a ) {
3111 if ( $( el ).css(
"overflow" ) ===
"hidden") {
3115 var scroll = ( a && a ===
"left" ) ?
"scrollLeft" :
"scrollTop",
3118 if ( el[ scroll ] > 0 ) {
3126 has = ( el[ scroll ] > 0 );
3131 _create:
function() {
3133 var n, i, handle, axis, hname,
3136 this.element.addClass(
"ui-resizable");
3139 _aspectRatio: !!(o.aspectRatio),
3140 aspectRatio: o.aspectRatio,
3141 originalElement:
this.element,
3142 _proportionallyResizeElements: [],
3143 _helper: o.helper || o.ghost || o.animate ? o.helper ||
"ui-resizable-helper" : null
3147 if (this.element[0].nodeName.match(/canvas|textarea|input|select|button|img/i)) {
3150 $(
"<div class='ui-wrapper' style='overflow: hidden;'></div>").css({
3151 position: this.element.css(
"position"),
3152 width: this.element.outerWidth(),
3153 height: this.element.outerHeight(),
3154 top: this.element.css(
"top"),
3155 left: this.element.css(
"left")
3159 this.element = this.element.parent().data(
3160 "ui-resizable", this.element.resizable(
"instance" )
3163 this.elementIsWrapper =
true;
3166 marginLeft: this.originalElement.css(
"marginLeft"),
3167 marginTop: this.originalElement.css(
"marginTop"),
3168 marginRight: this.originalElement.css(
"marginRight"),
3169 marginBottom: this.originalElement.css(
"marginBottom")
3171 this.originalElement.css({
3179 this.originalResizeStyle = this.originalElement.css(
"resize");
3180 this.originalElement.css(
"resize",
"none");
3182 this._proportionallyResizeElements.push( this.originalElement.css({
3190 this.originalElement.css({ margin: this.originalElement.css(
"margin") });
3192 this._proportionallyResize();
3195 this.handles = o.handles ||
3196 ( !$(
".ui-resizable-handle", this.element).length ?
3198 n:
".ui-resizable-n",
3199 e:
".ui-resizable-e",
3200 s:
".ui-resizable-s",
3201 w:
".ui-resizable-w",
3202 se:
".ui-resizable-se",
3203 sw:
".ui-resizable-sw",
3204 ne:
".ui-resizable-ne",
3205 nw:
".ui-resizable-nw" 3208 if (this.handles.constructor === String) {
3210 if ( this.handles ===
"all") {
3211 this.handles =
"n,e,s,w,se,sw,ne,nw";
3214 n = this.handles.split(
",");
3217 for (i = 0; i < n.length; i++) {
3219 handle = $.trim(n[i]);
3220 hname =
"ui-resizable-" + handle;
3221 axis = $(
"<div class='ui-resizable-handle " + hname +
"'></div>");
3223 axis.css({ zIndex: o.zIndex });
3226 if (
"se" === handle) {
3227 axis.addClass(
"ui-icon ui-icon-gripsmall-diagonal-se");
3230 this.handles[handle] =
".ui-resizable-" + handle;
3231 this.element.append(axis);
3236 this._renderAxis =
function(target) {
3238 var i, axis, padPos, padWrapper;
3240 target = target || this.element;
3242 for (i in this.handles) {
3244 if (this.handles[i].constructor === String) {
3245 this.handles[i] = this.element.children( this.handles[ i ] ).first().show();
3248 if (this.elementIsWrapper && this.originalElement[0].nodeName.match(/textarea|input|select|button/i)) {
3250 axis = $(this.handles[i], this.element);
3252 padWrapper = /sw|ne|nw|
se|n|
s/.test(i) ? axis.outerHeight() : axis.outerWidth();
3254 padPos = [
"padding",
3255 /ne|nw|n/.test(i) ?
"Top" :
3256 /
se|sw|
s/.test(i) ?
"Bottom" :
3257 /^
e$/.test(i) ?
"Right" :
"Left" ].join(
"");
3259 target.css(padPos, padWrapper);
3261 this._proportionallyResize();
3266 if (!$(this.handles[i]).length) {
3273 this._renderAxis(this.element);
3275 this._handles = $(
".ui-resizable-handle", this.element)
3276 .disableSelection();
3278 this._handles.mouseover(
function() {
3279 if (!that.resizing) {
3280 if (this.className) {
3281 axis = this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i);
3283 that.axis = axis && axis[1] ? axis[1] :
"se";
3288 this._handles.hide();
3291 .mouseenter(
function() {
3295 $(
this).removeClass(
"ui-resizable-autohide");
3296 that._handles.show();
3298 .mouseleave(
function() {
3302 if (!that.resizing) {
3303 $(
this).
addClass(
"ui-resizable-autohide");
3304 that._handles.hide();
3313 _destroy:
function() {
3315 this._mouseDestroy();
3318 _destroy =
function(exp) {
3320 .removeClass(
"ui-resizable ui-resizable-disabled ui-resizable-resizing")
3321 .removeData(
"resizable")
3322 .removeData(
"ui-resizable")
3323 .unbind(
".resizable")
3324 .find(
".ui-resizable-handle")
3329 if (this.elementIsWrapper) {
3330 _destroy(this.element);
3331 wrapper = this.element;
3332 this.originalElement.css({
3333 position: wrapper.css(
"position"),
3334 width: wrapper.outerWidth(),
3335 height: wrapper.outerHeight(),
3336 top: wrapper.css(
"top"),
3337 left: wrapper.css(
"left")
3338 }).insertAfter( wrapper );
3342 this.originalElement.css(
"resize", this.originalResizeStyle);
3343 _destroy(this.originalElement);
3348 _mouseCapture:
function(event) {
3352 for (i in this.handles) {
3353 handle = $(this.handles[i])[0];
3354 if (handle === event.target || $.contains(handle, event.target)) {
3359 return !this.options.disabled && capture;
3362 _mouseStart:
function(event) {
3364 var curleft, curtop, cursor,
3368 this.resizing =
true;
3370 this._renderProxy();
3372 curleft = this._num(this.helper.css(
"left"));
3373 curtop = this._num(this.helper.css(
"top"));
3375 if (o.containment) {
3376 curleft += $(o.containment).scrollLeft() || 0;
3377 curtop += $(o.containment).
scrollTop() || 0;
3380 this.
offset = this.helper.offset();
3381 this.position = { left: curleft, top: curtop };
3383 this.
size = this._helper ? {
3384 width: this.helper.width(),
3385 height: this.helper.height()
3391 this.originalSize = this._helper ? {
3392 width: el.outerWidth(),
3400 width: el.outerWidth() - el.width(),
3401 height: el.outerHeight() - el.height()
3404 this.originalPosition = { left: curleft, top: curtop };
3405 this.originalMousePosition = { left:
event.pageX, top:
event.pageY };
3407 this.aspectRatio = (typeof o.aspectRatio ===
"number") ?
3409 ((
this.originalSize.width /
this.originalSize.height) || 1);
3411 cursor = $(
".ui-resizable-" + this.axis).css(
"cursor");
3412 $(
"body").css(
"cursor", cursor ===
"auto" ? this.axis +
"-resize" : cursor);
3414 el.addClass(
"ui-resizable-resizing");
3415 this._propagate(
"start", event);
3419 _mouseDrag:
function(event) {
3422 smp = this.originalMousePosition,
3424 dx = (
event.pageX - smp.left) || 0,
3425 dy = (event.pageY - smp.top) || 0,
3426 trigger = this._change[a];
3428 this._updatePrevProperties();
3434 data = trigger.apply(
this, [ event, dx, dy ]);
3436 this._updateVirtualBoundaries(event.shiftKey);
3437 if (this._aspectRatio || event.shiftKey) {
3438 data = this._updateRatio(data, event);
3441 data = this._respectSize(data, event);
3443 this._updateCache(data);
3445 this._propagate(
"resize", event);
3447 props = this._applyChanges();
3449 if ( !this._helper && this._proportionallyResizeElements.length ) {
3450 this._proportionallyResize();
3453 if ( !$.isEmptyObject( props ) ) {
3454 this._updatePrevProperties();
3455 this._trigger(
"resize", event, this.ui() );
3456 this._applyChanges();
3462 _mouseStop:
function(event) {
3464 this.resizing =
false;
3465 var pr, ista, soffseth, soffsetw,
s, left, top,
3466 o = this.options, that =
this;
3470 pr = this._proportionallyResizeElements;
3471 ista = pr.length && (/textarea/i).test(pr[0].nodeName);
3472 soffseth = ista && this._hasScroll(pr[0],
"left") ? 0 : that.sizeDiff.height;
3473 soffsetw = ista ? 0 : that.sizeDiff.width;
3476 width: (that.helper.width() - soffsetw),
3477 height: (that.helper.height() - soffseth)
3479 left = (parseInt(that.element.css(
"left"), 10) +
3480 (that.position.left - that.originalPosition.left)) || null;
3481 top = (parseInt(that.element.css(
"top"), 10) +
3482 (that.position.top - that.originalPosition.top)) || null;
3485 this.element.css($.
extend(s, { top: top, left: left }));
3488 that.helper.height(that.size.height);
3489 that.helper.width(that.size.width);
3491 if (this._helper && !o.animate) {
3492 this._proportionallyResize();
3496 $(
"body").css(
"cursor",
"auto");
3498 this.element.removeClass(
"ui-resizable-resizing");
3500 this._propagate(
"stop", event);
3503 this.helper.remove();
3510 _updatePrevProperties:
function() {
3511 this.prevPosition = {
3512 top: this.position.top,
3513 left: this.position.left
3521 _applyChanges:
function() {
3524 if ( this.position.top !==
this.prevPosition.top ) {
3525 props.top = this.position.top +
"px";
3527 if ( this.position.left !==
this.prevPosition.left ) {
3528 props.left = this.position.left +
"px";
3530 if ( this.
size.width !==
this.prevSize.width ) {
3531 props.width = this.
size.width +
"px";
3533 if ( this.
size.height !==
this.prevSize.height ) {
3534 props.height = this.
size.height +
"px";
3537 this.helper.css( props );
3542 _updateVirtualBoundaries:
function(forceAspectRatio) {
3543 var pMinWidth, pMaxWidth, pMinHeight, pMaxHeight, b,
3547 minWidth: this._isNumber(o.minWidth) ? o.minWidth : 0,
3548 maxWidth: this._isNumber(o.maxWidth) ? o.maxWidth : Infinity,
3549 minHeight: this._isNumber(o.minHeight) ? o.minHeight : 0,
3550 maxHeight: this._isNumber(o.maxHeight) ? o.maxHeight : Infinity
3553 if (this._aspectRatio || forceAspectRatio) {
3554 pMinWidth = b.minHeight * this.aspectRatio;
3555 pMinHeight = b.minWidth / this.aspectRatio;
3556 pMaxWidth = b.maxHeight * this.aspectRatio;
3557 pMaxHeight = b.maxWidth / this.aspectRatio;
3559 if (pMinWidth > b.minWidth) {
3560 b.minWidth = pMinWidth;
3562 if (pMinHeight > b.minHeight) {
3563 b.minHeight = pMinHeight;
3565 if (pMaxWidth < b.maxWidth) {
3566 b.maxWidth = pMaxWidth;
3568 if (pMaxHeight < b.maxHeight) {
3569 b.maxHeight = pMaxHeight;
3572 this._vBoundaries = b;
3575 _updateCache:
function(data) {
3576 this.
offset = this.helper.offset();
3577 if (this._isNumber(data.left)) {
3578 this.position.left = data.left;
3580 if (this._isNumber(data.top)) {
3581 this.position.top = data.top;
3583 if (this._isNumber(data.height)) {
3584 this.
size.height = data.height;
3586 if (this._isNumber(data.width)) {
3587 this.
size.width = data.width;
3591 _updateRatio:
function( data ) {
3593 var cpos = this.position,
3597 if (this._isNumber(data.height)) {
3598 data.width = (data.height * this.aspectRatio);
3599 }
else if (this._isNumber(data.width)) {
3600 data.height = (data.width / this.aspectRatio);
3604 data.left = cpos.left + (csize.width - data.width);
3608 data.top = cpos.top + (csize.height - data.height);
3609 data.left = cpos.left + (csize.width - data.width);
3615 _respectSize:
function( data ) {
3617 var o = this._vBoundaries,
3619 ismaxw = this._isNumber(data.width) && o.maxWidth && (o.maxWidth < data.width),
3620 ismaxh = this._isNumber(data.height) && o.maxHeight && (o.maxHeight < data.height),
3621 isminw = this._isNumber(data.width) && o.minWidth && (o.minWidth > data.width),
3622 isminh = this._isNumber(data.height) && o.minHeight && (o.minHeight > data.height),
3623 dw = this.originalPosition.left +
this.originalSize.width,
3624 dh =
this.position.top +
this.size.height,
3625 cw = /sw|nw|
w/.test(a), ch = /nw|ne|n/.test(a);
3627 data.width = o.minWidth;
3630 data.height = o.minHeight;
3633 data.width = o.maxWidth;
3636 data.height = o.maxHeight;
3640 data.left = dw - o.minWidth;
3643 data.left = dw - o.maxWidth;
3646 data.top = dh - o.minHeight;
3649 data.top = dh - o.maxHeight;
3653 if (!data.width && !data.height && !data.left && data.top) {
3655 }
else if (!data.width && !data.height && !data.top && data.left) {
3662 _getPaddingPlusBorderDimensions:
function( element ) {
3666 element.css(
"borderTopWidth" ),
3667 element.css(
"borderRightWidth" ),
3668 element.css(
"borderBottomWidth" ),
3669 element.css(
"borderLeftWidth" )
3672 element.css(
"paddingTop" ),
3673 element.css(
"paddingRight" ),
3674 element.css(
"paddingBottom" ),
3675 element.css(
"paddingLeft" )
3678 for ( ; i < 4; i++ ) {
3679 widths[ i ] = ( parseInt( borders[ i ], 10 ) || 0 );
3680 widths[ i ] += ( parseInt( paddings[ i ], 10 ) || 0 );
3684 height: widths[ 0 ] + widths[ 2 ],
3685 width: widths[ 1 ] + widths[ 3 ]
3689 _proportionallyResize:
function() {
3691 if (!this._proportionallyResizeElements.length) {
3697 element = this.helper || this.element;
3699 for ( ; i < this._proportionallyResizeElements.length; i++) {
3701 prel = this._proportionallyResizeElements[i];
3705 if (!this.outerDimensions) {
3706 this.outerDimensions = this._getPaddingPlusBorderDimensions( prel );
3710 height: (element.height() - this.outerDimensions.height) || 0,
3711 width: (element.width() - this.outerDimensions.width) || 0
3718 _renderProxy:
function() {
3720 var el = this.element, o = this.options;
3721 this.elementOffset = el.offset();
3725 this.helper = this.helper || $(
"<div style='overflow:hidden;'></div>");
3727 this.helper.addClass(this._helper).css({
3728 width: this.element.outerWidth() - 1,
3729 height: this.element.outerHeight() - 1,
3730 position:
"absolute",
3731 left: this.elementOffset.left +
"px",
3732 top: this.elementOffset.top +
"px",
3738 .disableSelection();
3741 this.helper = this.element;
3747 e:
function(event, dx) {
3748 return {
width: this.originalSize.width + dx };
3750 w:
function(event, dx) {
3751 var cs = this.originalSize, sp = this.originalPosition;
3752 return { left: sp.left + dx,
width: cs.width - dx };
3754 n:
function(event, dx, dy) {
3755 var cs = this.originalSize, sp = this.originalPosition;
3756 return { top: sp.top + dy,
height: cs.height - dy };
3758 s:
function(event, dx, dy) {
3759 return {
height: this.originalSize.height + dy };
3761 se:
function(event, dx, dy) {
3762 return $.extend(this._change.s.apply(
this, arguments),
3763 this._change.e.apply(
this, [ event, dx, dy ]));
3765 sw:
function(event, dx, dy) {
3766 return $.extend(this._change.s.apply(
this, arguments),
3767 this._change.w.apply(
this, [ event, dx, dy ]));
3769 ne:
function(event, dx, dy) {
3770 return $.extend(this._change.n.apply(
this, arguments),
3771 this._change.e.apply(
this, [ event, dx, dy ]));
3773 nw:
function(event, dx, dy) {
3774 return $.extend(this._change.n.apply(
this, arguments),
3775 this._change.w.apply(
this, [ event, dx, dy ]));
3779 _propagate:
function(n, event) {
3780 $.ui.plugin.call(
this, n, [ event, this.ui() ]);
3781 (n !==
"resize" && this._trigger(n, event, this.ui()));
3788 originalElement: this.originalElement,
3789 element: this.element,
3790 helper: this.helper,
3791 position: this.position,
3793 originalSize: this.originalSize,
3794 originalPosition: this.originalPosition
3804 $.ui.plugin.add(
"resizable",
"animate", {
3806 stop:
function( event ) {
3807 var that = $(
this).resizable(
"instance" ),
3809 pr = that._proportionallyResizeElements,
3810 ista = pr.length && (/textarea/i).test(pr[0].nodeName),
3811 soffseth = ista && that._hasScroll(pr[0],
"left") ? 0 : that.sizeDiff.height,
3812 soffsetw = ista ? 0 : that.sizeDiff.width,
3813 style = {
width: (that.size.width - soffsetw),
height: (that.size.height - soffseth) },
3814 left = (parseInt(that.element.css(
"left"), 10) +
3815 (that.position.left - that.originalPosition.left)) || null,
3816 top = (parseInt(that.element.css(
"top"), 10) +
3817 (that.position.top - that.originalPosition.top)) || null;
3819 that.element.animate(
3820 $.
extend(style, top && left ? { top: top, left: left } : {}), {
3821 duration: o.animateDuration,
3826 width: parseInt(that.element.css(
"width"), 10),
3827 height: parseInt(that.element.css(
"height"), 10),
3828 top: parseInt(that.element.css(
"top"), 10),
3829 left: parseInt(that.element.css(
"left"), 10)
3832 if (pr && pr.length) {
3833 $(pr[0]).css({
width: data.width,
height: data.height });
3837 that._updateCache(data);
3838 that._propagate(
"resize", event);
3847 $.ui.plugin.add(
"resizable",
"containment", {
3851 that = $( this ).resizable(
"instance" ),
3855 ce = ( oc instanceof $ ) ? oc.get( 0 ) : ( /parent/.test( oc ) ) ? el.parent().get( 0 ) : oc;
3861 that.containerElement = $( ce );
3863 if ( /document/.test( oc ) || oc === document ) {
3864 that.containerOffset = {
3868 that.containerPosition = {
3874 element: $( document ),
3877 width: $( document ).width(),
3878 height: $( document ).
height() || document.body.parentNode.scrollHeight
3883 $([
"Top",
"Right",
"Left",
"Bottom" ]).
each(
function( i, name ) {
3884 p[ i ] = that._num( element.css(
"padding" + name ) );
3887 that.containerOffset = element.offset();
3888 that.containerPosition = element.position();
3889 that.containerSize = {
3890 height: ( element.innerHeight() - p[ 3 ] ),
3891 width: ( element.innerWidth() - p[ 1 ] )
3894 co = that.containerOffset;
3895 ch = that.containerSize.height;
3896 cw = that.containerSize.width;
3897 width = ( that._hasScroll ( ce,
"left" ) ? ce.scrollWidth : cw );
3898 height = ( that._hasScroll ( ce ) ? ce.scrollHeight : ch ) ;
3910 resize:
function( event ) {
3911 var woset, hoset, isParent, isOffsetRelative,
3912 that = $( this ).resizable(
"instance" ),
3914 co = that.containerOffset,
3916 pRatio = that._aspectRatio ||
event.shiftKey,
3921 ce = that.containerElement,
3922 continueResize =
true;
3924 if ( ce[ 0 ] !== document && ( /
static/ ).test( ce.css(
"position" ) ) ) {
3928 if ( cp.left < ( that._helper ? co.left : 0 ) ) {
3929 that.size.width = that.size.width +
3931 ( that.position.left - co.left ) :
3932 ( that.position.left - cop.left ) );
3935 that.size.height = that.size.width / that.aspectRatio;
3936 continueResize =
false;
3938 that.position.left = o.helper ? co.left : 0;
3941 if ( cp.top < ( that._helper ? co.top : 0 ) ) {
3942 that.size.height = that.size.height +
3944 ( that.position.top - co.top ) :
3945 that.position.top );
3948 that.size.width = that.size.height * that.aspectRatio;
3949 continueResize =
false;
3951 that.position.top = that._helper ? co.top : 0;
3954 isParent = that.containerElement.get( 0 ) === that.element.parent().get( 0 );
3955 isOffsetRelative = /relative|absolute/.test( that.containerElement.css(
"position" ) );
3957 if ( isParent && isOffsetRelative ) {
3958 that.offset.left = that.parentData.left + that.position.left;
3959 that.offset.top = that.parentData.top + that.position.top;
3961 that.offset.left = that.element.offset().left;
3962 that.offset.top = that.element.offset().top;
3965 woset = Math.abs( that.sizeDiff.width +
3967 that.offset.left - cop.left :
3968 (that.offset.left - co.left)) );
3970 hoset = Math.abs( that.sizeDiff.height +
3972 that.offset.top - cop.top :
3973 (that.offset.top - co.top)) );
3975 if ( woset + that.size.width >= that.parentData.width ) {
3976 that.size.width = that.parentData.width - woset;
3978 that.size.height = that.size.width / that.aspectRatio;
3979 continueResize =
false;
3983 if ( hoset + that.size.height >= that.parentData.height ) {
3984 that.size.height = that.parentData.height - hoset;
3986 that.size.width = that.size.height * that.aspectRatio;
3987 continueResize =
false;
3991 if ( !continueResize ){
3992 that.position.left = that.prevPosition.left;
3993 that.position.top = that.prevPosition.top;
3994 that.size.width = that.prevSize.width;
3995 that.size.height = that.prevSize.height;
4000 var that = $( this ).resizable(
"instance" ),
4002 co = that.containerOffset,
4003 cop = that.containerPosition,
4004 ce = that.containerElement,
4005 helper = $( that.helper ),
4006 ho = helper.offset(),
4007 w = helper.outerWidth() - that.sizeDiff.width,
4008 h = helper.outerHeight() - that.sizeDiff.height;
4010 if ( that._helper && !o.animate && ( /relative/ ).test( ce.css(
"position" ) ) ) {
4012 left: ho.left - cop.left - co.left,
4018 if ( that._helper && !o.animate && ( /
static/ ).test( ce.css(
"position" ) ) ) {
4020 left: ho.left - cop.left - co.left,
4028 $.ui.plugin.add(
"resizable",
"alsoResize", {
4031 var that = $(
this).resizable(
"instance" ),
4033 _store =
function(exp) {
4034 $(exp).
each(
function() {
4036 el.data(
"ui-resizable-alsoresize", {
4037 width: parseInt(el.width(), 10), height: parseInt(el.height(), 10),
4038 left: parseInt(el.css(
"left"), 10), top: parseInt(el.css(
"top"), 10)
4043 if (typeof(o.alsoResize) ===
"object" && !o.alsoResize.parentNode) {
4044 if (o.alsoResize.length) {
4045 o.alsoResize = o.alsoResize[0];
4046 _store(o.alsoResize);
4048 $.each(o.alsoResize,
function(exp) {
4053 _store(o.alsoResize);
4057 resize:
function(event, ui) {
4058 var that = $(
this).resizable(
"instance" ),
4060 os = that.originalSize,
4061 op = that.originalPosition,
4063 height: (that.size.height - os.height) || 0,
4064 width: (that.size.width - os.width) || 0,
4065 top: (that.position.top - op.top) || 0,
4066 left: (that.position.left - op.left) || 0
4069 _alsoResize =
function(exp, c) {
4070 $(exp).
each(
function() {
4071 var el = $(
this),
start = $(
this).data(
"ui-resizable-alsoresize"), style = {},
4072 css = c && c.length ?
4074 el.parents(ui.originalElement[0]).length ?
4075 [
"width",
"height" ] :
4076 [
"width",
"height",
"top",
"left" ];
4078 $.each(css,
function(i, prop) {
4079 var sum = (
start[prop] || 0) + (delta[prop] || 0);
4080 if (sum && sum >= 0) {
4081 style[prop] = sum || null;
4089 if (typeof(o.alsoResize) ===
"object" && !o.alsoResize.nodeType) {
4090 $.each(o.alsoResize,
function(exp, c) {
4091 _alsoResize(exp, c);
4094 _alsoResize(o.alsoResize);
4099 $(
this).removeData(
"resizable-alsoresize");
4103 $.ui.plugin.add(
"resizable",
"ghost", {
4107 var that = $(
this).resizable(
"instance" ), o = that.options, cs = that.size;
4109 that.ghost = that.originalElement.clone();
4114 position:
"relative",
4122 .addClass(typeof o.ghost ===
"string" ? o.ghost :
"");
4124 that.ghost.appendTo(that.helper);
4128 resize:
function() {
4129 var that = $(
this).resizable(
"instance" );
4132 position:
"relative",
4133 height: that.size.height,
4134 width: that.size.width
4140 var that = $(
this).resizable(
"instance" );
4141 if (that.ghost && that.helper) {
4142 that.helper.get(0).removeChild(that.ghost.get(0));
4148 $.ui.plugin.add(
"resizable",
"grid", {
4150 resize:
function() {
4151 var outerDimensions,
4152 that = $(
this).resizable(
"instance" ),
4155 os = that.originalSize,
4156 op = that.originalPosition,
4158 grid = typeof o.grid ===
"number" ? [ o.grid, o.grid ] : o.grid,
4159 gridX = (grid[0] || 1),
4160 gridY = (grid[1] || 1),
4161 ox = Math.round((cs.width - os.width) / gridX) * gridX,
4162 oy = Math.round((cs.height - os.height) / gridY) * gridY,
4163 newWidth = os.width + ox,
4164 newHeight = os.height + oy,
4165 isMaxWidth = o.maxWidth && (o.maxWidth < newWidth),
4166 isMaxHeight = o.maxHeight && (o.maxHeight < newHeight),
4167 isMinWidth = o.minWidth && (o.minWidth > newWidth),
4168 isMinHeight = o.minHeight && (o.minHeight > newHeight);
4185 if (/^(
se|s|
e)$/.test(a)) {
4186 that.size.width = newWidth;
4187 that.size.height = newHeight;
4188 }
else if (/^(ne)$/.test(a)) {
4189 that.size.width = newWidth;
4190 that.size.height = newHeight;
4191 that.position.top = op.top - oy;
4192 }
else if (/^(sw)$/.test(a)) {
4193 that.size.width = newWidth;
4194 that.size.height = newHeight;
4195 that.position.left = op.left - ox;
4197 if ( newHeight - gridY <= 0 || newWidth - gridX <= 0) {
4198 outerDimensions = that._getPaddingPlusBorderDimensions(
this );
4201 if ( newHeight - gridY > 0 ) {
4202 that.size.height = newHeight;
4203 that.position.top = op.top - oy;
4205 newHeight = gridY - outerDimensions.height;
4206 that.size.height = newHeight;
4207 that.position.top = op.top + os.height - newHeight;
4209 if ( newWidth - gridX > 0 ) {
4210 that.size.width = newWidth;
4211 that.position.left = op.left - ox;
4213 newWidth = gridY - outerDimensions.height;
4214 that.size.width = newWidth;
4215 that.position.left = op.left + os.width - newWidth;
4222 var resizable = $.ui.resizable;
4237 var selectable = $.widget(
"ui.selectable", $.ui.mouse, {
4254 _create:
function() {
4258 this.element.addClass(
"ui-selectable");
4260 this.dragged = false;
4263 this.refresh = function() {
4264 selectees = $(that.options.filter, that.element[0]);
4265 selectees.addClass(
"ui-selectee");
4266 selectees.each(function() {
4267 var $this = $(this),
4268 pos = $this.offset();
4269 $.data(this,
"selectable-item", {
4274 right: pos.left + $this.outerWidth(),
4275 bottom: pos.top + $this.outerHeight(),
4276 startselected: false,
4277 selected: $this.hasClass(
"ui-selected"),
4278 selecting: $this.hasClass(
"ui-selecting"),
4279 unselecting: $this.hasClass(
"ui-unselecting")
4285 this.selectees = selectees.addClass(
"ui-selectee");
4289 this.helper = $(
"<div class='ui-selectable-helper'></div>");
4292 _destroy:
function() {
4294 .removeClass(
"ui-selectee")
4295 .removeData(
"selectable-item");
4297 .removeClass(
"ui-selectable ui-selectable-disabled");
4298 this._mouseDestroy();
4301 _mouseStart:
function(event) {
4303 options = this.options;
4305 this.opos = [
event.pageX,
event.pageY ];
4307 if (this.options.disabled) {
4311 this.selectees = $(options.filter, this.element[0]);
4313 this._trigger(
"start", event);
4315 $(options.appendTo).append(this.helper);
4318 "left":
event.pageX,
4324 if (options.autoRefresh) {
4328 this.selectees.filter(
".ui-selected").each(
function() {
4329 var selectee = $.data(
this,
"selectable-item");
4330 selectee.startselected =
true;
4331 if (!event.metaKey && !event.ctrlKey) {
4332 selectee.$element.removeClass(
"ui-selected");
4333 selectee.selected =
false;
4334 selectee.$element.addClass(
"ui-unselecting");
4335 selectee.unselecting =
true;
4337 that._trigger(
"unselecting", event, {
4338 unselecting: selectee.element
4343 $(
event.target).parents().addBack().each(
function() {
4345 selectee = $.data(
this,
"selectable-item");
4347 doSelect = (!
event.metaKey && !
event.ctrlKey) || !selectee.$element.hasClass(
"ui-selected");
4349 .removeClass(doSelect ?
"ui-unselecting" :
"ui-selected")
4350 .addClass(doSelect ?
"ui-selecting" :
"ui-unselecting");
4351 selectee.unselecting = !doSelect;
4352 selectee.selecting = doSelect;
4353 selectee.selected = doSelect;
4356 that._trigger(
"selecting", event, {
4357 selecting: selectee.element
4360 that._trigger(
"unselecting", event, {
4361 unselecting: selectee.element
4370 _mouseDrag:
function(event) {
4372 this.dragged =
true;
4374 if (this.options.disabled) {
4380 options = this.options,
4386 if (x1 > x2) { tmp = x2; x2 = x1; x1 = tmp; }
4387 if (y1 > y2) { tmp = y2; y2 = y1; y1 = tmp; }
4388 this.helper.css({ left: x1, top: y1, width: x2 - x1, height: y2 - y1 });
4390 this.selectees.each(
function() {
4391 var selectee = $.data(
this,
"selectable-item"),
4395 if (!selectee || selectee.element === that.element[0]) {
4399 if (options.tolerance ===
"touch") {
4400 hit = ( !(selectee.left > x2 || selectee.right < x1 || selectee.top > y2 || selectee.bottom < y1) );
4401 }
else if (options.tolerance ===
"fit") {
4402 hit = (selectee.left > x1 && selectee.right < x2 && selectee.top > y1 && selectee.bottom < y2);
4407 if (selectee.selected) {
4408 selectee.$element.removeClass(
"ui-selected");
4409 selectee.selected =
false;
4411 if (selectee.unselecting) {
4412 selectee.$element.removeClass(
"ui-unselecting");
4413 selectee.unselecting =
false;
4415 if (!selectee.selecting) {
4416 selectee.$element.addClass(
"ui-selecting");
4417 selectee.selecting =
true;
4419 that._trigger(
"selecting", event, {
4420 selecting: selectee.element
4425 if (selectee.selecting) {
4426 if ((event.metaKey || event.ctrlKey) && selectee.startselected) {
4427 selectee.$element.removeClass(
"ui-selecting");
4428 selectee.selecting =
false;
4429 selectee.$element.addClass(
"ui-selected");
4430 selectee.selected =
true;
4432 selectee.$element.removeClass(
"ui-selecting");
4433 selectee.selecting =
false;
4434 if (selectee.startselected) {
4435 selectee.$element.addClass(
"ui-unselecting");
4436 selectee.unselecting =
true;
4439 that._trigger(
"unselecting", event, {
4440 unselecting: selectee.element
4444 if (selectee.selected) {
4445 if (!event.metaKey && !event.ctrlKey && !selectee.startselected) {
4446 selectee.$element.removeClass(
"ui-selected");
4447 selectee.selected =
false;
4449 selectee.$element.addClass(
"ui-unselecting");
4450 selectee.unselecting =
true;
4452 that._trigger(
"unselecting", event, {
4453 unselecting: selectee.element
4463 _mouseStop:
function(event) {
4466 this.dragged =
false;
4468 $(
".ui-unselecting", this.element[0]).
each(
function() {
4469 var selectee = $.data(
this,
"selectable-item");
4470 selectee.$element.removeClass(
"ui-unselecting");
4471 selectee.unselecting =
false;
4472 selectee.startselected =
false;
4473 that._trigger(
"unselected", event, {
4474 unselected: selectee.element
4477 $(
".ui-selecting", this.element[0]).
each(
function() {
4478 var selectee = $.data(
this,
"selectable-item");
4479 selectee.$element.removeClass(
"ui-selecting").addClass(
"ui-selected");
4480 selectee.selecting =
false;
4481 selectee.selected =
true;
4482 selectee.startselected =
true;
4483 that._trigger(
"selected", event, {
4484 selected: selectee.element
4487 this._trigger(
"stop", event);
4489 this.helper.remove();
4509 var sortable = $.widget(
"ui.sortable", $.ui.mouse, {
4511 widgetEventPrefix:
"sort",
4521 forcePlaceholderSize: false,
4522 forceHelperSize: false,
4531 scrollSensitivity: 20,
4534 tolerance:
"intersect",
4552 _isOverAxis:
function( x, reference,
size ) {
4553 return ( x >= reference ) && ( x < ( reference + size ) );
4556 _isFloating:
function( item ) {
4557 return (/left|right/).test(item.css(
"float")) || (/inline|table-cell/).test(item.css(
"display"));
4560 _create:
function() {
4562 var o = this.options;
4563 this.containerCache = {};
4564 this.element.addClass(
"ui-sortable");
4570 this.floating = this.items.length ? o.axis ===
"x" || this._isFloating(this.items[0].item) : false;
4573 this.
offset = this.element.offset();
4578 this._setHandleClassName();
4585 _setOption:
function( key, value ) {
4586 this._super( key, value );
4588 if ( key ===
"handle" ) {
4589 this._setHandleClassName();
4593 _setHandleClassName:
function() {
4594 this.element.find(
".ui-sortable-handle" ).removeClass(
"ui-sortable-handle" );
4595 $.each( this.items,
function() {
4596 ( this.instance.options.handle ?
4597 this.item.find( this.instance.options.handle ) : this.item )
4602 _destroy:
function() {
4604 .removeClass(
"ui-sortable ui-sortable-disabled" )
4605 .find(
".ui-sortable-handle" )
4606 .removeClass(
"ui-sortable-handle" );
4607 this._mouseDestroy();
4609 for ( var i = this.items.length - 1; i >= 0; i-- ) {
4610 this.items[i].item.removeData(this.widgetName +
"-item");
4616 _mouseCapture:
function(event, overrideHandle) {
4617 var currentItem = null,
4618 validHandle =
false,
4621 if (this.reverting) {
4625 if(this.options.disabled ||
this.options.type ===
"static") {
4630 this._refreshItems(event);
4633 $(
event.target).parents().each(
function() {
4634 if($.data(
this, that.widgetName +
"-item") === that) {
4635 currentItem = $(this);
4639 if($.data(event.target, that.widgetName +
"-item") === that) {
4640 currentItem = $(
event.target);
4646 if(this.options.handle && !overrideHandle) {
4647 $(this.options.handle, currentItem).find(
"*").addBack().each(
function() {
4648 if(
this === event.target) {
4657 this.currentItem = currentItem;
4658 this._removeCurrentsFromItems();
4663 _mouseStart:
function(event, overrideHandle, noActivation) {
4668 this.currentContainer =
this;
4671 this.refreshPositions();
4674 this.helper = this._createHelper(event);
4677 this._cacheHelperProportions();
4685 this._cacheMargins();
4688 this.scrollParent = this.helper.scrollParent();
4691 this.
offset = this.currentItem.offset();
4693 top: this.
offset.top - this.margins.top,
4694 left: this.
offset.left - this.margins.left
4699 left:
event.pageX - this.
offset.left,
4700 top:
event.pageY - this.
offset.top
4702 parent: this._getParentOffset(),
4703 relative: this._getRelativeOffset()
4708 this.helper.css(
"position",
"absolute");
4709 this.cssPosition = this.helper.css(
"position");
4712 this.originalPosition = this._generatePosition(event);
4713 this.originalPageX =
event.pageX;
4714 this.originalPageY =
event.pageY;
4717 (o.cursorAt && this._adjustOffsetFromHelper(o.cursorAt));
4720 this.domPosition = { prev: this.currentItem.prev()[0], parent: this.currentItem.parent()[0] };
4723 if(this.helper[0] !== this.currentItem[0]) {
4724 this.currentItem.hide();
4728 this._createPlaceholder();
4732 this._setContainment();
4735 if( o.cursor && o.cursor !==
"auto" ) {
4736 body = this.document.find(
"body" );
4739 this.storedCursor = body.css(
"cursor" );
4740 body.css(
"cursor", o.cursor );
4742 this.storedStylesheet = $(
"<style>*{ cursor: "+o.cursor+
" !important; }</style>" ).appendTo( body );
4746 if (this.helper.css(
"opacity")) {
4747 this._storedOpacity = this.helper.css(
"opacity");
4749 this.helper.css(
"opacity", o.opacity);
4753 if (this.helper.css(
"zIndex")) {
4754 this._storedZIndex = this.helper.css(
"zIndex");
4756 this.helper.css(
"zIndex", o.zIndex);
4760 if(this.scrollParent[0] !== document && this.scrollParent[0].tagName !==
"HTML") {
4761 this.overflowOffset = this.scrollParent.offset();
4765 this._trigger(
"start", event, this._uiHash());
4768 if(!this._preserveHelperProportions) {
4769 this._cacheHelperProportions();
4774 if( !noActivation ) {
4775 for ( i = this.containers.length - 1; i >= 0; i-- ) {
4776 this.containers[ i ]._trigger(
"activate", event, this._uiHash(
this ) );
4781 if($.ui.ddmanager) {
4782 $.ui.ddmanager.current =
this;
4785 if ($.ui.ddmanager && !o.dropBehaviour) {
4786 $.ui.ddmanager.prepareOffsets(
this, event);
4791 this.helper.addClass(
"ui-sortable-helper");
4792 this._mouseDrag(event);
4797 _mouseDrag:
function(event) {
4798 var i, item, itemElement, intersection,
4803 this.position = this._generatePosition(event);
4804 this.positionAbs = this._convertPositionTo(
"absolute");
4806 if (!this.lastPositionAbs) {
4807 this.lastPositionAbs = this.positionAbs;
4811 if(this.options.scroll) {
4812 if(this.scrollParent[0] !== document && this.scrollParent[0].tagName !==
"HTML") {
4814 if((this.overflowOffset.top +
this.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity) {
4815 this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop + o.scrollSpeed;
4816 }
else if(event.pageY -
this.overflowOffset.top < o.scrollSensitivity) {
4817 this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop - o.scrollSpeed;
4820 if((this.overflowOffset.left +
this.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity) {
4821 this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft + o.scrollSpeed;
4822 }
else if(event.pageX -
this.overflowOffset.left < o.scrollSensitivity) {
4823 this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft - o.scrollSpeed;
4828 if(event.pageY - $(document).scrollTop() < o.scrollSensitivity) {
4829 scrolled = $(document).
scrollTop($(document).scrollTop() - o.scrollSpeed);
4830 }
else if($(
window).height() - (
event.pageY - $(document).
scrollTop()) < o.scrollSensitivity) {
4831 scrolled = $(document).
scrollTop($(document).scrollTop() + o.scrollSpeed);
4834 if(event.pageX - $(document).scrollLeft() < o.scrollSensitivity) {
4835 scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed);
4836 }
else if($(
window).width() - (
event.pageX - $(document).scrollLeft()) < o.scrollSensitivity) {
4837 scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);
4842 if(scrolled !==
false && $.ui.ddmanager && !o.dropBehaviour) {
4843 $.ui.ddmanager.prepareOffsets(
this, event);
4848 this.positionAbs = this._convertPositionTo(
"absolute");
4851 if(!this.options.axis ||
this.options.axis !==
"y") {
4852 this.helper[0].style.left = this.position.left+
"px";
4854 if(!this.options.axis ||
this.options.axis !==
"x") {
4855 this.helper[0].style.top = this.position.top+
"px";
4859 for (i = this.items.length - 1; i >= 0; i--) {
4862 item = this.items[i];
4863 itemElement = item.item[0];
4864 intersection = this._intersectsWithPointer(item);
4865 if (!intersection) {
4876 if (item.instance !==
this.currentContainer) {
4883 if (itemElement !== this.currentItem[0] &&
4884 this.placeholder[intersection === 1 ?
"next" :
"prev"]()[0] !== itemElement &&
4885 !$.contains(this.placeholder[0], itemElement) &&
4886 (this.options.type ===
"semi-dynamic" ? !$.contains(
this.element[0], itemElement) :
true)
4889 this.direction = intersection === 1 ?
"down" :
"up";
4891 if (this.options.tolerance ===
"pointer" ||
this._intersectsWithSides(item)) {
4892 this._rearrange(event, item);
4897 this._trigger(
"change", event, this._uiHash());
4903 this._contactContainers(event);
4906 if($.ui.ddmanager) {
4907 $.ui.ddmanager.drag(
this, event);
4911 this._trigger(
"sort", event, this._uiHash());
4913 this.lastPositionAbs = this.positionAbs;
4918 _mouseStop:
function(event, noPropagation) {
4925 if ($.ui.ddmanager && !
this.options.dropBehaviour) {
4926 $.ui.ddmanager.drop(
this, event);
4929 if(this.options.revert) {
4931 cur = this.placeholder.offset(),
4932 axis = this.options.axis,
4935 if ( !axis || axis ===
"x" ) {
4936 animation.left = cur.left - this.
offset.parent.left - this.margins.left + (this.offsetParent[0] === document.body ? 0 : this.offsetParent[0].scrollLeft);
4938 if ( !axis || axis ===
"y" ) {
4939 animation.top = cur.top - this.
offset.parent.top - this.margins.top + (this.offsetParent[0] === document.body ? 0 : this.offsetParent[0].scrollTop);
4941 this.reverting =
true;
4942 $(this.helper).animate(
animation, parseInt(this.options.revert, 10) || 500,
function() {
4946 this._clear(event, noPropagation);
4953 cancel:
function() {
4957 this._mouseUp({ target: null });
4959 if(this.options.helper ===
"original") {
4960 this.currentItem.css(this._storedCSS).removeClass(
"ui-sortable-helper");
4962 this.currentItem.show();
4966 for (var i = this.containers.length - 1; i >= 0; i--){
4967 this.containers[i]._trigger(
"deactivate", null, this._uiHash(
this));
4968 if(this.containers[i].containerCache.over) {
4969 this.containers[i]._trigger(
"out", null, this._uiHash(
this));
4970 this.containers[i].containerCache.over = 0;
4976 if (this.placeholder) {
4978 if(this.placeholder[0].parentNode) {
4979 this.placeholder[0].parentNode.removeChild(this.placeholder[0]);
4981 if(this.options.helper !==
"original" &&
this.helper &&
this.helper[0].parentNode) {
4982 this.helper.remove();
4992 if(this.domPosition.prev) {
4993 $(this.domPosition.prev).after(this.currentItem);
4995 $(this.domPosition.parent).prepend(this.currentItem);
5003 serialize:
function(o) {
5005 var items = this._getItemsAsjQuery(o && o.connected),
5009 $(items).
each(
function() {
5010 var res = ($(o.item ||
this).attr(o.attribute ||
"id") ||
"").match(o.expression || (/(.+)[\-=_](.+)/));
5012 str.push((o.key || res[1]+
"[]")+
"="+(o.key && o.expression ? res[1] : res[2]));
5016 if(!str.length && o.key) {
5017 str.push(o.key +
"=");
5020 return str.join(
"&");
5024 toArray:
function(o) {
5026 var items = this._getItemsAsjQuery(o && o.connected),
5031 items.each(
function() { ret.push($(o.item ||
this).attr(o.attribute ||
"id") ||
""); });
5037 _intersectsWith:
function(item) {
5039 var x1 = this.positionAbs.left,
5040 x2 = x1 + this.helperProportions.width,
5041 y1 = this.positionAbs.top,
5042 y2 = y1 + this.helperProportions.height,
5046 b = t + item.height,
5047 dyClick = this.
offset.click.top,
5048 dxClick = this.
offset.click.left,
5049 isOverElementHeight = ( this.options.axis ===
"x" ) || ( ( y1 + dyClick ) > t && ( y1 + dyClick ) < b ),
5050 isOverElementWidth = ( this.options.axis ===
"y" ) || ( ( x1 + dxClick ) > l && ( x1 + dxClick ) < r ),
5051 isOverElement = isOverElementHeight && isOverElementWidth;
5053 if ( this.options.tolerance ===
"pointer" ||
5054 this.options.forcePointerForContainers ||
5055 (
this.options.tolerance !==
"pointer" &&
this.helperProportions[
this.floating ?
"width" :
"height"] > item[
this.floating ?
"width" :
"height"])
5057 return isOverElement;
5060 return (l < x1 + (this.helperProportions.width / 2) &&
5061 x2 - (this.helperProportions.width / 2) < r &&
5062 t < y1 + (this.helperProportions.height / 2) &&
5063 y2 - (this.helperProportions.height / 2) < b );
5068 _intersectsWithPointer:
function(item) {
5070 var isOverElementHeight = (this.options.axis ===
"x") || this._isOverAxis(this.positionAbs.top +
this.offset.click.top, item.top, item.height),
5071 isOverElementWidth = (this.options.axis ===
"y") || this._isOverAxis(this.positionAbs.left +
this.offset.click.left, item.left, item.width),
5072 isOverElement = isOverElementHeight && isOverElementWidth,
5073 verticalDirection = this._getDragVerticalDirection(),
5074 horizontalDirection = this._getDragHorizontalDirection();
5076 if (!isOverElement) {
5080 return this.floating ?
5081 ( ((horizontalDirection && horizontalDirection ===
"right") || verticalDirection ===
"down") ? 2 : 1 )
5082 : ( verticalDirection && (verticalDirection ===
"down" ? 2 : 1) );
5086 _intersectsWithSides:
function(item) {
5088 var isOverBottomHalf = this._isOverAxis(this.positionAbs.top +
this.offset.click.top, item.top + (item.height/2), item.height),
5089 isOverRightHalf = this._isOverAxis(this.positionAbs.left +
this.offset.click.left, item.left + (item.width/2), item.width),
5090 verticalDirection = this._getDragVerticalDirection(),
5091 horizontalDirection = this._getDragHorizontalDirection();
5093 if (this.floating && horizontalDirection) {
5094 return ((horizontalDirection ===
"right" && isOverRightHalf) || (horizontalDirection ===
"left" && !isOverRightHalf));
5096 return verticalDirection && ((verticalDirection ===
"down" && isOverBottomHalf) || (verticalDirection ===
"up" && !isOverBottomHalf));
5101 _getDragVerticalDirection:
function() {
5102 var delta = this.positionAbs.top - this.lastPositionAbs.top;
5103 return delta !== 0 && (delta > 0 ?
"down" :
"up");
5106 _getDragHorizontalDirection:
function() {
5107 var delta = this.positionAbs.left - this.lastPositionAbs.left;
5108 return delta !== 0 && (delta > 0 ?
"right" :
"left");
5111 refresh:
function(event) {
5112 this._refreshItems(event);
5113 this._setHandleClassName();
5114 this.refreshPositions();
5118 _connectWith:
function() {
5119 var options = this.options;
5120 return options.connectWith.constructor === String ? [options.connectWith] : options.connectWith;
5123 _getItemsAsjQuery:
function(connected) {
5125 var i, j, cur, inst,
5128 connectWith = this._connectWith();
5130 if(connectWith && connected) {
5131 for (i = connectWith.length - 1; i >= 0; i--){
5132 cur = $(connectWith[i]);
5133 for ( j = cur.length - 1; j >= 0; j--){
5134 inst = $.data(cur[j], this.widgetFullName);
5135 if(inst && inst !==
this && !inst.options.disabled) {
5136 queries.push([$.isFunction(inst.options.items) ? inst.options.items.call(inst.element) : $(inst.options.items, inst.element).not(
".ui-sortable-helper").not(
".ui-sortable-placeholder"), inst]);
5142 queries.push([$.isFunction(this.options.items) ?
this.options.items.call(
this.element, null, { options: this.options, item: this.currentItem }) : $(this.options.items, this.element).not(
".ui-sortable-helper").not(
".ui-sortable-placeholder"),
this]);
5144 function addItems() {
5147 for (i = queries.length - 1; i >= 0; i--){
5148 queries[i][0].each( addItems );
5155 _removeCurrentsFromItems:
function() {
5157 var list = this.currentItem.find(
":data(" + this.widgetName +
"-item)");
5159 this.items = $.grep(this.items,
function (item) {
5160 for (var j=0; j < list.length; j++) {
5161 if(list[j] === item.item[0]) {
5170 _refreshItems:
function(event) {
5173 this.containers = [
this];
5175 var i, j, cur, inst, targetData, _queries, item, queriesLength,
5177 queries = [[$.isFunction(this.options.items) ? this.options.items.call(this.element[0], event, { item: this.currentItem }) : $(this.options.items,
this.element),
this]],
5178 connectWith = this._connectWith();
5180 if(connectWith && this.
ready) {
5181 for (i = connectWith.length - 1; i >= 0; i--){
5182 cur = $(connectWith[i]);
5183 for (j = cur.length - 1; j >= 0; j--){
5184 inst = $.data(cur[j], this.widgetFullName);
5185 if(inst && inst !==
this && !inst.options.disabled) {
5186 queries.push([$.isFunction(inst.options.items) ? inst.options.items.call(inst.element[0], event, { item: this.currentItem }) : $(inst.options.items, inst.element), inst]);
5187 this.containers.push(inst);
5193 for (i = queries.length - 1; i >= 0; i--) {
5194 targetData = queries[i][1];
5195 _queries = queries[i][0];
5197 for (j=0, queriesLength = _queries.length; j < queriesLength; j++) {
5198 item = $(_queries[j]);
5200 item.data(this.widgetName +
"-item", targetData);
5204 instance: targetData,
5205 width: 0, height: 0,
5213 refreshPositions:
function(fast) {
5216 if(this.offsetParent && this.helper) {
5217 this.
offset.parent = this._getParentOffset();
5222 for (i = this.items.length - 1; i >= 0; i--){
5223 item = this.items[i];
5226 if(item.instance !==
this.currentContainer &&
this.currentContainer && item.item[0] !==
this.currentItem[0]) {
5230 t = this.options.toleranceElement ? $(this.options.toleranceElement, item.item) : item.item;
5233 item.width = t.outerWidth();
5234 item.height = t.outerHeight();
5242 if(this.options.custom &&
this.options.custom.refreshContainers) {
5243 this.options.custom.refreshContainers.call(
this);
5245 for (i = this.containers.length - 1; i >= 0; i--){
5246 p = this.containers[i].element.offset();
5247 this.containers[i].containerCache.left = p.left;
5248 this.containers[i].containerCache.top = p.top;
5249 this.containers[i].containerCache.width = this.containers[i].element.outerWidth();
5250 this.containers[i].containerCache.height = this.containers[i].element.outerHeight();
5257 _createPlaceholder:
function(that) {
5258 that = that ||
this;
5262 if(!o.placeholder || o.placeholder.constructor === String) {
5263 className = o.placeholder;
5265 element:
function() {
5267 var nodeName = that.currentItem[0].nodeName.toLowerCase(),
5268 element = $(
"<" + nodeName +
">", that.document[0] )
5269 .
addClass(className || that.currentItem[0].className+
" ui-sortable-placeholder")
5270 .removeClass(
"ui-sortable-helper");
5272 if ( nodeName ===
"tr" ) {
5273 that.currentItem.children().each(
function() {
5274 $(
"<td> </td>", that.document[0] )
5275 .attr(
"colspan", $(
this ).attr(
"colspan" ) || 1 )
5276 .appendTo( element );
5278 }
else if ( nodeName ===
"img" ) {
5279 element.attr(
"src", that.currentItem.attr(
"src" ) );
5283 element.css(
"visibility",
"hidden" );
5288 update:
function(container, p) {
5292 if(className && !o.forcePlaceholderSize) {
5297 if(!p.height()) { p.height(that.currentItem.innerHeight() - parseInt(that.currentItem.css(
"paddingTop")||0, 10) - parseInt(that.currentItem.css(
"paddingBottom")||0, 10)); }
5298 if(!p.width()) { p.width(that.currentItem.innerWidth() - parseInt(that.currentItem.css(
"paddingLeft")||0, 10) - parseInt(that.currentItem.css(
"paddingRight")||0, 10)); }
5304 that.placeholder = $(o.placeholder.element.call(that.element, that.currentItem));
5307 that.currentItem.after(that.placeholder);
5310 o.placeholder.update(that, that.placeholder);
5314 _contactContainers:
function(event) {
5315 var i, j, dist, itemWithLeastDistance, posProperty, sizeProperty, cur, nearBottom, floating, axis,
5316 innermostContainer = null,
5317 innermostIndex = null;
5320 for (i = this.containers.length - 1; i >= 0; i--) {
5323 if($.contains(this.currentItem[0], this.containers[i].element[0])) {
5327 if(this._intersectsWith(this.containers[i].containerCache)) {
5330 if(innermostContainer && $.contains(this.containers[i].element[0], innermostContainer.element[0])) {
5334 innermostContainer = this.containers[i];
5339 if(this.containers[i].containerCache.over) {
5340 this.containers[i]._trigger(
"out", event, this._uiHash(
this));
5341 this.containers[i].containerCache.over = 0;
5348 if(!innermostContainer) {
5353 if(this.containers.length === 1) {
5354 if (!this.containers[innermostIndex].containerCache.over) {
5355 this.containers[innermostIndex]._trigger(
"over", event, this._uiHash(
this));
5356 this.containers[innermostIndex].containerCache.over = 1;
5362 itemWithLeastDistance = null;
5363 floating = innermostContainer.floating || this._isFloating(this.currentItem);
5364 posProperty = floating ?
"left" :
"top";
5365 sizeProperty = floating ?
"width" :
"height";
5366 axis = floating ?
"clientX" :
"clientY";
5368 for (j = this.items.length - 1; j >= 0; j--) {
5369 if(!$.contains(this.containers[innermostIndex].element[0], this.items[j].item[0])) {
5372 if(this.items[j].item[0] === this.currentItem[0]) {
5376 cur = this.items[j].item.offset()[posProperty];
5378 if ( event[ axis ] - cur > this.items[ j ][ sizeProperty ] / 2 ) {
5382 if ( Math.abs( event[ axis ] - cur ) < dist ) {
5383 dist = Math.abs( event[ axis ] - cur );
5384 itemWithLeastDistance = this.items[ j ];
5385 this.direction = nearBottom ?
"up":
"down";
5390 if(!itemWithLeastDistance && !this.options.dropOnEmpty) {
5394 if(this.currentContainer === this.containers[innermostIndex]) {
5395 if ( !this.currentContainer.containerCache.over ) {
5396 this.containers[ innermostIndex ]._trigger(
"over", event, this._uiHash() );
5397 this.currentContainer.containerCache.over = 1;
5402 itemWithLeastDistance ? this._rearrange(event, itemWithLeastDistance, null,
true) : this._rearrange(event, null, this.containers[innermostIndex].element, true);
5403 this._trigger(
"change", event, this._uiHash());
5404 this.containers[innermostIndex]._trigger(
"change", event, this._uiHash(
this));
5405 this.currentContainer = this.containers[innermostIndex];
5408 this.options.placeholder.update(this.currentContainer, this.placeholder);
5410 this.containers[innermostIndex]._trigger(
"over", event, this._uiHash(
this));
5411 this.containers[innermostIndex].containerCache.over = 1;
5417 _createHelper:
function(event) {
5419 var o = this.options,
5420 helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [event, this.currentItem])) : (o.helper ===
"clone" ?
this.currentItem.clone() : this.currentItem);
5423 if(!helper.parents(
"body").length) {
5424 $(o.appendTo !==
"parent" ? o.appendTo : this.currentItem[0].parentNode)[0].appendChild(helper[0]);
5427 if(helper[0] === this.currentItem[0]) {
5428 this._storedCSS = { width: this.currentItem[0].style.width, height: this.currentItem[0].style.height, position: this.currentItem.css(
"position"), top: this.currentItem.css(
"top"), left: this.currentItem.css(
"left") };
5431 if(!helper[0].style.width || o.forceHelperSize) {
5432 helper.width(this.currentItem.width());
5434 if(!helper[0].style.height || o.forceHelperSize) {
5435 helper.height(this.currentItem.height());
5442 _adjustOffsetFromHelper:
function(obj) {
5443 if (typeof obj ===
"string") {
5444 obj = obj.split(
" ");
5446 if ($.isArray(obj)) {
5447 obj = {left: +obj[0], top: +obj[1] || 0};
5449 if (
"left" in obj) {
5450 this.
offset.click.left = obj.left + this.margins.left;
5452 if (
"right" in obj) {
5453 this.
offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
5456 this.
offset.click.top = obj.top + this.margins.top;
5458 if (
"bottom" in obj) {
5459 this.
offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
5463 _getParentOffset:
function() {
5467 this.offsetParent = this.helper.offsetParent();
5468 var po = this.offsetParent.offset();
5474 if(this.cssPosition ===
"absolute" && this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) {
5475 po.left += this.scrollParent.scrollLeft();
5476 po.top += this.scrollParent.scrollTop();
5481 if( this.offsetParent[0] === document.body || (
this.offsetParent[0].tagName &&
this.offsetParent[0].tagName.toLowerCase() ===
"html" && $.ui.ie)) {
5482 po = { top: 0, left: 0 };
5486 top: po.top + (parseInt(this.offsetParent.css(
"borderTopWidth"),10) || 0),
5487 left: po.left + (parseInt(this.offsetParent.css(
"borderLeftWidth"),10) || 0)
5492 _getRelativeOffset:
function() {
5494 if(this.cssPosition ===
"relative") {
5495 var p = this.currentItem.position();
5497 top: p.top - (parseInt(this.helper.css(
"top"),10) || 0) + this.scrollParent.scrollTop(),
5498 left: p.left - (parseInt(this.helper.css(
"left"),10) || 0) + this.scrollParent.scrollLeft()
5501 return { top: 0, left: 0 };
5506 _cacheMargins:
function() {
5508 left: (parseInt(this.currentItem.css(
"marginLeft"),10) || 0),
5509 top: (parseInt(this.currentItem.css(
"marginTop"),10) || 0)
5513 _cacheHelperProportions:
function() {
5514 this.helperProportions = {
5515 width: this.helper.outerWidth(),
5516 height: this.helper.outerHeight()
5520 _setContainment:
function() {
5524 if(o.containment ===
"parent") {
5525 o.containment = this.helper[0].parentNode;
5527 if(o.containment ===
"document" || o.containment ===
"window") {
5528 this.containment = [
5529 0 - this.
offset.relative.left - this.
offset.parent.left,
5531 $(o.containment ===
"document" ? document :
window).
width() - this.helperProportions.width - this.margins.left,
5532 ($(o.containment ===
"document" ? document :
window).
height() || document.body.parentNode.scrollHeight) - this.helperProportions.height -
this.margins.top
5536 if(!(/^(document|
window|parent)$/).test(o.containment)) {
5537 ce = $(o.containment)[0];
5538 co = $(o.containment).
offset();
5539 over = ($(ce).css(
"overflow") !==
"hidden");
5541 this.containment = [
5542 co.left + (parseInt($(ce).css(
"borderLeftWidth"),10) || 0) + (parseInt($(ce).css(
"paddingLeft"),10) || 0) - this.margins.left,
5543 co.top + (parseInt($(ce).css(
"borderTopWidth"),10) || 0) + (parseInt($(ce).css(
"paddingTop"),10) || 0) - this.margins.top,
5544 co.left+(over ? Math.max(ce.scrollWidth,ce.offsetWidth) : ce.offsetWidth) - (parseInt($(ce).css(
"borderLeftWidth"),10) || 0) - (parseInt($(ce).css(
"paddingRight"),10) || 0) - this.helperProportions.width -
this.margins.left,
5545 co.top+(over ? Math.max(ce.scrollHeight,ce.offsetHeight) : ce.offsetHeight) - (parseInt($(ce).css(
"borderTopWidth"),10) || 0) - (parseInt($(ce).css(
"paddingBottom"),10) || 0) - this.helperProportions.height -
this.margins.top
5551 _convertPositionTo:
function(
d, pos) {
5554 pos = this.position;
5556 var mod =
d ===
"absolute" ? 1 : -1,
5557 scroll = this.cssPosition ===
"absolute" && !(this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent,
5558 scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
5563 this.
offset.relative.top * mod +
5564 this.
offset.parent.top * mod -
5565 ( ( this.cssPosition ===
"fixed" ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod)
5569 this.
offset.relative.left * mod +
5570 this.
offset.parent.left * mod -
5571 ( ( this.cssPosition ===
"fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ) * mod)
5577 _generatePosition:
function(event) {
5581 pageX =
event.pageX,
5582 pageY =
event.pageY,
5583 scroll = this.cssPosition ===
"absolute" && !(this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
5589 if(this.cssPosition ===
"relative" && !(this.scrollParent[0] !== document && this.scrollParent[0] !== this.offsetParent[0])) {
5590 this.
offset.relative = this._getRelativeOffset();
5598 if(this.originalPosition) {
5600 if(this.containment) {
5601 if(event.pageX -
this.offset.click.left <
this.containment[0]) {
5602 pageX = this.containment[0] + this.
offset.click.left;
5604 if(event.pageY -
this.offset.click.top <
this.containment[1]) {
5605 pageY = this.containment[1] + this.
offset.click.top;
5607 if(event.pageX -
this.offset.click.left >
this.containment[2]) {
5608 pageX = this.containment[2] + this.
offset.click.left;
5610 if(event.pageY -
this.offset.click.top >
this.containment[3]) {
5611 pageY = this.containment[3] + this.
offset.click.top;
5616 top = this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1];
5617 pageY = this.containment ? ( (top - this.
offset.click.top >= this.containment[1] && top - this.
offset.click.top <= this.containment[3]) ? top : ((top - this.
offset.click.top >=
this.containment[1]) ? top - o.grid[1] : top + o.grid[1])) : top;
5619 left = this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0];
5620 pageX = this.containment ? ( (left - this.
offset.click.left >= this.containment[0] && left - this.
offset.click.left <= this.containment[2]) ? left : ((left - this.
offset.click.left >=
this.containment[0]) ? left - o.grid[0] : left + o.grid[0])) : left;
5629 this.
offset.relative.top -
5631 ( ( this.cssPosition ===
"fixed" ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ))
5636 this.
offset.relative.left -
5637 this.
offset.parent.left +
5638 ( ( this.cssPosition ===
"fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ))
5644 _rearrange:
function(event, i, a, hardRefresh) {
5646 a ? a[0].appendChild(this.placeholder[0]) : i.item[0].parentNode.insertBefore(this.placeholder[0], (this.direction ===
"down" ? i.item[0] : i.item[0].nextSibling));
5653 this.counter = this.counter ? ++this.counter : 1;
5654 var counter = this.counter;
5656 this._delay(
function() {
5657 if(counter === this.counter) {
5658 this.refreshPositions(!hardRefresh);
5664 _clear:
function(event, noPropagation) {
5666 this.reverting =
false;
5670 delayedTriggers = [];
5674 if(!this._noFinalSort && this.currentItem.parent().length) {
5675 this.placeholder.before(this.currentItem);
5677 this._noFinalSort = null;
5679 if(this.helper[0] === this.currentItem[0]) {
5680 for(i in this._storedCSS) {
5681 if(this._storedCSS[i] ===
"auto" || this._storedCSS[i] ===
"static") {
5682 this._storedCSS[i] =
"";
5685 this.currentItem.css(this._storedCSS).removeClass(
"ui-sortable-helper");
5687 this.currentItem.show();
5690 if(this.fromOutside && !noPropagation) {
5691 delayedTriggers.push(
function(event) { this._trigger(
"receive", event, this._uiHash(this.fromOutside)); });
5693 if((this.fromOutside || this.domPosition.prev !==
this.currentItem.prev().not(
".ui-sortable-helper")[0] || this.domPosition.parent !== this.currentItem.parent()[0]) && !noPropagation) {
5694 delayedTriggers.push(
function(event) { this._trigger(
"update", event, this._uiHash()); });
5699 if (
this !== this.currentContainer) {
5700 if(!noPropagation) {
5701 delayedTriggers.push(
function(event) { this._trigger(
"remove", event, this._uiHash()); });
5702 delayedTriggers.push((
function(c) {
return function(event) { c._trigger(
"receive", event, this._uiHash(
this)); }; }).call(
this, this.currentContainer));
5703 delayedTriggers.push((
function(c) {
return function(event) { c._trigger(
"update", event, this._uiHash(
this)); }; }).call(
this, this.currentContainer));
5709 function delayEvent( type, instance, container ) {
5710 return function( event ) {
5711 container._trigger( type, event, instance._uiHash( instance ) );
5714 for (i = this.containers.length - 1; i >= 0; i--){
5715 if (!noPropagation) {
5716 delayedTriggers.push( delayEvent(
"deactivate",
this, this.containers[ i ] ) );
5718 if(this.containers[i].containerCache.over) {
5719 delayedTriggers.push( delayEvent(
"out",
this, this.containers[ i ] ) );
5720 this.containers[i].containerCache.over = 0;
5725 if ( this.storedCursor ) {
5726 this.document.find(
"body" ).css(
"cursor", this.storedCursor );
5727 this.storedStylesheet.remove();
5729 if(this._storedOpacity) {
5730 this.helper.css(
"opacity", this._storedOpacity);
5732 if(this._storedZIndex) {
5733 this.helper.css(
"zIndex", this._storedZIndex ===
"auto" ?
"" : this._storedZIndex);
5738 if(!noPropagation) {
5739 this._trigger(
"beforeStop", event, this._uiHash());
5743 this.placeholder[0].parentNode.removeChild(this.placeholder[0]);
5745 if ( !this.cancelHelperRemoval ) {
5746 if ( this.helper[ 0 ] !== this.currentItem[ 0 ] ) {
5747 this.helper.remove();
5752 if(!noPropagation) {
5753 for (i=0; i < delayedTriggers.length; i++) {
5754 delayedTriggers[i].call(
this, event);
5756 this._trigger(
"stop", event, this._uiHash());
5759 this.fromOutside =
false;
5760 return !this.cancelHelperRemoval;
5764 _trigger:
function() {
5765 if ($.Widget.prototype._trigger.apply(
this, arguments) ===
false) {
5770 _uiHash:
function(_inst) {
5771 var inst = _inst ||
this;
5773 helper: inst.helper,
5774 placeholder: inst.placeholder || $([]),
5775 position: inst.position,
5776 originalPosition: inst.originalPosition,
5777 offset: inst.positionAbs,
5778 item: inst.currentItem,
5779 sender: _inst ? _inst.element : null
5798 var accordion = $.widget(
"ui.accordion", {
5805 header:
"> li > :first-child,> :not(li):even",
5806 heightStyle:
"auto",
5808 activeHeader:
"ui-icon-triangle-1-s",
5809 header:
"ui-icon-triangle-1-e" 5814 beforeActivate: null
5818 borderTopWidth:
"hide",
5819 borderBottomWidth:
"hide",
5821 paddingBottom:
"hide",
5826 borderTopWidth:
"show",
5827 borderBottomWidth:
"show",
5829 paddingBottom:
"show",
5833 _create:
function() {
5834 var options = this.options;
5835 this.prevShow = this.prevHide = $();
5836 this.element.addClass(
"ui-accordion ui-widget ui-helper-reset" )
5838 .attr(
"role",
"tablist" );
5841 if ( !options.collapsible && (options.active ===
false || options.active == null) ) {
5845 this._processPanels();
5847 if ( options.active < 0 ) {
5848 options.active += this.headers.length;
5853 _getCreateEventData:
function() {
5855 header: this.active,
5856 panel: !this.active.length ? $() : this.active.next()
5860 _createIcons:
function() {
5861 var icons = this.options.icons;
5864 .
addClass(
"ui-accordion-header-icon ui-icon " + icons.header )
5865 .prependTo( this.headers );
5866 this.active.children(
".ui-accordion-header-icon" )
5867 .removeClass( icons.header )
5868 .addClass( icons.activeHeader );
5869 this.headers.addClass(
"ui-accordion-icons" );
5873 _destroyIcons:
function() {
5875 .removeClass(
"ui-accordion-icons" )
5876 .children(
".ui-accordion-header-icon" )
5880 _destroy:
function() {
5885 .removeClass(
"ui-accordion ui-widget ui-helper-reset" )
5886 .removeAttr(
"role" );
5890 .removeClass(
"ui-accordion-header ui-accordion-header-active ui-state-default " +
5891 "ui-corner-all ui-state-active ui-state-disabled ui-corner-top" )
5892 .removeAttr(
"role" )
5893 .removeAttr(
"aria-expanded" )
5894 .removeAttr(
"aria-selected" )
5895 .removeAttr(
"aria-controls" )
5896 .removeAttr(
"tabIndex" )
5899 this._destroyIcons();
5902 contents = this.headers.next()
5903 .removeClass(
"ui-helper-reset ui-widget-content ui-corner-bottom " +
5904 "ui-accordion-content ui-accordion-content-active ui-state-disabled" )
5905 .css(
"display",
"" )
5906 .removeAttr(
"role" )
5907 .removeAttr(
"aria-hidden" )
5908 .removeAttr(
"aria-labelledby" )
5911 if ( this.options.heightStyle !==
"content" ) {
5912 contents.css(
"height",
"" );
5916 _setOption:
function( key, value ) {
5917 if ( key ===
"active" ) {
5919 this._activate( value );
5923 if ( key ===
"event" ) {
5924 if ( this.options.event ) {
5925 this._off( this.headers, this.options.event );
5927 this._setupEvents( value );
5930 this._super( key, value );
5933 if ( key ===
"collapsible" && !value && this.options.active ===
false ) {
5934 this._activate( 0 );
5937 if ( key ===
"icons" ) {
5938 this._destroyIcons();
5940 this._createIcons();
5946 if ( key ===
"disabled" ) {
5948 .toggleClass(
"ui-state-disabled", !!value )
5949 .attr(
"aria-disabled", value );
5950 this.headers.add( this.headers.next() )
5951 .toggleClass(
"ui-state-disabled", !!value );
5955 _keydown:
function( event ) {
5956 if ( event.altKey || event.ctrlKey ) {
5960 var keyCode = $.ui.keyCode,
5961 length = this.headers.length,
5962 currentIndex = this.headers.index( event.target ),
5965 switch ( event.keyCode ) {
5968 toFocus = this.headers[ ( currentIndex + 1 ) % length ];
5972 toFocus = this.headers[ ( currentIndex - 1 + length ) % length ];
5976 this._eventHandler( event );
5979 toFocus = this.headers[ 0 ];
5982 toFocus = this.headers[ length - 1 ];
5987 $(
event.target ).attr(
"tabIndex", -1 );
5988 $( toFocus ).attr(
"tabIndex", 0 );
5990 event.preventDefault();
5994 _panelKeyDown:
function( event ) {
5995 if ( event.keyCode === $.ui.keyCode.UP && event.ctrlKey ) {
5996 $(
event.currentTarget ).prev().focus();
6000 refresh:
function() {
6001 var options = this.options;
6002 this._processPanels();
6005 if ( ( options.active ===
false && options.collapsible ===
true ) || !
this.headers.length ) {
6006 options.active =
false;
6009 }
else if ( options.active ===
false ) {
6010 this._activate( 0 );
6012 }
else if ( this.active.length && !$.contains(
this.element[ 0 ],
this.active[ 0 ] ) ) {
6014 if ( this.headers.length ===
this.headers.find(
".ui-state-disabled").length ) {
6015 options.active =
false;
6019 this._activate( Math.max( 0, options.active - 1 ) );
6024 options.active = this.headers.index( this.active );
6027 this._destroyIcons();
6032 _processPanels:
function() {
6033 var prevHeaders = this.headers,
6034 prevPanels = this.panels;
6036 this.headers = this.element.find( this.options.header )
6037 .addClass(
"ui-accordion-header ui-state-default ui-corner-all" );
6039 this.panels = this.headers.next()
6040 .addClass(
"ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom" )
6041 .filter(
":not(.ui-accordion-content-active)" )
6046 this._off( prevHeaders.not(
this.headers ) );
6047 this._off( prevPanels.not(
this.panels ) );
6051 _refresh:
function() {
6053 options = this.options,
6054 heightStyle = options.heightStyle,
6055 parent = this.element.parent();
6057 this.active = this._findActive( options.active )
6058 .addClass(
"ui-accordion-header-active ui-state-active ui-corner-top" )
6059 .removeClass(
"ui-corner-all" );
6061 .addClass(
"ui-accordion-content-active" )
6065 .attr(
"role",
"tab" )
6067 var header = $( this ),
6068 headerId = header.uniqueId().attr(
"id" ),
6069 panel = header.next(),
6070 panelId = panel.uniqueId().attr(
"id" );
6071 header.attr(
"aria-controls", panelId );
6072 panel.attr(
"aria-labelledby", headerId );
6075 .attr(
"role",
"tabpanel" );
6080 "aria-selected":
"false",
6081 "aria-expanded":
"false",
6086 "aria-hidden":
"true" 6091 if ( !this.active.length ) {
6092 this.headers.eq( 0 ).attr(
"tabIndex", 0 );
6095 "aria-selected":
"true",
6096 "aria-expanded":
"true",
6101 "aria-hidden":
"false" 6105 this._createIcons();
6107 this._setupEvents( options.event );
6109 if ( heightStyle ===
"fill" ) {
6110 maxHeight = parent.height();
6111 this.element.siblings(
":visible" ).each(
function() {
6112 var elem = $( this ),
6113 position = elem.css(
"position" );
6115 if ( position ===
"absolute" || position ===
"fixed" ) {
6118 maxHeight -= elem.outerHeight(
true );
6121 this.headers.each(
function() {
6122 maxHeight -= $( this ).outerHeight(
true );
6127 $( this ).
height( Math.max( 0, maxHeight -
6128 $(
this ).innerHeight() + $( this ).
height() ) );
6130 .css(
"overflow",
"auto" );
6131 }
else if ( heightStyle ===
"auto" ) {
6135 maxHeight = Math.max( maxHeight, $(
this ).css(
"height",
"" ).
height() );
6141 _activate:
function( index ) {
6142 var active = this._findActive( index )[ 0 ];
6145 if ( active === this.active[ 0 ] ) {
6150 active = active || this.active[ 0 ];
6152 this._eventHandler({
6154 currentTarget: active,
6155 preventDefault: $.noop
6159 _findActive:
function( selector ) {
6160 return typeof selector ===
"number" ? this.headers.eq( selector ) : $();
6163 _setupEvents:
function( event ) {
6168 $.each( event.split(
" " ),
function( index, eventName ) {
6169 events[ eventName ] =
"_eventHandler";
6173 this._off( this.headers.add(
this.headers.next() ) );
6174 this._on( this.headers, events );
6175 this._on( this.headers.next(), { keydown:
"_panelKeyDown" });
6176 this._hoverable( this.headers );
6177 this._focusable( this.headers );
6180 _eventHandler:
function( event ) {
6181 var options = this.options,
6182 active = this.active,
6183 clicked = $(
event.currentTarget ),
6184 clickedIsActive = clicked[ 0 ] === active[ 0 ],
6185 collapsing = clickedIsActive && options.collapsible,
6186 toShow = collapsing ? $() : clicked.next(),
6187 toHide = active.next(),
6191 newHeader: collapsing ? $() : clicked,
6195 event.preventDefault();
6199 ( clickedIsActive && !options.collapsible ) ||
6201 (
this._trigger(
"beforeActivate", event, eventData ) === false ) ) {
6205 options.active = collapsing ?
false : this.headers.index( clicked );
6209 this.active = clickedIsActive ? $() : clicked;
6210 this._toggle( eventData );
6214 active.removeClass(
"ui-accordion-header-active ui-state-active" );
6215 if ( options.icons ) {
6216 active.children(
".ui-accordion-header-icon" )
6217 .removeClass( options.icons.activeHeader )
6218 .addClass( options.icons.header );
6221 if ( !clickedIsActive ) {
6223 .removeClass(
"ui-corner-all" )
6224 .addClass(
"ui-accordion-header-active ui-state-active ui-corner-top" );
6225 if ( options.icons ) {
6226 clicked.children(
".ui-accordion-header-icon" )
6227 .removeClass( options.icons.header )
6228 .addClass( options.icons.activeHeader );
6233 .addClass(
"ui-accordion-content-active" );
6237 _toggle:
function( data ) {
6238 var toShow = data.newPanel,
6239 toHide = this.prevShow.length ? this.prevShow : data.oldPanel;
6242 this.prevShow.add( this.prevHide ).stop(
true,
true );
6243 this.prevShow = toShow;
6244 this.prevHide = toHide;
6246 if ( this.options.animate ) {
6247 this._animate( toShow, toHide, data );
6251 this._toggleComplete( data );
6255 "aria-hidden":
"true" 6257 toHide.prev().attr(
"aria-selected",
"false" );
6261 if ( toShow.length && toHide.length ) {
6262 toHide.prev().attr({
6264 "aria-expanded":
"false" 6266 }
else if ( toShow.length ) {
6267 this.headers.filter(
function() {
6268 return $( this ).attr(
"tabIndex" ) === 0;
6270 .attr(
"tabIndex", -1 );
6274 .attr(
"aria-hidden",
"false" )
6277 "aria-selected":
"true",
6279 "aria-expanded":
"true" 6283 _animate:
function( toShow, toHide, data ) {
6284 var total,
easing, duration,
6287 down = toShow.length &&
6288 ( !toHide.length || ( toShow.index() < toHide.index() ) ),
6289 animate = this.options.animate || {},
6290 options = down && animate.down || animate,
6291 complete =
function() {
6292 that._toggleComplete( data );
6295 if ( typeof options ===
"number" ) {
6298 if ( typeof options ===
"string" ) {
6302 easing = easing || options.easing || animate.easing;
6303 duration = duration || options.duration || animate.duration;
6305 if ( !toHide.length ) {
6306 return toShow.animate( this.showProps, duration, easing, complete );
6308 if ( !toShow.length ) {
6309 return toHide.animate( this.hideProps, duration, easing, complete );
6312 total = toShow.show().outerHeight();
6313 toHide.animate( this.hideProps, {
6316 step:
function( now,
fx ) {
6317 fx.now = Math.round( now );
6322 .animate( this.showProps, {
6326 step:
function( now,
fx ) {
6327 fx.now = Math.round( now );
6328 if (
fx.prop !==
"height" ) {
6330 }
else if ( that.options.heightStyle !==
"content" ) {
6331 fx.now = Math.round( total - toHide.outerHeight() - adjust );
6338 _toggleComplete:
function( data ) {
6339 var toHide = data.oldPanel;
6342 .removeClass(
"ui-accordion-content-active" )
6344 .removeClass(
"ui-corner-top" )
6345 .addClass(
"ui-corner-all" );
6348 if ( toHide.length ) {
6349 toHide.parent()[ 0 ].className = toHide.parent()[ 0 ].className;
6351 this._trigger(
"activate", null, data );
6368 var menu = $.widget(
"ui.menu", {
6370 defaultElement:
"<ul>",
6374 submenu:
"ui-icon-carat-1-e" 6390 _create:
function() {
6391 this.activeMenu = this.element;
6395 this.mouseHandled =
false;
6398 .addClass(
"ui-menu ui-widget ui-widget-content" )
6399 .toggleClass(
"ui-menu-icons", !!this.element.find(
".ui-icon" ).length )
6401 role: this.options.role,
6405 if ( this.options.disabled ) {
6407 .addClass(
"ui-state-disabled" )
6408 .attr(
"aria-disabled",
"true" );
6414 "mousedown .ui-menu-item":
function( event ) {
6415 event.preventDefault();
6417 "click .ui-menu-item":
function( event ) {
6418 var target = $(
event.target );
6419 if ( !this.mouseHandled && target.not(
".ui-state-disabled" ).length ) {
6420 this.select( event );
6423 if ( !event.isPropagationStopped() ) {
6424 this.mouseHandled =
true;
6428 if ( target.has(
".ui-menu" ).length ) {
6429 this.expand( event );
6430 }
else if ( !this.element.is(
":focus" ) && $( this.document[ 0 ].activeElement ).closest(
".ui-menu" ).length ) {
6433 this.element.trigger(
"focus", [
true ] );
6437 if ( this.active && this.active.parents(
".ui-menu" ).length === 1 ) {
6438 clearTimeout( this.
timer );
6443 "mouseenter .ui-menu-item":
function( event ) {
6447 if ( this.previousFilter ) {
6450 var target = $(
event.currentTarget );
6453 target.siblings(
".ui-state-active" ).removeClass(
"ui-state-active" );
6454 this.focus( event, target );
6456 mouseleave:
"collapseAll",
6457 "mouseleave .ui-menu":
"collapseAll",
6458 focus:
function( event, keepActiveItem ) {
6461 var item = this.active || this.element.find( this.options.items ).eq( 0 );
6463 if ( !keepActiveItem ) {
6464 this.focus( event, item );
6467 blur:
function( event ) {
6468 this._delay(
function() {
6469 if ( !$.contains( this.element[0], this.document[0].activeElement ) ) {
6470 this.collapseAll( event );
6480 this._on( this.document, {
6481 click:
function( event ) {
6482 if ( this._closeOnDocumentClick( event ) ) {
6483 this.collapseAll( event );
6487 this.mouseHandled =
false;
6492 _destroy:
function() {
6495 .removeAttr(
"aria-activedescendant" )
6496 .find(
".ui-menu" ).addBack()
6497 .removeClass(
"ui-menu ui-widget ui-widget-content ui-menu-icons ui-front" )
6498 .removeAttr(
"role" )
6499 .removeAttr(
"tabIndex" )
6500 .removeAttr(
"aria-labelledby" )
6501 .removeAttr(
"aria-expanded" )
6502 .removeAttr(
"aria-hidden" )
6503 .removeAttr(
"aria-disabled" )
6508 this.element.find(
".ui-menu-item" )
6509 .removeClass(
"ui-menu-item" )
6510 .removeAttr(
"role" )
6511 .removeAttr(
"aria-disabled" )
6513 .removeClass(
"ui-state-hover" )
6514 .removeAttr(
"tabIndex" )
6515 .removeAttr(
"role" )
6516 .removeAttr(
"aria-haspopup" )
6517 .children().each(
function() {
6518 var elem = $( this );
6519 if ( elem.data(
"ui-menu-submenu-carat" ) ) {
6525 this.element.find(
".ui-menu-divider" ).removeClass(
"ui-menu-divider ui-widget-content" );
6528 _keydown:
function( event ) {
6529 var match, prev, character, skip,
6530 preventDefault =
true;
6532 switch ( event.keyCode ) {
6533 case $.ui.keyCode.PAGE_UP:
6534 this.previousPage( event );
6536 case $.ui.keyCode.PAGE_DOWN:
6537 this.nextPage( event );
6539 case $.ui.keyCode.HOME:
6540 this._move(
"first",
"first", event );
6542 case $.ui.keyCode.END:
6543 this._move(
"last",
"last", event );
6545 case $.ui.keyCode.UP:
6546 this.previous( event );
6548 case $.ui.keyCode.DOWN:
6551 case $.ui.keyCode.LEFT:
6552 this.collapse( event );
6554 case $.ui.keyCode.RIGHT:
6555 if ( this.active && !this.active.is(
".ui-state-disabled" ) ) {
6556 this.expand( event );
6559 case $.ui.keyCode.ENTER:
6560 case $.ui.keyCode.SPACE:
6561 this._activate( event );
6563 case $.ui.keyCode.ESCAPE:
6564 this.collapse( event );
6567 preventDefault =
false;
6568 prev = this.previousFilter ||
"";
6569 character = String.fromCharCode( event.keyCode );
6572 clearTimeout( this.filterTimer );
6574 if ( character === prev ) {
6577 character = prev + character;
6580 match = this._filterMenuItems( character );
6581 match = skip && match.index( this.active.next() ) !== -1 ?
6582 this.active.nextAll(
".ui-menu-item" ) :
6587 if ( !match.length ) {
6588 character = String.fromCharCode( event.keyCode );
6589 match = this._filterMenuItems( character );
6592 if ( match.length ) {
6593 this.focus( event, match );
6594 this.previousFilter = character;
6595 this.filterTimer = this._delay(
function() {
6596 delete this.previousFilter;
6599 delete this.previousFilter;
6603 if ( preventDefault ) {
6604 event.preventDefault();
6608 _activate:
function( event ) {
6609 if ( !this.active.is(
".ui-state-disabled" ) ) {
6610 if ( this.active.is(
"[aria-haspopup='true']" ) ) {
6611 this.expand( event );
6613 this.select( event );
6618 refresh:
function() {
6621 icon = this.options.icons.submenu,
6622 submenus = this.element.find( this.options.menus );
6624 this.element.toggleClass(
"ui-menu-icons", !!this.element.find(
".ui-icon" ).length );
6627 submenus.filter(
":not(.ui-menu)" )
6628 .addClass(
"ui-menu ui-widget ui-widget-content ui-front" )
6631 role: this.options.role,
6632 "aria-hidden":
"true",
6633 "aria-expanded":
"false" 6636 var menu = $( this ),
6637 item = menu.parent(),
6638 submenuCarat = $(
"<span>" )
6639 .
addClass(
"ui-menu-icon ui-icon " + icon )
6640 .data(
"ui-menu-submenu-carat",
true );
6643 .attr(
"aria-haspopup",
"true" )
6644 .prepend( submenuCarat );
6645 menu.attr(
"aria-labelledby", item.attr(
"id" ) );
6648 menus = submenus.add( this.element );
6649 items = menus.find( this.options.items );
6652 items.not(
".ui-menu-item" ).each(
function() {
6653 var item = $( this );
6654 if ( that._isDivider( item ) ) {
6655 item.addClass(
"ui-widget-content ui-menu-divider" );
6660 items.not(
".ui-menu-item, .ui-menu-divider" )
6661 .addClass(
"ui-menu-item" )
6665 role: this._itemRole()
6669 items.filter(
".ui-state-disabled" ).attr(
"aria-disabled",
"true" );
6672 if ( this.active && !$.contains( this.element[ 0 ], this.active[ 0 ] ) ) {
6677 _itemRole:
function() {
6681 }[ this.options.role ];
6684 _setOption:
function( key, value ) {
6685 if ( key ===
"icons" ) {
6686 this.element.find(
".ui-menu-icon" )
6687 .removeClass( this.options.icons.submenu )
6688 .addClass( value.submenu );
6690 if ( key ===
"disabled" ) {
6692 .toggleClass(
"ui-state-disabled", !!value )
6693 .attr(
"aria-disabled", value );
6695 this._super( key, value );
6698 focus:
function( event, item ) {
6699 var nested, focused;
6700 this.blur( event, event && event.type ===
"focus" );
6702 this._scrollIntoView( item );
6704 this.active = item.first();
6705 focused = this.active.addClass(
"ui-state-focus" ).removeClass(
"ui-state-active" );
6708 if ( this.options.role ) {
6709 this.element.attr(
"aria-activedescendant", focused.attr(
"id" ) );
6715 .closest(
".ui-menu-item" )
6716 .addClass(
"ui-state-active" );
6718 if ( event && event.type ===
"keydown" ) {
6721 this.
timer = this._delay(
function() {
6726 nested = item.children(
".ui-menu" );
6727 if ( nested.length && event && ( /^mouse/.test( event.type ) ) ) {
6728 this._startOpening(nested);
6730 this.activeMenu = item.parent();
6732 this._trigger(
"focus", event, { item: item } );
6735 _scrollIntoView:
function( item ) {
6736 var borderTop, paddingTop,
offset, scroll, elementHeight, itemHeight;
6737 if ( this._hasScroll() ) {
6738 borderTop = parseFloat( $.css( this.activeMenu[0],
"borderTopWidth" ) ) || 0;
6739 paddingTop = parseFloat( $.css( this.activeMenu[0],
"paddingTop" ) ) || 0;
6740 offset = item.offset().top - this.activeMenu.offset().top - borderTop - paddingTop;
6741 scroll = this.activeMenu.scrollTop();
6742 elementHeight = this.activeMenu.height();
6743 itemHeight = item.outerHeight();
6746 this.activeMenu.scrollTop( scroll + offset );
6747 }
else if ( offset + itemHeight > elementHeight ) {
6748 this.activeMenu.scrollTop( scroll + offset - elementHeight + itemHeight );
6753 blur:
function( event, fromFocus ) {
6755 clearTimeout( this.
timer );
6758 if ( !this.active ) {
6762 this.active.removeClass(
"ui-state-focus" );
6765 this._trigger(
"blur", event, { item: this.active } );
6768 _startOpening:
function( submenu ) {
6769 clearTimeout( this.
timer );
6773 if ( submenu.attr(
"aria-hidden" ) !==
"true" ) {
6777 this.
timer = this._delay(
function() {
6779 this._open( submenu );
6783 _open:
function( submenu ) {
6784 var position = $.extend({
6786 }, this.options.position );
6788 clearTimeout( this.
timer );
6789 this.element.find(
".ui-menu" ).not( submenu.parents(
".ui-menu" ) )
6791 .attr(
"aria-hidden",
"true" );
6795 .removeAttr(
"aria-hidden" )
6796 .attr(
"aria-expanded",
"true" )
6797 .position( position );
6800 collapseAll:
function( event, all ) {
6801 clearTimeout( this.
timer );
6802 this.
timer = this._delay(
function() {
6804 var currentMenu = all ? this.element :
6805 $(
event &&
event.target ).closest( this.element.find(
".ui-menu" ) );
6808 if ( !currentMenu.length ) {
6809 currentMenu = this.element;
6812 this._close( currentMenu );
6815 this.activeMenu = currentMenu;
6821 _close:
function( startMenu ) {
6823 startMenu = this.active ? this.active.parent() : this.element;
6829 .attr(
"aria-hidden",
"true" )
6830 .attr(
"aria-expanded",
"false" )
6832 .find(
".ui-state-active" ).not(
".ui-state-focus" )
6833 .removeClass(
"ui-state-active" );
6836 _closeOnDocumentClick:
function( event ) {
6837 return !$(
event.target ).closest(
".ui-menu" ).length;
6840 _isDivider:
function( item ) {
6846 collapse:
function( event ) {
6847 var newItem = this.active &&
6848 this.active.parent().closest(
".ui-menu-item", this.element );
6849 if ( newItem && newItem.length ) {
6851 this.focus( event, newItem );
6855 expand:
function( event ) {
6856 var newItem = this.active &&
6858 .children(
".ui-menu " )
6859 .find( this.options.items )
6862 if ( newItem && newItem.length ) {
6863 this._open( newItem.parent() );
6866 this._delay(
function() {
6867 this.focus( event, newItem );
6872 next:
function( event ) {
6873 this._move(
"next",
"first", event );
6876 previous:
function( event ) {
6877 this._move(
"prev",
"last", event );
6880 isFirstItem:
function() {
6881 return this.active && !this.active.prevAll(
".ui-menu-item" ).length;
6884 isLastItem:
function() {
6885 return this.active && !this.active.nextAll(
".ui-menu-item" ).length;
6888 _move:
function( direction, filter, event ) {
6890 if ( this.active ) {
6891 if ( direction ===
"first" || direction ===
"last" ) {
6893 [ direction ===
"first" ?
"prevAll" :
"nextAll" ](
".ui-menu-item" )
6897 [ direction +
"All" ](
".ui-menu-item" )
6901 if ( !next || !next.length || !
this.active ) {
6902 next = this.activeMenu.find( this.options.items )[ filter ]();
6905 this.focus( event, next );
6908 nextPage:
function( event ) {
6911 if ( !this.active ) {
6915 if ( this.isLastItem() ) {
6918 if ( this._hasScroll() ) {
6919 base = this.active.offset().top;
6920 height = this.element.height();
6921 this.active.nextAll(
".ui-menu-item" ).each(
function() {
6923 return item.offset().top - base - height < 0;
6926 this.focus( event, item );
6928 this.focus( event, this.activeMenu.find(
this.options.items )
6929 [ !this.active ?
"first" :
"last" ]() );
6933 previousPage:
function( event ) {
6935 if ( !this.active ) {
6939 if ( this.isFirstItem() ) {
6942 if ( this._hasScroll() ) {
6943 base = this.active.offset().top;
6944 height = this.element.height();
6945 this.active.prevAll(
".ui-menu-item" ).each(
function() {
6947 return item.offset().top - base + height > 0;
6950 this.focus( event, item );
6952 this.focus( event, this.activeMenu.find(
this.options.items ).first() );
6956 _hasScroll:
function() {
6957 return this.element.outerHeight() < this.element.prop(
"scrollHeight" );
6960 select:
function( event ) {
6963 this.active = this.active || $(
event.target ).closest(
".ui-menu-item" );
6964 var ui = { item: this.active };
6965 if ( !this.active.has(
".ui-menu" ).length ) {
6966 this.collapseAll( event,
true );
6968 this._trigger(
"select", event, ui );
6971 _filterMenuItems:
function(character) {
6972 var escapedCharacter = character.replace( /[\-\[\]{}()*+?.,\\\^$|#\s]/
g,
"\\$&" ),
6973 regex =
new RegExp(
"^" + escapedCharacter,
"i" );
6975 return this.activeMenu
6976 .find( this.options.items )
6979 .filter(
".ui-menu-item" )
6980 .filter(
function() {
6981 return regex.test( $.trim( $(
this ).text() ) );
6999 $.widget(
"ui.autocomplete", {
7001 defaultElement:
"<input>",
7027 _create:
function() {
7035 var suppressKeyPress, suppressKeyPressRepeat, suppressInput,
7036 nodeName = this.element[ 0 ].nodeName.toLowerCase(),
7037 isTextarea = nodeName ===
"textarea",
7038 isInput = nodeName ===
"input";
7047 this.element.prop(
"isContentEditable" );
7049 this.valueMethod = this.element[ isTextarea || isInput ?
"val" :
"text" ];
7050 this.isNewMenu =
true;
7053 .addClass(
"ui-autocomplete-input" )
7054 .attr(
"autocomplete",
"off" );
7056 this._on( this.element, {
7057 keydown:
function( event ) {
7058 if ( this.element.prop(
"readOnly" ) ) {
7059 suppressKeyPress =
true;
7060 suppressInput =
true;
7061 suppressKeyPressRepeat =
true;
7065 suppressKeyPress =
false;
7066 suppressInput =
false;
7067 suppressKeyPressRepeat =
false;
7068 var keyCode = $.ui.keyCode;
7069 switch ( event.keyCode ) {
7070 case keyCode.PAGE_UP:
7071 suppressKeyPress =
true;
7072 this._move(
"previousPage", event );
7074 case keyCode.PAGE_DOWN:
7075 suppressKeyPress =
true;
7076 this._move(
"nextPage", event );
7079 suppressKeyPress =
true;
7080 this._keyEvent(
"previous", event );
7083 suppressKeyPress =
true;
7084 this._keyEvent(
"next", event );
7088 if ( this.menu.active ) {
7091 suppressKeyPress =
true;
7092 event.preventDefault();
7093 this.menu.select( event );
7097 if ( this.menu.active ) {
7098 this.menu.select( event );
7101 case keyCode.ESCAPE:
7102 if ( this.menu.element.is(
":visible" ) ) {
7103 if ( !this.isMultiLine ) {
7104 this._value( this.term );
7106 this.close( event );
7110 event.preventDefault();
7114 suppressKeyPressRepeat =
true;
7116 this._searchTimeout( event );
7120 keypress:
function( event ) {
7121 if ( suppressKeyPress ) {
7122 suppressKeyPress =
false;
7123 if ( !this.isMultiLine || this.menu.element.is(
":visible" ) ) {
7124 event.preventDefault();
7128 if ( suppressKeyPressRepeat ) {
7133 var keyCode = $.ui.keyCode;
7134 switch ( event.keyCode ) {
7135 case keyCode.PAGE_UP:
7136 this._move(
"previousPage", event );
7138 case keyCode.PAGE_DOWN:
7139 this._move(
"nextPage", event );
7142 this._keyEvent(
"previous", event );
7145 this._keyEvent(
"next", event );
7149 input:
function( event ) {
7150 if ( suppressInput ) {
7151 suppressInput =
false;
7152 event.preventDefault();
7155 this._searchTimeout( event );
7158 this.selectedItem = null;
7159 this.previous = this._value();
7161 blur:
function( event ) {
7162 if ( this.cancelBlur ) {
7163 delete this.cancelBlur;
7167 clearTimeout( this.searching );
7168 this.close( event );
7169 this._change( event );
7174 this.menu = $(
"<ul>" )
7175 .
addClass(
"ui-autocomplete ui-front" )
7176 .appendTo( this._appendTo() )
7182 .menu(
"instance" );
7184 this._on( this.menu.element, {
7185 mousedown: function( event ) {
7187 event.preventDefault();
7191 this.cancelBlur = true;
7192 this._delay(function() {
7193 delete this.cancelBlur;
7200 var menuElement = this.menu.element[ 0 ];
7201 if ( !$( event.target ).closest(
".ui-menu-item" ).length ) {
7202 this._delay(function() {
7204 this.document.one(
"mousedown", function( event ) {
7205 if ( event.target !== that.element[ 0 ] &&
7206 event.target !== menuElement &&
7207 !$.contains( menuElement, event.target ) ) {
7214 menufocus:
function( event, ui ) {
7218 if ( this.isNewMenu ) {
7219 this.isNewMenu = false;
7220 if ( event.originalEvent && /^mouse/.test( event.originalEvent.type ) ) {
7223 this.document.one(
"mousemove", function() {
7224 $( event.target ).trigger( event.originalEvent );
7231 item = ui.item.data(
"ui-autocomplete-item" );
7232 if (
false !== this._trigger(
"focus", event, { item: item } ) ) {
7234 if ( event.originalEvent && /^key/.test( event.originalEvent.type ) ) {
7235 this._value( item.value );
7240 label = ui.item.attr(
"aria-label" ) || item.value;
7241 if ( label && $.trim( label ).length ) {
7242 this.liveRegion.children().hide();
7243 $(
"<div>" ).text( label ).appendTo( this.liveRegion );
7246 menuselect:
function( event, ui ) {
7247 var item = ui.item.data(
"ui-autocomplete-item" ),
7248 previous = this.previous;
7251 if ( this.element[ 0 ] !== this.document[ 0 ].activeElement ) {
7252 this.element.focus();
7253 this.previous = previous;
7257 this._delay(
function() {
7258 this.previous = previous;
7259 this.selectedItem = item;
7263 if (
false !== this._trigger(
"select", event, { item: item } ) ) {
7264 this._value( item.value );
7268 this.term = this._value();
7270 this.close( event );
7271 this.selectedItem = item;
7275 this.liveRegion = $(
"<span>", {
7277 "aria-live":
"assertive",
7278 "aria-relevant":
"additions" 7280 .
addClass(
"ui-helper-hidden-accessible" )
7281 .appendTo( this.document[ 0 ].body );
7287 beforeunload:
function() {
7288 this.element.removeAttr(
"autocomplete" );
7293 _destroy:
function() {
7294 clearTimeout( this.searching );
7296 .removeClass(
"ui-autocomplete-input" )
7297 .removeAttr(
"autocomplete" );
7298 this.menu.element.remove();
7299 this.liveRegion.remove();
7302 _setOption:
function( key, value ) {
7303 this._super( key, value );
7304 if ( key ===
"source" ) {
7307 if ( key ===
"appendTo" ) {
7308 this.menu.element.appendTo( this._appendTo() );
7310 if ( key ===
"disabled" && value && this.
xhr ) {
7315 _appendTo:
function() {
7316 var element = this.options.appendTo;
7319 element = element.jquery || element.nodeType ?
7321 this.document.find( element ).eq( 0 );
7324 if ( !element || !element[ 0 ] ) {
7325 element = this.element.closest(
".ui-front" );
7328 if ( !element.length ) {
7329 element = this.document[ 0 ].body;
7335 _initSource:
function() {
7338 if ( $.isArray( this.options.source ) ) {
7339 array = this.options.source;
7340 this.source =
function( request, response ) {
7341 response( $.ui.autocomplete.filter( array, request.term ) );
7343 }
else if ( typeof this.options.source ===
"string" ) {
7344 url = this.options.source;
7345 this.source =
function( request, response ) {
7362 this.source = this.options.source;
7366 _searchTimeout:
function( event ) {
7367 clearTimeout( this.searching );
7368 this.searching = this._delay(
function() {
7371 var equalValues = this.term === this._value(),
7372 menuVisible = this.menu.element.is(
":visible" ),
7373 modifierKey =
event.altKey ||
event.ctrlKey ||
event.metaKey ||
event.shiftKey;
7375 if ( !equalValues || ( equalValues && !menuVisible && !modifierKey ) ) {
7376 this.selectedItem = null;
7377 this.search( null, event );
7379 }, this.options.delay );
7382 search:
function( value, event ) {
7383 value = value != null ? value : this._value();
7386 this.term = this._value();
7388 if ( value.length <
this.options.minLength ) {
7389 return this.close( event );
7392 if ( this._trigger(
"search", event ) ===
false ) {
7396 return this._search( value );
7399 _search:
function( value ) {
7401 this.element.addClass(
"ui-autocomplete-loading" );
7402 this.cancelSearch =
false;
7404 this.source( { term: value }, this._response() );
7407 _response:
function() {
7408 var index = ++this.requestIndex;
7410 return $.proxy(
function( content ) {
7411 if ( index === this.requestIndex ) {
7412 this.__response( content );
7416 if ( !this.pending ) {
7417 this.element.removeClass(
"ui-autocomplete-loading" );
7422 __response:
function( content ) {
7424 content = this._normalize( content );
7426 this._trigger(
"response", null, { content: content } );
7427 if ( !this.options.disabled && content && content.length && !
this.cancelSearch ) {
7428 this._suggest( content );
7429 this._trigger(
"open" );
7436 close:
function( event ) {
7437 this.cancelSearch =
true;
7438 this._close( event );
7441 _close:
function( event ) {
7442 if ( this.menu.element.is(
":visible" ) ) {
7443 this.menu.element.hide();
7445 this.isNewMenu =
true;
7446 this._trigger(
"close", event );
7450 _change:
function( event ) {
7451 if ( this.previous !== this._value() ) {
7452 this._trigger(
"change", event, { item: this.selectedItem } );
7456 _normalize:
function( items ) {
7458 if ( items.length && items[ 0 ].label && items[ 0 ].value ) {
7461 return $.map( items,
function( item ) {
7462 if ( typeof item ===
"string" ) {
7468 return $.extend( {}, item, {
7469 label: item.label || item.value,
7470 value: item.value || item.label
7475 _suggest:
function( items ) {
7476 var ul = this.menu.element.empty();
7477 this._renderMenu( ul, items );
7478 this.isNewMenu =
true;
7479 this.menu.refresh();
7486 }, this.options.position ) );
7488 if ( this.options.autoFocus ) {
7493 _resizeMenu:
function() {
7494 var ul = this.menu.element;
7495 ul.outerWidth( Math.max(
7498 ul.width(
"" ).outerWidth() + 1,
7499 this.element.outerWidth()
7503 _renderMenu:
function( ul, items ) {
7505 $.each( items,
function( index, item ) {
7506 that._renderItemData( ul, item );
7510 _renderItemData:
function( ul, item ) {
7511 return this._renderItem( ul, item ).data(
"ui-autocomplete-item", item );
7514 _renderItem:
function( ul, item ) {
7515 return $(
"<li>" ).text( item.label ).appendTo( ul );
7518 _move:
function( direction, event ) {
7519 if ( !this.menu.element.is(
":visible" ) ) {
7520 this.search( null, event );
7523 if ( this.menu.isFirstItem() && /^previous/.test( direction ) ||
7524 this.menu.isLastItem() && /^next/.test( direction ) ) {
7526 if ( !this.isMultiLine ) {
7527 this._value( this.term );
7533 this.menu[ direction ]( event );
7536 widget:
function() {
7537 return this.menu.element;
7540 _value:
function() {
7541 return this.valueMethod.apply( this.element, arguments );
7544 _keyEvent:
function( keyEvent, event ) {
7545 if ( !this.isMultiLine || this.menu.element.is(
":visible" ) ) {
7546 this._move( keyEvent, event );
7549 event.preventDefault();
7554 $.extend( $.ui.autocomplete, {
7555 escapeRegex: function( value ) {
7556 return value.replace( /[\-\[\]{}()*+?.,\\\^$|#\s]/g,
"\\$&" );
7558 filter:
function( array, term ) {
7559 var matcher = new RegExp( $.ui.autocomplete.escapeRegex( term ),
"i" );
7560 return $.grep( array, function( value ) {
7561 return matcher.test( value.label || value.value || value );
7569 $.widget(
"ui.autocomplete", $.ui.autocomplete, {
7572 noResults:
"No search results.",
7573 results: function( amount ) {
7574 return amount + ( amount > 1 ?
" results are" :
" result is" ) +
7575 " available, use up and down arrow keys to navigate.";
7580 __response:
function( content ) {
7582 this._superApply( arguments );
7583 if ( this.options.disabled || this.cancelSearch ) {
7586 if ( content && content.length ) {
7587 message = this.options.messages.results( content.length );
7589 message = this.options.messages.noResults;
7591 this.liveRegion.children().hide();
7592 $(
"<div>" ).text( message ).appendTo( this.liveRegion );
7596 var autocomplete = $.ui.autocomplete;
7612 baseClasses =
"ui-button ui-widget ui-state-default ui-corner-all",
7613 typeClasses =
"ui-button-icons-only ui-button-icon-only ui-button-text-icons ui-button-text-icon-primary ui-button-text-icon-secondary ui-button-text-only",
7614 formResetHandler =
function() {
7615 var form = $( this );
7616 setTimeout(
function() {
7617 form.find(
":ui-button" ).button(
"refresh" );
7620 radioGroup =
function( radio ) {
7621 var name = radio.name,
7625 name = name.replace( /
'/g, "\\'" ); 7627 radios = $( form ).find( "[name=
'" + name + "'][type=radio]
" ); 7629 radios = $( "[name=
'" + name + "'][type=radio]
", radio.ownerDocument ) 7630 .filter(function() { 7638 $.widget( "ui.button
", { 7640 defaultElement: "<button>
", 7650 _create: function() { 7651 this.element.closest( "form
" ) 7652 .unbind( "reset
" + this.eventNamespace ) 7653 .bind( "reset
" + this.eventNamespace, formResetHandler ); 7655 if ( typeof this.options.disabled !== "boolean" ) { 7656 this.options.disabled = !!this.element.prop( "disabled
" ); 7658 this.element.prop( "disabled
", this.options.disabled ); 7661 this._determineButtonType(); 7662 this.hasTitle = !!this.buttonElement.attr( "title
" ); 7665 options = this.options, 7666 toggleButton = this.type === "checkbox
" || this.type === "radio
", 7667 activeClass = !toggleButton ? "ui-state-active
" : ""; 7669 if ( options.label === null ) { 7670 options.label = (this.type === "input
" ? this.buttonElement.val() : this.buttonElement.html()); 7673 this._hoverable( this.buttonElement ); 7676 .addClass( baseClasses ) 7677 .attr( "role
", "button
" ) 7678 .bind( "mouseenter
" + this.eventNamespace, function() { 7679 if ( options.disabled ) { 7682 if ( this === lastActive ) { 7683 $( this ).addClass( "ui-state-active
" ); 7686 .bind( "mouseleave
" + this.eventNamespace, function() { 7687 if ( options.disabled ) { 7690 $( this ).removeClass( activeClass ); 7692 .bind( "click
" + this.eventNamespace, function( event ) { 7693 if ( options.disabled ) { 7694 event.preventDefault(); 7695 event.stopImmediatePropagation(); 7699 // Can't use _focusable() because the element that receives focus 7700 // and the element that gets the ui-state-focus class are different 7703 this.buttonElement.addClass( "ui-state-focus
" ); 7706 this.buttonElement.removeClass( "ui-state-focus
" ); 7710 if ( toggleButton ) { 7711 this.element.bind( "change
" + this.eventNamespace, function() { 7716 if ( this.type === "checkbox
" ) { 7717 this.buttonElement.bind( "click
" + this.eventNamespace, function() { 7718 if ( options.disabled ) { 7722 } else if ( this.type === "radio
" ) { 7723 this.buttonElement.bind( "click
" + this.eventNamespace, function() { 7724 if ( options.disabled ) { 7727 $( this ).addClass( "ui-state-active
" ); 7728 that.buttonElement.attr( "aria-pressed
", "true" ); 7730 var radio = that.element[ 0 ]; 7734 return $( this ).button( "widget
" )[ 0 ]; 7736 .removeClass( "ui-state-active
" ) 7737 .attr( "aria-pressed
", "false" ); 7741 .bind( "mousedown
" + this.eventNamespace, function() { 7742 if ( options.disabled ) { 7745 $( this ).addClass( "ui-state-active
" ); 7747 that.document.one( "mouseup
", function() { 7751 .bind( "mouseup
" + this.eventNamespace, function() { 7752 if ( options.disabled ) { 7755 $( this ).removeClass( "ui-state-active
" ); 7757 .bind( "keydown
" + this.eventNamespace, function(event) { 7758 if ( options.disabled ) { 7761 if ( event.keyCode === $.ui.keyCode.SPACE || event.keyCode === $.ui.keyCode.ENTER ) { 7762 $( this ).addClass( "ui-state-active
" ); 7765 // see #8559, we bind to blur here in case the button element loses 7766 // focus between keydown and keyup, it would be left in an "active
" state 7767 .bind( "keyup
" + this.eventNamespace + " blur
" + this.eventNamespace, function() { 7768 $( this ).removeClass( "ui-state-active
" ); 7771 if ( this.buttonElement.is("a
") ) { 7772 this.buttonElement.keyup(function(event) { 7773 if ( event.keyCode === $.ui.keyCode.SPACE ) { 7774 // TODO pass through original event correctly (just as 2nd argument doesn't work) 7781 this._setOption( "disabled
", options.disabled ); 7782 this._resetButton(); 7785 _determineButtonType: function() { 7786 var ancestor, labelSelector, checked; 7788 if ( this.element.is("[type=checkbox]
") ) { 7789 this.type = "checkbox
"; 7790 } else if ( this.element.is("[type=radio]
") ) { 7791 this.type = "radio
"; 7792 } else if ( this.element.is("input
") ) { 7793 this.type = "input
"; 7795 this.type = "button
"; 7798 if ( this.type === "checkbox
" || this.type === "radio
" ) { 7799 // we don't search against the document in case the element 7800 // is disconnected from the DOM 7801 ancestor = this.element.parents().last(); 7802 labelSelector = "label[
for=
'" + this.element.attr("id") + "']
"; 7803 this.buttonElement = ancestor.find( labelSelector ); 7804 if ( !this.buttonElement.length ) { 7805 ancestor = ancestor.length ? ancestor.siblings() : this.element.siblings(); 7806 this.buttonElement = ancestor.filter( labelSelector ); 7807 if ( !this.buttonElement.length ) { 7808 this.buttonElement = ancestor.find( labelSelector ); 7811 this.element.addClass( "ui-helper-hidden-accessible
" ); 7813 checked = this.element.is( ":checked
" ); 7815 this.buttonElement.addClass( "ui-state-active
" ); 7817 this.buttonElement.prop( "aria-pressed
", checked ); 7819 this.buttonElement = this.element; 7823 widget: function() { 7824 return this.buttonElement; 7827 _destroy: function() { 7829 .removeClass( "ui-helper-hidden-accessible
" ); 7831 .removeClass( baseClasses + " ui-state-active
" + typeClasses ) 7832 .removeAttr( "role
" ) 7833 .removeAttr( "aria-pressed
" ) 7834 .html( this.buttonElement.find(".ui-button-text
").html() ); 7836 if ( !this.hasTitle ) { 7837 this.buttonElement.removeAttr( "title
" ); 7841 _setOption: function( key, value ) { 7842 this._super( key, value ); 7843 if ( key === "disabled
" ) { 7844 this.widget().toggleClass( "ui-state-disabled
", !!value ); 7845 this.element.prop( "disabled
", !!value ); 7847 if ( this.type === "checkbox
" || this.type === "radio
" ) { 7848 this.buttonElement.removeClass( "ui-state-focus
" ); 7850 this.buttonElement.removeClass( "ui-state-focus ui-state-active
" ); 7855 this._resetButton(); 7858 refresh: function() { 7860 var isDisabled = this.element.is( "input, button
" ) ? this.element.is( ":disabled
" ) : this.element.hasClass( "ui-button-disabled
" ); 7862 if ( isDisabled !== this.options.disabled ) { 7863 this._setOption( "disabled
", isDisabled ); 7865 if ( this.type === "radio
" ) { 7866 radioGroup( this.element[0] ).each(function() { 7867 if ( $( this ).is( ":checked
" ) ) { 7868 $( this ).button( "widget
" ) 7869 .addClass( "ui-state-active
" ) 7870 .attr( "aria-pressed
", "true" ); 7872 $( this ).button( "widget
" ) 7873 .removeClass( "ui-state-active
" ) 7874 .attr( "aria-pressed
", "false" ); 7877 } else if ( this.type === "checkbox
" ) { 7878 if ( this.element.is( ":checked
" ) ) { 7880 .addClass( "ui-state-active
" ) 7881 .attr( "aria-pressed
", "true" ); 7884 .removeClass( "ui-state-active
" ) 7885 .attr( "aria-pressed
", "false" ); 7890 _resetButton: function() { 7891 if ( this.type === "input
" ) { 7892 if ( this.options.label ) { 7893 this.element.val( this.options.label ); 7897 var buttonElement = this.buttonElement.removeClass( typeClasses ), 7898 buttonText = $( "<span></span>
", this.document[0] ) 7899 .addClass( "ui-button-text
" ) 7900 .html( this.options.label ) 7901 .appendTo( buttonElement.empty() ) 7903 icons = this.options.icons, 7904 multipleIcons = icons.primary && icons.secondary, 7907 if ( icons.primary || icons.secondary ) { 7908 if ( this.options.text ) { 7909 buttonClasses.push( "ui-button-text-icon
" + ( multipleIcons ? "s
" : ( icons.primary ? "-primary
" : "-secondary
" ) ) ); 7912 if ( icons.primary ) { 7913 buttonElement.prepend( "<span
class=
'ui-button-icon-primary ui-icon " + icons.primary + "'></span>
" ); 7916 if ( icons.secondary ) { 7917 buttonElement.append( "<span
class=
'ui-button-icon-secondary ui-icon " + icons.secondary + "'></span>
" ); 7920 if ( !this.options.text ) { 7921 buttonClasses.push( multipleIcons ? "ui-button-icons-only
" : "ui-button-icon-only
" ); 7923 if ( !this.hasTitle ) { 7924 buttonElement.attr( "title
", $.trim( buttonText ) ); 7928 buttonClasses.push( "ui-button-text-only
" ); 7930 buttonElement.addClass( buttonClasses.join( " " ) ); 7934 $.widget( "ui.buttonset
", { 7937 items: "button, input[type=button], input[type=submit], input[type=reset], input[type=checkbox], input[type=radio], a, :data(ui-button)
" 7940 _create: function() { 7941 this.element.addClass( "ui-buttonset
" ); 7948 _setOption: function( key, value ) { 7949 if ( key === "disabled
" ) { 7950 this.buttons.button( "option
", key, value ); 7953 this._super( key, value ); 7956 refresh: function() { 7957 var rtl = this.element.css( "direction
" ) === "rtl
", 7958 allButtons = this.element.find( this.options.items ), 7959 existingButtons = allButtons.filter( ":ui-button
" ); 7961 // Initialize new buttons 7962 allButtons.not( ":ui-button
" ).button(); 7964 // Refresh existing buttons 7965 existingButtons.button( "refresh
" ); 7967 this.buttons = allButtons 7969 return $( this ).button( "widget
" )[ 0 ]; 7971 .removeClass( "ui-corner-all ui-corner-left ui-corner-right
" ) 7973 .addClass( rtl ? "ui-corner-right
" : "ui-corner-left
" ) 7976 .addClass( rtl ? "ui-corner-left
" : "ui-corner-right
" ) 7981 _destroy: function() { 7982 this.element.removeClass( "ui-buttonset
" ); 7985 return $( this ).button( "widget
" )[ 0 ]; 7987 .removeClass( "ui-corner-left ui-corner-right
" ) 7989 .button( "destroy
" ); 7993 var button = $.ui.button; 8008 $.extend($.ui, { datepicker: { version: "1.11.2
" } }); 8010 var datepicker_instActive; 8012 function datepicker_getZindex( elem ) { 8013 var position, value; 8014 while ( elem.length && elem[ 0 ] !== document ) { 8015 // Ignore z-index if position is set to a value where z-index is ignored by the browser 8016 // This makes behavior of this function consistent across browsers 8017 // WebKit always returns auto if the element is positioned 8018 position = elem.css( "position
" ); 8019 if ( position === "absolute
" || position === "relative
" || position === "fixed
" ) { 8020 // IE returns 0 when zIndex is not specified 8021 // other browsers return a string 8022 // we ignore the case of nested elements with an explicit value of 0 8023 // <div style="z-index: -10;
"><div style="z-index: 0;
"></div></div> 8024 value = parseInt( elem.css( "zIndex
" ), 10 ); 8025 if ( !isNaN( value ) && value !== 0 ) { 8029 elem = elem.parent(); 8034 /* Date picker manager. 8035 Use the singleton instance of this class, $.datepicker, to interact with the date picker. 8036 Settings for (groups of) date pickers are maintained in an instance object, 8037 allowing multiple different settings on the same page. */ 8039 function Datepicker() { 8040 this._curInst = null; // The current instance in use 8041 this._keyEvent = false; // If the last event was a key event 8042 this._disabledInputs = []; // List of date picker inputs that have been disabled 8043 this._datepickerShowing = false; // True if the popup picker is showing , false if not 8044 this._inDialog = false; // True if showing within a "dialog
", false if not 8045 this._mainDivId = "ui-datepicker-div
"; // The ID of the main datepicker division 8046 this._inlineClass = "ui-datepicker-
inline"; // The name of the inline marker class 8047 this._appendClass = "ui-datepicker-append
"; // The name of the append marker class 8048 this._triggerClass = "ui-datepicker-trigger
"; // The name of the trigger marker class 8049 this._dialogClass = "ui-datepicker-dialog
"; // The name of the dialog marker class 8050 this._disableClass = "ui-datepicker-disabled
"; // The name of the disabled covering marker class 8051 this._unselectableClass = "ui-datepicker-unselectable
"; // The name of the unselectable cell marker class 8052 this._currentClass = "ui-datepicker-current-day
"; // The name of the current day marker class 8053 this._dayOverClass = "ui-datepicker-days-cell-over
"; // The name of the day hover marker class 8054 this.regional = []; // Available regional settings, indexed by language code 8055 this.regional[""] = { // Default regional settings 8056 closeText: "Done
", // Display text for close link 8057 prevText: "Prev
", // Display text for previous month link 8058 nextText: "Next
", // Display text for next month link 8059 currentText: "Today
", // Display text for current month link 8060 monthNames: ["January
","February
","March
","April
","May
","June
", 8061 "July
","August
","September
","October
","November
","December
"], // Names of months for drop-down and formatting 8062 monthNamesShort: ["Jan
", "Feb
", "Mar
", "Apr
", "May
", "Jun
", "Jul
", "Aug
", "Sep
", "Oct
", "Nov
", "Dec
"], // For formatting 8063 dayNames: ["Sunday
", "Monday
", "Tuesday
", "Wednesday
", "Thursday
", "Friday
", "Saturday
"], // For formatting 8064 dayNamesShort: ["Sun
", "Mon
", "Tue
", "Wed
", "Thu
", "Fri
", "Sat
"], // For formatting 8065 dayNamesMin: ["Su
","Mo
","Tu
","We
","Th
","Fr
","Sa
"], // Column headings for days starting at Sunday 8066 weekHeader: "Wk
", // Column header for week of the year 8067 dateFormat: "mm/dd/yy
", // See format options on parseDate 8068 firstDay: 0, // The first day of the week, Sun = 0, Mon = 1, ... 8069 isRTL: false, // True if right-to-left language, false if left-to-right 8070 showMonthAfterYear: false, // True if the year select precedes month, false for month then year 8071 yearSuffix: "" // Additional text to append to the year in the month headers 8073 this._defaults = { // Global defaults for all the date picker instances 8074 showOn: "focus
", // "focus
" for popup on focus, 8075 // "button
" for trigger button, or "both
" for either 8076 showAnim: "fadeIn
", // Name of jQuery animation for popup 8077 showOptions: {}, // Options for enhanced animations 8078 defaultDate: null, // Used when field is blank: actual date, 8079 // +/-number for offset from today, null for today 8080 appendText: "", // Display text following the input box, e.g. showing the format 8081 buttonText: "...
", // Text for trigger button 8082 buttonImage: "", // URL for trigger button image 8083 buttonImageOnly: false, // True if the image appears alone, false if it appears on a button 8084 hideIfNoPrevNext: false, // True to hide next/previous month links 8085 // if not applicable, false to just disable them 8086 navigationAsDateFormat: false, // True if date formatting applied to prev/today/next links 8087 gotoCurrent: false, // True if today link goes back to current selection instead 8088 changeMonth: false, // True if month can be selected directly, false if only prev/next 8089 changeYear: false, // True if year can be selected directly, false if only prev/next 8090 yearRange: "c-10:c+10
", // Range of years to display in drop-down, 8091 // either relative to today's year (-nn:+nn), relative to currently displayed year 8092 // (c-nn:c+nn), absolute (nnnn:nnnn), or a combination of the above (nnnn:-n) 8093 showOtherMonths: false, // True to show dates in other months, false to leave blank 8094 selectOtherMonths: false, // True to allow selection of dates in other months, false for unselectable 8095 showWeek: false, // True to show week of the year, false to not show it 8096 calculateWeek: this.iso8601Week, // How to calculate the week of the year, 8097 // takes a Date and returns the number of the week for it 8098 shortYearCutoff: "+10
", // Short year values < this are in the current century, 8099 // > this are in the previous century, 8100 // string value starting with "+
" for current year + value 8101 minDate: null, // The earliest selectable date, or null for no limit 8102 maxDate: null, // The latest selectable date, or null for no limit 8103 duration: "fast
", // Duration of display/closure 8104 beforeShowDay: null, // Function that takes a date and returns an array with 8105 // [0] = true if selectable, false if not, [1] = custom CSS class name(s) or "", 8106 // [2] = cell title (optional), e.g. $.datepicker.noWeekends 8107 beforeShow: null, // Function that takes an input field and 8108 // returns a set of custom settings for the date picker 8109 onSelect: null, // Define a callback function when a date is selected 8110 onChangeMonthYear: null, // Define a callback function when the month or year is changed 8111 onClose: null, // Define a callback function when the datepicker is closed 8112 numberOfMonths: 1, // Number of months to show at a time 8113 showCurrentAtPos: 0, // The position in multipe months at which to show the current month (starting at 0) 8114 stepMonths: 1, // Number of months to step back/forward 8115 stepBigMonths: 12, // Number of months to step back/forward for the big links 8116 altField: "", // Selector for an alternate field to store selected dates into 8117 altFormat: "", // The date format to use for the alternate field 8118 constrainInput: true, // The input is constrained by the current date format 8119 showButtonPanel: false, // True to show button panel, false to not show it 8120 autoSize: false, // True to size the input for the date format, false to leave as is 8121 disabled: false // The initial disabled state 8123 $.extend(this._defaults, this.regional[""]); 8124 this.regional.en = $.extend( true, {}, this.regional[ "" ]); 8125 this.regional[ "en-US
" ] = $.extend( true, {}, this.regional.en ); 8126 this.dpDiv = datepicker_bindHover($("<div
id=
'" + this._mainDivId + "' class=
'ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all'></div>
")); 8129 $.extend(Datepicker.prototype, { 8130 /* Class name added to elements to indicate already configured with a date picker. */ 8131 markerClassName: "hasDatepicker
", 8133 //Keep track of the maximum number of rows displayed (see #7043) 8136 // TODO rename to "widget
" when switching to widget factory 8137 _widgetDatepicker: function() { 8141 /* Override the default settings for all instances of the date picker. 8142 * @param settings object - the new settings to use as defaults (anonymous object) 8143 * @return the manager object 8145 setDefaults: function(settings) { 8146 datepicker_extendRemove(this._defaults, settings || {}); 8150 /* Attach the date picker to a jQuery selection. 8151 * @param target element - the target input field or division or span 8152 * @param settings object - the new settings to use for this date picker instance (anonymous) 8154 _attachDatepicker: function(target, settings) { 8155 var nodeName, inline, inst; 8156 nodeName = target.nodeName.toLowerCase(); 8157 inline = (nodeName === "div
" || nodeName === "span
"); 8160 target.id = "dp
" + this.uuid; 8162 inst = this._newInst($(target), inline); 8163 inst.settings = $.extend({}, settings || {}); 8164 if (nodeName === "input
") { 8165 this._connectDatepicker(target, inst); 8166 } else if (inline) { 8167 this._inlineDatepicker(target, inst); 8171 /* Create a new instance object. */ 8172 _newInst: function(target, inline) { 8173 var id = target[0].id.replace(/([^A-Za-z0-9_\-])/g, "\\\\$1
"); // escape jQuery meta chars 8174 return {id: id, input: target, // associated target 8175 selectedDay: 0, selectedMonth: 0, selectedYear: 0, // current selection 8176 drawMonth: 0, drawYear: 0, // month being drawn 8177 inline: inline, // is datepicker inline or not 8178 dpDiv: (!inline ? this.dpDiv : // presentation div 8179 datepicker_bindHover($("<div
class=
'" + this._inlineClass + " ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all'></div>
")))}; 8182 /* Attach the date picker to an input field. */ 8183 _connectDatepicker: function(target, inst) { 8184 var input = $(target); 8185 inst.append = $([]); 8186 inst.trigger = $([]); 8187 if (input.hasClass(this.markerClassName)) { 8190 this._attachments(input, inst); 8191 input.addClass(this.markerClassName).keydown(this._doKeyDown). 8192 keypress(this._doKeyPress).keyup(this._doKeyUp); 8193 this._autoSize(inst); 8194 $.data(target, "datepicker
", inst); 8195 //If disabled option is true, disable the datepicker once it has been attached to the input (see ticket #5665) 8196 if( inst.settings.disabled ) { 8197 this._disableDatepicker( target ); 8201 /* Make attachments based on settings. */ 8202 _attachments: function(input, inst) { 8203 var showOn, buttonText, buttonImage, 8204 appendText = this._get(inst, "appendText
"), 8205 isRTL = this._get(inst, "isRTL
"); 8208 inst.append.remove(); 8211 inst.append = $("<span
class=
'" + this._appendClass + "'>
" + appendText + "</span>
"); 8212 input[isRTL ? "before
" : "after
"](inst.append); 8215 input.unbind("focus
", this._showDatepicker); 8218 inst.trigger.remove(); 8221 showOn = this._get(inst, "showOn
"); 8222 if (showOn === "focus
" || showOn === "both
") { // pop-up date picker when in the marked field 8223 input.focus(this._showDatepicker); 8225 if (showOn === "button
" || showOn === "both
") { // pop-up date picker when button clicked 8226 buttonText = this._get(inst, "buttonText
"); 8227 buttonImage = this._get(inst, "buttonImage
"); 8228 inst.trigger = $(this._get(inst, "buttonImageOnly
") ? 8229 $("<img/>
").addClass(this._triggerClass). 8230 attr({ src: buttonImage, alt: buttonText, title: buttonText }) : 8231 $("<button type=
'button'></button>
").addClass(this._triggerClass). 8232 html(!buttonImage ? buttonText : $("<img/>
").attr( 8233 { src:buttonImage, alt:buttonText, title:buttonText }))); 8234 input[isRTL ? "before
" : "after
"](inst.trigger); 8235 inst.trigger.click(function() { 8236 if ($.datepicker._datepickerShowing && $.datepicker._lastInput === input[0]) { 8237 $.datepicker._hideDatepicker(); 8238 } else if ($.datepicker._datepickerShowing && $.datepicker._lastInput !== input[0]) { 8239 $.datepicker._hideDatepicker(); 8240 $.datepicker._showDatepicker(input[0]); 8242 $.datepicker._showDatepicker(input[0]); 8249 /* Apply the maximum length for the date format. */ 8250 _autoSize: function(inst) { 8251 if (this._get(inst, "autoSize
") && !inst.inline) { 8252 var findMax, max, maxI, i, 8253 date = new Date(2009, 12 - 1, 20), // Ensure double digits 8254 dateFormat = this._get(inst, "dateFormat
"); 8256 if (dateFormat.match(/[DM]/)) { 8257 findMax = function(names) { 8260 for (i = 0; i < names.length; i++) { 8261 if (names[i].length > max) { 8262 max = names[i].length; 8268 date.setMonth(findMax(this._get(inst, (dateFormat.match(/MM/) ? 8269 "monthNames
" : "monthNamesShort
")))); 8270 date.setDate(findMax(this._get(inst, (dateFormat.match(/DD/) ? 8271 "dayNames
" : "dayNamesShort
"))) + 20 - date.getDay()); 8273 inst.input.attr("size", this._formatDate(inst, date).length); 8277 /* Attach an inline date picker to a div. */ 8278 _inlineDatepicker: function(target, inst) { 8279 var divSpan = $(target); 8280 if (divSpan.hasClass(this.markerClassName)) { 8283 divSpan.addClass(this.markerClassName).append(inst.dpDiv); 8284 $.data(target, "datepicker
", inst); 8285 this._setDate(inst, this._getDefaultDate(inst), true); 8286 this._updateDatepicker(inst); 8287 this._updateAlternate(inst); 8288 //If disabled option is true, disable the datepicker before showing it (see ticket #5665) 8289 if( inst.settings.disabled ) { 8290 this._disableDatepicker( target ); 8292 // Set display:block in place of inst.dpDiv.show() which won't work on disconnected elements 8293 // http://bugs.jqueryui.com/ticket/7552 - A Datepicker created on a detached div has zero height 8294 inst.dpDiv.css( "display
", "block
" ); 8297 /* Pop-up the date picker in a "dialog
" box. 8298 * @param input element - ignored 8299 * @param date string or Date - the initial date to display 8300 * @param onSelect function - the function to call when a date is selected 8301 * @param settings object - update the dialog date picker instance's settings (anonymous object) 8302 * @param pos int[2] - coordinates for the dialog's position within the screen or 8303 * event - with x/y coordinates or 8304 * leave empty for default (screen centre) 8305 * @return the manager object 8307 _dialogDatepicker: function(input, date, onSelect, settings, pos) { 8308 var id, browserWidth, browserHeight, scrollX, scrollY, 8309 inst = this._dialogInst; // internal instance 8313 id = "dp
" + this.uuid; 8314 this._dialogInput = $("<input type=
'text' id=
'" + id + 8315 "' style=
'position: absolute; top: -100px; width: 0px;'/>
"); 8316 this._dialogInput.keydown(this._doKeyDown); 8317 $("body
").append(this._dialogInput); 8318 inst = this._dialogInst = this._newInst(this._dialogInput, false); 8320 $.data(this._dialogInput[0], "datepicker
", inst); 8322 datepicker_extendRemove(inst.settings, settings || {}); 8323 date = (date && date.constructor === Date ? this._formatDate(inst, date) : date); 8324 this._dialogInput.val(date); 8326 this._pos = (pos ? (pos.length ? pos : [pos.pageX, pos.pageY]) : null); 8328 browserWidth = document.documentElement.clientWidth; 8329 browserHeight = document.documentElement.clientHeight; 8330 scrollX = document.documentElement.scrollLeft || document.body.scrollLeft; 8331 scrollY = document.documentElement.scrollTop || document.body.scrollTop; 8332 this._pos = // should use actual width/height below 8333 [(browserWidth / 2) - 100 + scrollX, (browserHeight / 2) - 150 + scrollY]; 8336 // move input on screen for focus, but hidden behind dialog 8337 this._dialogInput.css("left
", (this._pos[0] + 20) + "px
").css("top
", this._pos[1] + "px
"); 8338 inst.settings.onSelect = onSelect; 8339 this._inDialog = true; 8340 this.dpDiv.addClass(this._dialogClass); 8341 this._showDatepicker(this._dialogInput[0]); 8343 $.blockUI(this.dpDiv); 8345 $.data(this._dialogInput[0], "datepicker
", inst); 8349 /* Detach a datepicker from its control. 8350 * @param target element - the target input field or division or span 8352 _destroyDatepicker: function(target) { 8354 $target = $(target), 8355 inst = $.data(target, "datepicker
"); 8357 if (!$target.hasClass(this.markerClassName)) { 8361 nodeName = target.nodeName.toLowerCase(); 8362 $.removeData(target, "datepicker
"); 8363 if (nodeName === "input
") { 8364 inst.append.remove(); 8365 inst.trigger.remove(); 8366 $target.removeClass(this.markerClassName). 8367 unbind("focus
", this._showDatepicker). 8368 unbind("keydown
", this._doKeyDown). 8369 unbind("keypress
", this._doKeyPress). 8370 unbind("keyup
", this._doKeyUp); 8371 } else if (nodeName === "div
" || nodeName === "span
") { 8372 $target.removeClass(this.markerClassName).empty(); 8376 /* Enable the date picker to a jQuery selection. 8377 * @param target element - the target input field or division or span 8379 _enableDatepicker: function(target) { 8380 var nodeName, inline, 8381 $target = $(target), 8382 inst = $.data(target, "datepicker
"); 8384 if (!$target.hasClass(this.markerClassName)) { 8388 nodeName = target.nodeName.toLowerCase(); 8389 if (nodeName === "input
") { 8390 target.disabled = false; 8391 inst.trigger.filter("button
"). 8392 each(function() { this.disabled = false; }).end(). 8393 filter("img
").css({opacity: "1.0
", cursor: ""}); 8394 } else if (nodeName === "div
" || nodeName === "span
") { 8395 inline = $target.children(".
" + this._inlineClass); 8396 inline.children().removeClass("ui-state-disabled
"); 8397 inline.find("select.ui-datepicker-month, select.ui-datepicker-year
"). 8398 prop("disabled
", false); 8400 this._disabledInputs = $.map(this._disabledInputs, 8401 function(value) { return (value === target ? null : value); }); // delete entry 8404 /* Disable the date picker to a jQuery selection. 8405 * @param target element - the target input field or division or span 8407 _disableDatepicker: function(target) { 8408 var nodeName, inline, 8409 $target = $(target), 8410 inst = $.data(target, "datepicker
"); 8412 if (!$target.hasClass(this.markerClassName)) { 8416 nodeName = target.nodeName.toLowerCase(); 8417 if (nodeName === "input
") { 8418 target.disabled = true; 8419 inst.trigger.filter("button
"). 8420 each(function() { this.disabled = true; }).end(). 8421 filter("img
").css({opacity: "0.5
", cursor: "default
"}); 8422 } else if (nodeName === "div
" || nodeName === "span
") { 8423 inline = $target.children(".
" + this._inlineClass); 8424 inline.children().addClass("ui-state-disabled
"); 8425 inline.find("select.ui-datepicker-month, select.ui-datepicker-year
"). 8426 prop("disabled
", true); 8428 this._disabledInputs = $.map(this._disabledInputs, 8429 function(value) { return (value === target ? null : value); }); // delete entry 8430 this._disabledInputs[this._disabledInputs.length] = target; 8433 /* Is the first field in a jQuery collection disabled as a datepicker? 8434 * @param target element - the target input field or division or span 8435 * @return boolean - true if disabled, false if enabled 8437 _isDisabledDatepicker: function(target) { 8441 for (var i = 0; i < this._disabledInputs.length; i++) { 8442 if (this._disabledInputs[i] === target) { 8449 /* Retrieve the instance data for the target control. 8450 * @param target element - the target input field or division or span 8451 * @return object - the associated instance data 8452 * @throws error if a jQuery problem getting data 8454 _getInst: function(target) { 8456 return $.data(target, "datepicker
"); 8459 throw "Missing instance data
for this datepicker
"; 8463 /* Update or retrieve the settings for a date picker attached to an input field or division. 8464 * @param target element - the target input field or division or span 8465 * @param name object - the new settings to update or 8466 * string - the name of the setting to change or retrieve, 8467 * when retrieving also "all
" for all instance settings or 8468 * "defaults
" for all global defaults 8469 * @param value any - the new value for the setting 8470 * (omit if above is an object or to retrieve a value) 8472 _optionDatepicker: function(target, name, value) { 8473 var settings, date, minDate, maxDate, 8474 inst = this._getInst(target); 8476 if (arguments.length === 2 && typeof name === "string") { 8477 return (name === "defaults
" ? $.extend({}, $.datepicker._defaults) : 8478 (inst ? (name === "all
" ? $.extend({}, inst.settings) : 8479 this._get(inst, name)) : null)); 8482 settings = name || {}; 8483 if (typeof name === "string") { 8485 settings[name] = value; 8489 if (this._curInst === inst) { 8490 this._hideDatepicker(); 8493 date = this._getDateDatepicker(target, true); 8494 minDate = this._getMinMaxDate(inst, "min
"); 8495 maxDate = this._getMinMaxDate(inst, "max
"); 8496 datepicker_extendRemove(inst.settings, settings); 8497 // reformat the old minDate/maxDate values if dateFormat changes and a new minDate/maxDate isn't provided 8498 if (minDate !== null && settings.dateFormat !== undefined && settings.minDate === undefined) { 8499 inst.settings.minDate = this._formatDate(inst, minDate); 8501 if (maxDate !== null && settings.dateFormat !== undefined && settings.maxDate === undefined) { 8502 inst.settings.maxDate = this._formatDate(inst, maxDate); 8504 if ( "disabled
" in settings ) { 8505 if ( settings.disabled ) { 8506 this._disableDatepicker(target); 8508 this._enableDatepicker(target); 8511 this._attachments($(target), inst); 8512 this._autoSize(inst); 8513 this._setDate(inst, date); 8514 this._updateAlternate(inst); 8515 this._updateDatepicker(inst); 8519 // change method deprecated 8520 _changeDatepicker: function(target, name, value) { 8521 this._optionDatepicker(target, name, value); 8524 /* Redraw the date picker attached to an input field or division. 8525 * @param target element - the target input field or division or span 8527 _refreshDatepicker: function(target) { 8528 var inst = this._getInst(target); 8530 this._updateDatepicker(inst); 8534 /* Set the dates for a jQuery selection. 8535 * @param target element - the target input field or division or span 8536 * @param date Date - the new date 8538 _setDateDatepicker: function(target, date) { 8539 var inst = this._getInst(target); 8541 this._setDate(inst, date); 8542 this._updateDatepicker(inst); 8543 this._updateAlternate(inst); 8547 /* Get the date(s) for the first entry in a jQuery selection. 8548 * @param target element - the target input field or division or span 8549 * @param noDefault boolean - true if no default date is to be used 8550 * @return Date - the current date 8552 _getDateDatepicker: function(target, noDefault) { 8553 var inst = this._getInst(target); 8554 if (inst && !inst.inline) { 8555 this._setDateFromField(inst, noDefault); 8557 return (inst ? this._getDate(inst) : null); 8560 /* Handle keystrokes. */ 8561 _doKeyDown: function(event) { 8562 var onSelect, dateStr, sel, 8563 inst = $.datepicker._getInst(event.target), 8565 isRTL = inst.dpDiv.is(".ui-datepicker-rtl
"); 8567 inst._keyEvent = true; 8568 if ($.datepicker._datepickerShowing) { 8569 switch (event.keyCode) { 8570 case 9: $.datepicker._hideDatepicker(); 8572 break; // hide on tab out 8573 case 13: sel = $("td.
" + $.datepicker._dayOverClass + ":not(.
" + 8574 $.datepicker._currentClass + ")
", inst.dpDiv); 8576 $.datepicker._selectDay(event.target, inst.selectedMonth, inst.selectedYear, sel[0]); 8579 onSelect = $.datepicker._get(inst, "onSelect
"); 8581 dateStr = $.datepicker._formatDate(inst); 8583 // trigger custom callback 8584 onSelect.apply((inst.input ? inst.input[0] : null), [dateStr, inst]); 8586 $.datepicker._hideDatepicker(); 8589 return false; // don't submit the form 8590 case 27: $.datepicker._hideDatepicker(); 8591 break; // hide on escape 8592 case 33: $.datepicker._adjustDate(event.target, (event.ctrlKey ? 8593 -$.datepicker._get(inst, "stepBigMonths
") : 8594 -$.datepicker._get(inst, "stepMonths
")), "M
"); 8595 break; // previous month/year on page up/+ ctrl 8596 case 34: $.datepicker._adjustDate(event.target, (event.ctrlKey ? 8597 +$.datepicker._get(inst, "stepBigMonths
") : 8598 +$.datepicker._get(inst, "stepMonths
")), "M
"); 8599 break; // next month/year on page down/+ ctrl 8600 case 35: if (event.ctrlKey || event.metaKey) { 8601 $.datepicker._clearDate(event.target); 8603 handled = event.ctrlKey || event.metaKey; 8604 break; // clear on ctrl or command +end 8605 case 36: if (event.ctrlKey || event.metaKey) { 8606 $.datepicker._gotoToday(event.target); 8608 handled = event.ctrlKey || event.metaKey; 8609 break; // current on ctrl or command +home 8610 case 37: if (event.ctrlKey || event.metaKey) { 8611 $.datepicker._adjustDate(event.target, (isRTL ? +1 : -1), "D
"); 8613 handled = event.ctrlKey || event.metaKey; 8614 // -1 day on ctrl or command +left 8615 if (event.originalEvent.altKey) { 8616 $.datepicker._adjustDate(event.target, (event.ctrlKey ? 8617 -$.datepicker._get(inst, "stepBigMonths
") : 8618 -$.datepicker._get(inst, "stepMonths
")), "M
"); 8620 // next month/year on alt +left on Mac 8622 case 38: if (event.ctrlKey || event.metaKey) { 8623 $.datepicker._adjustDate(event.target, -7, "D
"); 8625 handled = event.ctrlKey || event.metaKey; 8626 break; // -1 week on ctrl or command +up 8627 case 39: if (event.ctrlKey || event.metaKey) { 8628 $.datepicker._adjustDate(event.target, (isRTL ? -1 : +1), "D
"); 8630 handled = event.ctrlKey || event.metaKey; 8631 // +1 day on ctrl or command +right 8632 if (event.originalEvent.altKey) { 8633 $.datepicker._adjustDate(event.target, (event.ctrlKey ? 8634 +$.datepicker._get(inst, "stepBigMonths
") : 8635 +$.datepicker._get(inst, "stepMonths
")), "M
"); 8637 // next month/year on alt +right 8639 case 40: if (event.ctrlKey || event.metaKey) { 8640 $.datepicker._adjustDate(event.target, +7, "D
"); 8642 handled = event.ctrlKey || event.metaKey; 8643 break; // +1 week on ctrl or command +down 8644 default: handled = false; 8646 } else if (event.keyCode === 36 && event.ctrlKey) { // display the date picker on ctrl+home 8647 $.datepicker._showDatepicker(this); 8653 event.preventDefault(); 8654 event.stopPropagation(); 8658 /* Filter entered characters - based on date format. */ 8659 _doKeyPress: function(event) { 8661 inst = $.datepicker._getInst(event.target); 8663 if ($.datepicker._get(inst, "constrainInput
")) { 8664 chars = $.datepicker._possibleChars($.datepicker._get(inst, "dateFormat
")); 8665 chr = String.fromCharCode(event.charCode == null ? event.keyCode : event.charCode); 8666 return event.ctrlKey || event.metaKey || (chr < " " || !chars || chars.indexOf(chr) > -1); 8670 /* Synchronise manual entry and field/alternate field. */ 8671 _doKeyUp: function(event) { 8673 inst = $.datepicker._getInst(event.target); 8675 if (inst.input.val() !== inst.lastVal) { 8677 date = $.datepicker.parseDate($.datepicker._get(inst, "dateFormat
"), 8678 (inst.input ? inst.input.val() : null), 8679 $.datepicker._getFormatConfig(inst)); 8681 if (date) { // only if valid 8682 $.datepicker._setDateFromField(inst); 8683 $.datepicker._updateAlternate(inst); 8684 $.datepicker._updateDatepicker(inst); 8693 /* Pop-up the date picker for a given input field. 8694 * If false returned from beforeShow event handler do not show. 8695 * @param input element - the input field attached to the date picker or 8696 * event - if triggered by focus 8698 _showDatepicker: function(input) { 8699 input = input.target || input; 8700 if (input.nodeName.toLowerCase() !== "input
") { // find from button/image trigger 8701 input = $("input
", input.parentNode)[0]; 8704 if ($.datepicker._isDisabledDatepicker(input) || $.datepicker._lastInput === input) { // already here 8708 var inst, beforeShow, beforeShowSettings, isFixed, 8709 offset, showAnim, duration; 8711 inst = $.datepicker._getInst(input); 8712 if ($.datepicker._curInst && $.datepicker._curInst !== inst) { 8713 $.datepicker._curInst.dpDiv.stop(true, true); 8714 if ( inst && $.datepicker._datepickerShowing ) { 8715 $.datepicker._hideDatepicker( $.datepicker._curInst.input[0] ); 8719 beforeShow = $.datepicker._get(inst, "beforeShow
"); 8720 beforeShowSettings = beforeShow ? beforeShow.apply(input, [input, inst]) : {}; 8721 if(beforeShowSettings === false){ 8724 datepicker_extendRemove(inst.settings, beforeShowSettings); 8726 inst.lastVal = null; 8727 $.datepicker._lastInput = input; 8728 $.datepicker._setDateFromField(inst); 8730 if ($.datepicker._inDialog) { // hide cursor 8733 if (!$.datepicker._pos) { // position below input 8734 $.datepicker._pos = $.datepicker._findPos(input); 8735 $.datepicker._pos[1] += input.offsetHeight; // add the height 8739 $(input).parents().each(function() { 8740 isFixed |= $(this).css("position
") === "fixed
"; 8744 offset = {left: $.datepicker._pos[0], top: $.datepicker._pos[1]}; 8745 $.datepicker._pos = null; 8746 //to avoid flashes on Firefox 8748 // determine sizing offscreen 8749 inst.dpDiv.css({position: "absolute
", display: "block
", top: "-1000px
"}); 8750 $.datepicker._updateDatepicker(inst); 8751 // fix width for dynamic number of date pickers 8752 // and adjust position before showing 8753 offset = $.datepicker._checkOffset(inst, offset, isFixed); 8754 inst.dpDiv.css({position: ($.datepicker._inDialog && $.blockUI ? 8755 "static" : (isFixed ? "fixed
" : "absolute
")), display: "none
", 8756 left: offset.left + "px
", top: offset.top + "px
"}); 8759 showAnim = $.datepicker._get(inst, "showAnim
"); 8760 duration = $.datepicker._get(inst, "duration
"); 8761 inst.dpDiv.css( "z-index
", datepicker_getZindex( $( input ) ) + 1 ); 8762 $.datepicker._datepickerShowing = true; 8764 if ( $.effects && $.effects.effect[ showAnim ] ) { 8765 inst.dpDiv.show(showAnim, $.datepicker._get(inst, "showOptions
"), duration); 8767 inst.dpDiv[showAnim || "show
"](showAnim ? duration : null); 8770 if ( $.datepicker._shouldFocusInput( inst ) ) { 8774 $.datepicker._curInst = inst; 8778 /* Generate the date picker content. */ 8779 _updateDatepicker: function(inst) { 8780 this.maxRows = 4; //Reset the max number of rows being displayed (see #7043) 8781 datepicker_instActive = inst; // for delegate hover events 8782 inst.dpDiv.empty().append(this._generateHTML(inst)); 8783 this._attachHandlers(inst); 8786 numMonths = this._getNumberOfMonths(inst), 8787 cols = numMonths[1], 8789 activeCell = inst.dpDiv.find( ".
" + this._dayOverClass + " a
" ); 8791 if ( activeCell.length > 0 ) { 8792 datepicker_handleMouseover.apply( activeCell.get( 0 ) ); 8795 inst.dpDiv.removeClass("ui-datepicker-multi-2 ui-datepicker-multi-3 ui-datepicker-multi-4
").width(""); 8797 inst.dpDiv.addClass("ui-datepicker-multi-
" + cols).css("width
", (width * cols) + "em
"); 8799 inst.dpDiv[(numMonths[0] !== 1 || numMonths[1] !== 1 ? "add
" : "remove") + 8800 "Class
"]("ui-datepicker-multi
"); 8801 inst.dpDiv[(this._get(inst, "isRTL
") ? "add
" : "remove") + 8802 "Class
"]("ui-datepicker-rtl
"); 8804 if (inst === $.datepicker._curInst && $.datepicker._datepickerShowing && $.datepicker._shouldFocusInput( inst ) ) { 8808 // deffered render of the years select (to avoid flashes on Firefox) 8809 if( inst.yearshtml ){ 8810 origyearshtml = inst.yearshtml; 8811 setTimeout(function(){ 8812 //assure that inst.yearshtml didn't change. 8813 if( origyearshtml === inst.yearshtml && inst.yearshtml ){ 8814 inst.dpDiv.find("select.ui-datepicker-year:first
").replaceWith(inst.yearshtml); 8816 origyearshtml = inst.yearshtml = null; 8821 // #6694 - don't focus the input if it's already focused 8822 // this breaks the change event in IE 8823 // Support: IE and jQuery <1.9 8824 _shouldFocusInput: function( inst ) { 8825 return inst.input && inst.input.is( ":visible
" ) && !inst.input.is( ":disabled
" ) && !inst.input.is( ":focus
" ); 8828 /* Check positioning to remain on screen. */ 8829 _checkOffset: function(inst, offset, isFixed) { 8830 var dpWidth = inst.dpDiv.outerWidth(), 8831 dpHeight = inst.dpDiv.outerHeight(), 8832 inputWidth = inst.input ? inst.input.outerWidth() : 0, 8833 inputHeight = inst.input ? inst.input.outerHeight() : 0, 8834 viewWidth = document.documentElement.clientWidth + (isFixed ? 0 : $(document).scrollLeft()), 8835 viewHeight = document.documentElement.clientHeight + (isFixed ? 0 : $(document).scrollTop()); 8837 offset.left -= (this._get(inst, "isRTL
") ? (dpWidth - inputWidth) : 0); 8838 offset.left -= (isFixed && offset.left === inst.input.offset().left) ? $(document).scrollLeft() : 0; 8839 offset.top -= (isFixed && offset.top === (inst.input.offset().top + inputHeight)) ? $(document).scrollTop() : 0; 8841 // now check if datepicker is showing outside window viewport - move to a better place if so. 8842 offset.left -= Math.min(offset.left, (offset.left + dpWidth > viewWidth && viewWidth > dpWidth) ? 8843 Math.abs(offset.left + dpWidth - viewWidth) : 0); 8844 offset.top -= Math.min(offset.top, (offset.top + dpHeight > viewHeight && viewHeight > dpHeight) ? 8845 Math.abs(dpHeight + inputHeight) : 0); 8850 /* Find an object's position on the screen. */ 8851 _findPos: function(obj) { 8853 inst = this._getInst(obj), 8854 isRTL = this._get(inst, "isRTL
"); 8856 while (obj && (obj.type === "hidden
" || obj.nodeType !== 1 || $.expr.filters.hidden(obj))) { 8857 obj = obj[isRTL ? "previousSibling
" : "nextSibling
"]; 8860 position = $(obj).offset(); 8861 return [position.left, position.top]; 8864 /* Hide the date picker from view. 8865 * @param input element - the input field attached to the date picker 8867 _hideDatepicker: function(input) { 8868 var showAnim, duration, postProcess, onClose, 8869 inst = this._curInst; 8871 if (!inst || (input && inst !== $.data(input, "datepicker
"))) { 8875 if (this._datepickerShowing) { 8876 showAnim = this._get(inst, "showAnim
"); 8877 duration = this._get(inst, "duration
"); 8878 postProcess = function() { 8879 $.datepicker._tidyDialog(inst); 8882 // DEPRECATED: after BC for 1.8.x $.effects[ showAnim ] is not needed 8883 if ( $.effects && ( $.effects.effect[ showAnim ] || $.effects[ showAnim ] ) ) { 8884 inst.dpDiv.hide(showAnim, $.datepicker._get(inst, "showOptions
"), duration, postProcess); 8886 inst.dpDiv[(showAnim === "slideDown
" ? "slideUp
" : 8887 (showAnim === "fadeIn
" ? "fadeOut
" : "hide
"))]((showAnim ? duration : null), postProcess); 8893 this._datepickerShowing = false; 8895 onClose = this._get(inst, "onClose
"); 8897 onClose.apply((inst.input ? inst.input[0] : null), [(inst.input ? inst.input.val() : ""), inst]); 8900 this._lastInput = null; 8901 if (this._inDialog) { 8902 this._dialogInput.css({ position: "absolute
", left: "0
", top: "-100px
" }); 8905 $("body
").append(this.dpDiv); 8908 this._inDialog = false; 8912 /* Tidy up after a dialog display. */ 8913 _tidyDialog: function(inst) { 8914 inst.dpDiv.removeClass(this._dialogClass).unbind(".ui-datepicker-calendar
"); 8917 /* Close date picker if clicked elsewhere. */ 8918 _checkExternalClick: function(event) { 8919 if (!$.datepicker._curInst) { 8923 var $target = $(event.target), 8924 inst = $.datepicker._getInst($target[0]); 8926 if ( ( ( $target[0].id !== $.datepicker._mainDivId && 8927 $target.parents("#
" + $.datepicker._mainDivId).length === 0 && 8928 !$target.hasClass($.datepicker.markerClassName) && 8929 !$target.closest(".
" + $.datepicker._triggerClass).length && 8930 $.datepicker._datepickerShowing && !($.datepicker._inDialog && $.blockUI) ) ) || 8931 ( $target.hasClass($.datepicker.markerClassName) && $.datepicker._curInst !== inst ) ) { 8932 $.datepicker._hideDatepicker(); 8936 /* Adjust one of the date sub-fields. */ 8937 _adjustDate: function(id, offset, period) { 8939 inst = this._getInst(target[0]); 8941 if (this._isDisabledDatepicker(target[0])) { 8944 this._adjustInstDate(inst, offset + 8945 (period === "M
" ? this._get(inst, "showCurrentAtPos
") : 0), // undo positioning 8947 this._updateDatepicker(inst); 8950 /* Action for current link. */ 8951 _gotoToday: function(id) { 8954 inst = this._getInst(target[0]); 8956 if (this._get(inst, "gotoCurrent
") && inst.currentDay) { 8957 inst.selectedDay = inst.currentDay; 8958 inst.drawMonth = inst.selectedMonth = inst.currentMonth; 8959 inst.drawYear = inst.selectedYear = inst.currentYear; 8962 inst.selectedDay = date.getDate(); 8963 inst.drawMonth = inst.selectedMonth = date.getMonth(); 8964 inst.drawYear = inst.selectedYear = date.getFullYear(); 8966 this._notifyChange(inst); 8967 this._adjustDate(target); 8970 /* Action for selecting a new month/year. */ 8971 _selectMonthYear: function(id, select, period) { 8973 inst = this._getInst(target[0]); 8975 inst["selected
" + (period === "M
" ? "Month
" : "Year
")] = 8976 inst["draw
" + (period === "M
" ? "Month
" : "Year
")] = 8977 parseInt(select.options[select.selectedIndex].value,10); 8979 this._notifyChange(inst); 8980 this._adjustDate(target); 8983 /* Action for selecting a day. */ 8984 _selectDay: function(id, month, year, td) { 8988 if ($(td).hasClass(this._unselectableClass) || this._isDisabledDatepicker(target[0])) { 8992 inst = this._getInst(target[0]); 8993 inst.selectedDay = inst.currentDay = $("a
", td).html(); 8994 inst.selectedMonth = inst.currentMonth = month; 8995 inst.selectedYear = inst.currentYear = year; 8996 this._selectDate(id, this._formatDate(inst, 8997 inst.currentDay, inst.currentMonth, inst.currentYear)); 9000 /* Erase the input field and hide the date picker. */ 9001 _clearDate: function(id) { 9003 this._selectDate(target, ""); 9006 /* Update the input field with the selected date. */ 9007 _selectDate: function(id, dateStr) { 9010 inst = this._getInst(target[0]); 9012 dateStr = (dateStr != null ? dateStr : this._formatDate(inst)); 9014 inst.input.val(dateStr); 9016 this._updateAlternate(inst); 9018 onSelect = this._get(inst, "onSelect
"); 9020 onSelect.apply((inst.input ? inst.input[0] : null), [dateStr, inst]); // trigger custom callback 9021 } else if (inst.input) { 9022 inst.input.trigger("change
"); // fire the change event 9026 this._updateDatepicker(inst); 9028 this._hideDatepicker(); 9029 this._lastInput = inst.input[0]; 9030 if (typeof(inst.input[0]) !== "object") { 9031 inst.input.focus(); // restore focus 9033 this._lastInput = null; 9037 /* Update any alternate field to synchronise with the main field. */ 9038 _updateAlternate: function(inst) { 9039 var altFormat, date, dateStr, 9040 altField = this._get(inst, "altField
"); 9042 if (altField) { // update alternate field too 9043 altFormat = this._get(inst, "altFormat
") || this._get(inst, "dateFormat
"); 9044 date = this._getDate(inst); 9045 dateStr = this.formatDate(altFormat, date, this._getFormatConfig(inst)); 9046 $(altField).each(function() { $(this).val(dateStr); }); 9050 /* Set as beforeShowDay function to prevent selection of weekends. 9051 * @param date Date - the date to customise 9052 * @return [boolean, string] - is this date selectable?, what is its CSS class? 9054 noWeekends: function(date) { 9055 var day = date.getDay(); 9056 return [(day > 0 && day < 6), ""]; 9059 /* Set as calculateWeek to determine the week of the year based on the ISO 8601 definition. 9060 * @param date Date - the date to get the week for 9061 * @return number - the number of the week within the year that contains this date 9063 iso8601Week: function(date) { 9065 checkDate = new Date(date.getTime()); 9067 // Find Thursday of this week starting on Monday 9068 checkDate.setDate(checkDate.getDate() + 4 - (checkDate.getDay() || 7)); 9070 time = checkDate.getTime(); 9071 checkDate.setMonth(0); // Compare with Jan 1 9072 checkDate.setDate(1); 9073 return Math.floor(Math.round((time - checkDate) / 86400000) / 7) + 1; 9076 /* Parse a string value into a date object. 9077 * See formatDate below for the possible formats. 9079 * @param format string - the expected format of the date 9080 * @param value string - the date in the above format 9081 * @param settings Object - attributes include: 9082 * shortYearCutoff number - the cutoff year for determining the century (optional) 9083 * dayNamesShort string[7] - abbreviated names of the days from Sunday (optional) 9084 * dayNames string[7] - names of the days from Sunday (optional) 9085 * monthNamesShort string[12] - abbreviated names of the months (optional) 9086 * monthNames string[12] - names of the months (optional) 9087 * @return Date - the extracted date value or null if value is blank 9089 parseDate: function (format, value, settings) { 9090 if (format == null || value == null) { 9091 throw "Invalid arguments
"; 9094 value = (typeof value === "object" ? value.toString() : value + ""); 9099 var iFormat, dim, extra, 9101 shortYearCutoffTemp = (settings ? settings.shortYearCutoff : null) || this._defaults.shortYearCutoff, 9102 shortYearCutoff = (typeof shortYearCutoffTemp !== "string" ? shortYearCutoffTemp : 9103 new Date().getFullYear() % 100 + parseInt(shortYearCutoffTemp, 10)), 9104 dayNamesShort = (settings ? settings.dayNamesShort : null) || this._defaults.dayNamesShort, 9105 dayNames = (settings ? settings.dayNames : null) || this._defaults.dayNames, 9106 monthNamesShort = (settings ? settings.monthNamesShort : null) || this._defaults.monthNamesShort, 9107 monthNames = (settings ? settings.monthNames : null) || this._defaults.monthNames, 9114 // Check whether a format character is doubled 9115 lookAhead = function(match) { 9116 var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) === match); 9122 // Extract a number from the string value 9123 getNumber = function(match) { 9124 var isDoubled = lookAhead(match), 9125 size = (match === "@" ? 14 : (match === "!
" ? 20 : 9126 (match === "y
" && isDoubled ? 4 : (match === "o
" ? 3 : 2)))), 9127 minSize = (match === "y
" ? size : 1), 9128 digits = new RegExp("^\
\d{
" + minSize + ",
" + size + "}
"), 9129 num = value.substring(iValue).match(digits); 9131 throw "Missing number at position
" + iValue; 9133 iValue += num[0].length; 9134 return parseInt(num[0], 10); 9136 // Extract a name from the string value and convert to an index 9137 getName = function(match, shortNames, longNames) { 9139 names = $.map(lookAhead(match) ? longNames : shortNames, function (v, k) { 9141 }).sort(function (a, b) { 9142 return -(a[1].length - b[1].length); 9145 $.each(names, function (i, pair) { 9147 if (value.substr(iValue, name.length).toLowerCase() === name.toLowerCase()) { 9149 iValue += name.length; 9156 throw "Unknown name at position
" + iValue; 9159 // Confirm that a literal character matches the string value 9160 checkLiteral = function() { 9161 if (value.charAt(iValue) !== format.charAt(iFormat)) { 9162 throw "Unexpected literal at position
" + iValue; 9167 for (iFormat = 0; iFormat < format.length; iFormat++) { 9169 if (format.charAt(iFormat) === "'" && !lookAhead("'")) { 9175 switch (format.charAt(iFormat)) { 9177 day = getNumber("d"); 9180 getName("D
", dayNamesShort, dayNames); 9183 doy = getNumber("o
"); 9186 month = getNumber("m
"); 9189 month = getName("M
", monthNamesShort, monthNames); 9192 year = getNumber("y
"); 9195 date = new Date(getNumber("@")); 9196 year = date.getFullYear(); 9197 month = date.getMonth() + 1; 9198 day = date.getDate(); 9201 date = new Date((getNumber("!
") - this._ticksTo1970) / 10000); 9202 year = date.getFullYear(); 9203 month = date.getMonth() + 1; 9204 day = date.getDate(); 9207 if (lookAhead("'")){ 9219 if (iValue < value.length){ 9220 extra = value.substr(iValue); 9221 if (!/^\s+/.test(extra)) { 9222 throw "Extra/unparsed characters found in date:
" + extra; 9227 year = new Date().getFullYear(); 9228 } else if (year < 100) { 9229 year += new Date().getFullYear() - new Date().getFullYear() % 100 + 9230 (year <= shortYearCutoff ? 0 : -100); 9237 dim = this._getDaysInMonth(year, month - 1); 9246 date = this._daylightSavingAdjust(new Date(year, month - 1, day)); 9247 if (date.getFullYear() !== year || date.getMonth() + 1 !== month || date.getDate() !== day) { 9248 throw "Invalid date
"; // E.g. 31/02/00 9253 /* Standard date formats. */ 9254 ATOM: "yy-mm-dd
", // RFC 3339 (ISO 8601) 9255 COOKIE: "D, dd M yy
", 9256 ISO_8601: "yy-mm-dd
", 9257 RFC_822: "D,
d M y
", 9258 RFC_850: "DD, dd-M-y
", 9259 RFC_1036: "D,
d M y
", 9260 RFC_1123: "D,
d M yy
", 9261 RFC_2822: "D,
d M yy
", 9262 RSS: "D,
d M y
", // RFC 822 9265 W3C: "yy-mm-dd
", // ISO 8601 9267 _ticksTo1970: (((1970 - 1) * 365 + Math.floor(1970 / 4) - Math.floor(1970 / 100) + 9268 Math.floor(1970 / 400)) * 24 * 60 * 60 * 10000000), 9270 /* Format a date object into a string value. 9271 * The format can be combinations of the following: 9272 * d - day of month (no leading zero) 9273 * dd - day of month (two digit) 9274 * o - day of year (no leading zeros) 9275 * oo - day of year (three digit) 9276 * D - day name short 9277 * DD - day name long 9278 * m - month of year (no leading zero) 9279 * mm - month of year (two digit) 9280 * M - month name short 9281 * MM - month name long 9282 * y - year (two digit) 9283 * yy - year (four digit) 9284 * @ - Unix timestamp (ms since 01/01/1970) 9285 * ! - Windows ticks (100ns since 01/01/0001) 9286 * "...
" - literal text 9289 * @param format string - the desired format of the date 9290 * @param date Date - the date value to format 9291 * @param settings Object - attributes include: 9292 * dayNamesShort string[7] - abbreviated names of the days from Sunday (optional) 9293 * dayNames string[7] - names of the days from Sunday (optional) 9294 * monthNamesShort string[12] - abbreviated names of the months (optional) 9295 * monthNames string[12] - names of the months (optional) 9296 * @return string - the date in the above format 9298 formatDate: function (format, date, settings) { 9304 dayNamesShort = (settings ? settings.dayNamesShort : null) || this._defaults.dayNamesShort, 9305 dayNames = (settings ? settings.dayNames : null) || this._defaults.dayNames, 9306 monthNamesShort = (settings ? settings.monthNamesShort : null) || this._defaults.monthNamesShort, 9307 monthNames = (settings ? settings.monthNames : null) || this._defaults.monthNames, 9308 // Check whether a format character is doubled 9309 lookAhead = function(match) { 9310 var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) === match); 9316 // Format a number, with leading zero if necessary 9317 formatNumber = function(match, value, len) { 9318 var num = "" + value; 9319 if (lookAhead(match)) { 9320 while (num.length < len) { 9326 // Format a name, short or long as requested 9327 formatName = function(match, value, shortNames, longNames) { 9328 return (lookAhead(match) ? longNames[value] : shortNames[value]); 9334 for (iFormat = 0; iFormat < format.length; iFormat++) { 9336 if (format.charAt(iFormat) === "'" && !lookAhead("'")) { 9339 output += format.charAt(iFormat); 9342 switch (format.charAt(iFormat)) { 9344 output += formatNumber("d", date.getDate(), 2); 9347 output += formatName("D
", date.getDay(), dayNamesShort, dayNames); 9350 output += formatNumber("o
", 9351 Math.round((new Date(date.getFullYear(), date.getMonth(), date.getDate()).getTime() - new Date(date.getFullYear(), 0, 0).getTime()) / 86400000), 3); 9354 output += formatNumber("m
", date.getMonth() + 1, 2); 9357 output += formatName("M
", date.getMonth(), monthNamesShort, monthNames); 9360 output += (lookAhead("y
") ? date.getFullYear() : 9361 (date.getYear() % 100 < 10 ? "0
" : "") + date.getYear() % 100); 9364 output += date.getTime(); 9367 output += date.getTime() * 10000 + this._ticksTo1970; 9370 if (lookAhead("'")) { 9377 output += format.charAt(iFormat); 9385 /* Extract all possible characters from the date format. */ 9386 _possibleChars: function (format) { 9390 // Check whether a format character is doubled 9391 lookAhead = function(match) { 9392 var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) === match); 9399 for (iFormat = 0; iFormat < format.length; iFormat++) { 9401 if (format.charAt(iFormat) === "'" && !lookAhead("'")) { 9404 chars += format.charAt(iFormat); 9407 switch (format.charAt(iFormat)) { 9408 case "d": case "m": case "y": case "@": 9409 chars += "0123456789"; 9412 return null; // Accept anything 9414 if (lookAhead("'")) { 9421 chars += format.charAt(iFormat); 9428 /* Get a setting value, defaulting if necessary. */ 9429 _get: function(inst, name) { 9430 return inst.settings[name] !== undefined ? 9431 inst.settings[name] : this._defaults[name]; 9434 /* Parse existing date and initialise date picker. */ 9435 _setDateFromField: function(inst, noDefault) { 9436 if (inst.input.val() === inst.lastVal) { 9440 var dateFormat = this._get(inst, "dateFormat
"), 9441 dates = inst.lastVal = inst.input ? inst.input.val() : null, 9442 defaultDate = this._getDefaultDate(inst), 9444 settings = this._getFormatConfig(inst); 9447 date = this.parseDate(dateFormat, dates, settings) || defaultDate; 9449 dates = (noDefault ? "" : dates); 9451 inst.selectedDay = date.getDate(); 9452 inst.drawMonth = inst.selectedMonth = date.getMonth(); 9453 inst.drawYear = inst.selectedYear = date.getFullYear(); 9454 inst.currentDay = (dates ? date.getDate() : 0); 9455 inst.currentMonth = (dates ? date.getMonth() : 0); 9456 inst.currentYear = (dates ? date.getFullYear() : 0); 9457 this._adjustInstDate(inst); 9460 /* Retrieve the default date shown on opening. */ 9461 _getDefaultDate: function(inst) { 9462 return this._restrictMinMax(inst, 9463 this._determineDate(inst, this._get(inst, "defaultDate
"), new Date())); 9466 /* A date may be specified as an exact value or a relative one. */ 9467 _determineDate: function(inst, date, defaultDate) { 9468 var offsetNumeric = function(offset) { 9469 var date = new Date(); 9470 date.setDate(date.getDate() + offset); 9473 offsetString = function(offset) { 9475 return $.datepicker.parseDate($.datepicker._get(inst, "dateFormat
"), 9476 offset, $.datepicker._getFormatConfig(inst)); 9482 var date = (offset.toLowerCase().match(/^c/) ? 9483 $.datepicker._getDate(inst) : null) || new Date(), 9484 year = date.getFullYear(), 9485 month = date.getMonth(), 9486 day = date.getDate(), 9487 pattern = /([+\-]?[0-9]+)\s*(d|D|w|W|m|M|y|Y)?/g, 9488 matches = pattern.exec(offset); 9491 switch (matches[2] || "d") { 9492 case "d" : case "D
" : 9493 day += parseInt(matches[1],10); break; 9494 case "w" : case "W" : 9495 day += parseInt(matches[1],10) * 7; break; 9496 case "m
" : case "M
" : 9497 month += parseInt(matches[1],10); 9498 day = Math.min(day, $.datepicker._getDaysInMonth(year, month)); 9500 case "y
": case "Y
" : 9501 year += parseInt(matches[1],10); 9502 day = Math.min(day, $.datepicker._getDaysInMonth(year, month)); 9505 matches = pattern.exec(offset); 9507 return new Date(year, month, day); 9509 newDate = (date == null || date === "" ? defaultDate : (typeof date === "string" ? offsetString(date) : 9510 (typeof date === "number
" ? (isNaN(date) ? defaultDate : offsetNumeric(date)) : new Date(date.getTime())))); 9512 newDate = (newDate && newDate.toString() === "Invalid Date
" ? defaultDate : newDate); 9514 newDate.setHours(0); 9515 newDate.setMinutes(0); 9516 newDate.setSeconds(0); 9517 newDate.setMilliseconds(0); 9519 return this._daylightSavingAdjust(newDate); 9522 /* Handle switch to/from daylight saving. 9523 * Hours may be non-zero on daylight saving cut-over: 9524 * > 12 when midnight changeover, but then cannot generate 9525 * midnight datetime, so jump to 1AM, otherwise reset. 9526 * @param date (Date) the date to check 9527 * @return (Date) the corrected date 9529 _daylightSavingAdjust: function(date) { 9533 date.setHours(date.getHours() > 12 ? date.getHours() + 2 : 0); 9537 /* Set the date(s) directly. */ 9538 _setDate: function(inst, date, noChange) { 9540 origMonth = inst.selectedMonth, 9541 origYear = inst.selectedYear, 9542 newDate = this._restrictMinMax(inst, this._determineDate(inst, date, new Date())); 9544 inst.selectedDay = inst.currentDay = newDate.getDate(); 9545 inst.drawMonth = inst.selectedMonth = inst.currentMonth = newDate.getMonth(); 9546 inst.drawYear = inst.selectedYear = inst.currentYear = newDate.getFullYear(); 9547 if ((origMonth !== inst.selectedMonth || origYear !== inst.selectedYear) && !noChange) { 9548 this._notifyChange(inst); 9550 this._adjustInstDate(inst); 9552 inst.input.val(clear ? "" : this._formatDate(inst)); 9556 /* Retrieve the date(s) directly. */ 9557 _getDate: function(inst) { 9558 var startDate = (!inst.currentYear || (inst.input && inst.input.val() === "") ? null : 9559 this._daylightSavingAdjust(new Date( 9560 inst.currentYear, inst.currentMonth, inst.currentDay))); 9564 /* Attach the onxxx handlers. These are declared statically so 9565 * they work with static code transformers like Caja. 9567 _attachHandlers: function(inst) { 9568 var stepMonths = this._get(inst, "stepMonths
"), 9569 id = "#
" + inst.id.replace( /\\\\/g, "\\
" ); 9570 inst.dpDiv.find("[data-handler]
").map(function () { 9573 $.datepicker._adjustDate(id, -stepMonths, "M
"); 9576 $.datepicker._adjustDate(id, +stepMonths, "M
"); 9579 $.datepicker._hideDatepicker(); 9581 today: function () { 9582 $.datepicker._gotoToday(id); 9584 selectDay: function () { 9585 $.datepicker._selectDay(id, +this.getAttribute("data-month
"), +this.getAttribute("data-year
"), this); 9588 selectMonth: function () { 9589 $.datepicker._selectMonthYear(id, this, "M
"); 9592 selectYear: function () { 9593 $.datepicker._selectMonthYear(id, this, "Y
"); 9597 $(this).bind(this.getAttribute("data-
event"), handler[this.getAttribute("data-handler
")]); 9601 /* Generate the HTML for the current state of the date picker. */ 9602 _generateHTML: function(inst) { 9603 var maxDraw, prevText, prev, nextText, next, currentText, gotoDate, 9604 controls, buttonPanel, firstDay, showWeek, dayNames, dayNamesMin, 9605 monthNames, monthNamesShort, beforeShowDay, showOtherMonths, 9606 selectOtherMonths, defaultDate, html, dow, row, group, col, selectedDate, 9607 cornerClass, calender, thead, day, daysInMonth, leadDays, curRows, numRows, 9608 printDate, dRow, tbody, daySettings, otherMonth, unselectable, 9609 tempDate = new Date(), 9610 today = this._daylightSavingAdjust( 9611 new Date(tempDate.getFullYear(), tempDate.getMonth(), tempDate.getDate())), // clear time 9612 isRTL = this._get(inst, "isRTL
"), 9613 showButtonPanel = this._get(inst, "showButtonPanel
"), 9614 hideIfNoPrevNext = this._get(inst, "hideIfNoPrevNext
"), 9615 navigationAsDateFormat = this._get(inst, "navigationAsDateFormat
"), 9616 numMonths = this._getNumberOfMonths(inst), 9617 showCurrentAtPos = this._get(inst, "showCurrentAtPos
"), 9618 stepMonths = this._get(inst, "stepMonths
"), 9619 isMultiMonth = (numMonths[0] !== 1 || numMonths[1] !== 1), 9620 currentDate = this._daylightSavingAdjust((!inst.currentDay ? new Date(9999, 9, 9) : 9621 new Date(inst.currentYear, inst.currentMonth, inst.currentDay))), 9622 minDate = this._getMinMaxDate(inst, "min
"), 9623 maxDate = this._getMinMaxDate(inst, "max
"), 9624 drawMonth = inst.drawMonth - showCurrentAtPos, 9625 drawYear = inst.drawYear; 9627 if (drawMonth < 0) { 9632 maxDraw = this._daylightSavingAdjust(new Date(maxDate.getFullYear(), 9633 maxDate.getMonth() - (numMonths[0] * numMonths[1]) + 1, maxDate.getDate())); 9634 maxDraw = (minDate && maxDraw < minDate ? minDate : maxDraw); 9635 while (this._daylightSavingAdjust(new Date(drawYear, drawMonth, 1)) > maxDraw) { 9637 if (drawMonth < 0) { 9643 inst.drawMonth = drawMonth; 9644 inst.drawYear = drawYear; 9646 prevText = this._get(inst, "prevText
"); 9647 prevText = (!navigationAsDateFormat ? prevText : this.formatDate(prevText, 9648 this._daylightSavingAdjust(new Date(drawYear, drawMonth - stepMonths, 1)), 9649 this._getFormatConfig(inst))); 9651 prev = (this._canAdjustMonth(inst, -1, drawYear, drawMonth) ? 9652 "<a
class=
'ui-datepicker-prev ui-corner-all' data-handler=
'prev' data-
event=
'click'" + 9653 " title=
'" + prevText + "'><span
class=
'ui-icon ui-icon-circle-triangle-" + ( isRTL ? "e" : "w") + "'>
" + prevText + "</span></a>
" : 9654 (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>
")); 9656 nextText = this._get(inst, "nextText
"); 9657 nextText = (!navigationAsDateFormat ? nextText : this.formatDate(nextText, 9658 this._daylightSavingAdjust(new Date(drawYear, drawMonth + stepMonths, 1)), 9659 this._getFormatConfig(inst))); 9661 next = (this._canAdjustMonth(inst, +1, drawYear, drawMonth) ? 9662 "<a
class=
'ui-datepicker-next ui-corner-all' data-handler=
'next' data-
event=
'click'" + 9663 " title=
'" + nextText + "'><span
class=
'ui-icon ui-icon-circle-triangle-" + ( isRTL ? "w" : "e") + "'>
" + nextText + "</span></a>
" : 9664 (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>
")); 9666 currentText = this._get(inst, "currentText
"); 9667 gotoDate = (this._get(inst, "gotoCurrent
") && inst.currentDay ? currentDate : today); 9668 currentText = (!navigationAsDateFormat ? currentText : 9669 this.formatDate(currentText, gotoDate, this._getFormatConfig(inst))); 9671 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'>
" + 9672 this._get(inst, "closeText
") + "</button>
" : ""); 9674 buttonPanel = (showButtonPanel) ? "<div
class=
'ui-datepicker-buttonpane ui-widget-content'>
" + (isRTL ? controls : "") + 9675 (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'" + 9676 ">
" + currentText + "</button>
" : "") + (isRTL ? "" : controls) + "</div>
" : ""; 9678 firstDay = parseInt(this._get(inst, "firstDay
"),10); 9679 firstDay = (isNaN(firstDay) ? 0 : firstDay); 9681 showWeek = this._get(inst, "showWeek
"); 9682 dayNames = this._get(inst, "dayNames
"); 9683 dayNamesMin = this._get(inst, "dayNamesMin
"); 9684 monthNames = this._get(inst, "monthNames
"); 9685 monthNamesShort = this._get(inst, "monthNamesShort
"); 9686 beforeShowDay = this._get(inst, "beforeShowDay
"); 9687 showOtherMonths = this._get(inst, "showOtherMonths
"); 9688 selectOtherMonths = this._get(inst, "selectOtherMonths
"); 9689 defaultDate = this._getDefaultDate(inst); 9692 for (row = 0; row < numMonths[0]; row++) { 9695 for (col = 0; col < numMonths[1]; col++) { 9696 selectedDate = this._daylightSavingAdjust(new Date(drawYear, drawMonth, inst.selectedDay)); 9697 cornerClass = " ui-corner-all
"; 9700 calender += "<div
class=
'ui-datepicker-group"; 9701 if (numMonths[1] > 1) { 9703 case 0: calender += " ui-datepicker-group-first"; 9704 cornerClass = " ui-corner-" + (isRTL ? "right" : "left"); break; 9705 case numMonths[1]-1: calender += " ui-datepicker-group-last"; 9706 cornerClass = " ui-corner-" + (isRTL ? "left" : "right"); break; 9707 default: calender += " ui-datepicker-group-middle"; cornerClass = ""; break; 9712 calender += "<div
class=
'ui-datepicker-header ui-widget-header ui-helper-clearfix" + cornerClass + "'>
" + 9713 (/all|left/.test(cornerClass) && row === 0 ? (isRTL ? next : prev) : "") + 9714 (/all|right/.test(cornerClass) && row === 0 ? (isRTL ? prev : next) : "") + 9715 this._generateMonthYearHeader(inst, drawMonth, drawYear, minDate, maxDate, 9716 row > 0 || col > 0, monthNames, monthNamesShort) + // draw month headers 9717 "</div><table
class=
'ui-datepicker-calendar'><thead>
" + 9719 thead = (showWeek ? "<th
class=
'ui-datepicker-week-col'>
" + this._get(inst, "weekHeader
") + "</th>
" : ""); 9720 for (dow = 0; dow < 7; dow++) { // days of the week 9721 day = (dow + firstDay) % 7; 9722 thead += "<th scope=
'col'" + ((dow + firstDay + 6) % 7 >= 5 ? " class=
'ui-datepicker-week-end'" : "") + ">
" + 9723 "<span title=
'" + dayNames[day] + "'>
" + dayNamesMin[day] + "</span></th>
"; 9725 calender += thead + "</tr></thead><tbody>
"; 9726 daysInMonth = this._getDaysInMonth(drawYear, drawMonth); 9727 if (drawYear === inst.selectedYear && drawMonth === inst.selectedMonth) { 9728 inst.selectedDay = Math.min(inst.selectedDay, daysInMonth); 9730 leadDays = (this._getFirstDayOfMonth(drawYear, drawMonth) - firstDay + 7) % 7; 9731 curRows = Math.ceil((leadDays + daysInMonth) / 7); // calculate the number of rows to generate 9732 numRows = (isMultiMonth ? this.maxRows > curRows ? this.maxRows : curRows : curRows); //If multiple months, use the higher number of rows (see #7043) 9733 this.maxRows = numRows; 9734 printDate = this._daylightSavingAdjust(new Date(drawYear, drawMonth, 1 - leadDays)); 9735 for (dRow = 0; dRow < numRows; dRow++) { // create date picker rows 9737 tbody = (!showWeek ? "" : "<td
class=
'ui-datepicker-week-col'>
" + 9738 this._get(inst, "calculateWeek
")(printDate) + "</td>
"); 9739 for (dow = 0; dow < 7; dow++) { // create date picker days 9740 daySettings = (beforeShowDay ? 9741 beforeShowDay.apply((inst.input ? inst.input[0] : null), [printDate]) : [true, ""]); 9742 otherMonth = (printDate.getMonth() !== drawMonth); 9743 unselectable = (otherMonth && !selectOtherMonths) || !daySettings[0] || 9744 (minDate && printDate < minDate) || (maxDate && printDate > maxDate); 9745 tbody += "<td
class=
'" + 9746 ((dow + firstDay + 6) % 7 >= 5 ? " ui-datepicker-week-end" : "") + // highlight weekends 9747 (otherMonth ? " ui-datepicker-other-month" : "") + // highlight days from other months 9748 ((printDate.getTime() === selectedDate.getTime() && drawMonth === inst.selectedMonth && inst._keyEvent) || // user pressed key 9749 (defaultDate.getTime() === printDate.getTime() && defaultDate.getTime() === selectedDate.getTime()) ? 9750 // or defaultDate is current printedDate and defaultDate is selectedDate 9751 " " + this._dayOverClass : "") + // highlight selected day 9752 (unselectable ? " " + this._unselectableClass + " ui-state-disabled": "") + // highlight unselectable days 9753 (otherMonth && !showOtherMonths ? "" : " " + daySettings[1] + // highlight custom dates 9754 (printDate.getTime() === currentDate.getTime() ? " " + this._currentClass : "") + // highlight selected day 9755 (printDate.getTime() === today.getTime() ? " ui-datepicker-today" : "")) + "'" + // highlight today (if different) 9756 ((!otherMonth || showOtherMonths) && daySettings[2] ? " title=
'" + daySettings[2].replace(/'/
g,
"'") +
"'" :
"") +
9757 (unselectable ?
"" :
" data-handler='selectDay' data-event='click' data-month='" + printDate.getMonth() +
"' data-year='" + printDate.getFullYear() +
"'") +
">" +
9758 (otherMonth && !showOtherMonths ?
" " :
9759 (unselectable ?
"<span class='ui-state-default'>" + printDate.getDate() +
"</span>" :
"<a class='ui-state-default" +
9760 (printDate.getTime() === today.getTime() ?
" ui-state-highlight" :
"") +
9761 (printDate.getTime() === currentDate.getTime() ?
" ui-state-active" :
"") +
9762 (otherMonth ?
" ui-priority-secondary" :
"") +
9763 "' href='#'>" + printDate.getDate() +
"</a>")) +
"</td>";
9764 printDate.setDate(printDate.getDate() + 1);
9765 printDate = this._daylightSavingAdjust(printDate);
9767 calender += tbody +
"</tr>";
9770 if (drawMonth > 11) {
9774 calender +=
"</tbody></table>" + (isMultiMonth ?
"</div>" +
9775 ((numMonths[0] > 0 && col === numMonths[1]-1) ?
"<div class='ui-datepicker-row-break'></div>" :
"") :
"");
9780 html += buttonPanel;
9781 inst._keyEvent =
false;
9786 _generateMonthYearHeader:
function(inst, drawMonth, drawYear, minDate, maxDate,
9787 secondary, monthNames, monthNamesShort) {
9789 var inMinYear, inMaxYear, month, years, thisYear, determineYear, year, endYear,
9790 changeMonth = this._get(inst,
"changeMonth"),
9791 changeYear = this._get(inst,
"changeYear"),
9792 showMonthAfterYear = this._get(inst,
"showMonthAfterYear"),
9793 html =
"<div class='ui-datepicker-title'>",
9797 if (secondary || !changeMonth) {
9798 monthHtml +=
"<span class='ui-datepicker-month'>" + monthNames[drawMonth] +
"</span>";
9800 inMinYear = (minDate && minDate.getFullYear() === drawYear);
9801 inMaxYear = (maxDate && maxDate.getFullYear() === drawYear);
9802 monthHtml +=
"<select class='ui-datepicker-month' data-handler='selectMonth' data-event='change'>";
9803 for ( month = 0; month < 12; month++) {
9804 if ((!inMinYear || month >= minDate.getMonth()) && (!inMaxYear || month <= maxDate.getMonth())) {
9805 monthHtml +=
"<option value='" + month +
"'" +
9806 (month === drawMonth ?
" selected='selected'" :
"") +
9807 ">" + monthNamesShort[month] +
"</option>";
9810 monthHtml +=
"</select>";
9813 if (!showMonthAfterYear) {
9814 html += monthHtml + (secondary || !(changeMonth && changeYear) ?
" " :
"");
9818 if ( !inst.yearshtml ) {
9819 inst.yearshtml =
"";
9820 if (secondary || !changeYear) {
9821 html +=
"<span class='ui-datepicker-year'>" + drawYear +
"</span>";
9824 years = this._get(inst,
"yearRange").split(
":");
9825 thisYear =
new Date().getFullYear();
9826 determineYear =
function(value) {
9827 var year = (value.match(/c[+\-].*/) ? drawYear + parseInt(value.substring(1), 10) :
9828 (value.match(/[+\-].*/) ? thisYear + parseInt(value, 10) :
9829 parseInt(value, 10)));
9830 return (isNaN(year) ? thisYear : year);
9832 year = determineYear(years[0]);
9833 endYear = Math.max(year, determineYear(years[1] ||
""));
9834 year = (minDate ? Math.max(year, minDate.getFullYear()) : year);
9835 endYear = (maxDate ? Math.min(endYear, maxDate.getFullYear()) : endYear);
9836 inst.yearshtml +=
"<select class='ui-datepicker-year' data-handler='selectYear' data-event='change'>";
9837 for (; year <= endYear; year++) {
9838 inst.yearshtml +=
"<option value='" + year +
"'" +
9839 (year === drawYear ?
" selected='selected'" :
"") +
9840 ">" + year +
"</option>";
9842 inst.yearshtml +=
"</select>";
9844 html += inst.yearshtml;
9845 inst.yearshtml = null;
9849 html += this._get(inst,
"yearSuffix");
9850 if (showMonthAfterYear) {
9851 html += (secondary || !(changeMonth && changeYear) ?
" " :
"") + monthHtml;
9858 _adjustInstDate:
function(inst,
offset, period) {
9859 var year = inst.drawYear + (period ===
"Y" ? offset : 0),
9860 month = inst.drawMonth + (period ===
"M" ? offset : 0),
9861 day = Math.min(inst.selectedDay,
this._getDaysInMonth(year, month)) + (period ===
"D" ? offset : 0),
9862 date = this._restrictMinMax(inst, this._daylightSavingAdjust(
new Date(year, month, day)));
9864 inst.selectedDay = date.getDate();
9865 inst.drawMonth = inst.selectedMonth = date.getMonth();
9866 inst.drawYear = inst.selectedYear = date.getFullYear();
9867 if (period ===
"M" || period ===
"Y") {
9868 this._notifyChange(inst);
9873 _restrictMinMax:
function(inst, date) {
9874 var minDate = this._getMinMaxDate(inst,
"min"),
9875 maxDate = this._getMinMaxDate(inst,
"max"),
9876 newDate = (minDate && date < minDate ? minDate : date);
9877 return (maxDate && newDate > maxDate ? maxDate : newDate);
9881 _notifyChange:
function(inst) {
9882 var onChange = this._get(inst,
"onChangeMonthYear");
9884 onChange.apply((inst.input ? inst.input[0] : null),
9885 [inst.selectedYear, inst.selectedMonth + 1, inst]);
9890 _getNumberOfMonths:
function(inst) {
9891 var numMonths = this._get(inst,
"numberOfMonths");
9892 return (numMonths == null ? [1, 1] : (typeof numMonths ===
"number" ? [1, numMonths] : numMonths));
9896 _getMinMaxDate:
function(inst, minMax) {
9897 return this._determineDate(inst, this._get(inst, minMax +
"Date"), null);
9901 _getDaysInMonth:
function(year, month) {
9902 return 32 - this._daylightSavingAdjust(
new Date(year, month, 32)).getDate();
9906 _getFirstDayOfMonth:
function(year, month) {
9907 return new Date(year, month, 1).getDay();
9911 _canAdjustMonth:
function(inst,
offset, curYear, curMonth) {
9912 var numMonths = this._getNumberOfMonths(inst),
9913 date = this._daylightSavingAdjust(
new Date(curYear,
9914 curMonth + (offset < 0 ? offset : numMonths[0] * numMonths[1]), 1));
9917 date.setDate(this._getDaysInMonth(date.getFullYear(), date.getMonth()));
9919 return this._isInRange(inst, date);
9923 _isInRange:
function(inst, date) {
9924 var yearSplit, currentYear,
9925 minDate = this._getMinMaxDate(inst,
"min"),
9926 maxDate = this._getMinMaxDate(inst,
"max"),
9929 years = this._get(inst,
"yearRange");
9931 yearSplit = years.split(
":");
9932 currentYear =
new Date().getFullYear();
9933 minYear = parseInt(yearSplit[0], 10);
9934 maxYear = parseInt(yearSplit[1], 10);
9935 if ( yearSplit[0].match(/[+\-].*/) ) {
9936 minYear += currentYear;
9938 if ( yearSplit[1].match(/[+\-].*/) ) {
9939 maxYear += currentYear;
9943 return ((!minDate || date.getTime() >= minDate.getTime()) &&
9944 (!maxDate || date.getTime() <= maxDate.getTime()) &&
9945 (!minYear || date.getFullYear() >= minYear) &&
9946 (!maxYear || date.getFullYear() <= maxYear));
9950 _getFormatConfig:
function(inst) {
9951 var shortYearCutoff = this._get(inst,
"shortYearCutoff");
9952 shortYearCutoff = (typeof shortYearCutoff !==
"string" ? shortYearCutoff :
9953 new Date().getFullYear() % 100 + parseInt(shortYearCutoff, 10));
9954 return {shortYearCutoff: shortYearCutoff,
9955 dayNamesShort: this._get(inst,
"dayNamesShort"), dayNames: this._get(inst,
"dayNames"),
9956 monthNamesShort: this._get(inst,
"monthNamesShort"), monthNames: this._get(inst,
"monthNames")};
9960 _formatDate:
function(inst, day, month, year) {
9962 inst.currentDay = inst.selectedDay;
9963 inst.currentMonth = inst.selectedMonth;
9964 inst.currentYear = inst.selectedYear;
9966 var date = (day ? (typeof day ===
"object" ? day :
9967 this._daylightSavingAdjust(
new Date(year, month, day))) :
9968 this._daylightSavingAdjust(
new Date(inst.currentYear, inst.currentMonth, inst.currentDay)));
9969 return this.formatDate(this._get(inst,
"dateFormat"), date, this._getFormatConfig(inst));
9978 function datepicker_bindHover(dpDiv) {
9979 var selector =
"button, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-calendar td a";
9980 return dpDiv.delegate(selector,
"mouseout",
function() {
9981 $(
this).removeClass(
"ui-state-hover");
9982 if (this.className.indexOf(
"ui-datepicker-prev") !== -1) {
9983 $(
this).removeClass(
"ui-datepicker-prev-hover");
9985 if (this.className.indexOf(
"ui-datepicker-next") !== -1) {
9986 $(
this).removeClass(
"ui-datepicker-next-hover");
9989 .delegate( selector,
"mouseover", datepicker_handleMouseover );
9992 function datepicker_handleMouseover() {
9993 if (!$.datepicker._isDisabledDatepicker( datepicker_instActive.inline? datepicker_instActive.dpDiv.parent()[0] : datepicker_instActive.input[0])) {
9994 $(
this).parents(
".ui-datepicker-calendar").find(
"a").removeClass(
"ui-state-hover");
9995 $(
this).
addClass(
"ui-state-hover");
9996 if (this.className.indexOf(
"ui-datepicker-prev") !== -1) {
9997 $(
this).
addClass(
"ui-datepicker-prev-hover");
9999 if (this.className.indexOf(
"ui-datepicker-next") !== -1) {
10000 $(
this).
addClass(
"ui-datepicker-next-hover");
10006 function datepicker_extendRemove(target, props) {
10007 $.extend(target, props);
10008 for (var name in props) {
10009 if (props[name] == null) {
10020 $.fn.datepicker =
function(options){
10023 if ( !this.length ) {
10028 if (!$.datepicker.initialized) {
10029 $(document).mousedown($.datepicker._checkExternalClick);
10030 $.datepicker.initialized =
true;
10034 if ($(
"#"+$.datepicker._mainDivId).length === 0) {
10035 $(
"body").append($.datepicker.dpDiv);
10038 var otherArgs = Array.prototype.slice.call(arguments, 1);
10039 if (typeof options ===
"string" && (options ===
"isDisabled" || options ===
"getDate" || options ===
"widget")) {
10040 return $.datepicker[
"_" + options +
"Datepicker"].
10041 apply($.datepicker, [
this[0]].concat(otherArgs));
10043 if (options ===
"option" && arguments.length === 2 && typeof arguments[1] ===
"string") {
10044 return $.datepicker[
"_" + options +
"Datepicker"].
10045 apply($.datepicker, [
this[0]].concat(otherArgs));
10047 return this.
each(
function() {
10048 typeof options ===
"string" ?
10049 $.datepicker[
"_" + options +
"Datepicker"].
10050 apply($.datepicker, [
this].concat(otherArgs)) :
10051 $.datepicker._attachDatepicker(this, options);
10055 $.datepicker =
new Datepicker();
10056 $.datepicker.initialized =
false;
10057 $.datepicker.uuid =
new Date().getTime();
10058 $.datepicker.version =
"1.11.2";
10060 var datepicker = $.datepicker;
10075 var dialog = $.widget(
"ui.dialog", {
10081 closeOnEscape:
true,
10082 closeText:
"Close",
10098 using:
function( pos ) {
10099 var topOffset = $( this ).css( pos ).offset().top;
10100 if ( topOffset < 0 ) {
10101 $( this ).css(
"top", pos.top - topOffset );
10123 sizeRelatedOptions: {
10133 resizableRelatedOptions: {
10140 _create:
function() {
10141 this.originalCss = {
10142 display: this.element[ 0 ].style.display,
10143 width: this.element[ 0 ].style.width,
10144 minHeight: this.element[ 0 ].style.minHeight,
10145 maxHeight: this.element[ 0 ].style.maxHeight,
10146 height: this.element[ 0 ].style.height
10148 this.originalPosition = {
10149 parent: this.element.parent(),
10150 index: this.element.parent().children().index( this.element )
10152 this.originalTitle = this.element.attr(
"title" );
10153 this.options.title = this.options.title || this.originalTitle;
10155 this._createWrapper();
10159 .removeAttr(
"title" )
10160 .addClass(
"ui-dialog-content ui-widget-content" )
10161 .appendTo( this.uiDialog );
10163 this._createTitlebar();
10164 this._createButtonPane();
10166 if ( this.options.draggable && $.fn.draggable ) {
10167 this._makeDraggable();
10169 if ( this.options.resizable && $.fn.resizable ) {
10170 this._makeResizable();
10173 this._isOpen =
false;
10175 this._trackFocus();
10178 _init:
function() {
10179 if ( this.options.autoOpen ) {
10184 _appendTo:
function() {
10185 var element = this.options.appendTo;
10186 if ( element && (element.jquery || element.nodeType) ) {
10187 return $( element );
10189 return this.document.find( element ||
"body" ).eq( 0 );
10192 _destroy:
function() {
10194 originalPosition = this.originalPosition;
10196 this._destroyOverlay();
10200 .removeClass(
"ui-dialog-content ui-widget-content" )
10201 .css( this.originalCss )
10205 this.uiDialog.stop(
true,
true ).remove();
10207 if ( this.originalTitle ) {
10208 this.element.attr(
"title", this.originalTitle );
10211 next = originalPosition.parent.children().eq( originalPosition.index );
10213 if ( next.length && next[ 0 ] !==
this.element[ 0 ] ) {
10214 next.before( this.element );
10216 originalPosition.parent.append( this.element );
10220 widget:
function() {
10221 return this.uiDialog;
10227 close:
function( event ) {
10231 if ( !this._isOpen || this._trigger(
"beforeClose", event ) === false ) {
10235 this._isOpen =
false;
10236 this._focusedElement = null;
10237 this._destroyOverlay();
10238 this._untrackInstance();
10240 if ( !this.opener.filter(
":focusable" ).focus().length ) {
10245 activeElement = this.document[ 0 ].activeElement;
10249 if ( activeElement && activeElement.nodeName.toLowerCase() !==
"body" ) {
10254 $( activeElement ).blur();
10256 }
catch ( error ) {}
10259 this._hide( this.uiDialog, this.options.hide,
function() {
10260 that._trigger(
"close", event );
10264 isOpen:
function() {
10265 return this._isOpen;
10268 moveToTop:
function() {
10272 _moveToTop:
function( event, silent ) {
10274 zIndicies = this.uiDialog.siblings(
".ui-front:visible" ).map(
function() {
10275 return +$( this ).css(
"z-index" );
10277 zIndexMax = Math.max.apply( null, zIndicies );
10279 if ( zIndexMax >= +this.uiDialog.css(
"z-index" ) ) {
10280 this.uiDialog.css(
"z-index", zIndexMax + 1 );
10284 if ( moved && !silent ) {
10285 this._trigger(
"focus", event );
10292 if ( this._isOpen ) {
10293 if ( this._moveToTop() ) {
10294 this._focusTabbable();
10299 this._isOpen =
true;
10300 this.opener = $( this.document[ 0 ].activeElement );
10304 this._createOverlay();
10305 this._moveToTop( null,
true );
10310 if ( this.overlay ) {
10311 this.overlay.css(
"z-index", this.uiDialog.css(
"z-index" ) - 1 );
10314 this._show( this.uiDialog, this.options.show,
function() {
10315 that._focusTabbable();
10316 that._trigger(
"focus" );
10322 this._makeFocusTarget();
10324 this._trigger(
"open" );
10327 _focusTabbable:
function() {
10335 var hasFocus = this._focusedElement;
10337 hasFocus = this.element.find(
"[autofocus]" );
10339 if ( !hasFocus.length ) {
10340 hasFocus = this.element.find(
":tabbable" );
10342 if ( !hasFocus.length ) {
10343 hasFocus = this.uiDialogButtonPane.find(
":tabbable" );
10345 if ( !hasFocus.length ) {
10346 hasFocus = this.uiDialogTitlebarClose.filter(
":tabbable" );
10348 if ( !hasFocus.length ) {
10349 hasFocus = this.uiDialog;
10351 hasFocus.eq( 0 ).focus();
10354 _keepFocus:
function( event ) {
10355 function checkFocus() {
10356 var activeElement = this.document[0].activeElement,
10357 isActive = this.uiDialog[0] === activeElement ||
10358 $.contains( this.uiDialog[0], activeElement );
10360 this._focusTabbable();
10363 event.preventDefault();
10364 checkFocus.call(
this );
10368 this._delay( checkFocus );
10371 _createWrapper:
function() {
10372 this.uiDialog = $(
"<div>")
10373 .
addClass(
"ui-dialog ui-widget ui-widget-content ui-corner-all ui-front " +
10374 this.options.dialogClass )
10381 .appendTo( this._appendTo() );
10383 this._on( this.uiDialog, {
10384 keydown:
function( event ) {
10385 if ( this.options.closeOnEscape && !event.isDefaultPrevented() &&
event.keyCode &&
10386 event.keyCode === $.ui.keyCode.ESCAPE ) {
10387 event.preventDefault();
10388 this.close( event );
10393 if ( event.keyCode !== $.ui.keyCode.TAB || event.isDefaultPrevented() ) {
10396 var tabbables = this.uiDialog.find(
":tabbable" ),
10397 first = tabbables.filter(
":first" ),
10398 last = tabbables.filter(
":last" );
10400 if ( ( event.target === last[0] || event.target ===
this.uiDialog[0] ) && !event.shiftKey ) {
10401 this._delay(
function() {
10404 event.preventDefault();
10405 }
else if ( ( event.target === first[0] || event.target ===
this.uiDialog[0] ) && event.shiftKey ) {
10406 this._delay(
function() {
10409 event.preventDefault();
10412 mousedown:
function( event ) {
10413 if ( this._moveToTop( event ) ) {
10414 this._focusTabbable();
10422 if ( !this.element.find(
"[aria-describedby]" ).length ) {
10423 this.uiDialog.attr({
10424 "aria-describedby": this.element.uniqueId().attr(
"id" )
10429 _createTitlebar:
function() {
10432 this.uiDialogTitlebar = $(
"<div>" )
10433 .
addClass(
"ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix" )
10434 .prependTo( this.uiDialog );
10435 this._on( this.uiDialogTitlebar, {
10436 mousedown:
function( event ) {
10440 if ( !$( event.target ).closest(
".ui-dialog-titlebar-close" ) ) {
10442 this.uiDialog.focus();
10450 this.uiDialogTitlebarClose = $(
"<button type='button'></button>" )
10452 label: this.options.closeText,
10454 primary:
"ui-icon-closethick" 10458 .
addClass(
"ui-dialog-titlebar-close" )
10459 .appendTo( this.uiDialogTitlebar );
10460 this._on( this.uiDialogTitlebarClose, {
10461 click:
function( event ) {
10462 event.preventDefault();
10463 this.close( event );
10467 uiDialogTitle = $(
"<span>" )
10469 .addClass(
"ui-dialog-title" )
10470 .prependTo( this.uiDialogTitlebar );
10471 this._title( uiDialogTitle );
10473 this.uiDialog.attr({
10474 "aria-labelledby": uiDialogTitle.attr(
"id" )
10478 _title:
function( title ) {
10479 if ( !this.options.title ) {
10480 title.html(
" " );
10482 title.text( this.options.title );
10485 _createButtonPane:
function() {
10486 this.uiDialogButtonPane = $(
"<div>" )
10487 .
addClass(
"ui-dialog-buttonpane ui-widget-content ui-helper-clearfix" );
10489 this.uiButtonSet = $(
"<div>" )
10490 .
addClass(
"ui-dialog-buttonset" )
10491 .appendTo( this.uiDialogButtonPane );
10493 this._createButtons();
10496 _createButtons:
function() {
10498 buttons = this.options.buttons;
10501 this.uiDialogButtonPane.remove();
10502 this.uiButtonSet.empty();
10504 if ( $.isEmptyObject( buttons ) || ($.isArray( buttons ) && !buttons.length) ) {
10505 this.uiDialog.removeClass(
"ui-dialog-buttons" );
10509 $.each( buttons,
function( name, props ) {
10510 var click, buttonOptions;
10511 props = $.isFunction( props ) ?
10512 { click:
props, text: name } :
10515 props = $.extend( { type:
"button" },
props );
10517 click = props.click;
10518 props.click =
function() {
10519 click.apply( that.element[ 0 ], arguments );
10522 icons: props.icons,
10523 text: props.showText
10525 delete props.icons;
10526 delete props.showText;
10527 $(
"<button></button>",
props )
10528 .button( buttonOptions )
10529 .appendTo( that.uiButtonSet );
10531 this.uiDialog.addClass(
"ui-dialog-buttons" );
10532 this.uiDialogButtonPane.appendTo( this.uiDialog );
10535 _makeDraggable:
function() {
10537 options = this.options;
10539 function filteredUi( ui ) {
10541 position: ui.position,
10546 this.uiDialog.draggable({
10547 cancel:
".ui-dialog-content, .ui-dialog-titlebar-close",
10548 handle:
".ui-dialog-titlebar",
10549 containment:
"document",
10550 start:
function( event, ui ) {
10551 $( this ).
addClass(
"ui-dialog-dragging" );
10552 that._blockFrames();
10553 that._trigger(
"dragStart", event, filteredUi( ui ) );
10555 drag:
function( event, ui ) {
10556 that._trigger(
"drag", event, filteredUi( ui ) );
10558 stop:
function( event, ui ) {
10559 var left = ui.offset.left - that.document.scrollLeft(),
10560 top = ui.offset.top - that.document.scrollTop();
10562 options.position = {
10564 at:
"left" + (left >= 0 ?
"+" :
"") + left +
" " +
10565 "top" + (top >= 0 ?
"+" :
"") + top,
10568 $( this ).removeClass(
"ui-dialog-dragging" );
10569 that._unblockFrames();
10570 that._trigger(
"dragStop", event, filteredUi( ui ) );
10575 _makeResizable:
function() {
10577 options = this.options,
10578 handles = options.resizable,
10581 position = this.uiDialog.css(
"position"),
10582 resizeHandles = typeof handles ===
"string" ?
10584 "n,e,s,w,se,sw,ne,nw";
10586 function filteredUi( ui ) {
10588 originalPosition: ui.originalPosition,
10589 originalSize: ui.originalSize,
10590 position: ui.position,
10595 this.uiDialog.resizable({
10596 cancel:
".ui-dialog-content",
10597 containment:
"document",
10598 alsoResize: this.element,
10599 maxWidth: options.maxWidth,
10600 maxHeight: options.maxHeight,
10601 minWidth: options.minWidth,
10602 minHeight: this._minHeight(),
10603 handles: resizeHandles,
10604 start:
function( event, ui ) {
10605 $( this ).
addClass(
"ui-dialog-resizing" );
10606 that._blockFrames();
10607 that._trigger(
"resizeStart", event, filteredUi( ui ) );
10609 resize:
function( event, ui ) {
10610 that._trigger(
"resize", event, filteredUi( ui ) );
10612 stop:
function( event, ui ) {
10613 var offset = that.uiDialog.offset(),
10614 left = offset.left - that.document.scrollLeft(),
10615 top = offset.top - that.document.scrollTop();
10617 options.height = that.uiDialog.height();
10618 options.width = that.uiDialog.width();
10619 options.position = {
10621 at:
"left" + (left >= 0 ?
"+" :
"") + left +
" " +
10622 "top" + (top >= 0 ?
"+" :
"") + top,
10625 $( this ).removeClass(
"ui-dialog-resizing" );
10626 that._unblockFrames();
10627 that._trigger(
"resizeStop", event, filteredUi( ui ) );
10630 .css(
"position", position );
10633 _trackFocus:
function() {
10634 this._on( this.widget(), {
10635 focusin:
function( event ) {
10636 this._makeFocusTarget();
10637 this._focusedElement = $(
event.target );
10642 _makeFocusTarget:
function() {
10643 this._untrackInstance();
10644 this._trackingInstances().unshift(
this );
10647 _untrackInstance:
function() {
10648 var instances = this._trackingInstances(),
10649 exists = $.inArray(
this, instances );
10650 if ( exists !== -1 ) {
10651 instances.splice( exists, 1 );
10655 _trackingInstances:
function() {
10656 var instances = this.document.data(
"ui-dialog-instances" );
10657 if ( !instances ) {
10659 this.document.data(
"ui-dialog-instances", instances );
10664 _minHeight:
function() {
10665 var options = this.options;
10667 return options.height ===
"auto" ?
10668 options.minHeight :
10669 Math.min( options.minHeight, options.height );
10672 _position:
function() {
10674 var isVisible = this.uiDialog.is(
":visible" );
10675 if ( !isVisible ) {
10676 this.uiDialog.show();
10678 this.uiDialog.position( this.options.position );
10679 if ( !isVisible ) {
10680 this.uiDialog.hide();
10684 _setOptions:
function( options ) {
10687 resizableOptions = {};
10689 $.each( options,
function( key, value ) {
10690 that._setOption( key, value );
10692 if ( key in that.sizeRelatedOptions ) {
10695 if ( key in that.resizableRelatedOptions ) {
10696 resizableOptions[ key ] = value;
10704 if ( this.uiDialog.is(
":data(ui-resizable)" ) ) {
10705 this.uiDialog.resizable(
"option", resizableOptions );
10709 _setOption:
function( key, value ) {
10710 var isDraggable, isResizable,
10711 uiDialog = this.uiDialog;
10713 if ( key ===
"dialogClass" ) {
10715 .removeClass( this.options.dialogClass )
10716 .addClass( value );
10719 if ( key ===
"disabled" ) {
10723 this._super( key, value );
10725 if ( key ===
"appendTo" ) {
10726 this.uiDialog.appendTo( this._appendTo() );
10729 if ( key ===
"buttons" ) {
10730 this._createButtons();
10733 if ( key ===
"closeText" ) {
10734 this.uiDialogTitlebarClose.button({
10740 if ( key ===
"draggable" ) {
10741 isDraggable = uiDialog.is(
":data(ui-draggable)" );
10742 if ( isDraggable && !value ) {
10743 uiDialog.draggable(
"destroy" );
10746 if ( !isDraggable && value ) {
10747 this._makeDraggable();
10751 if ( key ===
"position" ) {
10755 if ( key ===
"resizable" ) {
10757 isResizable = uiDialog.is(
":data(ui-resizable)" );
10758 if ( isResizable && !value ) {
10759 uiDialog.resizable(
"destroy" );
10763 if ( isResizable && typeof value ===
"string" ) {
10764 uiDialog.resizable(
"option",
"handles", value );
10768 if ( !isResizable && value !==
false ) {
10769 this._makeResizable();
10773 if ( key ===
"title" ) {
10774 this._title( this.uiDialogTitlebar.find(
".ui-dialog-title" ) );
10778 _size:
function() {
10781 var nonContentHeight, minContentHeight, maxContentHeight,
10782 options = this.options;
10785 this.element.show().css({
10792 if ( options.minWidth > options.width ) {
10793 options.width = options.minWidth;
10798 nonContentHeight = this.uiDialog.css({
10800 width: options.width
10803 minContentHeight = Math.max( 0, options.minHeight - nonContentHeight );
10804 maxContentHeight = typeof options.maxHeight ===
"number" ?
10805 Math.max( 0, options.maxHeight - nonContentHeight ) :
10808 if ( options.height ===
"auto" ) {
10810 minHeight: minContentHeight,
10811 maxHeight: maxContentHeight,
10815 this.element.height( Math.max( 0, options.height - nonContentHeight ) );
10818 if ( this.uiDialog.is(
":data(ui-resizable)" ) ) {
10819 this.uiDialog.resizable(
"option",
"minHeight", this._minHeight() );
10823 _blockFrames:
function() {
10824 this.iframeBlocks = this.document.find(
"iframe" ).map(
function() {
10825 var iframe = $( this );
10827 return $(
"<div>" )
10829 position:
"absolute",
10830 width: iframe.outerWidth(),
10831 height: iframe.outerHeight()
10833 .appendTo( iframe.parent() )
10834 .
offset( iframe.offset() )[0];
10838 _unblockFrames:
function() {
10839 if ( this.iframeBlocks ) {
10840 this.iframeBlocks.remove();
10841 delete this.iframeBlocks;
10845 _allowInteraction:
function( event ) {
10846 if ( $( event.target ).closest(
".ui-dialog" ).length ) {
10852 return !!$(
event.target ).closest(
".ui-datepicker" ).length;
10855 _createOverlay:
function() {
10856 if ( !this.options.modal ) {
10862 var isOpening =
true;
10863 this._delay(
function() {
10867 if ( !this.document.data(
"ui-dialog-overlays" ) ) {
10872 this._on( this.document, {
10873 focusin:
function( event ) {
10878 if ( !this._allowInteraction( event ) ) {
10879 event.preventDefault();
10880 this._trackingInstances()[ 0 ]._focusTabbable();
10886 this.overlay = $(
"<div>" )
10887 .
addClass(
"ui-widget-overlay ui-front" )
10888 .appendTo( this._appendTo() );
10889 this._on( this.overlay, {
10890 mousedown:
"_keepFocus" 10892 this.document.data(
"ui-dialog-overlays",
10893 (this.document.data(
"ui-dialog-overlays" ) || 0) + 1 );
10896 _destroyOverlay:
function() {
10897 if ( !this.options.modal ) {
10901 if ( this.overlay ) {
10902 var overlays = this.document.data(
"ui-dialog-overlays" ) - 1;
10906 .unbind(
"focusin" )
10907 .removeData(
"ui-dialog-overlays" );
10909 this.document.data(
"ui-dialog-overlays", overlays );
10912 this.overlay.remove();
10913 this.overlay = null;
10931 var progressbar = $.widget(
"ui.progressbar", {
10943 _create:
function() {
10945 this.oldValue = this.options.value = this._constrainedValue();
10948 .addClass(
"ui-progressbar ui-widget ui-widget-content ui-corner-all" )
10952 role:
"progressbar",
10953 "aria-valuemin": this.min
10956 this.valueDiv = $(
"<div class='ui-progressbar-value ui-widget-header ui-corner-left'></div>" )
10957 .appendTo( this.element );
10959 this._refreshValue();
10962 _destroy:
function() {
10964 .removeClass(
"ui-progressbar ui-widget ui-widget-content ui-corner-all" )
10965 .removeAttr(
"role" )
10966 .removeAttr(
"aria-valuemin" )
10967 .removeAttr(
"aria-valuemax" )
10968 .removeAttr(
"aria-valuenow" );
10970 this.valueDiv.remove();
10973 value:
function( newValue ) {
10975 return this.options.value;
10978 this.options.value = this._constrainedValue( newValue );
10979 this._refreshValue();
10982 _constrainedValue:
function( newValue ) {
10984 newValue = this.options.value;
10987 this.indeterminate = newValue ===
false;
10990 if ( typeof newValue !==
"number" ) {
10994 return this.indeterminate ?
false :
10995 Math.min( this.options.max, Math.max(
this.min, newValue ) );
10998 _setOptions:
function( options ) {
11000 var value = options.value;
11001 delete options.value;
11003 this._super( options );
11005 this.options.value = this._constrainedValue( value );
11006 this._refreshValue();
11009 _setOption:
function( key, value ) {
11010 if ( key ===
"max" ) {
11012 value = Math.max( this.min, value );
11014 if ( key ===
"disabled" ) {
11016 .toggleClass(
"ui-state-disabled", !!value )
11017 .attr(
"aria-disabled", value );
11019 this._super( key, value );
11022 _percentage:
function() {
11023 return this.indeterminate ? 100 : 100 * ( this.options.value - this.min ) / ( this.options.max -
this.min );
11026 _refreshValue:
function() {
11027 var value = this.options.value,
11028 percentage = this._percentage();
11031 .toggle( this.indeterminate || value > this.min )
11032 .toggleClass(
"ui-corner-right", value === this.options.max )
11033 .width( percentage.toFixed(0) +
"%" );
11035 this.element.toggleClass(
"ui-progressbar-indeterminate", this.indeterminate );
11037 if ( this.indeterminate ) {
11038 this.element.removeAttr(
"aria-valuenow" );
11039 if ( !this.overlayDiv ) {
11040 this.overlayDiv = $(
"<div class='ui-progressbar-overlay'></div>" ).appendTo( this.valueDiv );
11043 this.element.attr({
11044 "aria-valuemax": this.options.max,
11045 "aria-valuenow": value
11047 if ( this.overlayDiv ) {
11048 this.overlayDiv.remove();
11049 this.overlayDiv = null;
11053 if ( this.oldValue !== value ) {
11054 this.oldValue = value;
11055 this._trigger(
"change" );
11057 if ( value === this.options.max ) {
11058 this._trigger(
"complete" );
11076 var selectmenu = $.widget(
"ui.selectmenu", {
11078 defaultElement:
"<select>",
11083 button:
"ui-icon-triangle-1-s" 11100 _create:
function() {
11101 var selectmenuId = this.element.uniqueId().attr(
"id" );
11103 element: selectmenuId,
11104 button: selectmenuId +
"-button",
11105 menu: selectmenuId +
"-menu" 11108 this._drawButton();
11111 if ( this.options.disabled ) {
11116 _drawButton:
function() {
11118 tabindex = this.element.attr(
"tabindex" );
11121 this.label = $(
"label[for='" + this.ids.element +
"']" ).attr(
"for", this.ids.button );
11122 this._on( this.label, {
11123 click:
function( event ) {
11124 this.button.focus();
11125 event.preventDefault();
11130 this.element.hide();
11133 this.button = $(
"<span>", {
11134 "class":
"ui-selectmenu-button ui-widget ui-state-default ui-corner-all",
11135 tabindex: tabindex || this.options.disabled ? -1 : 0,
11136 id: this.ids.button,
11138 "aria-expanded":
"false",
11139 "aria-autocomplete":
"list",
11140 "aria-owns": this.ids.menu,
11141 "aria-haspopup":
"true" 11143 .insertAfter( this.element );
11146 "class":
"ui-icon " + this.options.icons.button
11148 .prependTo( this.button );
11150 this.buttonText = $(
"<span>", {
11151 "class":
"ui-selectmenu-text" 11153 .appendTo( this.button );
11155 this._setText( this.buttonText, this.element.find(
"option:selected" ).text() );
11156 this._resizeButton();
11158 this._on( this.button, this._buttonEvents );
11159 this.button.one(
"focusin",
function() {
11163 if ( !that.menuItems ) {
11164 that._refreshMenu();
11167 this._hoverable( this.button );
11168 this._focusable( this.button );
11171 _drawMenu:
function() {
11175 this.menu = $(
"<ul>", {
11176 "aria-hidden":
"true",
11177 "aria-labelledby": this.ids.button,
11182 this.menuWrap = $(
"<div>", {
11183 "class":
"ui-selectmenu-menu ui-front" 11185 .append( this.menu )
11186 .appendTo( this._appendTo() );
11189 this.menuInstance = this.menu
11192 select:
function( event, ui ) {
11193 event.preventDefault();
11198 that._setSelection();
11200 that._select( ui.item.data(
"ui-selectmenu-item" ), event );
11202 focus:
function( event, ui ) {
11203 var item = ui.item.data(
"ui-selectmenu-item" );
11206 if ( that.focusIndex != null && item.index !== that.focusIndex ) {
11207 that._trigger(
"focus", event, { item: item } );
11208 if ( !that.isOpen ) {
11209 that._select( item, event );
11212 that.focusIndex = item.index;
11214 that.button.attr(
"aria-activedescendant",
11215 that.menuItems.eq( item.index ).attr(
"id" ) );
11218 .menu(
"instance" );
11222 .addClass(
"ui-corner-bottom" )
11223 .removeClass(
"ui-corner-all" );
11226 this.menuInstance._off( this.menu,
"mouseleave" );
11229 this.menuInstance._closeOnDocumentClick =
function() {
11234 this.menuInstance._isDivider =
function() {
11239 refresh:
function() {
11240 this._refreshMenu();
11241 this._setText( this.buttonText, this._getSelectedItem().text() );
11242 if ( !this.options.width ) {
11243 this._resizeButton();
11247 _refreshMenu:
function() {
11251 options = this.element.find(
"option" );
11253 if ( !options.length ) {
11257 this._parseOptions( options );
11258 this._renderMenu( this.menu, this.items );
11260 this.menuInstance.refresh();
11261 this.menuItems = this.menu.find(
"li" ).not(
".ui-selectmenu-optgroup" );
11263 item = this._getSelectedItem();
11266 this.menuInstance.focus( null, item );
11267 this._setAria( item.data(
"ui-selectmenu-item" ) );
11270 this._setOption(
"disabled", this.element.prop(
"disabled" ) );
11273 open:
function( event ) {
11274 if ( this.options.disabled ) {
11279 if ( !this.menuItems ) {
11280 this._refreshMenu();
11284 this.menu.find(
".ui-state-focus" ).removeClass(
"ui-state-focus" );
11285 this.menuInstance.focus( null, this._getSelectedItem() );
11288 this.isOpen =
true;
11289 this._toggleAttr();
11290 this._resizeMenu();
11293 this._on( this.document, this._documentClick );
11295 this._trigger(
"open", event );
11298 _position:
function() {
11299 this.menuWrap.position( $.
extend( { of: this.button }, this.options.position ) );
11302 close:
function( event ) {
11303 if ( !this.isOpen ) {
11307 this.isOpen =
false;
11308 this._toggleAttr();
11311 this._off( this.document );
11313 this._trigger(
"close", event );
11316 widget:
function() {
11317 return this.button;
11320 menuWidget:
function() {
11324 _renderMenu:
function( ul, items ) {
11326 currentOptgroup =
"";
11328 $.each( items,
function( index, item ) {
11329 if ( item.optgroup !== currentOptgroup ) {
11331 "class":
"ui-selectmenu-optgroup ui-menu-divider" +
11332 ( item.element.parent(
"optgroup" ).prop(
"disabled" ) ?
11333 " ui-state-disabled" :
11335 text: item.optgroup
11339 currentOptgroup = item.optgroup;
11342 that._renderItemData( ul, item );
11346 _renderItemData:
function( ul, item ) {
11347 return this._renderItem( ul, item ).data(
"ui-selectmenu-item", item );
11350 _renderItem:
function( ul, item ) {
11351 var li = $(
"<li>" );
11353 if ( item.disabled ) {
11354 li.addClass(
"ui-state-disabled" );
11356 this._setText( li, item.label );
11358 return li.appendTo( ul );
11361 _setText:
function( element, value ) {
11363 element.text( value );
11365 element.html(
" " );
11369 _move:
function( direction, event ) {
11371 filter =
".ui-menu-item";
11373 if ( this.isOpen ) {
11374 item = this.menuItems.eq( this.focusIndex );
11376 item = this.menuItems.eq( this.element[ 0 ].selectedIndex );
11377 filter +=
":not(.ui-state-disabled)";
11380 if ( direction ===
"first" || direction ===
"last" ) {
11381 next = item[ direction ===
"first" ?
"prevAll" :
"nextAll" ]( filter ).eq( -1 );
11383 next = item[ direction +
"All" ]( filter ).eq( 0 );
11386 if ( next.length ) {
11387 this.menuInstance.focus( event, next );
11391 _getSelectedItem:
function() {
11392 return this.menuItems.eq( this.element[ 0 ].selectedIndex );
11395 _toggle:
function( event ) {
11396 this[ this.isOpen ?
"close" :
"open" ]( event );
11399 _setSelection:
function() {
11402 if ( !this.range ) {
11406 if (
window.getSelection ) {
11407 selection =
window.getSelection();
11408 selection.removeAllRanges();
11409 selection.addRange( this.range );
11413 this.range.select();
11419 this.button.focus();
11423 mousedown:
function( event ) {
11424 if ( !this.isOpen ) {
11428 if ( !$( event.target ).closest(
".ui-selectmenu-menu, #" + this.ids.button ).length ) {
11429 this.close( event );
11437 mousedown:
function() {
11440 if (
window.getSelection ) {
11441 selection =
window.getSelection();
11442 if ( selection.rangeCount ) {
11443 this.range = selection.getRangeAt( 0 );
11448 this.range = document.selection.createRange();
11452 click:
function( event ) {
11453 this._setSelection();
11454 this._toggle( event );
11457 keydown:
function( event ) {
11458 var preventDefault =
true;
11459 switch ( event.keyCode ) {
11460 case $.ui.keyCode.TAB:
11461 case $.ui.keyCode.ESCAPE:
11462 this.close( event );
11463 preventDefault =
false;
11465 case $.ui.keyCode.ENTER:
11466 if ( this.isOpen ) {
11467 this._selectFocusedItem( event );
11470 case $.ui.keyCode.UP:
11471 if ( event.altKey ) {
11472 this._toggle( event );
11474 this._move(
"prev", event );
11477 case $.ui.keyCode.DOWN:
11478 if ( event.altKey ) {
11479 this._toggle( event );
11481 this._move(
"next", event );
11484 case $.ui.keyCode.SPACE:
11485 if ( this.isOpen ) {
11486 this._selectFocusedItem( event );
11488 this._toggle( event );
11491 case $.ui.keyCode.LEFT:
11492 this._move(
"prev", event );
11494 case $.ui.keyCode.RIGHT:
11495 this._move(
"next", event );
11497 case $.ui.keyCode.HOME:
11498 case $.ui.keyCode.PAGE_UP:
11499 this._move(
"first", event );
11501 case $.ui.keyCode.END:
11502 case $.ui.keyCode.PAGE_DOWN:
11503 this._move(
"last", event );
11506 this.menu.trigger( event );
11507 preventDefault =
false;
11510 if ( preventDefault ) {
11511 event.preventDefault();
11516 _selectFocusedItem:
function( event ) {
11517 var item = this.menuItems.eq( this.focusIndex );
11518 if ( !item.hasClass(
"ui-state-disabled" ) ) {
11519 this._select( item.data(
"ui-selectmenu-item" ), event );
11523 _select:
function( item, event ) {
11524 var oldIndex = this.element[ 0 ].selectedIndex;
11527 this.element[ 0 ].selectedIndex = item.index;
11528 this._setText( this.buttonText, item.label );
11529 this._setAria( item );
11530 this._trigger(
"select", event, { item: item } );
11532 if ( item.index !== oldIndex ) {
11533 this._trigger(
"change", event, { item: item } );
11536 this.close( event );
11539 _setAria:
function( item ) {
11540 var
id = this.menuItems.eq( item.index ).attr(
"id" );
11543 "aria-labelledby": id,
11544 "aria-activedescendant":
id 11546 this.menu.attr(
"aria-activedescendant",
id );
11549 _setOption:
function( key, value ) {
11550 if ( key ===
"icons" ) {
11551 this.button.find(
"span.ui-icon" )
11552 .removeClass( this.options.icons.button )
11553 .addClass( value.button );
11556 this._super( key, value );
11558 if ( key ===
"appendTo" ) {
11559 this.menuWrap.appendTo( this._appendTo() );
11562 if ( key ===
"disabled" ) {
11563 this.menuInstance.option(
"disabled", value );
11565 .toggleClass(
"ui-state-disabled", value )
11566 .attr(
"aria-disabled", value );
11568 this.element.prop(
"disabled", value );
11570 this.button.attr(
"tabindex", -1 );
11573 this.button.attr(
"tabindex", 0 );
11577 if ( key ===
"width" ) {
11578 this._resizeButton();
11582 _appendTo:
function() {
11583 var element = this.options.appendTo;
11586 element = element.jquery || element.nodeType ?
11588 this.document.find( element ).eq( 0 );
11591 if ( !element || !element[ 0 ] ) {
11592 element = this.element.closest(
".ui-front" );
11595 if ( !element.length ) {
11596 element = this.document[ 0 ].body;
11602 _toggleAttr:
function() {
11604 .toggleClass(
"ui-corner-top", this.isOpen )
11605 .toggleClass(
"ui-corner-all", !this.isOpen )
11606 .attr(
"aria-expanded", this.isOpen );
11607 this.menuWrap.toggleClass(
"ui-selectmenu-open", this.isOpen );
11608 this.menu.attr(
"aria-hidden", !this.isOpen );
11611 _resizeButton:
function() {
11612 var width = this.options.width;
11615 width = this.element.show().outerWidth();
11616 this.element.hide();
11619 this.button.outerWidth( width );
11622 _resizeMenu:
function() {
11623 this.menu.outerWidth( Math.max(
11624 this.button.outerWidth(),
11629 this.menu.width(
"" ).outerWidth() + 1
11633 _getCreateOptions:
function() {
11634 return { disabled: this.element.prop(
"disabled" ) };
11637 _parseOptions:
function( options ) {
11639 options.each(
function( index, item ) {
11640 var option = $( item ),
11641 optgroup = option.parent(
"optgroup" );
11645 value: option.attr(
"value" ),
11646 label: option.text(),
11647 optgroup: optgroup.attr(
"label" ) ||
"",
11648 disabled: optgroup.prop(
"disabled" ) || option.prop(
"disabled" )
11654 _destroy:
function() {
11655 this.menuWrap.remove();
11656 this.button.remove();
11657 this.element.show();
11658 this.element.removeUniqueId();
11659 this.label.attr(
"for", this.ids.element );
11676 var slider = $.widget(
"ui.slider", $.ui.mouse, {
11678 widgetEventPrefix:
"slide",
11685 orientation:
"horizontal",
11702 _create:
function() {
11703 this._keySliding = false;
11704 this._mouseSliding = false;
11705 this._animateOff = true;
11706 this._handleIndex = null;
11707 this._detectOrientation();
11709 this._calculateNewMax();
11712 .addClass(
"ui-slider" +
11713 " ui-slider-" + this.orientation +
11715 " ui-widget-content" +
11719 this._setOption(
"disabled", this.options.disabled );
11721 this._animateOff = false;
11724 _refresh:
function() {
11725 this._createRange();
11726 this._createHandles();
11727 this._setupEvents();
11728 this._refreshValue();
11731 _createHandles:
function() {
11732 var i, handleCount,
11733 options = this.options,
11734 existingHandles = this.element.find(
".ui-slider-handle" ).addClass(
"ui-state-default ui-corner-all" ),
11735 handle =
"<span class='ui-slider-handle ui-state-default ui-corner-all' tabindex='0'></span>",
11738 handleCount = ( options.values && options.values.length ) || 1;
11740 if ( existingHandles.length > handleCount ) {
11741 existingHandles.slice( handleCount ).remove();
11742 existingHandles = existingHandles.slice( 0, handleCount );
11745 for ( i = existingHandles.length; i < handleCount; i++ ) {
11746 handles.push( handle );
11749 this.handles = existingHandles.add( $( handles.join(
"" ) ).appendTo( this.element ) );
11751 this.handle = this.handles.eq( 0 );
11753 this.handles.each(
function( i ) {
11754 $( this ).data(
"ui-slider-handle-index", i );
11758 _createRange:
function() {
11759 var options = this.options,
11762 if ( options.range ) {
11763 if ( options.range ===
true ) {
11764 if ( !options.values ) {
11765 options.values = [ this._valueMin(), this._valueMin() ];
11766 }
else if ( options.values.length && options.values.length !== 2 ) {
11767 options.values = [ options.values[0], options.values[0] ];
11768 }
else if ( $.isArray( options.values ) ) {
11769 options.values = options.values.slice(0);
11773 if ( !this.range || !this.range.length ) {
11774 this.range = $(
"<div></div>" )
11775 .appendTo( this.element );
11777 classes =
"ui-slider-range" +
11780 " ui-widget-header ui-corner-all";
11782 this.range.removeClass(
"ui-slider-range-min ui-slider-range-max" )
11790 this.range.addClass( classes +
11791 ( ( options.range ===
"min" || options.range ===
"max" ) ?
" ui-slider-range-" + options.range :
"" ) );
11793 if ( this.range ) {
11794 this.range.remove();
11800 _setupEvents:
function() {
11801 this._off( this.handles );
11802 this._on( this.handles, this._handleEvents );
11803 this._hoverable( this.handles );
11804 this._focusable( this.handles );
11807 _destroy:
function() {
11808 this.handles.remove();
11809 if ( this.range ) {
11810 this.range.remove();
11814 .removeClass(
"ui-slider" +
11815 " ui-slider-horizontal" +
11816 " ui-slider-vertical" +
11818 " ui-widget-content" +
11819 " ui-corner-all" );
11821 this._mouseDestroy();
11824 _mouseCapture:
function( event ) {
11825 var position, normValue, distance, closestHandle, index, allowed,
offset, mouseOverHandle,
11829 if ( o.disabled ) {
11833 this.elementSize = {
11834 width: this.element.outerWidth(),
11835 height: this.element.outerHeight()
11837 this.elementOffset = this.element.offset();
11839 position = { x:
event.pageX, y:
event.pageY };
11840 normValue = this._normValueFromMouse( position );
11841 distance = this._valueMax() - this._valueMin() + 1;
11842 this.handles.each(
function( i ) {
11843 var thisDistance = Math.abs( normValue - that.values(i) );
11844 if (( distance > thisDistance ) ||
11845 ( distance === thisDistance &&
11846 (i === that._lastChangedValue || that.values(i) === o.min ))) {
11847 distance = thisDistance;
11848 closestHandle = $( this );
11853 allowed = this._start( event, index );
11854 if ( allowed ===
false ) {
11857 this._mouseSliding =
true;
11859 this._handleIndex = index;
11862 .addClass(
"ui-state-active" )
11865 offset = closestHandle.offset();
11866 mouseOverHandle = !$(
event.target ).parents().addBack().is(
".ui-slider-handle" );
11867 this._clickOffset = mouseOverHandle ? { left: 0, top: 0 } : {
11868 left:
event.pageX - offset.left - ( closestHandle.width() / 2 ),
11869 top: event.pageY - offset.top -
11870 ( closestHandle.height() / 2 ) -
11871 ( parseInt( closestHandle.css(
"borderTopWidth"), 10 ) || 0 ) -
11872 ( parseInt( closestHandle.css(
"borderBottomWidth"), 10 ) || 0) +
11873 ( parseInt( closestHandle.css(
"marginTop"), 10 ) || 0)
11876 if ( !this.handles.hasClass(
"ui-state-hover" ) ) {
11877 this._slide( event, index, normValue );
11879 this._animateOff =
true;
11883 _mouseStart:
function() {
11887 _mouseDrag:
function( event ) {
11888 var position = { x:
event.pageX, y:
event.pageY },
11889 normValue = this._normValueFromMouse( position );
11891 this._slide( event, this._handleIndex, normValue );
11896 _mouseStop:
function( event ) {
11897 this.handles.removeClass(
"ui-state-active" );
11898 this._mouseSliding =
false;
11900 this._stop( event, this._handleIndex );
11901 this._change( event, this._handleIndex );
11903 this._handleIndex = null;
11904 this._clickOffset = null;
11905 this._animateOff =
false;
11910 _detectOrientation:
function() {
11911 this.orientation = ( this.options.orientation ===
"vertical" ) ?
"vertical" :
"horizontal";
11914 _normValueFromMouse:
function( position ) {
11921 if ( this.orientation ===
"horizontal" ) {
11922 pixelTotal = this.elementSize.width;
11923 pixelMouse = position.x - this.elementOffset.left - ( this._clickOffset ? this._clickOffset.left : 0 );
11925 pixelTotal = this.elementSize.height;
11926 pixelMouse = position.y - this.elementOffset.top - ( this._clickOffset ? this._clickOffset.top : 0 );
11929 percentMouse = ( pixelMouse / pixelTotal );
11930 if ( percentMouse > 1 ) {
11933 if ( percentMouse < 0 ) {
11936 if ( this.orientation ===
"vertical" ) {
11937 percentMouse = 1 - percentMouse;
11940 valueTotal = this._valueMax() - this._valueMin();
11941 valueMouse = this._valueMin() + percentMouse * valueTotal;
11943 return this._trimAlignValue( valueMouse );
11946 _start:
function( event, index ) {
11948 handle: this.handles[ index ],
11949 value: this.value()
11951 if ( this.options.values &&
this.options.values.length ) {
11952 uiHash.value = this.values( index );
11953 uiHash.values = this.values();
11955 return this._trigger(
"start", event, uiHash );
11958 _slide:
function( event, index, newVal ) {
11963 if ( this.options.values &&
this.options.values.length ) {
11964 otherVal = this.values( index ? 0 : 1 );
11966 if ( ( this.options.values.length === 2 &&
this.options.range ===
true ) &&
11967 ( ( index === 0 && newVal > otherVal) || ( index === 1 && newVal < otherVal ) )
11972 if ( newVal !== this.values( index ) ) {
11973 newValues = this.values();
11974 newValues[ index ] = newVal;
11976 allowed = this._trigger(
"slide", event, {
11977 handle: this.handles[ index ],
11981 otherVal = this.values( index ? 0 : 1 );
11982 if ( allowed !==
false ) {
11983 this.values( index, newVal );
11987 if ( newVal !== this.value() ) {
11989 allowed = this._trigger(
"slide", event, {
11990 handle: this.handles[ index ],
11993 if ( allowed !==
false ) {
11994 this.value( newVal );
12000 _stop:
function( event, index ) {
12002 handle: this.handles[ index ],
12003 value: this.value()
12005 if ( this.options.values &&
this.options.values.length ) {
12006 uiHash.value = this.values( index );
12007 uiHash.values = this.values();
12010 this._trigger(
"stop", event, uiHash );
12013 _change:
function( event, index ) {
12014 if ( !this._keySliding && !this._mouseSliding ) {
12016 handle: this.handles[ index ],
12017 value: this.value()
12019 if ( this.options.values &&
this.options.values.length ) {
12020 uiHash.value = this.values( index );
12021 uiHash.values = this.values();
12025 this._lastChangedValue = index;
12027 this._trigger(
"change", event, uiHash );
12031 value:
function( newValue ) {
12032 if ( arguments.length ) {
12033 this.options.value = this._trimAlignValue( newValue );
12034 this._refreshValue();
12035 this._change( null, 0 );
12039 return this._value();
12042 values:
function( index, newValue ) {
12047 if ( arguments.length > 1 ) {
12048 this.options.values[ index ] = this._trimAlignValue( newValue );
12049 this._refreshValue();
12050 this._change( null, index );
12054 if ( arguments.length ) {
12055 if ( $.isArray( arguments[ 0 ] ) ) {
12056 vals = this.options.values;
12057 newValues = arguments[ 0 ];
12058 for ( i = 0; i < vals.length; i += 1 ) {
12059 vals[ i ] = this._trimAlignValue( newValues[ i ] );
12060 this._change( null, i );
12062 this._refreshValue();
12064 if ( this.options.values &&
this.options.values.length ) {
12065 return this._values( index );
12067 return this.value();
12071 return this._values();
12075 _setOption:
function( key, value ) {
12079 if ( key ===
"range" && this.options.range ===
true ) {
12080 if ( value ===
"min" ) {
12081 this.options.value = this._values( 0 );
12082 this.options.values = null;
12083 }
else if ( value ===
"max" ) {
12084 this.options.value = this._values( this.options.values.length - 1 );
12085 this.options.values = null;
12089 if ( $.isArray( this.options.values ) ) {
12090 valsLength = this.options.values.length;
12093 if ( key ===
"disabled" ) {
12094 this.element.toggleClass(
"ui-state-disabled", !!value );
12097 this._super( key, value );
12100 case "orientation":
12101 this._detectOrientation();
12103 .removeClass(
"ui-slider-horizontal ui-slider-vertical" )
12104 .addClass(
"ui-slider-" + this.orientation );
12105 this._refreshValue();
12108 this.handles.css( value ===
"horizontal" ?
"bottom" :
"left",
"" );
12111 this._animateOff =
true;
12112 this._refreshValue();
12113 this._change( null, 0 );
12114 this._animateOff =
false;
12117 this._animateOff =
true;
12118 this._refreshValue();
12119 for ( i = 0; i < valsLength; i += 1 ) {
12120 this._change( null, i );
12122 this._animateOff =
false;
12127 this._animateOff =
true;
12128 this._calculateNewMax();
12129 this._refreshValue();
12130 this._animateOff =
false;
12133 this._animateOff =
true;
12135 this._animateOff =
false;
12142 _value:
function() {
12143 var val = this.options.value;
12144 val = this._trimAlignValue( val );
12152 _values:
function( index ) {
12157 if ( arguments.length ) {
12158 val = this.options.values[ index ];
12159 val = this._trimAlignValue( val );
12162 }
else if ( this.options.values &&
this.options.values.length ) {
12165 vals = this.options.values.slice();
12166 for ( i = 0; i < vals.length; i += 1) {
12167 vals[ i ] = this._trimAlignValue( vals[ i ] );
12177 _trimAlignValue:
function( val ) {
12178 if ( val <= this._valueMin() ) {
12179 return this._valueMin();
12181 if ( val >= this._valueMax() ) {
12182 return this._valueMax();
12184 var
step = ( this.options.step > 0 ) ? this.options.step : 1,
12185 valModStep = (val -
this._valueMin()) % step,
12186 alignValue = val - valModStep;
12188 if ( Math.abs(valModStep) * 2 >=
step ) {
12189 alignValue += ( valModStep > 0 ) ? step : ( -step );
12194 return parseFloat( alignValue.toFixed(5) );
12197 _calculateNewMax:
function() {
12198 var remainder = ( this.options.max - this._valueMin() ) % this.options.step;
12199 this.max =
this.options.max - remainder;
12202 _valueMin:
function() {
12203 return this.options.min;
12206 _valueMax:
function() {
12210 _refreshValue:
function() {
12211 var lastValPercent, valPercent, value, valueMin, valueMax,
12212 oRange = this.options.range,
12215 animate = ( !this._animateOff ) ? o.animate :
false,
12218 if ( this.options.values &&
this.options.values.length ) {
12219 this.handles.each(
function( i ) {
12220 valPercent = ( that.values(i) - that._valueMin() ) / ( that._valueMax() - that._valueMin() ) * 100;
12221 _set[ that.orientation ===
"horizontal" ?
"left" :
"bottom" ] = valPercent +
"%";
12222 $( this ).
stop( 1, 1 )[ animate ?
"animate" :
"css" ]( _set, o.animate );
12223 if ( that.options.range ===
true ) {
12224 if ( that.orientation ===
"horizontal" ) {
12226 that.range.stop( 1, 1 )[ animate ?
"animate" :
"css" ]( { left: valPercent +
"%" }, o.animate );
12229 that.range[ animate ?
"animate" :
"css" ]( { width: ( valPercent - lastValPercent ) +
"%" }, { queue:
false, duration: o.animate } );
12233 that.range.stop( 1, 1 )[ animate ?
"animate" :
"css" ]( { bottom: ( valPercent ) +
"%" }, o.animate );
12236 that.range[ animate ?
"animate" :
"css" ]( { height: ( valPercent - lastValPercent ) +
"%" }, { queue:
false, duration: o.animate } );
12240 lastValPercent = valPercent;
12243 value = this.value();
12244 valueMin = this._valueMin();
12245 valueMax = this._valueMax();
12246 valPercent = ( valueMax !== valueMin ) ?
12247 ( value - valueMin ) / ( valueMax - valueMin ) * 100 :
12249 _set[ this.orientation ===
"horizontal" ?
"left" :
"bottom" ] = valPercent +
"%";
12250 this.handle.stop( 1, 1 )[ animate ?
"animate" :
"css" ]( _set, o.animate );
12252 if ( oRange ===
"min" && this.orientation ===
"horizontal" ) {
12253 this.range.stop( 1, 1 )[ animate ?
"animate" :
"css" ]( { width: valPercent +
"%" }, o.animate );
12255 if ( oRange ===
"max" && this.orientation ===
"horizontal" ) {
12256 this.range[ animate ?
"animate" :
"css" ]( { width: ( 100 - valPercent ) +
"%" }, { queue:
false, duration: o.animate } );
12258 if ( oRange ===
"min" && this.orientation ===
"vertical" ) {
12259 this.range.stop( 1, 1 )[ animate ?
"animate" :
"css" ]( { height: valPercent +
"%" }, o.animate );
12261 if ( oRange ===
"max" && this.orientation ===
"vertical" ) {
12262 this.range[ animate ?
"animate" :
"css" ]( { height: ( 100 - valPercent ) +
"%" }, { queue:
false, duration: o.animate } );
12268 keydown:
function( event ) {
12269 var allowed, curVal, newVal,
step,
12270 index = $(
event.target ).data(
"ui-slider-handle-index" );
12272 switch ( event.keyCode ) {
12273 case $.ui.keyCode.HOME:
12274 case $.ui.keyCode.END:
12275 case $.ui.keyCode.PAGE_UP:
12276 case $.ui.keyCode.PAGE_DOWN:
12277 case $.ui.keyCode.UP:
12278 case $.ui.keyCode.RIGHT:
12279 case $.ui.keyCode.DOWN:
12280 case $.ui.keyCode.LEFT:
12281 event.preventDefault();
12282 if ( !this._keySliding ) {
12283 this._keySliding =
true;
12284 $(
event.target ).
addClass(
"ui-state-active" );
12285 allowed = this._start( event, index );
12286 if ( allowed ===
false ) {
12293 step = this.options.step;
12294 if ( this.options.values &&
this.options.values.length ) {
12295 curVal = newVal = this.values( index );
12297 curVal = newVal = this.value();
12300 switch ( event.keyCode ) {
12301 case $.ui.keyCode.HOME:
12302 newVal = this._valueMin();
12304 case $.ui.keyCode.END:
12305 newVal = this._valueMax();
12307 case $.ui.keyCode.PAGE_UP:
12308 newVal = this._trimAlignValue(
12309 curVal + ( ( this._valueMax() - this._valueMin() ) / this.numPages )
12312 case $.ui.keyCode.PAGE_DOWN:
12313 newVal = this._trimAlignValue(
12314 curVal - ( (this._valueMax() - this._valueMin()) / this.numPages ) );
12316 case $.ui.keyCode.UP:
12317 case $.ui.keyCode.RIGHT:
12318 if ( curVal === this._valueMax() ) {
12321 newVal = this._trimAlignValue( curVal + step );
12323 case $.ui.keyCode.DOWN:
12324 case $.ui.keyCode.LEFT:
12325 if ( curVal === this._valueMin() ) {
12328 newVal = this._trimAlignValue( curVal - step );
12332 this._slide( event, index, newVal );
12334 keyup:
function( event ) {
12335 var index = $(
event.target ).data(
"ui-slider-handle-index" );
12337 if ( this._keySliding ) {
12338 this._keySliding =
false;
12339 this._stop( event, index );
12340 this._change( event, index );
12341 $(
event.target ).removeClass(
"ui-state-active" );
12360 function spinner_modifier( fn ) {
12361 return function() {
12362 var previous = this.element.val();
12363 fn.apply(
this, arguments );
12365 if ( previous !== this.element.val() ) {
12366 this._trigger(
"change" );
12371 var spinner = $.widget(
"ui.spinner", {
12373 defaultElement:
"<input>",
12374 widgetEventPrefix:
"spin",
12378 down:
"ui-icon-triangle-1-s",
12379 up:
"ui-icon-triangle-1-n" 12384 numberFormat: null,
12394 _create:
function() {
12396 this._setOption(
"max", this.options.max );
12397 this._setOption(
"min", this.options.min );
12398 this._setOption(
"step", this.options.step );
12402 if ( this.value() !==
"" ) {
12404 this._value( this.element.val(), true );
12408 this._on( this._events );
12414 this._on( this.
window, {
12415 beforeunload:
function() {
12416 this.element.removeAttr(
"autocomplete" );
12421 _getCreateOptions:
function() {
12423 element = this.element;
12425 $.each( [
"min",
"max",
"step" ],
function( i, option ) {
12426 var value = element.attr( option );
12427 if ( value !==
undefined && value.length ) {
12428 options[ option ] = value;
12436 keydown:
function( event ) {
12437 if ( this._start( event ) && this._keydown( event ) ) {
12438 event.preventDefault();
12442 focus:
function() {
12443 this.previous = this.element.val();
12445 blur:
function( event ) {
12446 if ( this.cancelBlur ) {
12447 delete this.cancelBlur;
12453 if ( this.previous !== this.element.val() ) {
12454 this._trigger(
"change", event );
12457 mousewheel:
function( event, delta ) {
12461 if ( !this.spinning && !this._start( event ) ) {
12465 this._spin( (delta > 0 ? 1 : -1) * this.options.step, event );
12466 clearTimeout( this.mousewheelTimer );
12467 this.mousewheelTimer = this._delay(
function() {
12468 if ( this.spinning ) {
12469 this._stop( event );
12472 event.preventDefault();
12474 "mousedown .ui-spinner-button":
function( event ) {
12482 previous = this.element[0] === this.document[0].activeElement ?
12483 this.previous : this.element.val();
12484 function checkFocus() {
12485 var isActive = this.element[0] === this.document[0].activeElement;
12487 this.element.focus();
12488 this.previous = previous;
12492 this._delay(
function() {
12493 this.previous = previous;
12499 event.preventDefault();
12500 checkFocus.call(
this );
12506 this.cancelBlur =
true;
12507 this._delay(
function() {
12508 delete this.cancelBlur;
12509 checkFocus.call(
this );
12512 if ( this._start( event ) === false ) {
12516 this._repeat( null, $( event.currentTarget ).hasClass(
"ui-spinner-up" ) ? 1 : -1, event );
12518 "mouseup .ui-spinner-button":
"_stop",
12519 "mouseenter .ui-spinner-button":
function( event ) {
12521 if ( !$( event.currentTarget ).hasClass(
"ui-state-active" ) ) {
12525 if ( this._start( event ) === false ) {
12528 this._repeat( null, $( event.currentTarget ).hasClass(
"ui-spinner-up" ) ? 1 : -1, event );
12533 "mouseleave .ui-spinner-button":
"_stop" 12536 _draw:
function() {
12537 var uiSpinner = this.uiSpinner = this.element
12538 .addClass(
"ui-spinner-input" )
12539 .attr(
"autocomplete",
"off" )
12540 .wrap( this._uiSpinnerHtml() )
12543 .append( this._buttonHtml() );
12545 this.element.attr(
"role",
"spinbutton" );
12548 this.buttons = uiSpinner.find(
".ui-spinner-button" )
12549 .attr(
"tabIndex", -1 )
12551 .removeClass(
"ui-corner-all" );
12555 if ( this.buttons.height() > Math.ceil( uiSpinner.height() * 0.5 ) &&
12556 uiSpinner.height() > 0 ) {
12557 uiSpinner.height( uiSpinner.height() );
12561 if ( this.options.disabled ) {
12566 _keydown:
function( event ) {
12567 var options = this.options,
12568 keyCode = $.ui.keyCode;
12570 switch ( event.keyCode ) {
12572 this._repeat( null, 1, event );
12575 this._repeat( null, -1, event );
12577 case keyCode.PAGE_UP:
12578 this._repeat( null, options.page, event );
12580 case keyCode.PAGE_DOWN:
12581 this._repeat( null, -options.page, event );
12588 _uiSpinnerHtml:
function() {
12589 return "<span class='ui-spinner ui-widget ui-widget-content ui-corner-all'></span>";
12592 _buttonHtml:
function() {
12594 "<a class='ui-spinner-button ui-spinner-up ui-corner-tr'>" +
12595 "<span class='ui-icon " + this.options.icons.up +
"'>▲</span>" +
12597 "<a class='ui-spinner-button ui-spinner-down ui-corner-br'>" +
12598 "<span class='ui-icon " + this.options.icons.down +
"'>▼</span>" +
12602 _start:
function( event ) {
12603 if ( !this.spinning && this._trigger(
"start", event ) === false ) {
12607 if ( !this.counter ) {
12610 this.spinning =
true;
12614 _repeat:
function( i, steps, event ) {
12617 clearTimeout( this.
timer );
12618 this.
timer = this._delay(
function() {
12619 this._repeat( 40, steps, event );
12622 this._spin( steps * this.options.step, event );
12625 _spin:
function(
step, event ) {
12626 var value = this.value() || 0;
12628 if ( !this.counter ) {
12632 value = this._adjustValue( value + step * this._increment( this.counter ) );
12634 if ( !this.spinning || this._trigger(
"spin", event, { value: value } ) !==
false) {
12635 this._value( value );
12640 _increment:
function( i ) {
12641 var incremental = this.options.incremental;
12643 if ( incremental ) {
12644 return $.isFunction( incremental ) ?
12646 Math.floor( i * i * i / 50000 - i * i / 500 + 17 * i / 200 + 1 );
12652 _precision:
function() {
12653 var precision = this._precisionOf( this.options.step );
12654 if ( this.options.min !== null ) {
12655 precision = Math.max( precision, this._precisionOf( this.options.min ) );
12660 _precisionOf:
function( num ) {
12661 var str = num.toString(),
12662 decimal = str.indexOf(
"." );
12663 return decimal === -1 ? 0 : str.length - decimal - 1;
12666 _adjustValue:
function( value ) {
12667 var base, aboveMin,
12668 options = this.options;
12672 base = options.min !== null ? options.min : 0;
12673 aboveMin = value - base;
12675 aboveMin = Math.round(aboveMin / options.step) * options.step;
12677 value = base + aboveMin;
12680 value = parseFloat( value.toFixed(
this._precision() ) );
12683 if ( options.max !== null && value > options.max) {
12684 return options.max;
12686 if ( options.min !== null && value < options.min ) {
12687 return options.min;
12693 _stop:
function( event ) {
12694 if ( !this.spinning ) {
12698 clearTimeout( this.
timer );
12699 clearTimeout( this.mousewheelTimer );
12701 this.spinning =
false;
12702 this._trigger(
"stop", event );
12705 _setOption:
function( key, value ) {
12706 if ( key ===
"culture" || key ===
"numberFormat" ) {
12707 var prevValue = this._parse( this.element.val() );
12708 this.options[ key ] = value;
12709 this.element.val( this._format( prevValue ) );
12713 if ( key ===
"max" || key ===
"min" || key ===
"step" ) {
12714 if ( typeof value ===
"string" ) {
12715 value = this._parse( value );
12718 if ( key ===
"icons" ) {
12719 this.buttons.first().find(
".ui-icon" )
12720 .removeClass( this.options.icons.up )
12721 .addClass( value.up );
12722 this.buttons.last().find(
".ui-icon" )
12723 .removeClass( this.options.icons.down )
12724 .addClass( value.down );
12727 this._super( key, value );
12729 if ( key ===
"disabled" ) {
12730 this.widget().toggleClass(
"ui-state-disabled", !!value );
12731 this.element.prop(
"disabled", !!value );
12732 this.buttons.button( value ?
"disable" :
"enable" );
12736 _setOptions: spinner_modifier(
function( options ) {
12737 this._super( options );
12740 _parse:
function( val ) {
12741 if ( typeof val ===
"string" && val !==
"" ) {
12742 val =
window.Globalize && this.options.numberFormat ?
12743 Globalize.parseFloat( val, 10, this.options.culture ) : +val;
12745 return val ===
"" || isNaN( val ) ? null : val;
12748 _format:
function( value ) {
12749 if ( value ===
"" ) {
12752 return window.Globalize && this.options.numberFormat ?
12753 Globalize.format( value, this.options.numberFormat,
this.options.culture ) :
12757 _refresh:
function() {
12758 this.element.attr({
12759 "aria-valuemin": this.options.min,
12760 "aria-valuemax": this.options.max,
12762 "aria-valuenow": this._parse( this.element.val() )
12766 isValid:
function() {
12767 var value = this.value();
12770 if ( value === null ) {
12775 return value === this._adjustValue( value );
12779 _value:
function( value, allowAny ) {
12781 if ( value !==
"" ) {
12782 parsed = this._parse( value );
12783 if ( parsed !== null ) {
12785 parsed = this._adjustValue( parsed );
12787 value = this._format( parsed );
12790 this.element.val( value );
12794 _destroy:
function() {
12796 .removeClass(
"ui-spinner-input" )
12797 .prop(
"disabled",
false )
12798 .removeAttr(
"autocomplete" )
12799 .removeAttr(
"role" )
12800 .removeAttr(
"aria-valuemin" )
12801 .removeAttr(
"aria-valuemax" )
12802 .removeAttr(
"aria-valuenow" );
12803 this.uiSpinner.replaceWith( this.element );
12806 stepUp: spinner_modifier(
function( steps ) {
12807 this._stepUp( steps );
12809 _stepUp:
function( steps ) {
12810 if ( this._start() ) {
12811 this._spin( (steps || 1) * this.options.step );
12816 stepDown: spinner_modifier(
function( steps ) {
12817 this._stepDown( steps );
12819 _stepDown:
function( steps ) {
12820 if ( this._start() ) {
12821 this._spin( (steps || 1) * -this.options.step );
12826 pageUp: spinner_modifier(
function( pages ) {
12827 this._stepUp( (pages || 1) * this.options.page );
12830 pageDown: spinner_modifier(
function( pages ) {
12831 this._stepDown( (pages || 1) * this.options.page );
12834 value:
function( newVal ) {
12835 if ( !arguments.length ) {
12836 return this._parse( this.element.val() );
12838 spinner_modifier( this._value ).call(
this, newVal );
12841 widget:
function() {
12842 return this.uiSpinner;
12859 var tabs = $.widget(
"ui.tabs", {
12864 collapsible:
false,
12866 heightStyle:
"content",
12872 beforeActivate: null,
12877 _isLocal: (
function() {
12878 var
rhash = /#.*$/;
12880 return function( anchor ) {
12881 var anchorUrl, locationUrl;
12885 anchor = anchor.cloneNode(
false );
12887 anchorUrl = anchor.href.replace( rhash,
"" );
12888 locationUrl = location.href.replace( rhash,
"" );
12892 anchorUrl = decodeURIComponent( anchorUrl );
12893 }
catch ( error ) {}
12895 locationUrl = decodeURIComponent( locationUrl );
12896 }
catch ( error ) {}
12898 return anchor.hash.length > 1 && anchorUrl === locationUrl;
12902 _create:
function() {
12904 options = this.options;
12906 this.running =
false;
12909 .addClass(
"ui-tabs ui-widget ui-widget-content ui-corner-all" )
12910 .toggleClass(
"ui-tabs-collapsible", options.collapsible );
12912 this._processTabs();
12913 options.active = this._initialActive();
12917 if ( $.isArray( options.disabled ) ) {
12918 options.disabled = $.unique( options.disabled.concat(
12919 $.map(
this.tabs.filter(
".ui-state-disabled" ),
function( li ) {
12920 return that.tabs.index( li );
12926 if ( this.options.active !==
false &&
this.anchors.length ) {
12927 this.active = this._findActive( options.active );
12934 if ( this.active.length ) {
12935 this.
load( options.active );
12939 _initialActive:
function() {
12940 var active = this.options.active,
12941 collapsible = this.options.collapsible,
12942 locationHash = location.hash.substring( 1 );
12944 if ( active === null ) {
12946 if ( locationHash ) {
12947 this.tabs.each(
function( i, tab ) {
12948 if ( $( tab ).attr(
"aria-controls" ) === locationHash ) {
12956 if ( active === null ) {
12957 active = this.tabs.index( this.tabs.filter(
".ui-tabs-active" ) );
12961 if ( active === null || active === -1 ) {
12962 active = this.tabs.length ? 0 :
false;
12967 if ( active !==
false ) {
12968 active = this.tabs.index( this.tabs.eq( active ) );
12969 if ( active === -1 ) {
12970 active = collapsible ?
false : 0;
12975 if ( !collapsible && active ===
false && this.anchors.length ) {
12982 _getCreateEventData:
function() {
12985 panel: !this.active.length ? $() : this._getPanelForTab( this.active )
12989 _tabKeydown:
function( event ) {
12990 var focusedTab = $( this.document[0].activeElement ).closest(
"li" ),
12991 selectedIndex = this.tabs.index( focusedTab ),
12992 goingForward =
true;
12994 if ( this._handlePageNav( event ) ) {
12998 switch ( event.keyCode ) {
12999 case $.ui.keyCode.RIGHT:
13000 case $.ui.keyCode.DOWN:
13003 case $.ui.keyCode.UP:
13004 case $.ui.keyCode.LEFT:
13005 goingForward =
false;
13008 case $.ui.keyCode.END:
13009 selectedIndex = this.anchors.length - 1;
13011 case $.ui.keyCode.HOME:
13014 case $.ui.keyCode.SPACE:
13016 event.preventDefault();
13017 clearTimeout( this.activating );
13018 this._activate( selectedIndex );
13020 case $.ui.keyCode.ENTER:
13022 event.preventDefault();
13023 clearTimeout( this.activating );
13025 this._activate( selectedIndex === this.options.active ?
false : selectedIndex );
13032 event.preventDefault();
13033 clearTimeout( this.activating );
13034 selectedIndex = this._focusNextTab( selectedIndex, goingForward );
13037 if ( !event.ctrlKey ) {
13041 focusedTab.attr(
"aria-selected",
"false" );
13042 this.tabs.eq( selectedIndex ).attr(
"aria-selected",
"true" );
13044 this.activating = this._delay(
function() {
13045 this.option(
"active", selectedIndex );
13050 _panelKeydown:
function( event ) {
13051 if ( this._handlePageNav( event ) ) {
13056 if ( event.ctrlKey && event.keyCode === $.ui.keyCode.UP ) {
13057 event.preventDefault();
13058 this.active.focus();
13063 _handlePageNav:
function( event ) {
13064 if ( event.altKey && event.keyCode === $.ui.keyCode.PAGE_UP ) {
13065 this._activate( this._focusNextTab( this.options.active - 1,
false ) );
13068 if ( event.altKey && event.keyCode === $.ui.keyCode.PAGE_DOWN ) {
13069 this._activate( this._focusNextTab( this.options.active + 1,
true ) );
13074 _findNextTab:
function( index, goingForward ) {
13075 var lastTabIndex = this.tabs.length - 1;
13077 function constrain() {
13078 if ( index > lastTabIndex ) {
13082 index = lastTabIndex;
13087 while ( $.inArray( constrain(), this.options.disabled ) !== -1 ) {
13088 index = goingForward ? index + 1 : index - 1;
13094 _focusNextTab:
function( index, goingForward ) {
13095 index = this._findNextTab( index, goingForward );
13096 this.tabs.eq( index ).focus();
13100 _setOption:
function( key, value ) {
13101 if ( key ===
"active" ) {
13103 this._activate( value );
13107 if ( key ===
"disabled" ) {
13109 this._setupDisabled( value );
13113 this._super( key, value);
13115 if ( key ===
"collapsible" ) {
13116 this.element.toggleClass(
"ui-tabs-collapsible", value );
13118 if ( !value && this.options.active ===
false ) {
13119 this._activate( 0 );
13123 if ( key ===
"event" ) {
13124 this._setupEvents( value );
13127 if ( key ===
"heightStyle" ) {
13128 this._setupHeightStyle( value );
13132 _sanitizeSelector:
function( hash ) {
13133 return hash ? hash.replace( /[!
"$%&'()*+,.\/:;<=>?@\[\]\^`{|}~]/g, "\\$&
" ) : ""; 13136 refresh: function() { 13137 var options = this.options, 13138 lis = this.tablist.children( ":has(a[href])
" ); 13140 // get disabled tabs from class attribute from HTML 13141 // this will get converted to a boolean if needed in _refresh() 13142 options.disabled = $.map( lis.filter( ".ui-state-disabled
" ), function( tab ) { 13143 return lis.index( tab ); 13146 this._processTabs(); 13148 // was collapsed or no tabs 13149 if ( options.active === false || !this.anchors.length ) { 13150 options.active = false; 13152 // was active, but active tab is gone 13153 } else if ( this.active.length && !$.contains( this.tablist[ 0 ], this.active[ 0 ] ) ) { 13154 // all remaining tabs are disabled 13155 if ( this.tabs.length === options.disabled.length ) { 13156 options.active = false; 13158 // activate previous tab 13160 this._activate( this._findNextTab( Math.max( 0, options.active - 1 ), false ) ); 13162 // was active, active tab still exists 13164 // make sure active index is correct 13165 options.active = this.tabs.index( this.active ); 13171 _refresh: function() { 13172 this._setupDisabled( this.options.disabled ); 13173 this._setupEvents( this.options.event ); 13174 this._setupHeightStyle( this.options.heightStyle ); 13176 this.tabs.not( this.active ).attr({ 13177 "aria-selected
": "false", 13178 "aria-expanded
": "false", 13181 this.panels.not( this._getPanelForTab( this.active ) ) 13184 "aria-hidden
": "true" 13187 // Make sure one tab is in the tab order 13188 if ( !this.active.length ) { 13189 this.tabs.eq( 0 ).attr( "tabIndex
", 0 ); 13192 .addClass( "ui-tabs-active ui-state-active
" ) 13194 "aria-selected
": "true", 13195 "aria-expanded
": "true", 13198 this._getPanelForTab( this.active ) 13201 "aria-hidden
": "false" 13206 _processTabs: function() { 13208 prevTabs = this.tabs, 13209 prevAnchors = this.anchors, 13210 prevPanels = this.panels; 13212 this.tablist = this._getList() 13213 .addClass( "ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all
" ) 13214 .attr( "role
", "tablist
" ) 13216 // Prevent users from focusing disabled tabs via click 13217 .delegate( "> li
", "mousedown
" + this.eventNamespace, function( event ) { 13218 if ( $( this ).is( ".ui-state-disabled
" ) ) { 13219 event.preventDefault(); 13224 // Preventing the default action in mousedown doesn't prevent IE 13225 // from focusing the element, so if the anchor gets focused, blur. 13226 // We don't have to worry about focusing the previously focused 13227 // element since clicking on a non-focusable element should focus 13228 // the body anyway. 13229 .delegate( ".ui-tabs-anchor
", "focus
" + this.eventNamespace, function() { 13230 if ( $( this ).closest( "li
" ).is( ".ui-state-disabled
" ) ) { 13235 this.tabs = this.tablist.find( "> li:has(a[href])
" ) 13236 .addClass( "ui-state-
default ui-corner-top
" ) 13242 this.anchors = this.tabs.map(function() { 13243 return $( "a
", this )[ 0 ]; 13245 .addClass( "ui-tabs-anchor
" ) 13247 role: "presentation
", 13253 this.anchors.each(function( i, anchor ) { 13254 var selector, panel, panelId, 13255 anchorId = $( anchor ).uniqueId().attr( "id" ), 13256 tab = $( anchor ).closest( "li
" ), 13257 originalAriaControls = tab.attr( "aria-controls
" ); 13260 if ( that._isLocal( anchor ) ) { 13261 selector = anchor.hash; 13262 panelId = selector.substring( 1 ); 13263 panel = that.element.find( that._sanitizeSelector( selector ) ); 13266 // If the tab doesn't already have aria-controls, 13267 // generate an id by using a throw-away element 13268 panelId = tab.attr( "aria-controls
" ) || $( {} ).uniqueId()[ 0 ].id; 13269 selector = "#
" + panelId; 13270 panel = that.element.find( selector ); 13271 if ( !panel.length ) { 13272 panel = that._createPanel( panelId ); 13273 panel.insertAfter( that.panels[ i - 1 ] || that.tablist ); 13275 panel.attr( "aria-live
", "polite
" ); 13278 if ( panel.length) { 13279 that.panels = that.panels.add( panel ); 13281 if ( originalAriaControls ) { 13282 tab.data( "ui-tabs-aria-controls
", originalAriaControls ); 13285 "aria-controls
": panelId, 13286 "aria-labelledby
": anchorId 13288 panel.attr( "aria-labelledby
", anchorId ); 13292 .addClass( "ui-tabs-panel ui-widget-content ui-corner-bottom
" ) 13293 .attr( "role
", "tabpanel
" ); 13295 // Avoid memory leaks (#10056) 13297 this._off( prevTabs.not( this.tabs ) ); 13298 this._off( prevAnchors.not( this.anchors ) ); 13299 this._off( prevPanels.not( this.panels ) ); 13303 // allow overriding how to find the list for rare usage scenarios (#7715) 13304 _getList: function() { 13305 return this.tablist || this.element.find( "ol,ul
" ).eq( 0 ); 13308 _createPanel: function( id ) { 13309 return $( "<div>
" ) 13311 .addClass( "ui-tabs-panel ui-widget-content ui-corner-bottom
" ) 13312 .data( "ui-tabs-destroy
", true ); 13315 _setupDisabled: function( disabled ) { 13316 if ( $.isArray( disabled ) ) { 13317 if ( !disabled.length ) { 13319 } else if ( disabled.length === this.anchors.length ) { 13325 for ( var i = 0, li; ( li = this.tabs[ i ] ); i++ ) { 13326 if ( disabled === true || $.inArray( i, disabled ) !== -1 ) { 13328 .addClass( "ui-state-disabled
" ) 13329 .attr( "aria-disabled
", "true" ); 13332 .removeClass( "ui-state-disabled
" ) 13333 .removeAttr( "aria-disabled
" ); 13337 this.options.disabled = disabled; 13340 _setupEvents: function( event ) { 13343 $.each( event.split(" "), function( index, eventName ) { 13344 events[ eventName ] = "_eventHandler
"; 13348 this._off( this.anchors.add( this.tabs ).add( this.panels ) ); 13349 // Always prevent the default action, even when disabled 13350 this._on( true, this.anchors, { 13351 click: function( event ) { 13352 event.preventDefault(); 13355 this._on( this.anchors, events ); 13356 this._on( this.tabs, { keydown: "_tabKeydown
" } ); 13357 this._on( this.panels, { keydown: "_panelKeydown
" } ); 13359 this._focusable( this.tabs ); 13360 this._hoverable( this.tabs ); 13363 _setupHeightStyle: function( heightStyle ) { 13365 parent = this.element.parent(); 13367 if ( heightStyle === "fill
" ) { 13368 maxHeight = parent.height(); 13369 maxHeight -= this.element.outerHeight() - this.element.height(); 13371 this.element.siblings( ":visible
" ).each(function() { 13372 var elem = $( this ), 13373 position = elem.css( "position
" ); 13375 if ( position === "absolute
" || position === "fixed
" ) { 13378 maxHeight -= elem.outerHeight( true ); 13381 this.element.children().not( this.panels ).each(function() { 13382 maxHeight -= $( this ).outerHeight( true ); 13385 this.panels.each(function() { 13386 $( this ).height( Math.max( 0, maxHeight - 13387 $( this ).innerHeight() + $( this ).height() ) ); 13389 .css( "overflow
", "auto" ); 13390 } else if ( heightStyle === "auto" ) { 13392 this.panels.each(function() { 13393 maxHeight = Math.max( maxHeight, $( this ).height( "" ).height() ); 13394 }).height( maxHeight ); 13398 _eventHandler: function( event ) { 13399 var options = this.options, 13400 active = this.active, 13401 anchor = $( event.currentTarget ), 13402 tab = anchor.closest( "li
" ), 13403 clickedIsActive = tab[ 0 ] === active[ 0 ], 13404 collapsing = clickedIsActive && options.collapsible, 13405 toShow = collapsing ? $() : this._getPanelForTab( tab ), 13406 toHide = !active.length ? $() : this._getPanelForTab( active ), 13410 newTab: collapsing ? $() : tab, 13414 event.preventDefault(); 13416 if ( tab.hasClass( "ui-state-disabled
" ) || 13417 // tab is already loading 13418 tab.hasClass( "ui-tabs-loading
" ) || 13419 // can't switch durning an animation 13421 // click on active header, but not collapsible 13422 ( clickedIsActive && !options.collapsible ) || 13423 // allow canceling activation 13424 ( this._trigger( "beforeActivate
", event, eventData ) === false ) ) { 13428 options.active = collapsing ? false : this.tabs.index( tab ); 13430 this.active = clickedIsActive ? $() : tab; 13435 if ( !toHide.length && !toShow.length ) { 13436 $.error( "jQuery UI Tabs: Mismatching fragment identifier.
" ); 13439 if ( toShow.length ) { 13440 this.load( this.tabs.index( tab ), event ); 13442 this._toggle( event, eventData ); 13445 // handles show/hide for selecting tabs 13446 _toggle: function( event, eventData ) { 13448 toShow = eventData.newPanel, 13449 toHide = eventData.oldPanel; 13451 this.running = true; 13453 function complete() { 13454 that.running = false; 13455 that._trigger( "activate
", event, eventData ); 13459 eventData.newTab.closest( "li
" ).addClass( "ui-tabs-active ui-state-active
" ); 13461 if ( toShow.length && that.options.show ) { 13462 that._show( toShow, that.options.show, complete ); 13469 // start out by hiding, then showing, then completing 13470 if ( toHide.length && this.options.hide ) { 13471 this._hide( toHide, this.options.hide, function() { 13472 eventData.oldTab.closest( "li
" ).removeClass( "ui-tabs-active ui-state-active
" ); 13476 eventData.oldTab.closest( "li
" ).removeClass( "ui-tabs-active ui-state-active
" ); 13481 toHide.attr( "aria-hidden
", "true" ); 13482 eventData.oldTab.attr({ 13483 "aria-selected
": "false", 13484 "aria-expanded
": "false" 13486 // If we're switching tabs, remove the old tab from the tab order. 13487 // If we're opening from collapsed state, remove the previous tab from the tab order. 13488 // If we're collapsing, then keep the collapsing tab in the tab order. 13489 if ( toShow.length && toHide.length ) { 13490 eventData.oldTab.attr( "tabIndex
", -1 ); 13491 } else if ( toShow.length ) { 13492 this.tabs.filter(function() { 13493 return $( this ).attr( "tabIndex
" ) === 0; 13495 .attr( "tabIndex
", -1 ); 13498 toShow.attr( "aria-hidden
", "false" ); 13499 eventData.newTab.attr({ 13500 "aria-selected
": "true", 13501 "aria-expanded
": "true", 13506 _activate: function( index ) { 13508 active = this._findActive( index ); 13510 // trying to activate the already active panel 13511 if ( active[ 0 ] === this.active[ 0 ] ) { 13515 // trying to collapse, simulate a click on the current active header 13516 if ( !active.length ) { 13517 active = this.active; 13520 anchor = active.find( ".ui-tabs-anchor
" )[ 0 ]; 13521 this._eventHandler({ 13523 currentTarget: anchor, 13524 preventDefault: $.noop 13528 _findActive: function( index ) { 13529 return index === false ? $() : this.tabs.eq( index ); 13532 _getIndex: function( index ) { 13533 // meta-function to give users option to provide a href string instead of a numerical index. 13534 if ( typeof index === "string" ) { 13535 index = this.anchors.index( this.anchors.filter( "[href$=
'" + index + "']
" ) ); 13541 _destroy: function() { 13546 this.element.removeClass( "ui-tabs ui-widget ui-widget-content ui-corner-all ui-tabs-collapsible
" ); 13549 .removeClass( "ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all
" ) 13550 .removeAttr( "role
" ); 13553 .removeClass( "ui-tabs-anchor
" ) 13554 .removeAttr( "role
" ) 13555 .removeAttr( "tabIndex
" ) 13558 this.tablist.unbind( this.eventNamespace ); 13560 this.tabs.add( this.panels ).each(function() { 13561 if ( $.data( this, "ui-tabs-destroy
" ) ) { 13562 $( this ).remove(); 13565 .removeClass( "ui-state-
default ui-state-active ui-state-disabled
" + 13566 "ui-corner-top ui-corner-bottom ui-widget-content ui-tabs-active ui-tabs-panel
" ) 13567 .removeAttr( "tabIndex
" ) 13568 .removeAttr( "aria-live
" ) 13569 .removeAttr( "aria-busy
" ) 13570 .removeAttr( "aria-selected
" ) 13571 .removeAttr( "aria-labelledby
" ) 13572 .removeAttr( "aria-hidden
" ) 13573 .removeAttr( "aria-expanded
" ) 13574 .removeAttr( "role
" ); 13578 this.tabs.each(function() { 13579 var li = $( this ), 13580 prev = li.data( "ui-tabs-aria-controls
" ); 13583 .attr( "aria-controls
", prev ) 13584 .removeData( "ui-tabs-aria-controls
" ); 13586 li.removeAttr( "aria-controls
" ); 13590 this.panels.show(); 13592 if ( this.options.heightStyle !== "content
" ) { 13593 this.panels.css( "height
", "" ); 13597 enable: function( index ) { 13598 var disabled = this.options.disabled; 13599 if ( disabled === false ) { 13603 if ( index === undefined ) { 13606 index = this._getIndex( index ); 13607 if ( $.isArray( disabled ) ) { 13608 disabled = $.map( disabled, function( num ) { 13609 return num !== index ? num : null; 13612 disabled = $.map( this.tabs, function( li, num ) { 13613 return num !== index ? num : null; 13617 this._setupDisabled( disabled ); 13620 disable: function( index ) { 13621 var disabled = this.options.disabled; 13622 if ( disabled === true ) { 13626 if ( index === undefined ) { 13629 index = this._getIndex( index ); 13630 if ( $.inArray( index, disabled ) !== -1 ) { 13633 if ( $.isArray( disabled ) ) { 13634 disabled = $.merge( [ index ], disabled ).sort(); 13636 disabled = [ index ]; 13639 this._setupDisabled( disabled ); 13642 load: function( index, event ) { 13643 index = this._getIndex( index ); 13645 tab = this.tabs.eq( index ), 13646 anchor = tab.find( ".ui-tabs-anchor
" ), 13647 panel = this._getPanelForTab( tab ), 13654 if ( this._isLocal( anchor[ 0 ] ) ) { 13658 this.xhr = $.ajax( this._ajaxSettings( anchor, event, eventData ) ); 13660 // support: jQuery <1.8 13661 // jQuery <1.8 returns false if the request is canceled in beforeSend, 13662 // but as of 1.8, $.ajax() always returns a jqXHR object. 13663 if ( this.xhr && this.xhr.statusText !== "canceled
" ) { 13664 tab.addClass( "ui-tabs-loading
" ); 13665 panel.attr( "aria-busy
", "true" ); 13668 .success(function( response ) { 13669 // support: jQuery <1.8 13670 // http://bugs.jquery.com/ticket/11778 13671 setTimeout(function() { 13672 panel.html( response ); 13673 that._trigger( "load", event, eventData ); 13676 .complete(function( jqXHR, status ) { 13677 // support: jQuery <1.8 13678 // http://bugs.jquery.com/ticket/11778 13679 setTimeout(function() { 13680 if ( status === "abort
" ) { 13681 that.panels.stop( false, true ); 13684 tab.removeClass( "ui-tabs-loading
" ); 13685 panel.removeAttr( "aria-busy
" ); 13687 if ( jqXHR === that.xhr ) { 13695 _ajaxSettings: function( anchor, event, eventData ) { 13698 url: anchor.attr( "href
" ), 13699 beforeSend: function( jqXHR, settings ) { 13700 return that._trigger( "beforeLoad
", event, 13701 $.extend( { jqXHR: jqXHR, ajaxSettings: settings }, eventData ) ); 13706 _getPanelForTab: function( tab ) { 13707 var id = $( tab ).attr( "aria-controls
" ); 13708 return this.element.find( this._sanitizeSelector( "#
" + id ) ); 13725 var tooltip = $.widget( "ui.tooltip
", { 13728 content: function() { 13729 // support: IE<9, Opera in jQuery <1.7 13730 // .text() can't accept undefined, so coerce to a string 13731 var title = $( this ).attr( "title
" ) || ""; 13732 // Escape title, since we're going from an attribute to raw HTML 13733 return $( "<a>
" ).text( title ).html(); 13736 // Disabled elements have inconsistent behavior across browsers (#8661) 13737 items: "[title]:not([disabled])
", 13741 collision: "flipfit flip
" 13744 tooltipClass: null, 13752 _addDescribedBy: function( elem, id ) { 13753 var describedby = (elem.attr( "aria-describedby
" ) || "").split( /\s+/ ); 13754 describedby.push( id ); 13756 .data( "ui-tooltip-
id", id ) 13757 .attr( "aria-describedby
", $.trim( describedby.join( " " ) ) ); 13760 _removeDescribedBy: function( elem ) { 13761 var id = elem.data( "ui-tooltip-
id" ), 13762 describedby = (elem.attr( "aria-describedby
" ) || "").split( /\s+/ ), 13763 index = $.inArray( id, describedby ); 13765 if ( index !== -1 ) { 13766 describedby.splice( index, 1 ); 13769 elem.removeData( "ui-tooltip-
id" ); 13770 describedby = $.trim( describedby.join( " " ) ); 13771 if ( describedby ) { 13772 elem.attr( "aria-describedby
", describedby ); 13774 elem.removeAttr( "aria-describedby
" ); 13778 _create: function() { 13784 // IDs of generated tooltips, needed for destroy 13785 this.tooltips = {}; 13787 // IDs of parent tooltips where we removed the title attribute 13790 if ( this.options.disabled ) { 13794 // Append the aria-live region so tooltips announce correctly 13795 this.liveRegion = $( "<div>
" ) 13798 "aria-live
": "assertive
", 13799 "aria-relevant
": "additions
" 13801 .addClass( "ui-helper-hidden-accessible
" ) 13802 .appendTo( this.document[ 0 ].body ); 13805 _setOption: function( key, value ) { 13808 if ( key === "disabled
" ) { 13809 this[ value ? "_disable
" : "_enable
" ](); 13810 this.options[ key ] = value; 13811 // disable element style changes 13815 this._super( key, value ); 13817 if ( key === "content
" ) { 13818 $.each( this.tooltips, function( id, tooltipData ) { 13819 that._updateContent( tooltipData.element ); 13824 _disable: function() { 13827 // close open tooltips 13828 $.each( this.tooltips, function( id, tooltipData ) { 13829 var event = $.Event( "blur
" ); 13830 event.target = event.currentTarget = tooltipData.element[ 0 ]; 13831 that.close( event, true ); 13834 // remove title attributes to prevent native tooltips 13835 this.element.find( this.options.items ).addBack().each(function() { 13836 var element = $( this ); 13837 if ( element.is( "[title]
" ) ) { 13839 .data( "ui-tooltip-title
", element.attr( "title
" ) ) 13840 .removeAttr( "title
" ); 13845 _enable: function() { 13846 // restore title attributes 13847 this.element.find( this.options.items ).addBack().each(function() { 13848 var element = $( this ); 13849 if ( element.data( "ui-tooltip-title
" ) ) { 13850 element.attr( "title
", element.data( "ui-tooltip-title
" ) ); 13855 open: function( event ) { 13857 target = $( event ? event.target : this.element ) 13858 // we need closest here due to mouseover bubbling, 13859 // but always pointing at the same event target 13860 .closest( this.options.items ); 13862 // No element to show a tooltip for or the tooltip is already open 13863 if ( !target.length || target.data( "ui-tooltip-
id" ) ) { 13867 if ( target.attr( "title
" ) ) { 13868 target.data( "ui-tooltip-title
", target.attr( "title
" ) ); 13871 target.data( "ui-tooltip-open
", true ); 13873 // kill parent tooltips, custom or native, for hover 13874 if ( event && event.type === "mouseover
" ) { 13875 target.parents().each(function() { 13876 var parent = $( this ), 13878 if ( parent.data( "ui-tooltip-open
" ) ) { 13879 blurEvent = $.Event( "blur
" ); 13880 blurEvent.target = blurEvent.currentTarget = this; 13881 that.close( blurEvent, true ); 13883 if ( parent.attr( "title
" ) ) { 13885 that.parents[ this.id ] = { 13887 title: parent.attr( "title
" ) 13889 parent.attr( "title
", "" ); 13894 this._updateContent( target, event ); 13897 _updateContent: function( target, event ) { 13899 contentOption = this.options.content, 13901 eventType = event ? event.type : null; 13903 if ( typeof contentOption === "string" ) { 13904 return this._open( event, target, contentOption ); 13907 content = contentOption.call( target[0], function( response ) { 13908 // ignore async response if tooltip was closed already 13909 if ( !target.data( "ui-tooltip-open
" ) ) { 13912 // IE may instantly serve a cached response for ajax requests 13913 // delay this call to _open so the other call to _open runs first 13914 that._delay(function() { 13915 // jQuery creates a special event for focusin when it doesn't 13916 // exist natively. To improve performance, the native event 13917 // object is reused and the type is changed. Therefore, we can't 13918 // rely on the type being correct after the event finished 13919 // bubbling, so we set it back to the previous value. (#8740) 13921 event.type = eventType; 13923 this._open( event, target, response ); 13927 this._open( event, target, content ); 13931 _open: function( event, target, content ) { 13932 var tooltipData, tooltip, events, delayedShow, a11yContent, 13933 positionOption = $.extend( {}, this.options.position ); 13939 // Content can be updated multiple times. If the tooltip already 13940 // exists, then just update the content and bail. 13941 tooltipData = this._find( target ); 13942 if ( tooltipData ) { 13943 tooltipData.tooltip.find( ".ui-tooltip-content
" ).html( content ); 13947 // if we have a title, clear it to prevent the native tooltip 13948 // we have to check first to avoid defining a title if none exists 13949 // (we don't want to cause an element to start matching [title]) 13951 // We use removeAttr only for key events, to allow IE to export the correct 13952 // accessible attributes. For mouse events, set to empty string to avoid 13953 // native tooltip showing up (happens only when removing inside mouseover). 13954 if ( target.is( "[title]
" ) ) { 13955 if ( event && event.type === "mouseover
" ) { 13956 target.attr( "title
", "" ); 13958 target.removeAttr( "title
" ); 13962 tooltipData = this._tooltip( target ); 13963 tooltip = tooltipData.tooltip; 13964 this._addDescribedBy( target, tooltip.attr( "id" ) ); 13965 tooltip.find( ".ui-tooltip-content
" ).html( content ); 13967 // Support: Voiceover on OS X, JAWS on IE <= 9 13968 // JAWS announces deletions even when aria-relevant="additions
" 13969 // Voiceover will sometimes re-read the entire log region's contents from the beginning 13970 this.liveRegion.children().hide(); 13971 if ( content.clone ) { 13972 a11yContent = content.clone(); 13973 a11yContent.removeAttr( "id" ).find( "[
id]
" ).removeAttr( "id" ); 13975 a11yContent = content; 13977 $( "<div>
" ).html( a11yContent ).appendTo( this.liveRegion ); 13979 function position( event ) { 13980 positionOption.of = event; 13981 if ( tooltip.is( ":hidden
" ) ) { 13984 tooltip.position( positionOption ); 13986 if ( this.options.track && event && /^mouse/.test( event.type ) ) { 13987 this._on( this.document, { 13988 mousemove: position 13990 // trigger once to override element-relative positioning 13993 tooltip.position( $.extend({ 13995 }, this.options.position ) ); 14000 this._show( tooltip, this.options.show ); 14001 // Handle tracking tooltips that are shown with a delay (#8644). As soon 14002 // as the tooltip is visible, position the tooltip using the most recent 14004 if ( this.options.show && this.options.show.delay ) { 14005 delayedShow = this.delayedShow = setInterval(function() { 14006 if ( tooltip.is( ":visible
" ) ) { 14007 position( positionOption.of ); 14008 clearInterval( delayedShow ); 14010 }, $.fx.interval ); 14013 this._trigger( "open
", event, { tooltip: tooltip } ); 14016 keyup: function( event ) { 14017 if ( event.keyCode === $.ui.keyCode.ESCAPE ) { 14018 var fakeEvent = $.Event(event); 14019 fakeEvent.currentTarget = target[0]; 14020 this.close( fakeEvent, true ); 14025 // Only bind remove handler for delegated targets. Non-delegated 14026 // tooltips will handle this in destroy. 14027 if ( target[ 0 ] !== this.element[ 0 ] ) { 14028 events.remove = function() { 14029 this._removeTooltip( tooltip ); 14033 if ( !event || event.type === "mouseover
" ) { 14034 events.mouseleave = "close
"; 14036 if ( !event || event.type === "focusin
" ) { 14037 events.focusout = "close
"; 14039 this._on( true, target, events ); 14042 close: function( event ) { 14045 target = $( event ? event.currentTarget : this.element ), 14046 tooltipData = this._find( target ); 14048 // The tooltip may already be closed 14049 if ( !tooltipData ) { 14053 tooltip = tooltipData.tooltip; 14055 // disabling closes the tooltip, so we need to track when we're closing 14056 // to avoid an infinite loop in case the tooltip becomes disabled on close 14057 if ( tooltipData.closing ) { 14061 // Clear the interval for delayed tracking tooltips 14062 clearInterval( this.delayedShow ); 14064 // only set title if we had one before (see comment in _open()) 14065 // If the title attribute has changed since open(), don't restore 14066 if ( target.data( "ui-tooltip-title
" ) && !target.attr( "title
" ) ) { 14067 target.attr( "title
", target.data( "ui-tooltip-title
" ) ); 14070 this._removeDescribedBy( target ); 14072 tooltipData.hiding = true; 14073 tooltip.stop( true ); 14074 this._hide( tooltip, this.options.hide, function() { 14075 that._removeTooltip( $( this ) ); 14078 target.removeData( "ui-tooltip-open
" ); 14079 this._off( target, "mouseleave focusout keyup
" ); 14081 // Remove 'remove' binding only on delegated targets 14082 if ( target[ 0 ] !== this.element[ 0 ] ) { 14083 this._off( target, "remove" ); 14085 this._off( this.document, "mousemove
" ); 14087 if ( event && event.type === "mouseleave
" ) { 14088 $.each( this.parents, function( id, parent ) { 14089 $( parent.element ).attr( "title
", parent.title ); 14090 delete that.parents[ id ]; 14094 tooltipData.closing = true; 14095 this._trigger( "close
", event, { tooltip: tooltip } ); 14096 if ( !tooltipData.hiding ) { 14097 tooltipData.closing = false; 14101 _tooltip: function( element ) { 14102 var tooltip = $( "<div>
" ) 14103 .attr( "role
", "tooltip
" ) 14104 .addClass( "ui-tooltip ui-widget ui-corner-all ui-widget-content
" + 14105 ( this.options.tooltipClass || "" ) ), 14106 id = tooltip.uniqueId().attr( "id" ); 14109 .addClass( "ui-tooltip-content
" ) 14110 .appendTo( tooltip ); 14112 tooltip.appendTo( this.document[0].body ); 14114 return this.tooltips[ id ] = { 14120 _find: function( target ) { 14121 var id = target.data( "ui-tooltip-
id" ); 14122 return id ? this.tooltips[ id ] : null; 14125 _removeTooltip: function( tooltip ) { 14127 delete this.tooltips[ tooltip.attr( "id" ) ]; 14130 _destroy: function() { 14133 // close open tooltips 14134 $.each( this.tooltips, function( id, tooltipData ) { 14135 // Delegate to close method to handle common cleanup 14136 var event = $.Event( "blur
" ), 14137 element = tooltipData.element; 14138 event.target = event.currentTarget = element[ 0 ]; 14139 that.close( event, true ); 14141 // Remove immediately; destroying an open tooltip doesn't use the 14143 $( "#
" + id ).remove(); 14145 // Restore the title 14146 if ( element.data( "ui-tooltip-title
" ) ) { 14147 // If the title attribute has changed since open(), don't restore 14148 if ( !element.attr( "title
" ) ) { 14149 element.attr( "title
", element.data( "ui-tooltip-title
" ) ); 14151 element.removeData( "ui-tooltip-title
" ); 14154 this.liveRegion.remove(); 14171 var dataSpace = "ui-effects-
", 14173 // Create a local jQuery because jQuery Color relies on it and the 14174 // global may not exist with AMD and a custom build (#10199) 14191 (function( jQuery, undefined ) {
14193 var stepHooks = "backgroundColor borderBottomColor borderLeftColor borderRightColor borderTopColor color columnRuleColor outlineColor textDecorationColor textEmphasisColor
", 14195 // plusequals test for += 100 -= 100 14196 rplusequals = /^([\-+])=\s*(\d+\.?\d*)/, 14197 // a set of RE's that can match strings and generate color tuples. 14198 stringParsers = [ { 14199 re: /rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/, 14200 parse: function( execResult ) { 14209 re: /rgba?\(\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/, 14210 parse: function( execResult ) { 14212 execResult[ 1 ] * 2.55, 14213 execResult[ 2 ] * 2.55, 14214 execResult[ 3 ] * 2.55, 14219 // this regex ignores A-F because it's compared against an already lowercased string 14220 re: /#([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})/, 14221 parse: function( execResult ) { 14223 parseInt( execResult[ 1 ], 16 ), 14224 parseInt( execResult[ 2 ], 16 ), 14225 parseInt( execResult[ 3 ], 16 ) 14229 // this regex ignores A-F because it's compared against an already lowercased string 14230 re: /#([a-f0-9])([a-f0-9])([a-f0-9])/, 14231 parse: function( execResult ) { 14233 parseInt( execResult[ 1 ] + execResult[ 1 ], 16 ), 14234 parseInt( execResult[ 2 ] + execResult[ 2 ], 16 ), 14235 parseInt( execResult[ 3 ] + execResult[ 3 ], 16 ) 14239 re: /hsla?\(\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/, 14241 parse: function( execResult ) { 14244 execResult[ 2 ] / 100, 14245 execResult[ 3 ] / 100, 14252 color = jQuery.Color = function( color, green, blue, alpha ) { 14253 return new jQuery.Color.fn.parse( color, green, blue, alpha ); 14303 support = color.support = {}, 14305 // element for support tests 14306 supportElem = jQuery( "<p>
" )[ 0 ], 14308 // colors = jQuery.Color.names 14311 // local aliases of functions called often 14312 each = jQuery.each; 14314 // determine rgba support immediately 14315 supportElem.style.cssText = "background-color:rgba(1,1,1,.5)
"; 14316 support.rgba = supportElem.style.backgroundColor.indexOf( "rgba
" ) > -1; 14318 // define cache name and alpha properties 14319 // for rgba and hsla spaces 14320 each( spaces, function( spaceName, space ) { 14321 space.cache = "_
" + spaceName; 14322 space.props.alpha = { 14329 function clamp( value, prop, allowEmpty ) { 14330 var type = propTypes[ prop.type ] || {}; 14332 if ( value == null ) { 14333 return (allowEmpty || !prop.def) ? null : prop.def; 14336 // ~~ is an short way of doing floor for positive numbers 14337 value = type.floor ? ~~value : parseFloat( value ); 14339 // IE will pass in empty strings as value for alpha, 14340 // which will hit this case 14341 if ( isNaN( value ) ) { 14346 // we add mod before modding to make sure that negatives values 14347 // get converted properly: -10 -> 350 14348 return (value + type.mod) % type.mod; 14351 // for now all property types without mod have min and max 14352 return 0 > value ? 0 : type.max < value ? type.max : value; 14355 function stringParse( string ) { 14356 var inst = color(), 14357 rgba = inst._rgba = []; 14359 string = string.toLowerCase(); 14361 each( stringParsers, function( i, parser ) { 14363 match = parser.re.exec( string ), 14364 values = match && parser.parse( match ), 14365 spaceName = parser.space || "rgba
"; 14368 parsed = inst[ spaceName ]( values ); 14370 // if this was an rgba parse the assignment might happen twice 14372 inst[ spaces[ spaceName ].cache ] = parsed[ spaces[ spaceName ].cache ]; 14373 rgba = inst._rgba = parsed._rgba; 14375 // exit each( stringParsers ) here because we matched 14380 // Found a stringParser that handled it 14381 if ( rgba.length ) { 14383 // if this came from a parsed string, force "transparent
" when alpha is 0 14384 // chrome, (and maybe others) return "transparent
" as rgba(0,0,0,0) 14385 if ( rgba.join() === "0,0,0,0
" ) { 14386 jQuery.extend( rgba, colors.transparent ); 14392 return colors[ string ]; 14395 color.fn = jQuery.extend( color.prototype, { 14396 parse: function( red, green, blue, alpha ) { 14397 if ( red === undefined ) { 14398 this._rgba = [ null, null, null, null ]; 14401 if ( red.jquery || red.nodeType ) { 14402 red = jQuery( red ).css( green ); 14407 type = jQuery.type( red ), 14408 rgba = this._rgba = []; 14410 // more than 1 argument specified - assume ( red, green, blue, alpha ) 14411 if ( green !== undefined ) { 14412 red = [ red, green, blue, alpha ]; 14416 if ( type === "string" ) { 14417 return this.parse( stringParse( red ) || colors._default ); 14420 if ( type === "array
" ) { 14421 each( spaces.rgba.props, function( key, prop ) { 14422 rgba[ prop.idx ] = clamp( red[ prop.idx ], prop ); 14427 if ( type === "object" ) { 14428 if ( red instanceof color ) { 14429 each( spaces, function( spaceName, space ) { 14430 if ( red[ space.cache ] ) { 14431 inst[ space.cache ] = red[ space.cache ].slice(); 14435 each( spaces, function( spaceName, space ) { 14436 var cache = space.cache; 14437 each( space.props, function( key, prop ) { 14439 // if the cache doesn't exist, and we know how to convert 14440 if ( !inst[ cache ] && space.to ) { 14442 // if the value was null, we don't need to copy it 14443 // if the key was alpha, we don't need to copy it either 14444 if ( key === "alpha
" || red[ key ] == null ) { 14447 inst[ cache ] = space.to( inst._rgba ); 14450 // this is the only case where we allow nulls for ALL properties. 14451 // call clamp with alwaysAllowEmpty 14452 inst[ cache ][ prop.idx ] = clamp( red[ key ], prop, true ); 14455 // everything defined but alpha? 14456 if ( inst[ cache ] && jQuery.inArray( null, inst[ cache ].slice( 0, 3 ) ) < 0 ) { 14457 // use the default of 1 14458 inst[ cache ][ 3 ] = 1; 14459 if ( space.from ) { 14460 inst._rgba = space.from( inst[ cache ] ); 14468 is: function( compare ) { 14469 var is = color( compare ), 14473 each( spaces, function( _, space ) { 14475 isCache = is[ space.cache ]; 14477 localCache = inst[ space.cache ] || space.to && space.to( inst._rgba ) || []; 14478 each( space.props, function( _, prop ) { 14479 if ( isCache[ prop.idx ] != null ) { 14480 same = ( isCache[ prop.idx ] === localCache[ prop.idx ] ); 14489 _space: function() { 14492 each( spaces, function( spaceName, space ) { 14493 if ( inst[ space.cache ] ) { 14494 used.push( spaceName ); 14499 transition: function( other, distance ) { 14500 var end = color( other ), 14501 spaceName = end._space(), 14502 space = spaces[ spaceName ], 14503 startColor = this.alpha() === 0 ? color( "transparent
" ) : this, 14504 start = startColor[ space.cache ] || space.to( startColor._rgba ), 14505 result = start.slice(); 14507 end = end[ space.cache ]; 14508 each( space.props, function( key, prop ) { 14509 var index = prop.idx, 14510 startValue = start[ index ], 14511 endValue = end[ index ], 14512 type = propTypes[ prop.type ] || {}; 14514 // if null, don't override start value 14515 if ( endValue === null ) { 14518 // if null - use end 14519 if ( startValue === null ) { 14520 result[ index ] = endValue; 14523 if ( endValue - startValue > type.mod / 2 ) { 14524 startValue += type.mod; 14525 } else if ( startValue - endValue > type.mod / 2 ) { 14526 startValue -= type.mod; 14529 result[ index ] = clamp( ( endValue - startValue ) * distance + startValue, prop ); 14532 return this[ spaceName ]( result ); 14534 blend: function( opaque ) { 14535 // if we are already opaque - return ourself 14536 if ( this._rgba[ 3 ] === 1 ) { 14540 var rgb = this._rgba.slice(), 14542 blend = color( opaque )._rgba; 14544 return color( jQuery.map( rgb, function( v, i ) { 14545 return ( 1 - a ) * blend[ i ] + a * v; 14548 toRgbaString: function() { 14549 var prefix = "rgba(
", 14550 rgba = jQuery.map( this._rgba, function( v, i ) { 14551 return v == null ? ( i > 2 ? 1 : 0 ) : v; 14554 if ( rgba[ 3 ] === 1 ) { 14559 return prefix + rgba.join() + ")
"; 14561 toHslaString: function() { 14562 var prefix = "hsla(
", 14563 hsla = jQuery.map( this.hsla(), function( v, i ) { 14569 if ( i && i < 3 ) { 14570 v = Math.round( v * 100 ) + "%
"; 14575 if ( hsla[ 3 ] === 1 ) { 14579 return prefix + hsla.join() + ")
"; 14581 toHexString: function( includeAlpha ) { 14582 var rgba = this._rgba.slice(), 14583 alpha = rgba.pop(); 14585 if ( includeAlpha ) { 14586 rgba.push( ~~( alpha * 255 ) ); 14589 return "#
" + jQuery.map( rgba, function( v ) { 14591 // default to 0 when nulls exist 14592 v = ( v || 0 ).toString( 16 ); 14593 return v.length === 1 ? "0
" + v : v; 14596 toString: function() { 14597 return this._rgba[ 3 ] === 0 ? "transparent
" : this.toRgbaString(); 14600 color.fn.parse.prototype = color.fn; 14602 // hsla conversions adapted from: 14603 // https://code.google.com/p/maashaack/source/browse/packages/graphics/trunk/src/graphics/colors/HUE2RGB.as?r=5021 14605 function hue2rgb( p, q, h ) { 14608 return p + ( q - p ) * h * 6; 14614 return p + ( q - p ) * ( ( 2 / 3 ) - h ) * 6; 14619 spaces.hsla.to = function( rgba ) { 14620 if ( rgba[ 0 ] == null || rgba[ 1 ] == null || rgba[ 2 ] == null ) { 14621 return [ null, null, null, rgba[ 3 ] ]; 14623 var r = rgba[ 0 ] / 255, 14624 g = rgba[ 1 ] / 255, 14625 b = rgba[ 2 ] / 255, 14627 max = Math.max( r, g, b ), 14628 min = Math.min( r, g, b ), 14634 if ( min === max ) { 14636 } else if ( r === max ) { 14637 h = ( 60 * ( g - b ) / diff ) + 360; 14638 } else if ( g === max ) { 14639 h = ( 60 * ( b - r ) / diff ) + 120; 14641 h = ( 60 * ( r - g ) / diff ) + 240; 14644 // chroma (diff) == 0 means greyscale which, by definition, saturation = 0% 14645 // otherwise, saturation is based on the ratio of chroma (diff) to lightness (add) 14646 if ( diff === 0 ) { 14648 } else if ( l <= 0.5 ) { 14651 s = diff / ( 2 - add ); 14653 return [ Math.round(h) % 360, s, l, a == null ? 1 : a ]; 14656 spaces.hsla.from = function( hsla ) { 14657 if ( hsla[ 0 ] == null || hsla[ 1 ] == null || hsla[ 2 ] == null ) { 14658 return [ null, null, null, hsla[ 3 ] ]; 14660 var h = hsla[ 0 ] / 360, 14664 q = l <= 0.5 ? l * ( 1 + s ) : l + s - l * s, 14668 Math.round( hue2rgb( p, q, h + ( 1 / 3 ) ) * 255 ), 14669 Math.round( hue2rgb( p, q, h ) * 255 ), 14670 Math.round( hue2rgb( p, q, h - ( 1 / 3 ) ) * 255 ), 14675 each( spaces, function( spaceName, space ) { 14676 var props = space.props, 14677 cache = space.cache, 14681 // makes rgba() and hsla() 14682 color.fn[ spaceName ] = function( value ) { 14684 // generate a cache for this space if it doesn't exist 14685 if ( to && !this[ cache ] ) { 14686 this[ cache ] = to( this._rgba ); 14688 if ( value === undefined ) { 14689 return this[ cache ].slice(); 14693 type = jQuery.type( value ), 14694 arr = ( type === "array
" || type === "object" ) ? value : arguments, 14695 local = this[ cache ].slice(); 14697 each( props, function( key, prop ) { 14698 var val = arr[ type === "object" ? key : prop.idx ]; 14699 if ( val == null ) { 14700 val = local[ prop.idx ]; 14702 local[ prop.idx ] = clamp( val, prop ); 14706 ret = color( from( local ) ); 14707 ret[ cache ] = local; 14710 return color( local ); 14714 // makes red() green() blue() alpha() hue() saturation() lightness() 14715 each( props, function( key, prop ) { 14716 // alpha is included in more than one space 14717 if ( color.fn[ key ] ) { 14720 color.fn[ key ] = function( value ) { 14721 var vtype = jQuery.type( value ), 14722 fn = ( key === "alpha
" ? ( this._hsla ? "hsla
" : "rgba
" ) : spaceName ), 14723 local = this[ fn ](), 14724 cur = local[ prop.idx ], 14731 if ( vtype === "function" ) { 14732 value = value.call( this, cur ); 14733 vtype = jQuery.type( value ); 14735 if ( value == null && prop.empty ) { 14738 if ( vtype === "string" ) { 14739 match = rplusequals.exec( value ); 14741 value = cur + parseFloat( match[ 2 ] ) * ( match[ 1 ] === "+
" ? 1 : -1 ); 14744 local[ prop.idx ] = value; 14745 return this[ fn ]( local ); 14750 // add cssHook and .fx.step function for each named hook. 14751 // accept a space separated string of properties 14752 color.hook = function( hook ) { 14753 var hooks = hook.split( " " ); 14754 each( hooks, function( i, hook ) { 14755 jQuery.cssHooks[ hook ] = { 14756 set: function( elem, value ) { 14757 var parsed, curElem, 14758 backgroundColor = ""; 14760 if ( value !== "transparent
" && ( jQuery.type( value ) !== "string" || ( parsed = stringParse( value ) ) ) ) { 14761 value = color( parsed || value ); 14762 if ( !support.rgba && value._rgba[ 3 ] !== 1 ) { 14763 curElem = hook === "backgroundColor
" ? elem.parentNode : elem; 14765 (backgroundColor === "" || backgroundColor === "transparent
") && 14766 curElem && curElem.style 14769 backgroundColor = jQuery.css( curElem, "backgroundColor
" ); 14770 curElem = curElem.parentNode; 14775 value = value.blend( backgroundColor && backgroundColor !== "transparent
" ? 14780 value = value.toRgbaString(); 14783 elem.style[ hook ] = value; 14785 // wrapped to prevent IE from throwing errors on "invalid
" values like 'auto' or 'inherit' 14789 jQuery.fx.step[ hook ] = function( fx ) { 14790 if ( !fx.colorInit ) { 14791 fx.start = color( fx.elem, hook ); 14792 fx.end = color( fx.end ); 14793 fx.colorInit = true; 14795 jQuery.cssHooks[ hook ].set( fx.elem, fx.start.transition( fx.end, fx.pos ) ); 14801 color.hook( stepHooks ); 14803 jQuery.cssHooks.borderColor = { 14804 expand: function( value ) { 14808 expanded[ "border
" + part + "Color
" ] = value; 14814 // Basic color names only. 14815 // Usage of any of the other color names requires adding yourself or including 14816 // jquery.color.svg-names.js. 14817 colors = jQuery.Color.names = { 14818 // 4.1. Basic color keywords 14822 fuchsia: "#ff00ff
", 14836 // 4.2.3. "transparent
" color keyword 14837 transparent: [ null, null, null, 0 ], 14839 _default: "#ffffff
" 14844 /******************************************************************************/ 14845 /****************************** CLASS ANIMATIONS ******************************/ 14846 /******************************************************************************/ 14849 var classAnimationActions = [ "add
", "remove", "toggle
" ], 14850 shorthandStyles = { 14862 $.each([ "borderLeftStyle
", "borderRightStyle
", "borderBottomStyle
", "borderTopStyle
" ], function( _, prop ) { 14863 $.fx.step[ prop ] = function( fx ) { 14864 if ( fx.end !== "none
" && !fx.setAttr || fx.pos === 1 && !fx.setAttr ) { 14865 jQuery.style( fx.elem, prop, fx.end ); 14871 function getElementStyles( elem ) { 14873 style = elem.ownerDocument.defaultView ? 14874 elem.ownerDocument.defaultView.getComputedStyle( elem, null ) : 14878 if ( style && style.length && style[ 0 ] && style[ style[ 0 ] ] ) { 14879 len = style.length; 14881 key = style[ len ]; 14882 if ( typeof style[ key ] === "string" ) { 14883 styles[ $.camelCase( key ) ] = style[ key ]; 14886 // support: Opera, IE <9 14888 for ( key in style ) { 14889 if ( typeof style[ key ] === "string" ) { 14890 styles[ key ] = style[ key ]; 14898 function styleDifference( oldStyle, newStyle ) { 14902 for ( name in newStyle ) { 14903 value = newStyle[ name ]; 14904 if ( oldStyle[ name ] !== value ) { 14905 if ( !shorthandStyles[ name ] ) { 14906 if ( $.fx.step[ name ] || !isNaN( parseFloat( value ) ) ) { 14907 diff[ name ] = value; 14916 // support: jQuery <1.8 14917 if ( !$.fn.addBack ) { 14918 $.fn.addBack = function( selector ) { 14919 return this.add( selector == null ? 14920 this.prevObject : this.prevObject.filter( selector ) 14925 $.effects.animateClass = function( value, duration, easing, callback ) { 14926 var o = $.speed( duration, easing, callback ); 14928 return this.queue( function() { 14929 var animated = $( this ), 14930 baseClass = animated.attr( "class" ) || "", 14932 allAnimations = o.children ? animated.find( "*
" ).addBack() : animated; 14934 // map the animated objects to store the original styles. 14935 allAnimations = allAnimations.map(function() { 14936 var el = $( this ); 14939 start: getElementStyles( this ) 14943 // apply class change 14944 applyClassChange = function() { 14945 $.each( classAnimationActions, function(i, action) { 14946 if ( value[ action ] ) { 14947 animated[ action + "Class
" ]( value[ action ] ); 14951 applyClassChange(); 14953 // map all animated objects again - calculate new styles and diff 14954 allAnimations = allAnimations.map(function() { 14955 this.end = getElementStyles( this.el[ 0 ] ); 14956 this.diff = styleDifference( this.start, this.end ); 14960 // apply original class 14961 animated.attr( "class", baseClass ); 14963 // map all animated objects again - this time collecting a promise 14964 allAnimations = allAnimations.map(function() { 14965 var styleInfo = this, 14966 dfd = $.Deferred(), 14967 opts = $.extend({}, o, { 14969 complete: function() { 14970 dfd.resolve( styleInfo ); 14974 this.el.animate( this.diff, opts ); 14975 return dfd.promise(); 14978 // once all animations have completed: 14979 $.when.apply( $, allAnimations.get() ).done(function() { 14981 // set the final class 14982 applyClassChange(); 14984 // for each animated element, 14985 // clear all css properties that were animated 14986 $.each( arguments, function() { 14988 $.each( this.diff, function(key) { 14993 // this is guarnteed to be there if you use jQuery.speed() 14994 // it also handles dequeuing the next anim... 14995 o.complete.call( animated[ 0 ] ); 15001 addClass: (function( orig ) { 15002 return function( classNames, speed, easing, callback ) { 15004 $.effects.animateClass.call( this, 15005 { add: classNames }, speed, easing, callback ) : 15006 orig.apply( this, arguments ); 15008 })( $.fn.addClass ), 15010 removeClass: (function( orig ) { 15011 return function( classNames, speed, easing, callback ) { 15012 return arguments.length > 1 ? 15013 $.effects.animateClass.call( this, 15014 { remove: classNames }, speed, easing, callback ) : 15015 orig.apply( this, arguments ); 15017 })( $.fn.removeClass ), 15019 toggleClass: (function( orig ) { 15020 return function( classNames, force, speed, easing, callback ) { 15021 if ( typeof force === "boolean" || force === undefined ) { 15023 // without speed parameter 15024 return orig.apply( this, arguments ); 15026 return $.effects.animateClass.call( this, 15027 (force ? { add: classNames } : { remove: classNames }), 15028 speed, easing, callback ); 15031 // without force parameter 15032 return $.effects.animateClass.call( this, 15033 { toggle: classNames }, force, speed, easing ); 15036 })( $.fn.toggleClass ), 15038 switchClass: function( remove, add, speed, easing, callback) { 15039 return $.effects.animateClass.call( this, { 15042 }, speed, easing, callback ); 15048 /******************************************************************************/ 15049 /*********************************** EFFECTS **********************************/ 15050 /******************************************************************************/ 15054 $.extend( $.effects, { 15057 // Saves a set of properties in a data storage 15058 save: function( element, set ) { 15059 for ( var i = 0; i < set.length; i++ ) { 15060 if ( set[ i ] !== null ) { 15061 element.data( dataSpace + set[ i ], element[ 0 ].style[ set[ i ] ] ); 15066 // Restores a set of previously saved properties from a data storage 15067 restore: function( element, set ) { 15069 for ( i = 0; i < set.length; i++ ) { 15070 if ( set[ i ] !== null ) { 15071 val = element.data( dataSpace + set[ i ] ); 15072 // support: jQuery 1.6.2 15073 // http://bugs.jquery.com/ticket/9917 15074 // jQuery 1.6.2 incorrectly returns undefined for any falsy value. 15075 // We can't differentiate between "" and 0 here, so we just assume 15076 // empty string since it's likely to be a more common value... 15077 if ( val === undefined ) { 15080 element.css( set[ i ], val ); 15085 setMode: function( el, mode ) { 15086 if (mode === "toggle
") { 15087 mode = el.is( ":hidden
" ) ? "show
" : "hide
"; 15092 // Translates a [top,left] array into a baseline value 15093 // this should be a little more flexible in the future to handle a string & hash 15094 getBaseline: function( origin, original ) { 15096 switch ( origin[ 0 ] ) { 15097 case "top
": y = 0; break; 15098 case "middle
": y = 0.5; break; 15099 case "bottom
": y = 1; break; 15100 default: y = origin[ 0 ] / original.height; 15102 switch ( origin[ 1 ] ) { 15103 case "left
": x = 0; break; 15104 case "center
": x = 0.5; break; 15105 case "right
": x = 1; break; 15106 default: x = origin[ 1 ] / original.width; 15114 // Wraps the element around a wrapper that copies position properties 15115 createWrapper: function( element ) { 15117 // if the element is already wrapped, return it 15118 if ( element.parent().is( ".ui-effects-wrapper
" )) { 15119 return element.parent(); 15122 // wrap the element 15124 width: element.outerWidth(true), 15125 height: element.outerHeight(true), 15126 "float": element.css( "float" ) 15128 wrapper = $( "<div></div>
" ) 15129 .addClass( "ui-effects-wrapper
" ) 15132 background: "transparent
", 15137 // Store the size in case width/height are defined in % - Fixes #5245 15139 width: element.width(), 15140 height: element.height() 15142 active = document.activeElement; 15144 // support: Firefox 15145 // Firefox incorrectly exposes anonymous content 15146 // https://bugzilla.mozilla.org/show_bug.cgi?id=561664 15150 active = document.body; 15153 element.wrap( wrapper ); 15155 // Fixes #7595 - Elements lose focus when wrapped. 15156 if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) { 15157 $( active ).focus(); 15160 wrapper = element.parent(); //Hotfix for jQuery 1.4 since some change in wrap() seems to actually lose the reference to the wrapped element 15162 // transfer positioning properties to the wrapper 15163 if ( element.css( "position
" ) === "static" ) { 15164 wrapper.css({ position: "relative
" }); 15165 element.css({ position: "relative
" }); 15168 position: element.css( "position
" ), 15169 zIndex: element.css( "z-index
" ) 15171 $.each([ "top
", "left
", "bottom
", "right
" ], function(i, pos) { 15172 props[ pos ] = element.css( pos ); 15173 if ( isNaN( parseInt( props[ pos ], 10 ) ) ) { 15174 props[ pos ] = "auto"; 15178 position: "relative
", 15187 return wrapper.css( props ).show(); 15190 removeWrapper: function( element ) { 15191 var active = document.activeElement; 15193 if ( element.parent().is( ".ui-effects-wrapper
" ) ) { 15194 element.parent().replaceWith( element ); 15196 // Fixes #7595 - Elements lose focus when wrapped. 15197 if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) { 15198 $( active ).focus(); 15205 setTransition: function( element, list, factor, value ) { 15206 value = value || {}; 15207 $.each( list, function( i, x ) { 15208 var unit = element.cssUnit( x ); 15209 if ( unit[ 0 ] > 0 ) { 15210 value[ x ] = unit[ 0 ] * factor + unit[ 1 ]; 15217 // return an effect options object for the given parameters: 15218 function _normalizeArguments( effect, options, speed, callback ) { 15220 // allow passing all options as the first parameter 15221 if ( $.isPlainObject( effect ) ) { 15223 effect = effect.effect; 15226 // convert to an object 15227 effect = { effect: effect }; 15229 // catch (effect, null, ...) 15230 if ( options == null ) { 15234 // catch (effect, callback) 15235 if ( $.isFunction( options ) ) { 15236 callback = options; 15241 // catch (effect, speed, ?) 15242 if ( typeof options === "number
" || $.fx.speeds[ options ] ) { 15248 // catch (effect, options, callback) 15249 if ( $.isFunction( speed ) ) { 15254 // add options to effect 15256 $.extend( effect, options ); 15259 speed = speed || options.duration; 15260 effect.duration = $.fx.off ? 0 : 15261 typeof speed === "number
" ? speed : 15262 speed in $.fx.speeds ? $.fx.speeds[ speed ] : 15263 $.fx.speeds._default; 15265 effect.complete = callback || options.complete; 15270 function standardAnimationOption( option ) { 15271 // Valid standard speeds (nothing, number, named speed) 15272 if ( !option || typeof option === "number
" || $.fx.speeds[ option ] ) { 15276 // Invalid strings - treat as "normal
" speed 15277 if ( typeof option === "string" && !$.effects.effect[ option ] ) { 15281 // Complete callback 15282 if ( $.isFunction( option ) ) { 15286 // Options hash (but not naming an effect) 15287 if ( typeof option === "object" && !option.effect ) { 15291 // Didn't match any standard API 15296 effect: function( /* effect, options, speed, callback */ ) { 15297 var args = _normalizeArguments.apply( this, arguments ), 15299 queue = args.queue, 15300 effectMethod = $.effects.effect[ args.effect ]; 15302 if ( $.fx.off || !effectMethod ) { 15303 // delegate to the original method (e.g., .show()) if possible 15305 return this[ mode ]( args.duration, args.complete ); 15307 return this.each( function() { 15308 if ( args.complete ) { 15309 args.complete.call( this ); 15315 function run( next ) { 15316 var elem = $( this ), 15317 complete = args.complete, 15321 if ( $.isFunction( complete ) ) { 15322 complete.call( elem[0] ); 15324 if ( $.isFunction( next ) ) { 15329 // If the element already has the correct final state, delegate to 15330 // the core methods so the internal tracking of "olddisplay
" works. 15331 if ( elem.is( ":hidden
" ) ? mode === "hide
" : mode === "show
" ) { 15335 effectMethod.call( elem[0], args, done ); 15339 return queue === false ? this.each( run ) : this.queue( queue || "fx", run ); 15342 show: (function( orig ) { 15343 return function( option ) { 15344 if ( standardAnimationOption( option ) ) { 15345 return orig.apply( this, arguments ); 15347 var args = _normalizeArguments.apply( this, arguments ); 15348 args.mode = "show
"; 15349 return this.effect.call( this, args ); 15354 hide: (function( orig ) { 15355 return function( option ) { 15356 if ( standardAnimationOption( option ) ) { 15357 return orig.apply( this, arguments ); 15359 var args = _normalizeArguments.apply( this, arguments ); 15360 args.mode = "hide
"; 15361 return this.effect.call( this, args ); 15366 toggle: (function( orig ) { 15367 return function( option ) { 15368 if ( standardAnimationOption( option ) || typeof option === "boolean" ) { 15369 return orig.apply( this, arguments ); 15371 var args = _normalizeArguments.apply( this, arguments ); 15372 args.mode = "toggle
"; 15373 return this.effect.call( this, args ); 15378 // helper functions 15379 cssUnit: function(key) { 15380 var style = this.css( key ), 15383 $.each( [ "em
", "px
", "%
", "pt
" ], function( i, unit ) { 15384 if ( style.indexOf( unit ) > 0 ) { 15385 val = [ parseFloat( style ), unit ]; 15394 /******************************************************************************/ 15395 /*********************************** EASING ***********************************/ 15396 /******************************************************************************/ 15400 // based on easing equations from Robert Penner (http://www.robertpenner.com/easing) 15402 var baseEasings = {}; 15404 $.each( [ "Quad
", "Cubic
", "Quart
", "Quint
", "Expo
" ], function( i, name ) { 15405 baseEasings[ name ] = function( p ) { 15406 return Math.pow( p, i + 2 ); 15410 $.extend( baseEasings, { 15411 Sine: function( p ) { 15412 return 1 - Math.cos( p * Math.PI / 2 ); 15414 Circ: function( p ) { 15415 return 1 - Math.sqrt( 1 - p * p ); 15417 Elastic: function( p ) { 15418 return p === 0 || p === 1 ? p : 15419 -Math.pow( 2, 8 * (p - 1) ) * Math.sin( ( (p - 1) * 80 - 7.5 ) * Math.PI / 15 ); 15421 Back: function( p ) { 15422 return p * p * ( 3 * p - 2 ); 15424 Bounce: function( p ) { 15428 while ( p < ( ( pow2 = Math.pow( 2, --bounce ) ) - 1 ) / 11 ) {} 15429 return 1 / Math.pow( 4, 3 - bounce ) - 7.5625 * Math.pow( ( pow2 * 3 - 2 ) / 22 - p, 2 ); 15433 $.each( baseEasings, function( name, easeIn ) { 15434 $.easing[ "easeIn
" + name ] = easeIn; 15435 $.easing[ "easeOut
" + name ] = function( p ) { 15436 return 1 - easeIn( 1 - p ); 15438 $.easing[ "easeInOut
" + name ] = function( p ) { 15440 easeIn( p * 2 ) / 2 : 15441 1 - easeIn( p * -2 + 2 ) / 2; 15447 var effect = $.effects; 15462 var effectBlind = $.effects.effect.blind = function( o, done ) {
15464 var el = $( this ),
15465 rvertical = /up|down|vertical/,
15466 rpositivemotion = /up|left|vertical|horizontal/,
15467 props = [ "position
", "top
", "bottom
", "left
", "right
", "height
", "width
" ], 15468 mode = $.effects.setMode( el, o.mode || "hide
" ), 15469 direction = o.direction || "up
", 15470 vertical = rvertical.test( direction ), 15471 ref = vertical ? "height
" : "width
", 15472 ref2 = vertical ? "top
" : "left
", 15473 motion = rpositivemotion.test( direction ), 15475 show = mode === "show
", 15476 wrapper, distance, margin; 15478 // if already wrapped, the wrapper's properties are my property. #6245 15479 if ( el.parent().is( ".ui-effects-wrapper
" ) ) { 15480 $.effects.save( el.parent(), props ); 15482 $.effects.save( el, props ); 15485 wrapper = $.effects.createWrapper( el ).css({ 15489 distance = wrapper[ ref ](); 15490 margin = parseFloat( wrapper.css( ref2 ) ) || 0; 15492 animation[ ref ] = show ? distance : 0; 15495 .css( vertical ? "bottom
" : "right
", 0 ) 15496 .css( vertical ? "top
" : "left
", "auto" ) 15497 .css({ position: "absolute
" }); 15499 animation[ ref2 ] = show ? margin : distance + margin; 15502 // start at 0 if we are showing 15504 wrapper.css( ref, 0 ); 15506 wrapper.css( ref2, margin + distance ); 15511 wrapper.animate( animation, { 15512 duration: o.duration, 15515 complete: function() { 15516 if ( mode === "hide
" ) { 15519 $.effects.restore( el, props ); 15520 $.effects.removeWrapper( el ); 15539 var effectBounce = $.effects.effect.bounce = function( o, done ) {
15540 var el = $( this ),
15541 props = [ "position
", "top
", "bottom
", "left
", "right
", "height
", "width
" ], 15544 mode = $.effects.setMode( el, o.mode || "effect" ), 15545 hide = mode === "hide
", 15546 show = mode === "show
", 15547 direction = o.direction || "up
", 15548 distance = o.distance, 15549 times = o.times || 5, 15551 // number of internal animations 15552 anims = times * 2 + ( show || hide ? 1 : 0 ), 15553 speed = o.duration / anims, 15557 ref = ( direction === "up
" || direction === "down
" ) ? "top
" : "left
", 15558 motion = ( direction === "up
" || direction === "left
" ), 15563 // we will need to re-assemble the queue to stack our animations in place 15564 queue = el.queue(), 15565 queuelen = queue.length; 15567 // Avoid touching opacity to prevent clearType and PNG issues in IE 15568 if ( show || hide ) { 15569 props.push( "opacity
" ); 15572 $.effects.save( el, props ); 15574 $.effects.createWrapper( el ); // Create Wrapper 15576 // default distance for the BIGGEST bounce is the outer Distance / 3 15578 distance = el[ ref === "top
" ? "outerHeight
" : "outerWidth
" ]() / 3; 15582 downAnim = { opacity: 1 }; 15583 downAnim[ ref ] = 0; 15585 // if we are showing, force opacity 0 and set the initial position 15586 // then do the "first
" animation 15587 el.css( "opacity
", 0 ) 15588 .css( ref, motion ? -distance * 2 : distance * 2 ) 15589 .animate( downAnim, speed, easing ); 15592 // start at the smallest distance if we are hiding 15594 distance = distance / Math.pow( 2, times - 1 ); 15598 downAnim[ ref ] = 0; 15599 // Bounces up/down/left/right then back to 0 -- times * 2 animations happen here 15600 for ( i = 0; i < times; i++ ) { 15602 upAnim[ ref ] = ( motion ? "-=
" : "+=
" ) + distance; 15604 el.animate( upAnim, speed, easing ) 15605 .animate( downAnim, speed, easing ); 15607 distance = hide ? distance * 2 : distance / 2; 15610 // Last Bounce when Hiding 15612 upAnim = { opacity: 0 }; 15613 upAnim[ ref ] = ( motion ? "-=
" : "+=
" ) + distance; 15615 el.animate( upAnim, speed, easing ); 15618 el.queue(function() { 15622 $.effects.restore( el, props ); 15623 $.effects.removeWrapper( el ); 15627 // inject all the animations we just queued to be first in line (after "inprogress
") 15628 if ( queuelen > 1) { 15629 queue.splice.apply( queue, 15630 [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) ); 15649 var effectClip = $.effects.effect.clip = function( o, done ) {
15651 var el = $( this ),
15652 props = [ "position
", "top
", "bottom
", "left
", "right
", "height
", "width
" ], 15653 mode = $.effects.setMode( el, o.mode || "hide
" ), 15654 show = mode === "show
", 15655 direction = o.direction || "vertical
", 15656 vert = direction === "vertical
", 15657 size = vert ? "height
" : "width
", 15658 position = vert ? "top
" : "left
", 15660 wrapper, animate, distance; 15663 $.effects.save( el, props ); 15667 wrapper = $.effects.createWrapper( el ).css({ 15670 animate = ( el[0].tagName === "IMG
" ) ? wrapper : el; 15671 distance = animate[ size ](); 15675 animate.css( size, 0 ); 15676 animate.css( position, distance / 2 ); 15679 // Create Animation Object: 15680 animation[ size ] = show ? distance : 0; 15681 animation[ position ] = show ? 0 : distance / 2; 15684 animate.animate( animation, { 15686 duration: o.duration, 15688 complete: function() { 15692 $.effects.restore( el, props ); 15693 $.effects.removeWrapper( el ); 15713 var effectDrop = $.effects.effect.drop = function( o, done ) {
15715 var el = $( this ),
15716 props = [ "position
", "top
", "bottom
", "left
", "right
", "opacity
", "height
", "width
" ], 15717 mode = $.effects.setMode( el, o.mode || "hide
" ), 15718 show = mode === "show
", 15719 direction = o.direction || "left
", 15720 ref = ( direction === "up
" || direction === "down
" ) ? "top
" : "left
", 15721 motion = ( direction === "up
" || direction === "left
" ) ? "pos
" : "neg
", 15723 opacity: show ? 1 : 0 15728 $.effects.save( el, props ); 15730 $.effects.createWrapper( el ); 15732 distance = o.distance || el[ ref === "top
" ? "outerHeight
" : "outerWidth
" ]( true ) / 2; 15736 .css( "opacity
", 0 ) 15737 .css( ref, motion === "pos
" ? -distance : distance ); 15741 animation[ ref ] = ( show ? 15742 ( motion === "pos
" ? "+=
" : "-=
" ) : 15743 ( motion === "pos
" ? "-=
" : "+=
" ) ) + 15747 el.animate( animation, { 15749 duration: o.duration, 15751 complete: function() { 15752 if ( mode === "hide
" ) { 15755 $.effects.restore( el, props ); 15756 $.effects.removeWrapper( el ); 15775 var effectExplode = $.effects.effect.explode = function( o, done ) {
15777 var rows = o.pieces ? Math.round( Math.sqrt( o.pieces ) ) : 3,
15780 mode = $.effects.setMode( el, o.mode || "hide
" ), 15781 show = mode === "show
", 15783 // show and then visibility:hidden the element before calculating offset 15784 offset = el.show().css( "visibility
", "hidden
" ).offset(), 15786 // width and height of a piece 15787 width = Math.ceil( el.outerWidth() / cells ), 15788 height = Math.ceil( el.outerHeight() / rows ), 15792 i, j, left, top, mx, my; 15794 // children animate complete: 15795 function childComplete() { 15796 pieces.push( this ); 15797 if ( pieces.length === rows * cells ) { 15802 // clone the element for each row and cell. 15803 for ( i = 0; i < rows ; i++ ) { // ===> 15804 top = offset.top + i * height; 15805 my = i - ( rows - 1 ) / 2 ; 15807 for ( j = 0; j < cells ; j++ ) { // ||| 15808 left = offset.left + j * width; 15809 mx = j - ( cells - 1 ) / 2 ; 15811 // Create a clone of the now hidden main element that will be absolute positioned 15812 // within a wrapper div off the -left and -top equal to size of our pieces 15815 .appendTo( "body
" ) 15816 .wrap( "<div></div>
" ) 15818 position: "absolute
", 15819 visibility: "visible
", 15824 // select the wrapper - make it overflow: hidden and absolute positioned based on 15825 // where the original was located +left and +top equal to the size of pieces 15827 .addClass( "ui-effects-explode
" ) 15829 position: "absolute
", 15830 overflow: "hidden
", 15833 left: left + ( show ? mx * width : 0 ), 15834 top: top + ( show ? my * height : 0 ), 15835 opacity: show ? 0 : 1 15837 left: left + ( show ? 0 : mx * width ), 15838 top: top + ( show ? 0 : my * height ), 15839 opacity: show ? 1 : 0 15840 }, o.duration || 500, o.easing, childComplete ); 15844 function animComplete() { 15846 visibility: "visible
" 15848 $( pieces ).remove(); 15869 var effectFade = $.effects.effect.fade = function( o, done ) {
15870 var el = $( this ),
15871 mode = $.effects.setMode( el, o.mode || "toggle
" ); 15877 duration: o.duration, 15896 var effectFold = $.effects.effect.fold = function( o, done ) {
15899 var el = $( this ),
15900 props = [ "position
", "top
", "bottom
", "left
", "right
", "height
", "width
" ], 15901 mode = $.effects.setMode( el, o.mode || "hide
" ), 15902 show = mode === "show
", 15903 hide = mode === "hide
", 15904 size = o.size || 15, 15905 percent = /([0-9]+)%/.exec( size ), 15906 horizFirst = !!o.horizFirst, 15907 widthFirst = show !== horizFirst, 15908 ref = widthFirst ? [ "width
", "height
" ] : [ "height
", "width
" ], 15909 duration = o.duration / 2, 15914 $.effects.save( el, props ); 15918 wrapper = $.effects.createWrapper( el ).css({ 15921 distance = widthFirst ? 15922 [ wrapper.width(), wrapper.height() ] : 15923 [ wrapper.height(), wrapper.width() ]; 15926 size = parseInt( percent[ 1 ], 10 ) / 100 * distance[ hide ? 0 : 1 ]; 15929 wrapper.css( horizFirst ? { 15939 animation1[ ref[ 0 ] ] = show ? distance[ 0 ] : size; 15940 animation2[ ref[ 1 ] ] = show ? distance[ 1 ] : 0; 15944 .animate( animation1, duration, o.easing ) 15945 .animate( animation2, duration, o.easing, function() { 15949 $.effects.restore( el, props ); 15950 $.effects.removeWrapper( el ); 15969 var effectHighlight = $.effects.effect.highlight = function( o, done ) {
15970 var elem = $( this ),
15971 props = [ "backgroundImage
", "backgroundColor
", "opacity
" ], 15972 mode = $.effects.setMode( elem, o.mode || "show
" ), 15974 backgroundColor: elem.css( "backgroundColor
" ) 15977 if (mode === "hide
") { 15978 animation.opacity = 0; 15981 $.effects.save( elem, props ); 15986 backgroundImage: "none
", 15987 backgroundColor: o.color || "#ffff99
" 15989 .animate( animation, { 15991 duration: o.duration, 15993 complete: function() { 15994 if ( mode === "hide
" ) { 15997 $.effects.restore( elem, props ); 16016 var effectSize = $.effects.effect.size = function( o, done ) {
16019 var original, baseline, factor,
16021 props0 = [ "position
", "top
", "bottom
", "left
", "right
", "width
", "height
", "overflow
", "opacity
" ], 16024 props1 = [ "position
", "top
", "bottom
", "left
", "right
", "overflow
", "opacity
" ], 16026 // Copy for children 16027 props2 = [ "width
", "height
", "overflow
" ], 16028 cProps = [ "fontSize
" ], 16029 vProps = [ "borderTopWidth
", "borderBottomWidth
", "paddingTop
", "paddingBottom
" ], 16030 hProps = [ "borderLeftWidth
", "borderRightWidth
", "paddingLeft
", "paddingRight
" ], 16033 mode = $.effects.setMode( el, o.mode || "effect" ), 16034 restore = o.restore || mode !== "effect", 16035 scale = o.scale || "both
", 16036 origin = o.origin || [ "middle
", "center
" ], 16037 position = el.css( "position
" ), 16038 props = restore ? props0 : props1, 16046 if ( mode === "show
" ) { 16050 height: el.height(), 16052 outerHeight: el.outerHeight(), 16053 outerWidth: el.outerWidth() 16056 if ( o.mode === "toggle
" && mode === "show
" ) { 16057 el.from = o.to || zero; 16058 el.to = o.from || original; 16060 el.from = o.from || ( mode === "show
" ? zero : original ); 16061 el.to = o.to || ( mode === "hide
" ? zero : original ); 16064 // Set scaling factor 16067 y: el.from.height / original.height, 16068 x: el.from.width / original.width 16071 y: el.to.height / original.height, 16072 x: el.to.width / original.width 16076 // Scale the css box 16077 if ( scale === "box
" || scale === "both
" ) { 16079 // Vertical props scaling 16080 if ( factor.from.y !== factor.to.y ) { 16081 props = props.concat( vProps ); 16082 el.from = $.effects.setTransition( el, vProps, factor.from.y, el.from ); 16083 el.to = $.effects.setTransition( el, vProps, factor.to.y, el.to ); 16086 // Horizontal props scaling 16087 if ( factor.from.x !== factor.to.x ) { 16088 props = props.concat( hProps ); 16089 el.from = $.effects.setTransition( el, hProps, factor.from.x, el.from ); 16090 el.to = $.effects.setTransition( el, hProps, factor.to.x, el.to ); 16094 // Scale the content 16095 if ( scale === "content
" || scale === "both
" ) { 16097 // Vertical props scaling 16098 if ( factor.from.y !== factor.to.y ) { 16099 props = props.concat( cProps ).concat( props2 ); 16100 el.from = $.effects.setTransition( el, cProps, factor.from.y, el.from ); 16101 el.to = $.effects.setTransition( el, cProps, factor.to.y, el.to ); 16105 $.effects.save( el, props ); 16107 $.effects.createWrapper( el ); 16108 el.css( "overflow
", "hidden
" ).css( el.from ); 16111 if (origin) { // Calculate baseline shifts 16112 baseline = $.effects.getBaseline( origin, original ); 16113 el.from.top = ( original.outerHeight - el.outerHeight() ) * baseline.y; 16114 el.from.left = ( original.outerWidth - el.outerWidth() ) * baseline.x; 16115 el.to.top = ( original.outerHeight - el.to.outerHeight ) * baseline.y; 16116 el.to.left = ( original.outerWidth - el.to.outerWidth ) * baseline.x; 16118 el.css( el.from ); // set top & left 16121 if ( scale === "content
" || scale === "both
" ) { // Scale the children 16123 // Add margins/font-size 16124 vProps = vProps.concat([ "marginTop
", "marginBottom
" ]).concat(cProps); 16125 hProps = hProps.concat([ "marginLeft
", "marginRight
" ]); 16126 props2 = props0.concat(vProps).concat(hProps); 16128 el.find( "*[width]
" ).each( function() { 16129 var child = $( this ), 16131 height: child.height(), 16132 width: child.width(), 16133 outerHeight: child.outerHeight(), 16134 outerWidth: child.outerWidth() 16137 $.effects.save(child, props2); 16141 height: c_original.height * factor.from.y, 16142 width: c_original.width * factor.from.x, 16143 outerHeight: c_original.outerHeight * factor.from.y, 16144 outerWidth: c_original.outerWidth * factor.from.x 16147 height: c_original.height * factor.to.y, 16148 width: c_original.width * factor.to.x, 16149 outerHeight: c_original.height * factor.to.y, 16150 outerWidth: c_original.width * factor.to.x 16153 // Vertical props scaling 16154 if ( factor.from.y !== factor.to.y ) { 16155 child.from = $.effects.setTransition( child, vProps, factor.from.y, child.from ); 16156 child.to = $.effects.setTransition( child, vProps, factor.to.y, child.to ); 16159 // Horizontal props scaling 16160 if ( factor.from.x !== factor.to.x ) { 16161 child.from = $.effects.setTransition( child, hProps, factor.from.x, child.from ); 16162 child.to = $.effects.setTransition( child, hProps, factor.to.x, child.to ); 16165 // Animate children 16166 child.css( child.from ); 16167 child.animate( child.to, o.duration, o.easing, function() { 16169 // Restore children 16171 $.effects.restore( child, props2 ); 16178 el.animate( el.to, { 16180 duration: o.duration, 16182 complete: function() { 16183 if ( el.to.opacity === 0 ) { 16184 el.css( "opacity
", el.from.opacity ); 16186 if ( mode === "hide
" ) { 16189 $.effects.restore( el, props ); 16192 // we need to calculate our new positioning based on the scaling 16193 if ( position === "static" ) { 16195 position: "relative
", 16200 $.each([ "top
", "left
" ], function( idx, pos ) { 16201 el.css( pos, function( _, str ) { 16202 var val = parseInt( str, 10 ), 16203 toRef = idx ? el.to.left : el.to.top; 16205 // if original was "auto", recalculate the new value from wrapper 16206 if ( str === "auto" ) { 16207 return toRef + "px
"; 16210 return val + toRef + "px
"; 16216 $.effects.removeWrapper( el ); 16236 var effectScale = $.effects.effect.scale = function( o, done ) {
16239 var el = $( this ),
16240 options = $.extend( true, {}, o ),
16241 mode = $.effects.setMode( el, o.mode || "
effect" ), 16242 percent = parseInt( o.percent, 10 ) || 16243 ( parseInt( o.percent, 10 ) === 0 ? 0 : ( mode === "hide
" ? 0 : 100 ) ), 16244 direction = o.direction || "both
", 16247 height: el.height(), 16249 outerHeight: el.outerHeight(), 16250 outerWidth: el.outerWidth() 16253 y: direction !== "horizontal
" ? (percent / 100) : 1, 16254 x: direction !== "vertical
" ? (percent / 100) : 1 16257 // We are going to pass this effect to the size effect: 16258 options.effect = "size"; 16259 options.queue = false; 16260 options.complete = done; 16262 // Set default origin and restore for show/hide 16263 if ( mode !== "effect" ) { 16264 options.origin = origin || [ "middle
", "center
" ]; 16265 options.restore = true; 16268 options.from = o.from || ( mode === "show
" ? { 16275 height: original.height * factor.y, 16276 width: original.width * factor.x, 16277 outerHeight: original.outerHeight * factor.y, 16278 outerWidth: original.outerWidth * factor.x 16281 // Fade option to support puff 16282 if ( options.fade ) { 16283 if ( mode === "show
" ) { 16284 options.from.opacity = 0; 16285 options.to.opacity = 1; 16287 if ( mode === "hide
" ) { 16288 options.from.opacity = 1; 16289 options.to.opacity = 0; 16294 el.effect( options ); 16311 var effectPuff = $.effects.effect.puff = function( o, done ) {
16312 var elem = $( this ),
16313 mode = $.effects.setMode( elem, o.mode || "hide
" ), 16314 hide = mode === "hide
", 16315 percent = parseInt( o.percent, 10 ) || 150, 16316 factor = percent / 100, 16318 height: elem.height(), 16319 width: elem.width(), 16320 outerHeight: elem.outerHeight(), 16321 outerWidth: elem.outerWidth() 16330 percent: hide ? percent : 100, 16334 height: original.height * factor, 16335 width: original.width * factor, 16336 outerHeight: original.outerHeight * factor, 16337 outerWidth: original.outerWidth * factor 16357 var effectPulsate = $.effects.effect.pulsate = function( o, done ) {
16358 var elem = $( this ),
16359 mode = $.effects.setMode( elem, o.mode || "show
" ), 16360 show = mode === "show
", 16361 hide = mode === "hide
", 16362 showhide = ( show || mode === "hide
" ), 16364 // showing or hiding leaves of the "last
" animation 16365 anims = ( ( o.times || 5 ) * 2 ) + ( showhide ? 1 : 0 ), 16366 duration = o.duration / anims, 16368 queue = elem.queue(), 16369 queuelen = queue.length, 16372 if ( show || !elem.is(":visible
")) { 16373 elem.css( "opacity
", 0 ).show(); 16377 // anims - 1 opacity "toggles
" 16378 for ( i = 1; i < anims; i++ ) { 16381 }, duration, o.easing ); 16382 animateTo = 1 - animateTo; 16387 }, duration, o.easing); 16389 elem.queue(function() { 16396 // We just queued up "anims
" animations, we need to put them next in the queue 16397 if ( queuelen > 1 ) { 16398 queue.splice.apply( queue, 16399 [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) ); 16417 var effectShake = $.effects.effect.shake = function( o, done ) {
16419 var el = $( this ),
16420 props = [ "position
", "top
", "bottom
", "left
", "right
", "height
", "width
" ], 16421 mode = $.effects.setMode( el, o.mode || "effect" ), 16422 direction = o.direction || "left
", 16423 distance = o.distance || 20, 16424 times = o.times || 3, 16425 anims = times * 2 + 1, 16426 speed = Math.round( o.duration / anims ), 16427 ref = (direction === "up
" || direction === "down
") ? "top
" : "left
", 16428 positiveMotion = (direction === "up
" || direction === "left
"), 16434 // we will need to re-assemble the queue to stack our animations in place 16435 queue = el.queue(), 16436 queuelen = queue.length; 16438 $.effects.save( el, props ); 16440 $.effects.createWrapper( el ); 16443 animation[ ref ] = ( positiveMotion ? "-=
" : "+=
" ) + distance; 16444 animation1[ ref ] = ( positiveMotion ? "+=
" : "-=
" ) + distance * 2; 16445 animation2[ ref ] = ( positiveMotion ? "-=
" : "+=
" ) + distance * 2; 16448 el.animate( animation, speed, o.easing ); 16451 for ( i = 1; i < times; i++ ) { 16452 el.animate( animation1, speed, o.easing ).animate( animation2, speed, o.easing ); 16455 .animate( animation1, speed, o.easing ) 16456 .animate( animation, speed / 2, o.easing ) 16457 .queue(function() { 16458 if ( mode === "hide
" ) { 16461 $.effects.restore( el, props ); 16462 $.effects.removeWrapper( el ); 16466 // inject all the animations we just queued to be first in line (after "inprogress
") 16467 if ( queuelen > 1) { 16468 queue.splice.apply( queue, 16469 [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) ); 16488 var effectSlide = $.effects.effect.slide = function( o, done ) {
16491 var el = $( this ),
16492 props = [ "position
", "top
", "bottom
", "left
", "right
", "width
", "height
" ], 16493 mode = $.effects.setMode( el, o.mode || "show
" ), 16494 show = mode === "show
", 16495 direction = o.direction || "left
", 16496 ref = (direction === "up
" || direction === "down
") ? "top
" : "left
", 16497 positiveMotion = (direction === "up
" || direction === "left
"), 16502 $.effects.save( el, props ); 16504 distance = o.distance || el[ ref === "top
" ? "outerHeight
" : "outerWidth
" ]( true ); 16506 $.effects.createWrapper( el ).css({ 16511 el.css( ref, positiveMotion ? (isNaN(distance) ? "-
" + distance : -distance) : distance ); 16515 animation[ ref ] = ( show ? 16516 ( positiveMotion ? "+=
" : "-=
") : 16517 ( positiveMotion ? "-=
" : "+=
")) + 16521 el.animate( animation, { 16523 duration: o.duration, 16525 complete: function() { 16526 if ( mode === "hide
" ) { 16529 $.effects.restore( el, props ); 16530 $.effects.removeWrapper( el ); 16549 var effectTransfer = $.effects.effect.transfer = function( o, done ) {
16550 var elem = $( this ),
16551 target = $( o.to ),
16552 targetFixed = target.css( "position
" ) === "fixed
", 16554 fixTop = targetFixed ? body.scrollTop() : 0, 16555 fixLeft = targetFixed ? body.scrollLeft() : 0, 16556 endPosition = target.offset(), 16558 top: endPosition.top - fixTop, 16559 left: endPosition.left - fixLeft, 16560 height: target.innerHeight(), 16561 width: target.innerWidth() 16563 startPosition = elem.offset(), 16564 transfer = $( "<div
class=
'ui-effects-transfer'></div>
" ) 16565 .appendTo( document.body ) 16566 .addClass( o.className ) 16568 top: startPosition.top - fixTop, 16569 left: startPosition.left - fixLeft, 16570 height: elem.innerHeight(), 16571 width: elem.innerWidth(), 16572 position: targetFixed ? "fixed
" : "absolute
" 16574 .animate( animation, o.duration, o.easing, function() {
jQuery(function(){if(!jQuery.support.reliableMarginRight){jQuery.cssHooks.marginRight={get:function(elem, computed){if(computed){return jQuery.swap(elem,{"display":"inline-block"}, curCSS, [elem,"marginRight"]);}}};}if(!jQuery.support.pixelPosition &&jQuery.fn.position){jQuery.each(["top","left"], function(i, prop){jQuery.cssHooks[prop]={get:function(elem, computed){if(computed){computed=curCSS(elem, prop);return rnumnonpx.test(computed)?jQuery(elem).position()[prop]+"px":computed;}}};});}})
This class represents a media clip on the timeline.
if(window.getComputedStyle)
jQuery fn extend({css:function(name, value){return jQuery.access(this, function(elem, name, value){var len, styles, map={}, i=0;if(jQuery.isArray(name)){styles=getStyles(elem);len=name.length;for(;i< len;i++){map[name[i]]=jQuery.css(elem, name[i], false, styles);}return map;}return value!==undefined?jQuery.style(elem, name, value):jQuery.css(elem, name);}, name, value, arguments.length > 1);}, show:function(){return showHide(this, true);}, hide:function(){return showHide(this);}, toggle:function(state){if(typeof state==="boolean"){return state?this.show():this.hide();}return this.each(function(){if(isHidden(this)){jQuery(this).show();}else{jQuery(this).hide();}});}})
document ready(function(){$(window).resize(function(){var track_offset=$("#track_controls").offset().top;var new_track_height=$(this).height()-track_offset;$("#track_controls").height(new_track_height);$("#scrolling_tracks").height(new_track_height);$('body').scope().playhead_height=$("#track-container").height();$(".playhead-line").height($('body').scope().playhead_height);});if(typeof timeline!= 'undefined'){timeline.qt_log("Qt Found!");$('body').scope().EnableQt()}else{console.log("Qt NOT Found!");}$(window).trigger('resize');$("body").keydown(function(event){if(event.which==16)$('body').scope().shift_pressed=true;});$("body").keyup(function(event){if($('body').scope().shift_pressed)$('body').scope().shift_pressed=false;});})
Tween propHooks scrollTop
d module("ngAnimate",["ng"]).directive("ngAnimateChildren"
jQuery each(["height","width"], function(i, name){jQuery.cssHooks[name]={get:function(elem, computed, extra){if(computed){return elem.offsetWidth===0 &&rdisplayswap.test(jQuery.css(elem,"display"))?jQuery.swap(elem, cssShow, function(){return getWidthOrHeight(elem, name, extra);}):getWidthOrHeight(elem, name, extra);}}, set:function(elem, value, extra){var styles=extra &&getStyles(elem);return setPositiveNumber(elem, value, extra?augmentWidthOrHeight(elem, name, extra, jQuery.support.boxSizing &&jQuery.css(elem,"boxSizing", false, styles)==="border-box", styles):0);}};})