wai-website-theme 1.3.1 → 1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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,312 +1,412 @@
1
1
  (function ($) {
2
- // Loads files referenced in track elements, and performs appropriate setup.
3
- // For example, captions and text descriptions.
4
- // This will be called whenever the player is recreated.
5
- // Added in v2.2.23: Also handles YouTube caption tracks
6
- AblePlayer.prototype.setupTracks = function() {
7
-
8
- var thisObj = this;
9
-
10
- var deferred = new $.Deferred();
11
- var promise = deferred.promise();
12
- this.$tracks = this.$media.find('track');
13
-
14
- this.captions = [];
15
- this.captionLabels = [];
16
- this.descriptions = [];
17
- this.chapters = [];
18
- this.meta = [];
19
- if ($('#able-vts').length) {
20
- // Page includes a container for a VTS instance
21
- this.vtsTracks = [];
22
- this.hasVts = true;
23
- }
24
- else {
25
- this.hasVts = false;
26
- }
27
-
28
- var loadingPromises = [];
29
- for (var ii = 0; ii < this.$tracks.length; ii++) {
30
- var track = this.$tracks[ii];
31
- var kind = track.getAttribute('kind');
32
- var trackSrc = track.getAttribute('src');
33
- var isDefaultTrack = track.getAttribute('default');
34
-
35
- if (!trackSrc) {
36
- // Nothing to load!
37
- continue;
38
- }
39
-
40
- var loadingPromise = this.loadTextObject(trackSrc);
41
- loadingPromises.push(loadingPromise);
42
- loadingPromise.then((function (track, kind, trackLang, trackLabel) {
43
-
44
- // srcLang should always be included with <track>, but HTML5 spec doesn't require it
45
- // if not provided, assume track is the same language as the default player language
46
- var trackLang = track.getAttribute('srclang') || thisObj.lang;
47
- var trackLabel = track.getAttribute('label') || thisObj.getLanguageName(trackLang);
48
-
49
- return function (trackSrc, trackText) {
50
-
51
- var trackContents = trackText;
52
-
53
- // convert XMl/TTML captions file
54
- if (thisObj.useTtml && (trackSrc.endsWith('.xml') || trackText.startsWith('<?xml'))) {
55
- trackContents = thisObj.ttml2webvtt(trackText);
56
- }
57
-
58
- if (thisObj.hasVts) {
59
- // setupVtsTracks() is in vts.js
60
- thisObj.setupVtsTracks(kind, trackLang, trackLabel, trackSrc, trackContents);
61
- }
62
-
63
- var cues = thisObj.parseWebVTT(trackSrc, trackContents).cues;
64
-
65
- if (kind === 'captions' || kind === 'subtitles') {
66
- thisObj.setupCaptions(track, cues, trackLang, trackLabel);
67
- }
68
- else if (kind === 'descriptions') {
69
- thisObj.setupDescriptions(track, cues, trackLang);
70
- }
71
- else if (kind === 'chapters') {
72
- thisObj.setupChapters(track, cues, trackLang);
73
- }
74
- else if (kind === 'metadata') {
75
- thisObj.setupMetadata(track, cues);
76
- }
77
- }
78
- })(track, kind));
79
- }
80
-
81
- $.when.apply($, loadingPromises).then(function () {
82
- deferred.resolve();
83
- });
84
- return promise;
85
- };
86
-
87
- AblePlayer.prototype.setupCaptions = function (track, cues, trackLang, trackLabel) {
88
-
89
- this.hasCaptions = true;
90
- if (typeof track.getAttribute('default') == 'string') {
91
- var isDefaultTrack = true;
92
- // Now remove 'default' attribute from <track>
93
- // Otherwise, some browsers will display the track
94
- track.removeAttribute('default');
95
- }
96
- else {
97
- var isDefaultTrack = false;
98
- }
99
- // caption cues from WebVTT are used to build a transcript for both audio and video
100
- // but captions are currently only supported for video
101
- if (this.mediaType === 'video') {
102
-
103
- // create a pair of nested divs for displaying captions
104
- // includes aria-hidden="true" because otherwise
105
- // captions being added and removed causes sporadic changes to focus in JAWS
106
- // (not a problem in NVDA or VoiceOver)
107
- if (!this.$captionsDiv) {
108
- this.$captionsDiv = $('<div>',{
109
- 'class': 'able-captions',
110
- });
111
- this.$captionsWrapper = $('<div>',{
112
- 'class': 'able-captions-wrapper',
113
- 'aria-hidden': 'true'
114
- }).hide();
115
- if (this.prefCaptionsPosition === 'below') {
116
- this.$captionsWrapper.addClass('able-captions-below');
117
- }
118
- else {
119
- this.$captionsWrapper.addClass('able-captions-overlay');
120
- }
121
- this.$captionsWrapper.append(this.$captionsDiv);
122
- this.$vidcapContainer.append(this.$captionsWrapper);
123
- }
124
- }
125
-
126
- this.currentCaption = -1;
127
- if (this.prefCaptions === 1) {
128
- // Captions default to on.
129
- this.captionsOn = true;
130
- }
131
- else {
132
- this.captionsOn = false;
133
- }
134
-
135
- if (this.transcriptType === 'external' || this.transcriptType === 'popup') {
136
- // Remove the "Unknown" option from the select box.
137
- if (this.$unknownTranscriptOption) {
138
- this.$unknownTranscriptOption.remove();
139
- this.$unknownTranscriptOption = null;
140
- }
141
- var option = $('<option></option>',{
142
- value: trackLang,
143
- lang: trackLang
144
- }).text(trackLabel);
145
- }
146
- // alphabetize tracks by label
147
- if (this.transcriptType === 'external' || this.transcriptType === 'popup') {
148
- var options = this.$transcriptLanguageSelect.find('option');
149
- }
150
- if (this.captions.length === 0) { // this is the first
151
- this.captions.push({
152
- 'cues': cues,
153
- 'language': trackLang,
154
- 'label': trackLabel,
155
- 'def': isDefaultTrack
156
- });
157
- if (this.transcriptType === 'external' || this.transcriptType === 'popup') {
158
- if (isDefaultTrack) {
159
- option.prop('selected', true);
160
- }
161
- this.$transcriptLanguageSelect.append(option);
162
- }
163
- this.captionLabels.push(trackLabel);
164
- }
165
- else { // there are already tracks in the array
166
- var inserted = false;
167
- for (var i = 0; i < this.captions.length; i++) {
168
- var capLabel = this.captionLabels[i];
169
- if (trackLabel.toLowerCase() < this.captionLabels[i].toLowerCase()) {
170
- // insert before track i
171
- this.captions.splice(i,0,{
172
- 'cues': cues,
173
- 'language': trackLang,
174
- 'label': trackLabel,
175
- 'def': isDefaultTrack
176
- });
177
- if (this.transcriptType === 'external' || this.transcriptType === 'popup') {
178
- if (isDefaultTrack) {
179
- option.prop('selected', true);
180
- }
181
- option.insertBefore(options.eq(i));
182
- }
183
- this.captionLabels.splice(i,0,trackLabel);
184
- inserted = true;
185
- break;
186
- }
187
- }
188
- if (!inserted) {
189
- // just add track to the end
190
- this.captions.push({
191
- 'cues': cues,
192
- 'language': trackLang,
193
- 'label': trackLabel,
194
- 'def': isDefaultTrack
195
- });
196
- if (this.transcriptType === 'external' || this.transcriptType === 'popup') {
197
- if (isDefaultTrack) {
198
- option.prop('selected', true);
199
- }
200
- this.$transcriptLanguageSelect.append(option);
201
- }
202
- this.captionLabels.push(trackLabel);
203
- }
204
- }
205
- if (this.transcriptType === 'external' || this.transcriptType === 'popup') {
206
- if (this.$transcriptLanguageSelect.find('option').length > 1) {
207
- // More than one option now, so enable the select.
208
- this.$transcriptLanguageSelect.prop('disabled', false);
209
- }
210
- }
211
- };
212
-
213
-
214
- AblePlayer.prototype.setupDescriptions = function (track, cues, trackLang) {
215
-
216
- // called via setupTracks() only if there is track with kind="descriptions"
217
- // prepares for delivery of text description , in case it's needed
218
- // whether and how it's delivered is controlled within description.js > initDescription()
219
-
220
- this.hasClosedDesc = true;
221
- this.currentDescription = -1;
222
- this.descriptions.push({
223
- cues: cues,
224
- language: trackLang
225
- });
226
- };
227
-
228
- AblePlayer.prototype.setupChapters = function (track, cues, trackLang) {
229
-
230
- // NOTE: WebVTT supports nested timestamps (to form an outline)
231
- // This is not currently supported.
232
-
233
- this.hasChapters = true;
234
-
235
- this.chapters.push({
236
- cues: cues,
237
- language: trackLang
238
- });
239
- };
240
-
241
- AblePlayer.prototype.setupMetadata = function(track, cues) {
242
-
243
- if (this.metaType === 'text') {
244
- // Metadata is only supported if data-meta-div is provided
245
- // The player does not display metadata internally
246
- if (this.metaDiv) {
247
- if ($('#' + this.metaDiv)) {
248
- // container exists
249
- this.$metaDiv = $('#' + this.metaDiv);
250
- this.hasMeta = true;
251
- this.meta = cues;
252
- }
253
- }
254
- }
255
- else if (this.metaType === 'selector') {
256
- this.hasMeta = true;
257
- this.visibleSelectors = [];
258
- this.meta = cues;
259
- }
260
- };
261
-
262
- AblePlayer.prototype.loadTextObject = function(src) {
263
-
264
- var deferred = new $.Deferred();
265
- var promise = deferred.promise();
266
- var thisObj = this;
267
-
268
- // create a temp div for holding data
269
- var $tempDiv = $('<div>',{
270
- style: 'display:none'
271
- });
272
-
273
- $tempDiv.load(src, function (trackText, status, req) {
274
- if (status === 'error') {
275
- if (thisObj.debug) {
276
- console.log ('error reading file ' + src + ': ' + status);
277
- }
278
- deferred.fail();
279
- }
280
- else {
281
- deferred.resolve(src, trackText);
282
- }
283
- $tempDiv.remove();
284
- });
285
- return promise;
286
- };
287
-
288
- AblePlayer.prototype.setupAltCaptions = function() {
289
- // setup captions from an alternative source (not <track> elements)
290
- // only do this if no <track> captions are provided
291
- // currently supports: YouTube
292
- var deferred = new $.Deferred();
293
- var promise = deferred.promise();
294
-
295
- if (this.captions.length === 0) {
296
- if (this.player === 'youtube' && typeof youTubeDataAPIKey !== 'undefined') {
297
- this.setupYouTubeCaptions().done(function() {
298
- deferred.resolve();
299
- });
300
- }
301
- else {
302
- // repeat for other alt sources once supported (e.g., Vimeo, DailyMotion)
303
- deferred.resolve();
304
- }
305
- }
306
- else { // there are <track> captions, so no need for alt source captions
307
- deferred.resolve();
308
- }
309
- return promise;
310
- };
2
+ // Loads files referenced in track elements, and performs appropriate setup.
3
+ // For example, captions and text descriptions.
4
+ // This will be called whenever the player is recreated.
5
+ // Added in v2.2.23: Also handles YouTube caption tracks
6
+
7
+ AblePlayer.prototype.setupTracks = function() {
8
+
9
+ var thisObj, deferred, promise, loadingPromises, loadingPromise, i, tracks, track;
10
+
11
+ thisObj = this;
12
+
13
+ deferred = new $.Deferred();
14
+ promise = deferred.promise();
15
+
16
+ loadingPromises = [];
17
+
18
+ this.captions = [];
19
+ this.captionLabels = [];
20
+ this.descriptions = [];
21
+ this.chapters = [];
22
+ this.meta = [];
23
+
24
+ if ($('#able-vts').length) {
25
+ // Page includes a container for a VTS instance
26
+ this.vtsTracks = [];
27
+ this.hasVts = true;
28
+ }
29
+ else {
30
+ this.hasVts = false;
31
+ }
32
+
33
+ this.getTracks().then(function() {
34
+
35
+ tracks = thisObj.tracks;
36
+
37
+ if (thisObj.player === 'youtube') {
38
+ // If captions have been loaded into the captions array (either from YouTube or a local source),
39
+ // we no longer have a need to use YouTube captions
40
+ // TODO: Consider whether this is the right place to make this decision
41
+ // Probably better to make it when cues are identified from YouTube caption sources
42
+ if (tracks.length) {
43
+ thisObj.usingYouTubeCaptions = false;
44
+ }
45
+ }
46
+
47
+ for (i=0; i < tracks.length; i++) {
48
+
49
+ track = tracks[i];
50
+
51
+ var kind = track.kind;
52
+ var trackLang = track.language;
53
+ var trackLabel = track.label;
54
+
55
+ if (!track.src) {
56
+ if (thisObj.usingYouTubeCaptions || thisObj.usingVimeoCaptions) {
57
+ // skip all the hullabaloo and go straight to setupCaptions
58
+ thisObj.setupCaptions(track,trackLang,trackLabel);
59
+ }
60
+ else {
61
+ // Nothing to load!
62
+ // Skip this track; move on to next i
63
+ }
64
+ continue;
65
+ }
66
+
67
+ var trackSrc = track.src;
68
+
69
+ loadingPromise = thisObj.loadTextObject(trackSrc); // resolves with src, trackText
70
+ loadingPromises.push(loadingPromise);
71
+
72
+ loadingPromise.then((function (track, kind) {
73
+
74
+ var trackSrc = track.src;
75
+ var trackLang = track.language;
76
+ var trackLabel = track.label;
77
+
78
+ return function (trackSrc, trackText) { // these are the two vars returned from loadTextObject
79
+
80
+ var trackContents = trackText;
81
+ var cues = thisObj.parseWebVTT(trackSrc, trackContents).cues;
82
+
83
+ if (thisObj.hasVts) {
84
+ // setupVtsTracks() is in vts.js
85
+ thisObj.setupVtsTracks(kind, trackLang, trackLabel, trackSrc, trackContents);
86
+ }
87
+
88
+ if (kind === 'captions' || kind === 'subtitles') {
89
+ thisObj.setupCaptions(track, trackLang, trackLabel, cues);
90
+ }
91
+ else if (kind === 'descriptions') {
92
+ thisObj.setupDescriptions(track, cues, trackLang);
93
+ }
94
+ else if (kind === 'chapters') {
95
+ thisObj.setupChapters(track, cues, trackLang);
96
+ }
97
+ else if (kind === 'metadata') {
98
+ thisObj.setupMetadata(track, cues);
99
+ }
100
+ }
101
+ })(track, kind));
102
+ }
103
+ $.when.apply($, loadingPromises).then(function () {
104
+ deferred.resolve();
105
+ });
106
+ });
107
+
108
+ return promise;
109
+ };
110
+
111
+ AblePlayer.prototype.getTracks = function() {
112
+
113
+ // define an array tracks with the following structure:
114
+ // kind - string, e.g. "captions", "descriptions"
115
+ // src - string, URL of WebVTT source file
116
+ // language - string, lang code
117
+ // label - string to display, e.g., in CC menu
118
+ // def - Boolean, true if this is the default track
119
+ // cues - array with startTime, endTime, and payload
120
+
121
+ var thisObj, deferred, promise, captionTracks, trackLang, trackLabel, isDefault;
122
+
123
+ thisObj = this;
124
+
125
+ deferred = new $.Deferred();
126
+ promise = deferred.promise();
127
+
128
+ this.$tracks = this.$media.find('track');
129
+ this.tracks = [];
130
+
131
+ if (this.$tracks.length) {
132
+
133
+ // create object from HTML5 tracks
134
+ this.$tracks.each(function() {
135
+
136
+ // srcLang should always be included with <track>, but HTML5 spec doesn't require it
137
+ // if not provided, assume track is the same language as the default player language
138
+ if ($(this).attr('srclang')) {
139
+ trackLang = $(this).attr('srclang');
140
+ }
141
+ else {
142
+ trackLang = thisObj.lang;
143
+ }
144
+
145
+ if ($(this).attr('label')) {
146
+ trackLabel = $(this).attr('label');
147
+ }
148
+ else {
149
+ trackLabel = thisObj.getLanguageName(trackLang);
150
+ }
151
+
152
+ if ($(this).attr('default')) {
153
+ isDefault = true;
154
+ }
155
+ else if (trackLang === thisObj.lang) {
156
+ // There is no @default attribute,
157
+ // but this is the user's/browser's default language
158
+ // so make it the default caption track
159
+ isDefault = true;
160
+ }
161
+ else {
162
+ isDefault = false;
163
+ }
164
+
165
+ if (isDefault) {
166
+ // this.captionLang will also be the default language for non-caption tracks
167
+ thisObj.captionLang = trackLang;
168
+ }
169
+
170
+ thisObj.tracks.push({
171
+ 'kind': $(this).attr('kind'),
172
+ 'src': $(this).attr('src'),
173
+ 'language': trackLang,
174
+ 'label': trackLabel,
175
+ 'def': isDefault
176
+ });
177
+ });
178
+ }
179
+
180
+ // check to see if any HTML caption or subitle tracks were found.
181
+ captionTracks = this.$media.find('track[kind="captions"],track[kind="subtitles"]');
182
+ if (captionTracks.length) {
183
+ // HTML captions or subtitles were found. Use those.
184
+ deferred.resolve();
185
+ }
186
+ else {
187
+ // if this is a youtube or vimeo player, check there for captions/subtitles
188
+ if (this.player === 'youtube') {
189
+ this.getYouTubeCaptionTracks(this.youTubeId).then(function() {
190
+ deferred.resolve();
191
+ });
192
+ }
193
+ else if (this.player === 'vimeo') {
194
+ this.getVimeoCaptionTracks().then(function() {
195
+ deferred.resolve();
196
+ });
197
+ }
198
+ else {
199
+ // this is neither YouTube nor Vimeo
200
+ // there just ain't no caption tracks
201
+ deferred.resolve();
202
+ }
203
+ }
204
+ return promise;
205
+ };
206
+
207
+ AblePlayer.prototype.setupCaptions = function (track, trackLang, trackLabel, cues) {
208
+
209
+ var thisObj, inserted, i, capLabel;
210
+
211
+ thisObj = this;
212
+
213
+ if (typeof cues === 'undefined') {
214
+ cues = null;
215
+ }
216
+
217
+ this.hasCaptions = true;
218
+
219
+ // Remove 'default' attribute from all <track> elements
220
+ // This data has already been saved to this.tracks
221
+ // and some browsers will display the default captions, despite all standard efforts to suppress them
222
+ this.$media.find('track').removeAttr('default');
223
+
224
+ // caption cues from WebVTT are used to build a transcript for both audio and video
225
+ // but captions are currently only supported for video
226
+ if (this.mediaType === 'video') {
227
+
228
+ if (!(this.usingYouTubeCaptions || this.usingVimeoCaptions)) {
229
+ // create a pair of nested divs for displaying captions
230
+ // includes aria-hidden="true" because otherwise
231
+ // captions being added and removed causes sporadic changes to focus in JAWS
232
+ // (not a problem in NVDA or VoiceOver)
233
+ if (!this.$captionsDiv) {
234
+ this.$captionsDiv = $('<div>',{
235
+ 'class': 'able-captions',
236
+ });
237
+ this.$captionsWrapper = $('<div>',{
238
+ 'class': 'able-captions-wrapper',
239
+ 'aria-hidden': 'true'
240
+ }).hide();
241
+ if (this.prefCaptionsPosition === 'below') {
242
+ this.$captionsWrapper.addClass('able-captions-below');
243
+ }
244
+ else {
245
+ this.$captionsWrapper.addClass('able-captions-overlay');
246
+ }
247
+ this.$captionsWrapper.append(this.$captionsDiv);
248
+ this.$vidcapContainer.append(this.$captionsWrapper);
249
+ }
250
+ }
251
+ }
252
+
253
+ this.currentCaption = -1;
254
+ if (this.prefCaptions === 1) {
255
+ // Captions default to on.
256
+ this.captionsOn = true;
257
+ }
258
+ else {
259
+ this.captionsOn = false;
260
+ }
261
+ if (this.captions.length === 0) { // this is the first
262
+ this.captions.push({
263
+ 'cues': cues,
264
+ 'language': trackLang,
265
+ 'label': trackLabel,
266
+ 'def': track.def
267
+ });
268
+ this.captionLabels.push(trackLabel);
269
+ }
270
+ else { // there are already tracks in the array
271
+ inserted = false;
272
+ for (i = 0; i < this.captions.length; i++) {
273
+ capLabel = this.captionLabels[i];
274
+ if (trackLabel.toLowerCase() < this.captionLabels[i].toLowerCase()) {
275
+ // insert before track i
276
+ this.captions.splice(i,0,{
277
+ 'cues': cues,
278
+ 'language': trackLang,
279
+ 'label': trackLabel,
280
+ 'def': track.def
281
+ });
282
+ this.captionLabels.splice(i,0,trackLabel);
283
+ inserted = true;
284
+ break;
285
+ }
286
+ }
287
+ if (!inserted) {
288
+ // just add track to the end
289
+ this.captions.push({
290
+ 'cues': cues,
291
+ 'language': trackLang,
292
+ 'label': trackLabel,
293
+ 'def': track.def
294
+ });
295
+ this.captionLabels.push(trackLabel);
296
+ }
297
+ }
298
+ };
299
+
300
+ AblePlayer.prototype.setupDescriptions = function (track, cues, trackLang) {
301
+
302
+ // called via setupTracks() only if there is track with kind="descriptions"
303
+ // prepares for delivery of text description , in case it's needed
304
+ // whether and how it's delivered is controlled within description.js > initDescription()
305
+
306
+ this.hasClosedDesc = true;
307
+ this.currentDescription = -1;
308
+ this.descriptions.push({
309
+ cues: cues,
310
+ language: trackLang
311
+ });
312
+ };
313
+
314
+ AblePlayer.prototype.setupChapters = function (track, cues, trackLang) {
315
+
316
+ // NOTE: WebVTT supports nested timestamps (to form an outline)
317
+ // This is not currently supported.
318
+
319
+ this.hasChapters = true;
320
+
321
+ this.chapters.push({
322
+ cues: cues,
323
+ language: trackLang
324
+ });
325
+ };
326
+
327
+ AblePlayer.prototype.setupMetadata = function(track, cues) {
328
+
329
+ if (this.metaType === 'text') {
330
+ // Metadata is only supported if data-meta-div is provided
331
+ // The player does not display metadata internally
332
+ if (this.metaDiv) {
333
+ if ($('#' + this.metaDiv)) {
334
+ // container exists
335
+ this.$metaDiv = $('#' + this.metaDiv);
336
+ this.hasMeta = true;
337
+ this.meta = cues;
338
+ }
339
+ }
340
+ }
341
+ else if (this.metaType === 'selector') {
342
+ this.hasMeta = true;
343
+ this.visibleSelectors = [];
344
+ this.meta = cues;
345
+ }
346
+ };
347
+
348
+ AblePlayer.prototype.loadTextObject = function(src) {
349
+
350
+ // TODO: Incorporate the following function, moved from setupTracks()
351
+ // convert XMl/TTML captions file
352
+ /*
353
+ if (thisObj.useTtml && (trackSrc.endsWith('.xml') || trackText.startsWith('<?xml'))) {
354
+ trackContents = thisObj.ttml2webvtt(trackText);
355
+ }
356
+ */
357
+ var deferred, promise, thisObj, $tempDiv;
358
+
359
+ deferred = new $.Deferred();
360
+ promise = deferred.promise();
361
+ thisObj = this;
362
+
363
+ // create a temp div for holding data
364
+ $tempDiv = $('<div>',{
365
+ style: 'display:none'
366
+ });
367
+ $tempDiv.load(src, function (trackText, status, req) {
368
+ if (status === 'error') {
369
+ if (thisObj.debug) {
370
+ console.log ('error reading file ' + src + ': ' + status);
371
+ }
372
+ deferred.fail();
373
+ }
374
+ else {
375
+ deferred.resolve(src, trackText);
376
+ }
377
+ $tempDiv.remove();
378
+ });
379
+ return promise;
380
+ };
381
+
382
+ AblePlayer.prototype.setupAltCaptions = function() {
383
+
384
+ // setup captions from an alternative source (not <track> elements)
385
+ // only do this if no <track> captions are provided
386
+ // currently supports: YouTube, Vimeo
387
+ var deferred = new $.Deferred();
388
+ var promise = deferred.promise();
389
+ if (this.captions.length === 0) {
390
+ if (this.player === 'youtube' && this.usingYouTubeCaptions) {
391
+ this.setupYouTubeCaptions().done(function() {
392
+ deferred.resolve();
393
+ });
394
+ }
395
+ else if (this.player === 'vimeo' && this.usingVimeoCaptions) {
396
+ this.setupVimeoCaptions().done(function() {
397
+ deferred.resolve();
398
+ });
399
+ }
400
+
401
+ else {
402
+ // repeat for other alt sources once supported (e.g., Vimeo, DailyMotion)
403
+ deferred.resolve();
404
+ }
405
+ }
406
+ else { // there are <track> captions, so no need for alt source captions
407
+ deferred.resolve();
408
+ }
409
+ return promise;
410
+ };
311
411
 
312
412
  })(jQuery);