Skip to content
This repository was archived by the owner on Feb 18, 2022. It is now read-only.

Commit f62123f

Browse files
committed
linting
1 parent 5a71a68 commit f62123f

File tree

1 file changed

+84
-81
lines changed

1 file changed

+84
-81
lines changed

src/js/angular-datepicker.js

Lines changed: 84 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@
2020
}())
2121
, generateMonthAndYearHeader = function generateMonthAndYearHeader(prevButton, nextButton, preventMobile) {
2222

23-
if (preventMobile) { isMobile = false; }
23+
if (preventMobile) {
24+
25+
isMobile = false;
26+
}
2427

2528
if (isMobile) {
2629

@@ -157,7 +160,7 @@
157160
, date = new Date()
158161
, isMouseOn = false
159162
, isMouseOnInput = false
160-
, preventMobile = ( typeof attr.datepickerMobile !== 'undefined' && attr.datepickerMobile !== 'false' )
163+
, preventMobile = typeof attr.datepickerMobile !== 'undefined' && attr.datepickerMobile !== 'false'
161164
, datetime = $locale.DATETIME_FORMATS
162165
, pageDatepickers
163166
, hours24h = 86400000
@@ -171,6 +174,81 @@
171174
$scope.hideCalendar();
172175
}
173176
}
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+
}
174252
, resetToMinDate = function resetToMinDate() {
175253

176254
$scope.month = $filter('date')(new Date($scope.dateMinLimit), 'MMMM');
@@ -290,81 +368,6 @@
290368
}
291369
return $scope.$eval($scope.datepickerShow);
292370
}
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-
}
368371
, unregisterDataSetWatcher = $scope.$watch('dateSet', function dateSetWatcher(newValue) {
369372

370373
if (newValue) {
@@ -384,17 +387,17 @@
384387
}
385388
}
386389
})
387-
, unregisterDateMinLimitWatcher = $scope.$watch('dateMinLimit', function dateMinLimitWatcher(newValue){
390+
, unregisterDateMinLimitWatcher = $scope.$watch('dateMinLimit', function dateMinLimitWatcher(newValue) {
388391
if (newValue) {
389392
resetToMinDate();
390393
}
391394
})
392-
, unregisterDateMaxLimitWatcher = $scope.$watch('dateMaxLimit', function dateMaxLimitWatcher(newValue){
395+
, unregisterDateMaxLimitWatcher = $scope.$watch('dateMaxLimit', function dateMaxLimitWatcher(newValue) {
393396
if (newValue) {
394397
resetToMaxDate();
395398
}
396399
})
397-
, unregisterDateFormatWatcher = $scope.$watch('dateFormat', function dateFormatWatcher(newValue){
400+
, unregisterDateFormatWatcher = $scope.$watch('dateFormat', function dateFormatWatcher(newValue) {
398401
if (newValue) {
399402
setInputValue();
400403
}
@@ -540,7 +543,7 @@
540543
};
541544

542545
$scope.hideCalendar = function hideCalendar() {
543-
if (theCalendar.classList){
546+
if (theCalendar.classList) {
544547
theCalendar.classList.remove('_720kb-datepicker-open');
545548
} else {
546549

0 commit comments

Comments
 (0)