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,26 @@
1
+ module('Keyboard Navigation (All)', {
2
+ setup: function(){
3
+ this.input = $('<input type="text">')
4
+ .appendTo('#qunit-fixture')
5
+ .datepicker({format: "dd-mm-yyyy"})
6
+ .focus(); // Activate for visibility checks
7
+ this.dp = this.input.data('datepicker')
8
+ this.picker = this.dp.picker;
9
+ },
10
+ teardown: function(){
11
+ this.picker.remove();
12
+ }
13
+ });
14
+
15
+ test('TAB hides picker', function(){
16
+ var target;
17
+
18
+ ok(this.picker.is(':visible'), 'Picker is visible');
19
+
20
+ this.input.trigger({
21
+ type: 'keydown',
22
+ keyCode: 9
23
+ });
24
+
25
+ ok(this.picker.is(':not(:visible)'), 'Picker is hidden');
26
+ });
@@ -0,0 +1,78 @@
1
+ module('Methods', {
2
+ setup: function(){
3
+ this.input = $('<input type="text" value="31-03-2011">')
4
+ .appendTo('#qunit-fixture')
5
+ .datepicker({format: "dd-mm-yyyy"});
6
+ this.dp = this.input.data('datepicker')
7
+ },
8
+ teardown: function(){
9
+ this.dp.remove();
10
+ }
11
+ });
12
+
13
+ // test('remove', function(){
14
+
15
+ // });
16
+
17
+ // test('show', function(){
18
+
19
+ // });
20
+
21
+ // test('hide', function(){
22
+
23
+ // });
24
+
25
+ test('update - String', function(){
26
+ this.dp.update('13-03-2012');
27
+ datesEqual(this.dp.dates[0], UTCDate(2012, 2, 13));
28
+ var date = this.dp.picker.find('.datepicker-days td:contains(13)');
29
+ ok(date.is('.active'), 'Date is selected');
30
+ });
31
+
32
+ test('update - Date', function(){
33
+ this.dp.update(new Date(2012, 2, 13));
34
+ datesEqual(this.dp.dates[0], UTCDate(2012, 2, 13));
35
+ var date = this.dp.picker.find('.datepicker-days td:contains(13)');
36
+ ok(date.is('.active'), 'Date is selected');
37
+ });
38
+
39
+ test('update - null', function(){
40
+ this.dp.update(null);
41
+ equal(this.dp.dates[0], undefined);
42
+ var selected = this.dp.picker.find('.datepicker-days td.active');
43
+ equal(selected.length, 0, 'No date is selected');
44
+ });
45
+
46
+ test('setDate', function(){
47
+ var date_in = new Date(2013, 1, 1),
48
+ expected_date = new Date(Date.UTC(2013, 1, 1));
49
+
50
+ notEqual(this.dp.dates[0], date_in);
51
+ this.dp.setDate(date_in);
52
+ datesEqual(this.dp.dates[0], expected_date);
53
+ });
54
+
55
+ test('setUTCDate', function(){
56
+ var date_in = new Date(Date.UTC(2012, 3, 5)),
57
+ expected_date = date_in;
58
+
59
+ notEqual(this.dp.dates[0], date_in);
60
+ this.dp.setUTCDate(date_in);
61
+ datesEqual(this.dp.dates[0], expected_date);
62
+ });
63
+
64
+ // test('setStartDate', function(){
65
+
66
+ // });
67
+
68
+ // test('setEndDate', function(){
69
+
70
+ // });
71
+
72
+ // test('setDaysOfWeekDisabled - String', function(){
73
+
74
+ // });
75
+
76
+ // test('setDaysOfWeekDisabled - Array', function(){
77
+
78
+ // });
@@ -0,0 +1,66 @@
1
+ module('Mouse Navigation 2011', {
2
+ setup: function(){
3
+ /*
4
+ Tests start with picker on March 31, 2011.
5
+ */
6
+ this.input = $('<input type="text" value="31-03-2011">')
7
+ .appendTo('#qunit-fixture')
8
+ .datepicker({format: "dd-mm-yyyy"})
9
+ .focus(); // Activate for visibility checks
10
+ this.dp = this.input.data('datepicker')
11
+ this.picker = this.dp.picker;
12
+ },
13
+ teardown: function(){
14
+ this.picker.remove();
15
+ }
16
+ });
17
+
18
+ test('Selecting date from previous month while in January changes month and year displayed', function(){
19
+ var target;
20
+
21
+ this.input.val('01-01-2011');
22
+ this.dp.update();
23
+ datesEqual(this.dp.viewDate, UTCDate(2011, 0, 1))
24
+ datesEqual(this.dp.dates.get(-1), UTCDate(2011, 0, 1))
25
+
26
+ // Rendered correctly
27
+ equal(this.dp.viewMode, 0);
28
+ target = this.picker.find('.datepicker-days tbody td:first');
29
+ equal(target.text(), '26'); // Should be Dec 26
30
+ equal(this.picker.find('.datepicker-days thead th.datepicker-switch').text(), 'January 2011');
31
+
32
+ // Updated internally on click
33
+ target.click();
34
+ equal(this.picker.find('.datepicker-days thead th.datepicker-switch').text(), 'December 2010');
35
+ datesEqual(this.dp.viewDate, UTCDate(2010, 11, 26))
36
+ datesEqual(this.dp.dates.get(-1), UTCDate(2010, 11, 26))
37
+
38
+ // Re-rendered on click
39
+ target = this.picker.find('.datepicker-days tbody td:first');
40
+ equal(target.text(), '28'); // Should be Nov 28
41
+ });
42
+
43
+ test('Selecting date from next month while in December changes month and year displayed', function(){
44
+ var target;
45
+
46
+ this.input.val('01-12-2010');
47
+ this.dp.update();
48
+ datesEqual(this.dp.viewDate, UTCDate(2010, 11, 1))
49
+ datesEqual(this.dp.dates.get(-1), UTCDate(2010, 11, 1))
50
+
51
+ // Rendered correctly
52
+ equal(this.dp.viewMode, 0);
53
+ target = this.picker.find('.datepicker-days tbody td:last');
54
+ equal(target.text(), '8'); // Should be Jan 8
55
+ equal(this.picker.find('.datepicker-days thead th.datepicker-switch').text(), 'December 2010');
56
+
57
+ // Updated internally on click
58
+ target.click();
59
+ equal(this.picker.find('.datepicker-days thead th.datepicker-switch').text(), 'January 2011');
60
+ datesEqual(this.dp.viewDate, UTCDate(2011, 0, 8))
61
+ datesEqual(this.dp.dates.get(-1), UTCDate(2011, 0, 8))
62
+
63
+ // Re-rendered on click
64
+ target = this.picker.find('.datepicker-days tbody td:first');
65
+ equal(target.text(), '26'); // Should be Dec 26
66
+ });
@@ -0,0 +1,251 @@
1
+ module('Mouse Navigation 2012', {
2
+ setup: function(){
3
+ /*
4
+ Tests start with picker on March 31, 2012. Fun facts:
5
+
6
+ * February 1, 2012 was on a Wednesday
7
+ * February 29, 2012 was on a Wednesday
8
+ * March 1, 2012 was on a Thursday
9
+ * March 31, 2012 was on a Saturday
10
+ */
11
+ this.input = $('<input type="text" value="31-03-2012">')
12
+ .appendTo('#qunit-fixture')
13
+ .datepicker({format: "dd-mm-yyyy"})
14
+ .focus(); // Activate for visibility checks
15
+ this.dp = this.input.data('datepicker')
16
+ this.picker = this.dp.picker;
17
+ },
18
+ teardown: function(){
19
+ this.picker.remove();
20
+ }
21
+ });
22
+
23
+ test('Selecting date resets viewDate and date', function(){
24
+ var target;
25
+
26
+ // Rendered correctly
27
+ equal(this.dp.viewMode, 0);
28
+ target = this.picker.find('.datepicker-days tbody td:nth(7)');
29
+ equal(target.text(), '4'); // Should be Mar 4
30
+
31
+ // Updated internally on click
32
+ target.click();
33
+ datesEqual(this.dp.viewDate, UTCDate(2012, 2, 4))
34
+ datesEqual(this.dp.dates.get(-1), UTCDate(2012, 2, 4))
35
+
36
+ // Re-rendered on click
37
+ target = this.picker.find('.datepicker-days tbody td:first');
38
+ equal(target.text(), '26'); // Should be Feb 29
39
+ });
40
+
41
+ test('Navigating next/prev by month', function(){
42
+ var target;
43
+
44
+ equal(this.dp.viewMode, 0);
45
+ target = this.picker.find('.datepicker-days thead th.prev');
46
+ ok(target.is(':visible'), 'Month:prev nav is visible');
47
+
48
+ // Updated internally on click
49
+ target.click();
50
+ // Should handle month-length changes gracefully
51
+ datesEqual(this.dp.viewDate, UTCDate(2012, 1, 29));
52
+ datesEqual(this.dp.dates.get(-1), UTCDate(2012, 2, 31));
53
+
54
+ // Re-rendered on click
55
+ target = this.picker.find('.datepicker-days tbody td:first');
56
+ equal(target.text(), '29'); // Should be Jan 29
57
+
58
+ target = this.picker.find('.datepicker-days thead th.next');
59
+ ok(target.is(':visible'), 'Month:next nav is visible');
60
+
61
+ // Updated internally on click
62
+ target.click().click();
63
+ // Graceful moonth-end handling carries over
64
+ datesEqual(this.dp.viewDate, UTCDate(2012, 3, 29));
65
+ datesEqual(this.dp.dates.get(-1), UTCDate(2012, 2, 31));
66
+
67
+ // Re-rendered on click
68
+ target = this.picker.find('.datepicker-days tbody td:first');
69
+ equal(target.text(), '25'); // Should be Mar 25
70
+ // (includes "old" days at start of month, even if that's all the first week-row consists of)
71
+ });
72
+
73
+ test('Navigating to/from year view', function(){
74
+ var target;
75
+
76
+ equal(this.dp.viewMode, 0);
77
+ target = this.picker.find('.datepicker-days thead th.datepicker-switch');
78
+ ok(target.is(':visible'), 'View switcher is visible');
79
+
80
+ target.click();
81
+ ok(this.picker.find('.datepicker-months').is(':visible'), 'Month picker is visible');
82
+ equal(this.dp.viewMode, 1);
83
+ // Not modified when switching modes
84
+ datesEqual(this.dp.viewDate, UTCDate(2012, 2, 31));
85
+ datesEqual(this.dp.dates.get(-1), UTCDate(2012, 2, 31));
86
+
87
+ // Change months to test internal state
88
+ target = this.picker.find('.datepicker-months tbody span:contains(Apr)');
89
+ target.click();
90
+ equal(this.dp.viewMode, 0);
91
+ // Only viewDate modified
92
+ datesEqual(this.dp.viewDate, UTCDate(2012, 3, 1)); // Apr 30
93
+ datesEqual(this.dp.dates.get(-1), UTCDate(2012, 2, 31));
94
+ });
95
+
96
+ test('Navigating to/from decade view', function(){
97
+ var target;
98
+
99
+ equal(this.dp.viewMode, 0);
100
+ target = this.picker.find('.datepicker-days thead th.datepicker-switch');
101
+ ok(target.is(':visible'), 'View switcher is visible');
102
+
103
+ target.click();
104
+ ok(this.picker.find('.datepicker-months').is(':visible'), 'Month picker is visible');
105
+ equal(this.dp.viewMode, 1);
106
+ // Not modified when switching modes
107
+ datesEqual(this.dp.viewDate, UTCDate(2012, 2, 31));
108
+ datesEqual(this.dp.dates.get(-1), UTCDate(2012, 2, 31));
109
+
110
+ target = this.picker.find('.datepicker-months thead th.datepicker-switch');
111
+ ok(target.is(':visible'), 'View switcher is visible');
112
+
113
+ target.click();
114
+ ok(this.picker.find('.datepicker-years').is(':visible'), 'Year picker is visible');
115
+ equal(this.dp.viewMode, 2);
116
+ // Not modified when switching modes
117
+ datesEqual(this.dp.viewDate, UTCDate(2012, 2, 31));
118
+ datesEqual(this.dp.dates.get(-1), UTCDate(2012, 2, 31));
119
+
120
+ // Change years to test internal state changes
121
+ target = this.picker.find('.datepicker-years tbody span:contains(2011)');
122
+ target.click();
123
+ equal(this.dp.viewMode, 1);
124
+ // Only viewDate modified
125
+ datesEqual(this.dp.viewDate, UTCDate(2011, 2, 1));
126
+ datesEqual(this.dp.dates.get(-1), UTCDate(2012, 2, 31));
127
+
128
+ target = this.picker.find('.datepicker-months tbody span:contains(Apr)');
129
+ target.click();
130
+ equal(this.dp.viewMode, 0);
131
+ // Only viewDate modified
132
+ datesEqual(this.dp.viewDate, UTCDate(2011, 3, 1));
133
+ datesEqual(this.dp.dates.get(-1), UTCDate(2012, 2, 31));
134
+ });
135
+
136
+ test('Navigating prev/next in year view', function(){
137
+ var target;
138
+
139
+ equal(this.dp.viewMode, 0);
140
+ target = this.picker.find('.datepicker-days thead th.datepicker-switch');
141
+ ok(target.is(':visible'), 'View switcher is visible');
142
+
143
+ target.click();
144
+ ok(this.picker.find('.datepicker-months').is(':visible'), 'Month picker is visible');
145
+ equal(this.dp.viewMode, 1);
146
+ equal(this.picker.find('.datepicker-months thead th.datepicker-switch').text(), '2012');
147
+ // Not modified when switching modes
148
+ datesEqual(this.dp.viewDate, UTCDate(2012, 2, 31));
149
+ datesEqual(this.dp.dates.get(-1), UTCDate(2012, 2, 31));
150
+
151
+ // Go to next year (2013)
152
+ target = this.picker.find('.datepicker-months thead th.next');
153
+ target.click();
154
+ equal(this.picker.find('.datepicker-months thead th.datepicker-switch').text(), '2013');
155
+ // Only viewDate modified
156
+ datesEqual(this.dp.viewDate, UTCDate(2013, 2, 31));
157
+ datesEqual(this.dp.dates.get(-1), UTCDate(2012, 2, 31));
158
+
159
+ // Go to prev year (x2 == 2011)
160
+ target = this.picker.find('.datepicker-months thead th.prev');
161
+ target.click().click();
162
+ equal(this.picker.find('.datepicker-months thead th.datepicker-switch').text(), '2011');
163
+ // Only viewDate modified
164
+ datesEqual(this.dp.viewDate, UTCDate(2011, 2, 31));
165
+ datesEqual(this.dp.dates.get(-1), UTCDate(2012, 2, 31));
166
+ });
167
+
168
+ test('Navigating prev/next in decade view', function(){
169
+ var target;
170
+
171
+ equal(this.dp.viewMode, 0);
172
+ target = this.picker.find('.datepicker-days thead th.datepicker-switch');
173
+ ok(target.is(':visible'), 'View switcher is visible');
174
+
175
+ target.click();
176
+ ok(this.picker.find('.datepicker-months').is(':visible'), 'Month picker is visible');
177
+ equal(this.dp.viewMode, 1);
178
+ // Not modified when switching modes
179
+ datesEqual(this.dp.viewDate, UTCDate(2012, 2, 31));
180
+ datesEqual(this.dp.dates.get(-1), UTCDate(2012, 2, 31));
181
+
182
+ target = this.picker.find('.datepicker-months thead th.datepicker-switch');
183
+ ok(target.is(':visible'), 'View switcher is visible');
184
+
185
+ target.click();
186
+ ok(this.picker.find('.datepicker-years').is(':visible'), 'Year picker is visible');
187
+ equal(this.dp.viewMode, 2);
188
+ equal(this.picker.find('.datepicker-years thead th.datepicker-switch').text(), '2010-2019');
189
+ // Not modified when switching modes
190
+ datesEqual(this.dp.viewDate, UTCDate(2012, 2, 31));
191
+ datesEqual(this.dp.dates.get(-1), UTCDate(2012, 2, 31));
192
+
193
+ // Go to next decade (2020-29)
194
+ target = this.picker.find('.datepicker-years thead th.next');
195
+ target.click();
196
+ equal(this.picker.find('.datepicker-years thead th.datepicker-switch').text(), '2020-2029');
197
+ // Only viewDate modified
198
+ datesEqual(this.dp.viewDate, UTCDate(2022, 2, 31));
199
+ datesEqual(this.dp.dates.get(-1), UTCDate(2012, 2, 31));
200
+
201
+ // Go to prev year (x2 == 2000-09)
202
+ target = this.picker.find('.datepicker-years thead th.prev');
203
+ target.click().click();
204
+ equal(this.picker.find('.datepicker-years thead th.datepicker-switch').text(), '2000-2009');
205
+ // Only viewDate modified
206
+ datesEqual(this.dp.viewDate, UTCDate(2002, 2, 31));
207
+ datesEqual(this.dp.dates.get(-1), UTCDate(2012, 2, 31));
208
+ });
209
+
210
+ test('Selecting date from previous month resets viewDate and date, changing month displayed', function(){
211
+ var target;
212
+
213
+ // Rendered correctly
214
+ equal(this.dp.viewMode, 0);
215
+ target = this.picker.find('.datepicker-days tbody td:first');
216
+ equal(target.text(), '26'); // Should be Feb 26
217
+ equal(this.picker.find('.datepicker-days thead th.datepicker-switch').text(), 'March 2012');
218
+
219
+ // Updated internally on click
220
+ target.click();
221
+ equal(this.picker.find('.datepicker-days thead th.datepicker-switch').text(), 'February 2012');
222
+ datesEqual(this.dp.viewDate, UTCDate(2012, 1, 26))
223
+ datesEqual(this.dp.dates.get(-1), UTCDate(2012, 1, 26))
224
+
225
+ // Re-rendered on click
226
+ target = this.picker.find('.datepicker-days tbody td:first');
227
+ equal(target.text(), '29'); // Should be Jan 29
228
+ });
229
+
230
+ test('Selecting date from next month resets viewDate and date, changing month displayed', function(){
231
+ var target;
232
+
233
+ this.input.val('01-04-2012');
234
+ this.dp.update();
235
+
236
+ // Rendered correctly
237
+ equal(this.dp.viewMode, 0);
238
+ target = this.picker.find('.datepicker-days tbody td:last');
239
+ equal(target.text(), '5'); // Should be May 5
240
+ equal(this.picker.find('.datepicker-days thead th.datepicker-switch').text(), 'April 2012');
241
+
242
+ // Updated internally on click
243
+ target.click();
244
+ equal(this.picker.find('.datepicker-days thead th.datepicker-switch').text(), 'May 2012');
245
+ datesEqual(this.dp.viewDate, UTCDate(2012, 4, 5))
246
+ datesEqual(this.dp.dates.get(-1), UTCDate(2012, 4, 5))
247
+
248
+ // Re-rendered on click
249
+ target = this.picker.find('.datepicker-days tbody td:first');
250
+ equal(target.text(), '29'); // Should be Apr 29
251
+ });
@@ -0,0 +1,33 @@
1
+ module('Mouse Navigation (All)', {
2
+ setup: function(){
3
+ this.input = $('<input type="text">')
4
+ .appendTo('#qunit-fixture')
5
+ .datepicker({format: "dd-mm-yyyy"})
6
+ .focus(); // Activate for visibility checks
7
+ this.dp = this.input.data('datepicker')
8
+ this.picker = this.dp.picker;
9
+ },
10
+ teardown: function(){
11
+ this.picker.remove();
12
+ }
13
+ });
14
+
15
+ test('Clicking datepicker does not hide datepicker', function(){
16
+ ok(this.picker.is(':visible'), 'Picker is visible');
17
+ this.picker.trigger('mousedown');
18
+ ok(this.picker.is(':visible'), 'Picker is still visible');
19
+ });
20
+
21
+ test('Clicking outside datepicker hides datepicker', function(){
22
+ var $otherelement = $('<div />');
23
+ $('body').append($otherelement);
24
+
25
+ ok(this.picker.is(':visible'), 'Picker is visible');
26
+ this.input.trigger('click');
27
+ ok(this.picker.is(':visible'), 'Picker is still visible');
28
+
29
+ $otherelement.trigger('mousedown');
30
+ ok(this.picker.is(':not(:visible)'), 'Picker is hidden');
31
+
32
+ $otherelement.remove();
33
+ });