ravnur-player-public 3.4.2 → 3.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintignore +7 -0
- package/.eslintrc.js +206 -0
- package/.flowconfig +3 -0
- package/.vscode/extensions.json +7 -0
- package/.vscode/launch.json +37 -0
- package/.vscode/settings.json +4 -0
- package/README-Private.md +54 -0
- package/babel.config.js +28 -0
- package/bitbucket-pipelines.yml +61 -0
- package/cert.pem +23 -0
- package/demo/BaseM.mp4 +0 -0
- package/demo/HD.mp4 +0 -0
- package/demo/annotations.json +50 -0
- package/demo/annotations_ge.json +50 -0
- package/demo/base.mp3 +0 -0
- package/demo/cc_2125en.vtt +4958 -0
- package/demo/cc_en.vtt +171 -0
- package/demo/cc_ge.vtt +178 -0
- package/demo/chapters_en.vtt +38 -0
- package/demo/chapters_ge.vtt +5 -0
- package/demo/chapters_ge1.json +23 -0
- package/demo/hls/audio/stereo/en/128kbit.m3u8 +912 -0
- package/demo/hls/audio/stereo/none/128kbit.m3u8 +912 -0
- package/demo/hls/audio/surround/en/320kbit.m3u8 +912 -0
- package/demo/hls/playlist.m3u8 +31 -0
- package/demo/hls/video/10000kbit.m3u8 +894 -0
- package/demo/hls/video/1100kbit.m3u8 +894 -0
- package/demo/hls/video/1500kbit.m3u8 +894 -0
- package/demo/hls/video/250kbit.m3u8 +894 -0
- package/demo/hls/video/4000kbit.m3u8 +894 -0
- package/demo/hls/video/500kbit.m3u8 +894 -0
- package/demo/hls/video/6000kbit.m3u8 +894 -0
- package/demo/hls/video/800kbit.m3u8 +894 -0
- package/demo/hls.js +5 -0
- package/demo/hls.js.map +1 -0
- package/demo/hls.min.js +2 -0
- package/demo/hls.min.js.map +1 -0
- package/demo/playlist.m3u8 +31 -0
- 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 +4532 -0
- package/demo/shaka/shaka-player.foo.debug.externs.js +3886 -0
- package/demo/shaka/shaka-player.foo.debug.js +1746 -0
- package/demo/shaka/shaka-player.foo.debug.map +8 -0
- package/demo/shaka/wrapper.js +7 -0
- package/demo/test.html +458 -0
- package/dist/RavnurMediaPlayer.min.js +1 -1
- package/dist/cdn/RavnurMediaPlayer.min.js +1 -1
- package/jest.config.js +4 -0
- package/key.pem +27 -0
- package/lib/es5.js +344 -0
- 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 +225 -0
- package/package.json +1 -5
- package/server.js +29 -0
- package/src/config/cc.js +56 -0
- package/src/config/i18n.js +101 -0
- package/src/config/options.js +123 -0
- package/src/config/playlist.js +9 -0
- package/src/config/source.js +23 -0
- package/src/config/statuses.js +8 -0
- package/src/config/styles.js +16 -0
- package/src/entity.js +27 -0
- package/src/events.js +5 -0
- package/src/extensions/annotations.js +142 -0
- package/src/extensions/audio-tarcks.js +115 -0
- package/src/extensions/backward.js +45 -0
- package/src/extensions/base.js +73 -0
- package/src/extensions/bottom-next.js +50 -0
- package/src/extensions/bottom-prev.js +50 -0
- package/src/extensions/buffering.js +78 -0
- package/src/extensions/c2pa.js +350 -0
- package/src/extensions/caption-search.js +230 -0
- package/src/extensions/cc.js +874 -0
- package/src/extensions/crawl.js +118 -0
- package/src/extensions/download.js +411 -0
- package/src/extensions/error.js +47 -0
- package/src/extensions/forward.js +44 -0
- package/src/extensions/fullscreen.js +84 -0
- package/src/extensions/help.js +201 -0
- package/src/extensions/helpers/FileSaver.js +157 -0
- package/src/extensions/helpers/clickOpener.js +180 -0
- package/src/extensions/helpers/opener.js +30 -0
- package/src/extensions/helpers/openerHeightChecker.js +13 -0
- package/src/extensions/helpers/popover.js +33 -0
- package/src/extensions/helpers/popoverPosition.js +30 -0
- package/src/extensions/helpers/scrollIntoView.js +9 -0
- package/src/extensions/helpers/storage.js +20 -0
- package/src/extensions/helpers/textContent.js +6 -0
- package/src/extensions/helpers/timeCodeToSeconds.js +44 -0
- package/src/extensions/helpers/transport.js +43 -0
- package/src/extensions/helpers/vtt-loader.js +42 -0
- package/src/extensions/index.js +87 -0
- package/src/extensions/live.js +76 -0
- package/src/extensions/mux.js +57 -0
- package/src/extensions/next-frame.js +44 -0
- package/src/extensions/next.js +48 -0
- package/src/extensions/placeholder.js +241 -0
- package/src/extensions/play.js +102 -0
- package/src/extensions/poster.js +47 -0
- package/src/extensions/prev-frame.js +44 -0
- package/src/extensions/prev.js +48 -0
- package/src/extensions/progress.js +465 -0
- package/src/extensions/resizer.js +37 -0
- package/src/extensions/settings.js +367 -0
- package/src/extensions/theater.js +56 -0
- package/src/extensions/title.js +38 -0
- package/src/extensions/toc.js +334 -0
- package/src/extensions/volume.js +196 -0
- package/src/flash/FlashPlugin.js +301 -0
- package/src/flash/MediaElement.js +361 -0
- package/src/flash/plugins.js +32 -0
- package/src/flash-detector.js +66 -0
- package/src/helpers/$t.js +10 -0
- package/src/helpers/binder.js +11 -0
- package/src/helpers/isAndroid.js +5 -0
- package/src/helpers/isBlackBerry.js +5 -0
- package/src/helpers/isCanvasSupported.js +6 -0
- package/src/helpers/isIE.js +21 -0
- package/src/helpers/isMobile.js +10 -0
- package/src/helpers/isWindows.js +5 -0
- package/src/helpers/isWindowsPhone.js +5 -0
- package/src/helpers/isiOS.js +5 -0
- package/src/html5media.js +19 -0
- package/src/index.js +2 -0
- package/src/logger.js +31 -0
- package/src/microevent.js +65 -0
- package/src/normalize-options.js +139 -0
- package/src/player.js +864 -0
- package/src/players/base.js +209 -0
- package/src/players/flash.js +172 -0
- package/src/players/hls.js +278 -0
- package/src/players/html.js +205 -0
- package/src/players/index.js +59 -0
- package/src/players/shaka.js +219 -0
- package/src/playlist.js +362 -0
- package/src/screenfull.js +121 -0
- package/src/state.js +474 -0
- package/src/static/es5.js +344 -0
- 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 +225 -0
- package/src/styles/bplaylist.css.js +124 -0
- package/src/styles/index.js +1966 -0
- package/src/styles/playlist.css.js +84 -0
- package/src/styles/rplaylist.css.js +98 -0
- package/src/svgs.js +111 -0
- package/src/types/Logger.js +10 -0
- package/src/types/Options.js +179 -0
- package/src/types/Playlist.js +3 -0
- package/src/types/Source.js +28 -0
- package/src/types/State.js +46 -0
- package/src/types/Styles.js +11 -0
- package/src/types/TimeData.js +8 -0
- package/src/types/Translation.js +69 -0
- package/src/utils/absolutizeUrl.js +9 -0
- package/src/utils/addClass.js +9 -0
- package/src/utils/addEvent.js +31 -0
- package/src/utils/addProperty.js +65 -0
- package/src/utils/appendChild.js +14 -0
- package/src/utils/buff2hex.js +5 -0
- package/src/utils/contains.js +33 -0
- package/src/utils/createElement.js +24 -0
- package/src/utils/each.js +34 -0
- package/src/utils/escapeHTML.js +8 -0
- package/src/utils/existy.js +4 -0
- package/src/utils/extend.js +17 -0
- package/src/utils/filter.js +16 -0
- package/src/utils/find.js +11 -0
- package/src/utils/findIndex.js +20 -0
- package/src/utils/first.js +5 -0
- package/src/utils/get.js +19 -0
- package/src/utils/has.js +5 -0
- package/src/utils/hasClass.js +6 -0
- package/src/utils/head.js +11 -0
- package/src/utils/inRange.js +16 -0
- package/src/utils/index.js +73 -0
- package/src/utils/isArray.js +4 -0
- package/src/utils/isBoolean.js +3 -0
- package/src/utils/isElement.js +7 -0
- package/src/utils/isEmpty.js +6 -0
- package/src/utils/isEqual.js +33 -0
- package/src/utils/isEqualBuffer.js +13 -0
- package/src/utils/isFunction.js +3 -0
- package/src/utils/isNotEmpty.js +5 -0
- package/src/utils/isObject.js +5 -0
- package/src/utils/isString.js +9 -0
- package/src/utils/last.js +4 -0
- package/src/utils/map.js +11 -0
- package/src/utils/negate.js +8 -0
- package/src/utils/noop.js +1 -0
- package/src/utils/notExisty.js +5 -0
- package/src/utils/reduce.js +8 -0
- package/src/utils/remove.js +7 -0
- package/src/utils/removeClass.js +8 -0
- package/src/utils/removeEvent.js +7 -0
- package/src/utils/toArray.js +7 -0
- package/src/utils/toggleClass.js +16 -0
- package/src/utils/uidGenerator.js +8 -0
- package/src/utils/upperFirst.js +4 -0
- package/tests/extensions/__snapshots__/download.spec.js.snap +226 -0
- package/tests/extensions/__snapshots__/fullscreen.spec.js.snap +30 -0
- package/tests/extensions/__snapshots__/title.spec.js.snap +16 -0
- package/tests/extensions/download.spec.js +111 -0
- package/tests/extensions/fullscreen.spec.js +56 -0
- package/tests/extensions/title.spec.js +35 -0
- package/tests/mocks/assets/BaseM.mp4 +0 -0
- package/tests/mocks/assets/hls.min.js +5 -0
- package/tests/mocks/assets/styleMock.js +1 -0
- package/tests/mocks/base-player-options.js +47 -0
- package/tests/mocks/sources.js +58 -0
- package/tests/mocks/timedata/cc_en.vtt +171 -0
- package/tests/mocks/timedata/cc_ge.vtt +178 -0
- package/tests/utils/wait.js +1 -0
- package/webpack.config.js +78 -0
- package/dist/.DS_Store +0 -0
- package/dist/cdn/.DS_Store +0 -0
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
import BaseExtension from './base';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
createElement,
|
|
5
|
+
toggleClass,
|
|
6
|
+
each,
|
|
7
|
+
toArray,
|
|
8
|
+
filter,
|
|
9
|
+
isEmpty,
|
|
10
|
+
removeClass,
|
|
11
|
+
addClass,
|
|
12
|
+
inRange,
|
|
13
|
+
findIndex,
|
|
14
|
+
hasClass
|
|
15
|
+
} from '../utils';
|
|
16
|
+
|
|
17
|
+
import binder from '../helpers/binder';
|
|
18
|
+
import opener from './helpers/clickOpener';
|
|
19
|
+
import popover from './helpers/popover';
|
|
20
|
+
import { secondsToTime } from './helpers/timeCodeToSeconds';
|
|
21
|
+
import createSvg, { SEARCH, CLEAR } from '../svgs';
|
|
22
|
+
import scrollIntoView from './helpers/scrollIntoView';
|
|
23
|
+
import textContent from './helpers/textContent';
|
|
24
|
+
|
|
25
|
+
const CN = 'rmp-ext-search';
|
|
26
|
+
const HIDDEN_CN = 'rmp-ext-search--hidden';
|
|
27
|
+
const BUTTON_CN = `${CN}__button`;
|
|
28
|
+
const SELECTOR_CN = `${CN}__selector`;
|
|
29
|
+
const SELECTOR_OPEN_CN = `${SELECTOR_CN}--open`;
|
|
30
|
+
const CAPTIONS_CN = `${CN}__captions`;
|
|
31
|
+
const INPUT_CN = `${CN}__input`;
|
|
32
|
+
const ITEM_CN = `${CN}__item`;
|
|
33
|
+
const CURRENT_ITEM_CN = `${ITEM_CN}--current`;
|
|
34
|
+
const CC_TIME_CN = `${CN}__cc-time`;
|
|
35
|
+
const CC_TEXT_CN = `${CN}__cc-text`;
|
|
36
|
+
const CC_CLEAR_CN = `${CN}__cc-clear`;
|
|
37
|
+
|
|
38
|
+
export default class CaptionSearchExtension extends BaseExtension {
|
|
39
|
+
$el;
|
|
40
|
+
filter = '';
|
|
41
|
+
|
|
42
|
+
constructor(player, state, options) {
|
|
43
|
+
super(player, state, options, ['statechanged', 'timeupdate', 'showpopup', 'loadedmetadata', 'canplaythrough']);
|
|
44
|
+
this.logger.debug('search:extension:creating');
|
|
45
|
+
|
|
46
|
+
this.render();
|
|
47
|
+
this.init();
|
|
48
|
+
binder(this, ['onTimeupdate']);
|
|
49
|
+
|
|
50
|
+
this.logger.debug('search:extension:created');
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
render() {
|
|
54
|
+
/** @type {HTMLMediaElement} */
|
|
55
|
+
this.$el = createElement('div', { class: CN });
|
|
56
|
+
|
|
57
|
+
this.$button = createElement('button', { type: 'button', class: BUTTON_CN }, this.$el);
|
|
58
|
+
|
|
59
|
+
this.$selector = createElement('div', { class: SELECTOR_CN }, this.$el);
|
|
60
|
+
|
|
61
|
+
this.$captions = createElement('div', { class: CAPTIONS_CN }, this.$selector);
|
|
62
|
+
this.$input = createElement('input', { class: INPUT_CN, placeholder: this.$t('caption-search') }, this.$selector);
|
|
63
|
+
this.$clearBtn = createElement('button', { class: `${CC_CLEAR_CN} ${HIDDEN_CN}` }, this.$selector);
|
|
64
|
+
|
|
65
|
+
createSvg(this.$clearBtn, CLEAR);
|
|
66
|
+
createSvg(this.$button, SEARCH);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
init() {
|
|
70
|
+
const $button = this.$button;
|
|
71
|
+
const $selector = this.$selector;
|
|
72
|
+
const reposition = false;
|
|
73
|
+
const closeOnClick = false;
|
|
74
|
+
const heightControl = false;
|
|
75
|
+
|
|
76
|
+
popover(this, { $button, text: this.$t('caption-search') } );
|
|
77
|
+
opener(this, { $button, $selector, SELECTOR_OPEN_CN, reposition, closeOnClick, heightControl });
|
|
78
|
+
|
|
79
|
+
this.addEvent(this.$input, 'input', () => {
|
|
80
|
+
this.filter = this.$input.value;
|
|
81
|
+
this.renderCaptions();
|
|
82
|
+
|
|
83
|
+
if (this.$input.value) {
|
|
84
|
+
this.$clearBtn.classList.remove(HIDDEN_CN);
|
|
85
|
+
} else {
|
|
86
|
+
this.$clearBtn.classList.add(HIDDEN_CN);
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
this.$clearBtn.addEventListener('click', () => {
|
|
91
|
+
this.$input.value = '';
|
|
92
|
+
this.filter = '';
|
|
93
|
+
this.renderCaptions();
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
onStatechanged(state, old) {
|
|
98
|
+
if (state.cc.lang !== old.cc.lang) {
|
|
99
|
+
this.handleCaptionLanguageChanged(state.cc.lang);
|
|
100
|
+
} else if ( state.cc.timedata !== old.cc.timedata ) {
|
|
101
|
+
this.handleTimeDataChanged();
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
onCanplaythrough() {
|
|
106
|
+
this.handleTimeDataChanged();
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
onLoadedmetadata() {
|
|
110
|
+
this.handleTimeDataChanged();
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
handleCaptionLanguageChanged(lang) {
|
|
114
|
+
toggleClass(this.$el, HIDDEN_CN, !lang);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
handleTimeDataChanged() {
|
|
118
|
+
const lang = this.state.getCCLang();
|
|
119
|
+
this.handleCaptionLanguageChanged(lang);
|
|
120
|
+
this.renderCaptions();
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
filteredCaptions() {
|
|
124
|
+
const r = new RegExp(escapeRegExp(this.filter), 'ig');
|
|
125
|
+
return filter(this.state.getCCTimeData(), td => {
|
|
126
|
+
r.lastIndex = 0;
|
|
127
|
+
return r.test(td.text);
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
renderCaptions() {
|
|
132
|
+
const duration = this.player.getDuration();
|
|
133
|
+
if (!duration) {
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
const hasHour = duration > 3600;
|
|
137
|
+
each(toArray(this.$captions.childNodes), btn => this.$captions.removeChild(btn) );
|
|
138
|
+
|
|
139
|
+
const list = this.filteredCaptions();
|
|
140
|
+
each(list, caption => {
|
|
141
|
+
const item = createElement('button', { type: 'button', class: ITEM_CN, id: _id(caption.id) }, this.$captions);
|
|
142
|
+
const time = createElement('span', { class: CC_TIME_CN }, item);
|
|
143
|
+
time.textContent = secondsToTime(caption.from, hasHour);
|
|
144
|
+
const captionText = textContent(caption.text);
|
|
145
|
+
const text = createElement('span', { class: CC_TEXT_CN, title: captionText }, item);
|
|
146
|
+
text.textContent = captionText;
|
|
147
|
+
|
|
148
|
+
this.addEvent(item, 'click', (e) => {
|
|
149
|
+
e.preventDefault();
|
|
150
|
+
e.stopPropagation();
|
|
151
|
+
const isPaused = this.player.isPaused();
|
|
152
|
+
this.player.setCurrentTime(caption.from);
|
|
153
|
+
if (isPaused) {
|
|
154
|
+
this.player.play();
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
onShowpopup() {
|
|
161
|
+
this.onTimeupdate();
|
|
162
|
+
this.scrollToCurrentCaption();
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
scrollToCurrentCaption() {
|
|
166
|
+
const timeData = this.filteredCaptions();
|
|
167
|
+
const ct = this.player.getCurrentTime();
|
|
168
|
+
const idx = findIndex(timeData, ({ from, to }) => inRange(ct, from, to));
|
|
169
|
+
|
|
170
|
+
if (idx > -1) {
|
|
171
|
+
const btns = toArray(this.$captions.childNodes);
|
|
172
|
+
const btn = btns[Math.max(0, idx - 2)];
|
|
173
|
+
if (btn) {
|
|
174
|
+
scrollIntoView(btn, this.$captions);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
onTimeupdate() {
|
|
180
|
+
const timeData = this.filteredCaptions();
|
|
181
|
+
|
|
182
|
+
if (isEmpty(timeData)) {
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
const ct = this.player.getCurrentTime();
|
|
187
|
+
const idx = findIndex(timeData, ({ from, to }) => inRange(ct, from, to));
|
|
188
|
+
|
|
189
|
+
if (idx > -1) {
|
|
190
|
+
const item = timeData[idx];
|
|
191
|
+
const btn = document.getElementById(_id(item.id));
|
|
192
|
+
|
|
193
|
+
if (!btn) {
|
|
194
|
+
each(toArray(this.$captions.childNodes), btn => removeClass(btn, CURRENT_ITEM_CN));
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
if (hasClass(btn, CURRENT_ITEM_CN)) {
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
// this.scrollToCurrentCaption();
|
|
203
|
+
each(toArray(this.$captions.childNodes), btn => removeClass(btn, CURRENT_ITEM_CN));
|
|
204
|
+
addClass(btn, CURRENT_ITEM_CN);
|
|
205
|
+
} else {
|
|
206
|
+
each(toArray(this.$captions.childNodes), btn => removeClass(btn, CURRENT_ITEM_CN));
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
getElement() {
|
|
211
|
+
return this.$el;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
destroy() {
|
|
215
|
+
super.destroy();
|
|
216
|
+
const parent = this.$el.parentNode;
|
|
217
|
+
if (parent instanceof HTMLElement) {
|
|
218
|
+
parent.removeChild(this.$el);
|
|
219
|
+
}
|
|
220
|
+
this.$el = null;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
function escapeRegExp(text) {
|
|
225
|
+
return text.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
function _id(id) {
|
|
229
|
+
return `cc-${id}`;
|
|
230
|
+
}
|