|
547 | 547 | return this.meridien === 'PM'; |
548 | 548 | }, |
549 | 549 | incrementMonth: function (amount) { |
550 | | - if (amount === 1 && this.isNextMonthVisible()) { |
551 | | - this.selectDate(this.currentDate.add(amount, 'month')); |
552 | | - } |
553 | | - |
554 | | - if (amount === -1 && this.isPreviousMonthVisible()) { |
| 550 | + if ((amount === 1 && this.isNextMonthVisible()) || (amount === -1 && this.isPreviousMonthVisible())) { |
555 | 551 | this.selectDate(this.currentDate.add(amount, 'month')); |
556 | 552 | } |
557 | 553 | }, |
558 | 554 | incrementYear: function (amount) { |
559 | | - if (amount === 1 && this.isNextYearVisible()) { |
560 | | - this.selectDate(this.currentDate.add(amount, 'year')); |
561 | | - } |
562 | | - |
563 | | - if (amount === -1 && this.isPreviousYearVisible()) { |
| 555 | + if ((amount === 1 && this.isNextYearVisible()) || (amount === -1 && this.isPreviousYearVisible())) { |
564 | 556 | this.selectDate(this.currentDate.add(amount, 'year')); |
565 | 557 | } |
566 | 558 | }, |
567 | 559 | openMenu: function ($mdMenu, ev) { |
568 | 560 | $mdMenu.open(ev); |
569 | 561 | }, |
570 | 562 | monthsAvailable: function () { |
571 | | - var monthsArr = [], |
572 | | - _date = moment(this.currentDate); |
| 563 | + var monthsArr = [], _date = moment(this.currentDate); |
573 | 564 |
|
574 | 565 | for (var m = 0; m < 12; m++) { |
575 | 566 | var curMonth = _date.month(m); |
|
788 | 779 | var YEAR_MIN = 1920, |
789 | 780 | YEAR_MAX = new Date().getFullYear() + 30, |
790 | 781 | MONTHS_IN_ALL = (YEAR_MAX - YEAR_MIN + 1) * 12, |
791 | | - ITEM_HEIGHT = 240, |
792 | 782 | MONTHS = []; |
793 | 783 | for (var i = 0; i < MONTHS_IN_ALL; i++) { |
794 | 784 | MONTHS.push(i); |
795 | 785 | } |
796 | 786 |
|
797 | 787 | var currentMonthIndex = function (date, low) { |
798 | 788 | low = low ? low : 0; |
799 | | - var year = date.year(); |
800 | | - var month = date.month(); |
801 | | - return (((year - YEAR_MIN) * 12) + month - 1) - low; |
| 789 | + return (((date.year() - YEAR_MIN) * 12) + date.month() - 1) - low; |
802 | 790 | }; |
803 | 791 |
|
804 | 792 | return { |
|
826 | 814 | calendar.months = MONTHS; |
827 | 815 | } else { |
828 | 816 | var low = picker.minDate ? currentMonthIndex(picker.minDate) : 0; |
829 | | - var high = picker.maxDate ? (currentMonthIndex(picker.maxDate) + 1) : MONTHS_IN_ALL; |
| 817 | + var high = picker.maxDate ? (currentMonthIndex(picker.maxDate) +1) : MONTHS_IN_ALL; |
830 | 818 | calendar.months = MONTHS.slice(low, high); |
831 | 819 | } |
832 | 820 |
|
|
847 | 835 | }, function (val2, val1) { |
848 | 836 | if (val2 != val1) { |
849 | 837 | var nDate = moment(val2, 'YYYY-MM'); |
850 | | - var low = picker.minDate ? currentMonthIndex(picker.minDate) : 0; |
| 838 | + var low = picker.minDate ? currentMonthIndex(picker.minDate): 0; |
851 | 839 | var index = currentMonthIndex(nDate, low); |
852 | 840 | if (calendar.topIndex != index) { |
853 | 841 | calendar.topIndex = index; |
|
927 | 915 | }], |
928 | 916 | template: |
929 | 917 | '<md-virtual-repeat-container md-top-index="cal.topIndex" class="months">' + |
930 | | - '<div md-virtual-repeat="idx in ::cal.months" md-auto-shrink md-item-size="' + ITEM_HEIGHT + '">' + |
| 918 | + '<div md-virtual-repeat="idx in cal.months">' + |
931 | 919 | ' <div mdc-datetime-picker-calendar-month idx="idx"></div>' + |
932 | 920 | '</div>' + |
933 | 921 | '</md-virtual-repeat-container>' |
|
0 commit comments