jquery-ui_ui_widgets_datepicker__js.js 81 KB

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