aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSam Potts <sam@potts.es>2018-06-15 15:34:29 +1000
committerGitHub <noreply@github.com>2018-06-15 15:34:29 +1000
commitd522e405942e060180c7f5b28c914028e94a917b (patch)
tree71986987e1c10eca00d6796551b2f065f9d07d03
parent3cd2b9a6c3ab2a7b530f1f0e6eae884ba41b9211 (diff)
parent6bff6b317d6adcd9f94c8d4d8ee225d39f784e0f (diff)
downloadplyr-d522e405942e060180c7f5b28c914028e94a917b.tar.lz
plyr-d522e405942e060180c7f5b28c914028e94a917b.tar.xz
plyr-d522e405942e060180c7f5b28c914028e94a917b.zip
Merge pull request #1034 from friday/remove-array-newline-rule
Suggestion: Remove array newline rule
-rw-r--r--.eslintrc.json4
-rw-r--r--src/js/captions.js12
-rw-r--r--src/js/config/defaults.js16
-rw-r--r--src/js/controls.js38
-rw-r--r--src/js/fullscreen.js6
-rw-r--r--src/js/i18n.js5
-rw-r--r--src/js/listeners.js47
-rw-r--r--src/js/plugins/vimeo.js9
-rw-r--r--src/js/plugins/youtube.js5
-rw-r--r--src/js/plyr.js12
-rw-r--r--src/js/ui.js5
-rw-r--r--src/js/utils/elements.js5
-rw-r--r--src/js/utils/urls.js5
13 files changed, 31 insertions, 138 deletions
diff --git a/.eslintrc.json b/.eslintrc.json
index c8dc1b74..1fc24ce3 100644
--- a/.eslintrc.json
+++ b/.eslintrc.json
@@ -32,9 +32,7 @@
"message": "Use local parameter instead."
}
],
- "no-param-reassign": [2, { "props": false }],
- "array-bracket-newline": [2, { "minItems": 2 }],
- "array-element-newline": [2, { "minItems": 2 }]
+ "no-param-reassign": [2, { "props": false }]
},
"parserOptions": {
"sourceType": "module"
diff --git a/src/js/captions.js b/src/js/captions.js
index 63674b95..fd2692f7 100644
--- a/src/js/captions.js
+++ b/src/js/captions.js
@@ -49,10 +49,7 @@ const captions = {
const src = track.getAttribute('src');
const url = parseUrl(src);
- if (url !== null && url.hostname !== window.location.href.hostname && [
- 'http:',
- 'https:',
- ].includes(url.protocol)) {
+ if (url !== null && url.hostname !== window.location.href.hostname && ['http:', 'https:'].includes(url.protocol)) {
fetch(src, 'blob')
.then(blob => {
track.setAttribute('src', window.URL.createObjectURL(blob));
@@ -277,10 +274,9 @@ const captions = {
const tracks = Array.from((this.media || {}).textTracks || []);
// For HTML5, use cache instead of current tracks when it exists (if captions.update is false)
// Filter out removed tracks and tracks that aren't captions/subtitles (for example metadata)
- return tracks.filter(track => !this.isHTML5 || update || this.captions.meta.has(track)).filter(track => [
- 'captions',
- 'subtitles',
- ].includes(track.kind));
+ return tracks
+ .filter(track => !this.isHTML5 || update || this.captions.meta.has(track))
+ .filter(track => ['captions', 'subtitles'].includes(track.kind));
},
// Match tracks based on languages and get the first
diff --git a/src/js/config/defaults.js b/src/js/config/defaults.js
index 1789b026..34fb5519 100644
--- a/src/js/config/defaults.js
+++ b/src/js/config/defaults.js
@@ -89,15 +89,7 @@ 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
@@ -151,11 +143,7 @@ const defaults = {
'airplay',
'fullscreen',
],
- settings: [
- 'captions',
- 'quality',
- 'speed',
- ],
+ settings: ['captions', 'quality', 'speed'],
// Localisation
i18n: {
diff --git a/src/js/controls.js b/src/js/controls.js
index e601a03a..f091555f 100644
--- a/src/js/controls.js
+++ b/src/js/controls.js
@@ -580,10 +580,7 @@ const controls = {
// Show/hide the tooltip
// If the event is a moues in/out and percentage is inside bounds
- if (is.event(event) && [
- 'mouseenter',
- 'mouseleave',
- ].includes(event.type)) {
+ if (is.event(event) && ['mouseenter', 'mouseleave'].includes(event.type)) {
toggle(event.type === 'mouseenter');
}
},
@@ -888,15 +885,7 @@ const controls = {
if (is.array(options)) {
this.options.speed = options;
} else if (this.isHTML5 || this.isVimeo) {
- 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
@@ -1054,10 +1043,7 @@ 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;
}
@@ -1406,10 +1392,7 @@ const controls = {
const replace = input => {
let result = input;
- Object.entries(props).forEach(([
- key,
- value,
- ]) => {
+ Object.entries(props).forEach(([key, value]) => {
result = replaceAll(result, `{${key}}`, value);
});
@@ -1457,16 +1440,9 @@ const controls = {
// Setup tooltips
if (this.config.tooltips.controls) {
- const labels = getElements.call(
- this,
- [
- this.config.selectors.controls.wrapper,
- ' ',
- this.config.selectors.labels,
- ' .',
- this.config.classNames.hidden,
- ].join(''),
- );
+ const { classNames, selectors } = this.config;
+ const selector = `${selectors.controls.wrapper} ${selectors.labels} .${classNames.hidden}`;
+ const labels = getElements.call(this, selector);
Array.from(labels).forEach(label => {
toggleClass(label, this.config.classNames.hidden, false);
diff --git a/src/js/fullscreen.js b/src/js/fullscreen.js
index 998dc613..a8d8b7e5 100644
--- a/src/js/fullscreen.js
+++ b/src/js/fullscreen.js
@@ -96,11 +96,7 @@ class Fullscreen {
// Check for fullscreen support by vendor prefix
let value = '';
- const prefixes = [
- 'webkit',
- 'moz',
- 'ms',
- ];
+ const prefixes = ['webkit', 'moz', 'ms'];
prefixes.some(pre => {
if (is.function(document[`${pre}ExitFullscreen`]) || is.function(document[`${pre}CancelFullScreen`])) {
diff --git a/src/js/i18n.js b/src/js/i18n.js
index f1108dae..5b0ebbab 100644
--- a/src/js/i18n.js
+++ b/src/js/i18n.js
@@ -23,10 +23,7 @@ const i18n = {
'{title}': config.title,
};
- Object.entries(replace).forEach(([
- key,
- value,
- ]) => {
+ Object.entries(replace).forEach(([key, value]) => {
string = replaceAll(string, key, value);
});
diff --git a/src/js/listeners.js b/src/js/listeners.js
index 34cdc6fb..d962761c 100644
--- a/src/js/listeners.js
+++ b/src/js/listeners.js
@@ -46,29 +46,7 @@ class 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 = [32, 37, 38, 39, 40, 48, 49, 50, 51, 52, 53, 54, 56, 57, 67, 70, 73, 75, 76, 77, 79];
// Check focused element
// and if the focused element is not editable (e.g. text input)
@@ -249,11 +227,7 @@ class Listeners {
}
// Show, then hide after a timeout unless another control event occurs
- const show = [
- 'touchstart',
- 'touchmove',
- 'mousemove',
- ].includes(event.type);
+ const show = ['touchstart', 'touchmove', 'mousemove'].includes(event.type);
let delay = 0;
@@ -389,10 +363,8 @@ class Listeners {
// Proxy events to container
// Bubble up key events for Edge
- on.call(this.player, this.player.media, this.player.config.events.concat([
- 'keyup',
- 'keydown',
- ]).join(' '), event => {
+ const proxyEvents = this.player.config.events.concat(['keyup', 'keydown']).join(' ');
+ on.call(this.player, this.player.media, proxyEvents, event => {
let {detail = {}} = event;
// Get error details from media
@@ -554,11 +526,7 @@ class Listeners {
const play = seek.hasAttribute('play-on-seeked');
// Done seeking
- const done = [
- 'mouseup',
- 'touchend',
- 'keyup',
- ].includes(event.type);
+ const done = ['mouseup', 'touchend', 'keyup'].includes(event.type);
// If we're done seeking and it was playing, resume playback
if (play && done) {
@@ -633,10 +601,7 @@ class Listeners {
// Update controls.pressed state (used for ui.toggleControls to avoid hiding when interacting)
bind(this.player.elements.controls, 'mousedown mouseup touchstart touchend touchcancel', event => {
- this.player.elements.controls.pressed = [
- 'mousedown',
- 'touchstart',
- ].includes(event.type);
+ this.player.elements.controls.pressed = ['mousedown', 'touchstart'].includes(event.type);
});
// Focus in/out on controls
diff --git a/src/js/plugins/vimeo.js b/src/js/plugins/vimeo.js
index c8c09b05..312d53cf 100644
--- a/src/js/plugins/vimeo.js
+++ b/src/js/plugins/vimeo.js
@@ -70,8 +70,8 @@ const vimeo = {
// Set aspect ratio
// For Vimeo we have an extra 300% height <div> to hide the standard controls and UI
setAspectRatio(input) {
- const ratio = is.string(input) ? input.split(':') : this.config.ratio.split(':');
- const padding = 100 / ratio[0] * ratio[1];
+ const [x, y] = (is.string(input) ? input : this.config.ratio).split(':');
+ const padding = 100 / x * y;
this.elements.wrapper.style.paddingBottom = `${padding}%`;
if (this.supported.ui) {
@@ -294,10 +294,7 @@ const vimeo = {
});
// Set aspect ratio based on video size
- Promise.all([
- player.embed.getVideoWidth(),
- player.embed.getVideoHeight(),
- ]).then(dimensions => {
+ Promise.all([player.embed.getVideoWidth(), player.embed.getVideoHeight()]).then(dimensions => {
const ratio = getAspectRatio(dimensions[0], dimensions[1]);
vimeo.setAspectRatio.call(this, ratio);
});
diff --git a/src/js/plugins/youtube.js b/src/js/plugins/youtube.js
index 8a16726e..a1e52b48 100644
--- a/src/js/plugins/youtube.js
+++ b/src/js/plugins/youtube.js
@@ -408,10 +408,7 @@ const youtube = {
// Reset timer
clearInterval(player.timers.playing);
- const seeked = player.media.seeking && [
- 1,
- 2,
- ].includes(event.data);
+ const seeked = player.media.seeking && [1, 2].includes(event.data);
if (seeked) {
// Unset seeking and fire seeked event
diff --git a/src/js/plyr.js b/src/js/plyr.js
index 80555829..753db775 100644
--- a/src/js/plyr.js
+++ b/src/js/plyr.js
@@ -172,10 +172,7 @@ class Plyr {
// Get attributes from URL and set config
if (url.searchParams.length) {
- const truthy = [
- '1',
- 'true',
- ];
+ const truthy = ['1', 'true'];
if (truthy.includes(url.searchParams.get('autoplay'))) {
this.config.autoplay = true;
@@ -682,12 +679,7 @@ class Plyr {
return;
}
- let quality = ([
- !is.empty(input) && Number(input),
- this.storage.get('quality'),
- config.selected,
- config.default,
- ]).find(is.number);
+ let quality = [!is.empty(input) && Number(input), this.storage.get('quality'), config.selected, config.default].find(is.number);
if (!options.includes(quality)) {
const value = closest(options, quality);
diff --git a/src/js/ui.js b/src/js/ui.js
index d3d86124..285739a7 100644
--- a/src/js/ui.js
+++ b/src/js/ui.js
@@ -212,10 +212,7 @@ 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);
diff --git a/src/js/utils/elements.js b/src/js/utils/elements.js
index 55866367..39b944d2 100644
--- a/src/js/utils/elements.js
+++ b/src/js/utils/elements.js
@@ -42,10 +42,7 @@ export function setAttributes(element, attributes) {
return;
}
- Object.entries(attributes).forEach(([
- key,
- value,
- ]) => {
+ Object.entries(attributes).forEach(([key, value]) => {
element.setAttribute(key, value);
});
}
diff --git a/src/js/utils/urls.js b/src/js/utils/urls.js
index 89bd77ff..3ebe622e 100644
--- a/src/js/utils/urls.js
+++ b/src/js/utils/urls.js
@@ -30,10 +30,7 @@ export function buildUrlParams(input) {
const params = new URLSearchParams();
if (is.object(input)) {
- Object.entries(input).forEach(([
- key,
- value,
- ]) => {
+ Object.entries(input).forEach(([key, value]) => {
params.set(key, value);
});
}