Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(97)

Side by Side Diff: LayoutTests/platform/chromium/fast/forms/calendar-picker/resources/calendar-picker-common.js

Issue 14120003: Move LayoutTests from platform/chromium/... to generic location (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 function currentMonth() {
2 return popupWindow.global.picker.currentMonth().toString();
3 }
4
5 function availableDayCells() {
6 skipAnimation();
7 return Array.prototype.map.call(popupWindow.document.querySelectorAll(".day- cell:not(.disabled):not(.hidden)"), function(element) {
8 return element.$view.day.toString();
9 }).sort().join();
10 }
11
12 function highlightedDayCells() {
13 skipAnimation();
14 return Array.prototype.map.call(popupWindow.document.querySelectorAll(".day- cell.highlighted:not(.hidden)"), function(element) {
15 return element.$view.day.toString();
16 }).sort().join();
17 }
18
19 function selectedDayCells() {
20 skipAnimation();
21 return Array.prototype.map.call(popupWindow.document.querySelectorAll(".day- cell.selected:not(.hidden)"), function(element) {
22 return element.$view.day.toString();
23 }).sort().join();
24 }
25
26 function availableWeekNumberCells() {
27 skipAnimation();
28 return Array.prototype.map.call(popupWindow.document.querySelectorAll(".week -number-cell.highlighted:not(.hidden)"), function(element) {
29 return element.$view.day.toString();
30 }).sort().join();
31 }
32
33 function highlightedWeekNumberCells() {
34 skipAnimation();
35 return Array.prototype.map.call(popupWindow.document.querySelectorAll(".week -number-cell.highlighted:not(.hidden)"), function(element) {
36 return element.$view.day.toString();
37 }).sort().join();
38 }
39
40 function selectedWeekNumberCells() {
41 skipAnimation();
42 return Array.prototype.map.call(popupWindow.document.querySelectorAll(".week -number-cell.selected:not(.hidden)"), function(element) {
43 return element.$view.day.toString();
44 }).sort().join();
45 }
46
47 function highlightedValue() {
48 var highlight = popupWindow.global.picker.highlight();
49 if (highlight)
50 return highlight.toString();
51 return null;
52 }
53
54 function selectedValue() {
55 var selection = popupWindow.global.picker.selection();
56 if (selection)
57 return selection.toString();
58 return null;
59 }
60
61 function skipAnimation() {
62 popupWindow.AnimationManager.shared._animationFrameCallback(Infinity);
63 }
64
65 function hoverOverDayCellAt(column, row) {
66 skipAnimation();
67 var offset = cumulativeOffset(popupWindow.global.picker.calendarTableView.el ement);
68 var x = offset[0];
69 var y = offset[1];
70 if (popupWindow.global.picker.calendarTableView.hasWeekNumberColumn)
71 x += popupWindow.WeekNumberCell.Width;
72 x += (column + 0.5) * popupWindow.DayCell.Width;
73 y += (row + 0.5) * popupWindow.DayCell.Height + popupWindow.CalendarTableHea derView.Height;
74 eventSender.mouseMoveTo(x, y);
75 };
76
77 function clickDayCellAt(column, row) {
78 hoverOverDayCellAt(column, row);
79 eventSender.mouseDown();
80 eventSender.mouseUp();
81 }
82
83 function highlightedMonthButton() {
84 skipAnimation();
85 var year = popupWindow.global.picker.monthPopupView.yearListView.selectedRow + 1;
86 return Array.prototype.map.call(popupWindow.document.querySelectorAll(".mont h-button.highlighted"), function(element) {
87 return new popupWindow.Month(year, Number(element.dataset.month)).toStri ng();
88 }).sort().join();
89 }
90
91 function hoverOverMonthPopupButton() {
92 skipAnimation();
93 var buttonElement = popupWindow.global.picker.calendarHeaderView.monthPopupB utton.element;
94 var offset = cumulativeOffset(buttonElement);
95 eventSender.mouseMoveTo(offset[0] + buttonElement.offsetWidth / 2, offset[1] + buttonElement.offsetHeight / 2);
96 }
97
98 function clickMonthPopupButton() {
99 hoverOverMonthPopupButton();
100 eventSender.mouseDown();
101 eventSender.mouseUp();
102 }
103
104 function clickYearListCell(year) {
105 skipAnimation();
106 var row = year - 1;
107 var rowCell = popupWindow.global.picker.monthPopupView.yearListView.cellAtRo w(row);
108
109 var rowScrollOffset = popupWindow.global.picker.monthPopupView.yearListView. scrollOffsetForRow(row);
110 var scrollOffset = popupWindow.global.picker.monthPopupView.yearListView.scr ollView.contentOffset();
111 var rowOffsetFromViewportTop = rowScrollOffset - scrollOffset;
112
113 var scrollViewOffset = cumulativeOffset(popupWindow.global.picker.monthPopup View.yearListView.scrollView.element);
114 var rowCellCenterX = scrollViewOffset[0] + rowCell.element.offsetWidth / 2;
115 var rowCellCenterY = scrollViewOffset[1] + rowOffsetFromViewportTop + rowCel l.element.offsetHeight / 2;
116 eventSender.mouseMoveTo(rowCellCenterX, rowCellCenterY);
117 eventSender.mouseDown();
118 eventSender.mouseUp();
119 }
120
121 function hoverOverMonthButton(year, month) {
122 skipAnimation();
123 var row = year - 1;
124 var rowCell = popupWindow.global.picker.monthPopupView.yearListView.cellAtRo w(row);
125
126 var rowScrollOffset = popupWindow.global.picker.monthPopupView.yearListView. scrollOffsetForRow(row);
127 var scrollOffset = popupWindow.global.picker.monthPopupView.yearListView.scr ollView.contentOffset();
128 var rowOffsetFromViewportTop = rowScrollOffset - scrollOffset;
129
130 var button = popupWindow.global.picker.monthPopupView.yearListView.buttonFor Month(new popupWindow.Month(year, month));
131 var buttonOffset = cumulativeOffset(button);
132 var rowCellOffset = cumulativeOffset(rowCell.element);
133 var buttonOffsetRelativeToRowCell = [buttonOffset[0] - rowCellOffset[0], but tonOffset[1] - rowCellOffset[1]];
134
135 var scrollViewOffset = cumulativeOffset(popupWindow.global.picker.monthPopup View.yearListView.scrollView.element);
136 var buttonCenterX = scrollViewOffset[0] + buttonOffsetRelativeToRowCell[0] + button.offsetWidth / 2;
137 var buttonCenterY = scrollViewOffset[1] + buttonOffsetRelativeToRowCell[1] + rowOffsetFromViewportTop + button.offsetHeight / 2;
138 eventSender.mouseMoveTo(buttonCenterX, buttonCenterY);
139 }
140
141 function clickMonthButton(year, month) {
142 hoverOverMonthButton(year, month);
143 eventSender.mouseDown();
144 eventSender.mouseUp();
145 }
146
147 var lastYearListViewScrollOffset = NaN;
148 function checkYearListViewScrollOffset() {
149 skipAnimation();
150 var scrollOffset = popupWindow.global.picker.monthPopupView.yearListView.scr ollView.contentOffset();
151 var change = lastYearListViewScrollOffset - scrollOffset;
152 lastYearListViewScrollOffset = scrollOffset;
153 return change;
154 }
155
156 function isCalendarTableScrollingWithAnimation() {
157 var animator = popupWindow.global.picker.calendarTableView.scrollView.scroll Animator();
158 if (!animator)
159 return false;
160 return animator.isRunning();
161 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698