-
Notifications
You must be signed in to change notification settings - Fork 238
Expand file tree
/
Copy pathsign.js
More file actions
112 lines (98 loc) · 3.08 KB
/
sign.js
File metadata and controls
112 lines (98 loc) · 3.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
(function ($) {
AblePlayer.prototype.initSignLanguage = function() {
// Sign language is only currently supported in HTML5 player and YouTube.
if ( ! this.isIOS() && this.$media.data('sign-src') !== undefined && this.$media.data('sign-src') !== "" ) {
this.hasSignLanguage = true;
this.injectSignPlayerCode();
return;
}
if (this.player === 'html5') {
// check to see if there's a sign language video accompanying this video
// check only the first source
// If sign language is provided, it must be provided for all sources
this.signFile = this.$sources.first().attr('data-sign-src');
if (this.signFile) {
if (this.isIOS()) {
// iOS does not allow multiple videos to play simultaneously
// Therefore, sign language as rendered by Able Player unfortunately won't work
this.hasSignLanguage = false;
if (this.debug) {
console.log('Sign language has been disabled due to iOS restrictions');
}
}
else {
if (this.debug) {
console.log('This video has an accompanying sign language video: ' + this.signFile);
}
this.hasSignLanguage = true;
this.injectSignPlayerCode();
}
}
else {
this.hasSignLanguage = false;
}
}
else {
this.hasSignLanguage = false;
}
};
AblePlayer.prototype.injectSignPlayerCode = function() {
// create and inject surrounding HTML structure
var thisObj, signVideoId, signVideoWidth, i, signSrc, srcType, $signSource;
thisObj = this;
signVideoWidth = this.getDefaultWidth('sign');
signVideoId = this.mediaId + '-sign';
this.$signVideo = $('<video>',{
'id' : signVideoId,
'tabindex' : '-1',
'muted' : true,
});
this.signVideo = this.$signVideo[0];
if(this.$media.data('sign-src')) {
$signSource = $('<source>',{
'src' : this.$media.data('sign-src'),
'type' : 'video/' + this.$media.data('sign-src').substr(-3)
});
this.$signVideo.append($signSource);
}
else {
// for each original <source>, add a <source> to the sign <video>
for (i=0; i < this.$sources.length; i++) {
signSrc = DOMPurify.sanitize( this.$sources[i].getAttribute('data-sign-src') );
srcType = this.$sources[i].getAttribute('type');
if (signSrc) {
$signSource = $('<source>',{
'src' : signSrc,
'type' : srcType
});
this.$signVideo.append($signSource);
}
else {
// source is missing a sign language version
// can't include sign language
this.hasSignLanguage = false;
return;
}
}
}
this.$signWindow = $('<div>',{
'class' : 'able-sign-window',
'role': 'dialog',
'aria-label': this.tt.sign
});
this.$signToolbar = $('<div>',{
'class': 'able-window-toolbar able-' + this.toolbarIconColor + '-controls'
});
this.$signWindow.append(this.$signToolbar, this.$signVideo);
this.$ableWrapper.append(this.$signWindow);
// make it draggable
this.initDragDrop('sign');
if (this.prefSign === 1) {
// sign window is on. Go ahead and position it and show it
this.positionDraggableWindow('sign',this.getDefaultWidth('sign'));
}
else {
this.$signWindow.hide();
}
};
})(jQuery);