vendor: 5,629 bytes, lines 1-149
1/*! jQuery UI - v1.12.1 - 2017-07-13 2* http://jqueryui.com 3* Includes: keycode.js, widgets/datepicker.js 4* Copyright jQuery Foundation and other contributors; Licensed MIT */ 5 6(function( factory ) { 7 if ( typeof define === "function" && define.amd ) { 8 9 // AMD. Register as an anonymous module. 10 define([ "jquery" ], factory ); 11 } else { 12 13 // Browser globals 14 factory( jQuery ); 15 } 16}(function( $ ) { 17 18$.ui = $.ui || {}; 19 20var version = $.ui.version = "1.12.1"; 21 22 23/*! 24 * jQuery UI Keycode 1.12.1 25 * http://jqueryui.com 26 * 27 * Copyright jQuery Foundation and other contributors 28 * Released under the MIT license. 29 * http://jquery.org/license 30 */ 31 32//>>label: Keycode 33//>>group: Core 34//>>description: Provide keycodes as keynames 35//>>docs: http://api.jqueryui.com/jQuery.ui.keyCode/ 36 37 38var keycode = $.ui.keyCode = { 39 BACKSPACE: 8, 40 COMMA: 188, 41 DELETE: 46, 42 DOWN: 40, 43 END: 35, 44 ENTER: 13, 45 ESCAPE: 27, 46 HOME: 36, 47 LEFT: 37, 48 PAGE_DOWN: 34, 49 PAGE_UP: 33, 50 PERIOD: 190, 51 RIGHT: 39, 52 SPACE: 32, 53 TAB: 9, 54 UP: 38 55}; 56 57 58// jscs:disable maximumLineLength 59/* jscs:disable requireCamelCaseOrUpperCaseIdentifiers */ 60/*! 61 * jQuery UI Datepicker 1.12.1 62 * http://jqueryui.com 63 * 64 * Copyright jQuery Foundation and other contributors 65 * Released under the MIT license. 66 * http://jquery.org/license 67 */ 68 69//>>label: Datepicker 70//>>group: Widgets 71//>>description: Displays a calendar from an input or inline for selecting dates. 72//>>docs: http://api.jqueryui.com/datepicker/ 73//>>demos: http://jqueryui.com/datepicker/ 74//>>css.structure: ../../themes/base/core.css 75//>>css.structure: ../../themes/base/datepicker.css 76//>>css.theme: ../../themes/base/theme.css 77 78 79 80$.extend( $.ui, { datepicker: { version: "1.12.1" } } ); 81 82var datepicker_instActive; 83 84function datepicker_getZindex( elem ) { 85 var position, value; 86 while ( elem.length && elem[ 0 ] !== document ) { 87 88 // Ignore z-index if position is set to a value where z-index is ignored by the browser 89 // This makes behavior of this function consistent across browsers 90 // WebKit always returns auto if the element is positioned 91 position = elem.css( "position" ); 92 if ( position === "absolute" || position === "relative" || position === "fixed" ) { 93 94 // IE returns 0 when zIndex is not specified 95 // other browsers return a string 96 // we ignore the case of nested elements with an explicit value of 0 97 // <div style="z-index: -10;"><div style="z-index: 0;"></div></div> 98 value = parseInt( elem.css( "zIndex" ), 10 ); 99 if ( !isNaN( value ) && value !== 0 ) { 100 return value; 101 } 102 } 103 elem = elem.parent(); 104 } 105 106 return 0; 107} 108/* Date picker manager. 109 Use the singleton instance of this class, $.datepicker, to interact with the date picker. 110 Settings for (groups of) date pickers are maintained in an instance object, 111 allowing multiple different settings on the same page. */ 112 113function Datepicker() { 114 this._curInst = null; // The current instance in use 115 this._keyEvent = false; // If the last event was a key event 116 this._disabledInputs = []; // List of date picker inputs that have been disabled 117 this._datepickerShowing = false; // True if the popup picker is showing , false if not 118 this._inDialog = false; // True if showing within a "dialog", false if not 119 this._mainDivId = "ui-datepicker-div"; // The ID of the main datepicker division 120 this._inlineClass = "ui-datepicker-inline"; // The name of the inline marker class 121 this._appendClass = "ui-datepicker-append"; // The name of the append marker class 122 this._triggerClass = "ui-datepicker-trigger"; // The name of the trigger marker class 123 this._dialogClass = "ui-datepicker-dialog"; // The name of the dialog marker class 124 this._disableClass = "ui-datepicker-disabled"; // The name of the disabled covering marker class 125 this._unselectableClass = "ui-datepicker-unselectable"; // The name of the unselectable cell marker class 126 this._currentClass = "ui-datepicker-current-day"; // The name of the current day marker class 127 this._dayOverClass = "ui-datepicker-days-cell-over"; // The name of the day hover marker class 128 this.regional = []; // Available regional settings, indexed by language code 129 this.regional[ "" ] = { // Default regional settings 130 closeText: "Done", // Display text for close link 131 prevText: "Prev", // Display text for previous month link 132 nextText: "Next", // Display text for next month link 133 currentText: "Today", // Display text for current month link 134 monthNames: [ "January","February","March","April","May","June", 135 "July","August","September","October","November","December" ], // Names of months for drop-down and formatting 136 monthNamesShort: [ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" ], // For formatting 137 dayNames: [ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" ], // For formatting 138 dayNamesShort: [ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" ], // For formatting 139 dayNamesMin: [ "Su","Mo","Tu","We","Th","Fr","Sa" ], // Column headings for days starting at Sunday 140 weekHeader: "Wk", // Column header for week of the year 141 dateFormat: "mm/dd/yy", // See format options on parseDate 142 firstDay: 0, // The first day of the week, Sun = 0, Mon = 1, ... 143 isRTL: false, // True if right-to-left language, false if left-to-right 144 showMonthAfterYear: false, // True if the year select precedes month, false for month then year 145 yearSuffix: "" // Additional text to append to the year in the month headers 146 }; 147 this._defaults = { // Global defaults for all the date picker instances 148 showOn: "focus", // "focus" for popup on focus, 149 // "button" for trigger button, or "both" for either
vendor: 6,628 bytes, lines 150-282
150 showAnim: "fadeIn", // Name of jQuery animation for popup 151 showOptions: {}, // Options for enhanced animations 152 defaultDate: null, // Used when field is blank: actual date, 153 // +/-number for offset from today, null for today 154 appendText: "", // Display text following the input box, e.g. showing the format 155 buttonText: "...", // Text for trigger button 156 buttonImage: "", // URL for trigger button image 157 buttonImageOnly: false, // True if the image appears alone, false if it appears on a button 158 hideIfNoPrevNext: false, // True to hide next/previous month links 159 // if not applicable, false to just disable them 160 navigationAsDateFormat: false, // True if date formatting applied to prev/today/next links 161 gotoCurrent: false, // True if today link goes back to current selection instead 162 changeMonth: false, // True if month can be selected directly, false if only prev/next 163 changeYear: false, // True if year can be selected directly, false if only prev/next 164 yearRange: "c-10:c+10", // Range of years to display in drop-down, 165 // either relative to today's year (-nn:+nn), relative to currently displayed year 166 // (c-nn:c+nn), absolute (nnnn:nnnn), or a combination of the above (nnnn:-n) 167 showOtherMonths: false, // True to show dates in other months, false to leave blank 168 selectOtherMonths: false, // True to allow selection of dates in other months, false for unselectable 169 showWeek: false, // True to show week of the year, false to not show it 170 calculateWeek: this.iso8601Week, // How to calculate the week of the year, 171 // takes a Date and returns the number of the week for it 172 shortYearCutoff: "+10", // Short year values < this are in the current century, 173 // > this are in the previous century, 174 // string value starting with "+" for current year + value 175 minDate: null, // The earliest selectable date, or null for no limit 176 maxDate: null, // The latest selectable date, or null for no limit 177 duration: "fast", // Duration of display/closure 178 beforeShowDay: null, // Function that takes a date and returns an array with 179 // [0] = true if selectable, false if not, [1] = custom CSS class name(s) or "", 180 // [2] = cell title (optional), e.g. $.datepicker.noWeekends 181 beforeShow: null, // Function that takes an input field and 182 // returns a set of custom settings for the date picker 183 onSelect: null, // Define a callback function when a date is selected 184 onChangeMonthYear: null, // Define a callback function when the month or year is changed 185 onClose: null, // Define a callback function when the datepicker is closed 186 numberOfMonths: 1, // Number of months to show at a time 187 showCurrentAtPos: 0, // The position in multipe months at which to show the current month (starting at 0) 188 stepMonths: 1, // Number of months to step back/forward 189 stepBigMonths: 12, // Number of months to step back/forward for the big links 190 altField: "", // Selector for an alternate field to store selected dates into 191 altFormat: "", // The date format to use for the alternate field 192 constrainInput: true, // The input is constrained by the current date format 193 showButtonPanel: false, // True to show button panel, false to not show it 194 autoSize: false, // True to size the input for the date format, false to leave as is 195 disabled: false // The initial disabled state 196 }; 197 $.extend( this._defaults, this.regional[ "" ] ); 198 this.regional.en = $.extend( true, {}, this.regional[ "" ] ); 199 this.regional[ "en-US" ] = $.extend( true, {}, this.regional.en ); 200 this.dpDiv = datepicker_bindHover( $( "<div id='" + this._mainDivId + "' class='ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all'></div>" ) ); 201} 202 203$.extend( Datepicker.prototype, { 204 /* Class name added to elements to indicate already configured with a date picker. */ 205 markerClassName: "hasDatepicker", 206 207 //Keep track of the maximum number of rows displayed (see #7043) 208 maxRows: 4, 209 210 // TODO rename to "widget" when switching to widget factory 211 _widgetDatepicker: function() { 212 return this.dpDiv; 213 }, 214 215 /* Override the default settings for all instances of the date picker. 216 * @param settings object - the new settings to use as defaults (anonymous object) 217 * @return the manager object 218 */ 219 setDefaults: function( settings ) { 220 datepicker_extendRemove( this._defaults, settings || {} ); 221 return this; 222 }, 223 224 /* Attach the date picker to a jQuery selection. 225 * @param target element - the target input field or division or span 226 * @param settings object - the new settings to use for this date picker instance (anonymous) 227 */ 228 _attachDatepicker: function( target, settings ) { 229 var nodeName, inline, inst; 230 nodeName = target.nodeName.toLowerCase(); 231 inline = ( nodeName === "div" || nodeName === "span" ); 232 if ( !target.id ) { 233 this.uuid += 1; 234 target.id = "dp" + this.uuid; 235 } 236 inst = this._newInst( $( target ), inline ); 237 inst.settings = $.extend( {}, settings || {} ); 238 if ( nodeName === "input" ) { 239 this._connectDatepicker( target, inst ); 240 } else if ( inline ) { 241 this._inlineDatepicker( target, inst ); 242 } 243 }, 244 245 /* Create a new instance object. */ 246 _newInst: function( target, inline ) { 247 var id = target[ 0 ].id.replace( /([^A-Za-z0-9_\-])/g, "\\\\$1" ); // escape jQuery meta chars 248 return { id: id, input: target, // associated target 249 selectedDay: 0, selectedMonth: 0, selectedYear: 0, // current selection 250 drawMonth: 0, drawYear: 0, // month being drawn 251 inline: inline, // is datepicker inline or not 252 dpDiv: ( !inline ? this.dpDiv : // presentation div 253 datepicker_bindHover( $( "<div class='" + this._inlineClass + " ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all'></div>" ) ) ) }; 254 }, 255 256 /* Attach the date picker to an input field. */ 257 _connectDatepicker: function( target, inst ) { 258 var input = $( target ); 259 inst.append = $( [] ); 260 inst.trigger = $( [] ); 261 if ( input.hasClass( this.markerClassName ) ) { 262 return; 263 } 264 this._attachments( input, inst ); 265 input.addClass( this.markerClassName ).on( "keydown", this._doKeyDown ). 266 on( "keypress", this._doKeyPress ).on( "keyup", this._doKeyUp ); 267 this._autoSize( inst ); 268 $.data( target, "datepicker", inst ); 269 270 //If disabled option is true, disable the datepicker once it has been attached to the input (see ticket #5665) 271 if ( inst.settings.disabled ) { 272 this._disableDatepicker( target ); 273 } 274 }, 275 276 /* Make attachments based on settings. */ 277 _attachments: function( input, inst ) { 278 var showOn, buttonText, buttonImage, 279 appendText = this._get( inst, "appendText" ), 280 isRTL = this._get( inst, "isRTL" ); 281 282 if ( inst.append ) {
vendor: 13,169 bytes, lines 283-653
283 inst.append.remove(); 284 } 285 if ( appendText ) { 286 inst.append = $( "<span class='" + this._appendClass + "'>" + appendText + "</span>" ); 287 input[ isRTL ? "before" : "after" ]( inst.append ); 288 } 289 290 input.off( "focus", this._showDatepicker ); 291 292 if ( inst.trigger ) { 293 inst.trigger.remove(); 294 } 295 296 showOn = this._get( inst, "showOn" ); 297 if ( showOn === "focus" || showOn === "both" ) { // pop-up date picker when in the marked field 298 input.on( "focus", this._showDatepicker ); 299 } 300 if ( showOn === "button" || showOn === "both" ) { // pop-up date picker when button clicked 301 buttonText = this._get( inst, "buttonText" ); 302 buttonImage = this._get( inst, "buttonImage" ); 303 inst.trigger = $( this._get( inst, "buttonImageOnly" ) ? 304 $( "<img/>" ).addClass( this._triggerClass ). 305 attr( { src: buttonImage, alt: buttonText, title: buttonText } ) : 306 $( "<button type='button'></button>" ).addClass( this._triggerClass ). 307 html( !buttonImage ? buttonText : $( "<img/>" ).attr( 308 { src:buttonImage, alt:buttonText, title:buttonText } ) ) ); 309 input[ isRTL ? "before" : "after" ]( inst.trigger ); 310 inst.trigger.on( "click", function() { 311 if ( $.datepicker._datepickerShowing && $.datepicker._lastInput === input[ 0 ] ) { 312 $.datepicker._hideDatepicker(); 313 } else if ( $.datepicker._datepickerShowing && $.datepicker._lastInput !== input[ 0 ] ) { 314 $.datepicker._hideDatepicker(); 315 $.datepicker._showDatepicker( input[ 0 ] ); 316 } else { 317 $.datepicker._showDatepicker( input[ 0 ] ); 318 } 319 return false; 320 } ); 321 } 322 }, 323 324 /* Apply the maximum length for the date format. */ 325 _autoSize: function( inst ) { 326 if ( this._get( inst, "autoSize" ) && !inst.inline ) { 327 var findMax, max, maxI, i, 328 date = new Date( 2009, 12 - 1, 20 ), // Ensure double digits 329 dateFormat = this._get( inst, "dateFormat" ); 330 331 if ( dateFormat.match( /[DM]/ ) ) { 332 findMax = function( names ) { 333 max = 0; 334 maxI = 0; 335 for ( i = 0; i < names.length; i++ ) { 336 if ( names[ i ].length > max ) { 337 max = names[ i ].length; 338 maxI = i; 339 } 340 } 341 return maxI; 342 }; 343 date.setMonth( findMax( this._get( inst, ( dateFormat.match( /MM/ ) ? 344 "monthNames" : "monthNamesShort" ) ) ) ); 345 date.setDate( findMax( this._get( inst, ( dateFormat.match( /DD/ ) ? 346 "dayNames" : "dayNamesShort" ) ) ) + 20 - date.getDay() ); 347 } 348 inst.input.attr( "size", this._formatDate( inst, date ).length ); 349 } 350 }, 351 352 /* Attach an inline date picker to a div. */ 353 _inlineDatepicker: function( target, inst ) { 354 var divSpan = $( target ); 355 if ( divSpan.hasClass( this.markerClassName ) ) { 356 return; 357 } 358 divSpan.addClass( this.markerClassName ).append( inst.dpDiv ); 359 $.data( target, "datepicker", inst ); 360 this._setDate( inst, this._getDefaultDate( inst ), true ); 361 this._updateDatepicker( inst ); 362 this._updateAlternate( inst ); 363 364 //If disabled option is true, disable the datepicker before showing it (see ticket #5665) 365 if ( inst.settings.disabled ) { 366 this._disableDatepicker( target ); 367 } 368 369 // Set display:block in place of inst.dpDiv.show() which won't work on disconnected elements 370 // http://bugs.jqueryui.com/ticket/7552 - A Datepicker created on a detached div has zero height 371 inst.dpDiv.css( "display", "block" ); 372 }, 373 374 /* Pop-up the date picker in a "dialog" box. 375 * @param input element - ignored 376 * @param date string or Date - the initial date to display 377 * @param onSelect function - the function to call when a date is selected 378 * @param settings object - update the dialog date picker instance's settings (anonymous object) 379 * @param pos int[2] - coordinates for the dialog's position within the screen or 380 * event - with x/y coordinates or 381 * leave empty for default (screen centre) 382 * @return the manager object 383 */ 384 _dialogDatepicker: function( input, date, onSelect, settings, pos ) { 385 var id, browserWidth, browserHeight, scrollX, scrollY, 386 inst = this._dialogInst; // internal instance 387 388 if ( !inst ) { 389 this.uuid += 1; 390 id = "dp" + this.uuid; 391 this._dialogInput = $( "<input type='text' id='" + id + 392 "' style='position: absolute; top: -100px; width: 0px;'/>" ); 393 this._dialogInput.on( "keydown", this._doKeyDown ); 394 $( "body" ).append( this._dialogInput ); 395 inst = this._dialogInst = this._newInst( this._dialogInput, false ); 396 inst.settings = {}; 397 $.data( this._dialogInput[ 0 ], "datepicker", inst ); 398 } 399 datepicker_extendRemove( inst.settings, settings || {} ); 400 date = ( date && date.constructor === Date ? this._formatDate( inst, date ) : date ); 401 this._dialogInput.val( date ); 402 403 this._pos = ( pos ? ( pos.length ? pos : [ pos.pageX, pos.pageY ] ) : null ); 404 if ( !this._pos ) { 405 browserWidth = document.documentElement.clientWidth; 406 browserHeight = document.documentElement.clientHeight; 407 scrollX = document.documentElement.scrollLeft || document.body.scrollLeft; 408 scrollY = document.documentElement.scrollTop || document.body.scrollTop; 409 this._pos = // should use actual width/height below 410 [ ( browserWidth / 2 ) - 100 + scrollX, ( browserHeight / 2 ) - 150 + scrollY ]; 411 } 412 413 // Move input on screen for focus, but hidden behind dialog 414 this._dialogInput.css( "left", ( this._pos[ 0 ] + 20 ) + "px" ).css( "top", this._pos[ 1 ] + "px" ); 415 inst.settings.onSelect = onSelect; 416 this._inDialog = true; 417 this.dpDiv.addClass( this._dialogClass ); 418 this._showDatepicker( this._dialogInput[ 0 ] ); 419 if ( $.blockUI ) { 420 $.blockUI( this.dpDiv ); 421 } 422 $.data( this._dialogInput[ 0 ], "datepicker", inst ); 423 return this; 424 }, 425 426 /* Detach a datepicker from its control. 427 * @param target element - the target input field or division or span 428 */ 429 _destroyDatepicker: function( target ) { 430 var nodeName, 431 $target = $( target ), 432 inst = $.data( target, "datepicker" ); 433 434 if ( !$target.hasClass( this.markerClassName ) ) { 435 return; 436 } 437 438 nodeName = target.nodeName.toLowerCase(); 439 $.removeData( target, "datepicker" ); 440 if ( nodeName === "input" ) { 441 inst.append.remove(); 442 inst.trigger.remove(); 443 $target.removeClass( this.markerClassName ). 444 off( "focus", this._showDatepicker ). 445 off( "keydown", this._doKeyDown ). 446 off( "keypress", this._doKeyPress ). 447 off( "keyup", this._doKeyUp ); 448 } else if ( nodeName === "div" || nodeName === "span" ) { 449 $target.removeClass( this.markerClassName ).empty(); 450 } 451 452 if ( datepicker_instActive === inst ) { 453 datepicker_instActive = null; 454 } 455 }, 456 457 /* Enable the date picker to a jQuery selection. 458 * @param target element - the target input field or division or span 459 */ 460 _enableDatepicker: function( target ) { 461 var nodeName, inline, 462 $target = $( target ), 463 inst = $.data( target, "datepicker" ); 464 465 if ( !$target.hasClass( this.markerClassName ) ) { 466 return; 467 } 468 469 nodeName = target.nodeName.toLowerCase(); 470 if ( nodeName === "input" ) { 471 target.disabled = false; 472 inst.trigger.filter( "button" ). 473 each( function() { this.disabled = false; } ).end(). 474 filter( "img" ).css( { opacity: "1.0", cursor: "" } ); 475 } else if ( nodeName === "div" || nodeName === "span" ) { 476 inline = $target.children( "." + this._inlineClass ); 477 inline.children().removeClass( "ui-state-disabled" ); 478 inline.find( "select.ui-datepicker-month, select.ui-datepicker-year" ). 479 prop( "disabled", false ); 480 } 481 this._disabledInputs = $.map( this._disabledInputs, 482 function( value ) { return ( value === target ? null : value ); } ); // delete entry 483 }, 484 485 /* Disable the date picker to a jQuery selection. 486 * @param target element - the target input field or division or span 487 */ 488 _disableDatepicker: function( target ) { 489 var nodeName, inline, 490 $target = $( target ), 491 inst = $.data( target, "datepicker" ); 492 493 if ( !$target.hasClass( this.markerClassName ) ) { 494 return; 495 } 496 497 nodeName = target.nodeName.toLowerCase(); 498 if ( nodeName === "input" ) { 499 target.disabled = true; 500 inst.trigger.filter( "button" ). 501 each( function() { this.disabled = true; } ).end(). 502 filter( "img" ).css( { opacity: "0.5", cursor: "default" } ); 503 } else if ( nodeName === "div" || nodeName === "span" ) { 504 inline = $target.children( "." + this._inlineClass ); 505 inline.children().addClass( "ui-state-disabled" ); 506 inline.find( "select.ui-datepicker-month, select.ui-datepicker-year" ). 507 prop( "disabled", true ); 508 } 509 this._disabledInputs = $.map( this._disabledInputs, 510 function( value ) { return ( value === target ? null : value ); } ); // delete entry 511 this._disabledInputs[ this._disabledInputs.length ] = target; 512 }, 513 514 /* Is the first field in a jQuery collection disabled as a datepicker? 515 * @param target element - the target input field or division or span 516 * @return boolean - true if disabled, false if enabled 517 */ 518 _isDisabledDatepicker: function( target ) { 519 if ( !target ) { 520 return false; 521 } 522 for ( var i = 0; i < this._disabledInputs.length; i++ ) { 523 if ( this._disabledInputs[ i ] === target ) { 524 return true; 525 } 526 } 527 return false; 528 }, 529 530 /* Retrieve the instance data for the target control. 531 * @param target element - the target input field or division or span 532 * @return object - the associated instance data 533 * @throws error if a jQuery problem getting data 534 */ 535 _getInst: function( target ) { 536 try { 537 return $.data( target, "datepicker" ); 538 } 539 catch ( err ) { 540 throw "Missing instance data for this datepicker"; 541 } 542 }, 543 544 /* Update or retrieve the settings for a date picker attached to an input field or division. 545 * @param target element - the target input field or division or span 546 * @param name object - the new settings to update or 547 * string - the name of the setting to change or retrieve, 548 * when retrieving also "all" for all instance settings or 549 * "defaults" for all global defaults 550 * @param value any - the new value for the setting 551 * (omit if above is an object or to retrieve a value) 552 */ 553 _optionDatepicker: function( target, name, value ) { 554 var settings, date, minDate, maxDate, 555 inst = this._getInst( target ); 556 557 if ( arguments.length === 2 && typeof name === "string" ) { 558 return ( name === "defaults" ? $.extend( {}, $.datepicker._defaults ) : 559 ( inst ? ( name === "all" ? $.extend( {}, inst.settings ) : 560 this._get( inst, name ) ) : null ) ); 561 } 562 563 settings = name || {}; 564 if ( typeof name === "string" ) { 565 settings = {}; 566 settings[ name ] = value; 567 } 568 569 if ( inst ) { 570 if ( this._curInst === inst ) { 571 this._hideDatepicker(); 572 } 573 574 date = this._getDateDatepicker( target, true ); 575 minDate = this._getMinMaxDate( inst, "min" ); 576 maxDate = this._getMinMaxDate( inst, "max" ); 577 datepicker_extendRemove( inst.settings, settings ); 578 579 // reformat the old minDate/maxDate values if dateFormat changes and a new minDate/maxDate isn't provided 580 if ( minDate !== null && settings.dateFormat !== undefined && settings.minDate === undefined ) { 581 inst.settings.minDate = this._formatDate( inst, minDate ); 582 } 583 if ( maxDate !== null && settings.dateFormat !== undefined && settings.maxDate === undefined ) { 584 inst.settings.maxDate = this._formatDate( inst, maxDate ); 585 } 586 if ( "disabled" in settings ) { 587 if ( settings.disabled ) { 588 this._disableDatepicker( target ); 589 } else { 590 this._enableDatepicker( target ); 591 } 592 } 593 this._attachments( $( target ), inst ); 594 this._autoSize( inst ); 595 this._setDate( inst, date ); 596 this._updateAlternate( inst ); 597 this._updateDatepicker( inst ); 598 } 599 }, 600 601 // Change method deprecated 602 _changeDatepicker: function( target, name, value ) { 603 this._optionDatepicker( target, name, value ); 604 }, 605 606 /* Redraw the date picker attached to an input field or division. 607 * @param target element - the target input field or division or span 608 */ 609 _refreshDatepicker: function( target ) { 610 var inst = this._getInst( target ); 611 if ( inst ) { 612 this._updateDatepicker( inst ); 613 } 614 }, 615 616 /* Set the dates for a jQuery selection. 617 * @param target element - the target input field or division or span 618 * @param date Date - the new date 619 */ 620 _setDateDatepicker: function( target, date ) { 621 var inst = this._getInst( target ); 622 if ( inst ) { 623 this._setDate( inst, date ); 624 this._updateDatepicker( inst ); 625 this._updateAlternate( inst ); 626 } 627 }, 628 629 /* Get the date(s) for the first entry in a jQuery selection. 630 * @param target element - the target input field or division or span 631 * @param noDefault boolean - true if no default date is to be used 632 * @return Date - the current date 633 */ 634 _getDateDatepicker: function( target, noDefault ) { 635 var inst = this._getInst( target ); 636 if ( inst && !inst.inline ) { 637 this._setDateFromField( inst, noDefault ); 638 } 639 return ( inst ? this._getDate( inst ) : null ); 640 }, 641 642 /* Handle keystrokes. */ 643 _doKeyDown: function( event ) { 644 var onSelect, dateStr, sel, 645 inst = $.datepicker._getInst( event.target ), 646 handled = true, 647 isRTL = inst.dpDiv.is( ".ui-datepicker-rtl" ); 648 649 inst._keyEvent = true; 650 if ( $.datepicker._datepickerShowing ) { 651 switch ( event.keyCode ) { 652 case 9: $.datepicker._hideDatepicker(); 653 handled = false;
vendor: 4,635 bytes, lines 654-781
654 break; // hide on tab out 655 case 13: sel = $( "td." + $.datepicker._dayOverClass + ":not(." + 656 $.datepicker._currentClass + ")", inst.dpDiv ); 657 if ( sel[ 0 ] ) { 658 $.datepicker._selectDay( event.target, inst.selectedMonth, inst.selectedYear, sel[ 0 ] ); 659 } 660 661 onSelect = $.datepicker._get( inst, "onSelect" ); 662 if ( onSelect ) { 663 dateStr = $.datepicker._formatDate( inst ); 664 665 // Trigger custom callback 666 onSelect.apply( ( inst.input ? inst.input[ 0 ] : null ), [ dateStr, inst ] ); 667 } else { 668 $.datepicker._hideDatepicker(); 669 } 670 671 return false; // don't submit the form 672 case 27: $.datepicker._hideDatepicker(); 673 break; // hide on escape 674 case 33: $.datepicker._adjustDate( event.target, ( event.ctrlKey ? 675 -$.datepicker._get( inst, "stepBigMonths" ) : 676 -$.datepicker._get( inst, "stepMonths" ) ), "M" ); 677 break; // previous month/year on page up/+ ctrl 678 case 34: $.datepicker._adjustDate( event.target, ( event.ctrlKey ? 679 +$.datepicker._get( inst, "stepBigMonths" ) : 680 +$.datepicker._get( inst, "stepMonths" ) ), "M" ); 681 break; // next month/year on page down/+ ctrl 682 case 35: if ( event.ctrlKey || event.metaKey ) { 683 $.datepicker._clearDate( event.target ); 684 } 685 handled = event.ctrlKey || event.metaKey; 686 break; // clear on ctrl or command +end 687 case 36: if ( event.ctrlKey || event.metaKey ) { 688 $.datepicker._gotoToday( event.target ); 689 } 690 handled = event.ctrlKey || event.metaKey; 691 break; // current on ctrl or command +home 692 case 37: if ( event.ctrlKey || event.metaKey ) { 693 $.datepicker._adjustDate( event.target, ( isRTL ? +1 : -1 ), "D" ); 694 } 695 handled = event.ctrlKey || event.metaKey; 696 697 // -1 day on ctrl or command +left 698 if ( event.originalEvent.altKey ) { 699 $.datepicker._adjustDate( event.target, ( event.ctrlKey ? 700 -$.datepicker._get( inst, "stepBigMonths" ) : 701 -$.datepicker._get( inst, "stepMonths" ) ), "M" ); 702 } 703 704 // next month/year on alt +left on Mac 705 break; 706 case 38: if ( event.ctrlKey || event.metaKey ) { 707 $.datepicker._adjustDate( event.target, -7, "D" ); 708 } 709 handled = event.ctrlKey || event.metaKey; 710 break; // -1 week on ctrl or command +up 711 case 39: if ( event.ctrlKey || event.metaKey ) { 712 $.datepicker._adjustDate( event.target, ( isRTL ? -1 : +1 ), "D" ); 713 } 714 handled = event.ctrlKey || event.metaKey; 715 716 // +1 day on ctrl or command +right 717 if ( event.originalEvent.altKey ) { 718 $.datepicker._adjustDate( event.target, ( event.ctrlKey ? 719 +$.datepicker._get( inst, "stepBigMonths" ) : 720 +$.datepicker._get( inst, "stepMonths" ) ), "M" ); 721 } 722 723 // next month/year on alt +right 724 break; 725 case 40: if ( event.ctrlKey || event.metaKey ) { 726 $.datepicker._adjustDate( event.target, +7, "D" ); 727 } 728 handled = event.ctrlKey || event.metaKey; 729 break; // +1 week on ctrl or command +down 730 default: handled = false; 731 } 732 } else if ( event.keyCode === 36 && event.ctrlKey ) { // display the date picker on ctrl+home 733 $.datepicker._showDatepicker( this ); 734 } else { 735 handled = false; 736 } 737 738 if ( handled ) { 739 event.preventDefault(); 740 event.stopPropagation(); 741 } 742 }, 743 744 /* Filter entered characters - based on date format. */ 745 _doKeyPress: function( event ) { 746 var chars, chr, 747 inst = $.datepicker._getInst( event.target ); 748 749 if ( $.datepicker._get( inst, "constrainInput" ) ) { 750 chars = $.datepicker._possibleChars( $.datepicker._get( inst, "dateFormat" ) ); 751 chr = String.fromCharCode( event.charCode == null ? event.keyCode : event.charCode ); 752 return event.ctrlKey || event.metaKey || ( chr < " " || !chars || chars.indexOf( chr ) > -1 ); 753 } 754 }, 755 756 /* Synchronise manual entry and field/alternate field. */ 757 _doKeyUp: function( event ) { 758 var date, 759 inst = $.datepicker._getInst( event.target ); 760 761 if ( inst.input.val() !== inst.lastVal ) { 762 try { 763 date = $.datepicker.parseDate( $.datepicker._get( inst, "dateFormat" ), 764 ( inst.input ? inst.input.val() : null ), 765 $.datepicker._getFormatConfig( inst ) ); 766 767 if ( date ) { // only if valid 768 $.datepicker._setDateFromField( inst ); 769 $.datepicker._updateAlternate( inst ); 770 $.datepicker._updateDatepicker( inst ); 771 } 772 } 773 catch ( err ) { 774 } 775 } 776 return true; 777 }, 778 779 /* Pop-up the date picker for a given input field. 780 * If false returned from beforeShow event handler do not show. 781 * @param input element - the input field attached to the date picker or
vendor: 9,739 bytes, lines 782-1060
782 * event - if triggered by focus 783 */ 784 _showDatepicker: function( input ) { 785 input = input.target || input; 786 if ( input.nodeName.toLowerCase() !== "input" ) { // find from button/image trigger 787 input = $( "input", input.parentNode )[ 0 ]; 788 } 789 790 if ( $.datepicker._isDisabledDatepicker( input ) || $.datepicker._lastInput === input ) { // already here 791 return; 792 } 793 794 var inst, beforeShow, beforeShowSettings, isFixed, 795 offset, showAnim, duration; 796 797 inst = $.datepicker._getInst( input ); 798 if ( $.datepicker._curInst && $.datepicker._curInst !== inst ) { 799 $.datepicker._curInst.dpDiv.stop( true, true ); 800 if ( inst && $.datepicker._datepickerShowing ) { 801 $.datepicker._hideDatepicker( $.datepicker._curInst.input[ 0 ] ); 802 } 803 } 804 805 beforeShow = $.datepicker._get( inst, "beforeShow" ); 806 beforeShowSettings = beforeShow ? beforeShow.apply( input, [ input, inst ] ) : {}; 807 if ( beforeShowSettings === false ) { 808 return; 809 } 810 datepicker_extendRemove( inst.settings, beforeShowSettings ); 811 812 inst.lastVal = null; 813 $.datepicker._lastInput = input; 814 $.datepicker._setDateFromField( inst ); 815 816 if ( $.datepicker._inDialog ) { // hide cursor 817 input.value = ""; 818 } 819 if ( !$.datepicker._pos ) { // position below input 820 $.datepicker._pos = $.datepicker._findPos( input ); 821 $.datepicker._pos[ 1 ] += input.offsetHeight; // add the height 822 } 823 824 isFixed = false; 825 $( input ).parents().each( function() { 826 isFixed |= $( this ).css( "position" ) === "fixed"; 827 return !isFixed; 828 } ); 829 830 offset = { left: $.datepicker._pos[ 0 ], top: $.datepicker._pos[ 1 ] }; 831 $.datepicker._pos = null; 832 833 //to avoid flashes on Firefox 834 inst.dpDiv.empty(); 835 836 // determine sizing offscreen 837 inst.dpDiv.css( { position: "absolute", display: "block", top: "-1000px" } ); 838 $.datepicker._updateDatepicker( inst ); 839 840 // fix width for dynamic number of date pickers 841 // and adjust position before showing 842 offset = $.datepicker._checkOffset( inst, offset, isFixed ); 843 inst.dpDiv.css( { position: ( $.datepicker._inDialog && $.blockUI ? 844 "static" : ( isFixed ? "fixed" : "absolute" ) ), display: "none", 845 left: offset.left + "px", top: offset.top + "px" } ); 846 847 if ( !inst.inline ) { 848 showAnim = $.datepicker._get( inst, "showAnim" ); 849 duration = $.datepicker._get( inst, "duration" ); 850 inst.dpDiv.css( "z-index", datepicker_getZindex( $( input ) ) + 1 ); 851 $.datepicker._datepickerShowing = true; 852 853 if ( $.effects && $.effects.effect[ showAnim ] ) { 854 inst.dpDiv.show( showAnim, $.datepicker._get( inst, "showOptions" ), duration ); 855 } else { 856 inst.dpDiv[ showAnim || "show" ]( showAnim ? duration : null ); 857 } 858 859 if ( $.datepicker._shouldFocusInput( inst ) ) { 860 inst.input.trigger( "focus" ); 861 } 862 863 $.datepicker._curInst = inst; 864 } 865 }, 866 867 /* Generate the date picker content. */ 868 _updateDatepicker: function( inst ) { 869 this.maxRows = 4; //Reset the max number of rows being displayed (see #7043) 870 datepicker_instActive = inst; // for delegate hover events 871 inst.dpDiv.empty().append( this._generateHTML( inst ) ); 872 this._attachHandlers( inst ); 873 874 var origyearshtml, 875 numMonths = this._getNumberOfMonths( inst ), 876 cols = numMonths[ 1 ], 877 width = 17, 878 activeCell = inst.dpDiv.find( "." + this._dayOverClass + " a" ); 879 880 if ( activeCell.length > 0 ) { 881 datepicker_handleMouseover.apply( activeCell.get( 0 ) ); 882 } 883 884 inst.dpDiv.removeClass( "ui-datepicker-multi-2 ui-datepicker-multi-3 ui-datepicker-multi-4" ).width( "" ); 885 if ( cols > 1 ) { 886 inst.dpDiv.addClass( "ui-datepicker-multi-" + cols ).css( "width", ( width * cols ) + "em" ); 887 } 888 inst.dpDiv[ ( numMonths[ 0 ] !== 1 || numMonths[ 1 ] !== 1 ? "add" : "remove" ) + 889 "Class" ]( "ui-datepicker-multi" ); 890 inst.dpDiv[ ( this._get( inst, "isRTL" ) ? "add" : "remove" ) + 891 "Class" ]( "ui-datepicker-rtl" ); 892 893 if ( inst === $.datepicker._curInst && $.datepicker._datepickerShowing && $.datepicker._shouldFocusInput( inst ) ) { 894 inst.input.trigger( "focus" ); 895 } 896 897 // Deffered render of the years select (to avoid flashes on Firefox) 898 if ( inst.yearshtml ) { 899 origyearshtml = inst.yearshtml; 900 setTimeout( function() { 901 902 //assure that inst.yearshtml didn't change. 903 if ( origyearshtml === inst.yearshtml && inst.yearshtml ) { 904 inst.dpDiv.find( "select.ui-datepicker-year:first" ).replaceWith( inst.yearshtml ); 905 } 906 origyearshtml = inst.yearshtml = null; 907 }, 0 ); 908 } 909 }, 910 911 // #6694 - don't focus the input if it's already focused 912 // this breaks the change event in IE 913 // Support: IE and jQuery <1.9 914 _shouldFocusInput: function( inst ) { 915 return inst.input && inst.input.is( ":visible" ) && !inst.input.is( ":disabled" ) && !inst.input.is( ":focus" ); 916 }, 917 918 /* Check positioning to remain on screen. */ 919 _checkOffset: function( inst, offset, isFixed ) { 920 var dpWidth = inst.dpDiv.outerWidth(), 921 dpHeight = inst.dpDiv.outerHeight(), 922 inputWidth = inst.input ? inst.input.outerWidth() : 0, 923 inputHeight = inst.input ? inst.input.outerHeight() : 0, 924 viewWidth = document.documentElement.clientWidth + ( isFixed ? 0 : $( document ).scrollLeft() ), 925 viewHeight = document.documentElement.clientHeight + ( isFixed ? 0 : $( document ).scrollTop() ); 926 927 offset.left -= ( this._get( inst, "isRTL" ) ? ( dpWidth - inputWidth ) : 0 ); 928 offset.left -= ( isFixed && offset.left === inst.input.offset().left ) ? $( document ).scrollLeft() : 0; 929 offset.top -= ( isFixed && offset.top === ( inst.input.offset().top + inputHeight ) ) ? $( document ).scrollTop() : 0; 930 931 // Now check if datepicker is showing outside window viewport - move to a better place if so. 932 offset.left -= Math.min( offset.left, ( offset.left + dpWidth > viewWidth && viewWidth > dpWidth ) ? 933 Math.abs( offset.left + dpWidth - viewWidth ) : 0 ); 934 offset.top -= Math.min( offset.top, ( offset.top + dpHeight > viewHeight && viewHeight > dpHeight ) ? 935 Math.abs( dpHeight + inputHeight ) : 0 ); 936 937 return offset; 938 }, 939 940 /* Find an object's position on the screen. */ 941 _findPos: function( obj ) { 942 var position, 943 inst = this._getInst( obj ), 944 isRTL = this._get( inst, "isRTL" ); 945 946 while ( obj && ( obj.type === "hidden" || obj.nodeType !== 1 || $.expr.filters.hidden( obj ) ) ) { 947 obj = obj[ isRTL ? "previousSibling" : "nextSibling" ]; 948 } 949 950 position = $( obj ).offset(); 951 return [ position.left, position.top ]; 952 }, 953 954 /* Hide the date picker from view. 955 * @param input element - the input field attached to the date picker 956 */ 957 _hideDatepicker: function( input ) { 958 var showAnim, duration, postProcess, onClose, 959 inst = this._curInst; 960 961 if ( !inst || ( input && inst !== $.data( input, "datepicker" ) ) ) { 962 return; 963 } 964 965 if ( this._datepickerShowing ) { 966 showAnim = this._get( inst, "showAnim" ); 967 duration = this._get( inst, "duration" ); 968 postProcess = function() { 969 $.datepicker._tidyDialog( inst ); 970 }; 971 972 // DEPRECATED: after BC for 1.8.x $.effects[ showAnim ] is not needed 973 if ( $.effects && ( $.effects.effect[ showAnim ] || $.effects[ showAnim ] ) ) { 974 inst.dpDiv.hide( showAnim, $.datepicker._get( inst, "showOptions" ), duration, postProcess ); 975 } else { 976 inst.dpDiv[ ( showAnim === "slideDown" ? "slideUp" : 977 ( showAnim === "fadeIn" ? "fadeOut" : "hide" ) ) ]( ( showAnim ? duration : null ), postProcess ); 978 } 979 980 if ( !showAnim ) { 981 postProcess(); 982 } 983 this._datepickerShowing = false; 984 985 onClose = this._get( inst, "onClose" ); 986 if ( onClose ) { 987 onClose.apply( ( inst.input ? inst.input[ 0 ] : null ), [ ( inst.input ? inst.input.val() : "" ), inst ] ); 988 } 989 990 this._lastInput = null; 991 if ( this._inDialog ) { 992 this._dialogInput.css( { position: "absolute", left: "0", top: "-100px" } ); 993 if ( $.blockUI ) { 994 $.unblockUI(); 995 $( "body" ).append( this.dpDiv ); 996 } 997 } 998 this._inDialog = false; 999 } 1000 }, 1001 1002 /* Tidy up after a dialog display. */ 1003 _tidyDialog: function( inst ) { 1004 inst.dpDiv.removeClass( this._dialogClass ).off( ".ui-datepicker-calendar" ); 1005 }, 1006 1007 /* Close date picker if clicked elsewhere. */ 1008 _checkExternalClick: function( event ) { 1009 if ( !$.datepicker._curInst ) { 1010 return; 1011 } 1012 1013 var $target = $( event.target ), 1014 inst = $.datepicker._getInst( $target[ 0 ] ); 1015 1016 if ( ( ( $target[ 0 ].id !== $.datepicker._mainDivId && 1017 $target.parents( "#" + $.datepicker._mainDivId ).length === 0 && 1018 !$target.hasClass( $.datepicker.markerClassName ) && 1019 !$target.closest( "." + $.datepicker._triggerClass ).length && 1020 $.datepicker._datepickerShowing && !( $.datepicker._inDialog && $.blockUI ) ) ) || 1021 ( $target.hasClass( $.datepicker.markerClassName ) && $.datepicker._curInst !== inst ) ) { 1022 $.datepicker._hideDatepicker(); 1023 } 1024 }, 1025 1026 /* Adjust one of the date sub-fields. */ 1027 _adjustDate: function( id, offset, period ) { 1028 var target = $( id ), 1029 inst = this._getInst( target[ 0 ] ); 1030 1031 if ( this._isDisabledDatepicker( target[ 0 ] ) ) { 1032 return; 1033 } 1034 this._adjustInstDate( inst, offset + 1035 ( period === "M" ? this._get( inst, "showCurrentAtPos" ) : 0 ), // undo positioning 1036 period ); 1037 this._updateDatepicker( inst ); 1038 }, 1039 1040 /* Action for current link. */ 1041 _gotoToday: function( id ) { 1042 var date, 1043 target = $( id ), 1044 inst = this._getInst( target[ 0 ] ); 1045 1046 if ( this._get( inst, "gotoCurrent" ) && inst.currentDay ) { 1047 inst.selectedDay = inst.currentDay; 1048 inst.drawMonth = inst.selectedMonth = inst.currentMonth; 1049 inst.drawYear = inst.selectedYear = inst.currentYear; 1050 } else { 1051 date = new Date(); 1052 inst.selectedDay = date.getDate(); 1053 inst.drawMonth = inst.selectedMonth = date.getMonth(); 1054 inst.drawYear = inst.selectedYear = date.getFullYear(); 1055 } 1056 this._notifyChange( inst ); 1057 this._adjustDate( target ); 1058 }, 1059 1060 /* Action for selecting a new month/year. */
vendor: 2,372 bytes, lines 1061-1136
1061 _selectMonthYear: function( id, select, period ) { 1062 var target = $( id ), 1063 inst = this._getInst( target[ 0 ] ); 1064 1065 inst[ "selected" + ( period === "M" ? "Month" : "Year" ) ] = 1066 inst[ "draw" + ( period === "M" ? "Month" : "Year" ) ] = 1067 parseInt( select.options[ select.selectedIndex ].value, 10 ); 1068 1069 this._notifyChange( inst ); 1070 this._adjustDate( target ); 1071 }, 1072 1073 /* Action for selecting a day. */ 1074 _selectDay: function( id, month, year, td ) { 1075 var inst, 1076 target = $( id ); 1077 1078 if ( $( td ).hasClass( this._unselectableClass ) || this._isDisabledDatepicker( target[ 0 ] ) ) { 1079 return; 1080 } 1081 1082 inst = this._getInst( target[ 0 ] ); 1083 inst.selectedDay = inst.currentDay = $( "a", td ).html(); 1084 inst.selectedMonth = inst.currentMonth = month; 1085 inst.selectedYear = inst.currentYear = year; 1086 this._selectDate( id, this._formatDate( inst, 1087 inst.currentDay, inst.currentMonth, inst.currentYear ) ); 1088 }, 1089 1090 /* Erase the input field and hide the date picker. */ 1091 _clearDate: function( id ) { 1092 var target = $( id ); 1093 this._selectDate( target, "" ); 1094 }, 1095 1096 /* Update the input field with the selected date. */ 1097 _selectDate: function( id, dateStr ) { 1098 var onSelect, 1099 target = $( id ), 1100 inst = this._getInst( target[ 0 ] ); 1101 1102 dateStr = ( dateStr != null ? dateStr : this._formatDate( inst ) ); 1103 if ( inst.input ) { 1104 inst.input.val( dateStr ); 1105 } 1106 this._updateAlternate( inst ); 1107 1108 onSelect = this._get( inst, "onSelect" ); 1109 if ( onSelect ) { 1110 onSelect.apply( ( inst.input ? inst.input[ 0 ] : null ), [ dateStr, inst ] ); // trigger custom callback 1111 } else if ( inst.input ) { 1112 inst.input.trigger( "change" ); // fire the change event 1113 } 1114 1115 if ( inst.inline ) { 1116 this._updateDatepicker( inst ); 1117 } else { 1118 this._hideDatepicker(); 1119 this._lastInput = inst.input[ 0 ]; 1120 if ( typeof( inst.input[ 0 ] ) !== "object" ) { 1121 inst.input.trigger( "focus" ); // restore focus 1122 } 1123 this._lastInput = null; 1124 } 1125 }, 1126 1127 /* Update any alternate field to synchronise with the main field. */ 1128 _updateAlternate: function( inst ) { 1129 var altFormat, date, dateStr, 1130 altField = this._get( inst, "altField" ); 1131 1132 if ( altField ) { // update alternate field too 1133 altFormat = this._get( inst, "altFormat" ) || this._get( inst, "dateFormat" ); 1134 date = this._getDate( inst ); 1135 dateStr = this.formatDate( altFormat, date, this._getFormatConfig( inst ) ); 1136 $
vendor: 13,647 bytes, lines 1136-1575
1136( altField ).val( dateStr ); 1137 } 1138 }, 1139 1140 /* Set as beforeShowDay function to prevent selection of weekends. 1141 * @param date Date - the date to customise 1142 * @return [boolean, string] - is this date selectable?, what is its CSS class? 1143 */ 1144 noWeekends: function( date ) { 1145 var day = date.getDay(); 1146 return [ ( day > 0 && day < 6 ), "" ]; 1147 }, 1148 1149 /* Set as calculateWeek to determine the week of the year based on the ISO 8601 definition. 1150 * @param date Date - the date to get the week for 1151 * @return number - the number of the week within the year that contains this date 1152 */ 1153 iso8601Week: function( date ) { 1154 var time, 1155 checkDate = new Date( date.getTime() ); 1156 1157 // Find Thursday of this week starting on Monday 1158 checkDate.setDate( checkDate.getDate() + 4 - ( checkDate.getDay() || 7 ) ); 1159 1160 time = checkDate.getTime(); 1161 checkDate.setMonth( 0 ); // Compare with Jan 1 1162 checkDate.setDate( 1 ); 1163 return Math.floor( Math.round( ( time - checkDate ) / 86400000 ) / 7 ) + 1; 1164 }, 1165 1166 /* Parse a string value into a date object. 1167 * See formatDate below for the possible formats. 1168 * 1169 * @param format string - the expected format of the date 1170 * @param value string - the date in the above format 1171 * @param settings Object - attributes include: 1172 * shortYearCutoff number - the cutoff year for determining the century (optional) 1173 * dayNamesShort string[7] - abbreviated names of the days from Sunday (optional) 1174 * dayNames string[7] - names of the days from Sunday (optional) 1175 * monthNamesShort string[12] - abbreviated names of the months (optional) 1176 * monthNames string[12] - names of the months (optional) 1177 * @return Date - the extracted date value or null if value is blank 1178 */ 1179 parseDate: function( format, value, settings ) { 1180 if ( format == null || value == null ) { 1181 throw "Invalid arguments"; 1182 } 1183 1184 value = ( typeof value === "object" ? value.toString() : value + "" ); 1185 if ( value === "" ) { 1186 return null; 1187 } 1188 1189 var iFormat, dim, extra, 1190 iValue = 0, 1191 shortYearCutoffTemp = ( settings ? settings.shortYearCutoff : null ) || this._defaults.shortYearCutoff, 1192 shortYearCutoff = ( typeof shortYearCutoffTemp !== "string" ? shortYearCutoffTemp : 1193 new Date().getFullYear() % 100 + parseInt( shortYearCutoffTemp, 10 ) ), 1194 dayNamesShort = ( settings ? settings.dayNamesShort : null ) || this._defaults.dayNamesShort, 1195 dayNames = ( settings ? settings.dayNames : null ) || this._defaults.dayNames, 1196 monthNamesShort = ( settings ? settings.monthNamesShort : null ) || this._defaults.monthNamesShort, 1197 monthNames = ( settings ? settings.monthNames : null ) || this._defaults.monthNames, 1198 year = -1, 1199 month = -1, 1200 day = -1, 1201 doy = -1, 1202 literal = false, 1203 date, 1204 1205 // Check whether a format character is doubled 1206 lookAhead = function( match ) { 1207 var matches = ( iFormat + 1 < format.length && format.charAt( iFormat + 1 ) === match ); 1208 if ( matches ) { 1209 iFormat++; 1210 } 1211 return matches; 1212 }, 1213 1214 // Extract a number from the string value 1215 getNumber = function( match ) { 1216 var isDoubled = lookAhead( match ), 1217 size = ( match === "@" ? 14 : ( match === "!" ? 20 : 1218 ( match === "y" && isDoubled ? 4 : ( match === "o" ? 3 : 2 ) ) ) ), 1219 minSize = ( match === "y" ? size : 1 ), 1220 digits = new RegExp( "^\\d{" + minSize + "," + size + "}" ), 1221 num = value.substring( iValue ).match( digits ); 1222 if ( !num ) { 1223 throw "Missing number at position " + iValue; 1224 } 1225 iValue += num[ 0 ].length; 1226 return parseInt( num[ 0 ], 10 ); 1227 }, 1228 1229 // Extract a name from the string value and convert to an index 1230 getName = function( match, shortNames, longNames ) { 1231 var index = -1, 1232 names = $.map( lookAhead( match ) ? longNames : shortNames, function( v, k ) { 1233 return [ [ k, v ] ]; 1234 } ).sort( function( a, b ) { 1235 return -( a[ 1 ].length - b[ 1 ].length ); 1236 } ); 1237 1238 $.each( names, function( i, pair ) { 1239 var name = pair[ 1 ]; 1240 if ( value.substr( iValue, name.length ).toLowerCase() === name.toLowerCase() ) { 1241 index = pair[ 0 ]; 1242 iValue += name.length; 1243 return false; 1244 } 1245 } ); 1246 if ( index !== -1 ) { 1247 return index + 1; 1248 } else { 1249 throw "Unknown name at position " + iValue; 1250 } 1251 }, 1252 1253 // Confirm that a literal character matches the string value 1254 checkLiteral = function() { 1255 if ( value.charAt( iValue ) !== format.charAt( iFormat ) ) { 1256 throw "Unexpected literal at position " + iValue; 1257 } 1258 iValue++; 1259 }; 1260 1261 for ( iFormat = 0; iFormat < format.length; iFormat++ ) { 1262 if ( literal ) { 1263 if ( format.charAt( iFormat ) === "'" && !lookAhead( "'" ) ) { 1264 literal = false; 1265 } else { 1266 checkLiteral(); 1267 } 1268 } else { 1269 switch ( format.charAt( iFormat ) ) { 1270 case "d": 1271 day = getNumber( "d" ); 1272 break; 1273 case "D": 1274 getName( "D", dayNamesShort, dayNames ); 1275 break; 1276 case "o": 1277 doy = getNumber( "o" ); 1278 break; 1279 case "m": 1280 month = getNumber( "m" ); 1281 break; 1282 case "M": 1283 month = getName( "M", monthNamesShort, monthNames ); 1284 break; 1285 case "y": 1286 year = getNumber( "y" ); 1287 break; 1288 case "@": 1289 date = new Date( getNumber( "@" ) ); 1290 year = date.getFullYear(); 1291 month = date.getMonth() + 1; 1292 day = date.getDate(); 1293 break; 1294 case "!": 1295 date = new Date( ( getNumber( "!" ) - this._ticksTo1970 ) / 10000 ); 1296 year = date.getFullYear(); 1297 month = date.getMonth() + 1; 1298 day = date.getDate(); 1299 break; 1300 case "'": 1301 if ( lookAhead( "'" ) ) { 1302 checkLiteral(); 1303 } else { 1304 literal = true; 1305 } 1306 break; 1307 default: 1308 checkLiteral(); 1309 } 1310 } 1311 } 1312 1313 if ( iValue < value.length ) { 1314 extra = value.substr( iValue ); 1315 if ( !/^\s+/.test( extra ) ) { 1316 throw "Extra/unparsed characters found in date: " + extra; 1317 } 1318 } 1319 1320 if ( year === -1 ) { 1321 year = new Date().getFullYear(); 1322 } else if ( year < 100 ) { 1323 year += new Date().getFullYear() - new Date().getFullYear() % 100 + 1324 ( year <= shortYearCutoff ? 0 : -100 ); 1325 } 1326 1327 if ( doy > -1 ) { 1328 month = 1; 1329 day = doy; 1330 do { 1331 dim = this._getDaysInMonth( year, month - 1 ); 1332 if ( day <= dim ) { 1333 break; 1334 } 1335 month++; 1336 day -= dim; 1337 } while ( true ); 1338 } 1339 1340 date = this._daylightSavingAdjust( new Date( year, month - 1, day ) ); 1341 if ( date.getFullYear() !== year || date.getMonth() + 1 !== month || date.getDate() !== day ) { 1342 throw "Invalid date"; // E.g. 31/02/00 1343 } 1344 return date; 1345 }, 1346 1347 /* Standard date formats. */ 1348 ATOM: "yy-mm-dd", // RFC 3339 (ISO 8601) 1349 COOKIE: "D, dd M yy", 1350 ISO_8601: "yy-mm-dd", 1351 RFC_822: "D, d M y", 1352 RFC_850: "DD, dd-M-y", 1353 RFC_1036: "D, d M y", 1354 RFC_1123: "D, d M yy", 1355 RFC_2822: "D, d M yy", 1356 RSS: "D, d M y", // RFC 822 1357 TICKS: "!", 1358 TIMESTAMP: "@", 1359 W3C: "yy-mm-dd", // ISO 8601 1360 1361 _ticksTo1970: ( ( ( 1970 - 1 ) * 365 + Math.floor( 1970 / 4 ) - Math.floor( 1970 / 100 ) + 1362 Math.floor( 1970 / 400 ) ) * 24 * 60 * 60 * 10000000 ), 1363 1364 /* Format a date object into a string value. 1365 * The format can be combinations of the following: 1366 * d - day of month (no leading zero) 1367 * dd - day of month (two digit) 1368 * o - day of year (no leading zeros) 1369 * oo - day of year (three digit) 1370 * D - day name short 1371 * DD - day name long 1372 * m - month of year (no leading zero) 1373 * mm - month of year (two digit) 1374 * M - month name short 1375 * MM - month name long 1376 * y - year (two digit) 1377 * yy - year (four digit) 1378 * @ - Unix timestamp (ms since 01/01/1970) 1379 * ! - Windows ticks (100ns since 01/01/0001) 1380 * "..." - literal text 1381 * '' - single quote 1382 * 1383 * @param format string - the desired format of the date 1384 * @param date Date - the date value to format 1385 * @param settings Object - attributes include: 1386 * dayNamesShort string[7] - abbreviated names of the days from Sunday (optional) 1387 * dayNames string[7] - names of the days from Sunday (optional) 1388 * monthNamesShort string[12] - abbreviated names of the months (optional) 1389 * monthNames string[12] - names of the months (optional) 1390 * @return string - the date in the above format 1391 */ 1392 formatDate: function( format, date, settings ) { 1393 if ( !date ) { 1394 return ""; 1395 } 1396 1397 var iFormat, 1398 dayNamesShort = ( settings ? settings.dayNamesShort : null ) || this._defaults.dayNamesShort, 1399 dayNames = ( settings ? settings.dayNames : null ) || this._defaults.dayNames, 1400 monthNamesShort = ( settings ? settings.monthNamesShort : null ) || this._defaults.monthNamesShort, 1401 monthNames = ( settings ? settings.monthNames : null ) || this._defaults.monthNames, 1402 1403 // Check whether a format character is doubled 1404 lookAhead = function( match ) { 1405 var matches = ( iFormat + 1 < format.length && format.charAt( iFormat + 1 ) === match ); 1406 if ( matches ) { 1407 iFormat++; 1408 } 1409 return matches; 1410 }, 1411 1412 // Format a number, with leading zero if necessary 1413 formatNumber = function( match, value, len ) { 1414 var num = "" + value; 1415 if ( lookAhead( match ) ) { 1416 while ( num.length < len ) { 1417 num = "0" + num; 1418 } 1419 } 1420 return num; 1421 }, 1422 1423 // Format a name, short or long as requested 1424 formatName = function( match, value, shortNames, longNames ) { 1425 return ( lookAhead( match ) ? longNames[ value ] : shortNames[ value ] ); 1426 }, 1427 output = "", 1428 literal = false; 1429 1430 if ( date ) { 1431 for ( iFormat = 0; iFormat < format.length; iFormat++ ) { 1432 if ( literal ) { 1433 if ( format.charAt( iFormat ) === "'" && !lookAhead( "'" ) ) { 1434 literal = false; 1435 } else { 1436 output += format.charAt( iFormat ); 1437 } 1438 } else { 1439 switch ( format.charAt( iFormat ) ) { 1440 case "d": 1441 output += formatNumber( "d", date.getDate(), 2 ); 1442 break; 1443 case "D": 1444 output += formatName( "D", date.getDay(), dayNamesShort, dayNames ); 1445 break; 1446 case "o": 1447 output += formatNumber( "o", 1448 Math.round( ( new Date( date.getFullYear(), date.getMonth(), date.getDate() ).getTime() - new Date( date.getFullYear(), 0, 0 ).getTime() ) / 86400000 ), 3 ); 1449 break; 1450 case "m": 1451 output += formatNumber( "m", date.getMonth() + 1, 2 ); 1452 break; 1453 case "M": 1454 output += formatName( "M", date.getMonth(), monthNamesShort, monthNames ); 1455 break; 1456 case "y": 1457 output += ( lookAhead( "y" ) ? date.getFullYear() : 1458 ( date.getFullYear() % 100 < 10 ? "0" : "" ) + date.getFullYear() % 100 ); 1459 break; 1460 case "@": 1461 output += date.getTime(); 1462 break; 1463 case "!": 1464 output += date.getTime() * 10000 + this._ticksTo1970; 1465 break; 1466 case "'": 1467 if ( lookAhead( "'" ) ) { 1468 output += "'"; 1469 } else { 1470 literal = true; 1471 } 1472 break; 1473 default: 1474 output += format.charAt( iFormat ); 1475 } 1476 } 1477 } 1478 } 1479 return output; 1480 }, 1481 1482 /* Extract all possible characters from the date format. */ 1483 _possibleChars: function( format ) { 1484 var iFormat, 1485 chars = "", 1486 literal = false, 1487 1488 // Check whether a format character is doubled 1489 lookAhead = function( match ) { 1490 var matches = ( iFormat + 1 < format.length && format.charAt( iFormat + 1 ) === match ); 1491 if ( matches ) { 1492 iFormat++; 1493 } 1494 return matches; 1495 }; 1496 1497 for ( iFormat = 0; iFormat < format.length; iFormat++ ) { 1498 if ( literal ) { 1499 if ( format.charAt( iFormat ) === "'" && !lookAhead( "'" ) ) { 1500 literal = false; 1501 } else { 1502 chars += format.charAt( iFormat ); 1503 } 1504 } else { 1505 switch ( format.charAt( iFormat ) ) { 1506 case "d": case "m": case "y": case "@": 1507 chars += "0123456789"; 1508 break; 1509 case "D": case "M": 1510 return null; // Accept anything 1511 case "'": 1512 if ( lookAhead( "'" ) ) { 1513 chars += "'"; 1514 } else { 1515 literal = true; 1516 } 1517 break; 1518 default: 1519 chars += format.charAt( iFormat ); 1520 } 1521 } 1522 } 1523 return chars; 1524 }, 1525 1526 /* Get a setting value, defaulting if necessary. */ 1527 _get: function( inst, name ) { 1528 return inst.settings[ name ] !== undefined ? 1529 inst.settings[ name ] : this._defaults[ name ]; 1530 }, 1531 1532 /* Parse existing date and initialise date picker. */ 1533 _setDateFromField: function( inst, noDefault ) { 1534 if ( inst.input.val() === inst.lastVal ) { 1535 return; 1536 } 1537 1538 var dateFormat = this._get( inst, "dateFormat" ), 1539 dates = inst.lastVal = inst.input ? inst.input.val() : null, 1540 defaultDate = this._getDefaultDate( inst ), 1541 date = defaultDate, 1542 settings = this._getFormatConfig( inst ); 1543 1544 try { 1545 date = this.parseDate( dateFormat, dates, settings ) || defaultDate; 1546 } catch ( event ) { 1547 dates = ( noDefault ? "" : dates ); 1548 } 1549 inst.selectedDay = date.getDate(); 1550 inst.drawMonth = inst.selectedMonth = date.getMonth(); 1551 inst.drawYear = inst.selectedYear = date.getFullYear(); 1552 inst.currentDay = ( dates ? date.getDate() : 0 ); 1553 inst.currentMonth = ( dates ? date.getMonth() : 0 ); 1554 inst.currentYear = ( dates ? date.getFullYear() : 0 ); 1555 this._adjustInstDate( inst ); 1556 }, 1557 1558 /* Retrieve the default date shown on opening. */ 1559 _getDefaultDate: function( inst ) { 1560 return this._restrictMinMax( inst, 1561 this._determineDate( inst, this._get( inst, "defaultDate" ), new Date() ) ); 1562 }, 1563 1564 /* A date may be specified as an exact value or a relative one. */ 1565 _determineDate: function( inst, date, defaultDate ) { 1566 var offsetNumeric = function( offset ) { 1567 var date = new Date(); 1568 date.setDate( date.getDate() + offset ); 1569 return date; 1570 }, 1571 offsetString = function( offset ) { 1572 try { 1573 return $.datepicker.parseDate( $.datepicker._get( inst, "dateFormat" ), 1574 offset, $.datepicker._getFormatConfig( inst ) ); 1575 }
1575 1576
vendor: 6,426 bytes, lines 1576-1750
1576catch ( e ) { 1577 1578 // Ignore 1579 } 1580 1581 var date = ( offset.toLowerCase().match( /^c/ ) ? 1582 $.datepicker._getDate( inst ) : null ) || new Date(), 1583 year = date.getFullYear(), 1584 month = date.getMonth(), 1585 day = date.getDate(), 1586 pattern = /([+\-]?[0-9]+)\s*(d|D|w|W|m|M|y|Y)?/g, 1587 matches = pattern.exec( offset ); 1588 1589 while ( matches ) { 1590 switch ( matches[ 2 ] || "d" ) { 1591 case "d" : case "D" : 1592 day += parseInt( matches[ 1 ], 10 ); break; 1593 case "w" : case "W" : 1594 day += parseInt( matches[ 1 ], 10 ) * 7; break; 1595 case "m" : case "M" : 1596 month += parseInt( matches[ 1 ], 10 ); 1597 day = Math.min( day, $.datepicker._getDaysInMonth( year, month ) ); 1598 break; 1599 case "y": case "Y" : 1600 year += parseInt( matches[ 1 ], 10 ); 1601 day = Math.min( day, $.datepicker._getDaysInMonth( year, month ) ); 1602 break; 1603 } 1604 matches = pattern.exec( offset ); 1605 } 1606 return new Date( year, month, day ); 1607 }, 1608 newDate = ( date == null || date === "" ? defaultDate : ( typeof date === "string" ? offsetString( date ) : 1609 ( typeof date === "number" ? ( isNaN( date ) ? defaultDate : offsetNumeric( date ) ) : new Date( date.getTime() ) ) ) ); 1610 1611 newDate = ( newDate && newDate.toString() === "Invalid Date" ? defaultDate : newDate ); 1612 if ( newDate ) { 1613 newDate.setHours( 0 ); 1614 newDate.setMinutes( 0 ); 1615 newDate.setSeconds( 0 ); 1616 newDate.setMilliseconds( 0 ); 1617 } 1618 return this._daylightSavingAdjust( newDate ); 1619 }, 1620 1621 /* Handle switch to/from daylight saving. 1622 * Hours may be non-zero on daylight saving cut-over: 1623 * > 12 when midnight changeover, but then cannot generate 1624 * midnight datetime, so jump to 1AM, otherwise reset. 1625 * @param date (Date) the date to check 1626 * @return (Date) the corrected date 1627 */ 1628 _daylightSavingAdjust: function( date ) { 1629 if ( !date ) { 1630 return null; 1631 } 1632 date.setHours( date.getHours() > 12 ? date.getHours() + 2 : 0 ); 1633 return date; 1634 }, 1635 1636 /* Set the date(s) directly. */ 1637 _setDate: function( inst, date, noChange ) { 1638 var clear = !date, 1639 origMonth = inst.selectedMonth, 1640 origYear = inst.selectedYear, 1641 newDate = this._restrictMinMax( inst, this._determineDate( inst, date, new Date() ) ); 1642 1643 inst.selectedDay = inst.currentDay = newDate.getDate(); 1644 inst.drawMonth = inst.selectedMonth = inst.currentMonth = newDate.getMonth(); 1645 inst.drawYear = inst.selectedYear = inst.currentYear = newDate.getFullYear(); 1646 if ( ( origMonth !== inst.selectedMonth || origYear !== inst.selectedYear ) && !noChange ) { 1647 this._notifyChange( inst ); 1648 } 1649 this._adjustInstDate( inst ); 1650 if ( inst.input ) { 1651 inst.input.val( clear ? "" : this._formatDate( inst ) ); 1652 } 1653 }, 1654 1655 /* Retrieve the date(s) directly. */ 1656 _getDate: function( inst ) { 1657 var startDate = ( !inst.currentYear || ( inst.input && inst.input.val() === "" ) ? null : 1658 this._daylightSavingAdjust( new Date( 1659 inst.currentYear, inst.currentMonth, inst.currentDay ) ) ); 1660 return startDate; 1661 }, 1662 1663 /* Attach the onxxx handlers. These are declared statically so 1664 * they work with static code transformers like Caja. 1665 */ 1666 _attachHandlers: function( inst ) { 1667 var stepMonths = this._get( inst, "stepMonths" ), 1668 id = "#" + inst.id.replace( /\\\\/g, "\\" ); 1669 inst.dpDiv.find( "[data-handler]" ).map( function() { 1670 var handler = { 1671 prev: function() { 1672 $.datepicker._adjustDate( id, -stepMonths, "M" ); 1673 }, 1674 next: function() { 1675 $.datepicker._adjustDate( id, +stepMonths, "M" ); 1676 }, 1677 hide: function() { 1678 $.datepicker._hideDatepicker(); 1679 }, 1680 today: function() { 1681 $.datepicker._gotoToday( id ); 1682 }, 1683 selectDay: function() { 1684 $.datepicker._selectDay( id, +this.getAttribute( "data-month" ), +this.getAttribute( "data-year" ), this ); 1685 return false; 1686 }, 1687 selectMonth: function() { 1688 $.datepicker._selectMonthYear( id, this, "M" ); 1689 return false; 1690 }, 1691 selectYear: function() { 1692 $.datepicker._selectMonthYear( id, this, "Y" ); 1693 return false; 1694 } 1695 }; 1696 $( this ).on( this.getAttribute( "data-event" ), handler[ this.getAttribute( "data-handler" ) ] ); 1697 } ); 1698 }, 1699 1700 /* Generate the HTML for the current state of the date picker. */ 1701 _generateHTML: function( inst ) { 1702 var maxDraw, prevText, prev, nextText, next, currentText, gotoDate, 1703 controls, buttonPanel, firstDay, showWeek, dayNames, dayNamesMin, 1704 monthNames, monthNamesShort, beforeShowDay, showOtherMonths, 1705 selectOtherMonths, defaultDate, html, dow, row, group, col, selectedDate, 1706 cornerClass, calender, thead, day, daysInMonth, leadDays, curRows, numRows, 1707 printDate, dRow, tbody, daySettings, otherMonth, unselectable, 1708 tempDate = new Date(), 1709 today = this._daylightSavingAdjust( 1710 new Date( tempDate.getFullYear(), tempDate.getMonth(), tempDate.getDate() ) ), // clear time 1711 isRTL = this._get( inst, "isRTL" ), 1712 showButtonPanel = this._get( inst, "showButtonPanel" ), 1713 hideIfNoPrevNext = this._get( inst, "hideIfNoPrevNext" ), 1714 navigationAsDateFormat = this._get( inst, "navigationAsDateFormat" ), 1715 numMonths = this._getNumberOfMonths( inst ), 1716 showCurrentAtPos = this._get( inst, "showCurrentAtPos" ), 1717 stepMonths = this._get( inst, "stepMonths" ), 1718 isMultiMonth = ( numMonths[ 0 ] !== 1 || numMonths[ 1 ] !== 1 ), 1719 currentDate = this._daylightSavingAdjust( ( !inst.currentDay ? new Date( 9999, 9, 9 ) : 1720 new Date( inst.currentYear, inst.currentMonth, inst.currentDay ) ) ), 1721 minDate = this._getMinMaxDate( inst, "min" ), 1722 maxDate = this._getMinMaxDate( inst, "max" ), 1723 drawMonth = inst.drawMonth - showCurrentAtPos, 1724 drawYear = inst.drawYear; 1725 1726 if ( drawMonth < 0 ) { 1727 drawMonth += 12; 1728 drawYear--; 1729 } 1730 if ( maxDate ) { 1731 maxDraw = this._daylightSavingAdjust( new Date( maxDate.getFullYear(), 1732 maxDate.getMonth() - ( numMonths[ 0 ] * numMonths[ 1 ] ) + 1, maxDate.getDate() ) ); 1733 maxDraw = ( minDate && maxDraw < minDate ? minDate : maxDraw ); 1734 while ( this._daylightSavingAdjust( new Date( drawYear, drawMonth, 1 ) ) > maxDraw ) { 1735 drawMonth--; 1736 if ( drawMonth < 0 ) { 1737 drawMonth = 11; 1738 drawYear--; 1739 } 1740 } 1741 } 1742 inst.drawMonth = drawMonth; 1743 inst.drawYear = drawYear; 1744 1745 prevText = this._get( inst, "prevText" ); 1746 prevText = ( !navigationAsDateFormat ? prevText : this.formatDate( prevText, 1747 this._daylightSavingAdjust( new Date( drawYear, drawMonth - stepMonths, 1 ) ), 1748 this._getFormatConfig( inst ) ) ); 1749 1750
vendor: 3,273 bytes, lines 1750-1802
1750prev = ( this._canAdjustMonth( inst, -1, drawYear, drawMonth ) ? 1751 "<a class='ui-datepicker-prev ui-corner-all' data-handler='prev' data-event='click'" + 1752 " title='" + prevText + "'><span class='ui-icon ui-icon-circle-triangle-" + ( isRTL ? "e" : "w" ) + "'>" + prevText + "</span></a>" : 1753 ( 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>" ) ); 1754 1755 nextText = this._get( inst, "nextText" ); 1756 nextText = ( !navigationAsDateFormat ? nextText : this.formatDate( nextText, 1757 this._daylightSavingAdjust( new Date( drawYear, drawMonth + stepMonths, 1 ) ), 1758 this._getFormatConfig( inst ) ) ); 1759 1760 next = ( this._canAdjustMonth( inst, +1, drawYear, drawMonth ) ? 1761 "<a class='ui-datepicker-next ui-corner-all' data-handler='next' data-event='click'" + 1762 " title='" + nextText + "'><span class='ui-icon ui-icon-circle-triangle-" + ( isRTL ? "w" : "e" ) + "'>" + nextText + "</span></a>" : 1763 ( 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>" ) ); 1764 1765 currentText = this._get( inst, "currentText" ); 1766 gotoDate = ( this._get( inst, "gotoCurrent" ) && inst.currentDay ? currentDate : today ); 1767 currentText = ( !navigationAsDateFormat ? currentText : 1768 this.formatDate( currentText, gotoDate, this._getFormatConfig( inst ) ) ); 1769 1770 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'>" + 1771 this._get( inst, "closeText" ) + "</button>" : "" ); 1772 1773 buttonPanel = ( showButtonPanel ) ? "<div class='ui-datepicker-buttonpane ui-widget-content'>" + ( isRTL ? controls : "" ) + 1774 ( 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'" + 1775 ">" + currentText + "</button>" : "" ) + ( isRTL ? "" : controls ) + "</div>" : ""; 1776 1777 firstDay = parseInt( this._get( inst, "firstDay" ), 10 ); 1778 firstDay = ( isNaN( firstDay ) ? 0 : firstDay ); 1779 1780 showWeek = this._get( inst, "showWeek" ); 1781 dayNames = this._get( inst, "dayNames" ); 1782 dayNamesMin = this._get( inst, "dayNamesMin" ); 1783 monthNames = this._get( inst, "monthNames" ); 1784 monthNamesShort = this._get( inst, "monthNamesShort" ); 1785 beforeShowDay = this._get( inst, "beforeShowDay" ); 1786 showOtherMonths = this._get( inst, "showOtherMonths" ); 1787 selectOtherMonths = this._get( inst, "selectOtherMonths" ); 1788 defaultDate = this._getDefaultDate( inst ); 1789 html = ""; 1790 1791 for ( row = 0; row < numMonths[ 0 ]; row++ ) { 1792 group = ""; 1793 this.maxRows = 4; 1794 for ( col = 0; col < numMonths[ 1 ]; col++ ) { 1795 selectedDate = this._daylightSavingAdjust( new Date( drawYear, drawMonth, inst.selectedDay ) ); 1796 cornerClass = " ui-corner-all"; 1797 calender = ""; 1798 if ( isMultiMonth ) { 1799 calender += "<div class='ui-datepicker-group"; 1800 if ( numMonths[ 1 ] > 1 ) { 1801 switch ( col ) { 1802 case 0: calender += " ui-datepicker-group-first";
vendor: 5,222 bytes, lines 1803-1881
1803 cornerClass = " ui-corner-" + ( isRTL ? "right" : "left" ); break; 1804 case numMonths[ 1 ] - 1: calender += " ui-datepicker-group-last"; 1805 cornerClass = " ui-corner-" + ( isRTL ? "left" : "right" ); break; 1806 default: calender += " ui-datepicker-group-middle"; cornerClass = ""; break; 1807 } 1808 } 1809 calender += "'>"; 1810 } 1811 calender += "<div class='ui-datepicker-header ui-widget-header ui-helper-clearfix" + cornerClass + "'>" + 1812 ( /all|left/.test( cornerClass ) && row === 0 ? ( isRTL ? next : prev ) : "" ) + 1813 ( /all|right/.test( cornerClass ) && row === 0 ? ( isRTL ? prev : next ) : "" ) + 1814 this._generateMonthYearHeader( inst, drawMonth, drawYear, minDate, maxDate, 1815 row > 0 || col > 0, monthNames, monthNamesShort ) + // draw month headers 1816 "</div><table class='ui-datepicker-calendar'><thead>" + 1817 "<tr>"; 1818 thead = ( showWeek ? "<th class='ui-datepicker-week-col'>" + this._get( inst, "weekHeader" ) + "</th>" : "" ); 1819 for ( dow = 0; dow < 7; dow++ ) { // days of the week 1820 day = ( dow + firstDay ) % 7; 1821 thead += "<th scope='col'" + ( ( dow + firstDay + 6 ) % 7 >= 5 ? " class='ui-datepicker-week-end'" : "" ) + ">" + 1822 "<span title='" + dayNames[ day ] + "'>" + dayNamesMin[ day ] + "</span></th>"; 1823 } 1824 calender += thead + "</tr></thead><tbody>"; 1825 daysInMonth = this._getDaysInMonth( drawYear, drawMonth ); 1826 if ( drawYear === inst.selectedYear && drawMonth === inst.selectedMonth ) { 1827 inst.selectedDay = Math.min( inst.selectedDay, daysInMonth ); 1828 } 1829 leadDays = ( this._getFirstDayOfMonth( drawYear, drawMonth ) - firstDay + 7 ) % 7; 1830 curRows = Math.ceil( ( leadDays + daysInMonth ) / 7 ); // calculate the number of rows to generate 1831 numRows = ( isMultiMonth ? this.maxRows > curRows ? this.maxRows : curRows : curRows ); //If multiple months, use the higher number of rows (see #7043) 1832 this.maxRows = numRows; 1833 printDate = this._daylightSavingAdjust( new Date( drawYear, drawMonth, 1 - leadDays ) ); 1834 for ( dRow = 0; dRow < numRows; dRow++ ) { // create date picker rows 1835 calender += "<tr>"; 1836 tbody = ( !showWeek ? "" : "<td class='ui-datepicker-week-col'>" + 1837 this._get( inst, "calculateWeek" )( printDate ) + "</td>" ); 1838 for ( dow = 0; dow < 7; dow++ ) { // create date picker days 1839 daySettings = ( beforeShowDay ? 1840 beforeShowDay.apply( ( inst.input ? inst.input[ 0 ] : null ), [ printDate ] ) : [ true, "" ] ); 1841 otherMonth = ( printDate.getMonth() !== drawMonth ); 1842 unselectable = ( otherMonth && !selectOtherMonths ) || !daySettings[ 0 ] || 1843 ( minDate && printDate < minDate ) || ( maxDate && printDate > maxDate ); 1844 tbody += "<td class='" + 1845 ( ( dow + firstDay + 6 ) % 7 >= 5 ? " ui-datepicker-week-end" : "" ) + // highlight weekends 1846 ( otherMonth ? " ui-datepicker-other-month" : "" ) + // highlight days from other months 1847 ( ( printDate.getTime() === selectedDate.getTime() && drawMonth === inst.selectedMonth && inst._keyEvent ) || // user pressed key 1848 ( defaultDate.getTime() === printDate.getTime() && defaultDate.getTime() === selectedDate.getTime() ) ? 1849 1850 // or defaultDate is current printedDate and defaultDate is selectedDate 1851 " " + this._dayOverClass : "" ) + // highlight selected day 1852 ( unselectable ? " " + this._unselectableClass + " ui-state-disabled" : "" ) + // highlight unselectable days 1853 ( otherMonth && !showOtherMonths ? "" : " " + daySettings[ 1 ] + // highlight custom dates 1854 ( printDate.getTime() === currentDate.getTime() ? " " + this._currentClass : "" ) + // highlight selected day 1855 ( printDate.getTime() === today.getTime() ? " ui-datepicker-today" : "" ) ) + "'" + // highlight today (if different) 1856 ( ( !otherMonth || showOtherMonths ) && daySettings[ 2 ] ? " title='" + daySettings[ 2 ].replace( /'/g, "'" ) + "'" : "" ) + // cell title 1857 ( unselectable ? "" : " data-handler='selectDay' data-event='click' data-month='" + printDate.getMonth() + "' data-year='" + printDate.getFullYear() + "'" ) + ">" + // actions 1858 ( otherMonth && !showOtherMonths ? " " : // display for other months 1859 ( unselectable ? "<span class='ui-state-default'>" + printDate.getDate() + "</span>" : "<a class='ui-state-default" + 1860 ( printDate.getTime() === today.getTime() ? " ui-state-highlight" : "" ) + 1861 ( printDate.getTime() === currentDate.getTime() ? " ui-state-active" : "" ) + // highlight selected day 1862 ( otherMonth ? " ui-priority-secondary" : "" ) + // distinguish dates from other months 1863 "' href='#'>" + printDate.getDate() + "</a>" ) ) + "</td>"; // display selectable date 1864 printDate.setDate( printDate.getDate() + 1 ); 1865 printDate = this._daylightSavingAdjust( printDate ); 1866 } 1867 calender += tbody + "</tr>"; 1868 } 1869 drawMonth++; 1870 if ( drawMonth > 11 ) { 1871 drawMonth = 0; 1872 drawYear++; 1873 } 1874 calender += "</tbody></table>" + ( isMultiMonth ? "</div>" + 1875 ( ( numMonths[ 0 ] > 0 && col === numMonths[ 1 ] - 1 ) ? "<div class='ui-datepicker-row-break'></div>" : "" ) : "" ); 1876 group += calender; 1877 } 1878 html += group; 1879 } 1880 html += buttonPanel; 1881 inst._keyEvent = false;
vendor: 10,686 bytes, lines 1882-2157
1882 return html; 1883 }, 1884 1885 /* Generate the month and year header. */ 1886 _generateMonthYearHeader: function( inst, drawMonth, drawYear, minDate, maxDate, 1887 secondary, monthNames, monthNamesShort ) { 1888 1889 var inMinYear, inMaxYear, month, years, thisYear, determineYear, year, endYear, 1890 changeMonth = this._get( inst, "changeMonth" ), 1891 changeYear = this._get( inst, "changeYear" ), 1892 showMonthAfterYear = this._get( inst, "showMonthAfterYear" ), 1893 html = "<div class='ui-datepicker-title'>", 1894 monthHtml = ""; 1895 1896 // Month selection 1897 if ( secondary || !changeMonth ) { 1898 monthHtml += "<span class='ui-datepicker-month'>" + monthNames[ drawMonth ] + "</span>"; 1899 } else { 1900 inMinYear = ( minDate && minDate.getFullYear() === drawYear ); 1901 inMaxYear = ( maxDate && maxDate.getFullYear() === drawYear ); 1902 monthHtml += "<select class='ui-datepicker-month' data-handler='selectMonth' data-event='change'>"; 1903 for ( month = 0; month < 12; month++ ) { 1904 if ( ( !inMinYear || month >= minDate.getMonth() ) && ( !inMaxYear || month <= maxDate.getMonth() ) ) { 1905 monthHtml += "<option value='" + month + "'" + 1906 ( month === drawMonth ? " selected='selected'" : "" ) + 1907 ">" + monthNamesShort[ month ] + "</option>"; 1908 } 1909 } 1910 monthHtml += "</select>"; 1911 } 1912 1913 if ( !showMonthAfterYear ) { 1914 html += monthHtml + ( secondary || !( changeMonth && changeYear ) ? " " : "" ); 1915 } 1916 1917 // Year selection 1918 if ( !inst.yearshtml ) { 1919 inst.yearshtml = ""; 1920 if ( secondary || !changeYear ) { 1921 html += "<span class='ui-datepicker-year'>" + drawYear + "</span>"; 1922 } else { 1923 1924 // determine range of years to display 1925 years = this._get( inst, "yearRange" ).split( ":" ); 1926 thisYear = new Date().getFullYear(); 1927 determineYear = function( value ) { 1928 var year = ( value.match( /c[+\-].*/ ) ? drawYear + parseInt( value.substring( 1 ), 10 ) : 1929 ( value.match( /[+\-].*/ ) ? thisYear + parseInt( value, 10 ) : 1930 parseInt( value, 10 ) ) ); 1931 return ( isNaN( year ) ? thisYear : year ); 1932 }; 1933 year = determineYear( years[ 0 ] ); 1934 endYear = Math.max( year, determineYear( years[ 1 ] || "" ) ); 1935 year = ( minDate ? Math.max( year, minDate.getFullYear() ) : year ); 1936 endYear = ( maxDate ? Math.min( endYear, maxDate.getFullYear() ) : endYear ); 1937 inst.yearshtml += "<select class='ui-datepicker-year' data-handler='selectYear' data-event='change'>"; 1938 for ( ; year <= endYear; year++ ) { 1939 inst.yearshtml += "<option value='" + year + "'" + 1940 ( year === drawYear ? " selected='selected'" : "" ) + 1941 ">" + year + "</option>"; 1942 } 1943 inst.yearshtml += "</select>"; 1944 1945 html += inst.yearshtml; 1946 inst.yearshtml = null; 1947 } 1948 } 1949 1950 html += this._get( inst, "yearSuffix" ); 1951 if ( showMonthAfterYear ) { 1952 html += ( secondary || !( changeMonth && changeYear ) ? " " : "" ) + monthHtml; 1953 } 1954 html += "</div>"; // Close datepicker_header 1955 return html; 1956 }, 1957 1958 /* Adjust one of the date sub-fields. */ 1959 _adjustInstDate: function( inst, offset, period ) { 1960 var year = inst.selectedYear + ( period === "Y" ? offset : 0 ), 1961 month = inst.selectedMonth + ( period === "M" ? offset : 0 ), 1962 day = Math.min( inst.selectedDay, this._getDaysInMonth( year, month ) ) + ( period === "D" ? offset : 0 ), 1963 date = this._restrictMinMax( inst, this._daylightSavingAdjust( new Date( year, month, day ) ) ); 1964 1965 inst.selectedDay = date.getDate(); 1966 inst.drawMonth = inst.selectedMonth = date.getMonth(); 1967 inst.drawYear = inst.selectedYear = date.getFullYear(); 1968 if ( period === "M" || period === "Y" ) { 1969 this._notifyChange( inst ); 1970 } 1971 }, 1972 1973 /* Ensure a date is within any min/max bounds. */ 1974 _restrictMinMax: function( inst, date ) { 1975 var minDate = this._getMinMaxDate( inst, "min" ), 1976 maxDate = this._getMinMaxDate( inst, "max" ), 1977 newDate = ( minDate && date < minDate ? minDate : date ); 1978 return ( maxDate && newDate > maxDate ? maxDate : newDate ); 1979 }, 1980 1981 /* Notify change of month/year. */ 1982 _notifyChange: function( inst ) { 1983 var onChange = this._get( inst, "onChangeMonthYear" ); 1984 if ( onChange ) { 1985 onChange.apply( ( inst.input ? inst.input[ 0 ] : null ), 1986 [ inst.selectedYear, inst.selectedMonth + 1, inst ] ); 1987 } 1988 }, 1989 1990 /* Determine the number of months to show. */ 1991 _getNumberOfMonths: function( inst ) { 1992 var numMonths = this._get( inst, "numberOfMonths" ); 1993 return ( numMonths == null ? [ 1, 1 ] : ( typeof numMonths === "number" ? [ 1, numMonths ] : numMonths ) ); 1994 }, 1995 1996 /* Determine the current maximum date - ensure no time components are set. */ 1997 _getMinMaxDate: function( inst, minMax ) { 1998 return this._determineDate( inst, this._get( inst, minMax + "Date" ), null ); 1999 }, 2000 2001 /* Find the number of days in a given month. */ 2002 _getDaysInMonth: function( year, month ) { 2003 return 32 - this._daylightSavingAdjust( new Date( year, month, 32 ) ).getDate(); 2004 }, 2005 2006 /* Find the day of the week of the first of a month. */ 2007 _getFirstDayOfMonth: function( year, month ) { 2008 return new Date( year, month, 1 ).getDay(); 2009 }, 2010 2011 /* Determines if we should allow a "next/prev" month display change. */ 2012 _canAdjustMonth: function( inst, offset, curYear, curMonth ) { 2013 var numMonths = this._getNumberOfMonths( inst ), 2014 date = this._daylightSavingAdjust( new Date( curYear, 2015 curMonth + ( offset < 0 ? offset : numMonths[ 0 ] * numMonths[ 1 ] ), 1 ) ); 2016 2017 if ( offset < 0 ) { 2018 date.setDate( this._getDaysInMonth( date.getFullYear(), date.getMonth() ) ); 2019 } 2020 return this._isInRange( inst, date ); 2021 }, 2022 2023 /* Is the given date in the accepted range? */ 2024 _isInRange: function( inst, date ) { 2025 var yearSplit, currentYear, 2026 minDate = this._getMinMaxDate( inst, "min" ), 2027 maxDate = this._getMinMaxDate( inst, "max" ), 2028 minYear = null, 2029 maxYear = null, 2030 years = this._get( inst, "yearRange" ); 2031 if ( years ) { 2032 yearSplit = years.split( ":" ); 2033 currentYear = new Date().getFullYear(); 2034 minYear = parseInt( yearSplit[ 0 ], 10 ); 2035 maxYear = parseInt( yearSplit[ 1 ], 10 ); 2036 if ( yearSplit[ 0 ].match( /[+\-].*/ ) ) { 2037 minYear += currentYear; 2038 } 2039 if ( yearSplit[ 1 ].match( /[+\-].*/ ) ) { 2040 maxYear += currentYear; 2041 } 2042 } 2043 2044 return ( ( !minDate || date.getTime() >= minDate.getTime() ) && 2045 ( !maxDate || date.getTime() <= maxDate.getTime() ) && 2046 ( !minYear || date.getFullYear() >= minYear ) && 2047 ( !maxYear || date.getFullYear() <= maxYear ) ); 2048 }, 2049 2050 /* Provide the configuration settings for formatting/parsing. */ 2051 _getFormatConfig: function( inst ) { 2052 var shortYearCutoff = this._get( inst, "shortYearCutoff" ); 2053 shortYearCutoff = ( typeof shortYearCutoff !== "string" ? shortYearCutoff : 2054 new Date().getFullYear() % 100 + parseInt( shortYearCutoff, 10 ) ); 2055 return { shortYearCutoff: shortYearCutoff, 2056 dayNamesShort: this._get( inst, "dayNamesShort" ), dayNames: this._get( inst, "dayNames" ), 2057 monthNamesShort: this._get( inst, "monthNamesShort" ), monthNames: this._get( inst, "monthNames" ) }; 2058 }, 2059 2060 /* Format the given date for display. */ 2061 _formatDate: function( inst, day, month, year ) { 2062 if ( !day ) { 2063 inst.currentDay = inst.selectedDay; 2064 inst.currentMonth = inst.selectedMonth; 2065 inst.currentYear = inst.selectedYear; 2066 } 2067 var date = ( day ? ( typeof day === "object" ? day : 2068 this._daylightSavingAdjust( new Date( year, month, day ) ) ) : 2069 this._daylightSavingAdjust( new Date( inst.currentYear, inst.currentMonth, inst.currentDay ) ) ); 2070 return this.formatDate( this._get( inst, "dateFormat" ), date, this._getFormatConfig( inst ) ); 2071 } 2072} ); 2073 2074/* 2075 * Bind hover events for datepicker elements. 2076 * Done via delegate so the binding only occurs once in the lifetime of the parent div. 2077 * Global datepicker_instActive, set by _updateDatepicker allows the handlers to find their way back to the active picker. 2078 */ 2079function datepicker_bindHover( dpDiv ) { 2080 var selector = "button, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-calendar td a"; 2081 return dpDiv.on( "mouseout", selector, function() { 2082 $( this ).removeClass( "ui-state-hover" ); 2083 if ( this.className.indexOf( "ui-datepicker-prev" ) !== -1 ) { 2084 $( this ).removeClass( "ui-datepicker-prev-hover" ); 2085 } 2086 if ( this.className.indexOf( "ui-datepicker-next" ) !== -1 ) { 2087 $( this ).removeClass( "ui-datepicker-next-hover" ); 2088 } 2089 } ) 2090 .on( "mouseover", selector, datepicker_handleMouseover ); 2091} 2092 2093function datepicker_handleMouseover() { 2094 if ( !$.datepicker._isDisabledDatepicker( datepicker_instActive.inline ? datepicker_instActive.dpDiv.parent()[ 0 ] : datepicker_instActive.input[ 0 ] ) ) { 2095 $( this ).parents( ".ui-datepicker-calendar" ).find( "a" ).removeClass( "ui-state-hover" ); 2096 $( this ).addClass( "ui-state-hover" ); 2097 if ( this.className.indexOf( "ui-datepicker-prev" ) !== -1 ) { 2098 $( this ).addClass( "ui-datepicker-prev-hover" ); 2099 } 2100 if ( this.className.indexOf( "ui-datepicker-next" ) !== -1 ) { 2101 $( this ).addClass( "ui-datepicker-next-hover" ); 2102 } 2103 } 2104} 2105 2106/* jQuery extend now ignores nulls! */ 2107function datepicker_extendRemove( target, props ) { 2108 $.extend( target, props ); 2109 for ( var name in props ) { 2110 if ( props[ name ] == null ) { 2111 target[ name ] = props[ name ]; 2112 } 2113 } 2114 return target; 2115} 2116 2117/* Invoke the datepicker functionality. 2118 @param options string - a command, optionally followed by additional parameters or 2119 Object - settings for attaching new datepicker functionality 2120 @return jQuery object */ 2121$.fn.datepicker = function( options ) { 2122 2123 /* Verify an empty collection wasn't passed - Fixes #6976 */ 2124 if ( !this.length ) { 2125 return this; 2126 } 2127 2128 /* Initialise the date picker. */ 2129 if ( !$.datepicker.initialized ) { 2130 $( document ).on( "mousedown", $.datepicker._checkExternalClick ); 2131 $.datepicker.initialized = true; 2132 } 2133 2134 /* Append datepicker main container to body if not exist. */ 2135 if ( $( "#" + $.datepicker._mainDivId ).length === 0 ) { 2136 $( "body" ).append( $.datepicker.dpDiv ); 2137 } 2138 2139 var otherArgs = Array.prototype.slice.call( arguments, 1 ); 2140 if ( typeof options === "string" && ( options === "isDisabled" || options === "getDate" || options === "widget" ) ) { 2141 return $.datepicker[ "_" + options + "Datepicker" ]. 2142 apply( $.datepicker, [ this[ 0 ] ].concat( otherArgs ) ); 2143 } 2144 if ( options === "option" && arguments.length === 2 && typeof arguments[ 1 ] === "string" ) { 2145 return $.datepicker[ "_" + options + "Datepicker" ]. 2146 apply( $.datepicker, [ this[ 0 ] ].concat( otherArgs ) ); 2147 } 2148 return this.each( function() { 2149 typeof options === "string" ? 2150 $.datepicker[ "_" + options + "Datepicker" ]. 2151 apply( $.datepicker, [ this ].concat( otherArgs ) ) : 2152 $.datepicker._attachDatepicker( this, options ); 2153 } ); 2154}; 2155 2156$.datepicker = new Datepicker(); // singleton instance 2157$.datepicker.initialized = false;
2158$.datepicker.uuid = new Date().getTime(); 2159$.datepicker.version = "1.12.1"; 2160 2161var widgetsDatepicker = $.datepicker; 2162 2163 2164 2165 2166}));
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.