| OLD | NEW |
| 1 "use strict"; | 1 "use strict"; |
| 2 /* | 2 /* |
| 3 * Copyright (C) 2012 Google Inc. All rights reserved. | 3 * Copyright (C) 2012 Google Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
| 7 * met: | 7 * met: |
| 8 * | 8 * |
| 9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 2128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2139 /** | 2139 /** |
| 2140 * @type {!Array} Array of the 12 month button elements. | 2140 * @type {!Array} Array of the 12 month button elements. |
| 2141 * @const | 2141 * @const |
| 2142 */ | 2142 */ |
| 2143 this.monthButtons = []; | 2143 this.monthButtons = []; |
| 2144 var monthChooserElement = createElement("div", YearListCell.ClassNameMonthCh
ooser); | 2144 var monthChooserElement = createElement("div", YearListCell.ClassNameMonthCh
ooser); |
| 2145 for (var r = 0; r < YearListCell.ButtonRows; ++r) { | 2145 for (var r = 0; r < YearListCell.ButtonRows; ++r) { |
| 2146 var buttonsRow = createElement("div", YearListCell.ClassNameMonthButtons
Row); | 2146 var buttonsRow = createElement("div", YearListCell.ClassNameMonthButtons
Row); |
| 2147 for (var c = 0; c < YearListCell.ButtonColumns; ++c) { | 2147 for (var c = 0; c < YearListCell.ButtonColumns; ++c) { |
| 2148 var month = c + r * YearListCell.ButtonColumns; | 2148 var month = c + r * YearListCell.ButtonColumns; |
| 2149 var button = createElement("button", YearListCell.ClassNameMonthButt
on, shortMonthLabels[month]); | 2149 var button = createElement("div", YearListCell.ClassNameMonthButton,
shortMonthLabels[month]); |
| 2150 button.dataset.month = month; | 2150 button.dataset.month = month; |
| 2151 buttonsRow.appendChild(button); | 2151 buttonsRow.appendChild(button); |
| 2152 this.monthButtons.push(button); | 2152 this.monthButtons.push(button); |
| 2153 } | 2153 } |
| 2154 monthChooserElement.appendChild(buttonsRow); | 2154 monthChooserElement.appendChild(buttonsRow); |
| 2155 } | 2155 } |
| 2156 this.element.appendChild(monthChooserElement); | 2156 this.element.appendChild(monthChooserElement); |
| 2157 | 2157 |
| 2158 /** | 2158 /** |
| 2159 * @type {!boolean} | 2159 * @type {!boolean} |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2402 YearListView.prototype.onClick = function(event) { | 2402 YearListView.prototype.onClick = function(event) { |
| 2403 var oldSelectedRow = this.selectedRow; | 2403 var oldSelectedRow = this.selectedRow; |
| 2404 ListView.prototype.onClick.call(this, event); | 2404 ListView.prototype.onClick.call(this, event); |
| 2405 var year = this.selectedRow + 1; | 2405 var year = this.selectedRow + 1; |
| 2406 if (this.selectedRow !== oldSelectedRow) { | 2406 if (this.selectedRow !== oldSelectedRow) { |
| 2407 var month = this.highlightedMonth ? this.highlightedMonth.month : 0; | 2407 var month = this.highlightedMonth ? this.highlightedMonth.month : 0; |
| 2408 this.dispatchEvent(YearListView.EventTypeYearListViewDidSelectMonth, thi
s, new Month(year, month)); | 2408 this.dispatchEvent(YearListView.EventTypeYearListViewDidSelectMonth, thi
s, new Month(year, month)); |
| 2409 this.scrollView.scrollTo(this.selectedRow * YearListCell.Height, true); | 2409 this.scrollView.scrollTo(this.selectedRow * YearListCell.Height, true); |
| 2410 } else { | 2410 } else { |
| 2411 var monthButton = enclosingNodeOrSelfWithClass(event.target, YearListCel
l.ClassNameMonthButton); | 2411 var monthButton = enclosingNodeOrSelfWithClass(event.target, YearListCel
l.ClassNameMonthButton); |
| 2412 if (!monthButton) | 2412 if (!monthButton || monthButton.getAttribute("aria-disabled") == "true") |
| 2413 return; | 2413 return; |
| 2414 var month = parseInt(monthButton.dataset.month, 10); | 2414 var month = parseInt(monthButton.dataset.month, 10); |
| 2415 this.dispatchEvent(YearListView.EventTypeYearListViewDidSelectMonth, thi
s, new Month(year, month)); | 2415 this.dispatchEvent(YearListView.EventTypeYearListViewDidSelectMonth, thi
s, new Month(year, month)); |
| 2416 this.hide(); | 2416 this.hide(); |
| 2417 } | 2417 } |
| 2418 }; | 2418 }; |
| 2419 | 2419 |
| 2420 /** | 2420 /** |
| 2421 * @param {!number} scrollOffset | 2421 * @param {!number} scrollOffset |
| 2422 * @return {!number} | 2422 * @return {!number} |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2473 */ | 2473 */ |
| 2474 YearListView.prototype.prepareNewCell = function(row) { | 2474 YearListView.prototype.prepareNewCell = function(row) { |
| 2475 var cell = YearListCell._recycleBin.pop() || new YearListCell(global.params.
shortMonthLabels); | 2475 var cell = YearListCell._recycleBin.pop() || new YearListCell(global.params.
shortMonthLabels); |
| 2476 cell.reset(row); | 2476 cell.reset(row); |
| 2477 cell.setSelected(this.selectedRow === row); | 2477 cell.setSelected(this.selectedRow === row); |
| 2478 if (this.highlightedMonth && row === this.highlightedMonth.year - 1) { | 2478 if (this.highlightedMonth && row === this.highlightedMonth.year - 1) { |
| 2479 cell.monthButtons[this.highlightedMonth.month].classList.add(YearListCel
l.ClassNameHighlighted); | 2479 cell.monthButtons[this.highlightedMonth.month].classList.add(YearListCel
l.ClassNameHighlighted); |
| 2480 } | 2480 } |
| 2481 for (var i = 0; i < cell.monthButtons.length; ++i) { | 2481 for (var i = 0; i < cell.monthButtons.length; ++i) { |
| 2482 var month = new Month(row + 1, i); | 2482 var month = new Month(row + 1, i); |
| 2483 cell.monthButtons[i].disabled = this._minimumMonth > month || this._maxi
mumMonth < month; | 2483 cell.monthButtons[i].setAttribute("aria-disabled", this._minimumMonth >
month || this._maximumMonth < month ? "true" : "false"); |
| 2484 } | 2484 } |
| 2485 var animator = this._runningAnimators[row]; | 2485 var animator = this._runningAnimators[row]; |
| 2486 if (animator) | 2486 if (animator) |
| 2487 cell.setHeight(animator.currentValue); | 2487 cell.setHeight(animator.currentValue); |
| 2488 else if (row === this.selectedRow) | 2488 else if (row === this.selectedRow) |
| 2489 cell.setHeight(YearListCell.SelectedHeight); | 2489 cell.setHeight(YearListCell.SelectedHeight); |
| 2490 else | 2490 else |
| 2491 cell.setHeight(YearListCell.Height); | 2491 cell.setHeight(YearListCell.Height); |
| 2492 return cell; | 2492 return cell; |
| 2493 }; | 2493 }; |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2579 selectedCell.setHeight(YearListCell.SelectedHeight); | 2579 selectedCell.setHeight(YearListCell.SelectedHeight); |
| 2580 } | 2580 } |
| 2581 var month = this.highlightedMonth ? this.highlightedMonth.month : 0; | 2581 var month = this.highlightedMonth ? this.highlightedMonth.month : 0; |
| 2582 this.highlightMonth(new Month(this.selectedRow + 1, month)); | 2582 this.highlightMonth(new Month(this.selectedRow + 1, month)); |
| 2583 } | 2583 } |
| 2584 this.setNeedsUpdateCells(true); | 2584 this.setNeedsUpdateCells(true); |
| 2585 }; | 2585 }; |
| 2586 | 2586 |
| 2587 /** | 2587 /** |
| 2588 * @param {!Month} month | 2588 * @param {!Month} month |
| 2589 * @return {?HTMLButtonElement} | 2589 * @return {?HTMLDivElement} |
| 2590 */ | 2590 */ |
| 2591 YearListView.prototype.buttonForMonth = function(month) { | 2591 YearListView.prototype.buttonForMonth = function(month) { |
| 2592 if (!month) | 2592 if (!month) |
| 2593 return null; | 2593 return null; |
| 2594 var row = month.year - 1; | 2594 var row = month.year - 1; |
| 2595 var cell = this.cellAtRow(row); | 2595 var cell = this.cellAtRow(row); |
| 2596 if (!cell) | 2596 if (!cell) |
| 2597 return null; | 2597 return null; |
| 2598 return cell.monthButtons[month.month]; | 2598 return cell.monthButtons[month.month]; |
| 2599 }; | 2599 }; |
| (...skipping 1466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4066 event.stopPropagation(); | 4066 event.stopPropagation(); |
| 4067 event.preventDefault(); | 4067 event.preventDefault(); |
| 4068 } | 4068 } |
| 4069 }; | 4069 }; |
| 4070 | 4070 |
| 4071 if (window.dialogArguments) { | 4071 if (window.dialogArguments) { |
| 4072 initialize(dialogArguments); | 4072 initialize(dialogArguments); |
| 4073 } else { | 4073 } else { |
| 4074 window.addEventListener("message", handleMessage, false); | 4074 window.addEventListener("message", handleMessage, false); |
| 4075 } | 4075 } |
| OLD | NEW |