ravnur-player-public 3.4.4 → 3.4.6
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/dist/RavnurMediaPlayer.min.js +1 -1
- package/dist/cdn/RavnurMediaPlayer.min.js +1 -1
- package/package.json +72 -68
- package/.eslintignore +0 -7
- package/.eslintrc.js +0 -206
- package/.flowconfig +0 -3
- package/.vscode/extensions.json +0 -7
- package/.vscode/launch.json +0 -37
- package/.vscode/settings.json +0 -4
- package/README-Private.md +0 -54
- package/babel.config.js +0 -28
- package/bitbucket-pipelines.yml +0 -61
- package/cert.pem +0 -23
- package/demo/BaseM.mp4 +0 -0
- package/demo/HD.mp4 +0 -0
- package/demo/annotations.json +0 -50
- package/demo/annotations_ge.json +0 -50
- package/demo/base.mp3 +0 -0
- package/demo/cc_2125en.vtt +0 -4958
- package/demo/cc_en.vtt +0 -171
- package/demo/cc_ge.vtt +0 -178
- package/demo/chapters_en.vtt +0 -38
- package/demo/chapters_ge.vtt +0 -5
- package/demo/chapters_ge1.json +0 -23
- package/demo/hls/audio/stereo/en/128kbit.m3u8 +0 -912
- package/demo/hls/audio/stereo/none/128kbit.m3u8 +0 -912
- package/demo/hls/audio/surround/en/320kbit.m3u8 +0 -912
- package/demo/hls/playlist.m3u8 +0 -31
- package/demo/hls/video/10000kbit.m3u8 +0 -894
- package/demo/hls/video/1100kbit.m3u8 +0 -894
- package/demo/hls/video/1500kbit.m3u8 +0 -894
- package/demo/hls/video/250kbit.m3u8 +0 -894
- package/demo/hls/video/4000kbit.m3u8 +0 -894
- package/demo/hls/video/500kbit.m3u8 +0 -894
- package/demo/hls/video/6000kbit.m3u8 +0 -894
- package/demo/hls/video/800kbit.m3u8 +0 -894
- package/demo/hls.js +0 -5
- package/demo/hls.js.map +0 -1
- package/demo/hls.min.js +0 -2
- package/demo/hls.min.js.map +0 -1
- package/demo/playlist.m3u8 +0 -31
- package/demo/ravnur-flash-audio.swf +0 -0
- package/demo/ravnur-flash-video-hls.swf +0 -0
- package/demo/ravnur-flash-video.swf +0 -0
- package/demo/shaka/shaka-player.foo.debug.d.ts +0 -4532
- package/demo/shaka/shaka-player.foo.debug.externs.js +0 -3886
- package/demo/shaka/shaka-player.foo.debug.js +0 -1746
- package/demo/shaka/shaka-player.foo.debug.map +0 -8
- package/demo/shaka/wrapper.js +0 -7
- package/demo/test.html +0 -458
- package/jest.config.js +0 -4
- package/key.pem +0 -27
- package/lib/es5.js +0 -344
- package/lib/images/Spinner-small.gif +0 -0
- package/lib/images/close.png +0 -0
- package/lib/images/ic_check_box_black_24dp_1x.png +0 -0
- package/lib/images/ic_check_box_outline_blank_black_24dp_1x.png +0 -0
- package/lib/images/ic_chevron_left_white_24dp_1x.png +0 -0
- package/lib/images/ic_chevron_right_white_24dp_1x.png +0 -0
- package/lib/images/ic_closed_caption_white_24dp_1x.png +0 -0
- package/lib/images/ic_fast_forward_white_24dp_1x.png +0 -0
- package/lib/images/ic_fast_rewind_white_24dp_1x.png +0 -0
- package/lib/images/ic_fullscreen_exit_white_24dp_1x.png +0 -0
- package/lib/images/ic_fullscreen_white_24dp_1x.png +0 -0
- package/lib/images/ic_hd_white_24dp_1x.png +0 -0
- package/lib/images/ic_keyboard_arrow_left_black_24dp_1x.png +0 -0
- package/lib/images/ic_keyboard_arrow_right_black_24dp_1x.png +0 -0
- package/lib/images/ic_pause_white_24dp_1x.png +0 -0
- package/lib/images/ic_photo_white_24dp_1x.png +0 -0
- package/lib/images/ic_play_arrow_white_24dp_1x.png +0 -0
- package/lib/images/ic_refresh_white_24dp_1x.png +0 -0
- package/lib/images/ic_settings_white_24dp_1x.png +0 -0
- package/lib/images/ic_skip_next_white_24dp_1x.png +0 -0
- package/lib/images/ic_skip_previous_white_24dp_1x.png +0 -0
- package/lib/images/ic_toc_white_24dp_1x.png +0 -0
- package/lib/images/ic_volume_off_white_24dp_1x.png +0 -0
- package/lib/images/ic_volume_up_white_24dp_1x.png +0 -0
- package/lib/player4ie8.css +0 -225
- package/server.js +0 -29
- package/src/config/cc.js +0 -56
- package/src/config/i18n.js +0 -101
- package/src/config/options.js +0 -123
- package/src/config/playlist.js +0 -9
- package/src/config/source.js +0 -23
- package/src/config/statuses.js +0 -8
- package/src/config/styles.js +0 -16
- package/src/entity.js +0 -27
- package/src/events.js +0 -5
- package/src/extensions/annotations.js +0 -142
- package/src/extensions/audio-tarcks.js +0 -115
- package/src/extensions/backward.js +0 -45
- package/src/extensions/base.js +0 -73
- package/src/extensions/bottom-next.js +0 -50
- package/src/extensions/bottom-prev.js +0 -50
- package/src/extensions/buffering.js +0 -78
- package/src/extensions/c2pa.js +0 -350
- package/src/extensions/caption-search.js +0 -230
- package/src/extensions/cc.js +0 -874
- package/src/extensions/crawl.js +0 -118
- package/src/extensions/download.js +0 -411
- package/src/extensions/error.js +0 -47
- package/src/extensions/forward.js +0 -44
- package/src/extensions/fullscreen.js +0 -84
- package/src/extensions/help.js +0 -201
- package/src/extensions/helpers/FileSaver.js +0 -157
- package/src/extensions/helpers/clickOpener.js +0 -180
- package/src/extensions/helpers/opener.js +0 -30
- package/src/extensions/helpers/openerHeightChecker.js +0 -13
- package/src/extensions/helpers/popover.js +0 -33
- package/src/extensions/helpers/popoverPosition.js +0 -30
- package/src/extensions/helpers/scrollIntoView.js +0 -9
- package/src/extensions/helpers/storage.js +0 -20
- package/src/extensions/helpers/textContent.js +0 -6
- package/src/extensions/helpers/timeCodeToSeconds.js +0 -44
- package/src/extensions/helpers/transport.js +0 -43
- package/src/extensions/helpers/vtt-loader.js +0 -42
- package/src/extensions/index.js +0 -87
- package/src/extensions/live.js +0 -76
- package/src/extensions/mux.js +0 -57
- package/src/extensions/next-frame.js +0 -44
- package/src/extensions/next.js +0 -48
- package/src/extensions/placeholder.js +0 -241
- package/src/extensions/play.js +0 -102
- package/src/extensions/poster.js +0 -47
- package/src/extensions/prev-frame.js +0 -44
- package/src/extensions/prev.js +0 -48
- package/src/extensions/progress.js +0 -465
- package/src/extensions/resizer.js +0 -37
- package/src/extensions/settings.js +0 -367
- package/src/extensions/theater.js +0 -56
- package/src/extensions/title.js +0 -38
- package/src/extensions/toc.js +0 -334
- package/src/extensions/volume.js +0 -196
- package/src/flash/FlashPlugin.js +0 -301
- package/src/flash/MediaElement.js +0 -361
- package/src/flash/plugins.js +0 -32
- package/src/flash-detector.js +0 -66
- package/src/helpers/$t.js +0 -10
- package/src/helpers/binder.js +0 -11
- package/src/helpers/isAndroid.js +0 -5
- package/src/helpers/isBlackBerry.js +0 -5
- package/src/helpers/isCanvasSupported.js +0 -6
- package/src/helpers/isIE.js +0 -21
- package/src/helpers/isMobile.js +0 -10
- package/src/helpers/isWindows.js +0 -5
- package/src/helpers/isWindowsPhone.js +0 -5
- package/src/helpers/isiOS.js +0 -5
- package/src/html5media.js +0 -19
- package/src/index.js +0 -2
- package/src/logger.js +0 -31
- package/src/microevent.js +0 -65
- package/src/normalize-options.js +0 -139
- package/src/player.js +0 -864
- package/src/players/base.js +0 -209
- package/src/players/flash.js +0 -172
- package/src/players/hls.js +0 -278
- package/src/players/html.js +0 -205
- package/src/players/index.js +0 -59
- package/src/players/shaka.js +0 -219
- package/src/playlist.js +0 -362
- package/src/screenfull.js +0 -121
- package/src/state.js +0 -474
- package/src/static/es5.js +0 -344
- package/src/static/images/Spinner-small.gif +0 -0
- package/src/static/images/close.png +0 -0
- package/src/static/images/ic_check_box_black_24dp_1x.png +0 -0
- package/src/static/images/ic_check_box_outline_blank_black_24dp_1x.png +0 -0
- package/src/static/images/ic_chevron_left_white_24dp_1x.png +0 -0
- package/src/static/images/ic_chevron_right_white_24dp_1x.png +0 -0
- package/src/static/images/ic_closed_caption_white_24dp_1x.png +0 -0
- package/src/static/images/ic_fast_forward_white_24dp_1x.png +0 -0
- package/src/static/images/ic_fast_rewind_white_24dp_1x.png +0 -0
- package/src/static/images/ic_fullscreen_exit_white_24dp_1x.png +0 -0
- package/src/static/images/ic_fullscreen_white_24dp_1x.png +0 -0
- package/src/static/images/ic_hd_white_24dp_1x.png +0 -0
- package/src/static/images/ic_keyboard_arrow_left_black_24dp_1x.png +0 -0
- package/src/static/images/ic_keyboard_arrow_right_black_24dp_1x.png +0 -0
- package/src/static/images/ic_pause_white_24dp_1x.png +0 -0
- package/src/static/images/ic_play_arrow_white_24dp_1x.png +0 -0
- package/src/static/images/ic_refresh_white_24dp_1x.png +0 -0
- package/src/static/images/ic_settings_white_24dp_1x.png +0 -0
- package/src/static/images/ic_skip_next_white_24dp_1x.png +0 -0
- package/src/static/images/ic_skip_previous_white_24dp_1x.png +0 -0
- package/src/static/images/ic_toc_white_24dp_1x.png +0 -0
- package/src/static/images/ic_volume_off_white_24dp_1x.png +0 -0
- package/src/static/images/ic_volume_up_white_24dp_1x.png +0 -0
- package/src/static/player4ie8.css +0 -225
- package/src/styles/bplaylist.css.js +0 -124
- package/src/styles/index.js +0 -1966
- package/src/styles/playlist.css.js +0 -84
- package/src/styles/rplaylist.css.js +0 -98
- package/src/svgs.js +0 -111
- package/src/types/Logger.js +0 -10
- package/src/types/Options.js +0 -179
- package/src/types/Playlist.js +0 -3
- package/src/types/Source.js +0 -28
- package/src/types/State.js +0 -46
- package/src/types/Styles.js +0 -11
- package/src/types/TimeData.js +0 -8
- package/src/types/Translation.js +0 -69
- package/src/utils/absolutizeUrl.js +0 -9
- package/src/utils/addClass.js +0 -9
- package/src/utils/addEvent.js +0 -31
- package/src/utils/addProperty.js +0 -65
- package/src/utils/appendChild.js +0 -14
- package/src/utils/buff2hex.js +0 -5
- package/src/utils/contains.js +0 -33
- package/src/utils/createElement.js +0 -24
- package/src/utils/each.js +0 -34
- package/src/utils/escapeHTML.js +0 -8
- package/src/utils/existy.js +0 -4
- package/src/utils/extend.js +0 -17
- package/src/utils/filter.js +0 -16
- package/src/utils/find.js +0 -11
- package/src/utils/findIndex.js +0 -20
- package/src/utils/first.js +0 -5
- package/src/utils/get.js +0 -19
- package/src/utils/has.js +0 -5
- package/src/utils/hasClass.js +0 -6
- package/src/utils/head.js +0 -11
- package/src/utils/inRange.js +0 -16
- package/src/utils/index.js +0 -73
- package/src/utils/isArray.js +0 -4
- package/src/utils/isBoolean.js +0 -3
- package/src/utils/isElement.js +0 -7
- package/src/utils/isEmpty.js +0 -6
- package/src/utils/isEqual.js +0 -33
- package/src/utils/isEqualBuffer.js +0 -13
- package/src/utils/isFunction.js +0 -3
- package/src/utils/isNotEmpty.js +0 -5
- package/src/utils/isObject.js +0 -5
- package/src/utils/isString.js +0 -9
- package/src/utils/last.js +0 -4
- package/src/utils/map.js +0 -11
- package/src/utils/negate.js +0 -8
- package/src/utils/noop.js +0 -1
- package/src/utils/notExisty.js +0 -5
- package/src/utils/reduce.js +0 -8
- package/src/utils/remove.js +0 -7
- package/src/utils/removeClass.js +0 -8
- package/src/utils/removeEvent.js +0 -7
- package/src/utils/toArray.js +0 -7
- package/src/utils/toggleClass.js +0 -16
- package/src/utils/uidGenerator.js +0 -8
- package/src/utils/upperFirst.js +0 -4
- package/tests/extensions/__snapshots__/download.spec.js.snap +0 -226
- package/tests/extensions/__snapshots__/fullscreen.spec.js.snap +0 -30
- package/tests/extensions/__snapshots__/title.spec.js.snap +0 -16
- package/tests/extensions/download.spec.js +0 -111
- package/tests/extensions/fullscreen.spec.js +0 -56
- package/tests/extensions/title.spec.js +0 -35
- package/tests/mocks/assets/BaseM.mp4 +0 -0
- package/tests/mocks/assets/hls.min.js +0 -5
- package/tests/mocks/assets/styleMock.js +0 -1
- package/tests/mocks/base-player-options.js +0 -47
- package/tests/mocks/sources.js +0 -58
- package/tests/mocks/timedata/cc_en.vtt +0 -171
- package/tests/mocks/timedata/cc_ge.vtt +0 -178
- package/tests/utils/wait.js +0 -1
- package/webpack.config.js +0 -78
package/src/extensions/cc.js
DELETED
|
@@ -1,874 +0,0 @@
|
|
|
1
|
-
// @flow
|
|
2
|
-
import BaseExtension from './base';
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
createElement,
|
|
6
|
-
each,
|
|
7
|
-
find,
|
|
8
|
-
removeClass,
|
|
9
|
-
addClass,
|
|
10
|
-
inRange,
|
|
11
|
-
findIndex,
|
|
12
|
-
isEmpty,
|
|
13
|
-
toArray,
|
|
14
|
-
hasClass,
|
|
15
|
-
filter,
|
|
16
|
-
append
|
|
17
|
-
} from '../utils';
|
|
18
|
-
|
|
19
|
-
import opener from './helpers/clickOpener';
|
|
20
|
-
import popover from './helpers/popover';
|
|
21
|
-
import openerHeightChecker from './helpers/openerHeightChecker';
|
|
22
|
-
|
|
23
|
-
import binder from '../helpers/binder';
|
|
24
|
-
|
|
25
|
-
import BaseController from '../players/base';
|
|
26
|
-
import StateEntity from '../state';
|
|
27
|
-
|
|
28
|
-
import {
|
|
29
|
-
CC_COLORS,
|
|
30
|
-
CC_FONT_FAMILIES,
|
|
31
|
-
CC_FONT_SIZES,
|
|
32
|
-
CC_LOCATIONS
|
|
33
|
-
} from '../config/cc';
|
|
34
|
-
|
|
35
|
-
import {
|
|
36
|
-
UNAPPROVED_TIMEDATA_STATUS,
|
|
37
|
-
UNTRANSLATED_TIMEDATA_STATUS,
|
|
38
|
-
TRANSLATABLE_TIMEDATA_STATUS
|
|
39
|
-
} from '../config/statuses';
|
|
40
|
-
|
|
41
|
-
import createSvg, { CC, BACK, NEXT } from '../svgs';
|
|
42
|
-
|
|
43
|
-
import type { Player$ExtensionOptions } from '../types/Options';
|
|
44
|
-
import type { Player$State } from '../types/State';
|
|
45
|
-
import type { CCOption } from '../config/cc';
|
|
46
|
-
import type { Player$Translation } from '../types/Translation';
|
|
47
|
-
import type { Player$TimeDataSource } from '../types/Source';
|
|
48
|
-
|
|
49
|
-
const CN = 'rmp-ext-cc';
|
|
50
|
-
|
|
51
|
-
const BUTTON_CN = `${CN}__button`;
|
|
52
|
-
const SELECTOR_CN = `${CN}__selector`;
|
|
53
|
-
const SELECTOR_OPEN_CN = `${SELECTOR_CN}--open`;
|
|
54
|
-
const SELECTOR_MAIN_STEP_CN = `${SELECTOR_CN}--main-step`;
|
|
55
|
-
const SELECTOR_SETTINGS_STEP_CN = `${SELECTOR_CN}--settings-step`;
|
|
56
|
-
const SELECTOR_ADDITIONAL_STEP_CN = `${SELECTOR_CN}--additional-step`;
|
|
57
|
-
const SELECTOR_TRANSLATE_STEP_CN = `${SELECTOR_CN}--translate-step`;
|
|
58
|
-
|
|
59
|
-
const MAIN_STEP_CN = `${CN}__main-step`;
|
|
60
|
-
const SETTINGS_STEP_CN = `${CN}__settings-step`;
|
|
61
|
-
const ADDITIONAL_STEP_CN = `${CN}__additional-step`;
|
|
62
|
-
|
|
63
|
-
const ITEM_CN = `${CN}__item`;
|
|
64
|
-
const ITEM_CHECKED_CN = `${ITEM_CN}--checked`;
|
|
65
|
-
|
|
66
|
-
const SETTINGS_CN = `${CN}__settings`;
|
|
67
|
-
const PROGRESS_SETTINGS_CN = `${SETTINGS_CN}--progress`;
|
|
68
|
-
const MORE_CN = `${CN}__more`;
|
|
69
|
-
const CURRENT_VALUE_CN = `${CN}__current-value`;
|
|
70
|
-
|
|
71
|
-
const TEXT_CN = `${CN}__text`;
|
|
72
|
-
const TEXT_VISIBLE_CN = `${TEXT_CN}--visible`;
|
|
73
|
-
|
|
74
|
-
const TEXT_HOLDER_CN = `${CN}__text-holder`;
|
|
75
|
-
|
|
76
|
-
const BACK_BTN_CN = `${CN}__back`;
|
|
77
|
-
|
|
78
|
-
const TRANSLATE_WRAPPER_CN = `${CN}__translate-wrapper`;
|
|
79
|
-
const SETTINGS_WRAPPER_CN = `${CN}__settings-wrapper`;
|
|
80
|
-
|
|
81
|
-
export default class ClosedCaptionsExtension extends BaseExtension {
|
|
82
|
-
$el: HTMLElement;
|
|
83
|
-
$button: HTMLButtonElement;
|
|
84
|
-
$selector: HTMLElement;
|
|
85
|
-
$text: HTMLElement;
|
|
86
|
-
$textHolder: HTMLElement;
|
|
87
|
-
$mainStep: HTMLElement;
|
|
88
|
-
$embedCaptions: HTMLElement;
|
|
89
|
-
$settingsStep: HTMLElement;
|
|
90
|
-
$settings: HTMLElement;
|
|
91
|
-
$toMain: HTMLElement;
|
|
92
|
-
$toSettings: HTMLElement;
|
|
93
|
-
$fontColorSettings: HTMLElement;
|
|
94
|
-
$backgroundColorSettings: HTMLElement;
|
|
95
|
-
$fontSizeSettings: HTMLElement;
|
|
96
|
-
$fontFamilySettings: HTMLElement;
|
|
97
|
-
$locationSettings: ?HTMLElement = null;
|
|
98
|
-
$currentColor: HTMLElement;
|
|
99
|
-
$currentSize: HTMLElement;
|
|
100
|
-
$currentBgColor: HTMLElement;
|
|
101
|
-
$currentLocation: HTMLElement;
|
|
102
|
-
$currentFamily: HTMLElement;
|
|
103
|
-
$additionalStep: HTMLElement;
|
|
104
|
-
$additionalBackText: HTMLElement;
|
|
105
|
-
$additionalStepWrapper: HTMLElement;
|
|
106
|
-
$translate: ?HTMLElement;
|
|
107
|
-
$currentCustomTranslate: ?HTMLElement;
|
|
108
|
-
|
|
109
|
-
$captions: HTMLElement[] = [];
|
|
110
|
-
$translatableCaptions: HTMLElement[] = [];
|
|
111
|
-
|
|
112
|
-
embedCaptionsAutoShow: boolean = true;
|
|
113
|
-
|
|
114
|
-
constructor(
|
|
115
|
-
player: BaseController,
|
|
116
|
-
state: StateEntity,
|
|
117
|
-
options: Player$ExtensionOptions
|
|
118
|
-
) {
|
|
119
|
-
super(player, state, options, ['timeupdate', 'showpopup', 'statechanged']);
|
|
120
|
-
this.logger.debug('cc:extension:creating');
|
|
121
|
-
this.render();
|
|
122
|
-
this.init();
|
|
123
|
-
this.logger.debug('cc:extension:created');
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
init() {
|
|
127
|
-
binder(this, [
|
|
128
|
-
'_toSettingsPage',
|
|
129
|
-
'_toMainPage',
|
|
130
|
-
'_toColorPage',
|
|
131
|
-
'_toBackgroundColorPage',
|
|
132
|
-
'_toFontFamilyPage',
|
|
133
|
-
'_toSizesPage',
|
|
134
|
-
'_toLocationsPage',
|
|
135
|
-
'_toTranslatePage',
|
|
136
|
-
'_handleEmbedChanged'
|
|
137
|
-
]);
|
|
138
|
-
|
|
139
|
-
opener(this, {
|
|
140
|
-
$button: this.$button,
|
|
141
|
-
$selector: this.$selector,
|
|
142
|
-
SELECTOR_OPEN_CN,
|
|
143
|
-
heightControl: true,
|
|
144
|
-
firstFocusItemSelector: `.${ITEM_CN}`,
|
|
145
|
-
toMainFn: this._toMainPage.bind(this)
|
|
146
|
-
});
|
|
147
|
-
popover(this, { $button: this.$button, text: this.$t('cc') });
|
|
148
|
-
|
|
149
|
-
this.addEvent(this.$settings, 'click', this._toSettingsPage);
|
|
150
|
-
this.addEvent(this.$toMain, 'click', this._toMainPage);
|
|
151
|
-
this.addEvent(this.$toSettings, 'click', this._toSettingsPage);
|
|
152
|
-
|
|
153
|
-
this.addEvent(this.$fontColorSettings, 'click', this._toColorPage);
|
|
154
|
-
this.addEvent(
|
|
155
|
-
this.$backgroundColorSettings,
|
|
156
|
-
'click',
|
|
157
|
-
this._toBackgroundColorPage
|
|
158
|
-
);
|
|
159
|
-
this.addEvent(this.$fontFamilySettings, 'click', this._toFontFamilyPage);
|
|
160
|
-
this.addEvent(this.$fontSizeSettings, 'click', this._toSizesPage);
|
|
161
|
-
|
|
162
|
-
if (this.$locationSettings) {
|
|
163
|
-
this.addEvent(this.$locationSettings, 'click', this._toLocationsPage);
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
if (this.$translate) {
|
|
167
|
-
this.addEvent(this.$translate, 'click', this._toTranslatePage);
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
this.player.$el?.textTracks.addEventListener('addtrack', this._handleEmbedChanged);
|
|
171
|
-
this.player.$el?.textTracks.addEventListener('change', this._handleEmbedChanged);
|
|
172
|
-
|
|
173
|
-
this._toMainPage();
|
|
174
|
-
this._refresh();
|
|
175
|
-
|
|
176
|
-
this.changeLang(this.state.getCCLang());
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
render() {
|
|
180
|
-
this.$el = createElement('div', { class: CN });
|
|
181
|
-
|
|
182
|
-
this.$button = createElement(
|
|
183
|
-
'button',
|
|
184
|
-
{ type: 'button', class: BUTTON_CN },
|
|
185
|
-
this.$el
|
|
186
|
-
);
|
|
187
|
-
|
|
188
|
-
this.$selector = createElement('div', { class: SELECTOR_CN }, this.$el);
|
|
189
|
-
this.$text = createElement('span', { class: TEXT_CN });
|
|
190
|
-
this.$textHolder = createElement(
|
|
191
|
-
'span',
|
|
192
|
-
{ class: TEXT_HOLDER_CN },
|
|
193
|
-
this.$text
|
|
194
|
-
);
|
|
195
|
-
|
|
196
|
-
this._renderMainPage();
|
|
197
|
-
this._renderSettingsPage();
|
|
198
|
-
this._renderAdditionalPage();
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
_handleEmbedChanged() {
|
|
202
|
-
const textTracks = this.player.getTextTracks();
|
|
203
|
-
const sources = this.state.getCCSources();
|
|
204
|
-
|
|
205
|
-
this.$el.style.display = !sources.length && !textTracks?.length ? 'none' : 'block';
|
|
206
|
-
|
|
207
|
-
const addOffButton = () => {
|
|
208
|
-
const offItem = createElement(
|
|
209
|
-
'button',
|
|
210
|
-
{ type: 'button', class: ITEM_CN },
|
|
211
|
-
this.$embedCaptions
|
|
212
|
-
);
|
|
213
|
-
|
|
214
|
-
offItem.textContent = 'None';
|
|
215
|
-
this.addEvent(offItem, 'click', () => {
|
|
216
|
-
each(textTracks, (track) => {
|
|
217
|
-
each(this.$captions, (el) => removeClass(el, ITEM_CHECKED_CN));
|
|
218
|
-
track.mode = 'disabled';
|
|
219
|
-
addClass(offItem, ITEM_CHECKED_CN);
|
|
220
|
-
});
|
|
221
|
-
});
|
|
222
|
-
this.$captions.push(offItem);
|
|
223
|
-
};
|
|
224
|
-
|
|
225
|
-
if (!sources.length) {
|
|
226
|
-
this.$settings.style.display = 'none';
|
|
227
|
-
const offItem = this.$embedCaptions.childNodes[0];
|
|
228
|
-
if (!offItem || offItem?.textContent !== 'None') {
|
|
229
|
-
addOffButton();
|
|
230
|
-
}
|
|
231
|
-
} else {
|
|
232
|
-
this.$settings.style.display = 'block';
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
if (!textTracks?.length) {
|
|
236
|
-
return;
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
each(textTracks, (track) => {
|
|
240
|
-
const alreadyExist = find(this.$captions, (el) => el.textContent === track.label);
|
|
241
|
-
|
|
242
|
-
if (alreadyExist) {
|
|
243
|
-
return;
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
const item = createElement(
|
|
247
|
-
'button',
|
|
248
|
-
{ type: 'button', class: ITEM_CN },
|
|
249
|
-
this.$embedCaptions
|
|
250
|
-
);
|
|
251
|
-
|
|
252
|
-
item.textContent = track.label;
|
|
253
|
-
this.addEvent(item, 'click', () => {
|
|
254
|
-
each(this.$captions, (el) => removeClass(el, ITEM_CHECKED_CN));
|
|
255
|
-
each(this.$translatableCaptions, (el) => removeClass(el, ITEM_CHECKED_CN));
|
|
256
|
-
const idx = this.$captions.findIndex((el) => el === item);
|
|
257
|
-
addClass(this.$captions[idx], ITEM_CHECKED_CN);
|
|
258
|
-
track.mode = 'showing';
|
|
259
|
-
});
|
|
260
|
-
|
|
261
|
-
this.$captions.push(item);
|
|
262
|
-
|
|
263
|
-
if (this.embedCaptionsAutoShow) {
|
|
264
|
-
item.click();
|
|
265
|
-
this.embedCaptionsAutoShow = false;
|
|
266
|
-
}
|
|
267
|
-
});
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
_renderMainPage() {
|
|
271
|
-
this.$mainStep = createElement(
|
|
272
|
-
'div',
|
|
273
|
-
{ class: MAIN_STEP_CN, tabindex: -1 },
|
|
274
|
-
this.$selector
|
|
275
|
-
);
|
|
276
|
-
|
|
277
|
-
createSvg(this.$button, CC);
|
|
278
|
-
|
|
279
|
-
const sources = this.state.getCCSources();
|
|
280
|
-
|
|
281
|
-
this.$el.style.display = sources.length ? 'block' : 'none';
|
|
282
|
-
|
|
283
|
-
const alreadyTranslatedSources = filter(
|
|
284
|
-
sources,
|
|
285
|
-
(s) =>
|
|
286
|
-
s.state !== UNTRANSLATED_TIMEDATA_STATUS &&
|
|
287
|
-
s.state !== TRANSLATABLE_TIMEDATA_STATUS
|
|
288
|
-
);
|
|
289
|
-
|
|
290
|
-
each(alreadyTranslatedSources, (data) => {
|
|
291
|
-
const item = createElement(
|
|
292
|
-
'button',
|
|
293
|
-
{ type: 'button', class: ITEM_CN },
|
|
294
|
-
this.$mainStep
|
|
295
|
-
);
|
|
296
|
-
|
|
297
|
-
item.textContent =
|
|
298
|
-
data.state === UNAPPROVED_TIMEDATA_STATUS
|
|
299
|
-
? `${data.label} ${this.$t('unapproved-source')}`
|
|
300
|
-
: data.label;
|
|
301
|
-
this.addEvent(item, 'click', () => this.bus.emit('cclang', data.srclang));
|
|
302
|
-
this.$captions.push(item);
|
|
303
|
-
});
|
|
304
|
-
|
|
305
|
-
// Create empty container for embed captions (order is important)
|
|
306
|
-
this.$embedCaptions = createElement(
|
|
307
|
-
'div',
|
|
308
|
-
{},
|
|
309
|
-
this.$mainStep
|
|
310
|
-
);
|
|
311
|
-
|
|
312
|
-
const $translate = createElement(
|
|
313
|
-
'button',
|
|
314
|
-
{ type: 'button', class: SETTINGS_CN },
|
|
315
|
-
this.$mainStep
|
|
316
|
-
);
|
|
317
|
-
this.$translate = $translate;
|
|
318
|
-
let text = createElement('span', {}, $translate);
|
|
319
|
-
text.textContent = this.$t('translate');
|
|
320
|
-
_createMore($translate);
|
|
321
|
-
|
|
322
|
-
this.$currentCustomTranslate = createElement(
|
|
323
|
-
'span',
|
|
324
|
-
{ class: CURRENT_VALUE_CN },
|
|
325
|
-
this.$translate
|
|
326
|
-
);
|
|
327
|
-
const haveUntranslatedSources =
|
|
328
|
-
alreadyTranslatedSources.length !== sources.length;
|
|
329
|
-
$translate.style.display = haveUntranslatedSources ? 'block' : 'none';
|
|
330
|
-
|
|
331
|
-
this.$settings = createElement(
|
|
332
|
-
'button',
|
|
333
|
-
{ type: 'button', class: SETTINGS_CN },
|
|
334
|
-
this.$mainStep
|
|
335
|
-
);
|
|
336
|
-
text = createElement('span', {}, this.$settings);
|
|
337
|
-
text.textContent = this.$t('settings');
|
|
338
|
-
_createMore(this.$settings);
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
_rerenderLanguages(sources: Player$TimeDataSource[]) {
|
|
342
|
-
const { $mainStep, $translate, $settings } = this;
|
|
343
|
-
this.$el.style.display = sources.length ? 'block' : 'none';
|
|
344
|
-
|
|
345
|
-
if (!$mainStep) {
|
|
346
|
-
return;
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
each(this.$captions, (e) => {
|
|
350
|
-
$mainStep.removeChild(e);
|
|
351
|
-
});
|
|
352
|
-
this.$captions.length = 0;
|
|
353
|
-
|
|
354
|
-
const alreadyTranslatedSources = filter(
|
|
355
|
-
sources,
|
|
356
|
-
(s) =>
|
|
357
|
-
s.state !== UNTRANSLATED_TIMEDATA_STATUS &&
|
|
358
|
-
s.state !== TRANSLATABLE_TIMEDATA_STATUS
|
|
359
|
-
);
|
|
360
|
-
|
|
361
|
-
each(alreadyTranslatedSources, (data) => {
|
|
362
|
-
const item = createElement(
|
|
363
|
-
'button',
|
|
364
|
-
{ type: 'button', class: ITEM_CN },
|
|
365
|
-
this.$mainStep
|
|
366
|
-
);
|
|
367
|
-
|
|
368
|
-
item.textContent =
|
|
369
|
-
data.state === UNAPPROVED_TIMEDATA_STATUS
|
|
370
|
-
? `${data.label} ${this.$t('unapproved-source')}`
|
|
371
|
-
: data.label;
|
|
372
|
-
this.addEvent(item, 'click', () => this.bus.emit('cclang', data.srclang));
|
|
373
|
-
this.$captions.push(item);
|
|
374
|
-
});
|
|
375
|
-
|
|
376
|
-
if ($translate) {
|
|
377
|
-
$mainStep.removeChild($translate);
|
|
378
|
-
const haveUtranslatedSources =
|
|
379
|
-
alreadyTranslatedSources.length !== sources.length;
|
|
380
|
-
$translate.style.display = haveUtranslatedSources ? 'block' : 'none';
|
|
381
|
-
append($mainStep, $translate);
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
if ($settings) {
|
|
385
|
-
$mainStep.removeChild($settings);
|
|
386
|
-
append($mainStep, $settings);
|
|
387
|
-
}
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
_renderSettingsPage() {
|
|
391
|
-
this.$settingsStep = createElement(
|
|
392
|
-
'div',
|
|
393
|
-
{ class: SETTINGS_STEP_CN },
|
|
394
|
-
this.$selector
|
|
395
|
-
);
|
|
396
|
-
|
|
397
|
-
this.$toMain = createElement(
|
|
398
|
-
'button',
|
|
399
|
-
{ type: 'button', class: BACK_BTN_CN },
|
|
400
|
-
this.$settingsStep
|
|
401
|
-
);
|
|
402
|
-
|
|
403
|
-
const $backSpan = createElement('span', { class: 'arrow' }, this.$toMain);
|
|
404
|
-
createSvg($backSpan, BACK, { class: 'arrow' });
|
|
405
|
-
|
|
406
|
-
const $backText = createElement('span', {}, this.$toMain);
|
|
407
|
-
$backText.textContent = this.$t('cc');
|
|
408
|
-
|
|
409
|
-
const $settingsWrapper = createElement(
|
|
410
|
-
'div',
|
|
411
|
-
{ class: `${SETTINGS_WRAPPER_CN} tab-content` },
|
|
412
|
-
this.$settingsStep
|
|
413
|
-
);
|
|
414
|
-
|
|
415
|
-
this.$fontColorSettings = createElement(
|
|
416
|
-
'button',
|
|
417
|
-
{ type: 'button' },
|
|
418
|
-
$settingsWrapper
|
|
419
|
-
);
|
|
420
|
-
let text = createElement('span', {}, this.$fontColorSettings);
|
|
421
|
-
text.textContent = this.$t('settings-fontcolor');
|
|
422
|
-
_createMore(this.$fontColorSettings);
|
|
423
|
-
this.$currentColor = createElement(
|
|
424
|
-
'span',
|
|
425
|
-
{ class: CURRENT_VALUE_CN },
|
|
426
|
-
this.$fontColorSettings
|
|
427
|
-
);
|
|
428
|
-
let color = find(CC_COLORS, (c) => c.value === this.state.getCCTextColor());
|
|
429
|
-
this.$currentColor.textContent =
|
|
430
|
-
color && color.key ? this.$t(color.key) : '';
|
|
431
|
-
|
|
432
|
-
this.$fontSizeSettings = createElement(
|
|
433
|
-
'button',
|
|
434
|
-
{ type: 'button' },
|
|
435
|
-
$settingsWrapper
|
|
436
|
-
);
|
|
437
|
-
text = createElement('span', {}, this.$fontSizeSettings);
|
|
438
|
-
text.textContent = this.$t('settings-fontsize');
|
|
439
|
-
_createMore(this.$fontSizeSettings);
|
|
440
|
-
this.$currentSize = createElement(
|
|
441
|
-
'span',
|
|
442
|
-
{ class: CURRENT_VALUE_CN },
|
|
443
|
-
this.$fontSizeSettings
|
|
444
|
-
);
|
|
445
|
-
this.$currentSize.textContent = this.state.getCCFontSize();
|
|
446
|
-
|
|
447
|
-
this.$fontFamilySettings = createElement(
|
|
448
|
-
'button',
|
|
449
|
-
{ type: 'button' },
|
|
450
|
-
$settingsWrapper
|
|
451
|
-
);
|
|
452
|
-
text = createElement('span', {}, this.$fontFamilySettings);
|
|
453
|
-
text.textContent = this.$t('settings-fontfamily');
|
|
454
|
-
_createMore(this.$fontFamilySettings);
|
|
455
|
-
this.$currentFamily = createElement(
|
|
456
|
-
'span',
|
|
457
|
-
{ class: CURRENT_VALUE_CN },
|
|
458
|
-
this.$fontFamilySettings
|
|
459
|
-
);
|
|
460
|
-
const family = find(
|
|
461
|
-
CC_FONT_FAMILIES,
|
|
462
|
-
(c) => c.value === this.state.getCCFontFamily()
|
|
463
|
-
);
|
|
464
|
-
this.$currentFamily.textContent =
|
|
465
|
-
family && family.key ? this.$t(family.key) : '';
|
|
466
|
-
|
|
467
|
-
this.$backgroundColorSettings = createElement(
|
|
468
|
-
'button',
|
|
469
|
-
{ type: 'button' },
|
|
470
|
-
$settingsWrapper
|
|
471
|
-
);
|
|
472
|
-
text = createElement('span', {}, this.$backgroundColorSettings);
|
|
473
|
-
text.textContent = this.$t('settings-background');
|
|
474
|
-
_createMore(this.$backgroundColorSettings);
|
|
475
|
-
this.$currentBgColor = createElement(
|
|
476
|
-
'span',
|
|
477
|
-
{ class: CURRENT_VALUE_CN },
|
|
478
|
-
this.$backgroundColorSettings
|
|
479
|
-
);
|
|
480
|
-
color = find(CC_COLORS, (c) => c.value === this.state.getCCBgColor());
|
|
481
|
-
this.$currentBgColor.textContent =
|
|
482
|
-
color && color.key ? this.$t(color.key) : '';
|
|
483
|
-
|
|
484
|
-
if (this.options.showCCLayout) {
|
|
485
|
-
const $locationSettings = createElement(
|
|
486
|
-
'button',
|
|
487
|
-
{ type: 'button' },
|
|
488
|
-
$settingsWrapper
|
|
489
|
-
);
|
|
490
|
-
this.$locationSettings = $locationSettings;
|
|
491
|
-
text = createElement('span', {}, $locationSettings);
|
|
492
|
-
text.textContent = this.$t('settings-captionlocations');
|
|
493
|
-
_createMore($locationSettings);
|
|
494
|
-
this.$currentLocation = createElement(
|
|
495
|
-
'span',
|
|
496
|
-
{ class: CURRENT_VALUE_CN },
|
|
497
|
-
this.$locationSettings
|
|
498
|
-
);
|
|
499
|
-
const location = find(
|
|
500
|
-
CC_LOCATIONS,
|
|
501
|
-
(c) => c.value === this.state.getCCLocation()
|
|
502
|
-
);
|
|
503
|
-
this.$currentLocation.textContent =
|
|
504
|
-
location && location.key ? this.$t(location.key) : '';
|
|
505
|
-
}
|
|
506
|
-
|
|
507
|
-
const $translateWrapper = createElement(
|
|
508
|
-
'div',
|
|
509
|
-
{ class: `${TRANSLATE_WRAPPER_CN} tab-content` },
|
|
510
|
-
this.$settingsStep
|
|
511
|
-
);
|
|
512
|
-
|
|
513
|
-
const translatableSources = filter(
|
|
514
|
-
this.state.getCCSources(),
|
|
515
|
-
(s) =>
|
|
516
|
-
s.state === UNTRANSLATED_TIMEDATA_STATUS ||
|
|
517
|
-
s.state === TRANSLATABLE_TIMEDATA_STATUS
|
|
518
|
-
);
|
|
519
|
-
|
|
520
|
-
each(translatableSources, (data) => {
|
|
521
|
-
const item = createElement(
|
|
522
|
-
'button',
|
|
523
|
-
{ type: 'button', class: ITEM_CN },
|
|
524
|
-
$translateWrapper
|
|
525
|
-
);
|
|
526
|
-
item.textContent = data.label;
|
|
527
|
-
this.addEvent(item, 'click', () => {
|
|
528
|
-
this.bus.emit('cclang', data.srclang);
|
|
529
|
-
this._toMainPage();
|
|
530
|
-
});
|
|
531
|
-
this.$translatableCaptions.push(item);
|
|
532
|
-
});
|
|
533
|
-
}
|
|
534
|
-
|
|
535
|
-
_renderAdditionalPage() {
|
|
536
|
-
this.$additionalStep = createElement(
|
|
537
|
-
'div',
|
|
538
|
-
{ class: ADDITIONAL_STEP_CN },
|
|
539
|
-
this.$selector
|
|
540
|
-
);
|
|
541
|
-
this.$toSettings = createElement(
|
|
542
|
-
'button',
|
|
543
|
-
{ type: 'button', class: BACK_BTN_CN },
|
|
544
|
-
this.$additionalStep
|
|
545
|
-
);
|
|
546
|
-
const $backSpan = createElement(
|
|
547
|
-
'span',
|
|
548
|
-
{ class: 'arrow' },
|
|
549
|
-
this.$toSettings
|
|
550
|
-
);
|
|
551
|
-
createSvg($backSpan, BACK, { class: 'arrow' });
|
|
552
|
-
this.$additionalBackText = createElement('span', {}, this.$toSettings);
|
|
553
|
-
this.$additionalStepWrapper = createElement(
|
|
554
|
-
'div',
|
|
555
|
-
{ class: 'tab-content' },
|
|
556
|
-
this.$additionalStep
|
|
557
|
-
);
|
|
558
|
-
}
|
|
559
|
-
|
|
560
|
-
onStatechanged(state: Player$State, old: Player$State) {
|
|
561
|
-
if (state.cc.sources !== old.cc.sources) {
|
|
562
|
-
this._rerenderLanguages(state.cc.sources);
|
|
563
|
-
this.changeLang(state.cc.lang);
|
|
564
|
-
} else if (state.cc.lang !== old.cc.lang) {
|
|
565
|
-
this.changeLang(state.cc.lang);
|
|
566
|
-
} else if (state.cc.timedata !== old.cc.timedata) {
|
|
567
|
-
this.onLoadingTimedata();
|
|
568
|
-
} else if (
|
|
569
|
-
state.cc.location !== old.cc.location ||
|
|
570
|
-
state.cc.fontFamily !== old.cc.fontFamily ||
|
|
571
|
-
state.cc.fontSize !== old.cc.fontSize ||
|
|
572
|
-
state.cc.bgcolor !== old.cc.bgcolor ||
|
|
573
|
-
state.cc.color !== old.cc.color
|
|
574
|
-
) {
|
|
575
|
-
this._refresh();
|
|
576
|
-
}
|
|
577
|
-
}
|
|
578
|
-
|
|
579
|
-
onLoadingTimedata() {
|
|
580
|
-
const cc = this.state.getSelectedCC();
|
|
581
|
-
const { $currentCustomTranslate, $translate } = this;
|
|
582
|
-
if ($currentCustomTranslate && $translate) {
|
|
583
|
-
removeClass($translate, PROGRESS_SETTINGS_CN);
|
|
584
|
-
$currentCustomTranslate.textContent = '';
|
|
585
|
-
if (cc && !cc.state) {
|
|
586
|
-
$currentCustomTranslate.textContent = cc.label;
|
|
587
|
-
}
|
|
588
|
-
}
|
|
589
|
-
this.onTimeupdate();
|
|
590
|
-
}
|
|
591
|
-
|
|
592
|
-
changeLang(lang: ?string) {
|
|
593
|
-
each(this.$captions, (el) => removeClass(el, ITEM_CHECKED_CN));
|
|
594
|
-
each(this.$translatableCaptions, (el) => removeClass(el, ITEM_CHECKED_CN));
|
|
595
|
-
|
|
596
|
-
const textTracks = this.player.getTextTracks();
|
|
597
|
-
|
|
598
|
-
if (textTracks?.length) {
|
|
599
|
-
each(textTracks, (track) => {
|
|
600
|
-
track.mode = 'disabled';
|
|
601
|
-
});
|
|
602
|
-
}
|
|
603
|
-
|
|
604
|
-
const sources = this.state.getCCSources();
|
|
605
|
-
const alreadyTranslatedSources = filter(
|
|
606
|
-
sources,
|
|
607
|
-
(s) =>
|
|
608
|
-
s.state !== UNTRANSLATED_TIMEDATA_STATUS &&
|
|
609
|
-
s.state !== TRANSLATABLE_TIMEDATA_STATUS
|
|
610
|
-
);
|
|
611
|
-
|
|
612
|
-
const { $currentCustomTranslate, $translate } = this;
|
|
613
|
-
if ($currentCustomTranslate) {
|
|
614
|
-
$currentCustomTranslate.textContent = '';
|
|
615
|
-
}
|
|
616
|
-
|
|
617
|
-
let idx = findIndex(alreadyTranslatedSources, (d) => d.srclang === lang);
|
|
618
|
-
|
|
619
|
-
if (idx === -1) {
|
|
620
|
-
const translatableSources = filter(sources, (s) => !s.state);
|
|
621
|
-
idx = findIndex(translatableSources, (d) => d.srclang === lang);
|
|
622
|
-
if (this.$translatableCaptions[idx]) {
|
|
623
|
-
addClass(this.$translatableCaptions[idx], ITEM_CHECKED_CN);
|
|
624
|
-
}
|
|
625
|
-
if ($currentCustomTranslate && translatableSources[idx]) {
|
|
626
|
-
$currentCustomTranslate.textContent = this.$t('translating');
|
|
627
|
-
}
|
|
628
|
-
if ($translate) {
|
|
629
|
-
addClass($translate, PROGRESS_SETTINGS_CN);
|
|
630
|
-
}
|
|
631
|
-
} else {
|
|
632
|
-
if (this.$captions[idx]) {
|
|
633
|
-
addClass(this.$captions[idx], ITEM_CHECKED_CN);
|
|
634
|
-
}
|
|
635
|
-
if (!lang) {
|
|
636
|
-
removeClass(this.$text, TEXT_VISIBLE_CN);
|
|
637
|
-
}
|
|
638
|
-
}
|
|
639
|
-
}
|
|
640
|
-
|
|
641
|
-
onTimeupdate() {
|
|
642
|
-
const lang = this.state.getCCLang();
|
|
643
|
-
const timedata = this.state.getCCTimeData();
|
|
644
|
-
if (!lang) {
|
|
645
|
-
return;
|
|
646
|
-
}
|
|
647
|
-
|
|
648
|
-
if (isEmpty(timedata)) {
|
|
649
|
-
removeClass(this.$text, TEXT_VISIBLE_CN);
|
|
650
|
-
return;
|
|
651
|
-
}
|
|
652
|
-
|
|
653
|
-
const ct = this.player.getCurrentTime();
|
|
654
|
-
const item = find(timedata, ({ from, to }) => inRange(ct, from, to));
|
|
655
|
-
|
|
656
|
-
if (item) {
|
|
657
|
-
this.$textHolder.innerHTML = item.text.split('\n').join('<br>');
|
|
658
|
-
addClass(this.$text, TEXT_VISIBLE_CN);
|
|
659
|
-
} else {
|
|
660
|
-
removeClass(this.$text, TEXT_VISIBLE_CN);
|
|
661
|
-
}
|
|
662
|
-
}
|
|
663
|
-
|
|
664
|
-
onShowpopup($selector: ?HTMLElement) {
|
|
665
|
-
if ($selector === this.$selector) {
|
|
666
|
-
if (hasClass(this.$selector, SELECTOR_MAIN_STEP_CN)) {
|
|
667
|
-
openerHeightChecker(this.player, this.$mainStep);
|
|
668
|
-
} else if (hasClass(this.$selector, SELECTOR_SETTINGS_STEP_CN)) {
|
|
669
|
-
openerHeightChecker(this.player, this.$settingsStep);
|
|
670
|
-
} else if (hasClass(this.$selector, SELECTOR_ADDITIONAL_STEP_CN)) {
|
|
671
|
-
openerHeightChecker(this.player, this.$additionalStep);
|
|
672
|
-
}
|
|
673
|
-
}
|
|
674
|
-
}
|
|
675
|
-
|
|
676
|
-
_toMainPage() {
|
|
677
|
-
addClass(this.$selector, SELECTOR_MAIN_STEP_CN);
|
|
678
|
-
removeClass(this.$selector, SELECTOR_SETTINGS_STEP_CN);
|
|
679
|
-
removeClass(this.$selector, SELECTOR_ADDITIONAL_STEP_CN);
|
|
680
|
-
removeClass(this.$selector, SELECTOR_TRANSLATE_STEP_CN);
|
|
681
|
-
|
|
682
|
-
openerHeightChecker(this.player, this.$mainStep);
|
|
683
|
-
|
|
684
|
-
// Accessability: Focus on first item of main page
|
|
685
|
-
const mainStepItems = document.querySelectorAll(`.${MAIN_STEP_CN} > .${ITEM_CN}`);
|
|
686
|
-
if (mainStepItems[0]) mainStepItems[0].focus();
|
|
687
|
-
}
|
|
688
|
-
|
|
689
|
-
_toSettingsPage() {
|
|
690
|
-
addClass(this.$selector, SELECTOR_SETTINGS_STEP_CN);
|
|
691
|
-
removeClass(this.$selector, SELECTOR_MAIN_STEP_CN);
|
|
692
|
-
removeClass(this.$selector, SELECTOR_ADDITIONAL_STEP_CN);
|
|
693
|
-
removeClass(this.$selector, SELECTOR_TRANSLATE_STEP_CN);
|
|
694
|
-
|
|
695
|
-
openerHeightChecker(this.player, this.$settingsStep);
|
|
696
|
-
|
|
697
|
-
// Accessability: Focus on first item of settings page
|
|
698
|
-
const backBtn = document.querySelector(`.${BACK_BTN_CN}`);
|
|
699
|
-
backBtn.focus();
|
|
700
|
-
}
|
|
701
|
-
|
|
702
|
-
_toAdditionalPage() {
|
|
703
|
-
addClass(this.$selector, SELECTOR_ADDITIONAL_STEP_CN);
|
|
704
|
-
removeClass(this.$selector, SELECTOR_SETTINGS_STEP_CN);
|
|
705
|
-
removeClass(this.$selector, SELECTOR_MAIN_STEP_CN);
|
|
706
|
-
removeClass(this.$selector, SELECTOR_TRANSLATE_STEP_CN);
|
|
707
|
-
|
|
708
|
-
const items = toArray(this.$additionalStepWrapper.childNodes);
|
|
709
|
-
each(items, (btn) => this.$additionalStepWrapper.removeChild(btn));
|
|
710
|
-
|
|
711
|
-
openerHeightChecker(this.player, this.$additionalStep);
|
|
712
|
-
}
|
|
713
|
-
|
|
714
|
-
_toTranslatePage() {
|
|
715
|
-
if (this.state.isTranslatingCC()) {
|
|
716
|
-
return;
|
|
717
|
-
}
|
|
718
|
-
|
|
719
|
-
addClass(this.$selector, SELECTOR_TRANSLATE_STEP_CN);
|
|
720
|
-
removeClass(this.$selector, SELECTOR_SETTINGS_STEP_CN);
|
|
721
|
-
removeClass(this.$selector, SELECTOR_MAIN_STEP_CN);
|
|
722
|
-
removeClass(this.$selector, SELECTOR_ADDITIONAL_STEP_CN);
|
|
723
|
-
|
|
724
|
-
openerHeightChecker(this.player, this.$settingsStep);
|
|
725
|
-
|
|
726
|
-
// Accessability: Focus on first item of translate page
|
|
727
|
-
const backBtn = document.querySelector(`.${BACK_BTN_CN}`);
|
|
728
|
-
backBtn.focus();
|
|
729
|
-
}
|
|
730
|
-
|
|
731
|
-
_prepareAdditionalPage(
|
|
732
|
-
tkey: $Keys<Player$Translation>,
|
|
733
|
-
fnc: $Keys<StateEntity>,
|
|
734
|
-
event: string,
|
|
735
|
-
options: CCOption<any>[]
|
|
736
|
-
) {
|
|
737
|
-
this._toAdditionalPage();
|
|
738
|
-
this.$additionalBackText.textContent = this.$t(tkey);
|
|
739
|
-
// Accessability: Focus on additional menu back button
|
|
740
|
-
this.$toSettings.focus();
|
|
741
|
-
const buttons = [];
|
|
742
|
-
|
|
743
|
-
// $FlowFixMe
|
|
744
|
-
const value = this.state[fnc]();
|
|
745
|
-
|
|
746
|
-
each(options, (c) => {
|
|
747
|
-
const button = createElement(
|
|
748
|
-
'button',
|
|
749
|
-
{ type: 'button', class: ITEM_CN },
|
|
750
|
-
this.$additionalStepWrapper
|
|
751
|
-
);
|
|
752
|
-
const key = c.key;
|
|
753
|
-
button.textContent = key ? this.$t(key) : c.label;
|
|
754
|
-
|
|
755
|
-
if (value === c.value) {
|
|
756
|
-
addClass(button, ITEM_CHECKED_CN);
|
|
757
|
-
}
|
|
758
|
-
|
|
759
|
-
this.addEvent(button, 'click', () => {
|
|
760
|
-
each(buttons, (b) => removeClass(b, ITEM_CHECKED_CN));
|
|
761
|
-
addClass(button, ITEM_CHECKED_CN);
|
|
762
|
-
this.bus.emit(event, c.value);
|
|
763
|
-
this._toSettingsPage();
|
|
764
|
-
});
|
|
765
|
-
buttons.push(button);
|
|
766
|
-
});
|
|
767
|
-
}
|
|
768
|
-
|
|
769
|
-
_toColorPage() {
|
|
770
|
-
this._prepareAdditionalPage(
|
|
771
|
-
'settings-fontcolor',
|
|
772
|
-
'getCCTextColor',
|
|
773
|
-
'cccolor',
|
|
774
|
-
CC_COLORS
|
|
775
|
-
);
|
|
776
|
-
}
|
|
777
|
-
|
|
778
|
-
_toBackgroundColorPage() {
|
|
779
|
-
this._prepareAdditionalPage(
|
|
780
|
-
'settings-background',
|
|
781
|
-
'getCCBgColor',
|
|
782
|
-
'ccbgcolor',
|
|
783
|
-
CC_COLORS
|
|
784
|
-
);
|
|
785
|
-
}
|
|
786
|
-
|
|
787
|
-
_toSizesPage() {
|
|
788
|
-
this._prepareAdditionalPage(
|
|
789
|
-
'settings-fontsize',
|
|
790
|
-
'getCCFontSize',
|
|
791
|
-
'ccfontsize',
|
|
792
|
-
CC_FONT_SIZES
|
|
793
|
-
);
|
|
794
|
-
}
|
|
795
|
-
|
|
796
|
-
_toFontFamilyPage() {
|
|
797
|
-
this._prepareAdditionalPage(
|
|
798
|
-
'settings-fontfamily',
|
|
799
|
-
'getCCFontFamily',
|
|
800
|
-
'ccfontfamily',
|
|
801
|
-
CC_FONT_FAMILIES
|
|
802
|
-
);
|
|
803
|
-
}
|
|
804
|
-
|
|
805
|
-
_toLocationsPage() {
|
|
806
|
-
this._prepareAdditionalPage(
|
|
807
|
-
'settings-captionlocations',
|
|
808
|
-
'getCCLocation',
|
|
809
|
-
'cclocation',
|
|
810
|
-
CC_LOCATIONS
|
|
811
|
-
);
|
|
812
|
-
}
|
|
813
|
-
|
|
814
|
-
_detectLabel(options: CCOption<any>[], value: string): string {
|
|
815
|
-
const option = find(options, (c) => c.value === value);
|
|
816
|
-
if (!option) {
|
|
817
|
-
return '';
|
|
818
|
-
}
|
|
819
|
-
const key = option.key;
|
|
820
|
-
return key ? this.$t(key) : option.label || '';
|
|
821
|
-
}
|
|
822
|
-
|
|
823
|
-
_refresh() {
|
|
824
|
-
const color = this.state.getCCTextColor();
|
|
825
|
-
const bgcolor = this.state.getCCBgColor();
|
|
826
|
-
const fontSize = this.state.getCCFontSize();
|
|
827
|
-
const fontFamily = this.state.getCCFontFamily();
|
|
828
|
-
|
|
829
|
-
this.$textHolder.style.color = color;
|
|
830
|
-
this.$textHolder.style.backgroundColor = bgcolor;
|
|
831
|
-
this.$textHolder.style.fontSize = fontSize;
|
|
832
|
-
this.$textHolder.style.fontFamily = fontFamily;
|
|
833
|
-
|
|
834
|
-
this.$currentColor.textContent = this._detectLabel(CC_COLORS, color);
|
|
835
|
-
this.$currentBgColor.textContent = this._detectLabel(CC_COLORS, bgcolor);
|
|
836
|
-
this.$currentSize.textContent = this._detectLabel(CC_FONT_SIZES, fontSize);
|
|
837
|
-
this.$currentFamily.textContent = this._detectLabel(
|
|
838
|
-
CC_FONT_FAMILIES,
|
|
839
|
-
fontFamily
|
|
840
|
-
);
|
|
841
|
-
if (this.$currentLocation) {
|
|
842
|
-
this.$currentLocation.textContent = this._detectLabel(
|
|
843
|
-
CC_LOCATIONS,
|
|
844
|
-
this.state.getCCLocation()
|
|
845
|
-
);
|
|
846
|
-
}
|
|
847
|
-
}
|
|
848
|
-
|
|
849
|
-
getElement() {
|
|
850
|
-
return this.$el;
|
|
851
|
-
}
|
|
852
|
-
|
|
853
|
-
getOuter() {
|
|
854
|
-
return this.$text;
|
|
855
|
-
}
|
|
856
|
-
|
|
857
|
-
destroy() {
|
|
858
|
-
super.destroy();
|
|
859
|
-
if (this.$el.parentNode) {
|
|
860
|
-
this.$el.parentNode.removeChild(this.$el);
|
|
861
|
-
}
|
|
862
|
-
if (this.$text.parentNode) {
|
|
863
|
-
this.$text.parentNode.removeChild(this.$text);
|
|
864
|
-
}
|
|
865
|
-
}
|
|
866
|
-
}
|
|
867
|
-
|
|
868
|
-
function _createMore($parent: HTMLElement) {
|
|
869
|
-
addClass($parent, MORE_CN);
|
|
870
|
-
const span = createElement('span', { class: 'arrow' }, $parent);
|
|
871
|
-
createSvg(span, NEXT);
|
|
872
|
-
|
|
873
|
-
return span;
|
|
874
|
-
}
|