wai-website-theme 0.1.0
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.
- checksums.yaml +7 -0
- data/LICENSE.txt +21 -0
- data/README.md +52 -0
- data/_data/lang.json +730 -0
- data/_data/techniques.yml +180 -0
- data/_data/wcag.yml +125 -0
- data/_includes/.DS_Store +0 -0
- data/_includes/body-class.html +1 -0
- data/_includes/box.html +10 -0
- data/_includes/excol.html +13 -0
- data/_includes/footer.html +40 -0
- data/_includes/head.html +23 -0
- data/_includes/header.html +59 -0
- data/_includes/icon.html +6 -0
- data/_includes/img.html +17 -0
- data/_includes/multilang-list-policy-links.html +29 -0
- data/_includes/multilang-list.html +35 -0
- data/_includes/multilang-policy-title.html +5 -0
- data/_includes/multilang-title-full.html +1 -0
- data/_includes/multilang-title.html +1 -0
- data/_includes/navlist.html +22 -0
- data/_includes/notes.html +2 -0
- data/_includes/prevnext.html +34 -0
- data/_includes/resources.html +19 -0
- data/_includes/sidenav.html +65 -0
- data/_includes/sidenote.html +14 -0
- data/_includes/toc.html +10 -0
- data/_includes/video-player.html +99 -0
- data/_layouts/default.html +26 -0
- data/_layouts/home.html +14 -0
- data/_layouts/news.html +21 -0
- data/_layouts/none.html +1 -0
- data/_layouts/policy.html +72 -0
- data/_layouts/sidenav.html +27 -0
- data/_layouts/sidenavsidebar.html +22 -0
- data/assets/ableplayer/.gitattributes +14 -0
- data/assets/ableplayer/.gitignore +7 -0
- data/assets/ableplayer/Gruntfile.js +105 -0
- data/assets/ableplayer/LICENSE +26 -0
- data/assets/ableplayer/README.md +656 -0
- data/assets/ableplayer/build/ableplayer.dist.js +12157 -0
- data/assets/ableplayer/build/ableplayer.js +12157 -0
- data/assets/ableplayer/build/ableplayer.min.css +2 -0
- data/assets/ableplayer/build/ableplayer.min.js +8 -0
- data/assets/ableplayer/button-icons/able-icons.svg +116 -0
- data/assets/ableplayer/button-icons/black/captions.png +0 -0
- data/assets/ableplayer/button-icons/black/chapters.png +0 -0
- data/assets/ableplayer/button-icons/black/close.png +0 -0
- data/assets/ableplayer/button-icons/black/descriptions.png +0 -0
- data/assets/ableplayer/button-icons/black/ellipsis.png +0 -0
- data/assets/ableplayer/button-icons/black/faster.png +0 -0
- data/assets/ableplayer/button-icons/black/forward.png +0 -0
- data/assets/ableplayer/button-icons/black/fullscreen-collapse.png +0 -0
- data/assets/ableplayer/button-icons/black/fullscreen-expand.png +0 -0
- data/assets/ableplayer/button-icons/black/help.png +0 -0
- data/assets/ableplayer/button-icons/black/next.png +0 -0
- data/assets/ableplayer/button-icons/black/pause.png +0 -0
- data/assets/ableplayer/button-icons/black/pipe.png +0 -0
- data/assets/ableplayer/button-icons/black/play.png +0 -0
- data/assets/ableplayer/button-icons/black/preferences.png +0 -0
- data/assets/ableplayer/button-icons/black/previous.png +0 -0
- data/assets/ableplayer/button-icons/black/rabbit.png +0 -0
- data/assets/ableplayer/button-icons/black/restart.png +0 -0
- data/assets/ableplayer/button-icons/black/rewind.png +0 -0
- data/assets/ableplayer/button-icons/black/sign.png +0 -0
- data/assets/ableplayer/button-icons/black/slower.png +0 -0
- data/assets/ableplayer/button-icons/black/stop.png +0 -0
- data/assets/ableplayer/button-icons/black/transcript.png +0 -0
- data/assets/ableplayer/button-icons/black/turtle.png +0 -0
- data/assets/ableplayer/button-icons/black/volume-loud.png +0 -0
- data/assets/ableplayer/button-icons/black/volume-medium.png +0 -0
- data/assets/ableplayer/button-icons/black/volume-mute.png +0 -0
- data/assets/ableplayer/button-icons/black/volume-soft.png +0 -0
- data/assets/ableplayer/button-icons/fonts/able.eot +0 -0
- data/assets/ableplayer/button-icons/fonts/able.svg +40 -0
- data/assets/ableplayer/button-icons/fonts/able.ttf +0 -0
- data/assets/ableplayer/button-icons/fonts/able.woff +0 -0
- data/assets/ableplayer/button-icons/white/captions.png +0 -0
- data/assets/ableplayer/button-icons/white/chapters.png +0 -0
- data/assets/ableplayer/button-icons/white/close.png +0 -0
- data/assets/ableplayer/button-icons/white/descriptions.png +0 -0
- data/assets/ableplayer/button-icons/white/ellipsis.png +0 -0
- data/assets/ableplayer/button-icons/white/faster.png +0 -0
- data/assets/ableplayer/button-icons/white/forward.png +0 -0
- data/assets/ableplayer/button-icons/white/fullscreen-collapse.png +0 -0
- data/assets/ableplayer/button-icons/white/fullscreen-expand.png +0 -0
- data/assets/ableplayer/button-icons/white/help.png +0 -0
- data/assets/ableplayer/button-icons/white/next.png +0 -0
- data/assets/ableplayer/button-icons/white/pause.png +0 -0
- data/assets/ableplayer/button-icons/white/pipe.png +0 -0
- data/assets/ableplayer/button-icons/white/play.png +0 -0
- data/assets/ableplayer/button-icons/white/preferences.png +0 -0
- data/assets/ableplayer/button-icons/white/previous.png +0 -0
- data/assets/ableplayer/button-icons/white/rabbit.png +0 -0
- data/assets/ableplayer/button-icons/white/restart.png +0 -0
- data/assets/ableplayer/button-icons/white/rewind.png +0 -0
- data/assets/ableplayer/button-icons/white/sign.png +0 -0
- data/assets/ableplayer/button-icons/white/slower.png +0 -0
- data/assets/ableplayer/button-icons/white/stop.png +0 -0
- data/assets/ableplayer/button-icons/white/transcript.png +0 -0
- data/assets/ableplayer/button-icons/white/turtle.png +0 -0
- data/assets/ableplayer/button-icons/white/volume-loud.png +0 -0
- data/assets/ableplayer/button-icons/white/volume-medium.png +0 -0
- data/assets/ableplayer/button-icons/white/volume-mute.png +0 -0
- data/assets/ableplayer/button-icons/white/volume-soft.png +0 -0
- data/assets/ableplayer/images/wingrip.png +0 -0
- data/assets/ableplayer/package.json +22 -0
- data/assets/ableplayer/scripts/JQuery.doWhen.js +113 -0
- data/assets/ableplayer/scripts/ableplayer-base.js +440 -0
- data/assets/ableplayer/scripts/browser.js +162 -0
- data/assets/ableplayer/scripts/buildplayer.js +1609 -0
- data/assets/ableplayer/scripts/caption.js +385 -0
- data/assets/ableplayer/scripts/chapters.js +242 -0
- data/assets/ableplayer/scripts/control.js +1514 -0
- data/assets/ableplayer/scripts/description.js +283 -0
- data/assets/ableplayer/scripts/dialog.js +147 -0
- data/assets/ableplayer/scripts/dragdrop.js +766 -0
- data/assets/ableplayer/scripts/event.js +595 -0
- data/assets/ableplayer/scripts/initialize.js +725 -0
- data/assets/ableplayer/scripts/langs.js +750 -0
- data/assets/ableplayer/scripts/metadata.js +134 -0
- data/assets/ableplayer/scripts/misc.js +72 -0
- data/assets/ableplayer/scripts/preference.js +909 -0
- data/assets/ableplayer/scripts/search.js +171 -0
- data/assets/ableplayer/scripts/sign.js +92 -0
- data/assets/ableplayer/scripts/slider.js +454 -0
- data/assets/ableplayer/scripts/track.js +296 -0
- data/assets/ableplayer/scripts/transcript.js +590 -0
- data/assets/ableplayer/scripts/translation.js +66 -0
- data/assets/ableplayer/scripts/volume.js +383 -0
- data/assets/ableplayer/scripts/webvtt.js +765 -0
- data/assets/ableplayer/scripts/youtube.js +471 -0
- data/assets/ableplayer/styles/ableplayer.css +1241 -0
- data/assets/ableplayer/thirdparty/js.cookie.js +145 -0
- data/assets/ableplayer/thirdparty/modernizr.custom.js +4 -0
- data/assets/ableplayer/translations/ca.js +1 -0
- data/assets/ableplayer/translations/de.js +1 -0
- data/assets/ableplayer/translations/en.js +305 -0
- data/assets/ableplayer/translations/es.js +305 -0
- data/assets/ableplayer/translations/fr.js +305 -0
- data/assets/ableplayer/translations/it.js +303 -0
- data/assets/ableplayer/translations/ja.js +305 -0
- data/assets/ableplayer/translations/nl.js +305 -0
- data/assets/css/style.css +4360 -0
- data/assets/css/style.css.map +1 -0
- data/assets/fonts/anonymouspro-bold.woff +0 -0
- data/assets/fonts/anonymouspro-bold.woff2 +0 -0
- data/assets/fonts/anonymouspro-bolditalic.woff +0 -0
- data/assets/fonts/anonymouspro-bolditalic.woff2 +0 -0
- data/assets/fonts/anonymouspro-italic.woff +0 -0
- data/assets/fonts/anonymouspro-italic.woff2 +0 -0
- data/assets/fonts/anonymouspro-regular.woff +0 -0
- data/assets/fonts/anonymouspro-regular.woff2 +0 -0
- data/assets/fonts/notosans-bold.woff +0 -0
- data/assets/fonts/notosans-bold.woff2 +0 -0
- data/assets/fonts/notosans-bolditalic.woff +0 -0
- data/assets/fonts/notosans-bolditalic.woff2 +0 -0
- data/assets/fonts/notosans-italic.woff +0 -0
- data/assets/fonts/notosans-italic.woff2 +0 -0
- data/assets/fonts/notosans-regular.woff +0 -0
- data/assets/fonts/notosans-regular.woff2 +0 -0
- data/assets/images/.DS_Store +0 -0
- data/assets/images/Shape.svg +10 -0
- data/assets/images/icon-related-content.svg +14 -0
- data/assets/images/icons.svg +126 -0
- data/assets/images/teaser-image@1x.jpg +0 -0
- data/assets/images/teaser-image@2x.jpg +0 -0
- data/assets/images/w3c.sketch +0 -0
- data/assets/images/w3c.svg +10 -0
- data/assets/scripts/jquery.min.js +4 -0
- data/assets/scripts/main.js +208 -0
- data/assets/scripts/svg4everybody.js +1 -0
- metadata +257 -0
|
@@ -0,0 +1,590 @@
|
|
|
1
|
+
(function ($) {
|
|
2
|
+
|
|
3
|
+
AblePlayer.prototype.injectTranscriptArea = function() {
|
|
4
|
+
|
|
5
|
+
var thisObj = this;
|
|
6
|
+
|
|
7
|
+
this.$transcriptArea = $('<div>', {
|
|
8
|
+
'class': 'able-transcript-area',
|
|
9
|
+
'tabindex': '-1'
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
this.$transcriptToolbar = $('<div>', {
|
|
13
|
+
'class': 'able-window-toolbar able-' + this.toolbarIconColor + '-controls'
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
this.$transcriptDiv = $('<div>', {
|
|
17
|
+
'class' : 'able-transcript'
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
// Transcript toolbar content:
|
|
21
|
+
this.$autoScrollTranscriptCheckbox = $('<input id="autoscroll-transcript-checkbox" type="checkbox">');
|
|
22
|
+
this.$transcriptToolbar.append($('<label for="autoscroll-transcript-checkbox">' + this.tt.autoScroll + ': </label>'), this.$autoScrollTranscriptCheckbox);
|
|
23
|
+
|
|
24
|
+
// Add field for selecting a transcript language
|
|
25
|
+
// This will be deleted in initialize.js > recreatePlayer() if there are no languages
|
|
26
|
+
this.$transcriptLanguageSelect = $('<select id="transcript-language-select">');
|
|
27
|
+
// Add a default "Unknown" option; this will be deleted later if there are any
|
|
28
|
+
// elements with a language.
|
|
29
|
+
this.$unknownTranscriptOption = $('<option val="unknown">' + this.tt.unknown + '</option>');
|
|
30
|
+
this.$transcriptLanguageSelect.append(this.$unknownTranscriptOption);
|
|
31
|
+
this.$transcriptLanguageSelect.prop('disabled', true);
|
|
32
|
+
|
|
33
|
+
var languageSelectWrapper = $('<div class="transcript-language-select-wrapper">');
|
|
34
|
+
this.$transcriptLanguageSelectContainer = languageSelectWrapper;
|
|
35
|
+
|
|
36
|
+
languageSelectWrapper.append($('<label for="transcript-language-select">' + this.tt.language + ': </label>'), this.$transcriptLanguageSelect);
|
|
37
|
+
this.$transcriptToolbar.append(languageSelectWrapper);
|
|
38
|
+
|
|
39
|
+
this.$transcriptArea.append(this.$transcriptToolbar, this.$transcriptDiv);
|
|
40
|
+
|
|
41
|
+
// If client has provided separate transcript location, put it there.
|
|
42
|
+
// Otherwise append it to the body
|
|
43
|
+
if (this.transcriptDivLocation) {
|
|
44
|
+
$('#' + this.transcriptDivLocation).append(this.$transcriptArea);
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
this.$ableWrapper.append(this.$transcriptArea);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// make it draggable (popup only; NOT external transcript)
|
|
51
|
+
if (!this.transcriptDivLocation) {
|
|
52
|
+
this.initDragDrop('transcript');
|
|
53
|
+
if (this.prefTranscript === 1) {
|
|
54
|
+
// transcript is on. Go ahead and position it
|
|
55
|
+
this.positionDraggableWindow('transcript',this.getDefaultWidth('transcript'));
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// If client has provided separate transcript location, override user's preference for hiding transcript
|
|
60
|
+
if (!this.prefTranscript && !this.transcriptDivLocation) {
|
|
61
|
+
this.$transcriptArea.hide();
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
AblePlayer.prototype.addTranscriptAreaEvents = function() {
|
|
66
|
+
|
|
67
|
+
var thisObj = this;
|
|
68
|
+
|
|
69
|
+
this.$autoScrollTranscriptCheckbox.click(function () {
|
|
70
|
+
thisObj.handleTranscriptLockToggle(thisObj.$autoScrollTranscriptCheckbox.prop('checked'));
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
this.$transcriptDiv.bind('mousewheel DOMMouseScroll click scroll', function (event) {
|
|
74
|
+
// Propagation is stopped in transcript click handler, so clicks are on the scrollbar
|
|
75
|
+
// or outside of a clickable span.
|
|
76
|
+
if (!thisObj.scrollingTranscript) {
|
|
77
|
+
thisObj.autoScrollTranscript = false;
|
|
78
|
+
thisObj.refreshControls();
|
|
79
|
+
}
|
|
80
|
+
thisObj.scrollingTranscript = false;
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
if (typeof this.$transcriptLanguageSelect !== 'undefined') {
|
|
84
|
+
|
|
85
|
+
this.$transcriptLanguageSelect.on('click mousedown',function (event) {
|
|
86
|
+
// execute default behavior
|
|
87
|
+
// prevent propagation of mouse event to toolbar or window
|
|
88
|
+
event.stopPropagation();
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
this.$transcriptLanguageSelect.on('change',function () {
|
|
92
|
+
|
|
93
|
+
var language = thisObj.$transcriptLanguageSelect.val();
|
|
94
|
+
|
|
95
|
+
thisObj.syncTrackLanguages('transcript',language);
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
AblePlayer.prototype.transcriptSrcHasRequiredParts = function() {
|
|
101
|
+
|
|
102
|
+
// check the external transcript to be sure it has all required components
|
|
103
|
+
// return true or false
|
|
104
|
+
// in the process, define all the needed variables and properties
|
|
105
|
+
|
|
106
|
+
if ($('#' + this.transcriptSrc).length) {
|
|
107
|
+
this.$transcriptArea = $('#' + this.transcriptSrc);
|
|
108
|
+
if (this.$transcriptArea.find('.able-window-toolbar').length) {
|
|
109
|
+
this.$transcriptToolbar = this.$transcriptArea.find('.able-window-toolbar').eq(0);
|
|
110
|
+
if (this.$transcriptArea.find('.able-transcript').length) {
|
|
111
|
+
this.$transcriptDiv = this.$transcriptArea.find('.able-transcript').eq(0);
|
|
112
|
+
if (this.$transcriptArea.find('.able-transcript-seekpoint').length) {
|
|
113
|
+
this.$transcriptSeekpoints = this.$transcriptArea.find('.able-transcript-seekpoint');
|
|
114
|
+
return true;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
return false;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
AblePlayer.prototype.setupManualTranscript = function() {
|
|
123
|
+
|
|
124
|
+
// Add an auto-scroll checkbox to the toolbar
|
|
125
|
+
|
|
126
|
+
this.$autoScrollTranscriptCheckbox = $('<input id="autoscroll-transcript-checkbox" type="checkbox">');
|
|
127
|
+
this.$transcriptToolbar.append($('<label for="autoscroll-transcript-checkbox">' + this.tt.autoScroll + ': </label>'), this.$autoScrollTranscriptCheckbox);
|
|
128
|
+
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
AblePlayer.prototype.updateTranscript = function() {
|
|
132
|
+
|
|
133
|
+
if (!this.transcriptType) {
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
if (this.transcriptType === 'external' || this.transcriptType === 'popup') {
|
|
138
|
+
|
|
139
|
+
var chapters, captions, descriptions;
|
|
140
|
+
|
|
141
|
+
// Language of transcript might be different than language of captions
|
|
142
|
+
// But both are in sync by default
|
|
143
|
+
if (this.transcriptLang) {
|
|
144
|
+
captions = this.transcriptCaptions.cues;
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
if (this.transcriptCaptions) {
|
|
148
|
+
this.transcriptLang = this.transcriptCaptions.language;
|
|
149
|
+
captions = this.transcriptCaptions.cues;
|
|
150
|
+
}
|
|
151
|
+
else if (this.selectedCaptions) {
|
|
152
|
+
this.transcriptLang = this.captionLang;
|
|
153
|
+
captions = this.selectedCaptions.cues;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// setup chapters
|
|
158
|
+
if (this.transcriptChapters) {
|
|
159
|
+
chapters = this.transcriptChapters.cues;
|
|
160
|
+
}
|
|
161
|
+
else if (this.chapters.length > 0) {
|
|
162
|
+
// Try and match the caption language.
|
|
163
|
+
if (this.transcriptLang) {
|
|
164
|
+
for (var ii = 0; ii < this.chapters.length; ii++) {
|
|
165
|
+
if (this.chapters[ii].language === this.transcriptLang) {
|
|
166
|
+
chapters = this.chapters[ii].cues;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
if (typeof chapters === 'undefined') {
|
|
171
|
+
chapters = this.chapters[0].cues || [];
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// setup descriptions
|
|
176
|
+
if (this.transcriptDescriptions) {
|
|
177
|
+
descriptions = this.transcriptDescriptions.cues;
|
|
178
|
+
}
|
|
179
|
+
else if (this.descriptions.length > 0) {
|
|
180
|
+
// Try and match the caption language.
|
|
181
|
+
if (this.transcriptLang) {
|
|
182
|
+
for (var ii = 0; ii < this.descriptions.length; ii++) {
|
|
183
|
+
if (this.descriptions[ii].language === this.transcriptLang) {
|
|
184
|
+
descriptions = this.descriptions[ii].cues;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
if (!descriptions) {
|
|
189
|
+
descriptions = this.descriptions[0].cues || [];
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
var div = this.generateTranscript(chapters || [], captions || [], descriptions || []);
|
|
194
|
+
|
|
195
|
+
this.$transcriptDiv.html(div);
|
|
196
|
+
// reset transcript selected <option> to this.transcriptLang
|
|
197
|
+
if (this.$transcriptLanguageSelect) {
|
|
198
|
+
this.$transcriptLanguageSelect.find('option:selected').prop('selected',false);
|
|
199
|
+
this.$transcriptLanguageSelect.find('option[lang=' + this.transcriptLang + ']').prop('selected',true);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
var thisObj = this;
|
|
204
|
+
|
|
205
|
+
// Make transcript tabbable if preference is turned on.
|
|
206
|
+
if (this.prefTabbable === 1) {
|
|
207
|
+
$('.able-transcript span.able-transcript-seekpoint').attr('tabindex','0');
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
// handle clicks on text within transcript
|
|
211
|
+
// Note: This event listeners handles clicks only, not keydown events
|
|
212
|
+
// Pressing Enter on an element that is not natively clickable does NOT trigger click()
|
|
213
|
+
// Keydown events are handled elsehwere, both globally (ableplayer-base.js) and locally (event.js)
|
|
214
|
+
if (this.$transcriptArea.length > 0) {
|
|
215
|
+
this.$transcriptArea.find('span.able-transcript-seekpoint').click(function(event) {
|
|
216
|
+
var spanStart = parseFloat($(this).attr('data-start'));
|
|
217
|
+
// Add a tiny amount so that we're inside the span.
|
|
218
|
+
spanStart += .01;
|
|
219
|
+
thisObj.seekTo(spanStart);
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
};
|
|
223
|
+
|
|
224
|
+
AblePlayer.prototype.highlightTranscript = function (currentTime) {
|
|
225
|
+
|
|
226
|
+
//show highlight in transcript marking current caption
|
|
227
|
+
|
|
228
|
+
if (!this.transcriptType) {
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
var start, end;
|
|
233
|
+
var thisObj = this;
|
|
234
|
+
|
|
235
|
+
currentTime = parseFloat(currentTime);
|
|
236
|
+
|
|
237
|
+
// Highlight the current transcript item.
|
|
238
|
+
this.$transcriptArea.find('span.able-transcript-caption').each(function() {
|
|
239
|
+
start = parseFloat($(this).attr('data-start'));
|
|
240
|
+
end = parseFloat($(this).attr('data-end'));
|
|
241
|
+
if (currentTime >= start && currentTime <= end) {
|
|
242
|
+
// move all previous highlights before adding one to current span
|
|
243
|
+
thisObj.$transcriptArea.find('.able-highlight').removeClass('able-highlight');
|
|
244
|
+
$(this).addClass('able-highlight');
|
|
245
|
+
return false;
|
|
246
|
+
}
|
|
247
|
+
});
|
|
248
|
+
thisObj.currentHighlight = $('.able-highlight');
|
|
249
|
+
if (thisObj.currentHighlight.length === 0) {
|
|
250
|
+
// Nothing highlighted.
|
|
251
|
+
thisObj.currentHighlight = null;
|
|
252
|
+
}
|
|
253
|
+
};
|
|
254
|
+
|
|
255
|
+
AblePlayer.prototype.generateTranscript = function(chapters, captions, descriptions) {
|
|
256
|
+
|
|
257
|
+
var thisObj = this;
|
|
258
|
+
|
|
259
|
+
var $main = $('<div class="able-transcript-container"></div>');
|
|
260
|
+
var transcriptTitle;
|
|
261
|
+
|
|
262
|
+
// set language for transcript container
|
|
263
|
+
$main.attr('lang', this.transcriptLang);
|
|
264
|
+
|
|
265
|
+
if (typeof this.transcriptTitle !== 'undefined') {
|
|
266
|
+
transcriptTitle = this.transcriptTitle;
|
|
267
|
+
}
|
|
268
|
+
else if (this.lyricsMode) {
|
|
269
|
+
transcriptTitle = this.tt.lyricsTitle;
|
|
270
|
+
}
|
|
271
|
+
else {
|
|
272
|
+
transcriptTitle = this.tt.transcriptTitle;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
if (typeof this.transcriptDivLocation === 'undefined') {
|
|
276
|
+
// only add an HTML heading to internal transcript
|
|
277
|
+
// external transcript is expected to have its own heading
|
|
278
|
+
var headingNumber = this.playerHeadingLevel;
|
|
279
|
+
headingNumber += 1;
|
|
280
|
+
var chapterHeadingNumber = headingNumber + 1;
|
|
281
|
+
|
|
282
|
+
if (headingNumber <= 6) {
|
|
283
|
+
var transcriptHeading = 'h' + headingNumber.toString();
|
|
284
|
+
}
|
|
285
|
+
else {
|
|
286
|
+
var transcriptHeading = 'div';
|
|
287
|
+
}
|
|
288
|
+
// var transcriptHeadingTag = '<' + transcriptHeading + ' class="able-transcript-heading">';
|
|
289
|
+
var $transcriptHeadingTag = $('<' + transcriptHeading + '>');
|
|
290
|
+
$transcriptHeadingTag.addClass('able-transcript-heading');
|
|
291
|
+
if (headingNumber > 6) {
|
|
292
|
+
$transcriptHeadingTag.attr({
|
|
293
|
+
'role': 'heading',
|
|
294
|
+
'aria-level': headingNumber
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
$transcriptHeadingTag.text(transcriptTitle);
|
|
298
|
+
|
|
299
|
+
// set language of transcript heading to language of player
|
|
300
|
+
// this is independent of language of transcript
|
|
301
|
+
$transcriptHeadingTag.attr('lang', this.lang);
|
|
302
|
+
|
|
303
|
+
$main.append($transcriptHeadingTag);
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
var nextChapter = 0;
|
|
307
|
+
var nextCap = 0;
|
|
308
|
+
var nextDesc = 0;
|
|
309
|
+
|
|
310
|
+
var addChapter = function(div, chap) {
|
|
311
|
+
|
|
312
|
+
if (chapterHeadingNumber <= 6) {
|
|
313
|
+
var chapterHeading = 'h' + chapterHeadingNumber.toString();
|
|
314
|
+
}
|
|
315
|
+
else {
|
|
316
|
+
var chapterHeading = 'div';
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
var $chapterHeadingTag = $('<' + chapterHeading + '>',{
|
|
320
|
+
'class': 'able-transcript-chapter-heading'
|
|
321
|
+
});
|
|
322
|
+
if (chapterHeadingNumber > 6) {
|
|
323
|
+
$chapterHeadingTag.attr({
|
|
324
|
+
'role': 'heading',
|
|
325
|
+
'aria-level': chapterHeadingNumber
|
|
326
|
+
});
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
var flattenComponentForChapter = function(comp) {
|
|
330
|
+
|
|
331
|
+
var result = [];
|
|
332
|
+
if (comp.type === 'string') {
|
|
333
|
+
result.push(comp.value);
|
|
334
|
+
}
|
|
335
|
+
else {
|
|
336
|
+
for (var ii = 0; ii < comp.children.length; ii++) {
|
|
337
|
+
result = result.concat(flattenComponentForChapter(comp.children[ii]));
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
return result;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
var $chapSpan = $('<span>',{
|
|
344
|
+
'class': 'able-transcript-seekpoint'
|
|
345
|
+
});
|
|
346
|
+
for (var ii = 0; ii < chap.components.children.length; ii++) {
|
|
347
|
+
var results = flattenComponentForChapter(chap.components.children[ii]);
|
|
348
|
+
for (var jj = 0; jj < results.length; jj++) {
|
|
349
|
+
$chapSpan.append(results[jj]);
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
$chapSpan.attr('data-start', chap.start.toString());
|
|
353
|
+
$chapSpan.attr('data-end', chap.end.toString());
|
|
354
|
+
$chapterHeadingTag.append($chapSpan);
|
|
355
|
+
|
|
356
|
+
div.append($chapterHeadingTag);
|
|
357
|
+
};
|
|
358
|
+
|
|
359
|
+
var addDescription = function(div, desc) {
|
|
360
|
+
var $descDiv = $('<div>', {
|
|
361
|
+
'class': 'able-transcript-desc'
|
|
362
|
+
});
|
|
363
|
+
var $descHiddenSpan = $('<span>',{
|
|
364
|
+
'class': 'able-hidden'
|
|
365
|
+
});
|
|
366
|
+
$descHiddenSpan.attr('lang', thisObj.lang);
|
|
367
|
+
$descHiddenSpan.text(thisObj.tt.prefHeadingDescription + ': ');
|
|
368
|
+
$descDiv.append($descHiddenSpan);
|
|
369
|
+
|
|
370
|
+
var flattenComponentForDescription = function(comp) {
|
|
371
|
+
|
|
372
|
+
var result = [];
|
|
373
|
+
if (comp.type === 'string') {
|
|
374
|
+
result.push(comp.value);
|
|
375
|
+
}
|
|
376
|
+
else {
|
|
377
|
+
for (var ii = 0; ii < comp.children.length; ii++) {
|
|
378
|
+
result = result.concat(flattenComponentForDescription(comp.children[ii]));
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
return result;
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
var $descSpan = $('<span>',{
|
|
385
|
+
'class': 'able-transcript-seekpoint'
|
|
386
|
+
});
|
|
387
|
+
for (var ii = 0; ii < desc.components.children.length; ii++) {
|
|
388
|
+
var results = flattenComponentForDescription(desc.components.children[ii]);
|
|
389
|
+
for (var jj = 0; jj < results.length; jj++) {
|
|
390
|
+
$descSpan.append(results[jj]);
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
$descSpan.attr('data-start', desc.start.toString());
|
|
394
|
+
$descSpan.attr('data-end', desc.end.toString());
|
|
395
|
+
$descDiv.append($descSpan);
|
|
396
|
+
|
|
397
|
+
div.append($descDiv);
|
|
398
|
+
};
|
|
399
|
+
|
|
400
|
+
var addCaption = function(div, cap) {
|
|
401
|
+
|
|
402
|
+
var $capSpan = $('<span>',{
|
|
403
|
+
'class': 'able-transcript-seekpoint able-transcript-caption'
|
|
404
|
+
});
|
|
405
|
+
|
|
406
|
+
var flattenComponentForCaption = function(comp) {
|
|
407
|
+
|
|
408
|
+
var result = [];
|
|
409
|
+
|
|
410
|
+
var flattenString = function (str) {
|
|
411
|
+
var result = [];
|
|
412
|
+
if (str === '') {
|
|
413
|
+
return result;
|
|
414
|
+
}
|
|
415
|
+
var openBracket = str.indexOf('[');
|
|
416
|
+
var closeBracket = str.indexOf(']');
|
|
417
|
+
var openParen = str.indexOf('(');
|
|
418
|
+
var closeParen = str.indexOf(')');
|
|
419
|
+
|
|
420
|
+
var hasBrackets = openBracket !== -1 && closeBracket !== -1;
|
|
421
|
+
var hasParens = openParen !== -1 && closeParen !== -1;
|
|
422
|
+
|
|
423
|
+
if ((hasParens && hasBrackets && openBracket < openParen) || hasBrackets) {
|
|
424
|
+
result = result.concat(flattenString(str.substring(0, openBracket)));
|
|
425
|
+
var $silentSpan = $('<span>',{
|
|
426
|
+
'class': 'able-unspoken'
|
|
427
|
+
});
|
|
428
|
+
$silentSpan.text(str.substring(openBracket, closeBracket + 1));
|
|
429
|
+
result.push($silentSpan);
|
|
430
|
+
result = result.concat(flattenString(str.substring(openParen, closeParen + 1)));
|
|
431
|
+
}
|
|
432
|
+
else if (hasParens) {
|
|
433
|
+
result = result.concat(flattenString(str.substring(0, openParen)));
|
|
434
|
+
var $silentSpan = $('<span>',{
|
|
435
|
+
'class': 'able-unspoken'
|
|
436
|
+
});
|
|
437
|
+
$silentSpan.text(str.substring(openBracket, closeBracket + 1));
|
|
438
|
+
result.push($silentSpan);
|
|
439
|
+
result = result.concat(flattenString(str.substring(closeParen + 1)));
|
|
440
|
+
}
|
|
441
|
+
else {
|
|
442
|
+
result.push(str);
|
|
443
|
+
}
|
|
444
|
+
return result;
|
|
445
|
+
};
|
|
446
|
+
|
|
447
|
+
if (comp.type === 'string') {
|
|
448
|
+
result = result.concat(flattenString(comp.value));
|
|
449
|
+
}
|
|
450
|
+
else if (comp.type === 'v') {
|
|
451
|
+
var $vSpan = $('<span>',{
|
|
452
|
+
'class': 'able-unspoken'
|
|
453
|
+
});
|
|
454
|
+
$vSpan.text('(' + comp.value + ')');
|
|
455
|
+
result.push($vSpan);
|
|
456
|
+
for (var ii = 0; ii < comp.children.length; ii++) {
|
|
457
|
+
var subResults = flattenComponentForCaption(comp.children[ii]);
|
|
458
|
+
for (var jj = 0; jj < subResults.length; jj++) {
|
|
459
|
+
result.push(subResults[jj]);
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
else if (comp.type === 'b' || comp.type === 'i') {
|
|
464
|
+
if (comp.type === 'b') {
|
|
465
|
+
var $tag = $('<strong>');
|
|
466
|
+
}
|
|
467
|
+
else if (comp.type === 'i') {
|
|
468
|
+
var $tag = $('<em>');
|
|
469
|
+
}
|
|
470
|
+
for (var ii = 0; ii < comp.children.length; ii++) {
|
|
471
|
+
var subResults = flattenComponentForCaption(comp.children[ii]);
|
|
472
|
+
for (var jj = 0; jj < subResults.length; jj++) {
|
|
473
|
+
$tag.append(subResults[jj]);
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
if (comp.type === 'b' || comp.type == 'i') {
|
|
477
|
+
result.push($tag,' ');
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
else {
|
|
481
|
+
for (var ii = 0; ii < comp.children.length; ii++) {
|
|
482
|
+
result = result.concat(flattenComponentForCaption(comp.children[ii]));
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
return result;
|
|
486
|
+
};
|
|
487
|
+
|
|
488
|
+
for (var ii = 0; ii < cap.components.children.length; ii++) {
|
|
489
|
+
var results = flattenComponentForCaption(cap.components.children[ii]);
|
|
490
|
+
for (var jj = 0; jj < results.length; jj++) {
|
|
491
|
+
var result = results[jj];
|
|
492
|
+
if (typeof result === 'string') {
|
|
493
|
+
if (thisObj.lyricsMode) {
|
|
494
|
+
// add <br> BETWEEN each caption and WITHIN each caption (if payload includes "\n")
|
|
495
|
+
result = result.replace('\n','<br>') + '<br>';
|
|
496
|
+
}
|
|
497
|
+
else {
|
|
498
|
+
// just add a space between captions
|
|
499
|
+
result += ' ';
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
$capSpan.append(result);
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
$capSpan.attr('data-start', cap.start.toString());
|
|
506
|
+
$capSpan.attr('data-end', cap.end.toString());
|
|
507
|
+
div.append($capSpan);
|
|
508
|
+
div.append(' \n');
|
|
509
|
+
};
|
|
510
|
+
|
|
511
|
+
// keep looping as long as any one of the three arrays has content
|
|
512
|
+
while ((nextChapter < chapters.length) || (nextDesc < descriptions.length) || (nextCap < captions.length)) {
|
|
513
|
+
|
|
514
|
+
if ((nextChapter < chapters.length) && (nextDesc < descriptions.length) && (nextCap < captions.length)) {
|
|
515
|
+
// they all three have content
|
|
516
|
+
var firstStart = Math.min(chapters[nextChapter].start,descriptions[nextDesc].start,captions[nextCap].start);
|
|
517
|
+
}
|
|
518
|
+
else if ((nextChapter < chapters.length) && (nextDesc < descriptions.length)) {
|
|
519
|
+
// chapters & descriptions have content
|
|
520
|
+
var firstStart = Math.min(chapters[nextChapter].start,descriptions[nextDesc].start);
|
|
521
|
+
}
|
|
522
|
+
else if ((nextChapter < chapters.length) && (nextCap < captions.length)) {
|
|
523
|
+
// chapters & captions have content
|
|
524
|
+
var firstStart = Math.min(chapters[nextChapter].start,captions[nextCap].start);
|
|
525
|
+
}
|
|
526
|
+
else if ((nextDesc < descriptions.length) && (nextCap < captions.length)) {
|
|
527
|
+
// descriptions & captions have content
|
|
528
|
+
var firstStart = Math.min(descriptions[nextDesc].start,captions[nextCap].start);
|
|
529
|
+
}
|
|
530
|
+
else {
|
|
531
|
+
var firstStart = null;
|
|
532
|
+
}
|
|
533
|
+
if (firstStart !== null) {
|
|
534
|
+
if (typeof chapters[nextChapter] !== 'undefined' && chapters[nextChapter].start === firstStart) {
|
|
535
|
+
addChapter($main, chapters[nextChapter]);
|
|
536
|
+
nextChapter += 1;
|
|
537
|
+
}
|
|
538
|
+
else if (typeof descriptions[nextDesc] !== 'undefined' && descriptions[nextDesc].start === firstStart) {
|
|
539
|
+
addDescription($main, descriptions[nextDesc]);
|
|
540
|
+
nextDesc += 1;
|
|
541
|
+
}
|
|
542
|
+
else {
|
|
543
|
+
addCaption($main, captions[nextCap]);
|
|
544
|
+
nextCap += 1;
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
else {
|
|
548
|
+
if (nextChapter < chapters.length) {
|
|
549
|
+
addChapter($main, chapters[nextChapter]);
|
|
550
|
+
nextChapter += 1;
|
|
551
|
+
}
|
|
552
|
+
else if (nextDesc < descriptions.length) {
|
|
553
|
+
addDescription($main, descriptions[nextDesc]);
|
|
554
|
+
nextDesc += 1;
|
|
555
|
+
}
|
|
556
|
+
else if (nextCap < captions.length) {
|
|
557
|
+
addCaption($main, captions[nextCap]);
|
|
558
|
+
nextCap += 1;
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
// organize transcript into blocks using [] and () as starting points
|
|
563
|
+
var $components = $main.children();
|
|
564
|
+
var spanCount = 0;
|
|
565
|
+
var openBlock = true;
|
|
566
|
+
$components.each(function() {
|
|
567
|
+
if ($(this).hasClass('able-transcript-caption')) {
|
|
568
|
+
if ($(this).text().indexOf('[') !== -1 || $(this).text().indexOf('(') !== -1) {
|
|
569
|
+
// this caption includes a bracket or parenth. Start a new block
|
|
570
|
+
// close the previous block first
|
|
571
|
+
if (spanCount > 0) {
|
|
572
|
+
$main.find('.able-block-temp').removeClass('able-block-temp').wrapAll('<div class="able-transcript-block"></div>');
|
|
573
|
+
spanCount = 0;
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
$(this).addClass('able-block-temp');
|
|
577
|
+
spanCount++;
|
|
578
|
+
}
|
|
579
|
+
else {
|
|
580
|
+
// this is not a caption. Close the caption block
|
|
581
|
+
if (spanCount > 0) {
|
|
582
|
+
$main.find('.able-block-temp').removeClass('able-block-temp').wrapAll('<div class="able-transcript-block"></div>');
|
|
583
|
+
spanCount = 0;
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
});
|
|
587
|
+
return $main;
|
|
588
|
+
};
|
|
589
|
+
|
|
590
|
+
})(jQuery);
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
(function ($) {
|
|
2
|
+
AblePlayer.prototype.getSupportedLangs = function() {
|
|
3
|
+
// returns an array of languages for which AblePlayer has translation tables
|
|
4
|
+
// Removing 'nl' as of 2.3.54, pending updates
|
|
5
|
+
var langs = ['ca','de','en','es','fr','it','ja'];
|
|
6
|
+
return langs;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
AblePlayer.prototype.getTranslationText = function() {
|
|
10
|
+
// determine language, then get labels and prompts from corresponding translation var
|
|
11
|
+
var deferred, thisObj, lang, thisObj, msg, translationFile;
|
|
12
|
+
|
|
13
|
+
deferred = $.Deferred();
|
|
14
|
+
|
|
15
|
+
thisObj = this;
|
|
16
|
+
|
|
17
|
+
// override this.lang to language of the web page, if known and supported
|
|
18
|
+
// otherwise this.lang will continue using default
|
|
19
|
+
if (!this.forceLang) {
|
|
20
|
+
if ($('body').attr('lang')) {
|
|
21
|
+
lang = $('body').attr('lang');
|
|
22
|
+
}
|
|
23
|
+
else if ($('html').attr('lang')) {
|
|
24
|
+
lang = $('html').attr('lang');
|
|
25
|
+
}
|
|
26
|
+
if (lang !== this.lang) {
|
|
27
|
+
msg = 'Language of web page (' + lang +') ';
|
|
28
|
+
if ($.inArray(lang,this.getSupportedLangs()) !== -1) {
|
|
29
|
+
// this is a supported lang
|
|
30
|
+
msg += ' has a translation table available.';
|
|
31
|
+
this.lang = lang;
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
msg += ' is not currently supported. Using default language (' + this.lang + ')';
|
|
35
|
+
}
|
|
36
|
+
if (this.debug) {
|
|
37
|
+
console.log(msg);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
translationFile = this.rootPath + 'translations/' + this.lang + '.js';
|
|
42
|
+
this.importTranslationFile(translationFile).then(function(result) {
|
|
43
|
+
thisObj.tt = eval(thisObj.lang);
|
|
44
|
+
deferred.resolve();
|
|
45
|
+
});
|
|
46
|
+
return deferred.promise();
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
AblePlayer.prototype.importTranslationFile = function(translationFile) {
|
|
50
|
+
|
|
51
|
+
var deferred = $.Deferred();
|
|
52
|
+
|
|
53
|
+
$.getScript(translationFile)
|
|
54
|
+
.done(function(translationVar,textStatus) {
|
|
55
|
+
// translation file successfully retrieved
|
|
56
|
+
deferred.resolve(translationVar);
|
|
57
|
+
})
|
|
58
|
+
.fail(function(jqxhr, settings, exception) {
|
|
59
|
+
deferred.fail();
|
|
60
|
+
// error retrieving file
|
|
61
|
+
// TODO: handle this
|
|
62
|
+
});
|
|
63
|
+
return deferred.promise();
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
})(jQuery);
|