wai-website-theme 1.3.1 → 1.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/_includes/different.html +2 -1
  3. data/_includes/external.html +2 -1
  4. data/_includes/header.html +2 -1
  5. data/_includes/menuitem.html +6 -2
  6. data/_includes/peoplelist.html +21 -0
  7. data/_includes/prevnext-navigation.html +56 -0
  8. data/_includes/{prevnext.html → prevnext-order.html} +9 -0
  9. data/_includes/translation-note-msg.html +5 -3
  10. data/_includes/video-player.html +2 -2
  11. data/_layouts/default.html +8 -1
  12. data/_layouts/news.html +7 -1
  13. data/_layouts/policy.html +7 -1
  14. data/_layouts/sidenav.html +8 -1
  15. data/_layouts/sidenavsidebar.html +8 -1
  16. data/assets/ableplayer/Gruntfile.js +2 -1
  17. data/assets/ableplayer/README.md +158 -85
  18. data/assets/ableplayer/build/ableplayer.dist.js +15445 -13823
  19. data/assets/ableplayer/build/ableplayer.js +15445 -13823
  20. data/assets/ableplayer/build/ableplayer.min.css +1 -2
  21. data/assets/ableplayer/build/ableplayer.min.js +3 -10
  22. data/assets/ableplayer/package-lock.json +944 -346
  23. data/assets/ableplayer/package.json +8 -8
  24. data/assets/ableplayer/scripts/ableplayer-base.js +515 -524
  25. data/assets/ableplayer/scripts/browser.js +158 -158
  26. data/assets/ableplayer/scripts/buildplayer.js +1750 -1682
  27. data/assets/ableplayer/scripts/caption.js +424 -401
  28. data/assets/ableplayer/scripts/chapters.js +259 -259
  29. data/assets/ableplayer/scripts/control.js +1831 -1594
  30. data/assets/ableplayer/scripts/description.js +333 -256
  31. data/assets/ableplayer/scripts/dialog.js +145 -145
  32. data/assets/ableplayer/scripts/dragdrop.js +746 -749
  33. data/assets/ableplayer/scripts/event.js +875 -696
  34. data/assets/ableplayer/scripts/initialize.js +819 -912
  35. data/assets/ableplayer/scripts/langs.js +979 -743
  36. data/assets/ableplayer/scripts/metadata.js +124 -124
  37. data/assets/ableplayer/scripts/misc.js +170 -137
  38. data/assets/ableplayer/scripts/preference.js +904 -904
  39. data/assets/ableplayer/scripts/search.js +172 -172
  40. data/assets/ableplayer/scripts/sign.js +82 -78
  41. data/assets/ableplayer/scripts/slider.js +449 -448
  42. data/assets/ableplayer/scripts/track.js +409 -309
  43. data/assets/ableplayer/scripts/transcript.js +684 -595
  44. data/assets/ableplayer/scripts/translation.js +63 -67
  45. data/assets/ableplayer/scripts/ttml2webvtt.js +85 -85
  46. data/assets/ableplayer/scripts/vimeo.js +448 -0
  47. data/assets/ableplayer/scripts/volume.js +395 -380
  48. data/assets/ableplayer/scripts/vts.js +1077 -1077
  49. data/assets/ableplayer/scripts/webvtt.js +766 -763
  50. data/assets/ableplayer/scripts/youtube.js +695 -478
  51. data/assets/ableplayer/styles/ableplayer.css +54 -46
  52. data/assets/ableplayer/translations/nl.js +54 -54
  53. data/assets/ableplayer/translations/pt-br.js +311 -0
  54. data/assets/ableplayer/translations/tr.js +311 -0
  55. data/assets/ableplayer/translations/zh-tw.js +1 -1
  56. data/assets/css/style.css +1 -1
  57. data/assets/css/style.css.map +1 -1
  58. data/assets/images/icons.svg +5 -5
  59. data/assets/scripts/main.js +7 -0
  60. data/assets/search/tipuesearch.js +3 -3
  61. metadata +8 -3
@@ -1,455 +1,456 @@
1
1
  (function ($) {
2
2
 
3
3
 
4
- // Events:
5
- // startTracking(event, position)
6
- // tracking(event, position)
7
- // stopTracking(event, position)
8
-
9
- window. AccessibleSlider = function(mediaType, div, orientation, length, min, max, bigInterval, label, className, trackingMedia, initialState) {
10
-
11
- // mediaType is either 'audio' or 'video'
12
- // div is the host element around which the slider will be built
13
- // orientation is either 'horizontal' or 'vertical'
14
- // length is the width or height of the slider, depending on orientation
15
- // min is the low end of the slider scale
16
- // max is the high end of the slider scale
17
- // bigInterval is the number of steps supported by page up/page down (set to 0 if not supported)
18
- // (smallInterval, defined as nextStep below, is always set to 1) - this is the interval supported by arrow keys
19
- // label is used within an aria-label attribute to identify the slider to screen reader users
20
- // className is used as the root within class names (e.g., 'able-' + classname + '-head')
21
- // trackingMedia is true if this is a media timeline; otherwise false
22
- // initialState is either 'visible' or 'hidden'
23
-
24
- var thisObj;
25
-
26
- thisObj = this;
27
-
28
- // Initialize some variables.
29
- this.position = 0; // Note: position does not change while tracking.
30
- this.tracking = false;
31
- this.trackDevice = null; // 'mouse' or 'keyboard'
32
- this.keyTrackPosition = 0;
33
- this.lastTrackPosition = 0;
34
- this.nextStep = 1;
35
- this.inertiaCount = 0;
36
-
37
- this.bodyDiv = $(div);
38
-
39
- // Add divs for tracking amount of media loaded and played
40
- if (trackingMedia) {
41
- this.loadedDiv = $('<div></div>');
42
- this.playedDiv = $('<div></div>');
43
- }
44
-
45
- // Add a seekhead
46
- this.seekHead = $('<div>',{
47
- 'orientation': orientation,
48
- 'class': 'able-' + className + '-head'
49
- });
50
-
51
- if (initialState === 'visible') {
52
- this.seekHead.attr('tabindex', '0');
53
- }
54
- else {
55
- this.seekHead.attr('tabindex', '-1');
56
- }
57
- // Since head is focusable, it gets the aria roles/titles.
58
- this.seekHead.attr({
59
- 'role': 'slider',
60
- 'aria-label': label,
61
- 'aria-valuemin': min,
62
- 'aria-valuemax': max
63
- });
64
-
65
- this.timeTooltip = $('<div>');
66
- this.bodyDiv.append(this.timeTooltip);
67
-
68
- this.timeTooltip.attr('role', 'tooltip');
69
- this.timeTooltip.addClass('able-tooltip');
70
- this.timeTooltip.hide();
71
-
72
- this.bodyDiv.append(this.loadedDiv);
73
- this.bodyDiv.append(this.playedDiv);
74
- this.bodyDiv.append(this.seekHead);
75
-
76
- this.bodyDiv.wrap('<div></div>');
77
- this.wrapperDiv = this.bodyDiv.parent();
78
-
79
- if (orientation === 'horizontal') {
80
- this.wrapperDiv.width(length);
81
- this.loadedDiv.width(0);
82
- }
83
- else {
84
- this.wrapperDiv.height(length);
85
- this.loadedDiv.height(0);
86
- }
87
- this.wrapperDiv.addClass('able-' + className + '-wrapper');
88
-
89
- if (trackingMedia) {
90
- this.loadedDiv.addClass('able-' + className + '-loaded');
91
-
92
- this.playedDiv.width(0);
93
- this.playedDiv.addClass('able-' + className + '-played');
94
-
95
- // Set a default duration. User can call this dynamically if duration changes.
96
- this.setDuration(max);
97
- }
98
-
99
- this.seekHead.hover(function (e) {
100
- thisObj.overHead = true;
101
- thisObj.refreshTooltip();
102
- }, function (e) {
103
- thisObj.overHead = false;
104
-
105
- if (!thisObj.overBody && thisObj.tracking && thisObj.trackDevice === 'mouse') {
106
- thisObj.stopTracking(thisObj.pageXToPosition(e.pageX));
107
- }
108
- thisObj.refreshTooltip();
109
- });
110
-
111
- this.seekHead.mousemove(function (e) {
112
- if (thisObj.tracking && thisObj.trackDevice === 'mouse') {
113
- thisObj.trackHeadAtPageX(e.pageX);
114
- }
115
- });
116
-
117
- this.seekHead.focus(function (e) {
118
- thisObj.overHead = true;
119
- thisObj.refreshTooltip();
120
- });
121
-
122
- this.seekHead.blur(function (e) {
123
- thisObj.overHead = false;
124
- thisObj.refreshTooltip();
125
- });
126
-
127
- this.bodyDiv.hover(function () {
128
- thisObj.overBody = true;
129
- thisObj.refreshTooltip();
130
- }, function (e) {
131
- thisObj.overBody = false;
132
- thisObj.overBodyMousePos = null;
133
- thisObj.refreshTooltip();
134
-
135
- if (!thisObj.overHead && thisObj.tracking && thisObj.trackDevice === 'mouse') {
136
- thisObj.stopTracking(thisObj.pageXToPosition(e.pageX));
137
- }
138
- });
139
-
140
- this.bodyDiv.mousemove(function (e) {
141
- thisObj.overBodyMousePos = {
142
- x: e.pageX,
143
- y: e.pageY
144
- };
145
- if (thisObj.tracking && thisObj.trackDevice === 'mouse') {
146
- thisObj.trackHeadAtPageX(e.pageX);
147
- }
148
- thisObj.refreshTooltip();
149
- });
150
-
151
- this.bodyDiv.mousedown(function (e) {
152
- thisObj.startTracking('mouse', thisObj.pageXToPosition(e.pageX));
153
- thisObj.trackHeadAtPageX(e.pageX);
154
- if (!thisObj.seekHead.is(':focus')) {
155
- thisObj.seekHead.focus();
156
- }
157
- e.preventDefault();
158
- });
159
-
160
- this.seekHead.mousedown(function (e) {
161
- thisObj.startTracking('mouse', thisObj.pageXToPosition(thisObj.seekHead.offset() + (thisObj.seekHead.width() / 2)));
162
- if (!thisObj.bodyDiv.is(':focus')) {
163
- thisObj.bodyDiv.focus();
164
- }
165
- e.preventDefault();
166
- });
167
-
168
- this.bodyDiv.mouseup(function (e) {
169
- if (thisObj.tracking && thisObj.trackDevice === 'mouse') {
170
- thisObj.stopTracking(thisObj.pageXToPosition(e.pageX));
171
- }
172
- })
173
-
174
- this.seekHead.mouseup(function (e) {
175
- if (thisObj.tracking && thisObj.trackDevice === 'mouse') {
176
- thisObj.stopTracking(thisObj.pageXToPosition(e.pageX));
177
- }
178
- });
179
-
180
- this.bodyDiv.keydown(function (e) {
181
- // Home
182
- if (e.which === 36) {
183
- thisObj.trackImmediatelyTo(0);
184
- }
185
- // End
186
- else if (e.which === 35) {
187
- thisObj.trackImmediatelyTo(thisObj.duration);
188
- }
189
- // Left arrow or down arrow
190
- else if (e.which === 37 || e.which === 40) {
191
- thisObj.arrowKeyDown(-1);
192
- }
193
- // Right arrow or up arrow
194
- else if (e.which === 39 || e.which === 38) {
195
- thisObj.arrowKeyDown(1);
196
- }
197
- // Page up
198
- else if (e.which === 33 && bigInterval > 0) {
199
- thisObj.arrowKeyDown(bigInterval);
200
- }
201
- // Page down
202
- else if (e.which === 34 && bigInterval > 0) {
203
- thisObj.arrowKeyDown(-bigInterval);
204
- }
205
-
206
- else {
207
- return;
208
- }
209
- e.preventDefault();
210
- });
211
-
212
- this.bodyDiv.keyup(function (e) {
213
- if (e.which >= 33 && e.which <= 40) {
214
- if (thisObj.tracking && thisObj.trackDevice === 'keyboard') {
215
- thisObj.stopTracking(thisObj.keyTrackPosition);
216
- }
217
- e.preventDefault();
218
- }
219
- });
220
- }
221
-
222
- AccessibleSlider.prototype.arrowKeyDown = function (multiplier) {
223
- if (this.tracking && this.trackDevice === 'keyboard') {
224
- this.keyTrackPosition = this.boundPos(this.keyTrackPosition + (this.nextStep * multiplier));
225
- this.inertiaCount += 1;
226
- if (this.inertiaCount === 20) {
227
- this.inertiaCount = 0;
228
- this.nextStep *= 2;
229
- }
230
- this.trackHeadAtPosition(this.keyTrackPosition);
231
- }
232
- else {
233
- this.nextStep = 1;
234
- this.inertiaCount = 0;
235
- this.keyTrackPosition = this.boundPos(this.position + (this.nextStep * multiplier));
236
- this.startTracking('keyboard', this.keyTrackPosition);
237
- this.trackHeadAtPosition(this.keyTrackPosition);
238
- }
239
- };
4
+ // Events:
5
+ // startTracking(event, position)
6
+ // tracking(event, position)
7
+ // stopTracking(event, position)
8
+
9
+ window. AccessibleSlider = function(mediaType, div, orientation, length, min, max, bigInterval, label, className, trackingMedia, initialState) {
10
+
11
+ // mediaType is either 'audio' or 'video'
12
+ // div is the host element around which the slider will be built
13
+ // orientation is either 'horizontal' or 'vertical'
14
+ // length is the width or height of the slider, depending on orientation
15
+ // min is the low end of the slider scale
16
+ // max is the high end of the slider scale
17
+ // bigInterval is the number of steps supported by page up/page down (set to 0 if not supported)
18
+ // (smallInterval, defined as nextStep below, is always set to 1) - this is the interval supported by arrow keys
19
+ // label is used within an aria-label attribute to identify the slider to screen reader users
20
+ // className is used as the root within class names (e.g., 'able-' + classname + '-head')
21
+ // trackingMedia is true if this is a media timeline; otherwise false
22
+ // initialState is either 'visible' or 'hidden'
23
+
24
+ var thisObj;
25
+
26
+ thisObj = this;
27
+
28
+ // Initialize some variables.
29
+ this.position = 0; // Note: position does not change while tracking.
30
+ this.tracking = false;
31
+ this.trackDevice = null; // 'mouse' or 'keyboard'
32
+ this.keyTrackPosition = 0;
33
+ this.lastTrackPosition = 0;
34
+ this.nextStep = 1;
35
+ this.inertiaCount = 0;
36
+
37
+ this.bodyDiv = $(div);
38
+
39
+ // Add divs for tracking amount of media loaded and played
40
+ if (trackingMedia) {
41
+ this.loadedDiv = $('<div></div>');
42
+ this.playedDiv = $('<div></div>');
43
+ }
44
+
45
+ // Add a seekhead
46
+ this.seekHead = $('<div>',{
47
+ 'orientation': orientation,
48
+ 'class': 'able-' + className + '-head'
49
+ });
50
+
51
+ if (initialState === 'visible') {
52
+ this.seekHead.attr('tabindex', '0');
53
+ }
54
+ else {
55
+ this.seekHead.attr('tabindex', '-1');
56
+ }
57
+ // Since head is focusable, it gets the aria roles/titles.
58
+ this.seekHead.attr({
59
+ 'role': 'slider',
60
+ 'aria-label': label,
61
+ 'aria-valuemin': min,
62
+ 'aria-valuemax': max
63
+ });
64
+
65
+ this.timeTooltip = $('<div>');
66
+ this.bodyDiv.append(this.timeTooltip);
67
+
68
+ this.timeTooltip.attr('role', 'tooltip');
69
+ this.timeTooltip.addClass('able-tooltip');
70
+ this.timeTooltip.hide();
71
+
72
+ this.bodyDiv.append(this.loadedDiv);
73
+ this.bodyDiv.append(this.playedDiv);
74
+ this.bodyDiv.append(this.seekHead);
75
+
76
+ this.bodyDiv.wrap('<div></div>');
77
+ this.wrapperDiv = this.bodyDiv.parent();
78
+
79
+ if (orientation === 'horizontal') {
80
+ this.wrapperDiv.width(length);
81
+ this.loadedDiv.width(0);
82
+ }
83
+ else {
84
+ this.wrapperDiv.height(length);
85
+ this.loadedDiv.height(0);
86
+ }
87
+ this.wrapperDiv.addClass('able-' + className + '-wrapper');
88
+
89
+ if (trackingMedia) {
90
+ this.loadedDiv.addClass('able-' + className + '-loaded');
91
+
92
+ this.playedDiv.width(0);
93
+ this.playedDiv.addClass('able-' + className + '-played');
94
+
95
+ // Set a default duration. User can call this dynamically if duration changes.
96
+ this.setDuration(max);
97
+ }
98
+
99
+ this.seekHead.hover(function (e) {
100
+ thisObj.overHead = true;
101
+ thisObj.refreshTooltip();
102
+ }, function (e) {
103
+ thisObj.overHead = false;
104
+
105
+ if (!thisObj.overBody && thisObj.tracking && thisObj.trackDevice === 'mouse') {
106
+ thisObj.stopTracking(thisObj.pageXToPosition(e.pageX));
107
+ }
108
+ thisObj.refreshTooltip();
109
+ });
110
+
111
+ this.seekHead.mousemove(function (e) {
112
+ if (thisObj.tracking && thisObj.trackDevice === 'mouse') {
113
+ thisObj.trackHeadAtPageX(e.pageX);
114
+ }
115
+ });
116
+
117
+ this.seekHead.focus(function (e) {
118
+ thisObj.overHead = true;
119
+ thisObj.refreshTooltip();
120
+ });
121
+
122
+ this.seekHead.blur(function (e) {
123
+ thisObj.overHead = false;
124
+ thisObj.refreshTooltip();
125
+ });
126
+
127
+ this.bodyDiv.hover(function () {
128
+ thisObj.overBody = true;
129
+ thisObj.refreshTooltip();
130
+ }, function (e) {
131
+ thisObj.overBody = false;
132
+ thisObj.overBodyMousePos = null;
133
+ thisObj.refreshTooltip();
134
+
135
+ if (!thisObj.overHead && thisObj.tracking && thisObj.trackDevice === 'mouse') {
136
+ thisObj.stopTracking(thisObj.pageXToPosition(e.pageX));
137
+ }
138
+ });
139
+
140
+ this.bodyDiv.mousemove(function (e) {
141
+ thisObj.overBodyMousePos = {
142
+ x: e.pageX,
143
+ y: e.pageY
144
+ };
145
+ if (thisObj.tracking && thisObj.trackDevice === 'mouse') {
146
+ thisObj.trackHeadAtPageX(e.pageX);
147
+ }
148
+ thisObj.refreshTooltip();
149
+ });
150
+
151
+ this.bodyDiv.mousedown(function (e) {
152
+ thisObj.startTracking('mouse', thisObj.pageXToPosition(e.pageX));
153
+ thisObj.trackHeadAtPageX(e.pageX);
154
+ if (!thisObj.seekHead.is(':focus')) {
155
+ thisObj.seekHead.focus();
156
+ }
157
+ e.preventDefault();
158
+ });
159
+
160
+ this.seekHead.mousedown(function (e) {
161
+ thisObj.startTracking('mouse', thisObj.pageXToPosition(thisObj.seekHead.offset() + (thisObj.seekHead.width() / 2)));
162
+ if (!thisObj.bodyDiv.is(':focus')) {
163
+ thisObj.bodyDiv.focus();
164
+ }
165
+ e.preventDefault();
166
+ });
167
+
168
+ this.bodyDiv.mouseup(function (e) {
169
+ if (thisObj.tracking && thisObj.trackDevice === 'mouse') {
170
+ thisObj.stopTracking(thisObj.pageXToPosition(e.pageX));
171
+ }
172
+ })
173
+
174
+ this.seekHead.mouseup(function (e) {
175
+ if (thisObj.tracking && thisObj.trackDevice === 'mouse') {
176
+ thisObj.stopTracking(thisObj.pageXToPosition(e.pageX));
177
+ }
178
+ });
179
+
180
+ this.bodyDiv.keydown(function (e) {
181
+ // Home
182
+ if (e.which === 36) {
183
+ thisObj.trackImmediatelyTo(0);
184
+ }
185
+ // End
186
+ else if (e.which === 35) {
187
+ thisObj.trackImmediatelyTo(thisObj.duration);
188
+ }
189
+ // Left arrow or down arrow
190
+ else if (e.which === 37 || e.which === 40) {
191
+ thisObj.arrowKeyDown(-1);
192
+ }
193
+ // Right arrow or up arrow
194
+ else if (e.which === 39 || e.which === 38) {
195
+ thisObj.arrowKeyDown(1);
196
+ }
197
+ // Page up
198
+ else if (e.which === 33 && bigInterval > 0) {
199
+ thisObj.arrowKeyDown(bigInterval);
200
+ }
201
+ // Page down
202
+ else if (e.which === 34 && bigInterval > 0) {
203
+ thisObj.arrowKeyDown(-bigInterval);
204
+ }
205
+
206
+ else {
207
+ return;
208
+ }
209
+ e.preventDefault();
210
+ });
211
+
212
+ this.bodyDiv.keyup(function (e) {
213
+ if (e.which >= 33 && e.which <= 40) {
214
+ if (thisObj.tracking && thisObj.trackDevice === 'keyboard') {
215
+ thisObj.stopTracking(thisObj.keyTrackPosition);
216
+ }
217
+ e.preventDefault();
218
+ }
219
+ });
220
+ }
221
+
222
+ AccessibleSlider.prototype.arrowKeyDown = function (multiplier) {
223
+ if (this.tracking && this.trackDevice === 'keyboard') {
224
+ this.keyTrackPosition = this.boundPos(this.keyTrackPosition + (this.nextStep * multiplier));
225
+ this.inertiaCount += 1;
226
+ if (this.inertiaCount === 20) {
227
+ this.inertiaCount = 0;
228
+ this.nextStep *= 2;
229
+ }
230
+ this.trackHeadAtPosition(this.keyTrackPosition);
231
+ }
232
+ else {
233
+ this.nextStep = 1;
234
+ this.inertiaCount = 0;
235
+ this.keyTrackPosition = this.boundPos(this.position + (this.nextStep * multiplier));
236
+ this.startTracking('keyboard', this.keyTrackPosition);
237
+ this.trackHeadAtPosition(this.keyTrackPosition);
238
+ }
239
+ };
240
240
  /*
241
- AccessibleSlider.prototype.pageUp = function (multiplier) {
242
- if (this.tracking && this.trackDevice === 'keyboard') {
243
- this.keyTrackPosition = this.boundPos(this.keyTrackPosition + (this.nextStep * multiplier));
244
- this.inertiaCount += 1;
245
- if (this.inertiaCount === 20) {
246
- this.inertiaCount = 0;
247
- this.nextStep *= 2;
248
- }
249
- this.trackHeadAtPosition(this.keyTrackPosition);
250
- }
251
- else {
252
- this.nextStep = 1;
253
- this.inertiaCount = 0;
254
- this.keyTrackPosition = this.boundPos(this.position + (this.nextStep * multiplier));
255
- this.startTracking('keyboard', this.keyTrackPosition);
256
- this.trackHeadAtPosition(this.keyTrackPosition);
257
- }
258
- };
241
+ AccessibleSlider.prototype.pageUp = function (multiplier) {
242
+ if (this.tracking && this.trackDevice === 'keyboard') {
243
+ this.keyTrackPosition = this.boundPos(this.keyTrackPosition + (this.nextStep * multiplier));
244
+ this.inertiaCount += 1;
245
+ if (this.inertiaCount === 20) {
246
+ this.inertiaCount = 0;
247
+ this.nextStep *= 2;
248
+ }
249
+ this.trackHeadAtPosition(this.keyTrackPosition);
250
+ }
251
+ else {
252
+ this.nextStep = 1;
253
+ this.inertiaCount = 0;
254
+ this.keyTrackPosition = this.boundPos(this.position + (this.nextStep * multiplier));
255
+ this.startTracking('keyboard', this.keyTrackPosition);
256
+ this.trackHeadAtPosition(this.keyTrackPosition);
257
+ }
258
+ };
259
259
  */
260
- AccessibleSlider.prototype.pageXToPosition = function (pageX) {
261
- var offset = pageX - this.bodyDiv.offset().left;
262
- var position = this.duration * (offset / this.bodyDiv.width());
263
- return this.boundPos(position);
264
- };
265
-
266
- AccessibleSlider.prototype.boundPos = function (position) {
267
- return Math.max(0, Math.min(position, this.duration));
268
- }
269
-
270
- AccessibleSlider.prototype.setDuration = function (duration) {
271
- if (duration !== this.duration) {
272
- this.duration = duration;
273
- this.resetHeadLocation();
274
- this.seekHead.attr('aria-valuemax', duration);
275
- }
276
- };
277
-
278
- AccessibleSlider.prototype.setWidth = function (width) {
279
- this.wrapperDiv.width(width);
280
- this.resizeDivs();
281
- this.resetHeadLocation();
282
- };
283
-
284
- AccessibleSlider.prototype.getWidth = function () {
285
- return this.wrapperDiv.width();
286
- };
287
-
288
- AccessibleSlider.prototype.resizeDivs = function () {
289
- this.playedDiv.width(this.bodyDiv.width() * (this.position / this.duration));
290
- this.loadedDiv.width(this.bodyDiv.width() * this.buffered);
291
- };
292
-
293
- // Stops tracking, sets the head location to the current position.
294
- AccessibleSlider.prototype.resetHeadLocation = function () {
295
- var ratio = this.position / this.duration;
296
- var center = this.bodyDiv.width() * ratio;
297
- this.seekHead.css('left', center - (this.seekHead.width() / 2));
298
-
299
- if (this.tracking) {
300
- this.stopTracking(this.position);
301
- }
302
- };
303
-
304
- AccessibleSlider.prototype.setPosition = function (position, updateLive) {
305
- this.position = position;
306
- this.resetHeadLocation();
307
- this.refreshTooltip();
308
- this.resizeDivs();
309
- this.updateAriaValues(position, updateLive);
310
- }
311
-
312
- // TODO: Native HTML5 can have several buffered segments, and this actually happens quite often. Change this to display them all.
313
- AccessibleSlider.prototype.setBuffered = function (ratio) {
314
- this.buffered = ratio;
315
- this.redrawDivs;
316
- }
317
-
318
- AccessibleSlider.prototype.startTracking = function (device, position) {
319
- if (!this.tracking) {
320
- this.trackDevice = device;
321
- this.tracking = true;
322
- this.bodyDiv.trigger('startTracking', [position]);
323
- }
324
- };
325
-
326
- AccessibleSlider.prototype.stopTracking = function (position) {
327
- this.trackDevice = null;
328
- this.tracking = false;
329
- this.bodyDiv.trigger('stopTracking', [position]);
330
- this.setPosition(position, true);
331
- };
332
-
333
- AccessibleSlider.prototype.trackHeadAtPageX = function (pageX) {
334
- var position = this.pageXToPosition(pageX);
335
- var newLeft = pageX - this.bodyDiv.offset().left - (this.seekHead.width() / 2);
336
- newLeft = Math.max(0, Math.min(newLeft, this.bodyDiv.width() - this.seekHead.width()));
337
- this.lastTrackPosition = position;
338
- this.seekHead.css('left', newLeft);
339
- this.reportTrackAtPosition(position);
340
- };
341
-
342
- AccessibleSlider.prototype.trackHeadAtPosition = function (position) {
343
- var ratio = position / this.duration;
344
- var center = this.bodyDiv.width() * ratio;
345
- this.lastTrackPosition = position;
346
- this.seekHead.css('left', center - (this.seekHead.width() / 2));
347
- this.reportTrackAtPosition(position);
348
- };
349
-
350
- AccessibleSlider.prototype.reportTrackAtPosition = function (position) {
351
- this.bodyDiv.trigger('tracking', [position]);
352
- this.updateAriaValues(position, true);
353
- };
354
-
355
- AccessibleSlider.prototype.updateAriaValues = function (position, updateLive) {
356
- // TODO: Localize, move to another function.
357
- var pHours = Math.floor(position / 3600);
358
- var pMinutes = Math.floor((position % 3600) / 60);
359
- var pSeconds = Math.floor(position % 60);
360
-
361
- var pHourWord = pHours === 1 ? 'hour' : 'hours';
362
- var pMinuteWord = pMinutes === 1 ? 'minute' : 'minutes';
363
- var pSecondWord = pSeconds === 1 ? 'second' : 'seconds';
364
-
365
- var descriptionText;
366
- if (pHours > 0) {
367
- descriptionText = pHours +
368
- ' ' + pHourWord +
369
- ', ' + pMinutes +
370
- ' ' + pMinuteWord +
371
- ', ' + pSeconds +
372
- ' ' + pSecondWord;
373
- }
374
- else if (pMinutes > 0) {
375
- descriptionText = pMinutes +
376
- ' ' + pMinuteWord +
377
- ', ' + pSeconds +
378
- ' ' + pSecondWord;
379
- }
380
- else {
381
- descriptionText = pSeconds + ' ' + pSecondWord;
382
- }
383
-
384
- /* Comment to stop live region from generating or being used. */
385
- if (!this.liveAriaRegion) {
386
- this.liveAriaRegion = $('<span>', {
387
- 'class': 'able-offscreen',
388
- 'aria-live': 'polite'
389
- });
390
- this.wrapperDiv.append(this.liveAriaRegion);
391
- }
392
- if (updateLive && (this.liveAriaRegion.text() !== descriptionText)) {
393
- this.liveAriaRegion.text(descriptionText);
394
- }
395
-
396
- // Uncomment the following lines to use aria values instead of separate live region.
397
- this.seekHead.attr('aria-valuetext', descriptionText);
398
- this.seekHead.attr('aria-valuenow', Math.floor(position).toString());
399
- };
400
-
401
- AccessibleSlider.prototype.trackImmediatelyTo = function (position) {
402
- this.startTracking('keyboard', position);
403
- this.trackHeadAtPosition(position);
404
- this.keyTrackPosition = position;
405
- };
406
-
407
- AccessibleSlider.prototype.refreshTooltip = function () {
408
- if (this.overHead) {
409
- this.timeTooltip.show();
410
- if (this.tracking) {
411
- this.timeTooltip.text(this.positionToStr(this.lastTrackPosition));
412
- }
413
- else {
414
- this.timeTooltip.text(this.positionToStr(this.position));
415
- }
416
- this.setTooltipPosition(this.seekHead.position().left + (this.seekHead.width() / 2));
417
- }
418
- else if (this.overBody && this.overBodyMousePos) {
419
- this.timeTooltip.show();
420
- this.timeTooltip.text(this.positionToStr(this.pageXToPosition(this.overBodyMousePos.x)));
421
- this.setTooltipPosition(this.overBodyMousePos.x - this.bodyDiv.offset().left);
422
- }
423
- else {
424
- this.timeTooltip.hide();
425
- }
426
- };
427
-
428
- AccessibleSlider.prototype.setTooltipPosition = function (x) {
429
- this.timeTooltip.css({
430
- left: x - (this.timeTooltip.width() / 2) - 10,
431
- bottom: this.seekHead.height() + 10
432
- });
433
- };
434
-
435
- AccessibleSlider.prototype.positionToStr = function (seconds) {
436
-
437
- // same logic as misc.js > formatSecondsAsColonTime()
438
- var dHours = Math.floor(seconds / 3600);
439
- var dMinutes = Math.floor(seconds / 60) % 60;
440
- var dSeconds = Math.floor(seconds % 60);
441
- if (dSeconds < 10) {
442
- dSeconds = '0' + dSeconds;
443
- }
444
- if (dHours > 0) {
445
- if (dMinutes < 10) {
446
- dMinutes = '0' + dMinutes;
447
- }
448
- return dHours + ':' + dMinutes + ':' + dSeconds;
449
- }
450
- else {
451
- return dMinutes + ':' + dSeconds;
452
- }
453
- };
260
+ AccessibleSlider.prototype.pageXToPosition = function (pageX) {
261
+ var offset = pageX - this.bodyDiv.offset().left;
262
+ var position = this.duration * (offset / this.bodyDiv.width());
263
+ return this.boundPos(position);
264
+ };
265
+
266
+ AccessibleSlider.prototype.boundPos = function (position) {
267
+ return Math.max(0, Math.min(position, this.duration));
268
+ }
269
+
270
+ AccessibleSlider.prototype.setDuration = function (duration) {
271
+
272
+ if (duration !== this.duration) {
273
+ this.duration = duration;
274
+ this.resetHeadLocation();
275
+ this.seekHead.attr('aria-valuemax', duration);
276
+ }
277
+ };
278
+
279
+ AccessibleSlider.prototype.setWidth = function (width) {
280
+ this.wrapperDiv.width(width);
281
+ this.resizeDivs();
282
+ this.resetHeadLocation();
283
+ };
284
+
285
+ AccessibleSlider.prototype.getWidth = function () {
286
+ return this.wrapperDiv.width();
287
+ };
288
+
289
+ AccessibleSlider.prototype.resizeDivs = function () {
290
+ this.playedDiv.width(this.bodyDiv.width() * (this.position / this.duration));
291
+ this.loadedDiv.width(this.bodyDiv.width() * this.buffered);
292
+ };
293
+
294
+ // Stops tracking, sets the head location to the current position.
295
+ AccessibleSlider.prototype.resetHeadLocation = function () {
296
+ var ratio = this.position / this.duration;
297
+ var center = this.bodyDiv.width() * ratio;
298
+ this.seekHead.css('left', center - (this.seekHead.width() / 2));
299
+
300
+ if (this.tracking) {
301
+ this.stopTracking(this.position);
302
+ }
303
+ };
304
+
305
+ AccessibleSlider.prototype.setPosition = function (position, updateLive) {
306
+ this.position = position;
307
+ this.resetHeadLocation();
308
+ this.refreshTooltip();
309
+ this.resizeDivs();
310
+ this.updateAriaValues(position, updateLive);
311
+ }
312
+
313
+ // TODO: Native HTML5 can have several buffered segments, and this actually happens quite often. Change this to display them all.
314
+ AccessibleSlider.prototype.setBuffered = function (ratio) {
315
+ this.buffered = ratio;
316
+ this.redrawDivs;
317
+ }
318
+
319
+ AccessibleSlider.prototype.startTracking = function (device, position) {
320
+ if (!this.tracking) {
321
+ this.trackDevice = device;
322
+ this.tracking = true;
323
+ this.bodyDiv.trigger('startTracking', [position]);
324
+ }
325
+ };
326
+
327
+ AccessibleSlider.prototype.stopTracking = function (position) {
328
+ this.trackDevice = null;
329
+ this.tracking = false;
330
+ this.bodyDiv.trigger('stopTracking', [position]);
331
+ this.setPosition(position, true);
332
+ };
333
+
334
+ AccessibleSlider.prototype.trackHeadAtPageX = function (pageX) {
335
+ var position = this.pageXToPosition(pageX);
336
+ var newLeft = pageX - this.bodyDiv.offset().left - (this.seekHead.width() / 2);
337
+ newLeft = Math.max(0, Math.min(newLeft, this.bodyDiv.width() - this.seekHead.width()));
338
+ this.lastTrackPosition = position;
339
+ this.seekHead.css('left', newLeft);
340
+ this.reportTrackAtPosition(position);
341
+ };
342
+
343
+ AccessibleSlider.prototype.trackHeadAtPosition = function (position) {
344
+ var ratio = position / this.duration;
345
+ var center = this.bodyDiv.width() * ratio;
346
+ this.lastTrackPosition = position;
347
+ this.seekHead.css('left', center - (this.seekHead.width() / 2));
348
+ this.reportTrackAtPosition(position);
349
+ };
350
+
351
+ AccessibleSlider.prototype.reportTrackAtPosition = function (position) {
352
+ this.bodyDiv.trigger('tracking', [position]);
353
+ this.updateAriaValues(position, true);
354
+ };
355
+
356
+ AccessibleSlider.prototype.updateAriaValues = function (position, updateLive) {
357
+ // TODO: Localize, move to another function.
358
+ var pHours = Math.floor(position / 3600);
359
+ var pMinutes = Math.floor((position % 3600) / 60);
360
+ var pSeconds = Math.floor(position % 60);
361
+
362
+ var pHourWord = pHours === 1 ? 'hour' : 'hours';
363
+ var pMinuteWord = pMinutes === 1 ? 'minute' : 'minutes';
364
+ var pSecondWord = pSeconds === 1 ? 'second' : 'seconds';
365
+
366
+ var descriptionText;
367
+ if (pHours > 0) {
368
+ descriptionText = pHours +
369
+ ' ' + pHourWord +
370
+ ', ' + pMinutes +
371
+ ' ' + pMinuteWord +
372
+ ', ' + pSeconds +
373
+ ' ' + pSecondWord;
374
+ }
375
+ else if (pMinutes > 0) {
376
+ descriptionText = pMinutes +
377
+ ' ' + pMinuteWord +
378
+ ', ' + pSeconds +
379
+ ' ' + pSecondWord;
380
+ }
381
+ else {
382
+ descriptionText = pSeconds + ' ' + pSecondWord;
383
+ }
384
+
385
+ /* Comment to stop live region from generating or being used. */
386
+ if (!this.liveAriaRegion) {
387
+ this.liveAriaRegion = $('<span>', {
388
+ 'class': 'able-offscreen',
389
+ 'aria-live': 'polite'
390
+ });
391
+ this.wrapperDiv.append(this.liveAriaRegion);
392
+ }
393
+ if (updateLive && (this.liveAriaRegion.text() !== descriptionText)) {
394
+ this.liveAriaRegion.text(descriptionText);
395
+ }
396
+
397
+ // Uncomment the following lines to use aria values instead of separate live region.
398
+ this.seekHead.attr('aria-valuetext', descriptionText);
399
+ this.seekHead.attr('aria-valuenow', Math.floor(position).toString());
400
+ };
401
+
402
+ AccessibleSlider.prototype.trackImmediatelyTo = function (position) {
403
+ this.startTracking('keyboard', position);
404
+ this.trackHeadAtPosition(position);
405
+ this.keyTrackPosition = position;
406
+ };
407
+
408
+ AccessibleSlider.prototype.refreshTooltip = function () {
409
+ if (this.overHead) {
410
+ this.timeTooltip.show();
411
+ if (this.tracking) {
412
+ this.timeTooltip.text(this.positionToStr(this.lastTrackPosition));
413
+ }
414
+ else {
415
+ this.timeTooltip.text(this.positionToStr(this.position));
416
+ }
417
+ this.setTooltipPosition(this.seekHead.position().left + (this.seekHead.width() / 2));
418
+ }
419
+ else if (this.overBody && this.overBodyMousePos) {
420
+ this.timeTooltip.show();
421
+ this.timeTooltip.text(this.positionToStr(this.pageXToPosition(this.overBodyMousePos.x)));
422
+ this.setTooltipPosition(this.overBodyMousePos.x - this.bodyDiv.offset().left);
423
+ }
424
+ else {
425
+ this.timeTooltip.hide();
426
+ }
427
+ };
428
+
429
+ AccessibleSlider.prototype.setTooltipPosition = function (x) {
430
+ this.timeTooltip.css({
431
+ left: x - (this.timeTooltip.width() / 2) - 10,
432
+ bottom: this.seekHead.height() + 10
433
+ });
434
+ };
435
+
436
+ AccessibleSlider.prototype.positionToStr = function (seconds) {
437
+
438
+ // same logic as misc.js > formatSecondsAsColonTime()
439
+ var dHours = Math.floor(seconds / 3600);
440
+ var dMinutes = Math.floor(seconds / 60) % 60;
441
+ var dSeconds = Math.floor(seconds % 60);
442
+ if (dSeconds < 10) {
443
+ dSeconds = '0' + dSeconds;
444
+ }
445
+ if (dHours > 0) {
446
+ if (dMinutes < 10) {
447
+ dMinutes = '0' + dMinutes;
448
+ }
449
+ return dHours + ':' + dMinutes + ':' + dSeconds;
450
+ }
451
+ else {
452
+ return dMinutes + ':' + dSeconds;
453
+ }
454
+ };
454
455
 
455
456
  })(jQuery);