vendor: 8,235 bytes, lines 1-329
1/*! jQuery UI - v1.11.0 - 2014-07-22 2* http://jqueryui.com 3* Includes: core.js, widget.js, mouse.js, position.js, datepicker.js 4* Copyright 2014 jQuery Foundation and other contributors; Licensed MIT */ 5 6(function( factory ) { 7 if ( typeof define === "function" && define.amd ) { 8 9 // AMD. Register as an anonymous module. 10 define([ "jquery" ], factory ); 11 } else { 12 13 // Browser globals 14 factory( jQuery ); 15 } 16}(function( $ ) { 17/*! 18 * jQuery UI Core 1.11.0 19 * http://jqueryui.com 20 * 21 * Copyright 2014 jQuery Foundation and other contributors 22 * Released under the MIT license. 23 * http://jquery.org/license 24 * 25 * http://api.jqueryui.com/category/ui-core/ 26 */ 27 28 29// $.ui might exist from components with no dependencies, e.g., $.ui.position 30$.ui = $.ui || {}; 31 32$.extend( $.ui, { 33 version: "1.11.0", 34 35 keyCode: { 36 BACKSPACE: 8, 37 COMMA: 188, 38 DELETE: 46, 39 DOWN: 40, 40 END: 35, 41 ENTER: 13, 42 ESCAPE: 27, 43 HOME: 36, 44 LEFT: 37, 45 PAGE_DOWN: 34, 46 PAGE_UP: 33, 47 PERIOD: 190, 48 RIGHT: 39, 49 SPACE: 32, 50 TAB: 9, 51 UP: 38 52 } 53}); 54 55// plugins 56$.fn.extend({ 57 scrollParent: function() { 58 var position = this.css( "position" ), 59 excludeStaticParent = position === "absolute", 60 scrollParent = this.parents().filter( function() { 61 var parent = $( this ); 62 if ( excludeStaticParent && parent.css( "position" ) === "static" ) { 63 return false; 64 } 65 return (/(auto|scroll)/).test( parent.css( "overflow" ) + parent.css( "overflow-y" ) + parent.css( "overflow-x" ) ); 66 }).eq( 0 ); 67 68 return position === "fixed" || !scrollParent.length ? $( this[ 0 ].ownerDocument || document ) : scrollParent; 69 }, 70 71 uniqueId: (function() { 72 var uuid = 0; 73 74 return function() { 75 return this.each(function() { 76 if ( !this.id ) { 77 this.id = "ui-id-" + ( ++uuid ); 78 } 79 }); 80 }; 81 })(), 82 83 removeUniqueId: function() { 84 return this.each(function() { 85 if ( /^ui-id-\d+$/.test( this.id ) ) { 86 $( this ).removeAttr( "id" ); 87 } 88 }); 89 } 90}); 91 92// selectors 93function focusable( element, isTabIndexNotNaN ) { 94 var map, mapName, img, 95 nodeName = element.nodeName.toLowerCase(); 96 if ( "area" === nodeName ) { 97 map = element.parentNode; 98 mapName = map.name; 99 if ( !element.href || !mapName || map.nodeName.toLowerCase() !== "map" ) { 100 return false; 101 } 102 img = $( "img[usemap=#" + mapName + "]" )[0]; 103 return !!img && visible( img ); 104 } 105 return ( /input|select|textarea|button|object/.test( nodeName ) ? 106 !element.disabled : 107 "a" === nodeName ? 108 element.href || isTabIndexNotNaN : 109 isTabIndexNotNaN) && 110 // the element and all of its ancestors must be visible 111 visible( element ); 112} 113 114function visible( element ) { 115 return $.expr.filters.visible( element ) && 116 !$( element ).parents().addBack().filter(function() { 117 return $.css( this, "visibility" ) === "hidden"; 118 }).length; 119} 120 121$.extend( $.expr[ ":" ], { 122 data: $.expr.createPseudo ? 123 $.expr.createPseudo(function( dataName ) { 124 return function( elem ) { 125 return !!$.data( elem, dataName ); 126 }; 127 }) : 128 // support: jQuery <1.8 129 function( elem, i, match ) { 130 return !!$.data( elem, match[ 3 ] ); 131 }, 132 133 focusable: function( element ) { 134 return focusable( element, !isNaN( $.attr( element, "tabindex" ) ) ); 135 }, 136 137 tabbable: function( element ) { 138 var tabIndex = $.attr( element, "tabindex" ), 139 isTabIndexNaN = isNaN( tabIndex ); 140 return ( isTabIndexNaN || tabIndex >= 0 ) && focusable( element, !isTabIndexNaN ); 141 } 142}); 143 144// support: jQuery <1.8 145if ( !$( "<a>" ).outerWidth( 1 ).jquery ) { 146 $.each( [ "Width", "Height" ], function( i, name ) { 147 var side = name === "Width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ], 148 type = name.toLowerCase(), 149 orig = { 150 innerWidth: $.fn.innerWidth, 151 innerHeight: $.fn.innerHeight, 152 outerWidth: $.fn.outerWidth, 153 outerHeight: $.fn.outerHeight 154 }; 155 156 function reduce( elem, size, border, margin ) { 157 $.each( side, function() { 158 size -= parseFloat( $.css( elem, "padding" + this ) ) || 0; 159 if ( border ) { 160 size -= parseFloat( $.css( elem, "border" + this + "Width" ) ) || 0; 161 } 162 if ( margin ) { 163 size -= parseFloat( $.css( elem, "margin" + this ) ) || 0; 164 } 165 }); 166 return size; 167 } 168 169 $.fn[ "inner" + name ] = function( size ) { 170 if ( size === undefined ) { 171 return orig[ "inner" + name ].call( this ); 172 } 173 174 return this.each(function() { 175 $( this ).css( type, reduce( this, size ) + "px" ); 176 }); 177 }; 178 179 $.fn[ "outer" + name] = function( size, margin ) { 180 if ( typeof size !== "number" ) { 181 return orig[ "outer" + name ].call( this, size ); 182 } 183 184 return this.each(function() { 185 $( this).css( type, reduce( this, size, true, margin ) + "px" ); 186 }); 187 }; 188 }); 189} 190 191// support: jQuery <1.8 192if ( !$.fn.addBack ) { 193 $.fn.addBack = function( selector ) { 194 return this.add( selector == null ? 195 this.prevObject : this.prevObject.filter( selector ) 196 ); 197 }; 198} 199 200// support: jQuery 1.6.1, 1.6.2 (http://bugs.jquery.com/ticket/9413) 201if ( $( "<a>" ).data( "a-b", "a" ).removeData( "a-b" ).data( "a-b" ) ) { 202 $.fn.removeData = (function( removeData ) { 203 return function( key ) { 204 if ( arguments.length ) { 205 return removeData.call( this, $.camelCase( key ) ); 206 } else { 207 return removeData.call( this ); 208 } 209 }; 210 })( $.fn.removeData ); 211} 212 213// deprecated 214$.ui.ie = !!/msie [\w.]+/.exec( navigator.userAgent.toLowerCase() ); 215 216$.fn.extend({ 217 focus: (function( orig ) { 218 return function( delay, fn ) { 219 return typeof delay === "number" ? 220 this.each(function() { 221 var elem = this; 222 setTimeout(function() { 223 $( elem ).focus(); 224 if ( fn ) { 225 fn.call( elem ); 226 } 227 }, delay ); 228 }) : 229 orig.apply( this, arguments ); 230 }; 231 })( $.fn.focus ), 232 233 disableSelection: (function() { 234 var eventType = "onselectstart" in document.createElement( "div" ) ? 235 "selectstart" : 236 "mousedown"; 237 238 return function() { 239 return this.bind( eventType + ".ui-disableSelection", function( event ) { 240 event.preventDefault(); 241 }); 242 }; 243 })(), 244 245 enableSelection: function() { 246 return this.unbind( ".ui-disableSelection" ); 247 }, 248 249 zIndex: function( zIndex ) { 250 if ( zIndex !== undefined ) { 251 return this.css( "zIndex", zIndex ); 252 } 253 254 if ( this.length ) { 255 var elem = $( this[ 0 ] ), position, value; 256 while ( elem.length && elem[ 0 ] !== document ) { 257 // Ignore z-index if position is set to a value where z-index is ignored by the browser 258 // This makes behavior of this function consistent across browsers 259 // WebKit always returns auto if the element is positioned 260 position = elem.css( "position" ); 261 if ( position === "absolute" || position === "relative" || position === "fixed" ) { 262 // IE returns 0 when zIndex is not specified 263 // other browsers return a string 264 // we ignore the case of nested elements with an explicit value of 0 265 // <div style="z-index: -10;"><div style="z-index: 0;"></div></div> 266 value = parseInt( elem.css( "zIndex" ), 10 ); 267 if ( !isNaN( value ) && value !== 0 ) { 268 return value; 269 } 270 } 271 elem = elem.parent(); 272 } 273 } 274 275 return 0; 276 } 277}); 278 279// $.ui.plugin is deprecated. Use $.widget() extensions instead. 280$.ui.plugin = { 281 add: function( module, option, set ) { 282 var i, 283 proto = $.ui[ module ].prototype; 284 for ( i in set ) { 285 proto.plugins[ i ] = proto.plugins[ i ] || []; 286 proto.plugins[ i ].push( [ option, set[ i ] ] ); 287 } 288 }, 289 call: function( instance, name, args, allowDisconnected ) { 290 var i, 291 set = instance.plugins[ name ]; 292 293 if ( !set ) { 294 return; 295 } 296 297 if ( !allowDisconnected && ( !instance.element[ 0 ].parentNode || instance.element[ 0 ].parentNode.nodeType === 11 ) ) { 298 return; 299 } 300 301 for ( i = 0; i < set.length; i++ ) { 302 if ( instance.options[ set[ i ][ 0 ] ] ) { 303 set[ i ][ 1 ].apply( instance.element, args ); 304 } 305 } 306 } 307}; 308 309 310/*! 311 * jQuery UI Widget 1.11.0 312 * http://jqueryui.com 313 * 314 * Copyright 2014 jQuery Foundation and other contributors 315 * Released under the MIT license. 316 * http://jquery.org/license 317 * 318 * http://api.jqueryui.com/jQuery.widget/ 319 */ 320 321 322var widget_uuid = 0, 323 widget_slice = Array.prototype.slice; 324 325$.cleanData = (function( orig ) { 326 return function( elems ) { 327 for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) { 328 try { 329 $( elem ).triggerHandler( "remove" );
vendor: 14,778 bytes, lines 329-844
329 330 // http://bugs.jquery.com/ticket/8235 331 } catch( e ) {} 332 } 333 orig( elems ); 334 }; 335})( $.cleanData ); 336 337$.widget = function( name, base, prototype ) { 338 var fullName, existingConstructor, constructor, basePrototype, 339 // proxiedPrototype allows the provided prototype to remain unmodified 340 // so that it can be used as a mixin for multiple widgets (#8876) 341 proxiedPrototype = {}, 342 namespace = name.split( "." )[ 0 ]; 343 344 name = name.split( "." )[ 1 ]; 345 fullName = namespace + "-" + name; 346 347 if ( !prototype ) { 348 prototype = base; 349 base = $.Widget; 350 } 351 352 // create selector for plugin 353 $.expr[ ":" ][ fullName.toLowerCase() ] = function( elem ) { 354 return !!$.data( elem, fullName ); 355 }; 356 357 $[ namespace ] = $[ namespace ] || {}; 358 existingConstructor = $[ namespace ][ name ]; 359 constructor = $[ namespace ][ name ] = function( options, element ) { 360 // allow instantiation without "new" keyword 361 if ( !this._createWidget ) { 362 return new constructor( options, element ); 363 } 364 365 // allow instantiation without initializing for simple inheritance 366 // must use "new" keyword (the code above always passes args) 367 if ( arguments.length ) { 368 this._createWidget( options, element ); 369 } 370 }; 371 // extend with the existing constructor to carry over any static properties 372 $.extend( constructor, existingConstructor, { 373 version: prototype.version, 374 // copy the object used to create the prototype in case we need to 375 // redefine the widget later 376 _proto: $.extend( {}, prototype ), 377 // track widgets that inherit from this widget in case this widget is 378 // redefined after a widget inherits from it 379 _childConstructors: [] 380 }); 381 382 basePrototype = new base(); 383 // we need to make the options hash a property directly on the new instance 384 // otherwise we'll modify the options hash on the prototype that we're 385 // inheriting from 386 basePrototype.options = $.widget.extend( {}, basePrototype.options ); 387 $.each( prototype, function( prop, value ) { 388 if ( !$.isFunction( value ) ) { 389 proxiedPrototype[ prop ] = value; 390 return; 391 } 392 proxiedPrototype[ prop ] = (function() { 393 var _super = function() { 394 return base.prototype[ prop ].apply( this, arguments ); 395 }, 396 _superApply = function( args ) { 397 return base.prototype[ prop ].apply( this, args ); 398 }; 399 return function() { 400 var __super = this._super, 401 __superApply = this._superApply, 402 returnValue; 403 404 this._super = _super; 405 this._superApply = _superApply; 406 407 returnValue = value.apply( this, arguments ); 408 409 this._super = __super; 410 this._superApply = __superApply; 411 412 return returnValue; 413 }; 414 })(); 415 }); 416 constructor.prototype = $.widget.extend( basePrototype, { 417 // TODO: remove support for widgetEventPrefix 418 // always use the name + a colon as the prefix, e.g., draggable:start 419 // don't prefix for widgets that aren't DOM-based 420 widgetEventPrefix: existingConstructor ? (basePrototype.widgetEventPrefix || name) : name 421 }, proxiedPrototype, { 422 constructor: constructor, 423 namespace: namespace, 424 widgetName: name, 425 widgetFullName: fullName 426 }); 427 428 // If this widget is being redefined then we need to find all widgets that 429 // are inheriting from it and redefine all of them so that they inherit from 430 // the new version of this widget. We're essentially trying to replace one 431 // level in the prototype chain. 432 if ( existingConstructor ) { 433 $.each( existingConstructor._childConstructors, function( i, child ) { 434 var childPrototype = child.prototype; 435 436 // redefine the child widget using the same prototype that was 437 // originally used, but inherit from the new version of the base 438 $.widget( childPrototype.namespace + "." + childPrototype.widgetName, constructor, child._proto ); 439 }); 440 // remove the list of existing child constructors from the old constructor 441 // so the old child constructors can be garbage collected 442 delete existingConstructor._childConstructors; 443 } else { 444 base._childConstructors.push( constructor ); 445 } 446 447 $.widget.bridge( name, constructor ); 448 449 return constructor; 450}; 451 452$.widget.extend = function( target ) { 453 var input = widget_slice.call( arguments, 1 ), 454 inputIndex = 0, 455 inputLength = input.length, 456 key, 457 value; 458 for ( ; inputIndex < inputLength; inputIndex++ ) { 459 for ( key in input[ inputIndex ] ) { 460 value = input[ inputIndex ][ key ]; 461 if ( input[ inputIndex ].hasOwnProperty( key ) && value !== undefined ) { 462 // Clone objects 463 if ( $.isPlainObject( value ) ) { 464 target[ key ] = $.isPlainObject( target[ key ] ) ? 465 $.widget.extend( {}, target[ key ], value ) : 466 // Don't extend strings, arrays, etc. with objects 467 $.widget.extend( {}, value ); 468 // Copy everything else by reference 469 } else { 470 target[ key ] = value; 471 } 472 } 473 } 474 } 475 return target; 476}; 477 478$.widget.bridge = function( name, object ) { 479 var fullName = object.prototype.widgetFullName || name; 480 $.fn[ name ] = function( options ) { 481 var isMethodCall = typeof options === "string", 482 args = widget_slice.call( arguments, 1 ), 483 returnValue = this; 484 485 // allow multiple hashes to be passed on init 486 options = !isMethodCall && args.length ? 487 $.widget.extend.apply( null, [ options ].concat(args) ) : 488 options; 489 490 if ( isMethodCall ) { 491 this.each(function() { 492 var methodValue, 493 instance = $.data( this, fullName ); 494 if ( options === "instance" ) { 495 returnValue = instance; 496 return false; 497 } 498 if ( !instance ) { 499 return $.error( "cannot call methods on " + name + " prior to initialization; " + 500 "attempted to call method '" + options + "'" ); 501 } 502 if ( !$.isFunction( instance[options] ) || options.charAt( 0 ) === "_" ) { 503 return $.error( "no such method '" + options + "' for " + name + " widget instance" ); 504 } 505 methodValue = instance[ options ].apply( instance, args ); 506 if ( methodValue !== instance && methodValue !== undefined ) { 507 returnValue = methodValue && methodValue.jquery ? 508 returnValue.pushStack( methodValue.get() ) : 509 methodValue; 510 return false; 511 } 512 }); 513 } else { 514 this.each(function() { 515 var instance = $.data( this, fullName ); 516 if ( instance ) { 517 instance.option( options || {} ); 518 if ( instance._init ) { 519 instance._init(); 520 } 521 } else { 522 $.data( this, fullName, new object( options, this ) ); 523 } 524 }); 525 } 526 527 return returnValue; 528 }; 529}; 530 531$.Widget = function( /* options, element */ ) {}; 532$.Widget._childConstructors = []; 533 534$.Widget.prototype = { 535 widgetName: "widget", 536 widgetEventPrefix: "", 537 defaultElement: "<div>", 538 options: { 539 disabled: false, 540 541 // callbacks 542 create: null 543 }, 544 _createWidget: function( options, element ) { 545 element = $( element || this.defaultElement || this )[ 0 ]; 546 this.element = $( element ); 547 this.uuid = widget_uuid++; 548 this.eventNamespace = "." + this.widgetName + this.uuid; 549 this.options = $.widget.extend( {}, 550 this.options, 551 this._getCreateOptions(), 552 options ); 553 554 this.bindings = $(); 555 this.hoverable = $(); 556 this.focusable = $(); 557 558 if ( element !== this ) { 559 $.data( element, this.widgetFullName, this ); 560 this._on( true, this.element, { 561 remove: function( event ) { 562 if ( event.target === element ) { 563 this.destroy(); 564 } 565 } 566 }); 567 this.document = $( element.style ? 568 // element within the document 569 element.ownerDocument : 570 // element is window or document 571 element.document || element ); 572 this.window = $( this.document[0].defaultView || this.document[0].parentWindow ); 573 } 574 575 this._create(); 576 this._trigger( "create", null, this._getCreateEventData() ); 577 this._init(); 578 }, 579 _getCreateOptions: $.noop, 580 _getCreateEventData: $.noop, 581 _create: $.noop, 582 _init: $.noop, 583 584 destroy: function() { 585 this._destroy(); 586 // we can probably remove the unbind calls in 2.0 587 // all event bindings should go through this._on() 588 this.element 589 .unbind( this.eventNamespace ) 590 .removeData( this.widgetFullName ) 591 // support: jquery <1.6.3 592 // http://bugs.jquery.com/ticket/9413 593 .removeData( $.camelCase( this.widgetFullName ) ); 594 this.widget() 595 .unbind( this.eventNamespace ) 596 .removeAttr( "aria-disabled" ) 597 .removeClass( 598 this.widgetFullName + "-disabled " + 599 "ui-state-disabled" ); 600 601 // clean up events and states 602 this.bindings.unbind( this.eventNamespace ); 603 this.hoverable.removeClass( "ui-state-hover" ); 604 this.focusable.removeClass( "ui-state-focus" ); 605 }, 606 _destroy: $.noop, 607 608 widget: function() { 609 return this.element; 610 }, 611 612 option: function( key, value ) { 613 var options = key, 614 parts, 615 curOption, 616 i; 617 618 if ( arguments.length === 0 ) { 619 // don't return a reference to the internal hash 620 return $.widget.extend( {}, this.options ); 621 } 622 623 if ( typeof key === "string" ) { 624 // handle nested keys, e.g., "foo.bar" => { foo: { bar: ___ } } 625 options = {}; 626 parts = key.split( "." ); 627 key = parts.shift(); 628 if ( parts.length ) { 629 curOption = options[ key ] = $.widget.extend( {}, this.options[ key ] ); 630 for ( i = 0; i < parts.length - 1; i++ ) { 631 curOption[ parts[ i ] ] = curOption[ parts[ i ] ] || {}; 632 curOption = curOption[ parts[ i ] ]; 633 } 634 key = parts.pop(); 635 if ( arguments.length === 1 ) { 636 return curOption[ key ] === undefined ? null : curOption[ key ]; 637 } 638 curOption[ key ] = value; 639 } else { 640 if ( arguments.length === 1 ) { 641 return this.options[ key ] === undefined ? null : this.options[ key ]; 642 } 643 options[ key ] = value; 644 } 645 } 646 647 this._setOptions( options ); 648 649 return this; 650 }, 651 _setOptions: function( options ) { 652 var key; 653 654 for ( key in options ) { 655 this._setOption( key, options[ key ] ); 656 } 657 658 return this; 659 }, 660 _setOption: function( key, value ) { 661 this.options[ key ] = value; 662 663 if ( key === "disabled" ) { 664 this.widget() 665 .toggleClass( this.widgetFullName + "-disabled", !!value ); 666 667 // If the widget is becoming disabled, then nothing is interactive 668 if ( value ) { 669 this.hoverable.removeClass( "ui-state-hover" ); 670 this.focusable.removeClass( "ui-state-focus" ); 671 } 672 } 673 674 return this; 675 }, 676 677 enable: function() { 678 return this._setOptions({ disabled: false }); 679 }, 680 disable: function() { 681 return this._setOptions({ disabled: true }); 682 }, 683 684 _on: function( suppressDisabledCheck, element, handlers ) { 685 var delegateElement, 686 instance = this; 687 688 // no suppressDisabledCheck flag, shuffle arguments 689 if ( typeof suppressDisabledCheck !== "boolean" ) { 690 handlers = element; 691 element = suppressDisabledCheck; 692 suppressDisabledCheck = false; 693 } 694 695 // no element argument, shuffle and use this.element 696 if ( !handlers ) { 697 handlers = element; 698 element = this.element; 699 delegateElement = this.widget(); 700 } else { 701 element = delegateElement = $( element ); 702 this.bindings = this.bindings.add( element ); 703 } 704 705 $.each( handlers, function( event, handler ) { 706 function handlerProxy() { 707 // allow widgets to customize the disabled handling 708 // - disabled as an array instead of boolean 709 // - disabled class as method for disabling individual parts 710 if ( !suppressDisabledCheck && 711 ( instance.options.disabled === true || 712 $( this ).hasClass( "ui-state-disabled" ) ) ) { 713 return; 714 } 715 return ( typeof handler === "string" ? instance[ handler ] : handler ) 716 .apply( instance, arguments ); 717 } 718 719 // copy the guid so direct unbinding works 720 if ( typeof handler !== "string" ) { 721 handlerProxy.guid = handler.guid = 722 handler.guid || handlerProxy.guid || $.guid++; 723 } 724 725 var match = event.match( /^([\w:-]*)\s*(.*)$/ ), 726 eventName = match[1] + instance.eventNamespace, 727 selector = match[2]; 728 if ( selector ) { 729 delegateElement.delegate( selector, eventName, handlerProxy ); 730 } else { 731 element.bind( eventName, handlerProxy ); 732 } 733 }); 734 }, 735 736 _off: function( element, eventName ) { 737 eventName = (eventName || "").split( " " ).join( this.eventNamespace + " " ) + this.eventNamespace; 738 element.unbind( eventName ).undelegate( eventName ); 739 }, 740 741 _delay: function( handler, delay ) { 742 function handlerProxy() { 743 return ( typeof handler === "string" ? instance[ handler ] : handler ) 744 .apply( instance, arguments ); 745 } 746 var instance = this; 747 return setTimeout( handlerProxy, delay || 0 ); 748 }, 749 750 _hoverable: function( element ) { 751 this.hoverable = this.hoverable.add( element ); 752 this._on( element, { 753 mouseenter: function( event ) { 754 $( event.currentTarget ).addClass( "ui-state-hover" ); 755 }, 756 mouseleave: function( event ) { 757 $( event.currentTarget ).removeClass( "ui-state-hover" ); 758 } 759 }); 760 }, 761 762 _focusable: function( element ) { 763 this.focusable = this.focusable.add( element ); 764 this._on( element, { 765 focusin: function( event ) { 766 $( event.currentTarget ).addClass( "ui-state-focus" ); 767 }, 768 focusout: function( event ) { 769 $( event.currentTarget ).removeClass( "ui-state-focus" ); 770 } 771 }); 772 }, 773 774 _trigger: function( type, event, data ) { 775 var prop, orig, 776 callback = this.options[ type ]; 777 778 data = data || {}; 779 event = $.Event( event ); 780 event.type = ( type === this.widgetEventPrefix ? 781 type : 782 this.widgetEventPrefix + type ).toLowerCase(); 783 // the original event may come from any element 784 // so we need to reset the target on the new event 785 event.target = this.element[ 0 ]; 786 787 // copy original event properties over to the new event 788 orig = event.originalEvent; 789 if ( orig ) { 790 for ( prop in orig ) { 791 if ( !( prop in event ) ) { 792 event[ prop ] = orig[ prop ]; 793 } 794 } 795 } 796 797 this.element.trigger( event, data ); 798 return !( $.isFunction( callback ) && 799 callback.apply( this.element[0], [ event ].concat( data ) ) === false || 800 event.isDefaultPrevented() ); 801 } 802}; 803 804$.each( { show: "fadeIn", hide: "fadeOut" }, function( method, defaultEffect ) { 805 $.Widget.prototype[ "_" + method ] = function( element, options, callback ) { 806 if ( typeof options === "string" ) { 807 options = { effect: options }; 808 } 809 var hasOptions, 810 effectName = !options ? 811 method : 812 options === true || typeof options === "number" ? 813 defaultEffect : 814 options.effect || defaultEffect; 815 options = options || {}; 816 if ( typeof options === "number" ) { 817 options = { duration: options }; 818 } 819 hasOptions = !$.isEmptyObject( options ); 820 options.complete = callback; 821 if ( options.delay ) { 822 element.delay( options.delay ); 823 } 824 if ( hasOptions && $.effects && $.effects.effect[ effectName ] ) { 825 element[ method ]( options ); 826 } else if ( effectName !== method && element[ effectName ] ) { 827 element[ effectName ]( options.duration, options.easing, callback ); 828 } else { 829 element.queue(function( next ) { 830 $( this )[ method ](); 831 if ( callback ) { 832 callback.call( element[ 0 ] ); 833 } 834 next(); 835 }); 836 } 837 }; 838}); 839 840var widget = $.widget; 841 842 843/*! 844 * jQuery UI Mouse 1.11.
vendor: 7,818 bytes, lines 844-1133
8440 845 * http://jqueryui.com 846 * 847 * Copyright 2014 jQuery Foundation and other contributors 848 * Released under the MIT license. 849 * http://jquery.org/license 850 * 851 * http://api.jqueryui.com/mouse/ 852 */ 853 854 855var mouseHandled = false; 856$( document ).mouseup( function() { 857 mouseHandled = false; 858}); 859 860var mouse = $.widget("ui.mouse", { 861 version: "1.11.0", 862 options: { 863 cancel: "input,textarea,button,select,option", 864 distance: 1, 865 delay: 0 866 }, 867 _mouseInit: function() { 868 var that = this; 869 870 this.element 871 .bind("mousedown." + this.widgetName, function(event) { 872 return that._mouseDown(event); 873 }) 874 .bind("click." + this.widgetName, function(event) { 875 if (true === $.data(event.target, that.widgetName + ".preventClickEvent")) { 876 $.removeData(event.target, that.widgetName + ".preventClickEvent"); 877 event.stopImmediatePropagation(); 878 return false; 879 } 880 }); 881 882 this.started = false; 883 }, 884 885 // TODO: make sure destroying one instance of mouse doesn't mess with 886 // other instances of mouse 887 _mouseDestroy: function() { 888 this.element.unbind("." + this.widgetName); 889 if ( this._mouseMoveDelegate ) { 890 this.document 891 .unbind("mousemove." + this.widgetName, this._mouseMoveDelegate) 892 .unbind("mouseup." + this.widgetName, this._mouseUpDelegate); 893 } 894 }, 895 896 _mouseDown: function(event) { 897 // don't let more than one widget handle mouseStart 898 if ( mouseHandled ) { 899 return; 900 } 901 902 // we may have missed mouseup (out of window) 903 (this._mouseStarted && this._mouseUp(event)); 904 905 this._mouseDownEvent = event; 906 907 var that = this, 908 btnIsLeft = (event.which === 1), 909 // event.target.nodeName works around a bug in IE 8 with 910 // disabled inputs (#7620) 911 elIsCancel = (typeof this.options.cancel === "string" && event.target.nodeName ? $(event.target).closest(this.options.cancel).length : false); 912 if (!btnIsLeft || elIsCancel || !this._mouseCapture(event)) { 913 return true; 914 } 915 916 this.mouseDelayMet = !this.options.delay; 917 if (!this.mouseDelayMet) { 918 this._mouseDelayTimer = setTimeout(function() { 919 that.mouseDelayMet = true; 920 }, this.options.delay); 921 } 922 923 if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) { 924 this._mouseStarted = (this._mouseStart(event) !== false); 925 if (!this._mouseStarted) { 926 event.preventDefault(); 927 return true; 928 } 929 } 930 931 // Click event may never have fired (Gecko & Opera) 932 if (true === $.data(event.target, this.widgetName + ".preventClickEvent")) { 933 $.removeData(event.target, this.widgetName + ".preventClickEvent"); 934 } 935 936 // these delegates are required to keep context 937 this._mouseMoveDelegate = function(event) { 938 return that._mouseMove(event); 939 }; 940 this._mouseUpDelegate = function(event) { 941 return that._mouseUp(event); 942 }; 943 944 this.document 945 .bind( "mousemove." + this.widgetName, this._mouseMoveDelegate ) 946 .bind( "mouseup." + this.widgetName, this._mouseUpDelegate ); 947 948 event.preventDefault(); 949 950 mouseHandled = true; 951 return true; 952 }, 953 954 _mouseMove: function(event) { 955 // IE mouseup check - mouseup happened when mouse was out of window 956 if ($.ui.ie && ( !document.documentMode || document.documentMode < 9 ) && !event.button) { 957 return this._mouseUp(event); 958 959 // Iframe mouseup check - mouseup occurred in another document 960 } else if ( !event.which ) { 961 return this._mouseUp( event ); 962 } 963 964 if (this._mouseStarted) { 965 this._mouseDrag(event); 966 return event.preventDefault(); 967 } 968 969 if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) { 970 this._mouseStarted = 971 (this._mouseStart(this._mouseDownEvent, event) !== false); 972 (this._mouseStarted ? this._mouseDrag(event) : this._mouseUp(event)); 973 } 974 975 return !this._mouseStarted; 976 }, 977 978 _mouseUp: function(event) { 979 this.document 980 .unbind( "mousemove." + this.widgetName, this._mouseMoveDelegate ) 981 .unbind( "mouseup." + this.widgetName, this._mouseUpDelegate ); 982 983 if (this._mouseStarted) { 984 this._mouseStarted = false; 985 986 if (event.target === this._mouseDownEvent.target) { 987 $.data(event.target, this.widgetName + ".preventClickEvent", true); 988 } 989 990 this._mouseStop(event); 991 } 992 993 mouseHandled = false; 994 return false; 995 }, 996 997 _mouseDistanceMet: function(event) { 998 return (Math.max( 999 Math.abs(this._mouseDownEvent.pageX - event.pageX), 1000 Math.abs(this._mouseDownEvent.pageY - event.pageY) 1001 ) >= this.options.distance 1002 ); 1003 }, 1004 1005 _mouseDelayMet: function(/* event */) { 1006 return this.mouseDelayMet; 1007 }, 1008 1009 // These are placeholder methods, to be overriden by extending plugin 1010 _mouseStart: function(/* event */) {}, 1011 _mouseDrag: function(/* event */) {}, 1012 _mouseStop: function(/* event */) {}, 1013 _mouseCapture: function(/* event */) { return true; } 1014}); 1015 1016 1017/*! 1018 * jQuery UI Position 1.11.0 1019 * http://jqueryui.com 1020 * 1021 * Copyright 2014 jQuery Foundation and other contributors 1022 * Released under the MIT license. 1023 * http://jquery.org/license 1024 * 1025 * http://api.jqueryui.com/position/ 1026 */ 1027 1028(function() { 1029 1030$.ui = $.ui || {}; 1031 1032var cachedScrollbarWidth, supportsOffsetFractions, 1033 max = Math.max, 1034 abs = Math.abs, 1035 round = Math.round, 1036 rhorizontal = /left|center|right/, 1037 rvertical = /top|center|bottom/, 1038 roffset = /[\+\-]\d+(\.[\d]+)?%?/, 1039 rposition = /^\w+/, 1040 rpercent = /%$/, 1041 _position = $.fn.position; 1042 1043function getOffsets( offsets, width, height ) { 1044 return [ 1045 parseFloat( offsets[ 0 ] ) * ( rpercent.test( offsets[ 0 ] ) ? width / 100 : 1 ), 1046 parseFloat( offsets[ 1 ] ) * ( rpercent.test( offsets[ 1 ] ) ? height / 100 : 1 ) 1047 ]; 1048} 1049 1050function parseCss( element, property ) { 1051 return parseInt( $.css( element, property ), 10 ) || 0; 1052} 1053 1054function getDimensions( elem ) { 1055 var raw = elem[0]; 1056 if ( raw.nodeType === 9 ) { 1057 return { 1058 width: elem.width(), 1059 height: elem.height(), 1060 offset: { top: 0, left: 0 } 1061 }; 1062 } 1063 if ( $.isWindow( raw ) ) { 1064 return { 1065 width: elem.width(), 1066 height: elem.height(), 1067 offset: { top: elem.scrollTop(), left: elem.scrollLeft() } 1068 }; 1069 } 1070 if ( raw.preventDefault ) { 1071 return { 1072 width: 0, 1073 height: 0, 1074 offset: { top: raw.pageY, left: raw.pageX } 1075 }; 1076 } 1077 return { 1078 width: elem.outerWidth(), 1079 height: elem.outerHeight(), 1080 offset: elem.offset() 1081 }; 1082} 1083 1084$.position = { 1085 scrollbarWidth: function() { 1086 if ( cachedScrollbarWidth !== undefined ) { 1087 return cachedScrollbarWidth; 1088 } 1089 var w1, w2, 1090 div = $( "<div style='display:block;position:absolute;width:50px;height:50px;overflow:hidden;'><div style='height:100px;width:auto;'></div></div>" ), 1091 innerDiv = div.children()[0]; 1092 1093 $( "body" ).append( div ); 1094 w1 = innerDiv.offsetWidth; 1095 div.css( "overflow", "scroll" ); 1096 1097 w2 = innerDiv.offsetWidth; 1098 1099 if ( w1 === w2 ) { 1100 w2 = div[0].clientWidth; 1101 } 1102 1103 div.remove(); 1104 1105 return (cachedScrollbarWidth = w1 - w2); 1106 }, 1107 getScrollInfo: function( within ) { 1108 var overflowX = within.isWindow || within.isDocument ? "" : 1109 within.element.css( "overflow-x" ), 1110 overflowY = within.isWindow || within.isDocument ? "" : 1111 within.element.css( "overflow-y" ), 1112 hasOverflowX = overflowX === "scroll" || 1113 ( overflowX === "auto" && within.width < within.element[0].scrollWidth ), 1114 hasOverflowY = overflowY === "scroll" || 1115 ( overflowY === "auto" && within.height < within.element[0].scrollHeight ); 1116 return { 1117 width: hasOverflowY ? $.position.scrollbarWidth() : 0, 1118 height: hasOverflowX ? $.position.scrollbarWidth() : 0 1119 }; 1120 }, 1121 getWithinInfo: function( element ) { 1122 var withinElement = $( element || window ), 1123 isWindow = $.isWindow( withinElement[0] ), 1124 isDocument = !!withinElement[ 0 ] && withinElement[ 0 ].nodeType === 9; 1125 return { 1126 element: withinElement, 1127 isWindow: isWindow, 1128 isDocument: isDocument, 1129 offset: withinElement.offset() || { left: 0, top: 0 }, 1130 scrollLeft: withinElement.scrollLeft(), 1131 scrollTop: withinElement.scrollTop(), 1132 width: isWindow ? withinElement.width() : withinElement.outerWidth(), 1133 height: isWindow
vendor: 12,731 bytes, lines 1133-1522
1133 ? withinElement.height() : withinElement.outerHeight() 1134 }; 1135 } 1136}; 1137 1138$.fn.position = function( options ) { 1139 if ( !options || !options.of ) { 1140 return _position.apply( this, arguments ); 1141 } 1142 1143 // make a copy, we don't want to modify arguments 1144 options = $.extend( {}, options ); 1145 1146 var atOffset, targetWidth, targetHeight, targetOffset, basePosition, dimensions, 1147 target = $( options.of ), 1148 within = $.position.getWithinInfo( options.within ), 1149 scrollInfo = $.position.getScrollInfo( within ), 1150 collision = ( options.collision || "flip" ).split( " " ), 1151 offsets = {}; 1152 1153 dimensions = getDimensions( target ); 1154 if ( target[0].preventDefault ) { 1155 // force left top to allow flipping 1156 options.at = "left top"; 1157 } 1158 targetWidth = dimensions.width; 1159 targetHeight = dimensions.height; 1160 targetOffset = dimensions.offset; 1161 // clone to reuse original targetOffset later 1162 basePosition = $.extend( {}, targetOffset ); 1163 1164 // force my and at to have valid horizontal and vertical positions 1165 // if a value is missing or invalid, it will be converted to center 1166 $.each( [ "my", "at" ], function() { 1167 var pos = ( options[ this ] || "" ).split( " " ), 1168 horizontalOffset, 1169 verticalOffset; 1170 1171 if ( pos.length === 1) { 1172 pos = rhorizontal.test( pos[ 0 ] ) ? 1173 pos.concat( [ "center" ] ) : 1174 rvertical.test( pos[ 0 ] ) ? 1175 [ "center" ].concat( pos ) : 1176 [ "center", "center" ]; 1177 } 1178 pos[ 0 ] = rhorizontal.test( pos[ 0 ] ) ? pos[ 0 ] : "center"; 1179 pos[ 1 ] = rvertical.test( pos[ 1 ] ) ? pos[ 1 ] : "center"; 1180 1181 // calculate offsets 1182 horizontalOffset = roffset.exec( pos[ 0 ] ); 1183 verticalOffset = roffset.exec( pos[ 1 ] ); 1184 offsets[ this ] = [ 1185 horizontalOffset ? horizontalOffset[ 0 ] : 0, 1186 verticalOffset ? verticalOffset[ 0 ] : 0 1187 ]; 1188 1189 // reduce to just the positions without the offsets 1190 options[ this ] = [ 1191 rposition.exec( pos[ 0 ] )[ 0 ], 1192 rposition.exec( pos[ 1 ] )[ 0 ] 1193 ]; 1194 }); 1195 1196 // normalize collision option 1197 if ( collision.length === 1 ) { 1198 collision[ 1 ] = collision[ 0 ]; 1199 } 1200 1201 if ( options.at[ 0 ] === "right" ) { 1202 basePosition.left += targetWidth; 1203 } else if ( options.at[ 0 ] === "center" ) { 1204 basePosition.left += targetWidth / 2; 1205 } 1206 1207 if ( options.at[ 1 ] === "bottom" ) { 1208 basePosition.top += targetHeight; 1209 } else if ( options.at[ 1 ] === "center" ) { 1210 basePosition.top += targetHeight / 2; 1211 } 1212 1213 atOffset = getOffsets( offsets.at, targetWidth, targetHeight ); 1214 basePosition.left += atOffset[ 0 ]; 1215 basePosition.top += atOffset[ 1 ]; 1216 1217 return this.each(function() { 1218 var collisionPosition, using, 1219 elem = $( this ), 1220 elemWidth = elem.outerWidth(), 1221 elemHeight = elem.outerHeight(), 1222 marginLeft = parseCss( this, "marginLeft" ), 1223 marginTop = parseCss( this, "marginTop" ), 1224 collisionWidth = elemWidth + marginLeft + parseCss( this, "marginRight" ) + scrollInfo.width, 1225 collisionHeight = elemHeight + marginTop + parseCss( this, "marginBottom" ) + scrollInfo.height, 1226 position = $.extend( {}, basePosition ), 1227 myOffset = getOffsets( offsets.my, elem.outerWidth(), elem.outerHeight() ); 1228 1229 if ( options.my[ 0 ] === "right" ) { 1230 position.left -= elemWidth; 1231 } else if ( options.my[ 0 ] === "center" ) { 1232 position.left -= elemWidth / 2; 1233 } 1234 1235 if ( options.my[ 1 ] === "bottom" ) { 1236 position.top -= elemHeight; 1237 } else if ( options.my[ 1 ] === "center" ) { 1238 position.top -= elemHeight / 2; 1239 } 1240 1241 position.left += myOffset[ 0 ]; 1242 position.top += myOffset[ 1 ]; 1243 1244 // if the browser doesn't support fractions, then round for consistent results 1245 if ( !supportsOffsetFractions ) { 1246 position.left = round( position.left ); 1247 position.top = round( position.top ); 1248 } 1249 1250 collisionPosition = { 1251 marginLeft: marginLeft, 1252 marginTop: marginTop 1253 }; 1254 1255 $.each( [ "left", "top" ], function( i, dir ) { 1256 if ( $.ui.position[ collision[ i ] ] ) { 1257 $.ui.position[ collision[ i ] ][ dir ]( position, { 1258 targetWidth: targetWidth, 1259 targetHeight: targetHeight, 1260 elemWidth: elemWidth, 1261 elemHeight: elemHeight, 1262 collisionPosition: collisionPosition, 1263 collisionWidth: collisionWidth, 1264 collisionHeight: collisionHeight, 1265 offset: [ atOffset[ 0 ] + myOffset[ 0 ], atOffset [ 1 ] + myOffset[ 1 ] ], 1266 my: options.my, 1267 at: options.at, 1268 within: within, 1269 elem: elem 1270 }); 1271 } 1272 }); 1273 1274 if ( options.using ) { 1275 // adds feedback as second argument to using callback, if present 1276 using = function( props ) { 1277 var left = targetOffset.left - position.left, 1278 right = left + targetWidth - elemWidth, 1279 top = targetOffset.top - position.top, 1280 bottom = top + targetHeight - elemHeight, 1281 feedback = { 1282 target: { 1283 element: target, 1284 left: targetOffset.left, 1285 top: targetOffset.top, 1286 width: targetWidth, 1287 height: targetHeight 1288 }, 1289 element: { 1290 element: elem, 1291 left: position.left, 1292 top: position.top, 1293 width: elemWidth, 1294 height: elemHeight 1295 }, 1296 horizontal: right < 0 ? "left" : left > 0 ? "right" : "center", 1297 vertical: bottom < 0 ? "top" : top > 0 ? "bottom" : "middle" 1298 }; 1299 if ( targetWidth < elemWidth && abs( left + right ) < targetWidth ) { 1300 feedback.horizontal = "center"; 1301 } 1302 if ( targetHeight < elemHeight && abs( top + bottom ) < targetHeight ) { 1303 feedback.vertical = "middle"; 1304 } 1305 if ( max( abs( left ), abs( right ) ) > max( abs( top ), abs( bottom ) ) ) { 1306 feedback.important = "horizontal"; 1307 } else { 1308 feedback.important = "vertical"; 1309 } 1310 options.using.call( this, props, feedback ); 1311 }; 1312 } 1313 1314 elem.offset( $.extend( position, { using: using } ) ); 1315 }); 1316}; 1317 1318$.ui.position = { 1319 fit: { 1320 left: function( position, data ) { 1321 var within = data.within, 1322 withinOffset = within.isWindow ? within.scrollLeft : within.offset.left, 1323 outerWidth = within.width, 1324 collisionPosLeft = position.left - data.collisionPosition.marginLeft, 1325 overLeft = withinOffset - collisionPosLeft, 1326 overRight = collisionPosLeft + data.collisionWidth - outerWidth - withinOffset, 1327 newOverRight; 1328 1329 // element is wider than within 1330 if ( data.collisionWidth > outerWidth ) { 1331 // element is initially over the left side of within 1332 if ( overLeft > 0 && overRight <= 0 ) { 1333 newOverRight = position.left + overLeft + data.collisionWidth - outerWidth - withinOffset; 1334 position.left += overLeft - newOverRight; 1335 // element is initially over right side of within 1336 } else if ( overRight > 0 && overLeft <= 0 ) { 1337 position.left = withinOffset; 1338 // element is initially over both left and right sides of within 1339 } else { 1340 if ( overLeft > overRight ) { 1341 position.left = withinOffset + outerWidth - data.collisionWidth; 1342 } else { 1343 position.left = withinOffset; 1344 } 1345 } 1346 // too far left -> align with left edge 1347 } else if ( overLeft > 0 ) { 1348 position.left += overLeft; 1349 // too far right -> align with right edge 1350 } else if ( overRight > 0 ) { 1351 position.left -= overRight; 1352 // adjust based on position and margin 1353 } else { 1354 position.left = max( position.left - collisionPosLeft, position.left ); 1355 } 1356 }, 1357 top: function( position, data ) { 1358 var within = data.within, 1359 withinOffset = within.isWindow ? within.scrollTop : within.offset.top, 1360 outerHeight = data.within.height, 1361 collisionPosTop = position.top - data.collisionPosition.marginTop, 1362 overTop = withinOffset - collisionPosTop, 1363 overBottom = collisionPosTop + data.collisionHeight - outerHeight - withinOffset, 1364 newOverBottom; 1365 1366 // element is taller than within 1367 if ( data.collisionHeight > outerHeight ) { 1368 // element is initially over the top of within 1369 if ( overTop > 0 && overBottom <= 0 ) { 1370 newOverBottom = position.top + overTop + data.collisionHeight - outerHeight - withinOffset; 1371 position.top += overTop - newOverBottom; 1372 // element is initially over bottom of within 1373 } else if ( overBottom > 0 && overTop <= 0 ) { 1374 position.top = withinOffset; 1375 // element is initially over both top and bottom of within 1376 } else { 1377 if ( overTop > overBottom ) { 1378 position.top = withinOffset + outerHeight - data.collisionHeight; 1379 } else { 1380 position.top = withinOffset; 1381 } 1382 } 1383 // too far up -> align with top 1384 } else if ( overTop > 0 ) { 1385 position.top += overTop; 1386 // too far down -> align with bottom edge 1387 } else if ( overBottom > 0 ) { 1388 position.top -= overBottom; 1389 // adjust based on position and margin 1390 } else { 1391 position.top = max( position.top - collisionPosTop, position.top ); 1392 } 1393 } 1394 }, 1395 flip: { 1396 left: function( position, data ) { 1397 var within = data.within, 1398 withinOffset = within.offset.left + within.scrollLeft, 1399 outerWidth = within.width, 1400 offsetLeft = within.isWindow ? within.scrollLeft : within.offset.left, 1401 collisionPosLeft = position.left - data.collisionPosition.marginLeft, 1402 overLeft = collisionPosLeft - offsetLeft, 1403 overRight = collisionPosLeft + data.collisionWidth - outerWidth - offsetLeft, 1404 myOffset = data.my[ 0 ] === "left" ? 1405 -data.elemWidth : 1406 data.my[ 0 ] === "right" ? 1407 data.elemWidth : 1408 0, 1409 atOffset = data.at[ 0 ] === "left" ? 1410 data.targetWidth : 1411 data.at[ 0 ] === "right" ? 1412 -data.targetWidth : 1413 0, 1414 offset = -2 * data.offset[ 0 ], 1415 newOverRight, 1416 newOverLeft; 1417 1418 if ( overLeft < 0 ) { 1419 newOverRight = position.left + myOffset + atOffset + offset + data.collisionWidth - outerWidth - withinOffset; 1420 if ( newOverRight < 0 || newOverRight < abs( overLeft ) ) { 1421 position.left += myOffset + atOffset + offset; 1422 } 1423 } else if ( overRight > 0 ) { 1424 newOverLeft = position.left - data.collisionPosition.marginLeft + myOffset + atOffset + offset - offsetLeft; 1425 if ( newOverLeft > 0 || abs( newOverLeft ) < overRight ) { 1426 position.left += myOffset + atOffset + offset; 1427 } 1428 } 1429 }, 1430 top: function( position, data ) { 1431 var within = data.within, 1432 withinOffset = within.offset.top + within.scrollTop, 1433 outerHeight = within.height, 1434 offsetTop = within.isWindow ? within.scrollTop : within.offset.top, 1435 collisionPosTop = position.top - data.collisionPosition.marginTop, 1436 overTop = collisionPosTop - offsetTop, 1437 overBottom = collisionPosTop + data.collisionHeight - outerHeight - offsetTop, 1438 top = data.my[ 1 ] === "top", 1439 myOffset = top ? 1440 -data.elemHeight : 1441 data.my[ 1 ] === "bottom" ? 1442 data.elemHeight : 1443 0, 1444 atOffset = data.at[ 1 ] === "top" ? 1445 data.targetHeight : 1446 data.at[ 1 ] === "bottom" ? 1447 -data.targetHeight : 1448 0, 1449 offset = -2 * data.offset[ 1 ], 1450 newOverTop, 1451 newOverBottom; 1452 if ( overTop < 0 ) { 1453 newOverBottom = position.top + myOffset + atOffset + offset + data.collisionHeight - outerHeight - withinOffset; 1454 if ( ( position.top + myOffset + atOffset + offset) > overTop && ( newOverBottom < 0 || newOverBottom < abs( overTop ) ) ) { 1455 position.top += myOffset + atOffset + offset; 1456 } 1457 } else if ( overBottom > 0 ) { 1458 newOverTop = position.top - data.collisionPosition.marginTop + myOffset + atOffset + offset - offsetTop; 1459 if ( ( position.top + myOffset + atOffset + offset) > overBottom && ( newOverTop > 0 || abs( newOverTop ) < overBottom ) ) { 1460 position.top += myOffset + atOffset + offset; 1461 } 1462 } 1463 } 1464 }, 1465 flipfit: { 1466 left: function() { 1467 $.ui.position.flip.left.apply( this, arguments ); 1468 $.ui.position.fit.left.apply( this, arguments ); 1469 }, 1470 top: function() { 1471 $.ui.position.flip.top.apply( this, arguments ); 1472 $.ui.position.fit.top.apply( this, arguments ); 1473 } 1474 } 1475}; 1476 1477// fraction support test 1478(function() { 1479 var testElement, testElementParent, testElementStyle, offsetLeft, i, 1480 body = document.getElementsByTagName( "body" )[ 0 ], 1481 div = document.createElement( "div" ); 1482 1483 //Create a "fake body" for testing based on method used in jQuery.support 1484 testElement = document.createElement( body ? "div" : "body" ); 1485 testElementStyle = { 1486 visibility: "hidden", 1487 width: 0, 1488 height: 0, 1489 border: 0, 1490 margin: 0, 1491 background: "none" 1492 }; 1493 if ( body ) { 1494 $.extend( testElementStyle, { 1495 position: "absolute", 1496 left: "-1000px", 1497 top: "-1000px" 1498 }); 1499 } 1500 for ( i in testElementStyle ) { 1501 testElement.style[ i ] = testElementStyle[ i ]; 1502 } 1503 testElement.appendChild( div ); 1504 testElementParent = body || document.documentElement; 1505 testElementParent.insertBefore( testElement, testElementParent.firstChild ); 1506 1507 div.style.cssText = "position: absolute; left: 10.7432222px;"; 1508 1509 offsetLeft = $( div ).offset().left; 1510 supportsOffsetFractions = offsetLeft > 10 && offsetLeft < 11; 1511 1512 testElement.innerHTML = ""; 1513 testElementParent.removeChild( testElement ); 1514})(); 1515 1516})(); 1517 1518var position = $.ui.position; 1519 1520 1521/*! 1522 * jQuery UI
1522Datepicker 1.11.0 1523 * http://jqueryui.com 1524 * 1525 * Copyright 2014 jQuery Foundation and other contributors 1526 * Released under the MIT license. 1527 * http://jquery.org/license 1528 * 1529 * http://api.jqueryui.com/datepicker/ 1530 */ 1531 1532 1533$.extend($.ui, { datepicker: { version: "1.11.0
vendor: 16,250 bytes, lines 1533-1888
1533" } }); 1534 1535var datepicker_instActive; 1536 1537function datepicker_getZindex( elem ) { 1538 var position, value; 1539 while ( elem.length && elem[ 0 ] !== document ) { 1540 // Ignore z-index if position is set to a value where z-index is ignored by the browser 1541 // This makes behavior of this function consistent across browsers 1542 // WebKit always returns auto if the element is positioned 1543 position = elem.css( "position" ); 1544 if ( position === "absolute" || position === "relative" || position === "fixed" ) { 1545 // IE returns 0 when zIndex is not specified 1546 // other browsers return a string 1547 // we ignore the case of nested elements with an explicit value of 0 1548 // <div style="z-index: -10;"><div style="z-index: 0;"></div></div> 1549 value = parseInt( elem.css( "zIndex" ), 10 ); 1550 if ( !isNaN( value ) && value !== 0 ) { 1551 return value; 1552 } 1553 } 1554 elem = elem.parent(); 1555 } 1556 1557 return 0; 1558} 1559/* Date picker manager. 1560 Use the singleton instance of this class, $.datepicker, to interact with the date picker. 1561 Settings for (groups of) date pickers are maintained in an instance object, 1562 allowing multiple different settings on the same page. */ 1563 1564function Datepicker() { 1565 this._curInst = null; // The current instance in use 1566 this._keyEvent = false; // If the last event was a key event 1567 this._disabledInputs = []; // List of date picker inputs that have been disabled 1568 this._datepickerShowing = false; // True if the popup picker is showing , false if not 1569 this._inDialog = false; // True if showing within a "dialog", false if not 1570 this._mainDivId = "ui-datepicker-div"; // The ID of the main datepicker division 1571 this._inlineClass = "ui-datepicker-inline"; // The name of the inline marker class 1572 this._appendClass = "ui-datepicker-append"; // The name of the append marker class 1573 this._triggerClass = "ui-datepicker-trigger"; // The name of the trigger marker class 1574 this._dialogClass = "ui-datepicker-dialog"; // The name of the dialog marker class 1575 this._disableClass = "ui-datepicker-disabled"; // The name of the disabled covering marker class 1576 this._unselectableClass = "ui-datepicker-unselectable"; // The name of the unselectable cell marker class 1577 this._currentClass = "ui-datepicker-current-day"; // The name of the current day marker class 1578 this._dayOverClass = "ui-datepicker-days-cell-over"; // The name of the day hover marker class 1579 this.regional = []; // Available regional settings, indexed by language code 1580 this.regional[""] = { // Default regional settings 1581 closeText: "Done", // Display text for close link 1582 prevText: "Prev", // Display text for previous month link 1583 nextText: "Next", // Display text for next month link 1584 currentText: "Today", // Display text for current month link 1585 monthNames: ["January","February","March","April","May","June", 1586 "July","August","September","October","November","December"], // Names of months for drop-down and formatting 1587 monthNamesShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], // For formatting 1588 dayNames: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], // For formatting 1589 dayNamesShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], // For formatting 1590 dayNamesMin: ["Su","Mo","Tu","We","Th","Fr","Sa"], // Column headings for days starting at Sunday 1591 weekHeader: "Wk", // Column header for week of the year 1592 dateFormat: "mm/dd/yy", // See format options on parseDate 1593 firstDay: 0, // The first day of the week, Sun = 0, Mon = 1, ... 1594 isRTL: false, // True if right-to-left language, false if left-to-right 1595 showMonthAfterYear: false, // True if the year select precedes month, false for month then year 1596 yearSuffix: "" // Additional text to append to the year in the month headers 1597 }; 1598 this._defaults = { // Global defaults for all the date picker instances 1599 showOn: "focus", // "focus" for popup on focus, 1600 // "button" for trigger button, or "both" for either 1601 showAnim: "fadeIn", // Name of jQuery animation for popup 1602 showOptions: {}, // Options for enhanced animations 1603 defaultDate: null, // Used when field is blank: actual date, 1604 // +/-number for offset from today, null for today 1605 appendText: "", // Display text following the input box, e.g. showing the format 1606 buttonText: "...", // Text for trigger button 1607 buttonImage: "", // URL for trigger button image 1608 buttonImageOnly: false, // True if the image appears alone, false if it appears on a button 1609 hideIfNoPrevNext: false, // True to hide next/previous month links 1610 // if not applicable, false to just disable them 1611 navigationAsDateFormat: false, // True if date formatting applied to prev/today/next links 1612 gotoCurrent: false, // True if today link goes back to current selection instead 1613 changeMonth: false, // True if month can be selected directly, false if only prev/next 1614 changeYear: false, // True if year can be selected directly, false if only prev/next 1615 yearRange: "c-10:c+10", // Range of years to display in drop-down, 1616 // either relative to today's year (-nn:+nn), relative to currently displayed year 1617 // (c-nn:c+nn), absolute (nnnn:nnnn), or a combination of the above (nnnn:-n) 1618 showOtherMonths: false, // True to show dates in other months, false to leave blank 1619 selectOtherMonths: false, // True to allow selection of dates in other months, false for unselectable 1620 showWeek: false, // True to show week of the year, false to not show it 1621 calculateWeek: this.iso8601Week, // How to calculate the week of the year, 1622 // takes a Date and returns the number of the week for it 1623 shortYearCutoff: "+10", // Short year values < this are in the current century, 1624 // > this are in the previous century, 1625 // string value starting with "+" for current year + value 1626 minDate: null, // The earliest selectable date, or null for no limit 1627 maxDate: null, // The latest selectable date, or null for no limit 1628 duration: "fast", // Duration of display/closure 1629 beforeShowDay: null, // Function that takes a date and returns an array with 1630 // [0] = true if selectable, false if not, [1] = custom CSS class name(s) or "", 1631 // [2] = cell title (optional), e.g. $.datepicker.noWeekends 1632 beforeShow: null, // Function that takes an input field and 1633 // returns a set of custom settings for the date picker 1634 onSelect: null, // Define a callback function when a date is selected 1635 onChangeMonthYear: null, // Define a callback function when the month or year is changed 1636 onClose: null, // Define a callback function when the datepicker is closed 1637 numberOfMonths: 1, // Number of months to show at a time 1638 showCurrentAtPos: 0, // The position in multipe months at which to show the current month (starting at 0) 1639 stepMonths: 1, // Number of months to step back/forward 1640 stepBigMonths: 12, // Number of months to step back/forward for the big links 1641 altField: "", // Selector for an alternate field to store selected dates into 1642 altFormat: "", // The date format to use for the alternate field 1643 constrainInput: true, // The input is constrained by the current date format 1644 showButtonPanel: false, // True to show button panel, false to not show it 1645 autoSize: false, // True to size the input for the date format, false to leave as is 1646 disabled: false // The initial disabled state 1647 }; 1648 $.extend(this._defaults, this.regional[""]); 1649 this.regional.en = $.extend( true, {}, this.regional[ "" ]); 1650 this.regional[ "en-US" ] = $.extend( true, {}, this.regional.en ); 1651 this.dpDiv = datepicker_bindHover($("<div id='" + this._mainDivId + "' class='ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all'></div>")); 1652} 1653 1654$.extend(Datepicker.prototype, { 1655 /* Class name added to elements to indicate already configured with a date picker. */ 1656 markerClassName: "hasDatepicker", 1657 1658 //Keep track of the maximum number of rows displayed (see #7043) 1659 maxRows: 4, 1660 1661 // TODO rename to "widget" when switching to widget factory 1662 _widgetDatepicker: function() { 1663 return this.dpDiv; 1664 }, 1665 1666 /* Override the default settings for all instances of the date picker. 1667 * @param settings object - the new settings to use as defaults (anonymous object) 1668 * @return the manager object 1669 */ 1670 setDefaults: function(settings) { 1671 datepicker_extendRemove(this._defaults, settings || {}); 1672 return this; 1673 }, 1674 1675 /* Attach the date picker to a jQuery selection. 1676 * @param target element - the target input field or division or span 1677 * @param settings object - the new settings to use for this date picker instance (anonymous) 1678 */ 1679 _attachDatepicker: function(target, settings) { 1680 var nodeName, inline, inst; 1681 nodeName = target.nodeName.toLowerCase(); 1682 inline = (nodeName === "div" || nodeName === "span"); 1683 if (!target.id) { 1684 this.uuid += 1; 1685 target.id = "dp" + this.uuid; 1686 } 1687 inst = this._newInst($(target), inline); 1688 inst.settings = $.extend({}, settings || {}); 1689 if (nodeName === "input") { 1690 this._connectDatepicker(target, inst); 1691 } else if (inline) { 1692 this._inlineDatepicker(target, inst); 1693 } 1694 }, 1695 1696 /* Create a new instance object. */ 1697 _newInst: function(target, inline) { 1698 var id = target[0].id.replace(/([^A-Za-z0-9_\-])/g, "\\\\$1"); // escape jQuery meta chars 1699 return {id: id, input: target, // associated target 1700 selectedDay: 0, selectedMonth: 0, selectedYear: 0, // current selection 1701 drawMonth: 0, drawYear: 0, // month being drawn 1702 inline: inline, // is datepicker inline or not 1703 dpDiv: (!inline ? this.dpDiv : // presentation div 1704 datepicker_bindHover($("<div class='" + this._inlineClass + " ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all'></div>")))}; 1705 }, 1706 1707 /* Attach the date picker to an input field. */ 1708 _connectDatepicker: function(target, inst) { 1709 var input = $(target); 1710 inst.append = $([]); 1711 inst.trigger = $([]); 1712 if (input.hasClass(this.markerClassName)) { 1713 return; 1714 } 1715 this._attachments(input, inst); 1716 input.addClass(this.markerClassName).keydown(this._doKeyDown). 1717 keypress(this._doKeyPress).keyup(this._doKeyUp); 1718 this._autoSize(inst); 1719 $.data(target, "datepicker", inst); 1720 //If disabled option is true, disable the datepicker once it has been attached to the input (see ticket #5665) 1721 if( inst.settings.disabled ) { 1722 this._disableDatepicker( target ); 1723 } 1724 }, 1725 1726 /* Make attachments based on settings. */ 1727 _attachments: function(input, inst) { 1728 var showOn, buttonText, buttonImage, 1729 appendText = this._get(inst, "appendText"), 1730 isRTL = this._get(inst, "isRTL"); 1731 1732 if (inst.append) { 1733 inst.append.remove(); 1734 } 1735 if (appendText) { 1736 inst.append = $("<span class='" + this._appendClass + "'>" + appendText + "</span>"); 1737 input[isRTL ? "before" : "after"](inst.append); 1738 } 1739 1740 input.unbind("focus", this._showDatepicker); 1741 1742 if (inst.trigger) { 1743 inst.trigger.remove(); 1744 } 1745 1746 showOn = this._get(inst, "showOn"); 1747 if (showOn === "focus" || showOn === "both") { // pop-up date picker when in the marked field 1748 input.focus(this._showDatepicker); 1749 } 1750 if (showOn === "button" || showOn === "both") { // pop-up date picker when button clicked 1751 buttonText = this._get(inst, "buttonText"); 1752 buttonImage = this._get(inst, "buttonImage"); 1753 inst.trigger = $(this._get(inst, "buttonImageOnly") ? 1754 $("<img/>").addClass(this._triggerClass). 1755 attr({ src: buttonImage, alt: buttonText, title: buttonText }) : 1756 $("<button type='button'></button>").addClass(this._triggerClass). 1757 html(!buttonImage ? buttonText : $("<img/>").attr( 1758 { src:buttonImage, alt:buttonText, title:buttonText }))); 1759 input[isRTL ? "before" : "after"](inst.trigger); 1760 inst.trigger.click(function() { 1761 if ($.datepicker._datepickerShowing && $.datepicker._lastInput === input[0]) { 1762 $.datepicker._hideDatepicker(); 1763 } else if ($.datepicker._datepickerShowing && $.datepicker._lastInput !== input[0]) { 1764 $.datepicker._hideDatepicker(); 1765 $.datepicker._showDatepicker(input[0]); 1766 } else { 1767 $.datepicker._showDatepicker(input[0]); 1768 } 1769 return false; 1770 }); 1771 } 1772 }, 1773 1774 /* Apply the maximum length for the date format. */ 1775 _autoSize: function(inst) { 1776 if (this._get(inst, "autoSize") && !inst.inline) { 1777 var findMax, max, maxI, i, 1778 date = new Date(2009, 12 - 1, 20), // Ensure double digits 1779 dateFormat = this._get(inst, "dateFormat"); 1780 1781 if (dateFormat.match(/[DM]/)) { 1782 findMax = function(names) { 1783 max = 0; 1784 maxI = 0; 1785 for (i = 0; i < names.length; i++) { 1786 if (names[i].length > max) { 1787 max = names[i].length; 1788 maxI = i; 1789 } 1790 } 1791 return maxI; 1792 }; 1793 date.setMonth(findMax(this._get(inst, (dateFormat.match(/MM/) ? 1794 "monthNames" : "monthNamesShort")))); 1795 date.setDate(findMax(this._get(inst, (dateFormat.match(/DD/) ? 1796 "dayNames" : "dayNamesShort"))) + 20 - date.getDay()); 1797 } 1798 inst.input.attr("size", this._formatDate(inst, date).length); 1799 } 1800 }, 1801 1802 /* Attach an inline date picker to a div. */ 1803 _inlineDatepicker: function(target, inst) { 1804 var divSpan = $(target); 1805 if (divSpan.hasClass(this.markerClassName)) { 1806 return; 1807 } 1808 divSpan.addClass(this.markerClassName).append(inst.dpDiv); 1809 $.data(target, "datepicker", inst); 1810 this._setDate(inst, this._getDefaultDate(inst), true); 1811 this._updateDatepicker(inst); 1812 this._updateAlternate(inst); 1813 //If disabled option is true, disable the datepicker before showing it (see ticket #5665) 1814 if( inst.settings.disabled ) { 1815 this._disableDatepicker( target ); 1816 } 1817 // Set display:block in place of inst.dpDiv.show() which won't work on disconnected elements 1818 // http://bugs.jqueryui.com/ticket/7552 - A Datepicker created on a detached div has zero height 1819 inst.dpDiv.css( "display", "block" ); 1820 }, 1821 1822 /* Pop-up the date picker in a "dialog" box. 1823 * @param input element - ignored 1824 * @param date string or Date - the initial date to display 1825 * @param onSelect function - the function to call when a date is selected 1826 * @param settings object - update the dialog date picker instance's settings (anonymous object) 1827 * @param pos int[2] - coordinates for the dialog's position within the screen or 1828 * event - with x/y coordinates or 1829 * leave empty for default (screen centre) 1830 * @return the manager object 1831 */ 1832 _dialogDatepicker: function(input, date, onSelect, settings, pos) { 1833 var id, browserWidth, browserHeight, scrollX, scrollY, 1834 inst = this._dialogInst; // internal instance 1835 1836 if (!inst) { 1837 this.uuid += 1; 1838 id = "dp" + this.uuid; 1839 this._dialogInput = $("<input type='text' id='" + id + 1840 "' style='position: absolute; top: -100px; width: 0px;'/>"); 1841 this._dialogInput.keydown(this._doKeyDown); 1842 $("body").append(this._dialogInput); 1843 inst = this._dialogInst = this._newInst(this._dialogInput, false); 1844 inst.settings = {}; 1845 $.data(this._dialogInput[0], "datepicker", inst); 1846 } 1847 datepicker_extendRemove(inst.settings, settings || {}); 1848 date = (date && date.constructor === Date ? this._formatDate(inst, date) : date); 1849 this._dialogInput.val(date); 1850 1851 this._pos = (pos ? (pos.length ? pos : [pos.pageX, pos.pageY]) : null); 1852 if (!this._pos) { 1853 browserWidth = document.documentElement.clientWidth; 1854 browserHeight = document.documentElement.clientHeight; 1855 scrollX = document.documentElement.scrollLeft || document.body.scrollLeft; 1856 scrollY = document.documentElement.scrollTop || document.body.scrollTop; 1857 this._pos = // should use actual width/height below 1858 [(browserWidth / 2) - 100 + scrollX, (browserHeight / 2) - 150 + scrollY]; 1859 } 1860 1861 // move input on screen for focus, but hidden behind dialog 1862 this._dialogInput.css("left", (this._pos[0] + 20) + "px").css("top", this._pos[1] + "px"); 1863 inst.settings.onSelect = onSelect; 1864 this._inDialog = true; 1865 this.dpDiv.addClass(this._dialogClass); 1866 this._showDatepicker(this._dialogInput[0]); 1867 if ($.blockUI) { 1868 $.blockUI(this.dpDiv); 1869 } 1870 $.data(this._dialogInput[0], "datepicker", inst); 1871 return this; 1872 }, 1873 1874 /* Detach a datepicker from its control. 1875 * @param target element - the target input field or division or span 1876 */ 1877 _destroyDatepicker: function(target) { 1878 var nodeName, 1879 $target = $(target), 1880 inst = $.data(target, "datepicker"); 1881 1882 if (!$target.hasClass(this.markerClassName)) { 1883 return; 1884 } 1885 1886 nodeName = target.nodeName.toLowerCase(); 1887 $.removeData(target, "datepicker"); 1888 if (nodeName === "input") {
vendor: 6,854 bytes, lines 1889-2096
1889 inst.append.remove(); 1890 inst.trigger.remove(); 1891 $target.removeClass(this.markerClassName). 1892 unbind("focus", this._showDatepicker). 1893 unbind("keydown", this._doKeyDown). 1894 unbind("keypress", this._doKeyPress). 1895 unbind("keyup", this._doKeyUp); 1896 } else if (nodeName === "div" || nodeName === "span") { 1897 $target.removeClass(this.markerClassName).empty(); 1898 } 1899 }, 1900 1901 /* Enable the date picker to a jQuery selection. 1902 * @param target element - the target input field or division or span 1903 */ 1904 _enableDatepicker: function(target) { 1905 var nodeName, inline, 1906 $target = $(target), 1907 inst = $.data(target, "datepicker"); 1908 1909 if (!$target.hasClass(this.markerClassName)) { 1910 return; 1911 } 1912 1913 nodeName = target.nodeName.toLowerCase(); 1914 if (nodeName === "input") { 1915 target.disabled = false; 1916 inst.trigger.filter("button"). 1917 each(function() { this.disabled = false; }).end(). 1918 filter("img").css({opacity: "1.0", cursor: ""}); 1919 } else if (nodeName === "div" || nodeName === "span") { 1920 inline = $target.children("." + this._inlineClass); 1921 inline.children().removeClass("ui-state-disabled"); 1922 inline.find("select.ui-datepicker-month, select.ui-datepicker-year"). 1923 prop("disabled", false); 1924 } 1925 this._disabledInputs = $.map(this._disabledInputs, 1926 function(value) { return (value === target ? null : value); }); // delete entry 1927 }, 1928 1929 /* Disable the date picker to a jQuery selection. 1930 * @param target element - the target input field or division or span 1931 */ 1932 _disableDatepicker: function(target) { 1933 var nodeName, inline, 1934 $target = $(target), 1935 inst = $.data(target, "datepicker"); 1936 1937 if (!$target.hasClass(this.markerClassName)) { 1938 return; 1939 } 1940 1941 nodeName = target.nodeName.toLowerCase(); 1942 if (nodeName === "input") { 1943 target.disabled = true; 1944 inst.trigger.filter("button"). 1945 each(function() { this.disabled = true; }).end(). 1946 filter("img").css({opacity: "0.5", cursor: "default"}); 1947 } else if (nodeName === "div" || nodeName === "span") { 1948 inline = $target.children("." + this._inlineClass); 1949 inline.children().addClass("ui-state-disabled"); 1950 inline.find("select.ui-datepicker-month, select.ui-datepicker-year"). 1951 prop("disabled", true); 1952 } 1953 this._disabledInputs = $.map(this._disabledInputs, 1954 function(value) { return (value === target ? null : value); }); // delete entry 1955 this._disabledInputs[this._disabledInputs.length] = target; 1956 }, 1957 1958 /* Is the first field in a jQuery collection disabled as a datepicker? 1959 * @param target element - the target input field or division or span 1960 * @return boolean - true if disabled, false if enabled 1961 */ 1962 _isDisabledDatepicker: function(target) { 1963 if (!target) { 1964 return false; 1965 } 1966 for (var i = 0; i < this._disabledInputs.length; i++) { 1967 if (this._disabledInputs[i] === target) { 1968 return true; 1969 } 1970 } 1971 return false; 1972 }, 1973 1974 /* Retrieve the instance data for the target control. 1975 * @param target element - the target input field or division or span 1976 * @return object - the associated instance data 1977 * @throws error if a jQuery problem getting data 1978 */ 1979 _getInst: function(target) { 1980 try { 1981 return $.data(target, "datepicker"); 1982 } 1983 catch (err) { 1984 throw "Missing instance data for this datepicker"; 1985 } 1986 }, 1987 1988 /* Update or retrieve the settings for a date picker attached to an input field or division. 1989 * @param target element - the target input field or division or span 1990 * @param name object - the new settings to update or 1991 * string - the name of the setting to change or retrieve, 1992 * when retrieving also "all" for all instance settings or 1993 * "defaults" for all global defaults 1994 * @param value any - the new value for the setting 1995 * (omit if above is an object or to retrieve a value) 1996 */ 1997 _optionDatepicker: function(target, name, value) { 1998 var settings, date, minDate, maxDate, 1999 inst = this._getInst(target); 2000 2001 if (arguments.length === 2 && typeof name === "string") { 2002 return (name === "defaults" ? $.extend({}, $.datepicker._defaults) : 2003 (inst ? (name === "all" ? $.extend({}, inst.settings) : 2004 this._get(inst, name)) : null)); 2005 } 2006 2007 settings = name || {}; 2008 if (typeof name === "string") { 2009 settings = {}; 2010 settings[name] = value; 2011 } 2012 2013 if (inst) { 2014 if (this._curInst === inst) { 2015 this._hideDatepicker(); 2016 } 2017 2018 date = this._getDateDatepicker(target, true); 2019 minDate = this._getMinMaxDate(inst, "min"); 2020 maxDate = this._getMinMaxDate(inst, "max"); 2021 datepicker_extendRemove(inst.settings, settings); 2022 // reformat the old minDate/maxDate values if dateFormat changes and a new minDate/maxDate isn't provided 2023 if (minDate !== null && settings.dateFormat !== undefined && settings.minDate === undefined) { 2024 inst.settings.minDate = this._formatDate(inst, minDate); 2025 } 2026 if (maxDate !== null && settings.dateFormat !== undefined && settings.maxDate === undefined) { 2027 inst.settings.maxDate = this._formatDate(inst, maxDate); 2028 } 2029 if ( "disabled" in settings ) { 2030 if ( settings.disabled ) { 2031 this._disableDatepicker(target); 2032 } else { 2033 this._enableDatepicker(target); 2034 } 2035 } 2036 this._attachments($(target), inst); 2037 this._autoSize(inst); 2038 this._setDate(inst, date); 2039 this._updateAlternate(inst); 2040 this._updateDatepicker(inst); 2041 } 2042 }, 2043 2044 // change method deprecated 2045 _changeDatepicker: function(target, name, value) { 2046 this._optionDatepicker(target, name, value); 2047 }, 2048 2049 /* Redraw the date picker attached to an input field or division. 2050 * @param target element - the target input field or division or span 2051 */ 2052 _refreshDatepicker: function(target) { 2053 var inst = this._getInst(target); 2054 if (inst) { 2055 this._updateDatepicker(inst); 2056 } 2057 }, 2058 2059 /* Set the dates for a jQuery selection. 2060 * @param target element - the target input field or division or span 2061 * @param date Date - the new date 2062 */ 2063 _setDateDatepicker: function(target, date) { 2064 var inst = this._getInst(target); 2065 if (inst) { 2066 this._setDate(inst, date); 2067 this._updateDatepicker(inst); 2068 this._updateAlternate(inst); 2069 } 2070 }, 2071 2072 /* Get the date(s) for the first entry in a jQuery selection. 2073 * @param target element - the target input field or division or span 2074 * @param noDefault boolean - true if no default date is to be used 2075 * @return Date - the current date 2076 */ 2077 _getDateDatepicker: function(target, noDefault) { 2078 var inst = this._getInst(target); 2079 if (inst && !inst.inline) { 2080 this._setDateFromField(inst, noDefault); 2081 } 2082 return (inst ? this._getDate(inst) : null); 2083 }, 2084 2085 /* Handle keystrokes. */ 2086 _doKeyDown: function(event) { 2087 var onSelect, dateStr, sel, 2088 inst = $.datepicker._getInst(event.target), 2089 handled = true, 2090 isRTL = inst.dpDiv.is(".ui-datepicker-rtl"); 2091 2092 inst._keyEvent = true; 2093 if ($.datepicker._datepickerShowing) { 2094 switch (event.keyCode) { 2095 case 9: $.datepicker._hideDatepicker(); 2096 handled = false;
vendor: 5,416 bytes, lines 2097-2249
2097 break; // hide on tab out 2098 case 13: sel = $("td." + $.datepicker._dayOverClass + ":not(." + 2099 $.datepicker._currentClass + ")", inst.dpDiv); 2100 if (sel[0]) { 2101 $.datepicker._selectDay(event.target, inst.selectedMonth, inst.selectedYear, sel[0]); 2102 } 2103 2104 onSelect = $.datepicker._get(inst, "onSelect"); 2105 if (onSelect) { 2106 dateStr = $.datepicker._formatDate(inst); 2107 2108 // trigger custom callback 2109 onSelect.apply((inst.input ? inst.input[0] : null), [dateStr, inst]); 2110 } else { 2111 $.datepicker._hideDatepicker(); 2112 } 2113 2114 return false; // don't submit the form 2115 case 27: $.datepicker._hideDatepicker(); 2116 break; // hide on escape 2117 case 33: $.datepicker._adjustDate(event.target, (event.ctrlKey ? 2118 -$.datepicker._get(inst, "stepBigMonths") : 2119 -$.datepicker._get(inst, "stepMonths")), "M"); 2120 break; // previous month/year on page up/+ ctrl 2121 case 34: $.datepicker._adjustDate(event.target, (event.ctrlKey ? 2122 +$.datepicker._get(inst, "stepBigMonths") : 2123 +$.datepicker._get(inst, "stepMonths")), "M"); 2124 break; // next month/year on page down/+ ctrl 2125 case 35: if (event.ctrlKey || event.metaKey) { 2126 $.datepicker._clearDate(event.target); 2127 } 2128 handled = event.ctrlKey || event.metaKey; 2129 break; // clear on ctrl or command +end 2130 case 36: if (event.ctrlKey || event.metaKey) { 2131 $.datepicker._gotoToday(event.target); 2132 } 2133 handled = event.ctrlKey || event.metaKey; 2134 break; // current on ctrl or command +home 2135 case 37: if (event.ctrlKey || event.metaKey) { 2136 $.datepicker._adjustDate(event.target, (isRTL ? +1 : -1), "D"); 2137 } 2138 handled = event.ctrlKey || event.metaKey; 2139 // -1 day on ctrl or command +left 2140 if (event.originalEvent.altKey) { 2141 $.datepicker._adjustDate(event.target, (event.ctrlKey ? 2142 -$.datepicker._get(inst, "stepBigMonths") : 2143 -$.datepicker._get(inst, "stepMonths")), "M"); 2144 } 2145 // next month/year on alt +left on Mac 2146 break; 2147 case 38: if (event.ctrlKey || event.metaKey) { 2148 $.datepicker._adjustDate(event.target, -7, "D"); 2149 } 2150 handled = event.ctrlKey || event.metaKey; 2151 break; // -1 week on ctrl or command +up 2152 case 39: if (event.ctrlKey || event.metaKey) { 2153 $.datepicker._adjustDate(event.target, (isRTL ? -1 : +1), "D"); 2154 } 2155 handled = event.ctrlKey || event.metaKey; 2156 // +1 day on ctrl or command +right 2157 if (event.originalEvent.altKey) { 2158 $.datepicker._adjustDate(event.target, (event.ctrlKey ? 2159 +$.datepicker._get(inst, "stepBigMonths") : 2160 +$.datepicker._get(inst, "stepMonths")), "M"); 2161 } 2162 // next month/year on alt +right 2163 break; 2164 case 40: if (event.ctrlKey || event.metaKey) { 2165 $.datepicker._adjustDate(event.target, +7, "D"); 2166 } 2167 handled = event.ctrlKey || event.metaKey; 2168 break; // +1 week on ctrl or command +down 2169 default: handled = false; 2170 } 2171 } else if (event.keyCode === 36 && event.ctrlKey) { // display the date picker on ctrl+home 2172 $.datepicker._showDatepicker(this); 2173 } else { 2174 handled = false; 2175 } 2176 2177 if (handled) { 2178 event.preventDefault(); 2179 event.stopPropagation(); 2180 } 2181 }, 2182 2183 /* Filter entered characters - based on date format. */ 2184 _doKeyPress: function(event) { 2185 var chars, chr, 2186 inst = $.datepicker._getInst(event.target); 2187 2188 if ($.datepicker._get(inst, "constrainInput")) { 2189 chars = $.datepicker._possibleChars($.datepicker._get(inst, "dateFormat")); 2190 chr = String.fromCharCode(event.charCode == null ? event.keyCode : event.charCode); 2191 return event.ctrlKey || event.metaKey || (chr < " " || !chars || chars.indexOf(chr) > -1); 2192 } 2193 }, 2194 2195 /* Synchronise manual entry and field/alternate field. */ 2196 _doKeyUp: function(event) { 2197 var date, 2198 inst = $.datepicker._getInst(event.target); 2199 2200 if (inst.input.val() !== inst.lastVal) { 2201 try { 2202 date = $.datepicker.parseDate($.datepicker._get(inst, "dateFormat"), 2203 (inst.input ? inst.input.val() : null), 2204 $.datepicker._getFormatConfig(inst)); 2205 2206 if (date) { // only if valid 2207 $.datepicker._setDateFromField(inst); 2208 $.datepicker._updateAlternate(inst); 2209 $.datepicker._updateDatepicker(inst); 2210 } 2211 } 2212 catch (err) { 2213 } 2214 } 2215 return true; 2216 }, 2217 2218 /* Pop-up the date picker for a given input field. 2219 * If false returned from beforeShow event handler do not show. 2220 * @param input element - the input field attached to the date picker or 2221 * event - if triggered by focus 2222 */ 2223 _showDatepicker: function(input) { 2224 input = input.target || input; 2225 if (input.nodeName.toLowerCase() !== "input") { // find from button/image trigger 2226 input = $("input", input.parentNode)[0]; 2227 } 2228 2229 if ($.datepicker._isDisabledDatepicker(input) || $.datepicker._lastInput === input) { // already here 2230 return; 2231 } 2232 2233 var inst, beforeShow, beforeShowSettings, isFixed, 2234 offset, showAnim, duration; 2235 2236 inst = $.datepicker._getInst(input); 2237 if ($.datepicker._curInst && $.datepicker._curInst !== inst) { 2238 $.datepicker._curInst.dpDiv.stop(true, true); 2239 if ( inst && $.datepicker._datepickerShowing ) { 2240 $.datepicker._hideDatepicker( $.datepicker._curInst.input[0] ); 2241 } 2242 } 2243 2244 beforeShow = $.datepicker._get(inst, "beforeShow"); 2245 beforeShowSettings = beforeShow ? beforeShow.apply(input, [input, inst]) : {}; 2246 if(beforeShowSettings === false){ 2247 return; 2248 } 2249
vendor: 3,313 bytes, lines 2249-2343
2249datepicker_extendRemove(inst.settings, beforeShowSettings); 2250 2251 inst.lastVal = null; 2252 $.datepicker._lastInput = input; 2253 $.datepicker._setDateFromField(inst); 2254 2255 if ($.datepicker._inDialog) { // hide cursor 2256 input.value = ""; 2257 } 2258 if (!$.datepicker._pos) { // position below input 2259 $.datepicker._pos = $.datepicker._findPos(input); 2260 $.datepicker._pos[1] += input.offsetHeight; // add the height 2261 } 2262 2263 isFixed = false; 2264 $(input).parents().each(function() { 2265 isFixed |= $(this).css("position") === "fixed"; 2266 return !isFixed; 2267 }); 2268 2269 offset = {left: $.datepicker._pos[0], top: $.datepicker._pos[1]}; 2270 $.datepicker._pos = null; 2271 //to avoid flashes on Firefox 2272 inst.dpDiv.empty(); 2273 // determine sizing offscreen 2274 inst.dpDiv.css({position: "absolute", display: "block", top: "-1000px"}); 2275 $.datepicker._updateDatepicker(inst); 2276 // fix width for dynamic number of date pickers 2277 // and adjust position before showing 2278 offset = $.datepicker._checkOffset(inst, offset, isFixed); 2279 inst.dpDiv.css({position: ($.datepicker._inDialog && $.blockUI ? 2280 "static" : (isFixed ? "fixed" : "absolute")), display: "none", 2281 left: offset.left + "px", top: offset.top + "px"}); 2282 2283 if (!inst.inline) { 2284 showAnim = $.datepicker._get(inst, "showAnim"); 2285 duration = $.datepicker._get(inst, "duration"); 2286 inst.dpDiv.css( "z-index", datepicker_getZindex( $( input ) ) + 1 ); 2287 $.datepicker._datepickerShowing = true; 2288 2289 if ( $.effects && $.effects.effect[ showAnim ] ) { 2290 inst.dpDiv.show(showAnim, $.datepicker._get(inst, "showOptions"), duration); 2291 } else { 2292 inst.dpDiv[showAnim || "show"](showAnim ? duration : null); 2293 } 2294 2295 if ( $.datepicker._shouldFocusInput( inst ) ) { 2296 inst.input.focus(); 2297 } 2298 2299 $.datepicker._curInst = inst; 2300 } 2301 }, 2302 2303 /* Generate the date picker content. */ 2304 _updateDatepicker: function(inst) { 2305 this.maxRows = 4; //Reset the max number of rows being displayed (see #7043) 2306 datepicker_instActive = inst; // for delegate hover events 2307 inst.dpDiv.empty().append(this._generateHTML(inst)); 2308 this._attachHandlers(inst); 2309 inst.dpDiv.find("." + this._dayOverClass + " a"); 2310 2311 var origyearshtml, 2312 numMonths = this._getNumberOfMonths(inst), 2313 cols = numMonths[1], 2314 width = 17; 2315 2316 inst.dpDiv.removeClass("ui-datepicker-multi-2 ui-datepicker-multi-3 ui-datepicker-multi-4").width(""); 2317 if (cols > 1) { 2318 inst.dpDiv.addClass("ui-datepicker-multi-" + cols).css("width", (width * cols) + "em"); 2319 } 2320 inst.dpDiv[(numMonths[0] !== 1 || numMonths[1] !== 1 ? "add" : "remove") + 2321 "Class"]("ui-datepicker-multi"); 2322 inst.dpDiv[(this._get(inst, "isRTL") ? "add" : "remove") + 2323 "Class"]("ui-datepicker-rtl"); 2324 2325 if (inst === $.datepicker._curInst && $.datepicker._datepickerShowing && $.datepicker._shouldFocusInput( inst ) ) { 2326 inst.input.focus(); 2327 } 2328 2329 // deffered render of the years select (to avoid flashes on Firefox) 2330 if( inst.yearshtml ){ 2331 origyearshtml = inst.yearshtml; 2332 setTimeout(function(){ 2333 //assure that inst.yearshtml didn't change. 2334 if( origyearshtml === inst.yearshtml && inst.yearshtml ){ 2335 inst.dpDiv.find("select.ui-datepicker-year:first").replaceWith(inst.yearshtml); 2336 } 2337 origyearshtml = inst.yearshtml = null; 2338 }, 0); 2339 } 2340 }, 2341 2342 // #6694 - don't focus the input if it's already focused 2343 // this breaks the change event in IE
vendor: 2,062 bytes, lines 2344-2392
2344 // Support: IE and jQuery <1.9 2345 _shouldFocusInput: function( inst ) { 2346 return inst.input && inst.input.is( ":visible" ) && !inst.input.is( ":disabled" ) && !inst.input.is( ":focus" ); 2347 }, 2348 2349 /* Check positioning to remain on screen. */ 2350 _checkOffset: function(inst, offset, isFixed) { 2351 var dpWidth = inst.dpDiv.outerWidth(), 2352 dpHeight = inst.dpDiv.outerHeight(), 2353 inputWidth = inst.input ? inst.input.outerWidth() : 0, 2354 inputHeight = inst.input ? inst.input.outerHeight() : 0, 2355 viewWidth = document.documentElement.clientWidth + (isFixed ? 0 : $(document).scrollLeft()), 2356 viewHeight = document.documentElement.clientHeight + (isFixed ? 0 : $(document).scrollTop()); 2357 2358 offset.left -= (this._get(inst, "isRTL") ? (dpWidth - inputWidth) : 0); 2359 offset.left -= (isFixed && offset.left === inst.input.offset().left) ? $(document).scrollLeft() : 0; 2360 offset.top -= (isFixed && offset.top === (inst.input.offset().top + inputHeight)) ? $(document).scrollTop() : 0; 2361 2362 // now check if datepicker is showing outside window viewport - move to a better place if so. 2363 offset.left -= Math.min(offset.left, (offset.left + dpWidth > viewWidth && viewWidth > dpWidth) ? 2364 Math.abs(offset.left + dpWidth - viewWidth) : 0); 2365 offset.top -= Math.min(offset.top, (offset.top + dpHeight > viewHeight && viewHeight > dpHeight) ? 2366 Math.abs(dpHeight + inputHeight) : 0); 2367 2368 return offset; 2369 }, 2370 2371 /* Find an object's position on the screen. */ 2372 _findPos: function(obj) { 2373 var position, 2374 inst = this._getInst(obj), 2375 isRTL = this._get(inst, "isRTL"); 2376 2377 while (obj && (obj.type === "hidden" || obj.nodeType !== 1 || $.expr.filters.hidden(obj))) { 2378 obj = obj[isRTL ? "previousSibling" : "nextSibling"]; 2379 } 2380 2381 position = $(obj).offset(); 2382 return [position.left, position.top]; 2383 }, 2384 2385 /* Hide the date picker from view. 2386 * @param input element - the input field attached to the date picker 2387 */ 2388 _hideDatepicker: function(input) { 2389 var showAnim, duration, postProcess, onClose, 2390 inst = this._curInst; 2391 2392 if (!inst || (input && inst !== $.data(input, "datepicker"
vendor: 28,231 bytes, lines 2392-3232
2392))) { 2393 return; 2394 } 2395 2396 if (this._datepickerShowing) { 2397 showAnim = this._get(inst, "showAnim"); 2398 duration = this._get(inst, "duration"); 2399 postProcess = function() { 2400 $.datepicker._tidyDialog(inst); 2401 }; 2402 2403 // DEPRECATED: after BC for 1.8.x $.effects[ showAnim ] is not needed 2404 if ( $.effects && ( $.effects.effect[ showAnim ] || $.effects[ showAnim ] ) ) { 2405 inst.dpDiv.hide(showAnim, $.datepicker._get(inst, "showOptions"), duration, postProcess); 2406 } else { 2407 inst.dpDiv[(showAnim === "slideDown" ? "slideUp" : 2408 (showAnim === "fadeIn" ? "fadeOut" : "hide"))]((showAnim ? duration : null), postProcess); 2409 } 2410 2411 if (!showAnim) { 2412 postProcess(); 2413 } 2414 this._datepickerShowing = false; 2415 2416 onClose = this._get(inst, "onClose"); 2417 if (onClose) { 2418 onClose.apply((inst.input ? inst.input[0] : null), [(inst.input ? inst.input.val() : ""), inst]); 2419 } 2420 2421 this._lastInput = null; 2422 if (this._inDialog) { 2423 this._dialogInput.css({ position: "absolute", left: "0", top: "-100px" }); 2424 if ($.blockUI) { 2425 $.unblockUI(); 2426 $("body").append(this.dpDiv); 2427 } 2428 } 2429 this._inDialog = false; 2430 } 2431 }, 2432 2433 /* Tidy up after a dialog display. */ 2434 _tidyDialog: function(inst) { 2435 inst.dpDiv.removeClass(this._dialogClass).unbind(".ui-datepicker-calendar"); 2436 }, 2437 2438 /* Close date picker if clicked elsewhere. */ 2439 _checkExternalClick: function(event) { 2440 if (!$.datepicker._curInst) { 2441 return; 2442 } 2443 2444 var $target = $(event.target), 2445 inst = $.datepicker._getInst($target[0]); 2446 2447 if ( ( ( $target[0].id !== $.datepicker._mainDivId && 2448 $target.parents("#" + $.datepicker._mainDivId).length === 0 && 2449 !$target.hasClass($.datepicker.markerClassName) && 2450 !$target.closest("." + $.datepicker._triggerClass).length && 2451 $.datepicker._datepickerShowing && !($.datepicker._inDialog && $.blockUI) ) ) || 2452 ( $target.hasClass($.datepicker.markerClassName) && $.datepicker._curInst !== inst ) ) { 2453 $.datepicker._hideDatepicker(); 2454 } 2455 }, 2456 2457 /* Adjust one of the date sub-fields. */ 2458 _adjustDate: function(id, offset, period) { 2459 var target = $(id), 2460 inst = this._getInst(target[0]); 2461 2462 if (this._isDisabledDatepicker(target[0])) { 2463 return; 2464 } 2465 this._adjustInstDate(inst, offset + 2466 (period === "M" ? this._get(inst, "showCurrentAtPos") : 0), // undo positioning 2467 period); 2468 this._updateDatepicker(inst); 2469 }, 2470 2471 /* Action for current link. */ 2472 _gotoToday: function(id) { 2473 var date, 2474 target = $(id), 2475 inst = this._getInst(target[0]); 2476 2477 if (this._get(inst, "gotoCurrent") && inst.currentDay) { 2478 inst.selectedDay = inst.currentDay; 2479 inst.drawMonth = inst.selectedMonth = inst.currentMonth; 2480 inst.drawYear = inst.selectedYear = inst.currentYear; 2481 } else { 2482 date = new Date(); 2483 inst.selectedDay = date.getDate(); 2484 inst.drawMonth = inst.selectedMonth = date.getMonth(); 2485 inst.drawYear = inst.selectedYear = date.getFullYear(); 2486 } 2487 this._notifyChange(inst); 2488 this._adjustDate(target); 2489 }, 2490 2491 /* Action for selecting a new month/year. */ 2492 _selectMonthYear: function(id, select, period) { 2493 var target = $(id), 2494 inst = this._getInst(target[0]); 2495 2496 inst["selected" + (period === "M" ? "Month" : "Year")] = 2497 inst["draw" + (period === "M" ? "Month" : "Year")] = 2498 parseInt(select.options[select.selectedIndex].value,10); 2499 2500 this._notifyChange(inst); 2501 this._adjustDate(target); 2502 }, 2503 2504 /* Action for selecting a day. */ 2505 _selectDay: function(id, month, year, td) { 2506 var inst, 2507 target = $(id); 2508 2509 if ($(td).hasClass(this._unselectableClass) || this._isDisabledDatepicker(target[0])) { 2510 return; 2511 } 2512 2513 inst = this._getInst(target[0]); 2514 inst.selectedDay = inst.currentDay = $("a", td).html(); 2515 inst.selectedMonth = inst.currentMonth = month; 2516 inst.selectedYear = inst.currentYear = year; 2517 this._selectDate(id, this._formatDate(inst, 2518 inst.currentDay, inst.currentMonth, inst.currentYear)); 2519 }, 2520 2521 /* Erase the input field and hide the date picker. */ 2522 _clearDate: function(id) { 2523 var target = $(id); 2524 this._selectDate(target, ""); 2525 }, 2526 2527 /* Update the input field with the selected date. */ 2528 _selectDate: function(id, dateStr) { 2529 var onSelect, 2530 target = $(id), 2531 inst = this._getInst(target[0]); 2532 2533 dateStr = (dateStr != null ? dateStr : this._formatDate(inst)); 2534 if (inst.input) { 2535 inst.input.val(dateStr); 2536 } 2537 this._updateAlternate(inst); 2538 2539 onSelect = this._get(inst, "onSelect"); 2540 if (onSelect) { 2541 onSelect.apply((inst.input ? inst.input[0] : null), [dateStr, inst]); // trigger custom callback 2542 } else if (inst.input) { 2543 inst.input.trigger("change"); // fire the change event 2544 } 2545 2546 if (inst.inline){ 2547 this._updateDatepicker(inst); 2548 } else { 2549 this._hideDatepicker(); 2550 this._lastInput = inst.input[0]; 2551 if (typeof(inst.input[0]) !== "object") { 2552 inst.input.focus(); // restore focus 2553 } 2554 this._lastInput = null; 2555 } 2556 }, 2557 2558 /* Update any alternate field to synchronise with the main field. */ 2559 _updateAlternate: function(inst) { 2560 var altFormat, date, dateStr, 2561 altField = this._get(inst, "altField"); 2562 2563 if (altField) { // update alternate field too 2564 altFormat = this._get(inst, "altFormat") || this._get(inst, "dateFormat"); 2565 date = this._getDate(inst); 2566 dateStr = this.formatDate(altFormat, date, this._getFormatConfig(inst)); 2567 $(altField).each(function() { $(this).val(dateStr); }); 2568 } 2569 }, 2570 2571 /* Set as beforeShowDay function to prevent selection of weekends. 2572 * @param date Date - the date to customise 2573 * @return [boolean, string] - is this date selectable?, what is its CSS class? 2574 */ 2575 noWeekends: function(date) { 2576 var day = date.getDay(); 2577 return [(day > 0 && day < 6), ""]; 2578 }, 2579 2580 /* Set as calculateWeek to determine the week of the year based on the ISO 8601 definition. 2581 * @param date Date - the date to get the week for 2582 * @return number - the number of the week within the year that contains this date 2583 */ 2584 iso8601Week: function(date) { 2585 var time, 2586 checkDate = new Date(date.getTime()); 2587 2588 // Find Thursday of this week starting on Monday 2589 checkDate.setDate(checkDate.getDate() + 4 - (checkDate.getDay() || 7)); 2590 2591 time = checkDate.getTime(); 2592 checkDate.setMonth(0); // Compare with Jan 1 2593 checkDate.setDate(1); 2594 return Math.floor(Math.round((time - checkDate) / 86400000) / 7) + 1; 2595 }, 2596 2597 /* Parse a string value into a date object. 2598 * See formatDate below for the possible formats. 2599 * 2600 * @param format string - the expected format of the date 2601 * @param value string - the date in the above format 2602 * @param settings Object - attributes include: 2603 * shortYearCutoff number - the cutoff year for determining the century (optional) 2604 * dayNamesShort string[7] - abbreviated names of the days from Sunday (optional) 2605 * dayNames string[7] - names of the days from Sunday (optional) 2606 * monthNamesShort string[12] - abbreviated names of the months (optional) 2607 * monthNames string[12] - names of the months (optional) 2608 * @return Date - the extracted date value or null if value is blank 2609 */ 2610 parseDate: function (format, value, settings) { 2611 if (format == null || value == null) { 2612 throw "Invalid arguments"; 2613 } 2614 2615 value = (typeof value === "object" ? value.toString() : value + ""); 2616 if (value === "") { 2617 return null; 2618 } 2619 2620 var iFormat, dim, extra, 2621 iValue = 0, 2622 shortYearCutoffTemp = (settings ? settings.shortYearCutoff : null) || this._defaults.shortYearCutoff, 2623 shortYearCutoff = (typeof shortYearCutoffTemp !== "string" ? shortYearCutoffTemp : 2624 new Date().getFullYear() % 100 + parseInt(shortYearCutoffTemp, 10)), 2625 dayNamesShort = (settings ? settings.dayNamesShort : null) || this._defaults.dayNamesShort, 2626 dayNames = (settings ? settings.dayNames : null) || this._defaults.dayNames, 2627 monthNamesShort = (settings ? settings.monthNamesShort : null) || this._defaults.monthNamesShort, 2628 monthNames = (settings ? settings.monthNames : null) || this._defaults.monthNames, 2629 year = -1, 2630 month = -1, 2631 day = -1, 2632 doy = -1, 2633 literal = false, 2634 date, 2635 // Check whether a format character is doubled 2636 lookAhead = function(match) { 2637 var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) === match); 2638 if (matches) { 2639 iFormat++; 2640 } 2641 return matches; 2642 }, 2643 // Extract a number from the string value 2644 getNumber = function(match) { 2645 var isDoubled = lookAhead(match), 2646 size = (match === "@" ? 14 : (match === "!" ? 20 : 2647 (match === "y" && isDoubled ? 4 : (match === "o" ? 3 : 2)))), 2648 digits = new RegExp("^\\d{1," + size + "}"), 2649 num = value.substring(iValue).match(digits); 2650 if (!num) { 2651 throw "Missing number at position " + iValue; 2652 } 2653 iValue += num[0].length; 2654 return parseInt(num[0], 10); 2655 }, 2656 // Extract a name from the string value and convert to an index 2657 getName = function(match, shortNames, longNames) { 2658 var index = -1, 2659 names = $.map(lookAhead(match) ? longNames : shortNames, function (v, k) { 2660 return [ [k, v] ]; 2661 }).sort(function (a, b) { 2662 return -(a[1].length - b[1].length); 2663 }); 2664 2665 $.each(names, function (i, pair) { 2666 var name = pair[1]; 2667 if (value.substr(iValue, name.length).toLowerCase() === name.toLowerCase()) { 2668 index = pair[0]; 2669 iValue += name.length; 2670 return false; 2671 } 2672 }); 2673 if (index !== -1) { 2674 return index + 1; 2675 } else { 2676 throw "Unknown name at position " + iValue; 2677 } 2678 }, 2679 // Confirm that a literal character matches the string value 2680 checkLiteral = function() { 2681 if (value.charAt(iValue) !== format.charAt(iFormat)) { 2682 throw "Unexpected literal at position " + iValue; 2683 } 2684 iValue++; 2685 }; 2686 2687 for (iFormat = 0; iFormat < format.length; iFormat++) { 2688 if (literal) { 2689 if (format.charAt(iFormat) === "'" && !lookAhead("'")) { 2690 literal = false; 2691 } else { 2692 checkLiteral(); 2693 } 2694 } else { 2695 switch (format.charAt(iFormat)) { 2696 case "d": 2697 day = getNumber("d"); 2698 break; 2699 case "D": 2700 getName("D", dayNamesShort, dayNames); 2701 break; 2702 case "o": 2703 doy = getNumber("o"); 2704 break; 2705 case "m": 2706 month = getNumber("m"); 2707 break; 2708 case "M": 2709 month = getName("M", monthNamesShort, monthNames); 2710 break; 2711 case "y": 2712 year = getNumber("y"); 2713 break; 2714 case "@": 2715 date = new Date(getNumber("@")); 2716 year = date.getFullYear(); 2717 month = date.getMonth() + 1; 2718 day = date.getDate(); 2719 break; 2720 case "!": 2721 date = new Date((getNumber("!") - this._ticksTo1970) / 10000); 2722 year = date.getFullYear(); 2723 month = date.getMonth() + 1; 2724 day = date.getDate(); 2725 break; 2726 case "'": 2727 if (lookAhead("'")){ 2728 checkLiteral(); 2729 } else { 2730 literal = true; 2731 } 2732 break; 2733 default: 2734 checkLiteral(); 2735 } 2736 } 2737 } 2738 2739 if (iValue < value.length){ 2740 extra = value.substr(iValue); 2741 if (!/^\s+/.test(extra)) { 2742 throw "Extra/unparsed characters found in date: " + extra; 2743 } 2744 } 2745 2746 if (year === -1) { 2747 year = new Date().getFullYear(); 2748 } else if (year < 100) { 2749 year += new Date().getFullYear() - new Date().getFullYear() % 100 + 2750 (year <= shortYearCutoff ? 0 : -100); 2751 } 2752 2753 if (doy > -1) { 2754 month = 1; 2755 day = doy; 2756 do { 2757 dim = this._getDaysInMonth(year, month - 1); 2758 if (day <= dim) { 2759 break; 2760 } 2761 month++; 2762 day -= dim; 2763 } while (true); 2764 } 2765 2766 date = this._daylightSavingAdjust(new Date(year, month - 1, day)); 2767 if (date.getFullYear() !== year || date.getMonth() + 1 !== month || date.getDate() !== day) { 2768 throw "Invalid date"; // E.g. 31/02/00 2769 } 2770 return date; 2771 }, 2772 2773 /* Standard date formats. */ 2774 ATOM: "yy-mm-dd", // RFC 3339 (ISO 8601) 2775 COOKIE: "D, dd M yy", 2776 ISO_8601: "yy-mm-dd", 2777 RFC_822: "D, d M y", 2778 RFC_850: "DD, dd-M-y", 2779 RFC_1036: "D, d M y", 2780 RFC_1123: "D, d M yy", 2781 RFC_2822: "D, d M yy", 2782 RSS: "D, d M y", // RFC 822 2783 TICKS: "!", 2784 TIMESTAMP: "@", 2785 W3C: "yy-mm-dd", // ISO 8601 2786 2787 _ticksTo1970: (((1970 - 1) * 365 + Math.floor(1970 / 4) - Math.floor(1970 / 100) + 2788 Math.floor(1970 / 400)) * 24 * 60 * 60 * 10000000), 2789 2790 /* Format a date object into a string value. 2791 * The format can be combinations of the following: 2792 * d - day of month (no leading zero) 2793 * dd - day of month (two digit) 2794 * o - day of year (no leading zeros) 2795 * oo - day of year (three digit) 2796 * D - day name short 2797 * DD - day name long 2798 * m - month of year (no leading zero) 2799 * mm - month of year (two digit) 2800 * M - month name short 2801 * MM - month name long 2802 * y - year (two digit) 2803 * yy - year (four digit) 2804 * @ - Unix timestamp (ms since 01/01/1970) 2805 * ! - Windows ticks (100ns since 01/01/0001) 2806 * "..." - literal text 2807 * '' - single quote 2808 * 2809 * @param format string - the desired format of the date 2810 * @param date Date - the date value to format 2811 * @param settings Object - attributes include: 2812 * dayNamesShort string[7] - abbreviated names of the days from Sunday (optional) 2813 * dayNames string[7] - names of the days from Sunday (optional) 2814 * monthNamesShort string[12] - abbreviated names of the months (optional) 2815 * monthNames string[12] - names of the months (optional) 2816 * @return string - the date in the above format 2817 */ 2818 formatDate: function (format, date, settings) { 2819 if (!date) { 2820 return ""; 2821 } 2822 2823 var iFormat, 2824 dayNamesShort = (settings ? settings.dayNamesShort : null) || this._defaults.dayNamesShort, 2825 dayNames = (settings ? settings.dayNames : null) || this._defaults.dayNames, 2826 monthNamesShort = (settings ? settings.monthNamesShort : null) || this._defaults.monthNamesShort, 2827 monthNames = (settings ? settings.monthNames : null) || this._defaults.monthNames, 2828 // Check whether a format character is doubled 2829 lookAhead = function(match) { 2830 var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) === match); 2831 if (matches) { 2832 iFormat++; 2833 } 2834 return matches; 2835 }, 2836 // Format a number, with leading zero if necessary 2837 formatNumber = function(match, value, len) { 2838 var num = "" + value; 2839 if (lookAhead(match)) { 2840 while (num.length < len) { 2841 num = "0" + num; 2842 } 2843 } 2844 return num; 2845 }, 2846 // Format a name, short or long as requested 2847 formatName = function(match, value, shortNames, longNames) { 2848 return (lookAhead(match) ? longNames[value] : shortNames[value]); 2849 }, 2850 output = "", 2851 literal = false; 2852 2853 if (date) { 2854 for (iFormat = 0; iFormat < format.length; iFormat++) { 2855 if (literal) { 2856 if (format.charAt(iFormat) === "'" && !lookAhead("'")) { 2857 literal = false; 2858 } else { 2859 output += format.charAt(iFormat); 2860 } 2861 } else { 2862 switch (format.charAt(iFormat)) { 2863 case "d": 2864 output += formatNumber("d", date.getDate(), 2); 2865 break; 2866 case "D": 2867 output += formatName("D", date.getDay(), dayNamesShort, dayNames); 2868 break; 2869 case "o": 2870 output += formatNumber("o", 2871 Math.round((new Date(date.getFullYear(), date.getMonth(), date.getDate()).getTime() - new Date(date.getFullYear(), 0, 0).getTime()) / 86400000), 3); 2872 break; 2873 case "m": 2874 output += formatNumber("m", date.getMonth() + 1, 2); 2875 break; 2876 case "M": 2877 output += formatName("M", date.getMonth(), monthNamesShort, monthNames); 2878 break; 2879 case "y": 2880 output += (lookAhead("y") ? date.getFullYear() : 2881 (date.getYear() % 100 < 10 ? "0" : "") + date.getYear() % 100); 2882 break; 2883 case "@": 2884 output += date.getTime(); 2885 break; 2886 case "!": 2887 output += date.getTime() * 10000 + this._ticksTo1970; 2888 break; 2889 case "'": 2890 if (lookAhead("'")) { 2891 output += "'"; 2892 } else { 2893 literal = true; 2894 } 2895 break; 2896 default: 2897 output += format.charAt(iFormat); 2898 } 2899 } 2900 } 2901 } 2902 return output; 2903 }, 2904 2905 /* Extract all possible characters from the date format. */ 2906 _possibleChars: function (format) { 2907 var iFormat, 2908 chars = "", 2909 literal = false, 2910 // Check whether a format character is doubled 2911 lookAhead = function(match) { 2912 var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) === match); 2913 if (matches) { 2914 iFormat++; 2915 } 2916 return matches; 2917 }; 2918 2919 for (iFormat = 0; iFormat < format.length; iFormat++) { 2920 if (literal) { 2921 if (format.charAt(iFormat) === "'" && !lookAhead("'")) { 2922 literal = false; 2923 } else { 2924 chars += format.charAt(iFormat); 2925 } 2926 } else { 2927 switch (format.charAt(iFormat)) { 2928 case "d": case "m": case "y": case "@": 2929 chars += "0123456789"; 2930 break; 2931 case "D": case "M": 2932 return null; // Accept anything 2933 case "'": 2934 if (lookAhead("'")) { 2935 chars += "'"; 2936 } else { 2937 literal = true; 2938 } 2939 break; 2940 default: 2941 chars += format.charAt(iFormat); 2942 } 2943 } 2944 } 2945 return chars; 2946 }, 2947 2948 /* Get a setting value, defaulting if necessary. */ 2949 _get: function(inst, name) { 2950 return inst.settings[name] !== undefined ? 2951 inst.settings[name] : this._defaults[name]; 2952 }, 2953 2954 /* Parse existing date and initialise date picker. */ 2955 _setDateFromField: function(inst, noDefault) { 2956 if (inst.input.val() === inst.lastVal) { 2957 return; 2958 } 2959 2960 var dateFormat = this._get(inst, "dateFormat"), 2961 dates = inst.lastVal = inst.input ? inst.input.val() : null, 2962 defaultDate = this._getDefaultDate(inst), 2963 date = defaultDate, 2964 settings = this._getFormatConfig(inst); 2965 2966 try { 2967 date = this.parseDate(dateFormat, dates, settings) || defaultDate; 2968 } catch (event) { 2969 dates = (noDefault ? "" : dates); 2970 } 2971 inst.selectedDay = date.getDate(); 2972 inst.drawMonth = inst.selectedMonth = date.getMonth(); 2973 inst.drawYear = inst.selectedYear = date.getFullYear(); 2974 inst.currentDay = (dates ? date.getDate() : 0); 2975 inst.currentMonth = (dates ? date.getMonth() : 0); 2976 inst.currentYear = (dates ? date.getFullYear() : 0); 2977 this._adjustInstDate(inst); 2978 }, 2979 2980 /* Retrieve the default date shown on opening. */ 2981 _getDefaultDate: function(inst) { 2982 return this._restrictMinMax(inst, 2983 this._determineDate(inst, this._get(inst, "defaultDate"), new Date())); 2984 }, 2985 2986 /* A date may be specified as an exact value or a relative one. */ 2987 _determineDate: function(inst, date, defaultDate) { 2988 var offsetNumeric = function(offset) { 2989 var date = new Date(); 2990 date.setDate(date.getDate() + offset); 2991 return date; 2992 }, 2993 offsetString = function(offset) { 2994 try { 2995 return $.datepicker.parseDate($.datepicker._get(inst, "dateFormat"), 2996 offset, $.datepicker._getFormatConfig(inst)); 2997 } 2998 catch (e) { 2999 // Ignore 3000 } 3001 3002 var date = (offset.toLowerCase().match(/^c/) ? 3003 $.datepicker._getDate(inst) : null) || new Date(), 3004 year = date.getFullYear(), 3005 month = date.getMonth(), 3006 day = date.getDate(), 3007 pattern = /([+\-]?[0-9]+)\s*(d|D|w|W|m|M|y|Y)?/g, 3008 matches = pattern.exec(offset); 3009 3010 while (matches) { 3011 switch (matches[2] || "d") { 3012 case "d" : case "D" : 3013 day += parseInt(matches[1],10); break; 3014 case "w" : case "W" : 3015 day += parseInt(matches[1],10) * 7; break; 3016 case "m" : case "M" : 3017 month += parseInt(matches[1],10); 3018 day = Math.min(day, $.datepicker._getDaysInMonth(year, month)); 3019 break; 3020 case "y": case "Y" : 3021 year += parseInt(matches[1],10); 3022 day = Math.min(day, $.datepicker._getDaysInMonth(year, month)); 3023 break; 3024 } 3025 matches = pattern.exec(offset); 3026 } 3027 return new Date(year, month, day); 3028 }, 3029 newDate = (date == null || date === "" ? defaultDate : (typeof date === "string" ? offsetString(date) : 3030 (typeof date === "number" ? (isNaN(date) ? defaultDate : offsetNumeric(date)) : new Date(date.getTime())))); 3031 3032 newDate = (newDate && newDate.toString() === "Invalid Date" ? defaultDate : newDate); 3033 if (newDate) { 3034 newDate.setHours(0); 3035 newDate.setMinutes(0); 3036 newDate.setSeconds(0); 3037 newDate.setMilliseconds(0); 3038 } 3039 return this._daylightSavingAdjust(newDate); 3040 }, 3041 3042 /* Handle switch to/from daylight saving. 3043 * Hours may be non-zero on daylight saving cut-over: 3044 * > 12 when midnight changeover, but then cannot generate 3045 * midnight datetime, so jump to 1AM, otherwise reset. 3046 * @param date (Date) the date to check 3047 * @return (Date) the corrected date 3048 */ 3049 _daylightSavingAdjust: function(date) { 3050 if (!date) { 3051 return null; 3052 } 3053 date.setHours(date.getHours() > 12 ? date.getHours() + 2 : 0); 3054 return date; 3055 }, 3056 3057 /* Set the date(s) directly. */ 3058 _setDate: function(inst, date, noChange) { 3059 var clear = !date, 3060 origMonth = inst.selectedMonth, 3061 origYear = inst.selectedYear, 3062 newDate = this._restrictMinMax(inst, this._determineDate(inst, date, new Date())); 3063 3064 inst.selectedDay = inst.currentDay = newDate.getDate(); 3065 inst.drawMonth = inst.selectedMonth = inst.currentMonth = newDate.getMonth(); 3066 inst.drawYear = inst.selectedYear = inst.currentYear = newDate.getFullYear(); 3067 if ((origMonth !== inst.selectedMonth || origYear !== inst.selectedYear) && !noChange) { 3068 this._notifyChange(inst); 3069 } 3070 this._adjustInstDate(inst); 3071 if (inst.input) { 3072 inst.input.val(clear ? "" : this._formatDate(inst)); 3073 } 3074 }, 3075 3076 /* Retrieve the date(s) directly. */ 3077 _getDate: function(inst) { 3078 var startDate = (!inst.currentYear || (inst.input && inst.input.val() === "") ? null : 3079 this._daylightSavingAdjust(new Date( 3080 inst.currentYear, inst.currentMonth, inst.currentDay))); 3081 return startDate; 3082 }, 3083 3084 /* Attach the onxxx handlers. These are declared statically so 3085 * they work with static code transformers like Caja. 3086 */ 3087 _attachHandlers: function(inst) { 3088 var stepMonths = this._get(inst, "stepMonths"), 3089 id = "#" + inst.id.replace( /\\\\/g, "\\" ); 3090 inst.dpDiv.find("[data-handler]").map(function () { 3091 var handler = { 3092 prev: function () { 3093 $.datepicker._adjustDate(id, -stepMonths, "M"); 3094 }, 3095 next: function () { 3096 $.datepicker._adjustDate(id, +stepMonths, "M"); 3097 }, 3098 hide: function () { 3099 $.datepicker._hideDatepicker(); 3100 }, 3101 today: function () { 3102 $.datepicker._gotoToday(id); 3103 }, 3104 selectDay: function () { 3105 $.datepicker._selectDay(id, +this.getAttribute("data-month"), +this.getAttribute("data-year"), this); 3106 return false; 3107 }, 3108 selectMonth: function () { 3109 $.datepicker._selectMonthYear(id, this, "M"); 3110 return false; 3111 }, 3112 selectYear: function () { 3113 $.datepicker._selectMonthYear(id, this, "Y"); 3114 return false; 3115 } 3116 }; 3117 $(this).bind(this.getAttribute("data-event"), handler[this.getAttribute("data-handler")]); 3118 }); 3119 }, 3120 3121 /* Generate the HTML for the current state of the date picker. */ 3122 _generateHTML: function(inst) { 3123 var maxDraw, prevText, prev, nextText, next, currentText, gotoDate, 3124 controls, buttonPanel, firstDay, showWeek, dayNames, dayNamesMin, 3125 monthNames, monthNamesShort, beforeShowDay, showOtherMonths, 3126 selectOtherMonths, defaultDate, html, dow, row, group, col, selectedDate, 3127 cornerClass, calender, thead, day, daysInMonth, leadDays, curRows, numRows, 3128 printDate, dRow, tbody, daySettings, otherMonth, unselectable, 3129 tempDate = new Date(), 3130 today = this._daylightSavingAdjust( 3131 new Date(tempDate.getFullYear(), tempDate.getMonth(), tempDate.getDate())), // clear time 3132 isRTL = this._get(inst, "isRTL"), 3133 showButtonPanel = this._get(inst, "showButtonPanel"), 3134 hideIfNoPrevNext = this._get(inst, "hideIfNoPrevNext"), 3135 navigationAsDateFormat = this._get(inst, "navigationAsDateFormat"), 3136 numMonths = this._getNumberOfMonths(inst), 3137 showCurrentAtPos = this._get(inst, "showCurrentAtPos"), 3138 stepMonths = this._get(inst, "stepMonths"), 3139 isMultiMonth = (numMonths[0] !== 1 || numMonths[1] !== 1), 3140 currentDate = this._daylightSavingAdjust((!inst.currentDay ? new Date(9999, 9, 9) : 3141 new Date(inst.currentYear, inst.currentMonth, inst.currentDay))), 3142 minDate = this._getMinMaxDate(inst, "min"), 3143 maxDate = this._getMinMaxDate(inst, "max"), 3144 drawMonth = inst.drawMonth - showCurrentAtPos, 3145 drawYear = inst.drawYear; 3146 3147 if (drawMonth < 0) { 3148 drawMonth += 12; 3149 drawYear--; 3150 } 3151 if (maxDate) { 3152 maxDraw = this._daylightSavingAdjust(new Date(maxDate.getFullYear(), 3153 maxDate.getMonth() - (numMonths[0] * numMonths[1]) + 1, maxDate.getDate())); 3154 maxDraw = (minDate && maxDraw < minDate ? minDate : maxDraw); 3155 while (this._daylightSavingAdjust(new Date(drawYear, drawMonth, 1)) > maxDraw) { 3156 drawMonth--; 3157 if (drawMonth < 0) { 3158 drawMonth = 11; 3159 drawYear--; 3160 } 3161 } 3162 } 3163 inst.drawMonth = drawMonth; 3164 inst.drawYear = drawYear; 3165 3166 prevText = this._get(inst, "prevText"); 3167 prevText = (!navigationAsDateFormat ? prevText : this.formatDate(prevText, 3168 this._daylightSavingAdjust(new Date(drawYear, drawMonth - stepMonths, 1)), 3169 this._getFormatConfig(inst))); 3170 3171 prev = (this._canAdjustMonth(inst, -1, drawYear, drawMonth) ? 3172 "<a class='ui-datepicker-prev ui-corner-all' data-handler='prev' data-event='click'" + 3173 " title='" + prevText + "'><span class='ui-icon ui-icon-circle-triangle-" + ( isRTL ? "e" : "w") + "'>" + prevText + "</span></a>" : 3174 (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>")); 3175 3176 nextText = this._get(inst, "nextText"); 3177 nextText = (!navigationAsDateFormat ? nextText : this.formatDate(nextText, 3178 this._daylightSavingAdjust(new Date(drawYear, drawMonth + stepMonths, 1)), 3179 this._getFormatConfig(inst))); 3180 3181 next = (this._canAdjustMonth(inst, +1, drawYear, drawMonth) ? 3182 "<a class='ui-datepicker-next ui-corner-all' data-handler='next' data-event='click'" + 3183 " title='" + nextText + "'><span class='ui-icon ui-icon-circle-triangle-" + ( isRTL ? "w" : "e") + "'>" + nextText + "</span></a>" : 3184 (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>")); 3185 3186 currentText = this._get(inst, "currentText"); 3187 gotoDate = (this._get(inst, "gotoCurrent") && inst.currentDay ? currentDate : today); 3188 currentText = (!navigationAsDateFormat ? currentText : 3189 this.formatDate(currentText, gotoDate, this._getFormatConfig(inst))); 3190 3191 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'>" + 3192 this._get(inst, "closeText") + "</button>" : ""); 3193 3194 buttonPanel = (showButtonPanel) ? "<div class='ui-datepicker-buttonpane ui-widget-content'>" + (isRTL ? controls : "") + 3195 (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'" + 3196 ">" + currentText + "</button>" : "") + (isRTL ? "" : controls) + "</div>" : ""; 3197 3198 firstDay = parseInt(this._get(inst, "firstDay"),10); 3199 firstDay = (isNaN(firstDay) ? 0 : firstDay); 3200 3201 showWeek = this._get(inst, "showWeek"); 3202 dayNames = this._get(inst, "dayNames"); 3203 dayNamesMin = this._get(inst, "dayNamesMin"); 3204 monthNames = this._get(inst, "monthNames"); 3205 monthNamesShort = this._get(inst, "monthNamesShort"); 3206 beforeShowDay = this._get(inst, "beforeShowDay"); 3207 showOtherMonths = this._get(inst, "showOtherMonths"); 3208 selectOtherMonths = this._get(inst, "selectOtherMonths"); 3209 defaultDate = this._getDefaultDate(inst); 3210 html = ""; 3211 dow; 3212 for (row = 0; row < numMonths[0]; row++) { 3213 group = ""; 3214 this.maxRows = 4; 3215 for (col = 0; col < numMonths[1]; col++) { 3216 selectedDate = this._daylightSavingAdjust(new Date(drawYear, drawMonth, inst.selectedDay)); 3217 cornerClass = " ui-corner-all"; 3218 calender = ""; 3219 if (isMultiMonth) { 3220 calender += "<div class='ui-datepicker-group"; 3221 if (numMonths[1] > 1) { 3222 switch (col) { 3223 case 0: calender += " ui-datepicker-group-first"; 3224 cornerClass = " ui-corner-" + (isRTL ? "right" : "left"); break; 3225 case numMonths[1]-1: calender += " ui-datepicker-group-last"; 3226 cornerClass = " ui-corner-" + (isRTL ? "left" : "right"); break; 3227 default: calender += " ui-datepicker-group-middle"; cornerClass = ""; break; 3228 } 3229 } 3230 calender += "'>"; 3231 } 3232 calender += "<div class='ui-
vendor: 731 bytes, lines 3232-3242
3232pointer'></div><div class='ui-datepicker-header ui-widget-header ui-helper-clearfix" + cornerClass + "'>" + 3233 (/all|left/.test(cornerClass) && row === 0 ? (isRTL ? next : prev) : "") + 3234 (/all|right/.test(cornerClass) && row === 0 ? (isRTL ? prev : next) : "") + 3235 this._generateMonthYearHeader(inst, drawMonth, drawYear, minDate, maxDate, 3236 row > 0 || col > 0, monthNames, monthNamesShort) + // draw month headers 3237 "</div><table class='ui-datepicker-calendar'><thead>" + 3238 "<tr>"; 3239 thead = (showWeek ? "<th class='ui-datepicker-week-col'>" + this._get(inst, "weekHeader") + "</th>" : ""); 3240 for (dow = 0; dow < 7; dow++) { // days of the week 3241 day = (dow + firstDay) % 7; 3242 thead += "<th scope='col'
vendor: 11,347 bytes, lines 3242-3496
3242" + ((dow + firstDay + 6) % 7 >= 5 ? " class='ui-datepicker-week-end'" : "") + ">" + 3243 "<span title='" + dayNames[day] + "'>" + dayNamesMin[day] + "</span></th>"; 3244 } 3245 calender += thead + "</tr></thead><tbody>"; 3246 daysInMonth = this._getDaysInMonth(drawYear, drawMonth); 3247 if (drawYear === inst.selectedYear && drawMonth === inst.selectedMonth) { 3248 inst.selectedDay = Math.min(inst.selectedDay, daysInMonth); 3249 } 3250 leadDays = (this._getFirstDayOfMonth(drawYear, drawMonth) - firstDay + 7) % 7; 3251 curRows = Math.ceil((leadDays + daysInMonth) / 7); // calculate the number of rows to generate 3252 numRows = (isMultiMonth ? this.maxRows > curRows ? this.maxRows : curRows : curRows); //If multiple months, use the higher number of rows (see #7043) 3253 this.maxRows = numRows; 3254 printDate = this._daylightSavingAdjust(new Date(drawYear, drawMonth, 1 - leadDays)); 3255 for (dRow = 0; dRow < numRows; dRow++) { // create date picker rows 3256 calender += "<tr>"; 3257 tbody = (!showWeek ? "" : "<td class='ui-datepicker-week-col'>" + 3258 this._get(inst, "calculateWeek")(printDate) + "</td>"); 3259 for (dow = 0; dow < 7; dow++) { // create date picker days 3260 daySettings = (beforeShowDay ? 3261 beforeShowDay.apply((inst.input ? inst.input[0] : null), [printDate]) : [true, ""]); 3262 otherMonth = (printDate.getMonth() !== drawMonth); 3263 unselectable = (otherMonth && !selectOtherMonths) || !daySettings[0] || 3264 (minDate && printDate < minDate) || (maxDate && printDate > maxDate); 3265 tbody += "<td class='" + 3266 ((dow + firstDay + 6) % 7 >= 5 ? " ui-datepicker-week-end" : "") + // highlight weekends 3267 (otherMonth ? " ui-datepicker-other-month" : "") + // highlight days from other months 3268 ((printDate.getTime() === selectedDate.getTime() && drawMonth === inst.selectedMonth && inst._keyEvent) || // user pressed key 3269 (defaultDate.getTime() === printDate.getTime() && defaultDate.getTime() === selectedDate.getTime()) ? 3270 // or defaultDate is current printedDate and defaultDate is selectedDate 3271 " " + this._dayOverClass : "") + // highlight selected day 3272 (unselectable ? " " + this._unselectableClass + " ui-state-disabled": "") + // highlight unselectable days 3273 (otherMonth && !showOtherMonths ? "" : " " + daySettings[1] + // highlight custom dates 3274 (printDate.getTime() === currentDate.getTime() ? " " + this._currentClass : "") + // highlight selected day 3275 (printDate.getTime() === today.getTime() ? " ui-datepicker-today" : "")) + "'" + // highlight today (if different) 3276 ((!otherMonth || showOtherMonths) && daySettings[2] ? " title='" + daySettings[2].replace(/'/g, "'") + "'" : "") + // cell title 3277 (unselectable ? "" : " data-handler='selectDay' data-event='click' data-month='" + printDate.getMonth() + "' data-year='" + printDate.getFullYear() + "'") + ">" + // actions 3278 (otherMonth && !showOtherMonths ? " " : // display for other months 3279 (unselectable ? "<span class='ui-state-default'>" + printDate.getDate() + "</span>" : "<a class='ui-state-default" + 3280 (printDate.getTime() === today.getTime() ? " ui-state-highlight" : "") + 3281 (printDate.getTime() === currentDate.getTime() ? " ui-state-active" : "") + // highlight selected day 3282 (otherMonth ? " ui-priority-secondary" : "") + // distinguish dates from other months 3283 "' href='#'>" + printDate.getDate() + "</a>")) + "</td>"; // display selectable date 3284 printDate.setDate(printDate.getDate() + 1); 3285 printDate = this._daylightSavingAdjust(printDate); 3286 } 3287 calender += tbody + "</tr>"; 3288 } 3289 drawMonth++; 3290 if (drawMonth > 11) { 3291 drawMonth = 0; 3292 drawYear++; 3293 } 3294 calender += "</tbody></table>" + (isMultiMonth ? "</div>" + 3295 ((numMonths[0] > 0 && col === numMonths[1]-1) ? "<div class='ui-datepicker-row-break'></div>" : "") : ""); 3296 group += calender; 3297 } 3298 html += group; 3299 } 3300 html += buttonPanel; 3301 inst._keyEvent = false; 3302 return html; 3303 }, 3304 3305 /* Generate the month and year header. */ 3306 _generateMonthYearHeader: function(inst, drawMonth, drawYear, minDate, maxDate, 3307 secondary, monthNames, monthNamesShort) { 3308 3309 var inMinYear, inMaxYear, month, years, thisYear, determineYear, year, endYear, 3310 changeMonth = this._get(inst, "changeMonth"), 3311 changeYear = this._get(inst, "changeYear"), 3312 showMonthAfterYear = this._get(inst, "showMonthAfterYear"), 3313 html = "<div class='ui-datepicker-title'>", 3314 monthHtml = ""; 3315 3316 // month selection 3317 if (secondary || !changeMonth) { 3318 monthHtml += "<span class='ui-datepicker-month'>" + monthNames[drawMonth] + "</span>"; 3319 } else { 3320 inMinYear = (minDate && minDate.getFullYear() === drawYear); 3321 inMaxYear = (maxDate && maxDate.getFullYear() === drawYear); 3322 monthHtml += "<select class='ui-datepicker-month' data-handler='selectMonth' data-event='change'>"; 3323 for ( month = 0; month < 12; month++) { 3324 if ((!inMinYear || month >= minDate.getMonth()) && (!inMaxYear || month <= maxDate.getMonth())) { 3325 monthHtml += "<option value='" + month + "'" + 3326 (month === drawMonth ? " selected='selected'" : "") + 3327 ">" + monthNamesShort[month] + "</option>"; 3328 } 3329 } 3330 monthHtml += "</select>"; 3331 } 3332 3333 if (!showMonthAfterYear) { 3334 html += monthHtml + (secondary || !(changeMonth && changeYear) ? " " : ""); 3335 } 3336 3337 // year selection 3338 if ( !inst.yearshtml ) { 3339 inst.yearshtml = ""; 3340 if (secondary || !changeYear) { 3341 html += "<span class='ui-datepicker-year'>" + drawYear + "</span>"; 3342 } else { 3343 // determine range of years to display 3344 years = this._get(inst, "yearRange").split(":"); 3345 thisYear = new Date().getFullYear(); 3346 determineYear = function(value) { 3347 var year = (value.match(/c[+\-].*/) ? drawYear + parseInt(value.substring(1), 10) : 3348 (value.match(/[+\-].*/) ? thisYear + parseInt(value, 10) : 3349 parseInt(value, 10))); 3350 return (isNaN(year) ? thisYear : year); 3351 }; 3352 year = determineYear(years[0]); 3353 endYear = Math.max(year, determineYear(years[1] || "")); 3354 year = (minDate ? Math.max(year, minDate.getFullYear()) : year); 3355 endYear = (maxDate ? Math.min(endYear, maxDate.getFullYear()) : endYear); 3356 inst.yearshtml += "<select class='ui-datepicker-year' data-handler='selectYear' data-event='change'>"; 3357 for (; year <= endYear; year++) { 3358 inst.yearshtml += "<option value='" + year + "'" + 3359 (year === drawYear ? " selected='selected'" : "") + 3360 ">" + year + "</option>"; 3361 } 3362 inst.yearshtml += "</select>"; 3363 3364 html += inst.yearshtml; 3365 inst.yearshtml = null; 3366 } 3367 } 3368 3369 html += this._get(inst, "yearSuffix"); 3370 if (showMonthAfterYear) { 3371 html += (secondary || !(changeMonth && changeYear) ? " " : "") + monthHtml; 3372 } 3373 html += "</div>"; // Close datepicker_header 3374 return html; 3375 }, 3376 3377 /* Adjust one of the date sub-fields. */ 3378 _adjustInstDate: function(inst, offset, period) { 3379 var year = inst.drawYear + (period === "Y" ? offset : 0), 3380 month = inst.drawMonth + (period === "M" ? offset : 0), 3381 day = Math.min(inst.selectedDay, this._getDaysInMonth(year, month)) + (period === "D" ? offset : 0), 3382 date = this._restrictMinMax(inst, this._daylightSavingAdjust(new Date(year, month, day))); 3383 3384 inst.selectedDay = date.getDate(); 3385 inst.drawMonth = inst.selectedMonth = date.getMonth(); 3386 inst.drawYear = inst.selectedYear = date.getFullYear(); 3387 if (period === "M" || period === "Y") { 3388 this._notifyChange(inst); 3389 } 3390 }, 3391 3392 /* Ensure a date is within any min/max bounds. */ 3393 _restrictMinMax: function(inst, date) { 3394 var minDate = this._getMinMaxDate(inst, "min"), 3395 maxDate = this._getMinMaxDate(inst, "max"), 3396 newDate = (minDate && date < minDate ? minDate : date); 3397 return (maxDate && newDate > maxDate ? maxDate : newDate); 3398 }, 3399 3400 /* Notify change of month/year. */ 3401 _notifyChange: function(inst) { 3402 var onChange = this._get(inst, "onChangeMonthYear"); 3403 if (onChange) { 3404 onChange.apply((inst.input ? inst.input[0] : null), 3405 [inst.selectedYear, inst.selectedMonth + 1, inst]); 3406 } 3407 }, 3408 3409 /* Determine the number of months to show. */ 3410 _getNumberOfMonths: function(inst) { 3411 var numMonths = this._get(inst, "numberOfMonths"); 3412 return (numMonths == null ? [1, 1] : (typeof numMonths === "number" ? [1, numMonths] : numMonths)); 3413 }, 3414 3415 /* Determine the current maximum date - ensure no time components are set. */ 3416 _getMinMaxDate: function(inst, minMax) { 3417 return this._determineDate(inst, this._get(inst, minMax + "Date"), null); 3418 }, 3419 3420 /* Find the number of days in a given month. */ 3421 _getDaysInMonth: function(year, month) { 3422 return 32 - this._daylightSavingAdjust(new Date(year, month, 32)).getDate(); 3423 }, 3424 3425 /* Find the day of the week of the first of a month. */ 3426 _getFirstDayOfMonth: function(year, month) { 3427 return new Date(year, month, 1).getDay(); 3428 }, 3429 3430 /* Determines if we should allow a "next/prev" month display change. */ 3431 _canAdjustMonth: function(inst, offset, curYear, curMonth) { 3432 var numMonths = this._getNumberOfMonths(inst), 3433 date = this._daylightSavingAdjust(new Date(curYear, 3434 curMonth + (offset < 0 ? offset : numMonths[0] * numMonths[1]), 1)); 3435 3436 if (offset < 0) { 3437 date.setDate(this._getDaysInMonth(date.getFullYear(), date.getMonth())); 3438 } 3439 return this._isInRange(inst, date); 3440 }, 3441 3442 /* Is the given date in the accepted range? */ 3443 _isInRange: function(inst, date) { 3444 var yearSplit, currentYear, 3445 minDate = this._getMinMaxDate(inst, "min"), 3446 maxDate = this._getMinMaxDate(inst, "max"), 3447 minYear = null, 3448 maxYear = null, 3449 years = this._get(inst, "yearRange"); 3450 if (years){ 3451 yearSplit = years.split(":"); 3452 currentYear = new Date().getFullYear(); 3453 minYear = parseInt(yearSplit[0], 10); 3454 maxYear = parseInt(yearSplit[1], 10); 3455 if ( yearSplit[0].match(/[+\-].*/) ) { 3456 minYear += currentYear; 3457 } 3458 if ( yearSplit[1].match(/[+\-].*/) ) { 3459 maxYear += currentYear; 3460 } 3461 } 3462 3463 return ((!minDate || date.getTime() >= minDate.getTime()) && 3464 (!maxDate || date.getTime() <= maxDate.getTime()) && 3465 (!minYear || date.getFullYear() >= minYear) && 3466 (!maxYear || date.getFullYear() <= maxYear)); 3467 }, 3468 3469 /* Provide the configuration settings for formatting/parsing. */ 3470 _getFormatConfig: function(inst) { 3471 var shortYearCutoff = this._get(inst, "shortYearCutoff"); 3472 shortYearCutoff = (typeof shortYearCutoff !== "string" ? shortYearCutoff : 3473 new Date().getFullYear() % 100 + parseInt(shortYearCutoff, 10)); 3474 return {shortYearCutoff: shortYearCutoff, 3475 dayNamesShort: this._get(inst, "dayNamesShort"), dayNames: this._get(inst, "dayNames"), 3476 monthNamesShort: this._get(inst, "monthNamesShort"), monthNames: this._get(inst, "monthNames")}; 3477 }, 3478 3479 /* Format the given date for display. */ 3480 _formatDate: function(inst, day, month, year) { 3481 if (!day) { 3482 inst.currentDay = inst.selectedDay; 3483 inst.currentMonth = inst.selectedMonth; 3484 inst.currentYear = inst.selectedYear; 3485 } 3486 var date = (day ? (typeof day === "object" ? day : 3487 this._daylightSavingAdjust(new Date(year, month, day))) : 3488 this._daylightSavingAdjust(new Date(inst.currentYear, inst.currentMonth, inst.currentDay))); 3489 return this.formatDate(this._get(inst, "dateFormat"), date, this._getFormatConfig(inst)); 3490 } 3491}); 3492 3493/* 3494 * Bind hover events for datepicker elements. 3495 * Done via delegate so the binding only occurs once in the lifetime of the parent div. 3496 * Global
vendor: 2,965 bytes, lines 3496-3576
3496datepicker_instActive, set by _updateDatepicker allows the handlers to find their way back to the active picker. 3497 */ 3498function datepicker_bindHover(dpDiv) { 3499 var selector = "button, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-calendar td a"; 3500 return dpDiv.delegate(selector, "mouseout", function() { 3501 $(this).removeClass("ui-state-hover"); 3502 if (this.className.indexOf("ui-datepicker-prev") !== -1) { 3503 $(this).removeClass("ui-datepicker-prev-hover"); 3504 } 3505 if (this.className.indexOf("ui-datepicker-next") !== -1) { 3506 $(this).removeClass("ui-datepicker-next-hover"); 3507 } 3508 }) 3509 .delegate(selector, "mouseover", function(){ 3510 if (!$.datepicker._isDisabledDatepicker( datepicker_instActive.inline ? dpDiv.parent()[0] : datepicker_instActive.input[0])) { 3511 $(this).parents(".ui-datepicker-calendar").find("a").removeClass("ui-state-hover"); 3512 $(this).addClass("ui-state-hover"); 3513 if (this.className.indexOf("ui-datepicker-prev") !== -1) { 3514 $(this).addClass("ui-datepicker-prev-hover"); 3515 } 3516 if (this.className.indexOf("ui-datepicker-next") !== -1) { 3517 $(this).addClass("ui-datepicker-next-hover"); 3518 } 3519 } 3520 }); 3521} 3522 3523/* jQuery extend now ignores nulls! */ 3524function datepicker_extendRemove(target, props) { 3525 $.extend(target, props); 3526 for (var name in props) { 3527 if (props[name] == null) { 3528 target[name] = props[name]; 3529 } 3530 } 3531 return target; 3532} 3533 3534/* Invoke the datepicker functionality. 3535 @param options string - a command, optionally followed by additional parameters or 3536 Object - settings for attaching new datepicker functionality 3537 @return jQuery object */ 3538$.fn.datepicker = function(options){ 3539 3540 /* Verify an empty collection wasn't passed - Fixes #6976 */ 3541 if ( !this.length ) { 3542 return this; 3543 } 3544 3545 /* Initialise the date picker. */ 3546 if (!$.datepicker.initialized) { 3547 $(document).mousedown($.datepicker._checkExternalClick); 3548 $.datepicker.initialized = true; 3549 } 3550 3551 /* Append datepicker main container to body if not exist. */ 3552 if ($("#"+$.datepicker._mainDivId).length === 0) { 3553 $("body").append($.datepicker.dpDiv); 3554 } 3555 3556 var otherArgs = Array.prototype.slice.call(arguments, 1); 3557 if (typeof options === "string" && (options === "isDisabled" || options === "getDate" || options === "widget")) { 3558 return $.datepicker["_" + options + "Datepicker"]. 3559 apply($.datepicker, [this[0]].concat(otherArgs)); 3560 } 3561 if (options === "option" && arguments.length === 2 && typeof arguments[1] === "string") { 3562 return $.datepicker["_" + options + "Datepicker"]. 3563 apply($.datepicker, [this[0]].concat(otherArgs)); 3564 } 3565 return this.each(function() { 3566 typeof options === "string" ? 3567 $.datepicker["_" + options + "Datepicker"]. 3568 apply($.datepicker, [this].concat(otherArgs)) : 3569 $.datepicker._attachDatepicker(this, options); 3570 }); 3571}; 3572 3573// Lucas Pedro: 3574// Verificando se no mes atual ha um evento ativo, se nao, ira para o proximo mes 3575$(document).ready(function(){ 3576 if($('.eventoCalendar div').hasClass('ui-datepicker')){
3577 var month = $('.ui-datepicker-month'); 3578 var calendar = $('.ui-datepicker-calendar'); 3579 var event = $('tbody tr td a'); 3580 var btn = $('a.ui-datepicker-next'); 3581 3582 var achou = false; 3583 3584 do{ 3585 if(event.hasClass('ui-state-default')){ 3586 achou = true; 3587 // console.log('TEM eventos, então não cliquei em next'); 3588 }else{ 3589 btn.click(); 3590 event = $('tbody tr td a'); 3591 btn = $('a.ui-datepicker-next'); 3592 // console.log('NÃO tem eventos, então cliquei em next'); 3593 } 3594 }while(achou == false); 3595 3596 // if(!event.hasClass('.ui-state-default')){ 3597 // mesEvento(); 3598 // console.log('NÃO tem eventos, então cliquei em next'); 3599 // }else{ 3600 // console.log('TEM eventos, então não cliquei em next'); 3601 // } 3602 3603 // function verificaMes(){ 3604 // if(!event.hasClass('.ui-state-default')){ 3605 // mesEvento(); 3606 // console.log('NÃO tem eventos, então cliquei em next'); 3607 // }else{ 3608 // console.log('TEM eventos, então não cliquei em next'); 3609 // } 3610 // } 3611 3612 // function mesEvento(){ 3613 // btn.click(); 3614 // verificaMes(); 3615 // console.log('cliquei'); 3616 // } 3617 3618 } 3619 3620}); 3621 3622$.datepicker = new Datepicker(); // singleton instance 3623$.datepicker.initialized = false; 3624$.datepicker.uuid = new Date().getTime(); 3625$.datepicker.version = "1.11.0"; 3626 3627var datepicker = $.datepicker; 3628 3629 3630 3631}));
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.