|
20 | 20 | }())
|
21 | 21 | , generateMonthAndYearHeader = function generateMonthAndYearHeader(prevButton, nextButton, preventMobile) {
|
22 | 22 |
|
23 |
| - if (preventMobile) { isMobile = false; } |
| 23 | + if (preventMobile) { |
| 24 | + |
| 25 | + isMobile = false; |
| 26 | + } |
24 | 27 |
|
25 | 28 | if (isMobile) {
|
26 | 29 |
|
|
157 | 160 | , date = new Date()
|
158 | 161 | , isMouseOn = false
|
159 | 162 | , isMouseOnInput = false
|
160 |
| - , preventMobile = ( typeof attr.datepickerMobile !== 'undefined' && attr.datepickerMobile !== 'false' ) |
| 163 | + , preventMobile = typeof attr.datepickerMobile !== 'undefined' && attr.datepickerMobile !== 'false' |
161 | 164 | , datetime = $locale.DATETIME_FORMATS
|
162 | 165 | , pageDatepickers
|
163 | 166 | , hours24h = 86400000
|
|
171 | 174 | $scope.hideCalendar();
|
172 | 175 | }
|
173 | 176 | }
|
| 177 | + , setDaysInMonth = function setDaysInMonth(month, year) { |
| 178 | + |
| 179 | + var i |
| 180 | + , limitDate = new Date(year, month, 0).getDate() |
| 181 | + , firstDayMonthNumber = new Date(year + '/' + month + '/' + 1).getDay() |
| 182 | + , lastDayMonthNumber = new Date(year + '/' + month + '/' + limitDate).getDay() |
| 183 | + , prevMonthDays = [] |
| 184 | + , nextMonthDays = [] |
| 185 | + , howManyNextDays |
| 186 | + , howManyPreviousDays |
| 187 | + , monthAlias |
| 188 | + , dateWeekEndDay; |
| 189 | + |
| 190 | + $scope.days = []; |
| 191 | + $scope.dateWeekStartDay = $scope.validateWeekDay($scope.dateWeekStartDay); |
| 192 | + dateWeekEndDay = ($scope.dateWeekStartDay + 6) % 7; |
| 193 | + |
| 194 | + for (i = 1; i <= limitDate; i += 1) { |
| 195 | + |
| 196 | + $scope.days.push(i); |
| 197 | + } |
| 198 | + |
| 199 | + //get previous month days if first day in month is not first day in week |
| 200 | + if (firstDayMonthNumber === $scope.dateWeekStartDay) { |
| 201 | + |
| 202 | + //no need for it |
| 203 | + $scope.prevMonthDays = []; |
| 204 | + } else { |
| 205 | + |
| 206 | + howManyPreviousDays = firstDayMonthNumber - $scope.dateWeekStartDay; |
| 207 | + |
| 208 | + if (firstDayMonthNumber < $scope.dateWeekStartDay) { |
| 209 | + |
| 210 | + howManyPreviousDays += 7; |
| 211 | + } |
| 212 | + |
| 213 | + //get previous month |
| 214 | + if (Number(month) === 1) { |
| 215 | + |
| 216 | + monthAlias = 12; |
| 217 | + } else { |
| 218 | + |
| 219 | + monthAlias = month - 1; |
| 220 | + } |
| 221 | + //return previous month days |
| 222 | + for (i = 1; i <= new Date(year, monthAlias, 0).getDate(); i += 1) { |
| 223 | + |
| 224 | + prevMonthDays.push(i); |
| 225 | + } |
| 226 | + //attach previous month days |
| 227 | + $scope.prevMonthDays = prevMonthDays.slice(-howManyPreviousDays); |
| 228 | + } |
| 229 | + |
| 230 | + //get next month days if last day in month is not last day in week |
| 231 | + if (lastDayMonthNumber === dateWeekEndDay) { |
| 232 | + //no need for it |
| 233 | + $scope.nextMonthDays = []; |
| 234 | + } else { |
| 235 | + howManyNextDays = 6 - lastDayMonthNumber + $scope.dateWeekStartDay; |
| 236 | + |
| 237 | + if (lastDayMonthNumber < $scope.dateWeekStartDay) { |
| 238 | + |
| 239 | + howManyNextDays -= 7; |
| 240 | + } |
| 241 | + //get previous month |
| 242 | + |
| 243 | + //return next month days |
| 244 | + for (i = 1; i <= howManyNextDays; i += 1) { |
| 245 | + |
| 246 | + nextMonthDays.push(i); |
| 247 | + } |
| 248 | + //attach previous month days |
| 249 | + $scope.nextMonthDays = nextMonthDays; |
| 250 | + } |
| 251 | + } |
174 | 252 | , resetToMinDate = function resetToMinDate() {
|
175 | 253 |
|
176 | 254 | $scope.month = $filter('date')(new Date($scope.dateMinLimit), 'MMMM');
|
|
290 | 368 | }
|
291 | 369 | return $scope.$eval($scope.datepickerShow);
|
292 | 370 | }
|
293 |
| - , setDaysInMonth = function setDaysInMonth(month, year) { |
294 |
| - |
295 |
| - var i |
296 |
| - , limitDate = new Date(year, month, 0).getDate() |
297 |
| - , firstDayMonthNumber = new Date(year + '/' + month + '/' + 1).getDay() |
298 |
| - , lastDayMonthNumber = new Date(year + '/' + month + '/' + limitDate).getDay() |
299 |
| - , prevMonthDays = [] |
300 |
| - , nextMonthDays = [] |
301 |
| - , howManyNextDays |
302 |
| - , howManyPreviousDays |
303 |
| - , monthAlias |
304 |
| - , dateWeekEndDay; |
305 |
| - |
306 |
| - $scope.days = []; |
307 |
| - $scope.dateWeekStartDay = $scope.validateWeekDay($scope.dateWeekStartDay); |
308 |
| - dateWeekEndDay = ($scope.dateWeekStartDay + 6) % 7; |
309 |
| - |
310 |
| - for (i = 1; i <= limitDate; i += 1) { |
311 |
| - |
312 |
| - $scope.days.push(i); |
313 |
| - } |
314 |
| - |
315 |
| - //get previous month days if first day in month is not first day in week |
316 |
| - if (firstDayMonthNumber === $scope.dateWeekStartDay) { |
317 |
| - |
318 |
| - //no need for it |
319 |
| - $scope.prevMonthDays = []; |
320 |
| - } else { |
321 |
| - |
322 |
| - howManyPreviousDays = firstDayMonthNumber - $scope.dateWeekStartDay; |
323 |
| - |
324 |
| - if (firstDayMonthNumber < $scope.dateWeekStartDay) { |
325 |
| - |
326 |
| - howManyPreviousDays += 7; |
327 |
| - } |
328 |
| - |
329 |
| - //get previous month |
330 |
| - if (Number(month) === 1) { |
331 |
| - |
332 |
| - monthAlias = 12; |
333 |
| - } else { |
334 |
| - |
335 |
| - monthAlias = month - 1; |
336 |
| - } |
337 |
| - //return previous month days |
338 |
| - for (i = 1; i <= new Date(year, monthAlias, 0).getDate(); i += 1) { |
339 |
| - |
340 |
| - prevMonthDays.push(i); |
341 |
| - } |
342 |
| - //attach previous month days |
343 |
| - $scope.prevMonthDays = prevMonthDays.slice(-howManyPreviousDays); |
344 |
| - } |
345 |
| - |
346 |
| - //get next month days if last day in month is not last day in week |
347 |
| - if (lastDayMonthNumber === dateWeekEndDay) { |
348 |
| - //no need for it |
349 |
| - $scope.nextMonthDays = []; |
350 |
| - } else { |
351 |
| - howManyNextDays = 6 - lastDayMonthNumber + $scope.dateWeekStartDay; |
352 |
| - |
353 |
| - if (lastDayMonthNumber < $scope.dateWeekStartDay) { |
354 |
| - |
355 |
| - howManyNextDays -= 7; |
356 |
| - } |
357 |
| - //get previous month |
358 |
| - |
359 |
| - //return next month days |
360 |
| - for (i = 1; i <= howManyNextDays; i += 1) { |
361 |
| - |
362 |
| - nextMonthDays.push(i); |
363 |
| - } |
364 |
| - //attach previous month days |
365 |
| - $scope.nextMonthDays = nextMonthDays; |
366 |
| - } |
367 |
| - } |
368 | 371 | , unregisterDataSetWatcher = $scope.$watch('dateSet', function dateSetWatcher(newValue) {
|
369 | 372 |
|
370 | 373 | if (newValue) {
|
|
384 | 387 | }
|
385 | 388 | }
|
386 | 389 | })
|
387 |
| - , unregisterDateMinLimitWatcher = $scope.$watch('dateMinLimit', function dateMinLimitWatcher(newValue){ |
| 390 | + , unregisterDateMinLimitWatcher = $scope.$watch('dateMinLimit', function dateMinLimitWatcher(newValue) { |
388 | 391 | if (newValue) {
|
389 | 392 | resetToMinDate();
|
390 | 393 | }
|
391 | 394 | })
|
392 |
| - , unregisterDateMaxLimitWatcher = $scope.$watch('dateMaxLimit', function dateMaxLimitWatcher(newValue){ |
| 395 | + , unregisterDateMaxLimitWatcher = $scope.$watch('dateMaxLimit', function dateMaxLimitWatcher(newValue) { |
393 | 396 | if (newValue) {
|
394 | 397 | resetToMaxDate();
|
395 | 398 | }
|
396 | 399 | })
|
397 |
| - , unregisterDateFormatWatcher = $scope.$watch('dateFormat', function dateFormatWatcher(newValue){ |
| 400 | + , unregisterDateFormatWatcher = $scope.$watch('dateFormat', function dateFormatWatcher(newValue) { |
398 | 401 | if (newValue) {
|
399 | 402 | setInputValue();
|
400 | 403 | }
|
|
540 | 543 | };
|
541 | 544 |
|
542 | 545 | $scope.hideCalendar = function hideCalendar() {
|
543 |
| - if (theCalendar.classList){ |
| 546 | + if (theCalendar.classList) { |
544 | 547 | theCalendar.classList.remove('_720kb-datepicker-open');
|
545 | 548 | } else {
|
546 | 549 |
|
|
0 commit comments