@viewlift/player-backup 1.0.2-lighteningjs → 1.0.2
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.
- package/cjs/autoNextVideo-815419cb.js +1 -0
- package/cjs/bundle.css +577 -0
- package/cjs/caption-settings-67212c17.js +1 -0
- package/cjs/caption-settings-6e301004.js +1 -0
- package/cjs/dvr_skin-f7f770ae.js +1 -0
- package/cjs/error-26d5a3c3.js +1 -0
- package/cjs/features-fd1e9785.js +1 -0
- package/cjs/generic-81b1be69.js +1 -0
- package/cjs/icons-51594f89.js +1 -0
- package/cjs/index.js +1 -0
- package/cjs/keyboardShortcuts-1afbf18c.js +1 -0
- package/cjs/loader-393b838a.js +1 -0
- package/cjs/multicam-1647c428.js +1 -0
- package/cjs/multicam-a41fe4a6.js +1 -0
- package/cjs/multicamv2-76d8530b.js +1 -0
- package/cjs/multicamv2-f48d95fe.js +1 -0
- package/cjs/mwebPotrait-3c11d7cf.js +1 -0
- package/cjs/mwebPotraitTray-a3a2715b.js +1 -0
- package/cjs/nextEpisodeButton-b6e6586f.js +1 -0
- package/cjs/nextEpisodeButton-cc80609a.js +1 -0
- package/cjs/nondvr_skin-ef2cb3b2.js +1 -0
- package/cjs/playlist-a550a735.js +1 -0
- package/cjs/playlist-df87ca90.js +1 -0
- package/cjs/renditions-c3ea26e8.js +1 -0
- package/cjs/resolution-51b38a3e.js +1 -0
- package/cjs/series-6178964e.js +1 -0
- package/cjs/series-9c237975.js +1 -0
- package/cjs/series-v2-70137d8c.js +1 -0
- package/cjs/series-v2-a265ff17.js +1 -0
- package/cjs/settings-icon-b350b587.js +1 -0
- package/cjs/settings-icon-e6a8feee.js +1 -0
- package/cjs/skin-14da56f6.js +1 -0
- package/cjs/skin-225252ff.js +1 -0
- package/cjs/skin-286f52db.js +1 -0
- package/cjs/skin-534810ae.js +1 -0
- package/cjs/skin-638aecc2.js +1 -0
- package/cjs/skin-84083352.js +1 -0
- package/cjs/skin-983a2ea7.js +1 -0
- package/cjs/skin-9eba464b.js +1 -0
- package/cjs/skin-b703ef26.js +1 -0
- package/cjs/skin-f225a42e.js +1 -0
- package/cjs/util-ce8a4138.js +1 -0
- package/cjs/videoSelector-a4c00f50.js +1 -0
- package/cjs/videoSelector-fcdf11eb.js +1 -0
- package/esm/autoNextVideo-89ede579.js +1 -0
- package/esm/bundle.css +577 -0
- package/esm/caption-settings-2e47813b.js +1 -0
- package/esm/caption-settings-3f6b6163.js +1 -0
- package/esm/dvr_skin-9cc1b144.js +1 -0
- package/esm/error-2395864b.js +1 -0
- package/esm/features-05101ce6.js +1 -0
- package/esm/generic-4a3c0d6b.js +1 -0
- package/esm/icons-f5378bf3.js +1 -0
- package/esm/index.js +1 -0
- package/esm/keyboardShortcuts-7fa108ec.js +1 -0
- package/esm/loader-580278fe.js +1 -0
- package/esm/multicam-bc0aea8a.js +1 -0
- package/esm/multicam-de741974.js +1 -0
- package/esm/multicamv2-d006cffa.js +1 -0
- package/esm/multicamv2-fb91fa98.js +1 -0
- package/esm/mwebPotrait-3c1805d8.js +1 -0
- package/esm/mwebPotraitTray-0ff12233.js +1 -0
- package/esm/nextEpisodeButton-a1556cdf.js +1 -0
- package/esm/nextEpisodeButton-ec95417f.js +1 -0
- package/esm/nondvr_skin-64be70e5.js +1 -0
- package/esm/playlist-5d3f4436.js +1 -0
- package/esm/playlist-7ecf432a.js +1 -0
- package/esm/renditions-0fdb57ed.js +1 -0
- package/esm/resolution-57e7767a.js +1 -0
- package/esm/series-041152aa.js +1 -0
- package/esm/series-998e2084.js +1 -0
- package/esm/series-v2-0727ee8c.js +1 -0
- package/esm/series-v2-9bcd5d54.js +1 -0
- package/esm/settings-icon-0125bffd.js +1 -0
- package/esm/settings-icon-9bac9ef3.js +1 -0
- package/esm/skin-0aea7a56.js +1 -0
- package/esm/skin-2c638dc1.js +1 -0
- package/esm/skin-5a02ebe6.js +1 -0
- package/esm/skin-665ec17e.js +1 -0
- package/esm/skin-80957fd8.js +1 -0
- package/esm/skin-851ea2fb.js +1 -0
- package/esm/skin-bb73c15b.js +1 -0
- package/esm/skin-cd537931.js +1 -0
- package/esm/skin-d5510f70.js +1 -0
- package/esm/skin-fba79111.js +1 -0
- package/esm/util-9c9ee6b3.js +1 -0
- package/esm/videoSelector-8da87dd3.js +1 -0
- package/esm/videoSelector-8e258d45.js +1 -0
- package/package.json +15 -32
- package/.babelrc +0 -8
- package/.browserslistrc +0 -2
- package/README.md +0 -29
- package/babel.config.json +0 -8
- package/dist/38afc79c94e0bcf0.png +0 -0
- package/dist/3bc8b7ff04e98d37.png +0 -0
- package/dist/522ea7c76ac4fd33.png +0 -0
- package/dist/a74cd46ed4277568.png +0 -0
- package/dist/b739faec1fde1346.png +0 -0
- package/dist/ed3d0a4d9de91460.png +0 -0
- package/dist/index.cjs.css +0 -2
- package/dist/index.cjs.css.map +0 -1
- package/dist/index.cjs.js +0 -2
- package/dist/index.d.ts +0 -45
- package/dist/index.esm.css +0 -2
- package/dist/index.esm.css.map +0 -1
- package/dist/index.esm.js +0 -2
- package/dist/main-player/player-ui.d.ts +0 -19
- package/dist/player-components/player-buttons/playerButtons.d.ts +0 -38
- package/dist/player-components/player-seekbar/playerSeekbar.d.ts +0 -25
- package/dist/player-ui/player-ui.d.ts +0 -18
- package/dist/playerInitializer.d.ts +0 -13
- package/index.html +0 -49
- package/rollup.config.mjs +0 -45
- package/src/ads-manager/ads-manager.js +0 -120
- package/src/assets/checkIcon.png +0 -0
- package/src/assets/pauseIcon.png +0 -0
- package/src/assets/pauseIconFocus.png +0 -0
- package/src/assets/playIcon.png +0 -0
- package/src/assets/playIconFocus.png +0 -0
- package/src/assets/settingsIcon.png +0 -0
- package/src/index.ts +0 -242
- package/src/player-components/player-buttons/playerButtons.js +0 -104
- package/src/player-components/player-seekbar/playerSeekbar.js +0 -223
- package/src/player-components/player-setting-option-wrapper/player-setting-option-one-wrapper.js +0 -82
- package/src/player-components/player-setting-option-wrapper/player-setting-option-two-wrapper.js +0 -84
- package/src/player-components/player-sidebar/player-sidebar.js +0 -188
- package/src/player-components/player-title/playerTitle.js +0 -55
- package/src/player-ui/player-ui.js +0 -514
- package/src/playerInitializer.js +0 -335
- package/src/styles/index.css +0 -200
- package/src/utilities/utilities.js +0 -79
- package/tsconfig.json +0 -14
|
@@ -1,223 +0,0 @@
|
|
|
1
|
-
export class PlayerSeekbar {
|
|
2
|
-
constructor(video) {
|
|
3
|
-
if (!video || !(video instanceof HTMLVideoElement)) {
|
|
4
|
-
throw new Error('PlayerSeekbar: A valid HTMLVideoElement is required');
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
this.video = video;
|
|
8
|
-
this.container = null;
|
|
9
|
-
this.progress = null;
|
|
10
|
-
this.buffer = null;
|
|
11
|
-
this.thumb = null;
|
|
12
|
-
this.tooltip = null;
|
|
13
|
-
this.timeLabel = null;
|
|
14
|
-
this.durationLabel = null;
|
|
15
|
-
this.isDragging = false;
|
|
16
|
-
this.focused = false;
|
|
17
|
-
|
|
18
|
-
this.init();
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
init() {
|
|
22
|
-
this.container = document.createElement('div');
|
|
23
|
-
this.container.className = 'seekbar-container';
|
|
24
|
-
|
|
25
|
-
this.buffer = document.createElement('div');
|
|
26
|
-
this.buffer.className = 'seekbar-buffer';
|
|
27
|
-
|
|
28
|
-
this.progress = document.createElement('div');
|
|
29
|
-
this.progress.className = 'seekbar-progress';
|
|
30
|
-
|
|
31
|
-
this.thumb = document.createElement('div');
|
|
32
|
-
this.thumb.className = 'seekbar-thumb';
|
|
33
|
-
this.thumb.tabIndex = 0; // Make thumb focusable
|
|
34
|
-
|
|
35
|
-
this.tooltip = document.createElement('div');
|
|
36
|
-
this.tooltip.className = 'seekbar-tooltip';
|
|
37
|
-
this.tooltip.style.display = 'none';
|
|
38
|
-
|
|
39
|
-
this.timeLabel = document.createElement('span');
|
|
40
|
-
this.timeLabel.className = 'seekbar-time-label';
|
|
41
|
-
this.durationLabel = document.createElement('span');
|
|
42
|
-
this.durationLabel.className = 'seekbar-duration-label';
|
|
43
|
-
|
|
44
|
-
this.container.appendChild(this.buffer);
|
|
45
|
-
this.container.appendChild(this.progress);
|
|
46
|
-
this.container.appendChild(this.thumb);
|
|
47
|
-
this.container.appendChild(this.tooltip);
|
|
48
|
-
this.container.appendChild(this.timeLabel);
|
|
49
|
-
this.container.appendChild(this.durationLabel);
|
|
50
|
-
|
|
51
|
-
// Update UI as video plays
|
|
52
|
-
this.video.addEventListener('timeupdate', () => this.update());
|
|
53
|
-
this.video.addEventListener('progress', () => this.updateBuffer());
|
|
54
|
-
this.video.addEventListener('durationchange', () => this.update());
|
|
55
|
-
|
|
56
|
-
// Seek on click
|
|
57
|
-
this.container.addEventListener('click', (e) => this.seek(e));
|
|
58
|
-
// Dragging
|
|
59
|
-
this.thumb.addEventListener('mousedown', (e) => this.startDrag(e));
|
|
60
|
-
// Tooltip on hover
|
|
61
|
-
this.container.addEventListener('mousemove', (e) => this.showTooltip(e));
|
|
62
|
-
this.container.addEventListener('mouseleave', () => this.hideTooltip());
|
|
63
|
-
|
|
64
|
-
// Focus/blur events for accessibility and visual feedback
|
|
65
|
-
this.thumb.addEventListener('focus', () => {
|
|
66
|
-
this.focused = true;
|
|
67
|
-
this.thumb.classList.add('focused');
|
|
68
|
-
});
|
|
69
|
-
this.thumb.addEventListener('blur', () => {
|
|
70
|
-
this.focused = false;
|
|
71
|
-
this.thumb.classList.remove('focused');
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
// Add keydown event listeners for arrow keys to simulate dragging
|
|
75
|
-
this.thumb.addEventListener('keydown', (e) => {
|
|
76
|
-
const increment = 1;
|
|
77
|
-
if (e.key === 'ArrowRight') {
|
|
78
|
-
e.preventDefault();
|
|
79
|
-
e.stopPropagation();
|
|
80
|
-
this.video.currentTime = Math.min(this.video.duration, this.video.currentTime + increment);
|
|
81
|
-
this.update();
|
|
82
|
-
} else if (e.key === 'ArrowLeft') {
|
|
83
|
-
e.preventDefault();
|
|
84
|
-
e.stopPropagation();
|
|
85
|
-
this.video.currentTime = Math.max(0, this.video.currentTime - increment);
|
|
86
|
-
this.update();
|
|
87
|
-
} else if (e.key === 'Enter') {
|
|
88
|
-
e.preventDefault();
|
|
89
|
-
e.stopPropagation();
|
|
90
|
-
if(this.video.paused) {
|
|
91
|
-
this.video.play(); // Resume playing the video
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
focus() {
|
|
98
|
-
if (this.thumb) {
|
|
99
|
-
this.thumb.focus();
|
|
100
|
-
this.thumb.classList.add('focused');
|
|
101
|
-
this.focused = true;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
blur() {
|
|
106
|
-
if (this.thumb) {
|
|
107
|
-
this.thumb.blur();
|
|
108
|
-
this.thumb.classList.remove('focused');
|
|
109
|
-
this.focused = false;
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
formatTime(seconds) {
|
|
114
|
-
if (isNaN(seconds)) return '0:00';
|
|
115
|
-
const m = Math.floor(seconds / 60);
|
|
116
|
-
const s = Math.floor(seconds % 60);
|
|
117
|
-
return `${m}:${String(s).padStart(2, '0')}`;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
update() {
|
|
121
|
-
if (!this.video || !this.progress || !this.thumb || !this.timeLabel || !this.durationLabel) return;
|
|
122
|
-
|
|
123
|
-
const percent = (this.video.currentTime / this.video.duration) * 100;
|
|
124
|
-
this.progress.style.width = percent + '%';
|
|
125
|
-
this.thumb.style.left = percent + '%';
|
|
126
|
-
this.timeLabel.textContent = this.formatTime(this.video.currentTime);
|
|
127
|
-
this.durationLabel.textContent = ' / ' + this.formatTime(this.video.duration);
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
updateBuffer() {
|
|
131
|
-
if (!this.video || !this.buffer) return;
|
|
132
|
-
|
|
133
|
-
if (this.video.buffered.length) {
|
|
134
|
-
const end = this.video.buffered.end(this.video.buffered.length - 1);
|
|
135
|
-
const percent = (end / this.video.duration) * 100;
|
|
136
|
-
this.buffer.style.width = percent + '%';
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
seek(e) {
|
|
141
|
-
if (this.isDragging || !this.container || !this.video) return;
|
|
142
|
-
|
|
143
|
-
const rect = this.container.getBoundingClientRect();
|
|
144
|
-
const percent = (e.clientX - rect.left) / rect.width;
|
|
145
|
-
this.video.currentTime = percent * this.video.duration;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
startDrag(e) {
|
|
149
|
-
if (!this.container || !this.video) return;
|
|
150
|
-
|
|
151
|
-
e.preventDefault();
|
|
152
|
-
this.isDragging = true;
|
|
153
|
-
const onMove = (moveEvent) => {
|
|
154
|
-
const rect = this.container.getBoundingClientRect();
|
|
155
|
-
let percent = (moveEvent.clientX - rect.left) / rect.width;
|
|
156
|
-
percent = Math.max(0, Math.min(1, percent));
|
|
157
|
-
this.progress.style.width = percent * 100 + '%';
|
|
158
|
-
this.thumb.style.left = percent * 100 + '%';
|
|
159
|
-
this.timeLabel.textContent = this.formatTime(percent * this.video.duration);
|
|
160
|
-
};
|
|
161
|
-
const onUp = (upEvent) => {
|
|
162
|
-
const rect = this.container.getBoundingClientRect();
|
|
163
|
-
let percent = (upEvent.clientX - rect.left) / rect.width;
|
|
164
|
-
percent = Math.max(0, Math.min(1, percent));
|
|
165
|
-
this.video.currentTime = percent * this.video.duration;
|
|
166
|
-
this.isDragging = false;
|
|
167
|
-
document.removeEventListener('mousemove', onMove);
|
|
168
|
-
document.removeEventListener('mouseup', onUp);
|
|
169
|
-
};
|
|
170
|
-
document.addEventListener('mousemove', onMove);
|
|
171
|
-
document.addEventListener('mouseup', onUp);
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
showTooltip(e) {
|
|
175
|
-
if (!this.container || !this.tooltip || !this.video) return;
|
|
176
|
-
|
|
177
|
-
const rect = this.container.getBoundingClientRect();
|
|
178
|
-
const percent = (e.clientX - rect.left) / rect.width;
|
|
179
|
-
const time = percent * this.video.duration;
|
|
180
|
-
this.tooltip.textContent = this.formatTime(time);
|
|
181
|
-
this.tooltip.style.display = 'block';
|
|
182
|
-
this.tooltip.style.left = `${percent * 100}%`;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
hideTooltip() {
|
|
186
|
-
if (this.tooltip) {
|
|
187
|
-
this.tooltip.style.display = 'none';
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
getElement() {
|
|
192
|
-
return this.thumb;
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
mount(parent) {
|
|
196
|
-
if (!parent || !(parent instanceof HTMLElement)) {
|
|
197
|
-
throw new Error('PlayerSeekbar: parent must be a valid DOM element');
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
parent.appendChild(this.container);
|
|
201
|
-
this.update();
|
|
202
|
-
this.updateBuffer();
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
unmount() {
|
|
206
|
-
if (!this.video || !this.container || !this.thumb) return;
|
|
207
|
-
|
|
208
|
-
this.video.removeEventListener('timeupdate', this.update);
|
|
209
|
-
this.video.removeEventListener('progress', this.updateBuffer);
|
|
210
|
-
this.video.removeEventListener('durationchange', this.update);
|
|
211
|
-
this.container.removeEventListener('click', this.seek);
|
|
212
|
-
this.thumb.removeEventListener('mousedown', this.startDrag);
|
|
213
|
-
this.container.removeEventListener('mousemove', this.showTooltip);
|
|
214
|
-
this.container.removeEventListener('mouseleave', this.hideTooltip);
|
|
215
|
-
this.thumb.removeEventListener('focus', this.focus);
|
|
216
|
-
this.thumb.removeEventListener('blur', this.blur);
|
|
217
|
-
this.thumb.removeEventListener('keydown', this.keydownHandler);
|
|
218
|
-
|
|
219
|
-
if (this.container) {
|
|
220
|
-
this.container.remove();
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
}
|
package/src/player-components/player-setting-option-wrapper/player-setting-option-one-wrapper.js
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
export class SettingsOptionOneWrapper {
|
|
2
|
-
constructor(props) {
|
|
3
|
-
if (!props || typeof props !== 'object') {
|
|
4
|
-
throw new Error('SettingsOptionOneWrapper: props must be a valid object');
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
this.title = props.title || 'Option';
|
|
8
|
-
this.klassname = props.klassname || 'default-option-wrapper';
|
|
9
|
-
this.handleClick = props.callback || (() => {});
|
|
10
|
-
this.focused = props.focused || false;
|
|
11
|
-
|
|
12
|
-
if (typeof this.handleClick !== 'function') {
|
|
13
|
-
throw new Error('SettingsOptionOneWrapper: callback must be a function');
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
this.handleClick = this.handleClick.bind(this);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
mount(mountPoint) {
|
|
20
|
-
if (!mountPoint || !(mountPoint instanceof HTMLElement)) {
|
|
21
|
-
throw new Error('SettingsOptionOneWrapper: mountPoint must be a valid DOM element');
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const optionWrapper = document.createElement('div');
|
|
25
|
-
optionWrapper.className = this.klassname;
|
|
26
|
-
optionWrapper.tabIndex = 0;
|
|
27
|
-
|
|
28
|
-
const titleElement = document.createElement('p');
|
|
29
|
-
titleElement.textContent = this.title;
|
|
30
|
-
optionWrapper.appendChild(titleElement);
|
|
31
|
-
|
|
32
|
-
const arrowElement = document.createElement('p');
|
|
33
|
-
arrowElement.textContent = "›";
|
|
34
|
-
optionWrapper.appendChild(arrowElement);
|
|
35
|
-
|
|
36
|
-
if (this.focused) {
|
|
37
|
-
optionWrapper.classList.add('focused');
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
optionWrapper.addEventListener('focus', () => {
|
|
41
|
-
this.focused = true;
|
|
42
|
-
optionWrapper.classList.add('focused');
|
|
43
|
-
});
|
|
44
|
-
optionWrapper.addEventListener('blur', () => {
|
|
45
|
-
this.focused = false;
|
|
46
|
-
optionWrapper.classList.remove('focused');
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
optionWrapper.addEventListener('keydown', (event) => {
|
|
50
|
-
if (event.key === 'Enter' || event.key === 'OK') {
|
|
51
|
-
this.handleClick();
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
this.optionWrapper = optionWrapper;
|
|
56
|
-
optionWrapper.instance = this; // Set the instance property
|
|
57
|
-
mountPoint.appendChild(optionWrapper);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
unmount() {
|
|
61
|
-
if (this.optionWrapper) {
|
|
62
|
-
this.optionWrapper.remove();
|
|
63
|
-
this.optionWrapper = undefined;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
focus() {
|
|
68
|
-
if (this.optionWrapper) {
|
|
69
|
-
this.optionWrapper.focus();
|
|
70
|
-
this.optionWrapper.classList.add('focused');
|
|
71
|
-
this.focused = true;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
blur() {
|
|
76
|
-
if (this.optionWrapper) {
|
|
77
|
-
this.optionWrapper.blur();
|
|
78
|
-
this.optionWrapper.classList.remove('focused');
|
|
79
|
-
this.focused = false;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
}
|
package/src/player-components/player-setting-option-wrapper/player-setting-option-two-wrapper.js
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import checkIcon from '../../assets/checkIcon.png';
|
|
2
|
-
|
|
3
|
-
export class SettingsOptionTwoWrapper {
|
|
4
|
-
constructor(props) {
|
|
5
|
-
if (!props || typeof props !== 'object') {
|
|
6
|
-
throw new Error('SettingsOptionTwoWrapper: props must be a valid object');
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
this.title = props.title || 'Option';
|
|
10
|
-
this.klassname = props.klassname || 'default-option-wrapper';
|
|
11
|
-
this.selected = props.selected || false;
|
|
12
|
-
this.focused = props.focused || false;
|
|
13
|
-
this.imgSrc = props.imgSrc || checkIcon;
|
|
14
|
-
this.id = props.id;
|
|
15
|
-
|
|
16
|
-
if (typeof this.title !== 'string') {
|
|
17
|
-
throw new Error('SettingsOptionTwoWrapper: title must be a string');
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
mount(mountPoint) {
|
|
22
|
-
if (!mountPoint || !(mountPoint instanceof HTMLElement)) {
|
|
23
|
-
throw new Error('SettingsOptionTwoWrapper: mountPoint must be a valid DOM element');
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const optionWrapper = document.createElement('div');
|
|
27
|
-
optionWrapper.className = this.klassname;
|
|
28
|
-
optionWrapper.tabIndex = 0;
|
|
29
|
-
|
|
30
|
-
const titleElement = document.createElement('p');
|
|
31
|
-
titleElement.textContent = this.title;
|
|
32
|
-
optionWrapper.appendChild(titleElement);
|
|
33
|
-
|
|
34
|
-
if (this.selected) {
|
|
35
|
-
optionWrapper.classList.add('selected');
|
|
36
|
-
const selectedElement = document.createElement('span');
|
|
37
|
-
const img = document.createElement('img');
|
|
38
|
-
img.src = this.imgSrc;
|
|
39
|
-
img.alt = this.imgAltText || 'Selected';
|
|
40
|
-
selectedElement.appendChild(img);
|
|
41
|
-
optionWrapper.appendChild(selectedElement);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
if (this.focused) {
|
|
45
|
-
optionWrapper.classList.add('focused');
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
optionWrapper.addEventListener('focus', () => {
|
|
49
|
-
this.focused = true;
|
|
50
|
-
optionWrapper.classList.add('focused');
|
|
51
|
-
});
|
|
52
|
-
optionWrapper.addEventListener('blur', () => {
|
|
53
|
-
this.focused = false;
|
|
54
|
-
optionWrapper.classList.remove('focused');
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
this.optionWrapper = optionWrapper;
|
|
58
|
-
optionWrapper.instance = this; // Set the instance property
|
|
59
|
-
mountPoint.appendChild(optionWrapper);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
unmount() {
|
|
63
|
-
if (this.optionWrapper) {
|
|
64
|
-
this.optionWrapper.remove();
|
|
65
|
-
this.optionWrapper = undefined;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
focus() {
|
|
70
|
-
if (this.optionWrapper) {
|
|
71
|
-
this.optionWrapper.focus();
|
|
72
|
-
this.optionWrapper.classList.add('focused');
|
|
73
|
-
this.focused = true;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
blur() {
|
|
78
|
-
if (this.optionWrapper) {
|
|
79
|
-
this.optionWrapper.blur();
|
|
80
|
-
this.optionWrapper.classList.remove('focused');
|
|
81
|
-
this.focused = false;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
}
|
|
@@ -1,188 +0,0 @@
|
|
|
1
|
-
import { SettingsOptionOneWrapper } from '../player-setting-option-wrapper/player-setting-option-one-wrapper.js';
|
|
2
|
-
import { SettingsOptionTwoWrapper } from '../player-setting-option-wrapper/player-setting-option-two-wrapper.js';
|
|
3
|
-
|
|
4
|
-
export class Sidebar {
|
|
5
|
-
constructor(props) {
|
|
6
|
-
if (!props || typeof props !== 'object') {
|
|
7
|
-
throw new Error('Sidebar: props must be a valid object');
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
this.title = props.title || 'Settings';
|
|
11
|
-
this.items = props.items || [
|
|
12
|
-
{text: 'Video Quality', isSelected: true, callback: () => {}},
|
|
13
|
-
{text: 'Audio Language', isSelected: false, callback: () => {}},
|
|
14
|
-
{text: 'Subtitles', isSelected: false, callback: () => {}}
|
|
15
|
-
];
|
|
16
|
-
this.klassname = props.klassname || 'default-sidebar';
|
|
17
|
-
this.currentFocusedOption = null;
|
|
18
|
-
this.lastFocusedElement = props.lastFocusedElement || null;
|
|
19
|
-
this.type = props.type || 'navigation';
|
|
20
|
-
this.focused = props.focused || false;
|
|
21
|
-
this.callback = props.callback || (() => {});
|
|
22
|
-
this.onselect = props.onselect || (() => {});
|
|
23
|
-
|
|
24
|
-
if (typeof this.callback !== 'function') {
|
|
25
|
-
throw new Error('Sidebar: callback must be a function');
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
if (!['navigation', 'selection'].includes(this.type)) {
|
|
29
|
-
throw new Error('Sidebar: type must be either "navigation" or "selection"');
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
mount(mountPoint) {
|
|
34
|
-
if (!mountPoint || !(mountPoint instanceof HTMLElement)) {
|
|
35
|
-
throw new Error('Sidebar: mountPoint must be a valid DOM element');
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
const sidebar = document.createElement('div');
|
|
39
|
-
sidebar.className = this.klassname;
|
|
40
|
-
|
|
41
|
-
const titleElement = document.createElement('h2');
|
|
42
|
-
titleElement.textContent = this.title;
|
|
43
|
-
titleElement.style.fontSize = '38px';
|
|
44
|
-
sidebar.appendChild(titleElement);
|
|
45
|
-
|
|
46
|
-
const list = document.createElement('div');
|
|
47
|
-
if (this.type === 'navigation') {
|
|
48
|
-
this.items.forEach((item, idx) => {
|
|
49
|
-
const listItem = new SettingsOptionOneWrapper({
|
|
50
|
-
title: item.text,
|
|
51
|
-
klassname: 'default-option-wrapper',
|
|
52
|
-
focused: idx === 0,
|
|
53
|
-
callback: item.callback
|
|
54
|
-
});
|
|
55
|
-
item.instance = listItem; // Store the listItem instance in the item
|
|
56
|
-
if (idx === 0) {
|
|
57
|
-
this.currentFocusedOption = listItem;
|
|
58
|
-
}
|
|
59
|
-
listItem.mount(list);
|
|
60
|
-
});
|
|
61
|
-
} else if (this.type === 'selection') {
|
|
62
|
-
this.items.forEach((item, idx) => {
|
|
63
|
-
const listItem = new SettingsOptionTwoWrapper({
|
|
64
|
-
title: item.text,
|
|
65
|
-
klassname: 'default-option-wrapper',
|
|
66
|
-
focused: idx === 0,
|
|
67
|
-
selected: item.isSelected,
|
|
68
|
-
id: item.id,
|
|
69
|
-
});
|
|
70
|
-
item.instance = listItem; // Store the listItem instance in the item
|
|
71
|
-
if (idx === 0) {
|
|
72
|
-
this.currentFocusedOption = listItem;
|
|
73
|
-
}
|
|
74
|
-
listItem.mount(list);
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
sidebar.appendChild(list);
|
|
79
|
-
this.sidebarElement = sidebar;
|
|
80
|
-
mountPoint.appendChild(sidebar);
|
|
81
|
-
|
|
82
|
-
this.addEventListeners();
|
|
83
|
-
this.focus();
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
addEventListeners() {
|
|
87
|
-
if (!this.sidebarElement) {
|
|
88
|
-
throw new Error('Sidebar: sidebarElement is not initialized');
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
this.sidebarElement.addEventListener('keydown', (event) => {
|
|
92
|
-
if (event.key === 'ArrowDown') {
|
|
93
|
-
event.preventDefault();
|
|
94
|
-
event.stopPropagation();
|
|
95
|
-
this.focusNext();
|
|
96
|
-
} else if (event.key === 'ArrowUp') {
|
|
97
|
-
event.preventDefault();
|
|
98
|
-
event.stopPropagation();
|
|
99
|
-
this.focusPrevious();
|
|
100
|
-
} else if (event.key === 'Backspace' || event.key === 'Escape') {
|
|
101
|
-
event.preventDefault();
|
|
102
|
-
event.stopPropagation();
|
|
103
|
-
this.unfocus();
|
|
104
|
-
this.unmount();
|
|
105
|
-
} else if (event.key === 'Enter' || event.key === 'OK') {
|
|
106
|
-
event.preventDefault();
|
|
107
|
-
event.stopPropagation();
|
|
108
|
-
if (this.type === 'selection') {
|
|
109
|
-
this.selectionTypeAction();
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
selectionTypeAction() {
|
|
116
|
-
if (this.currentFocusedOption) {
|
|
117
|
-
// Deselect all options
|
|
118
|
-
this.items.forEach(item => {
|
|
119
|
-
if (item.instance) {
|
|
120
|
-
item.instance.optionWrapper.classList.remove('selected');
|
|
121
|
-
item.instance.selected = false;
|
|
122
|
-
// Remove image if present
|
|
123
|
-
const img = item.instance.optionWrapper.querySelector('img');
|
|
124
|
-
if (img) {
|
|
125
|
-
img.parentElement.remove();
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
});
|
|
129
|
-
// Select the current option
|
|
130
|
-
this.currentFocusedOption.optionWrapper.classList.add('selected');
|
|
131
|
-
this.currentFocusedOption.selected = true;
|
|
132
|
-
// Add image to the selected option
|
|
133
|
-
const selectedElement = document.createElement('span');
|
|
134
|
-
const img = document.createElement('img');
|
|
135
|
-
img.src = this.currentFocusedOption.imgSrc;
|
|
136
|
-
img.alt = 'Selected';
|
|
137
|
-
selectedElement.appendChild(img);
|
|
138
|
-
this.currentFocusedOption.optionWrapper.appendChild(selectedElement);
|
|
139
|
-
this.onselect(this.currentFocusedOption);
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
focusNext() {
|
|
144
|
-
if (this.sidebarElement && this.currentFocusedOption) {
|
|
145
|
-
const nextSibling = this.currentFocusedOption.optionWrapper.nextElementSibling;
|
|
146
|
-
if (nextSibling) {
|
|
147
|
-
this.currentFocusedOption.blur();
|
|
148
|
-
this.currentFocusedOption = nextSibling.instance;
|
|
149
|
-
this.currentFocusedOption.focus();
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
focusPrevious() {
|
|
155
|
-
if (this.sidebarElement && this.currentFocusedOption) {
|
|
156
|
-
const previousSibling = this.currentFocusedOption.optionWrapper.previousElementSibling;
|
|
157
|
-
if (previousSibling) {
|
|
158
|
-
this.currentFocusedOption.blur();
|
|
159
|
-
this.currentFocusedOption = previousSibling.instance;
|
|
160
|
-
this.currentFocusedOption.focus();
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
focus() {
|
|
166
|
-
if (this.sidebarElement && this.currentFocusedOption) {
|
|
167
|
-
this.currentFocusedOption.focus();
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
unfocus() {
|
|
172
|
-
if (this.sidebarElement && this.currentFocusedOption) {
|
|
173
|
-
this.currentFocusedOption.blur();
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
unmount() {
|
|
178
|
-
if (this.sidebarElement) {
|
|
179
|
-
this.sidebarElement.remove();
|
|
180
|
-
this.sidebarElement = undefined;
|
|
181
|
-
if (this.lastFocusedElement) {
|
|
182
|
-
this.callback();
|
|
183
|
-
this.lastFocusedElement.focus();
|
|
184
|
-
}
|
|
185
|
-
this.currentFocusedOption = null;
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
export class TextContent {
|
|
2
|
-
constructor(props) {
|
|
3
|
-
if (!props || typeof props !== 'object') {
|
|
4
|
-
throw new Error('TextContent: props must be a valid object');
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
this.text = props.text || '';
|
|
8
|
-
this.fontSize = props.fontSize || '16px';
|
|
9
|
-
this.fontFamily = props.fontFamily || 'Arial, sans-serif';
|
|
10
|
-
this.fontWeight = props.fontWeight || 'normal';
|
|
11
|
-
this.textAlign = props.textAlign || 'left';
|
|
12
|
-
this.textDecoration = props.textDecoration || 'none';
|
|
13
|
-
this.textTransform = props.textTransform || 'none';
|
|
14
|
-
this.lineHeight = props.lineHeight || 'normal';
|
|
15
|
-
this.letterSpacing = props.letterSpacing || 'normal';
|
|
16
|
-
this.color = props.color || '#000';
|
|
17
|
-
this.backgroundColor = props.backgroundColor || 'transparent';
|
|
18
|
-
this.klassname = props.klassname || 'default-text-content';
|
|
19
|
-
this.width = props.width || 100;
|
|
20
|
-
this.height = props.height || 50;
|
|
21
|
-
this.focused = props.focused || false;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
setText(text) {
|
|
25
|
-
if (typeof text !== 'string') {
|
|
26
|
-
throw new Error('TextContent: text must be a string');
|
|
27
|
-
}
|
|
28
|
-
this.text = text;
|
|
29
|
-
if (this.container) {
|
|
30
|
-
this.container.textContent = text;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
mount(mountPoint) {
|
|
35
|
-
if (!mountPoint || !(mountPoint instanceof HTMLElement)) {
|
|
36
|
-
throw new Error('TextContent: mountPoint must be a valid DOM element');
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
const text = document.createElement('div');
|
|
40
|
-
text.className = this.klassname;
|
|
41
|
-
text.style.fontSize = this.fontSize;
|
|
42
|
-
text.style.color = this.color;
|
|
43
|
-
text.style.backgroundColor = this.backgroundColor;
|
|
44
|
-
text.innerText = this.text;
|
|
45
|
-
mountPoint.appendChild(text);
|
|
46
|
-
this.container = text;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
unmount() {
|
|
50
|
-
if (this.container) {
|
|
51
|
-
this.container.remove();
|
|
52
|
-
this.container = undefined;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|