Changeset 133565 in webkit
- Timestamp:
- Nov 5, 2012 11:18:12 PM (11 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r133563 r133565 1 2012-11-05 Keishi Hattori <keishi@webkit.org> 2 3 Introduce Day class to calendar picker 4 https://bugs.webkit.org/show_bug.cgi?id=101194 5 6 Reviewed by Kent Tamura. 7 8 Introducing Day class so day, week, and month can all be abstracted. To 9 solve some of the complexity around which months to show, I made 10 CalendarPicker in charge of it. This also made YearMonthController and 11 DaysTable independent of each other. 12 13 No new tests. Covered by existing calendar-picker-*.html tests. 14 15 * Resources/pagepopups/calendarPicker.js: 16 (createUTCDate): Allow negative month or date. 17 (parseDateString): Will return Day or Month depending on string format. 18 (Day): Represents a day. 19 (Day.parse): Parse yyyy-mm-dd. 20 (Day.createFromDate): Creates a Day that contains a datetime. 21 (Day.createFromToday): Creates Day for today. A method with the same name will be added to Week and Month in the future. 22 (Day.prototype.equals): Returns true if they are the same. 23 (Day.prototype.previous): Returns the previous day. 24 (Day.prototype.next): Returns the next day. 25 (Day.prototype.startDate): Returns the datetime that is the start of this day. 26 (Day.prototype.endDate): Returns the datetime that is the start of this day. 27 (Day.prototype.valueOf): Returns the milliseconds since epoch. 28 (Day.prototype.toString): Returns an ISO date string. 29 (Month): Fix bug in calculating month from value. 30 (Month.prototype.endDate): Use Day.Maximum. 31 (CalendarPicker): Added _currentMonth. yearMonthController and daysTable can be private members now. 32 (CalendarPicker.prototype._layout): 33 (CalendarPicker.prototype.handleToday): Use Day.createFromToday. 34 (CalendarPicker.prototype.shouldShowMonth): Returns true if the month should be shown. 35 (CalendarPicker.prototype.showMonth): Shows the given month. If the month is out of the range of months that should be shown, we clamp the month and show that. 36 (CalendarPicker.prototype.currentMonth): Returns the current month that is shown. 37 (YearMonthController): Removed _currentMonth. 38 (YearMonthController.prototype.attachTo): 39 (YearMonthController.prototype.setMonth): 40 (YearMonthController.prototype._handleYearMonthChange): Use CalendarPicker.showMonth 41 (YearMonthController.prototype.moveRelatively): 42 (DaysTable): 43 (CalendarPicker.prototype._stepMismatch): Made private. 44 (CalendarPicker.prototype._outOfRange): Made private. 45 (CalendarPicker.prototype.isValidDate): Take Day or Month instead of milliseconds since epoch. 46 (DaysTable.prototype._renderMonth): 47 (DaysTable.prototype.navigateToMonth): Shows a given month. Can use animation and leave the selection position as is. 48 (DaysTable.prototype.selectRange): Select a range. 49 (DaysTable.prototype._maybeSetPreviousMonth): 50 (DaysTable.prototype._maybeSetNextMonth): 51 (DaysTable.prototype._handleKey): 52 (CalendarPicker.prototype._handleBodyKeyDown): 53 1 54 2012-11-05 Kenichi Ishibashi <bashi@chromium.org> 2 55 -
trunk/Source/WebCore/Resources/pagepopups/calendarPicker.js
r133434 r133565 176 176 177 177 function createUTCDate(year, month, date) { 178 var newDate = new Date(Date.UTC(year, month, date)); 179 if (year < 100) 180 newDate.setUTCFullYear(year); 178 var newDate = new Date(0); 179 newDate.setUTCFullYear(year); 180 newDate.setUTCMonth(month); 181 newDate.setUTCDate(date); 181 182 return newDate; 182 183 }; 183 184 184 185 /** 185 * @param {string=} opt_current 186 * @param {string} dateString 187 * @return {?Day|Month} 188 */ 189 function parseDateString(dateString) { 190 var month = Month.parse(dateString); 191 if (month) 192 return month; 193 return Day.parse(dateString); 194 } 195 196 /** 197 * @param {!number|Day} valueOrDayOrYear 198 * @param {!number=} month 199 * @param {!number=} date 200 */ 201 function Day(valueOrDayOrYear, month, date) { 202 var dateObject; 203 if (arguments.length == 3) 204 dateObject = createUTCDate(valueOrDayOrYear, month, date); 205 else if (valueOrDayOrYear instanceof Day) 206 dateObject = createUTCDate(valueOrDayOrYear.year, valueOrDayOrYear.month, valueOrDayOrYear.date); 207 else 208 dateObject = new Date(valueOrDayOrYear); 209 this.year = dateObject.getUTCFullYear(); 210 this.month = dateObject.getUTCMonth(); 211 this.date = dateObject.getUTCDate(); 212 }; 213 214 Day.ISOStringRegExp = /^(\d+)-(\d+)-(\d+)$/; 215 216 // See WebCore/platform/DateComponents.h. 217 Day.Minimum = new Date(-62135596800000.0); 218 Day.Maximum = new Date(8640000000000000.0); 219 220 /** 221 * @param {!string} str 222 * @return {?Month} 223 */ 224 Day.parse = function(str) { 225 var match = Day.ISOStringRegExp.exec(str); 226 if (!match) 227 return null; 228 var year = parseInt(match[1], 10); 229 var month = parseInt(match[2], 10) - 1; 230 var date = parseInt(match[3], 10); 231 return new Day(year, month, date); 232 }; 233 /** 234 * @param {!Date} date 235 * @return {!Month} 236 */ 237 Day.createFromDate = function(date) { 238 return new Day(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate()); 239 }; 240 241 Day.createFromToday = function() { 242 var now = new Date(); 243 return new Day(now.getFullYear(), now.getMonth(), now.getDate()); 244 } 245 246 /** 247 * @param {!Day} other 248 * @return {!bool} 249 */ 250 Day.prototype.equals = function(other) { 251 return this.year === other.year && this.month === other.month && this.date === other.date; 252 }; 253 254 /** 255 * @return {!Day} 256 */ 257 Day.prototype.previous = function() { 258 return new Day(this.year, this.month, this.date - 1); 259 }; 260 261 /** 262 * @return {!Day} 263 */ 264 Day.prototype.next = function() { 265 return new Day(this.year, this.month, this.date + 1); 266 }; 267 268 /** 186 269 * @return {!Date} 187 270 */ 188 function parseDateString(opt_current) { 189 if (opt_current) { 190 var result = opt_current.match(/(\d+)-(\d+)-(\d+)/); 191 if (result) 192 return createUTCDate(Number(result[1]), Number(result[2]) - 1, Number(result[3])); 193 } 194 var now = new Date(); 195 // Create UTC date with same numbers as local date. 196 return createUTCDate(now.getFullYear(), now.getMonth(), now.getDate()); 197 } 198 199 /** 200 * @param {!number} year 201 * @param {!number} month 202 * @param {!number} day 271 Day.prototype.startDate = function() { 272 return createUTCDate(this.year, this.month, this.date); 273 }; 274 275 /** 276 * @return {!Date} 277 */ 278 Day.prototype.endDate = function() { 279 return createUTCDate(this.year, this.month, this.date + 1); 280 }; 281 282 /** 283 * @return {!number} 284 */ 285 Day.prototype.valueOf = function() { 286 return this.startDate().getTime(); 287 }; 288 289 /** 203 290 * @return {!string} 204 291 */ 205 function serializeDate(year, month, day) {206 var yearString = String( year);292 Day.prototype.toString = function() { 293 var yearString = String(this.year); 207 294 if (yearString.length < 4) 208 295 yearString = ("000" + yearString).substr(-4, 4); 209 return yearString + "-" + ("0" + ( month + 1)).substr(-2, 2) + "-" + ("0" + day).substr(-2, 2);210 } 296 return yearString + "-" + ("0" + (this.month + 1)).substr(-2, 2) + "-" + ("0" + this.date).substr(-2, 2); 297 }; 211 298 212 299 /** … … 222 309 this.month = valueOrMonthOrYear.month; 223 310 } else { 224 this.year = Math.floor(valueOrMonthOrYear / 12) +1970;225 this.month = valueOrMonthOrYear % 12;311 this.year = 1970; 312 this.month = valueOrMonthOrYear; 226 313 } 227 314 this.year = this.year + Math.floor(this.month / 12); 228 315 this.month = this.month < 0 ? this.month % 12 + 12 : this.month % 12; 229 if (this.year < 0 || Month.Maximum < this) {316 if (this.year <= 0 || Month.Maximum < this) { 230 317 this.year = NaN; 231 318 this.month = NaN; … … 293 380 Month.prototype.endDate = function() { 294 381 if (this.equals(Month.Maximum)) 295 return CalendarPicker.MaximumPossibleDate;382 return Day.Maximum.startDate(); 296 383 return this.next().startDate(); 297 384 }; … … 419 506 window.addEventListener("resize", this._handleWindowResizeBound, false); 420 507 // We assume this._config.min is a valid date. 421 this. minimumDate = (typeof this._config.min !== "undefined") ? parseDateString(this._config.min) : CalendarPicker.MinimumPossibleDate;508 this._minimumValue = (typeof this._config.min !== "undefined") ? parseDateString(this._config.min).valueOf() : Day.Minimum.valueOf(); 422 509 // We assume this._config.max is a valid date. 423 this. maximumDate = (typeof this._config.max !== "undefined") ? parseDateString(this._config.max) : CalendarPicker.MaximumPossibleDate;510 this._maximumValue = (typeof this._config.max !== "undefined") ? parseDateString(this._config.max).valueOf() : Day.Maximum.valueOf(); 424 511 this.step = (typeof this._config.step !== undefined) ? Number(this._config.step) : CalendarPicker.DefaultStepScaleFactor; 425 512 this.stepBase = (typeof this._config.stepBase !== "undefined") ? Number(this._config.stepBase) : CalendarPicker.DefaultStepBase; 426 this.yearMonthController = new YearMonthController(this); 427 this.daysTable = new DaysTable(this); 513 this._minimumMonth = Month.createFromDate(new Date(this._minimumValue)); 514 this.maximumMonth = Month.createFromDate(new Date(this._maximumValue)); 515 this._currentMonth = new Month(NaN, NaN); 516 this._yearMonthController = new YearMonthController(this); 517 this._daysTable = new DaysTable(this); 428 518 this._hadKeyEvent = false; 429 519 this._layout(); 430 var initialDate = parseDateString(this._config.currentValue); 431 if (initialDate < this.minimumDate) 432 initialDate = this.minimumDate; 433 else if (initialDate > this.maximumDate) 434 initialDate = this.maximumDate; 435 this.daysTable.selectDate(initialDate); 520 var initialSelection = parseDateString(this._config.currentValue); 521 if (!initialSelection) 522 initialSelection = Day.createFromToday(); 523 if (initialSelection.valueOf() < this._minimumValue) 524 initialSelection = new Day(this._minimumValue); 525 else if (initialSelection.valueOf() > this._maximumValue) 526 initialSelection = new Day(this._maximumValue); 527 this.showMonth(Month.createFromDate(initialSelection.startDate()), false); 528 this._daysTable.selectRange(initialSelection); 436 529 this.fixWindowSize(); 437 530 this._handleBodyKeyDownBound = this._handleBodyKeyDown.bind(this); … … 440 533 CalendarPicker.prototype = Object.create(Picker.prototype); 441 534 442 // Hard limits of type=date. See WebCore/platform/DateComponents.h.443 CalendarPicker.MinimumPossibleDate = new Date(-62135596800000.0);444 CalendarPicker.MaximumPossibleDate = new Date(8640000000000000.0);445 535 // See WebCore/html/DateInputType.cpp. 446 536 CalendarPicker.DefaultStepScaleFactor = 86400000; … … 458 548 if (this._config.isCalendarRTL) 459 549 this._element.classList.add("rtl"); 460 this. yearMonthController.attachTo(this._element);461 this. daysTable.attachTo(this._element);550 this._yearMonthController.attachTo(this._element); 551 this._daysTable.attachTo(this._element); 462 552 this._layoutButtons(); 463 553 // DaysTable will have focus but we don't want to show its focus ring until the first key event. … … 466 556 467 557 CalendarPicker.prototype.handleToday = function() { 468 var date = new Date();469 this. daysTable.selectDate(date);470 this.submitValue( serializeDate(date.getFullYear(), date.getMonth(), date.getDate()));558 var today = Day.createFromToday(); 559 this._daysTable.selectRange(today); 560 this.submitValue(today.toString()); 471 561 }; 472 562 … … 529 619 }; 530 620 621 /** 622 * @param {!Month} month 623 * @return {!bool} 624 */ 625 CalendarPicker.prototype.shouldShowMonth = function(month) { 626 return this._minimumMonth.valueOf() <= month.valueOf() && this.maximumMonth.valueOf() >= month.valueOf(); 627 }; 628 629 /** 630 * @param {!Month} month 631 * @param {!bool=} animate 632 * @param {!bool=} keepSelectionPosition 633 */ 634 CalendarPicker.prototype.showMonth = function(month, animate, keepSelectionPosition) { 635 if (this._currentMonth.equals(month)) 636 return; 637 else if (month.valueOf() < this._minimumMonth.valueOf()) 638 month = this._minimumMonth; 639 else if (month.valueOf() > this.maximumMonth.valueOf()) 640 month = this.maximumMonth; 641 this._yearMonthController.setMonth(month); 642 this._daysTable.navigateToMonth(month, animate, keepSelectionPosition); 643 this._currentMonth = month; 644 }; 645 646 /** 647 * @return {!Month} 648 */ 649 CalendarPicker.prototype.currentMonth = function() { 650 return this._currentMonth; 651 }; 652 531 653 // ---------------------------------------------------------------- 532 654 … … 537 659 function YearMonthController(picker) { 538 660 this.picker = picker; 539 /**540 * @type {?Month}541 */542 this._currentMonth = null;543 661 } 544 662 … … 577 695 element.appendChild(this._wall); 578 696 579 var maximumYear = this.picker.maximumDate.getUTCFullYear(); 580 // Because the maximum possible year is September we should use the year before it. 581 if (maximumYear === Month.Maximum.year) 582 maximumYear--; 697 var month = this.picker.maximumMonth; 583 698 var maxWidth = 0; 584 699 for (var m = 0; m < 12; ++m) { 585 this._month.textContent = new Month(maximumYear, m).toLocaleString();700 this._month.textContent = month.toLocaleString(); 586 701 maxWidth = Math.max(maxWidth, this._month.offsetWidth); 702 month = month.previous(); 587 703 } 588 704 if (getLanguage() == "ja" && ImperialEraLimit < maximumYear) { … … 655 771 656 772 /** 657 * @return {?Month}658 */659 YearMonthController.prototype.month = function() {660 return this._currentMonth;661 };662 663 /**664 773 * @param {!Month} month 665 774 */ 666 775 YearMonthController.prototype.setMonth = function(month) { 667 this._currentMonth = new Month(month); 668 this._redraw(); 669 }; 670 671 YearMonthController.prototype._redraw = function() { 672 var min = Month.createFromDate(this.picker.minimumDate).valueOf(); 673 var max = Month.createFromDate(this.picker.maximumDate).valueOf(); 674 var current = this._currentMonth.valueOf(); 776 var monthValue = month.valueOf(); 675 777 if (this._left3) 676 this._left3.disabled = current - 13 < min;677 this._left2.disabled = current - 2 < min;678 this._left1.disabled = current - 1 < min;679 this._right1.disabled = current + 1 > max;680 this._right2.disabled = current + 2 > max;778 this._left3.disabled = !this.picker.shouldShowMonth(new Month(monthValue - 13)); 779 this._left2.disabled = !this.picker.shouldShowMonth(new Month(monthValue - 2)); 780 this._left1.disabled = !this.picker.shouldShowMonth(new Month(monthValue - 1)); 781 this._right1.disabled = !this.picker.shouldShowMonth(new Month(monthValue + 1)); 782 this._right2.disabled = !this.picker.shouldShowMonth(new Month(monthValue + 2)); 681 783 if (this._right3) 682 this._ right3.disabled = current + 13 > max;683 this._month.innerText = this._currentMonth.toLocaleString();784 this._left3.disabled = !this.picker.shouldShowMonth(new Month(monthValue + 13)); 785 this._month.innerText = month.toLocaleString(); 684 786 while (this._monthPopupContents.hasChildNodes()) 685 787 this._monthPopupContents.removeChild(this._monthPopupContents.firstChild); 686 788 687 for (var m = current - 6; m <= current + 6; m++) { 688 if (m < min || m > max) 789 for (var m = monthValue - 6; m <= monthValue + 6; m++) { 790 var month = new Month(m); 791 if (!this.picker.shouldShowMonth(month)) 689 792 continue; 690 var month = new Month(m);691 793 var option = createElement("div", ClassNames.MonthSelectorPopupEntry, month.toLocaleString()); 692 794 option.dataset.value = month.toString(); 693 795 this._monthPopupContents.appendChild(option); 694 if (m == current)796 if (m == monthValue) 695 797 option.classList.add(ClassNames.SelectedMonthYear); 696 798 } … … 811 913 if (!selection) 812 914 return; 813 this.picker. daysTable.navigateToMonthAndKeepSelectionPosition(Month.parse(selection.dataset.value));915 this.picker.showMonth(Month.parse(selection.dataset.value)); 814 916 }; 815 917 … … 869 971 */ 870 972 YearMonthController.prototype.moveRelatively = function(amount) { 871 var min = Month.createFromDate(this.picker.minimumDate).valueOf(); 872 var max = Month.createFromDate(this.picker.maximumDate).valueOf(); 873 var current = this._currentMonth.valueOf(); 874 var updated = current; 875 if (amount < 0) 876 updated = current + amount >= min ? current + amount : min; 877 else 878 updated = current + amount <= max ? current + amount : max; 879 if (updated == current) 880 return; 881 this.picker.daysTable.navigateToMonthAndKeepSelectionPosition(new Month(updated)); 973 var current = this.picker.currentMonth().valueOf(); 974 var updated = new Month(current + amount); 975 this.picker.showMonth(updated, true, true); 882 976 }; 883 977 … … 890 984 function DaysTable(picker) { 891 985 this.picker = picker; 892 /**893 * @type {?Month}894 */895 this._currentMonth = null;896 986 } 897 987 … … 948 1038 949 1039 /** 950 * @param {!number} time date in millisecond.1040 * @param {!number} value 951 1041 * @return {!boolean} 952 1042 */ 953 CalendarPicker.prototype. stepMismatch = function(time) {954 return ( time - this.stepBase) % this.step != 0;955 } 956 957 /** 958 * @param {!number} time date in millisecond.1043 CalendarPicker.prototype._stepMismatch = function(value) { 1044 return (value - this.stepBase) % this.step != 0; 1045 } 1046 1047 /** 1048 * @param {!number} value 959 1049 * @return {!boolean} 960 1050 */ 961 CalendarPicker.prototype. outOfRange = function(time) {962 return time < this.minimumDate.getTime() || time > this.maximumDate.getTime();963 } 964 965 /** 966 * @param {! number} time date in millisecond.1051 CalendarPicker.prototype._outOfRange = function(value) { 1052 return value < this._minimumValue || value > this._maximumValue; 1053 } 1054 1055 /** 1056 * @param {!Month|Day} range 967 1057 * @return {!boolean} 968 1058 */ 969 CalendarPicker.prototype.isValidDate = function( time) {970 return !this.outOfRange(time) && !this.stepMismatch(time);971 } 972 973 /** 974 * @param {!number} year 975 * @param {! number} month1059 CalendarPicker.prototype.isValidDate = function(range) { 1060 var value = range.valueOf(); 1061 return !this._outOfRange(value) && !this._stepMismatch(value); 1062 } 1063 1064 /** 1065 * @param {!Month} month 976 1066 */ 977 1067 DaysTable.prototype._renderMonth = function(month) { 978 this._currentMonth = new Month(month); 979 var dayIterator = this._currentMonth.startDate(); 1068 var dayIterator = month.startDate(); 980 1069 var monthStartDay = dayIterator.getUTCDay(); 981 1070 var weekStartDay = global.params.weekStartDay || 0; … … 991 1080 element.innerText = localizeNumber(dayIterator.getUTCDate()); 992 1081 element.className = ClassNames.Day; 993 element.dataset.submitValue = serializeDate(iterMonth.year, iterMonth.month, dayIterator.getUTCDate());1082 element.dataset.submitValue = Day.createFromDate(dayIterator).toString(); 994 1083 if (isNaN(time)) { 995 1084 element.innerText = "-"; 996 1085 element.classList.add(ClassNames.Unavailable); 997 } else if ( this.picker.outOfRange(time))1086 } else if (!this.picker.isValidDate(Day.createFromDate(dayIterator))) 998 1087 element.classList.add(ClassNames.Unavailable); 999 else if (this.picker.stepMismatch(time)) 1000 element.classList.add(ClassNames.Unavailable); 1001 else if (!iterMonth.equals(this._currentMonth)) { 1088 else if (!iterMonth.equals(month)) { 1002 1089 element.classList.add(ClassNames.Available); 1003 1090 element.classList.add(ClassNames.NotThisMonth); … … 1008 1095 } 1009 1096 1010 this.picker.today.disabled = !this.picker.isValidDate( parseDateString().getTime());1097 this.picker.today.disabled = !this.picker.isValidDate(Day.createFromToday().valueOf()); 1011 1098 }; 1012 1099 1013 1100 /** 1014 1101 * @param {!Month} month 1015 */ 1016 DaysTable.prototype._navigateToMonth = function(month) { 1017 this.picker.yearMonthController.setMonth(month); 1018 this._renderMonth(month); 1019 }; 1020 1021 /** 1022 * @param {!Month} month 1023 */ 1024 DaysTable.prototype._navigateToMonthWithAnimation = function(month) { 1025 if (this._currentMonth) { 1026 var delta = this._currentMonth.valueOf() - month.valueOf(); 1027 if (delta === 0) 1028 return; 1102 * @param {!bool} animate 1103 * @param {!bool} keepSelectionPosition 1104 */ 1105 DaysTable.prototype.navigateToMonth = function(month, animate, keepSelectionPosition) { 1106 var firstNodeInSelectedRange = this._firstNodeInSelectedRange(); 1107 if (animate) { 1029 1108 var daysStyle = this._daysContainer.style; 1030 1109 daysStyle.position = "relative"; 1031 1110 daysStyle.webkitTransition = "left 0.1s ease"; 1032 daysStyle.left = (delta > 0 ? "" : "-") + this._daysContainer.offsetWidth + "px"; 1033 } 1034 this._navigateToMonth(month); 1111 daysStyle.left = (this.picker.currentMonth().valueOf() > month.valueOf() ? "" : "-") + this._daysContainer.offsetWidth + "px"; 1112 } 1113 this._renderMonth(month); 1114 if (keepSelectionPosition && firstNodeInSelectedRange) { 1115 var x = parseInt(firstNodeInSelectedRange.dataset.positionX, 10); 1116 var y = parseInt(firstNodeInSelectedRange.dataset.positionY, 10); 1117 this._selectRangeAtPosition(x, y); 1118 } 1035 1119 }; 1036 1120 … … 1047 1131 1048 1132 /** 1049 * @param {!Month} month1050 */1051 DaysTable.prototype.navigateToMonthAndKeepSelectionPosition = function(month) {1052 if (this._currentMonth.equals(month))1053 return;1054 var firstNodeInSelectedRange = this._firstNodeInSelectedRange();1055 this._navigateToMonthWithAnimation(month);1056 if (firstNodeInSelectedRange) {1057 var x = parseInt(firstNodeInSelectedRange.dataset.positionX, 10);1058 var y = parseInt(firstNodeInSelectedRange.dataset.positionY, 10);1059 this._selectRangeAtPosition(x, y);1060 }1061 };1062 1063 /**1064 1133 * @param {!Date} date 1065 1134 */ 1066 DaysTable.prototype.select Date = function(date) {1135 DaysTable.prototype.selectRange = function(day) { 1067 1136 this._deselect(); 1068 this. _navigateToMonthWithAnimation(Month.createFromDate(date));1069 var dateString = serializeDate(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate());1137 this.picker.showMonth(Month.createFromDate(day.startDate()), true); 1138 var dateString = day.toString(); 1070 1139 for (var w = 0; w < DaysTable._Weeks; w++) { 1071 1140 for (var d = 0; d < 7; d++) { … … 1114 1183 */ 1115 1184 DaysTable.prototype._maybeSetPreviousMonth = function() { 1116 var currentMonth = this.picker.yearMonthController.month();1117 if ( this.picker.minimumDate >= currentMonth.startDate())1185 var previousMonth = this.picker.currentMonth().previous(); 1186 if (!this.picker.shouldShowMonth(previousMonth)) 1118 1187 return false; 1119 this. _navigateToMonthWithAnimation(currentMonth.previous());1188 this.picker.showMonth(previousMonth, true); 1120 1189 return true; 1121 1190 }; … … 1125 1194 */ 1126 1195 DaysTable.prototype._maybeSetNextMonth = function() { 1127 var currentMonth = this.picker.yearMonthController.month();1128 if ( this.picker.maximumDate < currentMonth.endDate())1196 var nextMonth = this.picker.currentMonth().next(); 1197 if (!this.picker.shouldShowMonth(nextMonth)) 1129 1198 return false; 1130 this. _navigateToMonthWithAnimation(currentMonth.next());1199 this.picker.showMonth(nextMonth, true); 1131 1200 return true; 1132 1201 }; … … 1238 1307 1239 1308 } else if (key == "U+0054") { // 't' 1240 this.select Date(new Date());1309 this.selectRange(Day.createFromToday()); 1241 1310 event.stopPropagation(); 1242 1311 event.preventDefault(); … … 1272 1341 } 1273 1342 } else if (key == "U+004D") { // 'm' 1274 this. yearMonthController.moveRelatively(event.shiftKey ? YearMonthController.PreviousMonth : YearMonthController.NextMonth);1343 this._yearMonthController.moveRelatively(event.shiftKey ? YearMonthController.PreviousMonth : YearMonthController.NextMonth); 1275 1344 } else if (key == "U+0059") { // 'y' 1276 this. yearMonthController.moveRelatively(event.shiftKey ? YearMonthController.PreviousYear : YearMonthController.NextYear);1345 this._yearMonthController.moveRelatively(event.shiftKey ? YearMonthController.PreviousYear : YearMonthController.NextYear); 1277 1346 } else if (key == "U+0044") { // 'd' 1278 this. yearMonthController.moveRelatively(event.shiftKey ? YearMonthController.PreviousTenYears : YearMonthController.NextTenYears);1347 this._yearMonthController.moveRelatively(event.shiftKey ? YearMonthController.PreviousTenYears : YearMonthController.NextTenYears); 1279 1348 } else if (key == "U+001B") // ESC 1280 1349 this.handleCancel();
Note: See TracChangeset
for help on using the changeset viewer.