bootstrap-datepicker 1.1.1

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 (123) hide show
  1. data/.gitignore +7 -0
  2. data/.hgignore +3 -0
  3. data/.hgtags +9 -0
  4. data/.travis.yml +4 -0
  5. data/CHANGELOG.md +89 -0
  6. data/CONTRIBUTING.md +40 -0
  7. data/Gemfile +4 -0
  8. data/Gruntfile.js +165 -0
  9. data/LICENSE +202 -0
  10. data/README.md +24 -0
  11. data/Rakefile +1 -0
  12. data/bootstrap-datepicker.gemspec +26 -0
  13. data/bower.json +9 -0
  14. data/build/build.less +67 -0
  15. data/build/build3.less +71 -0
  16. data/build/build_standalone.less +61 -0
  17. data/build/build_standalone3.less +63 -0
  18. data/composer.json +19 -0
  19. data/css/datepicker.css +509 -0
  20. data/css/datepicker3.css +790 -0
  21. data/docs/Makefile +153 -0
  22. data/docs/REAME.md +8 -0
  23. data/docs/_static/demo_head.png +0 -0
  24. data/docs/conf.py +248 -0
  25. data/docs/events.rst +48 -0
  26. data/docs/i18n.rst +28 -0
  27. data/docs/index.rst +122 -0
  28. data/docs/keyboard.rst +30 -0
  29. data/docs/make.bat +190 -0
  30. data/docs/markup.rst +50 -0
  31. data/docs/methods.rst +156 -0
  32. data/docs/options.rst +191 -0
  33. data/js/bootstrap-datepicker.js +1609 -0
  34. data/js/locales/bootstrap-datepicker.ar.js +15 -0
  35. data/js/locales/bootstrap-datepicker.bg.js +14 -0
  36. data/js/locales/bootstrap-datepicker.ca.js +14 -0
  37. data/js/locales/bootstrap-datepicker.cs.js +15 -0
  38. data/js/locales/bootstrap-datepicker.cy.js +14 -0
  39. data/js/locales/bootstrap-datepicker.da.js +15 -0
  40. data/js/locales/bootstrap-datepicker.de.js +17 -0
  41. data/js/locales/bootstrap-datepicker.el.js +13 -0
  42. data/js/locales/bootstrap-datepicker.es.js +14 -0
  43. data/js/locales/bootstrap-datepicker.et.js +18 -0
  44. data/js/locales/bootstrap-datepicker.fa.js +17 -0
  45. data/js/locales/bootstrap-datepicker.fi.js +16 -0
  46. data/js/locales/bootstrap-datepicker.fr.js +17 -0
  47. data/js/locales/bootstrap-datepicker.gl.js +11 -0
  48. data/js/locales/bootstrap-datepicker.he.js +15 -0
  49. data/js/locales/bootstrap-datepicker.hr.js +13 -0
  50. data/js/locales/bootstrap-datepicker.hu.js +16 -0
  51. data/js/locales/bootstrap-datepicker.id.js +15 -0
  52. data/js/locales/bootstrap-datepicker.is.js +14 -0
  53. data/js/locales/bootstrap-datepicker.it.js +16 -0
  54. data/js/locales/bootstrap-datepicker.ja.js +15 -0
  55. data/js/locales/bootstrap-datepicker.ka.js +17 -0
  56. data/js/locales/bootstrap-datepicker.kk.js +15 -0
  57. data/js/locales/bootstrap-datepicker.kr.js +13 -0
  58. data/js/locales/bootstrap-datepicker.lt.js +16 -0
  59. data/js/locales/bootstrap-datepicker.lv.js +16 -0
  60. data/js/locales/bootstrap-datepicker.mk.js +15 -0
  61. data/js/locales/bootstrap-datepicker.ms.js +14 -0
  62. data/js/locales/bootstrap-datepicker.nb.js +14 -0
  63. data/js/locales/bootstrap-datepicker.nl-BE.js +17 -0
  64. data/js/locales/bootstrap-datepicker.nl.js +14 -0
  65. data/js/locales/bootstrap-datepicker.no.js +16 -0
  66. data/js/locales/bootstrap-datepicker.pl.js +15 -0
  67. data/js/locales/bootstrap-datepicker.pt-BR.js +15 -0
  68. data/js/locales/bootstrap-datepicker.pt.js +16 -0
  69. data/js/locales/bootstrap-datepicker.ro.js +15 -0
  70. data/js/locales/bootstrap-datepicker.rs-latin.js +14 -0
  71. data/js/locales/bootstrap-datepicker.rs.js +14 -0
  72. data/js/locales/bootstrap-datepicker.ru.js +15 -0
  73. data/js/locales/bootstrap-datepicker.sk.js +15 -0
  74. data/js/locales/bootstrap-datepicker.sl.js +14 -0
  75. data/js/locales/bootstrap-datepicker.sq.js +15 -0
  76. data/js/locales/bootstrap-datepicker.sv.js +16 -0
  77. data/js/locales/bootstrap-datepicker.sw.js +15 -0
  78. data/js/locales/bootstrap-datepicker.th.js +14 -0
  79. data/js/locales/bootstrap-datepicker.tr.js +16 -0
  80. data/js/locales/bootstrap-datepicker.ua.js +15 -0
  81. data/js/locales/bootstrap-datepicker.uk.js +14 -0
  82. data/js/locales/bootstrap-datepicker.vi.js +16 -0
  83. data/js/locales/bootstrap-datepicker.zh-CN.js +16 -0
  84. data/js/locales/bootstrap-datepicker.zh-TW.js +17 -0
  85. data/less/datepicker.less +265 -0
  86. data/less/datepicker3.less +252 -0
  87. data/lib/bootstrap-datepicker.rb +11 -0
  88. data/lib/bootstrap-datepicker/version.rb +9 -0
  89. data/package.json +32 -0
  90. data/sass/build_standalone-sass.scss +70 -0
  91. data/sass/datepicker.scss +270 -0
  92. data/test/Readme.md +9 -0
  93. data/test/less_test.js +19 -0
  94. data/test/scss_test.js +19 -0
  95. data/test/support/less.patch +4 -0
  96. data/test/support/scss.patch +493 -0
  97. data/tests/README.md +55 -0
  98. data/tests/_coverage.html +26 -0
  99. data/tests/assets/coverage.js +48 -0
  100. data/tests/assets/jquery-1.7.1.min.js +4 -0
  101. data/tests/assets/mock.js +26 -0
  102. data/tests/assets/qunit-logging.js +29 -0
  103. data/tests/assets/qunit.css +235 -0
  104. data/tests/assets/qunit.js +1669 -0
  105. data/tests/assets/utils.js +21 -0
  106. data/tests/run-qunit.js +157 -0
  107. data/tests/suites/calendar-weeks.js +48 -0
  108. data/tests/suites/component.js +202 -0
  109. data/tests/suites/data-api.js +114 -0
  110. data/tests/suites/events.js +306 -0
  111. data/tests/suites/formats.js +235 -0
  112. data/tests/suites/inline.js +28 -0
  113. data/tests/suites/keyboard_navigation/2011.js +92 -0
  114. data/tests/suites/keyboard_navigation/2012.js +468 -0
  115. data/tests/suites/keyboard_navigation/all.js +26 -0
  116. data/tests/suites/methods.js +78 -0
  117. data/tests/suites/mouse_navigation/2011.js +66 -0
  118. data/tests/suites/mouse_navigation/2012.js +251 -0
  119. data/tests/suites/mouse_navigation/all.js +33 -0
  120. data/tests/suites/noconflict.js +20 -0
  121. data/tests/suites/options.js +648 -0
  122. data/tests/tests.html +50 -0
  123. metadata +240 -0
@@ -0,0 +1,20 @@
1
+ module('NoConflict', {
2
+ setup: function(){
3
+ var datepicker = $.fn.datepicker.noConflict();
4
+ $.fn.bootstrapDP = datepicker;
5
+ },
6
+ teardown: function(){
7
+ $.fn.datepicker = $.fn.bootstrapDP;
8
+ delete $.fn.bootstrapDP;
9
+ }
10
+ });
11
+
12
+ test('Datepicker starts after calling noConflict() (no undefined defaults or locale_opts)', function(){
13
+ $('<div class="input-append date" id="datepicker">'+
14
+ '<input size="16" type="text" value="12-02-2012" readonly>'+
15
+ '<span class="add-on"><i class="icon-th"></i></span>'+
16
+ '</div>')
17
+ .appendTo('#qunit-fixture')
18
+ .bootstrapDP();
19
+ expect(0);
20
+ });
@@ -0,0 +1,648 @@
1
+ module('Options', {
2
+ setup: function(){},
3
+ teardown: function(){
4
+ $('#qunit-fixture *').each(function(){
5
+ var t = $(this);
6
+ if ('datepicker' in t.data())
7
+ t.datepicker('remove');
8
+ });
9
+ }
10
+ });
11
+
12
+ test('Autoclose', function(){
13
+ var input = $('<input />')
14
+ .appendTo('#qunit-fixture')
15
+ .val('2012-03-05')
16
+ .datepicker({
17
+ format: 'yyyy-mm-dd',
18
+ autoclose: true
19
+ }),
20
+ dp = input.data('datepicker'),
21
+ picker = dp.picker,
22
+ target;
23
+
24
+
25
+ input.focus();
26
+ ok(picker.is(':visible'), 'Picker is visible');
27
+ target = picker.find('.datepicker-days tbody td:nth(7)');
28
+ equal(target.text(), '4'); // Mar 4
29
+
30
+ target.click();
31
+ ok(picker.is(':not(:visible)'), 'Picker is hidden');
32
+ datesEqual(dp.dates[0], UTCDate(2012, 2, 4));
33
+ datesEqual(dp.viewDate, UTCDate(2012, 2, 4));
34
+ });
35
+
36
+ test('Startview: year view (integer)', function(){
37
+ var input = $('<input />')
38
+ .appendTo('#qunit-fixture')
39
+ .val('2012-03-05')
40
+ .datepicker({
41
+ format: 'yyyy-mm-dd',
42
+ startView: 1
43
+ }),
44
+ dp = input.data('datepicker'),
45
+ picker = dp.picker,
46
+ target;
47
+
48
+ input.focus();
49
+ ok(picker.find('.datepicker-days').is(':not(:visible)'), 'Days view hidden');
50
+ ok(picker.find('.datepicker-months').is(':visible'), 'Months view visible');
51
+ ok(picker.find('.datepicker-years').is(':not(:visible)'), 'Years view hidden');
52
+ });
53
+
54
+ test('Startview: year view (string)', function(){
55
+ var input = $('<input />')
56
+ .appendTo('#qunit-fixture')
57
+ .val('2012-03-05')
58
+ .datepicker({
59
+ format: 'yyyy-mm-dd',
60
+ startView: 'year'
61
+ }),
62
+ dp = input.data('datepicker'),
63
+ picker = dp.picker,
64
+ target;
65
+
66
+ input.focus();
67
+ ok(picker.find('.datepicker-days').is(':not(:visible)'), 'Days view hidden');
68
+ ok(picker.find('.datepicker-months').is(':visible'), 'Months view visible');
69
+ ok(picker.find('.datepicker-years').is(':not(:visible)'), 'Years view hidden');
70
+ });
71
+
72
+ test('Startview: decade view (integer)', function(){
73
+ var input = $('<input />')
74
+ .appendTo('#qunit-fixture')
75
+ .val('2012-03-05')
76
+ .datepicker({
77
+ format: 'yyyy-mm-dd',
78
+ startView: 2
79
+ }),
80
+ dp = input.data('datepicker'),
81
+ picker = dp.picker,
82
+ target;
83
+
84
+ input.focus();
85
+ ok(picker.find('.datepicker-days').is(':not(:visible)'), 'Days view hidden');
86
+ ok(picker.find('.datepicker-months').is(':not(:visible)'), 'Months view hidden');
87
+ ok(picker.find('.datepicker-years').is(':visible'), 'Years view visible');
88
+ });
89
+
90
+ test('Startview: decade view (string)', function(){
91
+ var input = $('<input />')
92
+ .appendTo('#qunit-fixture')
93
+ .val('2012-03-05')
94
+ .datepicker({
95
+ format: 'yyyy-mm-dd',
96
+ startView: 'decade'
97
+ }),
98
+ dp = input.data('datepicker'),
99
+ picker = dp.picker,
100
+ target;
101
+
102
+ input.focus();
103
+ ok(picker.find('.datepicker-days').is(':not(:visible)'), 'Days view hidden');
104
+ ok(picker.find('.datepicker-months').is(':not(:visible)'), 'Months view hidden');
105
+ ok(picker.find('.datepicker-years').is(':visible'), 'Years view visible');
106
+ });
107
+
108
+ test('Today Button: today button not default', function(){
109
+ var input = $('<input />')
110
+ .appendTo('#qunit-fixture')
111
+ .val('2012-03-05')
112
+ .datepicker({
113
+ format: 'yyyy-mm-dd'
114
+ }),
115
+ dp = input.data('datepicker'),
116
+ picker = dp.picker,
117
+ target;
118
+
119
+ input.focus();
120
+ ok(picker.find('.datepicker-days').is(':visible'), 'Days view visible');
121
+ ok(picker.find('.datepicker-days tfoot .today').is(':not(:visible)'), 'Today button not visible');
122
+ });
123
+
124
+ test('Today Button: today visibility when enabled', function(){
125
+ var input = $('<input />')
126
+ .appendTo('#qunit-fixture')
127
+ .val('2012-03-05')
128
+ .datepicker({
129
+ format: 'yyyy-mm-dd',
130
+ todayBtn: true
131
+ }),
132
+ dp = input.data('datepicker'),
133
+ picker = dp.picker,
134
+ target;
135
+
136
+ input.focus();
137
+ ok(picker.find('.datepicker-days').is(':visible'), 'Days view visible');
138
+ ok(picker.find('.datepicker-days tfoot .today').is(':visible'), 'Today button visible');
139
+
140
+ picker.find('.datepicker-days thead th.datepicker-switch').click();
141
+ ok(picker.find('.datepicker-months').is(':visible'), 'Months view visible');
142
+ ok(picker.find('.datepicker-months tfoot .today').is(':visible'), 'Today button visible');
143
+
144
+ picker.find('.datepicker-months thead th.datepicker-switch').click();
145
+ ok(picker.find('.datepicker-years').is(':visible'), 'Years view visible');
146
+ ok(picker.find('.datepicker-years tfoot .today').is(':visible'), 'Today button visible');
147
+ });
148
+
149
+ test('Today Button: data-api', function(){
150
+ var input = $('<input data-date-today-btn="true" />')
151
+ .appendTo('#qunit-fixture')
152
+ .val('2012-03-05')
153
+ .datepicker({
154
+ format: 'yyyy-mm-dd'
155
+ }),
156
+ dp = input.data('datepicker'),
157
+ picker = dp.picker,
158
+ target;
159
+
160
+ input.focus();
161
+ ok(picker.find('.datepicker-days').is(':visible'), 'Days view visible');
162
+ ok(picker.find('.datepicker-days tfoot .today').is(':visible'), 'Today button visible');
163
+ });
164
+
165
+ test('Today Button: moves to today\'s date', function(){
166
+ var input = $('<input />')
167
+ .appendTo('#qunit-fixture')
168
+ .val('2012-03-05')
169
+ .datepicker({
170
+ format: 'yyyy-mm-dd',
171
+ todayBtn: true
172
+ }),
173
+ dp = input.data('datepicker'),
174
+ picker = dp.picker,
175
+ target;
176
+
177
+ input.focus();
178
+ ok(picker.find('.datepicker-days').is(':visible'), 'Days view visible');
179
+ ok(picker.find('.datepicker-days tfoot .today').is(':visible'), 'Today button visible');
180
+
181
+ target = picker.find('.datepicker-days tfoot .today');
182
+ target.click();
183
+
184
+ var d = new Date(),
185
+ today = UTCDate(d.getFullYear(), d.getMonth(), d.getDate());
186
+ datesEqual(dp.viewDate, today);
187
+ datesEqual(dp.dates[0], UTCDate(2012, 2, 5));
188
+ });
189
+
190
+ test('Today Button: "linked" selects today\'s date', function(){
191
+ var input = $('<input />')
192
+ .appendTo('#qunit-fixture')
193
+ .val('2012-03-05')
194
+ .datepicker({
195
+ format: 'yyyy-mm-dd',
196
+ todayBtn: "linked"
197
+ }),
198
+ dp = input.data('datepicker'),
199
+ picker = dp.picker,
200
+ target;
201
+
202
+ input.focus();
203
+ ok(picker.find('.datepicker-days').is(':visible'), 'Days view visible');
204
+ ok(picker.find('.datepicker-days tfoot .today').is(':visible'), 'Today button visible');
205
+
206
+ target = picker.find('.datepicker-days tfoot .today');
207
+ target.click();
208
+
209
+ var d = new Date(),
210
+ today = UTCDate(d.getFullYear(), d.getMonth(), d.getDate());
211
+ datesEqual(dp.viewDate, today);
212
+ datesEqual(dp.dates[0], today);
213
+ });
214
+
215
+ test('Today Highlight: today\'s date is not highlighted by default', patch_date(function(Date){
216
+ Date.now = UTCDate(2012, 2, 15);
217
+ var input = $('<input />')
218
+ .appendTo('#qunit-fixture')
219
+ .val('2012-03-05')
220
+ .datepicker({
221
+ format: 'yyyy-mm-dd'
222
+ }),
223
+ dp = input.data('datepicker'),
224
+ picker = dp.picker,
225
+ target;
226
+
227
+ input.focus();
228
+ ok(picker.find('.datepicker-days').is(':visible'), 'Days view visible');
229
+ equal(picker.find('.datepicker-days thead .datepicker-switch').text(), 'March 2012', 'Title is "March 2012"');
230
+
231
+ target = picker.find('.datepicker-days tbody td:contains(15)');
232
+ ok(!target.hasClass('today'), 'Today is not marked with "today" class');
233
+ target = picker.find('.datepicker-days tbody td:contains(14)');
234
+ ok(!target.hasClass('today'), 'Yesterday is not marked with "today" class');
235
+ target = picker.find('.datepicker-days tbody td:contains(16)');
236
+ ok(!target.hasClass('today'), 'Tomorrow is not marked with "today" class');
237
+ }));
238
+
239
+ test('Today Highlight: today\'s date is highlighted when not active', patch_date(function(Date){
240
+ Date.now = new Date(2012, 2, 15);
241
+ var input = $('<input />')
242
+ .appendTo('#qunit-fixture')
243
+ .val('2012-03-05')
244
+ .datepicker({
245
+ format: 'yyyy-mm-dd',
246
+ todayHighlight: true
247
+ }),
248
+ dp = input.data('datepicker'),
249
+ picker = dp.picker,
250
+ target;
251
+
252
+ input.focus();
253
+ ok(picker.find('.datepicker-days').is(':visible'), 'Days view visible');
254
+ equal(picker.find('.datepicker-days thead .datepicker-switch').text(), 'March 2012', 'Title is "March 2012"');
255
+
256
+ target = picker.find('.datepicker-days tbody td:contains(15)');
257
+ ok(target.hasClass('today'), 'Today is marked with "today" class');
258
+ target = picker.find('.datepicker-days tbody td:contains(14)');
259
+ ok(!target.hasClass('today'), 'Yesterday is not marked with "today" class');
260
+ target = picker.find('.datepicker-days tbody td:contains(16)');
261
+ ok(!target.hasClass('today'), 'Tomorrow is not marked with "today" class');
262
+ }));
263
+
264
+ test('Clear Button: clear visibility when enabled', function(){
265
+ var input = $('<input />')
266
+ .appendTo('#qunit-fixture')
267
+ .val('2012-03-05')
268
+ .datepicker({
269
+ format: 'yyyy-mm-dd',
270
+ clearBtn: true
271
+ }),
272
+ dp = input.data('datepicker'),
273
+ picker = dp.picker,
274
+ target;
275
+
276
+ input.focus();
277
+ ok(picker.find('.datepicker-days').is(':visible'), 'Days view visible');
278
+ ok(picker.find('.datepicker-days tfoot .clear').is(':visible'), 'Clear button visible');
279
+
280
+ picker.find('.datepicker-days thead th.datepicker-switch').click();
281
+ ok(picker.find('.datepicker-months').is(':visible'), 'Months view visible');
282
+ ok(picker.find('.datepicker-months tfoot .clear').is(':visible'), 'Clear button visible');
283
+
284
+ picker.find('.datepicker-months thead th.datepicker-switch').click();
285
+ ok(picker.find('.datepicker-years').is(':visible'), 'Years view visible');
286
+ ok(picker.find('.datepicker-years tfoot .clear').is(':visible'), 'Clear button visible');
287
+ });
288
+
289
+ test('Clear Button: clears input value', function(){
290
+ var input = $('<input />')
291
+ .appendTo('#qunit-fixture')
292
+ .val('2012-03-05')
293
+ .datepicker({
294
+ format: 'yyyy-mm-dd',
295
+ clearBtn: true
296
+ }),
297
+ dp = input.data('datepicker'),
298
+ picker = dp.picker,
299
+ target;
300
+
301
+ input.focus();
302
+ ok(picker.find('.datepicker-days').is(':visible'), 'Days view visible');
303
+ ok(picker.find('.datepicker-days tfoot .clear').is(':visible'), 'Today button visible');
304
+
305
+ target = picker.find('.datepicker-days tfoot .clear');
306
+ target.click();
307
+
308
+ equal(input.val(),'',"Input value has been cleared.")
309
+ ok(picker.is(':visible'), 'Picker is visible');
310
+ });
311
+
312
+ test('Clear Button: hides datepicker if autoclose is on', function(){
313
+ var input = $('<input />')
314
+ .appendTo('#qunit-fixture')
315
+ .val('2012-03-05')
316
+ .datepicker({
317
+ format: 'yyyy-mm-dd',
318
+ clearBtn: true,
319
+ autoclose: true
320
+ }),
321
+ dp = input.data('datepicker'),
322
+ picker = dp.picker,
323
+ target;
324
+
325
+ input.focus();
326
+ ok(picker.find('.datepicker-days').is(':visible'), 'Days view visible');
327
+ ok(picker.find('.datepicker-days tfoot .clear').is(':visible'), 'Today button visible');
328
+
329
+ target = picker.find('.datepicker-days tfoot .clear');
330
+ target.click();
331
+
332
+ equal(input.val(),'',"Input value has been cleared.");
333
+ ok(picker.is(':not(:visible)'), 'Picker is hidden');
334
+
335
+ });
336
+
337
+ test('DaysOfWeekDisabled', function(){
338
+ var input = $('<input />')
339
+ .appendTo('#qunit-fixture')
340
+ .val('2012-10-26')
341
+ .datepicker({
342
+ format: 'yyyy-mm-dd',
343
+ daysOfWeekDisabled: '1,5'
344
+ }),
345
+ dp = input.data('datepicker'),
346
+ picker = dp.picker,
347
+ target;
348
+
349
+
350
+ input.focus();
351
+ target = picker.find('.datepicker-days tbody td:nth(22)');
352
+ ok(target.hasClass('disabled'), 'Day of week is disabled');
353
+ target = picker.find('.datepicker-days tbody td:nth(24)');
354
+ ok(!target.hasClass('disabled'), 'Day of week is enabled');
355
+ target = picker.find('.datepicker-days tbody td:nth(26)');
356
+ ok(target.hasClass('disabled'), 'Day of week is disabled');
357
+ });
358
+
359
+ test('BeforeShowDay', function(){
360
+
361
+ var beforeShowDay = function(date) {
362
+ var dateTime = UTCDate(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate()).getTime();
363
+ var dateTime25th = UTCDate(2012, 9, 25).getTime();
364
+ var dateTime26th = UTCDate(2012, 9, 26).getTime();
365
+ var dateTime27th = UTCDate(2012, 9, 27).getTime();
366
+ var dateTime28th = UTCDate(2012, 9, 28).getTime();
367
+
368
+ if (dateTime == dateTime25th) {
369
+ return {tooltip: 'A tooltip'};
370
+ }
371
+ else if (dateTime == dateTime26th) {
372
+ return 'test26';
373
+ }
374
+ else if (dateTime == dateTime27th) {
375
+ return {enabled: false, classes:'test27'};
376
+ }
377
+ else if (dateTime == dateTime28th) {
378
+ return false;
379
+ }
380
+ };
381
+
382
+ var input = $('<input />')
383
+ .appendTo('#qunit-fixture')
384
+ .val('2012-10-26')
385
+ .datepicker({
386
+ format: 'yyyy-mm-dd',
387
+ beforeShowDay: beforeShowDay
388
+ }),
389
+ dp = input.data('datepicker'),
390
+ picker = dp.picker,
391
+ target;
392
+
393
+ input.focus();
394
+ target = picker.find('.datepicker-days tbody td:nth(25)');
395
+ equal(target.attr('title'), 'A tooltip', '25th has tooltip');
396
+ ok(!target.hasClass('disabled'), '25th is enabled');
397
+ target = picker.find('.datepicker-days tbody td:nth(26)');
398
+ ok(target.hasClass('test26'), '26th has test26 class');
399
+ ok(!target.hasClass('disabled'), '26th is enabled');
400
+ target = picker.find('.datepicker-days tbody td:nth(27)');
401
+ ok(target.hasClass('test27'), '27th has test27 class');
402
+ ok(target.hasClass('disabled'), '27th is disabled');
403
+ target = picker.find('.datepicker-days tbody td:nth(28)');
404
+ ok(target.hasClass('disabled'), '28th is disabled');
405
+ target = picker.find('.datepicker-days tbody td:nth(29)');
406
+ ok(!target.hasClass('disabled'), '29th is enabled');
407
+ });
408
+
409
+ test('Orientation: values are parsed correctly', function(){
410
+
411
+ var input = $('<input />')
412
+ .appendTo('#qunit-fixture')
413
+ .val('2012-10-26')
414
+ .datepicker({
415
+ format: 'yyyy-mm-dd'
416
+ }),
417
+ dp = input.data('datepicker');
418
+
419
+ equal(dp.o.orientation.x, 'auto');
420
+ equal(dp.o.orientation.y, 'auto');
421
+
422
+ dp._process_options({orientation: ''});
423
+ equal(dp.o.orientation.x, 'auto', 'Empty value');
424
+ equal(dp.o.orientation.y, 'auto', 'Empty value');
425
+
426
+ dp._process_options({orientation: 'left'});
427
+ equal(dp.o.orientation.x, 'left', '"left"');
428
+ equal(dp.o.orientation.y, 'auto', '"left"');
429
+
430
+ dp._process_options({orientation: 'right'});
431
+ equal(dp.o.orientation.x, 'right', '"right"');
432
+ equal(dp.o.orientation.y, 'auto', '"right"');
433
+
434
+ dp._process_options({orientation: 'top'});
435
+ equal(dp.o.orientation.x, 'auto', '"top"');
436
+ equal(dp.o.orientation.y, 'top', '"top"');
437
+
438
+ dp._process_options({orientation: 'bottom'});
439
+ equal(dp.o.orientation.x, 'auto', '"bottom"');
440
+ equal(dp.o.orientation.y, 'bottom', '"bottom"');
441
+
442
+ dp._process_options({orientation: 'left top'});
443
+ equal(dp.o.orientation.x, 'left', '"left top"');
444
+ equal(dp.o.orientation.y, 'top', '"left top"');
445
+
446
+ dp._process_options({orientation: 'left bottom'});
447
+ equal(dp.o.orientation.x, 'left', '"left bottom"');
448
+ equal(dp.o.orientation.y, 'bottom', '"left bottom"');
449
+
450
+ dp._process_options({orientation: 'right top'});
451
+ equal(dp.o.orientation.x, 'right', '"right top"');
452
+ equal(dp.o.orientation.y, 'top', '"right top"');
453
+
454
+ dp._process_options({orientation: 'right bottom'});
455
+ equal(dp.o.orientation.x, 'right', '"right bottom"');
456
+ equal(dp.o.orientation.y, 'bottom', '"right bottom"');
457
+
458
+ dp._process_options({orientation: 'left right'});
459
+ equal(dp.o.orientation.x, 'left', '"left right"');
460
+ equal(dp.o.orientation.y, 'auto', '"left right"');
461
+
462
+ dp._process_options({orientation: 'right left'});
463
+ equal(dp.o.orientation.x, 'right', '"right left"');
464
+ equal(dp.o.orientation.y, 'auto', '"right left"');
465
+
466
+ dp._process_options({orientation: 'top bottom'});
467
+ equal(dp.o.orientation.x, 'auto', '"top bottom"');
468
+ equal(dp.o.orientation.y, 'top', '"top bottom"');
469
+
470
+ dp._process_options({orientation: 'bottom top'});
471
+ equal(dp.o.orientation.x, 'auto', '"bottom top"');
472
+ equal(dp.o.orientation.y, 'bottom', '"bottom top"');
473
+
474
+ dp._process_options({orientation: 'foo bar'});
475
+ equal(dp.o.orientation.x, 'auto', '"foo bar"');
476
+ equal(dp.o.orientation.y, 'auto', '"foo bar"');
477
+
478
+ dp._process_options({orientation: 'foo left'});
479
+ equal(dp.o.orientation.x, 'left', '"foo left"');
480
+ equal(dp.o.orientation.y, 'auto', '"foo left"');
481
+
482
+ dp._process_options({orientation: 'top bar'});
483
+ equal(dp.o.orientation.x, 'auto', '"top bar"');
484
+ equal(dp.o.orientation.y, 'top', '"top bar"');
485
+ });
486
+
487
+ test('startDate', function(){
488
+ var input = $('<input />')
489
+ .appendTo('#qunit-fixture')
490
+ .val('2012-10-26')
491
+ .datepicker({
492
+ format: 'yyyy-mm-dd',
493
+ startDate: new Date(2012, 9, 26)
494
+ }),
495
+ dp = input.data('datepicker'),
496
+ picker = dp.picker,
497
+ target;
498
+
499
+ input.focus();
500
+ target = picker.find('.datepicker-days tbody td:nth(25)');
501
+ ok(target.hasClass('disabled'), 'Previous day is disabled');
502
+ target = picker.find('.datepicker-days tbody td:nth(26)');
503
+ ok(!target.hasClass('disabled'), 'Specified date is enabled');
504
+ target = picker.find('.datepicker-days tbody td:nth(27)');
505
+ ok(!target.hasClass('disabled'), 'Next day is enabled');
506
+ });
507
+
508
+ test('endDate', function(){
509
+ var input = $('<input />')
510
+ .appendTo('#qunit-fixture')
511
+ .val('2012-10-26')
512
+ .datepicker({
513
+ format: 'yyyy-mm-dd',
514
+ endDate: new Date(2012, 9, 26)
515
+ }),
516
+ dp = input.data('datepicker'),
517
+ picker = dp.picker,
518
+ target;
519
+
520
+ input.focus();
521
+ target = picker.find('.datepicker-days tbody td:nth(25)');
522
+ ok(!target.hasClass('disabled'), 'Previous day is enabled');
523
+ target = picker.find('.datepicker-days tbody td:nth(26)');
524
+ ok(!target.hasClass('disabled'), 'Specified date is enabled');
525
+ target = picker.find('.datepicker-days tbody td:nth(27)');
526
+ ok(target.hasClass('disabled'), 'Next day is disabled');
527
+ });
528
+
529
+ test('Multidate', function(){
530
+ var input = $('<input />')
531
+ .appendTo('#qunit-fixture')
532
+ .val('2012-03-05')
533
+ .datepicker({
534
+ format: 'yyyy-mm-dd',
535
+ multidate: true
536
+ }),
537
+ dp = input.data('datepicker'),
538
+ picker = dp.picker,
539
+ target;
540
+
541
+ input.focus();
542
+
543
+ // Initial value is selected
544
+ ok(dp.dates.contains(UTCDate(2012, 2, 5)) !== -1, '2012-03-05 (initial date) in dates');
545
+
546
+ // Select first
547
+ target = picker.find('.datepicker-days tbody td:nth(7)');
548
+ equal(target.text(), '4'); // Mar 4
549
+
550
+ target.click();
551
+ datesEqual(dp.dates.get(-1), UTCDate(2012, 2, 4), '2012-03-04 in dates');
552
+ datesEqual(dp.viewDate, UTCDate(2012, 2, 4));
553
+ equal(input.val(), '2012-03-05,2012-03-04');
554
+
555
+ // Select second
556
+ target = picker.find('.datepicker-days tbody td:nth(15)');
557
+ equal(target.text(), '12'); // Mar 12
558
+
559
+ target.click();
560
+ datesEqual(dp.dates.get(-1), UTCDate(2012, 2, 12), '2012-03-12 in dates');
561
+ datesEqual(dp.viewDate, UTCDate(2012, 2, 12));
562
+ equal(input.val(), '2012-03-05,2012-03-04,2012-03-12');
563
+
564
+ // Deselect first
565
+ target = picker.find('.datepicker-days tbody td:nth(7)');
566
+ equal(target.text(), '4'); // Mar 4
567
+
568
+ target.click();
569
+ ok(dp.dates.contains(UTCDate(2012, 2, 4)) === -1, '2012-03-04 no longer in dates');
570
+ datesEqual(dp.viewDate, UTCDate(2012, 2, 4));
571
+ equal(input.val(), '2012-03-05,2012-03-12');
572
+ });
573
+
574
+ test('Multidate with limit', function(){
575
+ var input = $('<input />')
576
+ .appendTo('#qunit-fixture')
577
+ .val('2012-03-05')
578
+ .datepicker({
579
+ format: 'yyyy-mm-dd',
580
+ multidate: 2
581
+ }),
582
+ dp = input.data('datepicker'),
583
+ picker = dp.picker,
584
+ target;
585
+
586
+ input.focus();
587
+
588
+ // Initial value is selected
589
+ ok(dp.dates.contains(UTCDate(2012, 2, 5)) !== -1, '2012-03-05 (initial date) in dates');
590
+
591
+ // Select first
592
+ target = picker.find('.datepicker-days tbody td:nth(7)');
593
+ equal(target.text(), '4'); // Mar 4
594
+
595
+ target.click();
596
+ datesEqual(dp.dates.get(-1), UTCDate(2012, 2, 4), '2012-03-04 in dates');
597
+ datesEqual(dp.viewDate, UTCDate(2012, 2, 4));
598
+ equal(input.val(), '2012-03-05,2012-03-04');
599
+
600
+ // Select second
601
+ target = picker.find('.datepicker-days tbody td:nth(15)');
602
+ equal(target.text(), '12'); // Mar 12
603
+
604
+ target.click();
605
+ datesEqual(dp.dates.get(-1), UTCDate(2012, 2, 12), '2012-03-12 in dates');
606
+ datesEqual(dp.viewDate, UTCDate(2012, 2, 12));
607
+ equal(input.val(), '2012-03-04,2012-03-12');
608
+
609
+ // Select third
610
+ target = picker.find('.datepicker-days tbody td:nth(20)');
611
+ equal(target.text(), '17'); // Mar 17
612
+
613
+ target.click();
614
+ datesEqual(dp.dates.get(-1), UTCDate(2012, 2, 17), '2012-03-17 in dates');
615
+ ok(dp.dates.contains(UTCDate(2012, 2, 4)) === -1, '2012-03-04 no longer in dates');
616
+ datesEqual(dp.viewDate, UTCDate(2012, 2, 17));
617
+ equal(input.val(), '2012-03-12,2012-03-17');
618
+ });
619
+
620
+ test('Multidate Separator', function(){
621
+ var input = $('<input />')
622
+ .appendTo('#qunit-fixture')
623
+ .val('2012-03-05')
624
+ .datepicker({
625
+ format: 'yyyy-mm-dd',
626
+ multidate: true,
627
+ multidateSeparator: ' '
628
+ }),
629
+ dp = input.data('datepicker'),
630
+ picker = dp.picker,
631
+ target;
632
+
633
+ input.focus();
634
+
635
+ // Select first
636
+ target = picker.find('.datepicker-days tbody td:nth(7)');
637
+ equal(target.text(), '4'); // Mar 4
638
+
639
+ target.click();
640
+ equal(input.val(), '2012-03-05 2012-03-04');
641
+
642
+ // Select second
643
+ target = picker.find('.datepicker-days tbody td:nth(15)');
644
+ equal(target.text(), '12'); // Mar 12
645
+
646
+ target.click();
647
+ equal(input.val(), '2012-03-05 2012-03-04 2012-03-12');
648
+ });