jqueryui-requirejs-rails 0.1.0

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