Converted to SASS/SCSS
This commit is contained in:
@ -109,7 +109,10 @@ const captions = {
|
||||
}
|
||||
|
||||
// Only get accepted kinds
|
||||
return Array.from(this.media.textTracks || []).filter(track => ['captions', 'subtitles'].includes(track.kind));
|
||||
return Array.from(this.media.textTracks || []).filter(track => [
|
||||
'captions',
|
||||
'subtitles',
|
||||
].includes(track.kind));
|
||||
},
|
||||
|
||||
// Get the current track for the current language
|
||||
|
33
src/js/controls.js
vendored
33
src/js/controls.js
vendored
@ -46,7 +46,10 @@ const controls = {
|
||||
}
|
||||
|
||||
// Insert new one
|
||||
styleSheet.insertRule([selector, styles].join(' '));
|
||||
styleSheet.insertRule([
|
||||
selector,
|
||||
styles,
|
||||
].join(' '));
|
||||
},
|
||||
|
||||
// Get icon URL
|
||||
@ -417,7 +420,10 @@ const controls = {
|
||||
|
||||
// Show/hide the tooltip
|
||||
// If the event is a moues in/out and percentage is inside bounds
|
||||
if (utils.is.event(event) && ['mouseenter', 'mouseleave'].includes(event.type)) {
|
||||
if (utils.is.event(event) && [
|
||||
'mouseenter',
|
||||
'mouseleave',
|
||||
].includes(event.type)) {
|
||||
utils.toggleClass(this.elements.display.seekTooltip, visible, event.type === 'mouseenter');
|
||||
}
|
||||
},
|
||||
@ -701,7 +707,15 @@ const controls = {
|
||||
|
||||
// Set the default speeds
|
||||
if (!utils.is.object(this.options.speed) || !Object.keys(this.options.speed).length) {
|
||||
this.options.speed = [0.5, 0.75, 1, 1.25, 1.5, 1.75, 2];
|
||||
this.options.speed = [
|
||||
0.5,
|
||||
0.75,
|
||||
1,
|
||||
1.25,
|
||||
1.5,
|
||||
1.75,
|
||||
2,
|
||||
];
|
||||
}
|
||||
|
||||
// Set options if passed and filter based on config
|
||||
@ -841,7 +855,10 @@ const controls = {
|
||||
// Restore auto height/width
|
||||
const restore = e => {
|
||||
// We're only bothered about height and width on the container
|
||||
if (e.target !== container || !['width', 'height'].includes(e.propertyName)) {
|
||||
if (e.target !== container || ![
|
||||
'width',
|
||||
'height',
|
||||
].includes(e.propertyName)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1211,7 +1228,13 @@ const controls = {
|
||||
if (this.config.tooltips.controls) {
|
||||
const labels = utils.getElements.call(
|
||||
this,
|
||||
[this.config.selectors.controls.wrapper, ' ', this.config.selectors.labels, ' .', this.config.classNames.hidden].join('')
|
||||
[
|
||||
this.config.selectors.controls.wrapper,
|
||||
' ',
|
||||
this.config.selectors.labels,
|
||||
' .',
|
||||
this.config.classNames.hidden,
|
||||
].join('')
|
||||
);
|
||||
|
||||
Array.from(labels).forEach(label => {
|
||||
|
@ -61,7 +61,17 @@ const defaults = {
|
||||
// Quality default
|
||||
quality: {
|
||||
default: 'default',
|
||||
options: ['hd2160', 'hd1440', 'hd1080', 'hd720', 'large', 'medium', 'small', 'tiny', 'default'],
|
||||
options: [
|
||||
'hd2160',
|
||||
'hd1440',
|
||||
'hd1080',
|
||||
'hd720',
|
||||
'large',
|
||||
'medium',
|
||||
'small',
|
||||
'tiny',
|
||||
'default',
|
||||
],
|
||||
},
|
||||
|
||||
// Set loops
|
||||
@ -74,7 +84,15 @@ const defaults = {
|
||||
// Speed default and options to display
|
||||
speed: {
|
||||
selected: 1,
|
||||
options: [0.5, 0.75, 1, 1.25, 1.5, 1.75, 2],
|
||||
options: [
|
||||
0.5,
|
||||
0.75,
|
||||
1,
|
||||
1.25,
|
||||
1.5,
|
||||
1.75,
|
||||
2,
|
||||
],
|
||||
},
|
||||
|
||||
// Keyboard shortcut settings
|
||||
@ -108,8 +126,25 @@ const defaults = {
|
||||
},
|
||||
|
||||
// Default controls
|
||||
controls: ['play-large', 'play', 'progress', 'current-time', 'mute', 'volume', 'captions', 'settings', 'pip', 'airplay', 'fullscreen'],
|
||||
settings: ['captions', 'quality', 'speed', 'loop'],
|
||||
controls: [
|
||||
'play-large',
|
||||
'play',
|
||||
'progress',
|
||||
'current-time',
|
||||
'mute',
|
||||
'volume',
|
||||
'captions',
|
||||
'settings',
|
||||
'pip',
|
||||
'airplay',
|
||||
'fullscreen',
|
||||
],
|
||||
settings: [
|
||||
'captions',
|
||||
'quality',
|
||||
'speed',
|
||||
'loop',
|
||||
],
|
||||
|
||||
// Localisation
|
||||
i18n: {
|
||||
|
@ -12,7 +12,13 @@ const prefix = (() => {
|
||||
value = '';
|
||||
} else {
|
||||
// Check for fullscreen support by vendor prefix
|
||||
['webkit', 'o', 'moz', 'ms', 'khtml'].some(pre => {
|
||||
[
|
||||
'webkit',
|
||||
'o',
|
||||
'moz',
|
||||
'ms',
|
||||
'khtml',
|
||||
].some(pre => {
|
||||
if (utils.is.function(document[`${pre}CancelFullScreen`])) {
|
||||
value = pre;
|
||||
return true;
|
||||
|
@ -46,7 +46,29 @@ const listeners = {
|
||||
// Reset on keyup
|
||||
if (pressed) {
|
||||
// Which keycodes should we prevent default
|
||||
const preventDefault = [48, 49, 50, 51, 52, 53, 54, 56, 57, 32, 75, 38, 40, 77, 39, 37, 70, 67, 73, 76, 79];
|
||||
const preventDefault = [
|
||||
48,
|
||||
49,
|
||||
50,
|
||||
51,
|
||||
52,
|
||||
53,
|
||||
54,
|
||||
56,
|
||||
57,
|
||||
32,
|
||||
75,
|
||||
38,
|
||||
40,
|
||||
77,
|
||||
39,
|
||||
37,
|
||||
70,
|
||||
67,
|
||||
73,
|
||||
76,
|
||||
79,
|
||||
];
|
||||
|
||||
// Check focused element
|
||||
// and if the focused element is not editable (e.g. text input)
|
||||
@ -325,7 +347,10 @@ const listeners = {
|
||||
|
||||
// Proxy events to container
|
||||
// Bubble up key events for Edge
|
||||
utils.on(this.media, this.config.events.concat(['keyup', 'keydown']).join(' '), event => {
|
||||
utils.on(this.media, this.config.events.concat([
|
||||
'keyup',
|
||||
'keydown',
|
||||
]).join(' '), event => {
|
||||
let detail = {};
|
||||
|
||||
// Get error details from media
|
||||
@ -499,7 +524,10 @@ const listeners = {
|
||||
|
||||
// Watch for cursor over controls so they don't hide when trying to interact
|
||||
utils.on(this.elements.controls, 'mousedown mouseup touchstart touchend touchcancel', event => {
|
||||
this.elements.controls.pressed = ['mousedown', 'touchstart'].includes(event.type);
|
||||
this.elements.controls.pressed = [
|
||||
'mousedown',
|
||||
'touchstart',
|
||||
].includes(event.type);
|
||||
});
|
||||
|
||||
// Focus in/out on controls
|
||||
|
@ -939,10 +939,20 @@ class Plyr {
|
||||
isEnterFullscreen = toggle.type === 'enterfullscreen';
|
||||
|
||||
// Whether to show controls
|
||||
show = ['mouseenter', 'mousemove', 'touchstart', 'touchmove', 'focusin'].includes(toggle.type);
|
||||
show = [
|
||||
'mouseenter',
|
||||
'mousemove',
|
||||
'touchstart',
|
||||
'touchmove',
|
||||
'focusin',
|
||||
].includes(toggle.type);
|
||||
|
||||
// Delay hiding on move events
|
||||
if (['mousemove', 'touchmove', 'touchend'].includes(toggle.type)) {
|
||||
if ([
|
||||
'mousemove',
|
||||
'touchmove',
|
||||
'touchend',
|
||||
].includes(toggle.type)) {
|
||||
delay = 2000;
|
||||
}
|
||||
|
||||
|
@ -153,7 +153,10 @@ const ui = {
|
||||
|
||||
// Check if media is loading
|
||||
checkLoading(event) {
|
||||
this.loading = ['stalled', 'waiting'].includes(event.type);
|
||||
this.loading = [
|
||||
'stalled',
|
||||
'waiting',
|
||||
].includes(event.type);
|
||||
|
||||
// Clear timer
|
||||
clearTimeout(this.timers.loading);
|
||||
|
Reference in New Issue
Block a user