1
0
mirror of https://github.com/videojs/video.js.git synced 2025-07-09 01:15:31 +02:00

@misteroneill updated source code for linter v5

This commit is contained in:
Pat O'Neill
2016-08-03 15:29:12 -04:00
committed by Gary Katsevman
parent 86068a5b45
commit 272d5eed83
39 changed files with 297 additions and 309 deletions

View File

@ -58,7 +58,7 @@ class Button extends ClickableComponent {
'aria-live': 'polite'
}, attributes);
let el = Component.prototype.createEl.call(this, tag, props, attributes);
const el = Component.prototype.createEl.call(this, tag, props, attributes);
this.createControlTextEl(el);
@ -75,7 +75,7 @@ class Button extends ClickableComponent {
* @method addChild
*/
addChild(child, options = {}) {
let className = this.constructor.name;
const className = this.constructor.name;
log.warn(`Adding an actionable (user controllable) child to a Button (${className}) is not supported; use a ClickableComponent instead.`);

View File

@ -57,7 +57,7 @@ class ClickableComponent extends Component {
'aria-live': 'polite'
}, attributes);
let el = super.createEl(tag, props, attributes);
const el = super.createEl(tag, props, attributes);
this.createControlTextEl(el);

View File

@ -64,7 +64,7 @@ class Component {
// If there was no ID from the options, generate one
if (!this.id_) {
// Don't require the player ID function in the case of mock players
let id = player && player.id && player.id() || 'no_player';
const id = player && player.id && player.id() || 'no_player';
this.id_ = `${id}_component_${Guid.newGUID()}`;
}
@ -217,21 +217,21 @@ class Component {
}
localize(string) {
let code = this.player_.language && this.player_.language();
let languages = this.player_.languages && this.player_.languages();
const code = this.player_.language && this.player_.language();
const languages = this.player_.languages && this.player_.languages();
if (!code || !languages) {
return string;
}
let language = languages[code];
const language = languages[code];
if (language && language[string]) {
return language[string];
}
let primaryCode = code.split('-')[0];
let primaryLang = languages[primaryCode];
const primaryCode = code.split('-')[0];
const primaryLang = languages[primaryCode];
if (primaryLang && primaryLang[string]) {
return primaryLang[string];
@ -359,14 +359,14 @@ class Component {
// If no componentClass in options, assume componentClass is the name lowercased
// (e.g. playButton)
let componentClassName = options.componentClass || toTitleCase(componentName);
const componentClassName = options.componentClass || toTitleCase(componentName);
// Set name through options
options.name = componentName;
// Create a new object & element for this controls set
// If there's no .player_, this is a player
let ComponentClass = Component.getComponent(componentClassName);
const ComponentClass = Component.getComponent(componentClassName);
if (!ComponentClass) {
throw new Error(`Component ${componentClassName} does not exist`);
@ -404,8 +404,8 @@ class Component {
// Add the UI object's element to the container div (box)
// Having an element is not required
if (typeof component.el === 'function' && component.el()) {
let childNodes = this.contentEl().children;
let refNode = childNodes[index] || null;
const childNodes = this.contentEl().children;
const refNode = childNodes[index] || null;
this.contentEl().insertBefore(component.el(), refNode);
}
@ -447,7 +447,7 @@ class Component {
this.childIndex_[component.id()] = null;
this.childNameIndex_[component.name()] = null;
let compEl = component.el();
const compEl = component.el();
if (compEl && compEl.parentNode === this.contentEl()) {
this.contentEl().removeChild(component.el());
@ -501,14 +501,14 @@ class Component {
* @method initChildren
*/
initChildren() {
let children = this.options_.children;
const children = this.options_.children;
if (children) {
// `this` is `parent`
let parentOptions = this.options_;
const parentOptions = this.options_;
let handleAdd = (child) => {
let name = child.name;
const handleAdd = (child) => {
const name = child.name;
let opts = child.opts;
// Allow options for children to be set at the parent options
@ -538,7 +538,7 @@ class Component {
// Add a direct reference to the child by name on the parent instance.
// If two of the same component are used, different names should be supplied
// for each
let newChild = this.addChild(name, opts);
const newChild = this.addChild(name, opts);
if (newChild) {
this[name] = newChild;
@ -547,7 +547,7 @@ class Component {
// Allow for an array of children details to passed in the options
let workingChildren;
let Tech = Component.getComponent('Tech');
const Tech = Component.getComponent('Tech');
if (Array.isArray(children)) {
workingChildren = children;
@ -585,7 +585,7 @@ class Component {
// we have to make sure that child.name isn't in the techOrder since
// techs are registerd as Components but can't aren't compatible
// See https://github.com/videojs/video.js/issues/2772
let c = Component.getComponent(child.opts.componentClass ||
const c = Component.getComponent(child.opts.componentClass ||
toTitleCase(child.name));
return c && !Tech.isTech(c);
@ -826,7 +826,7 @@ class Component {
// Ensure ready is triggerd asynchronously
this.setTimeout(function() {
let readyQueue = this.readyQueue_;
const readyQueue = this.readyQueue_;
// Reset Ready Queue
this.readyQueue_ = [];
@ -1078,8 +1078,8 @@ class Component {
}
// Get dimension value from style
let val = this.el_.style[widthOrHeight];
let pxIndex = val.indexOf('px');
const val = this.el_.style[widthOrHeight];
const pxIndex = val.indexOf('px');
if (pxIndex !== -1) {
// Return the pixel value with no 'px'
@ -1300,7 +1300,7 @@ class Component {
fn = Fn.bind(this, fn);
// window.setTimeout would be preferable here, but due to some bizarre issue with Sinon and/or Phantomjs, we can't.
let timeoutId = window.setTimeout(fn, timeout);
const timeoutId = window.setTimeout(fn, timeout);
const disposeFn = function() {
this.clearTimeout(timeoutId);
@ -1343,7 +1343,7 @@ class Component {
setInterval(fn, interval) {
fn = Fn.bind(this, fn);
let intervalId = window.setInterval(fn, interval);
const intervalId = window.setInterval(fn, interval);
const disposeFn = function() {
this.clearInterval(intervalId);
@ -1428,7 +1428,7 @@ class Component {
// Set up the constructor using the supplied init method
// or using the init of the parent object
// Make sure to check the unobfuscated version for external libs
let init = props.init || props.init || this.prototype.init || this.prototype.init || function() {};
const init = props.init || props.init || this.prototype.init || this.prototype.init || function() {};
// In Resig's simple class inheritance (previously used) the constructor
// is a function that calls `this.init.apply(arguments)`
// However that would prevent us from using `ParentObject.call(this);`
@ -1438,7 +1438,7 @@ class Component {
// `ParentObject.prototype.init.apply(this, arguments);`
// Bleh. We're not creating a _super() function, so it's good to keep
// the parent constructor reference simple.
let subObj = function() {
const subObj = function() {
init.apply(this, arguments);
};
@ -1452,7 +1452,7 @@ class Component {
subObj.extend = Component.extend;
// Extend subObj's prototype with functions and other properties from props
for (let name in props) {
for (const name in props) {
if (props.hasOwnProperty(name)) {
subObj.prototype[name] = props[name];
}

View File

@ -43,7 +43,7 @@ class ErrorDisplay extends ModalDialog {
* @return {String|Null}
*/
content() {
let error = this.player().error();
const error = this.player().error();
return error ? this.localize(error.message) : '';
}

View File

@ -10,7 +10,7 @@ EventTarget.prototype.allowedEvents_ = {};
EventTarget.prototype.on = function(type, fn) {
// Remove the addEventListener alias before calling Events.on
// so we don't get into an infinite type loop
let ael = this.addEventListener;
const ael = this.addEventListener;
this.addEventListener = () => {};
Events.on(this, type, fn);
@ -28,7 +28,7 @@ EventTarget.prototype.removeEventListener = EventTarget.prototype.off;
EventTarget.prototype.one = function(type, fn) {
// Remove the addEventListener alias before calling Events.on
// so we don't get into an infinite type loop
let ael = this.addEventListener;
const ael = this.addEventListener;
this.addEventListener = () => {};
Events.one(this, type, fn);
@ -36,7 +36,7 @@ EventTarget.prototype.one = function(type, fn) {
};
EventTarget.prototype.trigger = function(event) {
let type = event.type || event;
const type = event.type || event;
if (typeof event === 'string') {
event = {type};

View File

@ -67,7 +67,7 @@ const extendFn = function(superClass, subClassMethods = {}) {
_inherits(subClass, superClass);
// Extend subObj's prototype with functions and other properties from props
for (let name in methods) {
for (const name in methods) {
if (methods.hasOwnProperty(name)) {
subClass.prototype[name] = methods[name];
}

View File

@ -8,7 +8,7 @@ import document from 'global/document';
* @type {Object|undefined}
* @private
*/
let FullscreenApi = {};
const FullscreenApi = {};
// browser API methods
// map approach from Screenful.js - https://github.com/sindresorhus/screenfull.js
@ -60,7 +60,7 @@ const apiMap = [
]
];
let specApi = apiMap[0];
const specApi = apiMap[0];
let browserApi;
// determine the supported set of functions

View File

@ -8,7 +8,7 @@ import assign from 'object.assign';
*
* @param {Number} code The media error code
*/
let MediaError = function(code) {
const MediaError = function(code) {
if (typeof code === 'number') {
this.code = code;
} else if (typeof code === 'string') {

View File

@ -150,7 +150,7 @@ class ModalDialog extends Component {
*/
open() {
if (!this.opened_) {
let player = this.player();
const player = this.player();
this.trigger('beforemodalopen');
this.opened_ = true;
@ -206,7 +206,7 @@ class ModalDialog extends Component {
*/
close() {
if (this.opened_) {
let player = this.player();
const player = this.player();
this.trigger('beforemodalclose');
this.opened_ = false;
@ -242,7 +242,7 @@ class ModalDialog extends Component {
*/
closeable(value) {
if (typeof value === 'boolean') {
let closeable = this.closeable_ = !!value;
const closeable = this.closeable_ = !!value;
let close = this.getChild('closeButton');
// If this is being made closeable and has no close button, add one.
@ -250,7 +250,7 @@ class ModalDialog extends Component {
// The close button should be a child of the modal - not its
// content element, so temporarily change the content element.
let temp = this.contentEl_;
const temp = this.contentEl_;
this.contentEl_ = this.el_;
close = this.addChild('closeButton', {controlText: 'Close Modal Dialog'});
@ -292,9 +292,9 @@ class ModalDialog extends Component {
* @return {ModalDialog}
*/
fillWith(content) {
let contentEl = this.contentEl();
let parentEl = contentEl.parentNode;
let nextSiblingEl = contentEl.nextSibling;
const contentEl = this.contentEl();
const parentEl = contentEl.parentNode;
const nextSiblingEl = contentEl.nextSibling;
this.trigger('beforemodalfill');
this.hasBeenFilled_ = true;

View File

@ -97,7 +97,7 @@ class Player extends Component {
// If language is not set, get the closest lang attribute
if (!options.language) {
if (typeof tag.closest === 'function') {
let closest = tag.closest('[lang]');
const closest = tag.closest('[lang]');
if (closest) {
options.language = closest.getAttribute('lang');
@ -140,7 +140,7 @@ class Player extends Component {
// Update Supported Languages
if (options.languages) {
// Normalise player option languages to lowercase
let languagesToLower = {};
const languagesToLower = {};
Object.getOwnPropertyNames(options.languages).forEach(function(name) {
languagesToLower[name.toLowerCase()] = options.languages[name];
@ -178,11 +178,11 @@ class Player extends Component {
// as well so they don't need to reach back into the player for options later.
// We also need to do another copy of this.options_ so we don't end up with
// an infinite loop.
let playerOptionsCopy = mergeOptions(this.options_);
const playerOptionsCopy = mergeOptions(this.options_);
// Load plugins
if (options.plugins) {
let plugins = options.plugins;
const plugins = options.plugins;
Object.getOwnPropertyNames(plugins).forEach(function(name) {
if (typeof this[name] === 'function') {
@ -292,8 +292,8 @@ class Player extends Component {
* @method createEl
*/
createEl() {
let el = this.el_ = super.createEl('div');
let tag = this.tag;
const el = this.el_ = super.createEl('div');
const tag = this.tag;
// Remove width/height attrs from tag so CSS can make it 100% width/height
tag.removeAttribute('width');
@ -330,8 +330,8 @@ class Player extends Component {
// video element
if (window.VIDEOJS_NO_DYNAMIC_STYLE !== true) {
this.styleEl_ = stylesheet.createStyleElement('vjs-styles-dimensions');
let defaultsStyleEl = Dom.$('.vjs-styles-defaults');
let head = Dom.$('head');
const defaultsStyleEl = Dom.$('.vjs-styles-defaults');
const head = Dom.$('head');
head.insertBefore(this.styleEl_, defaultsStyleEl ? defaultsStyleEl.nextSibling : head.firstChild);
}
@ -343,10 +343,10 @@ class Player extends Component {
this.aspectRatio(this.options_.aspectRatio);
// Hide any links within the video/audio tag, because IE doesn't hide them completely.
let links = tag.getElementsByTagName('a');
const links = tag.getElementsByTagName('a');
for (let i = 0; i < links.length; i++) {
let linkEl = links.item(i);
const linkEl = links.item(i);
Dom.addElClass(linkEl, 'vjs-hidden');
linkEl.setAttribute('hidden', 'hidden');
@ -405,7 +405,7 @@ class Player extends Component {
* @method dimension
*/
dimension(dimension, value) {
let privDimension = dimension + '_';
const privDimension = dimension + '_';
if (value === undefined) {
return this[privDimension] || 0;
@ -415,7 +415,7 @@ class Player extends Component {
// If an empty string is given, reset the dimension to be automatic
this[privDimension] = undefined;
} else {
let parsedVal = parseFloat(value);
const parsedVal = parseFloat(value);
if (isNaN(parsedVal)) {
log.error(`Improper value "${value}" supplied for for ${dimension}`);
@ -483,7 +483,7 @@ class Player extends Component {
if (window.VIDEOJS_NO_DYNAMIC_STYLE === true) {
const width = typeof this.width_ === 'number' ? this.width_ : this.options_.width;
const height = typeof this.height_ === 'number' ? this.height_ : this.options_.height;
let techEl = this.tech_ && this.tech_.el();
const techEl = this.tech_ && this.tech_.el();
if (techEl) {
if (width >= 0) {
@ -515,8 +515,8 @@ class Player extends Component {
}
// Get the ratio as a decimal we can use to calculate dimensions
let ratioParts = aspectRatio.split(':');
let ratioMultiplier = ratioParts[1] / ratioParts[0];
const ratioParts = aspectRatio.split(':');
const ratioMultiplier = ratioParts[1] / ratioParts[0];
if (this.width_ !== undefined) {
// Use any width that's been specifically set
@ -589,7 +589,7 @@ class Player extends Component {
this.isReady_ = false;
// Grab tech-specific options from player options and add source and parent element to use.
let techOptions = assign({
const techOptions = assign({
source,
'nativeControlsForTouch': this.options_.nativeControlsForTouch,
'playerId': this.id(),
@ -717,7 +717,7 @@ class Player extends Component {
if (safety && safety.IWillNotUseThisInPlugins) {
return this.tech_;
}
let errorText = `
const errorText = `
Please make sure that you are not using this inside of a plugin.
To disable this alert and error, please pass in an object with
\`IWillNotUseThisInPlugins\` to the \`tech\` method. See
@ -1148,7 +1148,7 @@ class Player extends Component {
* @method handleTechError_
*/
handleTechError_() {
let error = this.tech_.error();
const error = this.tech_.error();
this.error(error);
}
@ -1553,8 +1553,8 @@ class Player extends Component {
* @method bufferedEnd
*/
bufferedEnd() {
let buffered = this.buffered();
let duration = this.duration();
const buffered = this.buffered();
const duration = this.duration();
let end = buffered.end(buffered.length - 1);
if (end > duration) {
@ -1671,7 +1671,7 @@ class Player extends Component {
* @method requestFullscreen
*/
requestFullscreen() {
let fsApi = FullscreenApi;
const fsApi = FullscreenApi;
this.isFullscreen(true);
@ -1721,7 +1721,7 @@ class Player extends Component {
* @method exitFullscreen
*/
exitFullscreen() {
let fsApi = FullscreenApi;
const fsApi = FullscreenApi;
this.isFullscreen(false);
@ -1809,7 +1809,7 @@ class Player extends Component {
// Loop through each playback technology in the options order
for (let i = 0, j = this.options_.techOrder; i < j.length; i++) {
let techName = toTitleCase(j[i]);
const techName = toTitleCase(j[i]);
let tech = Tech.getTech(techName);
// Support old behavior of techs being registered as components.
@ -1849,7 +1849,7 @@ class Player extends Component {
selectSource(sources) {
// Get only the techs specified in `techOrder` that exist and are supported by the
// current platform
let techs =
const techs =
this.options_.techOrder
.map(toTitleCase)
.map((techName) => {
@ -1872,7 +1872,7 @@ class Player extends Component {
// Iterate over each `innerArray` element once per `outerArray` element and execute
// `tester` with both. If `tester` returns a non-falsy value, exit early and return
// that value.
let findFirstPassingTechSourcePair = function(outerArray, innerArray, tester) {
const findFirstPassingTechSourcePair = function(outerArray, innerArray, tester) {
let found;
outerArray.some((outerChoice) => {
@ -1889,8 +1889,8 @@ class Player extends Component {
};
let foundSourceAndTech;
let flip = (fn) => (a, b) => fn(b, a);
let finder = ([techName, tech], source) => {
const flip = (fn) => (a, b) => fn(b, a);
const finder = ([techName, tech], source) => {
if (tech.canPlaySource(source, this.options_[techName.toLowerCase()])) {
return {source, tech: techName};
}
@ -2012,7 +2012,7 @@ class Player extends Component {
* @method sourceList_
*/
sourceList_(sources) {
let sourceTech = this.selectSource(sources);
const sourceTech = this.selectSource(sources);
if (sourceTech) {
if (sourceTech.tech === this.techName_) {
@ -2426,9 +2426,9 @@ class Player extends Component {
let mouseInProgress;
let lastMoveX;
let lastMoveY;
let handleActivity = Fn.bind(this, this.reportUserActivity);
const handleActivity = Fn.bind(this, this.reportUserActivity);
let handleMouseMove = function(e) {
const handleMouseMove = function(e) {
// #1068 - Prevent mousemove spamming
// Chrome Bug: https://code.google.com/p/chromium/issues/detail?id=366970
if (e.screenX !== lastMoveX || e.screenY !== lastMoveY) {
@ -2438,7 +2438,7 @@ class Player extends Component {
}
};
let handleMouseDown = function() {
const handleMouseDown = function() {
handleActivity();
// For as long as the they are touching the device or have their mouse down,
// we consider them active even if they're not moving their finger or mouse.
@ -2450,7 +2450,7 @@ class Player extends Component {
mouseInProgress = this.setInterval(handleActivity, 250);
};
let handleMouseUp = function(event) {
const handleMouseUp = function(event) {
handleActivity();
// Stop the interval that maintains activity if the mouse/touch is down
this.clearInterval(mouseInProgress);
@ -2485,7 +2485,7 @@ class Player extends Component {
// Clear any existing inactivity timeout to start the timer over
this.clearTimeout(inactivityTimeout);
let timeout = this.options_.inactivityTimeout;
const timeout = this.options_.inactivityTimeout;
if (timeout > 0) {
// In <timeout> milliseconds, if no more activity has occurred the
@ -2786,8 +2786,8 @@ class Player extends Component {
* @method toJSON
*/
toJSON() {
let options = mergeOptions(this.options_);
let tracks = options.tracks;
const options = mergeOptions(this.options_);
const tracks = options.tracks;
options.tracks = [];
@ -2823,7 +2823,7 @@ class Player extends Component {
options = options || {};
options.content = content || '';
let modal = new ModalDialog(this, options);
const modal = new ModalDialog(this, options);
this.addChild(modal);
modal.on('dispose', () => {
@ -2842,7 +2842,7 @@ class Player extends Component {
* @method getTagSettings
*/
static getTagSettings(tag) {
let baseOptions = {
const baseOptions = {
sources: [],
tracks: []
};
@ -2893,7 +2893,7 @@ class Player extends Component {
*/
Player.players = {};
let navigator = window.navigator;
const navigator = window.navigator;
/*
* Player instance options, surfaced using options
@ -3015,10 +3015,10 @@ Player.prototype.handleVolumeChange_; // eslint-disable-line
*
* @event error
*/
Player.prototype.handleError_ = Player.prototype.handleError_;
Player.prototype.handleError_; // eslint-disable-line
Player.prototype.flexNotSupported_ = function() {
let elem = document.createElement('i');
const elem = document.createElement('i');
// Note: We don't actually use flexBasis (or flexOrder), but it's one of the more
// common flex features that we can rely on when checking for flex support.

View File

@ -41,7 +41,7 @@ class PosterImage extends ClickableComponent {
* @method createEl
*/
createEl() {
let el = Dom.createEl('div', {
const el = Dom.createEl('div', {
className: 'vjs-poster',
// Don't want poster to be tabbable.
@ -66,7 +66,7 @@ class PosterImage extends ClickableComponent {
* @method update
*/
update() {
let url = this.player().poster();
const url = this.player().poster();
this.setSrc(url);

View File

@ -10,7 +10,6 @@ import window from 'global/window';
let _windowLoaded = false;
let videojs;
let autoSetupTimeout;
// Automatically set up any tags that have a data-setup attribute
const autoSetup = function() {
@ -41,7 +40,7 @@ const autoSetup = function() {
if (mediaEls && mediaEls.length > 0) {
for (let i = 0, e = mediaEls.length; i < e; i++) {
let mediaEl = mediaEls[i];
const mediaEl = mediaEls[i];
// Check if element exists, has getAttribute func.
// IE seems to consider typeof el.getAttribute == 'object' instead of
@ -50,7 +49,7 @@ const autoSetup = function() {
// Make sure this player hasn't already been set up.
if (mediaEl.player === undefined) {
let options = mediaEl.getAttribute('data-setup');
const options = mediaEl.getAttribute('data-setup');
// Check if data-setup attr exists.
// We only auto-setup if they've added the data-setup attr.
@ -74,13 +73,13 @@ const autoSetup = function() {
};
// Pause to let the DOM keep processing
autoSetupTimeout = function(wait, vjs) {
function autoSetupTimeout(wait, vjs) {
if (vjs) {
videojs = vjs;
}
setTimeout(autoSetup, wait);
};
}
if (document.readyState === 'complete') {
_windowLoaded = true;

View File

@ -12,7 +12,7 @@ function FlashRtmpDecorator(Flash) {
};
Flash.streamToParts = function(src) {
let parts = {
const parts = {
connection: '',
stream: ''
};
@ -82,7 +82,7 @@ function FlashRtmpDecorator(Flash) {
* @return {String} 'probably', 'maybe', or '' (empty string)
*/
Flash.rtmpSourceHandler.canHandleSource = function(source, options) {
let can = Flash.rtmpSourceHandler.canPlayType(source.type);
const can = Flash.rtmpSourceHandler.canPlayType(source.type);
if (can) {
return can;
@ -104,7 +104,7 @@ function FlashRtmpDecorator(Flash) {
* @param {Object} options The options to pass to the source
*/
Flash.rtmpSourceHandler.handleSource = function(source, tech, options) {
let srcParts = Flash.streamToParts(source.src);
const srcParts = Flash.streamToParts(source.src);
tech.setRtmpConnection(srcParts.connection);
tech.setRtmpStream(srcParts.stream);

View File

@ -14,7 +14,7 @@ import Component from '../component';
import window from 'global/window';
import assign from 'object.assign';
let navigator = window.navigator;
const navigator = window.navigator;
/**
* Flash Media Controller - Wrapper for fallback SWF API
@ -68,7 +68,7 @@ class Flash extends Tech {
* @method createEl
*/
createEl() {
let options = this.options_;
const options = this.options_;
// If video.js is hosted locally you should also set the location
// for the hosted swf, which should be relative to the page (not video.js)
@ -79,10 +79,10 @@ class Flash extends Tech {
}
// Generate ID for swf object
let objId = options.techId;
const objId = options.techId;
// Merge default flashvars with ones passed in to init
let flashVars = assign({
const flashVars = assign({
// SWF Callback Functions
readyFunction: 'videojs.Flash.onReady',
@ -98,7 +98,7 @@ class Flash extends Tech {
}, options.flashVars);
// Merge default parames with ones passed in
let params = assign({
const params = assign({
// Opaque is needed to overlay controls, but can affect playback performance
wmode: 'opaque',
// Using bgcolor prevents a white flash when the object is loading
@ -106,7 +106,7 @@ class Flash extends Tech {
}, options.params);
// Merge default attributes with ones passed in
let attributes = assign({
const attributes = assign({
// Both ID and Name needed or swf to identify itself
id: objId,
name: objId,
@ -190,7 +190,7 @@ class Flash extends Tech {
* @method setCurrentTime
*/
setCurrentTime(time) {
let seekable = this.seekable();
const seekable = this.seekable();
if (seekable.length) {
// clamp to the current seekable range
@ -241,7 +241,7 @@ class Flash extends Tech {
if (this.readyState() === 0) {
return NaN;
}
let duration = this.el_.vjs_getProperty('duration');
const duration = this.el_.vjs_getProperty('duration');
return duration >= 0 ? duration : Infinity;
}
@ -293,7 +293,7 @@ class Flash extends Tech {
* @method buffered
*/
buffered() {
let ranges = this.el_.vjs_getProperty('buffered');
const ranges = this.el_.vjs_getProperty('buffered');
if (ranges.length === 0) {
return createTimeRange();
@ -334,7 +334,7 @@ const _readWrite = 'rtmpConnection,rtmpStream,preload,defaultPlaybackRate,playba
const _readOnly = 'networkState,readyState,initialTime,startOffsetTime,paused,ended,videoWidth,videoHeight'.split(',');
function _createSetter(attr) {
let attrUpper = attr.charAt(0).toUpperCase() + attr.slice(1);
const attrUpper = attr.charAt(0).toUpperCase() + attr.slice(1);
_api['set' + attrUpper] = function(val) {
return this.el_.vjs_setProperty(attr, val);
@ -401,7 +401,7 @@ Flash.nativeSourceHandler.canHandleSource = function(source, options) {
let type;
function guessMimeType(src) {
let ext = Url.getFileExtension(src);
const ext = Url.getFileExtension(src);
if (ext) {
return `video/${ext}`;
@ -449,8 +449,8 @@ Flash.formats = {
};
Flash.onReady = function(currSwf) {
let el = Dom.getEl(currSwf);
let tech = el && el.tech;
const el = Dom.getEl(currSwf);
const tech = el && el.tech;
// if there is no el then the tech has been disposed
// and the tech element was removed from the player div
@ -482,7 +482,7 @@ Flash.checkReady = function(tech) {
// Trigger events from the swf on the player
Flash.onEvent = function(swfID, eventName) {
let tech = Dom.getEl(swfID).tech;
const tech = Dom.getEl(swfID).tech;
tech.trigger(eventName, Array.prototype.slice.call(arguments, 2));
};

View File

@ -45,13 +45,13 @@ class Html5 extends Tech {
if (this.el_.hasChildNodes()) {
let nodes = this.el_.childNodes;
const nodes = this.el_.childNodes;
let nodesLength = nodes.length;
let removeNodes = [];
const removeNodes = [];
while (nodesLength--) {
let node = nodes[nodesLength];
let nodeName = node.nodeName.toLowerCase();
const node = nodes[nodesLength];
const nodeName = node.nodeName.toLowerCase();
if (nodeName === 'track') {
if (!this.featuresNativeTextTracks) {
@ -78,16 +78,16 @@ class Html5 extends Tech {
}
}
let trackTypes = ['audio', 'video'];
const trackTypes = ['audio', 'video'];
// ProxyNativeTextTracks
trackTypes.forEach((type) => {
let capitalType = toTitleCase(type);
const capitalType = toTitleCase(type);
if (!this[`featuresNative${capitalType}Tracks`]) {
return;
}
let tl = this.el()[`${type}Tracks`];
const tl = this.el()[`${type}Tracks`];
if (tl && tl.addEventListener) {
tl.addEventListener('change', Fn.bind(this, this[`handle${capitalType}TrackChange_`]));
@ -131,8 +131,8 @@ class Html5 extends Tech {
dispose() {
// Un-ProxyNativeTracks
['audio', 'video', 'text'].forEach((type) => {
let capitalType = toTitleCase(type);
let tl = this.el_[`${type}Tracks`];
const capitalType = toTitleCase(type);
const tl = this.el_[`${type}Tracks`];
if (tl && tl.removeEventListener) {
tl.removeEventListener('change', this[`handle${capitalType}TrackChange_`]);
@ -176,8 +176,8 @@ class Html5 extends Tech {
el = document.createElement('video');
// determine if native controls should be used
let tagAttributes = this.options_.tag && Dom.getElAttributes(this.options_.tag);
let attributes = mergeOptions({}, tagAttributes);
const tagAttributes = this.options_.tag && Dom.getElAttributes(this.options_.tag);
const attributes = mergeOptions({}, tagAttributes);
if (!browser.TOUCH_ENABLED || this.options_.nativeControlsForTouch !== true) {
delete attributes.controls;
@ -193,11 +193,11 @@ class Html5 extends Tech {
}
// Update specific tag settings, in case they were overridden
let settingsAttrs = ['autoplay', 'preload', 'loop', 'muted'];
const settingsAttrs = ['autoplay', 'preload', 'loop', 'muted'];
for (let i = settingsAttrs.length - 1; i >= 0; i--) {
const attr = settingsAttrs[i];
let overwriteAttrs = {};
const overwriteAttrs = {};
if (typeof this.options_[attr] !== 'undefined') {
overwriteAttrs[attr] = this.options_[attr];
@ -232,13 +232,13 @@ class Html5 extends Tech {
// which could also happen between now and the next loop, so we'll
// watch for that also.
let loadstartFired = false;
let setLoadstartFired = function() {
const setLoadstartFired = function() {
loadstartFired = true;
};
this.on('loadstart', setLoadstartFired);
let triggerLoadstart = function() {
const triggerLoadstart = function() {
// We did miss the original loadstart. Make sure the player
// sees loadstart before loadedmetadata
if (!loadstartFired) {
@ -265,7 +265,7 @@ class Html5 extends Tech {
// The other readyState events aren't as much of a problem if we double
// them, so not going to go to as much trouble as loadstart to prevent
// that unless we find reason to.
let eventsToTrigger = ['loadstart'];
const eventsToTrigger = ['loadstart'];
// loadedmetadata: newly equal to HAVE_METADATA (1) or greater
eventsToTrigger.push('loadedmetadata');
@ -294,7 +294,7 @@ class Html5 extends Tech {
}
proxyNativeTextTracks_() {
let tt = this.el().textTracks;
const tt = this.el().textTracks;
if (tt) {
// Add tracks - if player is initialised after DOM loaded, textTracks
@ -315,7 +315,7 @@ class Html5 extends Tech {
}
handleTextTrackChange(e) {
let tt = this.textTracks();
const tt = this.textTracks();
this.textTracks().trigger({
type: 'change',
@ -334,7 +334,7 @@ class Html5 extends Tech {
}
handleVideoTrackChange_(e) {
let vt = this.videoTracks();
const vt = this.videoTracks();
this.videoTracks().trigger({
type: 'change',
@ -353,7 +353,7 @@ class Html5 extends Tech {
}
handleAudioTrackChange_(e) {
let audioTrackList = this.audioTracks();
const audioTrackList = this.audioTracks();
this.audioTracks().trigger({
type: 'change',
@ -381,14 +381,14 @@ class Html5 extends Tech {
removeOldTracks_(techTracks, elTracks) {
// This will loop over the techTracks and check if they are still used by the HTML5 video element
// If not, they will be removed from the emulated list
let removeTracks = [];
const removeTracks = [];
if (!elTracks) {
return;
}
for (let i = 0; i < techTracks.length; i++) {
let techTrack = techTracks[i];
const techTrack = techTracks[i];
let found = false;
for (let j = 0; j < elTracks.length; j++) {
@ -574,7 +574,7 @@ class Html5 extends Tech {
*/
supportsFullScreen() {
if (typeof this.el_.webkitEnterFullScreen === 'function') {
let userAgent = window.navigator.userAgent;
const userAgent = window.navigator.userAgent;
// Seems to be broken in Chromium/Chrome && Safari in Leopard
if ((/Android/).test(userAgent) || !(/Chrome|Mac OS X 10.5/).test(userAgent)) {
@ -590,7 +590,7 @@ class Html5 extends Tech {
* @method enterFullScreen
*/
enterFullScreen() {
let video = this.el_;
const video = this.el_;
if ('webkitDisplayingFullscreen' in video) {
this.one('webkitbeginfullscreen', function() {
@ -963,7 +963,7 @@ class Html5 extends Tech {
return super.addRemoteTextTrack(options);
}
let htmlTrackElement = document.createElement('track');
const htmlTrackElement = document.createElement('track');
if (options.kind) {
htmlTrackElement.kind = options.kind;
@ -1004,14 +1004,13 @@ class Html5 extends Tech {
return super.removeRemoteTextTrack(track);
}
let tracks;
let trackElement = this.remoteTextTrackEls().getTrackElementByTrack_(track);
const trackElement = this.remoteTextTrackEls().getTrackElementByTrack_(track);
// remove HTMLTrackElement and TextTrack from remote list
this.remoteTextTrackEls().removeTrackElement_(trackElement);
this.remoteTextTracks().removeTrack_(track);
tracks = this.$$('track');
const tracks = this.$$('track');
let i = tracks.length;
@ -1034,7 +1033,7 @@ class Html5 extends Tech {
* @private
*/
Html5.TEST_VID = document.createElement('video');
let track = document.createElement('track');
const track = document.createElement('track');
track.kind = 'captions';
track.srclang = 'en';
@ -1100,7 +1099,7 @@ Html5.nativeSourceHandler.canHandleSource = function(source, options) {
// If no type, fall back to checking 'video/[EXTENSION]'
} else if (source.src) {
let ext = Url.getFileExtension(source.src);
const ext = Url.getFileExtension(source.src);
return Html5.nativeSourceHandler.canPlayType(`video/${ext}`);
}
@ -1140,7 +1139,7 @@ Html5.registerSourceHandler(Html5.nativeSourceHandler);
Html5.canControlVolume = function() {
// IE will error if Windows Media Player not installed #3315
try {
let volume = Html5.TEST_VID.volume;
const volume = Html5.TEST_VID.volume;
Html5.TEST_VID.volume = (volume / 2) + 0.1;
return volume !== Html5.TEST_VID.volume;
@ -1162,7 +1161,7 @@ Html5.canControlPlaybackRate = function() {
}
// IE will error if Windows Media Player not installed #3315
try {
let playbackRate = Html5.TEST_VID.playbackRate;
const playbackRate = Html5.TEST_VID.playbackRate;
Html5.TEST_VID.playbackRate = (playbackRate / 2) + 0.1;
return playbackRate !== Html5.TEST_VID.playbackRate;
@ -1204,7 +1203,7 @@ Html5.supportsNativeTextTracks = function() {
* @return {Boolean}
*/
Html5.supportsNativeVideoTracks = function() {
let supportsVideoTracks = !!Html5.TEST_VID.videoTracks;
const supportsVideoTracks = !!Html5.TEST_VID.videoTracks;
return supportsVideoTracks;
};
@ -1215,7 +1214,7 @@ Html5.supportsNativeVideoTracks = function() {
* @return {Boolean}
*/
Html5.supportsNativeAudioTracks = function() {
let supportsAudioTracks = !!Html5.TEST_VID.audioTracks;
const supportsAudioTracks = !!Html5.TEST_VID.audioTracks;
return supportsAudioTracks;
};
@ -1343,7 +1342,7 @@ Html5.patchCanPlayType = function() {
};
Html5.unpatchCanPlayType = function() {
let r = Html5.TEST_VID.constructor.prototype.canPlayType;
const r = Html5.TEST_VID.constructor.prototype.canPlayType;
Html5.TEST_VID.constructor.prototype.canPlayType = canPlayType;
canPlayType = null;
@ -1390,7 +1389,7 @@ Html5.resetMediaElement = function(el) {
return;
}
let sources = el.querySelectorAll('source');
const sources = el.querySelectorAll('source');
let i = sources.length;
while (i--) {

View File

@ -25,7 +25,7 @@ class MediaLoader extends Component {
if (!options.playerOptions.sources || options.playerOptions.sources.length === 0) {
for (let i = 0, j = options.playerOptions.techOrder; i < j.length; i++) {
let techName = toTitleCase(j[i]);
const techName = toTitleCase(j[i]);
let tech = Tech.getTech(techName);
// Support old behavior of techs being registered as components.

View File

@ -21,7 +21,7 @@ import window from 'global/window';
import document from 'global/document';
function createTrackHelper(self, kind, label, language, options = {}) {
let tracks = self.textTracks();
const tracks = self.textTracks();
options.kind = kind;
@ -33,7 +33,7 @@ function createTrackHelper(self, kind, label, language, options = {}) {
}
options.tech = self;
let track = new TextTrack(options);
const track = new TextTrack(options);
tracks.addTrack_(track);
@ -135,7 +135,7 @@ class Tech extends Component {
this.progressInterval = this.setInterval(Fn.bind(this, function() {
// Don't trigger unless buffered amount is greater than last time
let numBufferedPercent = this.bufferedPercent();
const numBufferedPercent = this.bufferedPercent();
if (this.bufferedPercent_ !== numBufferedPercent) {
this.trigger('progress');
@ -277,11 +277,11 @@ class Tech extends Component {
types = [].concat(types);
// clear out all tracks because we can't reuse them between techs
types.forEach((type) => {
let list = this[`${type}Tracks`]() || [];
const list = this[`${type}Tracks`]() || [];
let i = list.length;
while (i--) {
let track = list[i];
const track = list[i];
if (type === 'text') {
this.removeRemoteTextTrack(track);
@ -353,11 +353,11 @@ class Tech extends Component {
* @method initTextTrackListeners
*/
initTextTrackListeners() {
let textTrackListChanges = Fn.bind(this, function() {
const textTrackListChanges = Fn.bind(this, function() {
this.trigger('texttrackchange');
});
let tracks = this.textTracks();
const tracks = this.textTracks();
if (!tracks) {
return;
@ -381,11 +381,11 @@ class Tech extends Component {
const trackTypes = ['video', 'audio'];
trackTypes.forEach((type) => {
let trackListChanges = () => {
const trackListChanges = () => {
this.trigger(`${type}trackchange`);
};
let tracks = this[`${type}Tracks`]();
const tracks = this[`${type}Tracks`]();
tracks.addEventListener('removetrack', trackListChanges);
tracks.addEventListener('addtrack', trackListChanges);
@ -403,14 +403,14 @@ class Tech extends Component {
* @method emulateTextTracks
*/
emulateTextTracks() {
let tracks = this.textTracks();
const tracks = this.textTracks();
if (!tracks) {
return;
}
if (!window.WebVTT && this.el().parentNode != null) {
let script = document.createElement('script');
if (!window.WebVTT && this.el().parentNode !== null && this.el().parentNode !== undefined) {
const script = document.createElement('script');
script.src = this.options_['vtt.js'] || '../node_modules/videojs-vtt.js/dist/vtt.js';
script.onload = () => {
@ -429,12 +429,12 @@ class Tech extends Component {
this.el().parentNode.appendChild(script);
}
let updateDisplay = () => this.trigger('texttrackchange');
let textTracksChanges = () => {
const updateDisplay = () => this.trigger('texttrackchange');
const textTracksChanges = () => {
updateDisplay();
for (let i = 0; i < tracks.length; i++) {
let track = tracks[i];
const track = tracks[i];
track.removeEventListener('cuechange', updateDisplay);
if (track.mode === 'showing') {
@ -539,11 +539,11 @@ class Tech extends Component {
* @method addRemoteTextTrack
*/
addRemoteTextTrack(options) {
let track = mergeOptions(options, {
const track = mergeOptions(options, {
tech: this
});
let htmlTrackElement = new HTMLTrackElement(track);
const htmlTrackElement = new HTMLTrackElement(track);
// store HTMLTrackElement and TextTrack to remote list
this.remoteTextTrackEls().addTrackElement_(htmlTrackElement);
@ -564,7 +564,7 @@ class Tech extends Component {
removeRemoteTextTrack(track) {
this.textTracks().removeTrack_(track);
let trackElement = this.remoteTextTrackEls().getTrackElementByTrack_(track);
const trackElement = this.remoteTextTrackEls().getTrackElementByTrack_(track);
// remove HTMLTrackElement and TextTrack from remote list
this.remoteTextTrackEls().removeTrackElement_(trackElement);
@ -723,7 +723,7 @@ Tech.withSourceHandlers = function(_Tech) {
* @return {String} 'probably', 'maybe', or '' (empty string)
*/
_Tech.canPlayType = function(type) {
let handlers = _Tech.sourceHandlers || [];
const handlers = _Tech.sourceHandlers || [];
let can;
for (let i = 0; i < handlers.length; i++) {
@ -746,7 +746,7 @@ Tech.withSourceHandlers = function(_Tech) {
* @returns {null} Null if no source handler is found
*/
_Tech.selectSourceHandler = function(source, options) {
let handlers = _Tech.sourceHandlers || [];
const handlers = _Tech.sourceHandlers || [];
let can;
for (let i = 0; i < handlers.length; i++) {
@ -767,7 +767,7 @@ Tech.withSourceHandlers = function(_Tech) {
* @return {String} 'probably', 'maybe', or '' (empty string)
*/
_Tech.canPlaySource = function(srcObj, options) {
let sh = _Tech.selectSourceHandler(srcObj, options);
const sh = _Tech.selectSourceHandler(srcObj, options);
if (sh) {
return sh.canHandleSource(srcObj, options);
@ -780,13 +780,13 @@ Tech.withSourceHandlers = function(_Tech) {
* When using a source handler, prefer its implementation of
* any function normally provided by the tech.
*/
let deferrable = [
const deferrable = [
'seekable',
'duration'
];
deferrable.forEach(function(fnName) {
let originalFn = this[fnName];
const originalFn = this[fnName];
if (typeof originalFn !== 'function') {
return;

View File

@ -58,12 +58,12 @@ class AudioTrackList extends TrackList {
// as it does not support Object.defineProperty properly
if (browser.IS_IE8) {
list = document.createElement('custom');
for (let prop in TrackList.prototype) {
for (const prop in TrackList.prototype) {
if (prop !== 'constructor') {
list[prop] = TrackList.prototype[prop];
}
}
for (let prop in AudioTrackList.prototype) {
for (const prop in AudioTrackList.prototype) {
if (prop !== 'constructor') {
list[prop] = AudioTrackList.prototype[prop];
}

View File

@ -20,16 +20,16 @@ import * as browser from '../utils/browser.js';
*/
class AudioTrack extends Track {
constructor(options = {}) {
let settings = merge(options, {
const settings = merge(options, {
kind: AudioTrackKind[options.kind] || ''
});
// on IE8 this will be a document element
// for every other browser this will be a normal object
let track = super(settings);
const track = super(settings);
let enabled = false;
if (browser.IS_IE8) {
for (let prop in AudioTrack.prototype) {
for (const prop in AudioTrack.prototype) {
if (prop !== 'constructor') {
track[prop] = AudioTrack.prototype[prop];
}

View File

@ -12,7 +12,7 @@ class HtmlTrackElementList {
if (browser.IS_IE8) {
list = document.createElement('custom');
for (let prop in HtmlTrackElementList.prototype) {
for (const prop in HtmlTrackElementList.prototype) {
if (prop !== 'constructor') {
list[prop] = HtmlTrackElementList.prototype[prop];
}

View File

@ -45,14 +45,14 @@ class HTMLTrackElement extends EventTarget {
if (browser.IS_IE8) {
trackElement = document.createElement('custom');
for (let prop in HTMLTrackElement.prototype) {
for (const prop in HTMLTrackElement.prototype) {
if (prop !== 'constructor') {
trackElement[prop] = HTMLTrackElement.prototype[prop];
}
}
}
let track = new TextTrack(options);
const track = new TextTrack(options);
trackElement.kind = track.kind;
trackElement.src = track.src;

View File

@ -25,7 +25,7 @@ class TextTrackCueList {
if (browser.IS_IE8) {
list = document.createElement('custom');
for (let prop in TextTrackCueList.prototype) {
for (const prop in TextTrackCueList.prototype) {
if (prop !== 'constructor') {
list[prop] = TextTrackCueList.prototype[prop];
}
@ -53,14 +53,14 @@ class TextTrackCueList {
* @private
*/
setCues_(cues) {
let oldLength = this.length || 0;
const oldLength = this.length || 0;
let i = 0;
let l = cues.length;
const l = cues.length;
this.cues_ = cues;
this.length_ = cues.length;
let defineProp = function(index) {
const defineProp = function(index) {
if (!('' + index in this)) {
Object.defineProperty(this, '' + index, {
get() {
@ -90,7 +90,7 @@ class TextTrackCueList {
let result = null;
for (let i = 0, l = this.length; i < l; i++) {
let cue = this[i];
const cue = this[i];
if (cue.id === id) {
result = cue;

View File

@ -85,20 +85,20 @@ class TextTrackDisplay extends Component {
player.on('fullscreenchange', Fn.bind(this, this.updateDisplay));
let tracks = this.options_.playerOptions.tracks || [];
const tracks = this.options_.playerOptions.tracks || [];
for (let i = 0; i < tracks.length; i++) {
this.player_.addRemoteTextTrack(tracks[i]);
}
let modes = {captions: 1, subtitles: 1};
let trackList = this.player_.textTracks();
const modes = {captions: 1, subtitles: 1};
const trackList = this.player_.textTracks();
let firstDesc;
let firstCaptions;
if (trackList) {
for (let i = 0; i < trackList.length; i++) {
let track = trackList[i];
const track = trackList[i];
if (track.default) {
if (track.kind === 'descriptions' && !firstDesc) {
@ -167,7 +167,7 @@ class TextTrackDisplay extends Component {
* @method updateDisplay
*/
updateDisplay() {
let tracks = this.player_.textTracks();
const tracks = this.player_.textTracks();
this.clearDisplay();
@ -185,7 +185,7 @@ class TextTrackDisplay extends Component {
let i = tracks.length;
while (i--) {
let track = tracks[i];
const track = tracks[i];
if (track.mode === 'showing') {
if (track.kind === 'descriptions') {
@ -214,8 +214,8 @@ class TextTrackDisplay extends Component {
return;
}
let overrides = this.player_.textTrackSettings.getValues();
let cues = [];
const overrides = this.player_.textTrackSettings.getValues();
const cues = [];
for (let i = 0; i < track.activeCues.length; i++) {
cues.push(track.activeCues[i]);
@ -226,13 +226,13 @@ class TextTrackDisplay extends Component {
let i = cues.length;
while (i--) {
let cue = cues[i];
const cue = cues[i];
if (!cue) {
continue;
}
let cueDiv = cue.displayState;
const cueDiv = cue.displayState;
if (overrides.color) {
cueDiv.firstChild.style.color = overrides.color;

View File

@ -12,8 +12,8 @@
* @return {Object} a serializable javascript representation of the
* @private
*/
let trackToJson_ = function(track) {
let ret = [
const trackToJson_ = function(track) {
const ret = [
'kind', 'label', 'language', 'id',
'inBandMetadataTrackDispatchType', 'mode', 'src'
].reduce((acc, prop, i) => {
@ -45,13 +45,13 @@ let trackToJson_ = function(track) {
* @return {Array} a serializable javascript representation of the
* @function textTracksToJson
*/
let textTracksToJson = function(tech) {
const textTracksToJson = function(tech) {
let trackEls = tech.$$('track');
const trackEls = tech.$$('track');
let trackObjs = Array.prototype.map.call(trackEls, (t) => t.track);
let tracks = Array.prototype.map.call(trackEls, function(trackEl) {
let json = trackToJson_(trackEl.track);
const trackObjs = Array.prototype.map.call(trackEls, (t) => t.track);
const tracks = Array.prototype.map.call(trackEls, function(trackEl) {
const json = trackToJson_(trackEl.track);
if (trackEl.src) {
json.src = trackEl.src;
@ -72,9 +72,9 @@ let textTracksToJson = function(tech) {
* @param tech {tech} the tech to create text tracks on
* @function jsonToTextTracks
*/
let jsonToTextTracks = function(json, tech) {
const jsonToTextTracks = function(json, tech) {
json.forEach(function(track) {
let addedTrack = tech.addRemoteTextTrack(track).track;
const addedTrack = tech.addRemoteTextTrack(track).track;
if (!track.src && track.cues) {
track.cues.forEach((cue) => addedTrack.addCue(cue));

View File

@ -33,12 +33,12 @@ class TextTrackList extends TrackList {
// as it does not support Object.defineProperty properly
if (browser.IS_IE8) {
list = document.createElement('custom');
for (let prop in TrackList.prototype) {
for (const prop in TrackList.prototype) {
if (prop !== 'constructor') {
list[prop] = TrackList.prototype[prop];
}
}
for (let prop in TextTrackList.prototype) {
for (const prop in TextTrackList.prototype) {
if (prop !== 'constructor') {
list[prop] = TextTrackList.prototype[prop];
}
@ -102,7 +102,7 @@ class TextTrackList extends TrackList {
let result = null;
for (let i = 0, l = this.length; i < l; i++) {
let track = this[i];
const track = this[i];
if (track.id === id) {
result = track;

View File

@ -9,7 +9,7 @@ import safeParseTuple from 'safe-json-parse/tuple';
import window from 'global/window';
function captionOptionsMenuTemplate(uniqueId, dialogLabelId, dialogDescriptionId) {
let template = `
const template = `
<div role="document">
<div role="heading" aria-level="1" id="${dialogLabelId}" class="vjs-control-text">Captions Settings Dialog</div>
<div id="${dialogDescriptionId}" class="vjs-control-text">Beginning of dialog window. Escape will cancel and close the window.</div>
@ -220,9 +220,9 @@ class TextTrackSettings extends Component {
* @method createEl
*/
createEl() {
let uniqueId = this.id_;
let dialogLabelId = 'TTsettingsDialogLabel-' + uniqueId;
let dialogDescriptionId = 'TTsettingsDialogDescription-' + uniqueId;
const uniqueId = this.id_;
const dialogLabelId = 'TTsettingsDialogLabel-' + uniqueId;
const dialogDescriptionId = 'TTsettingsDialogDescription-' + uniqueId;
return super.createEl('div', {
className: 'vjs-caption-settings vjs-modal-overlay',
@ -261,7 +261,7 @@ class TextTrackSettings extends Component {
const windowOpacity = getSelectedOptionValue(this.$('.vjs-window-opacity > select'));
const fontPercent = window.parseFloat(getSelectedOptionValue(this.$('.vjs-font-percent > select')));
let result = {
const result = {
fontPercent,
fontFamily,
textOpacity,
@ -273,7 +273,7 @@ class TextTrackSettings extends Component {
backgroundColor: bgColor
};
for (let name in result) {
for (const name in result) {
if (result[name] === '' || result[name] === 'none' || (name === 'fontPercent' && result[name] === 1.00)) {
delete result[name];
}
@ -349,7 +349,7 @@ class TextTrackSettings extends Component {
return;
}
let values = this.getValues();
const values = this.getValues();
try {
if (Object.getOwnPropertyNames(values).length > 0) {
@ -368,7 +368,7 @@ class TextTrackSettings extends Component {
* @method updateDisplay
*/
updateDisplay() {
let ttDisplay = this.player_.getChild('textTrackDisplay');
const ttDisplay = this.player_.getChild('textTrackDisplay');
if (ttDisplay) {
ttDisplay.updateDisplay();

View File

@ -19,10 +19,10 @@ import * as browser from '../utils/browser.js';
* @param {Track} track track to addcues to
*/
const parseCues = function(srcContent, track) {
let parser = new window.WebVTT.Parser(window,
const parser = new window.WebVTT.Parser(window,
window.vttjs,
window.WebVTT.StringDecoder());
let errors = [];
const errors = [];
parser.oncue = function(cue) {
track.addCue(cue);
@ -60,10 +60,10 @@ const parseCues = function(srcContent, track) {
* @param {Track} track track to addcues to
*/
const loadTrack = function(src, track) {
let opts = {
const opts = {
uri: src
};
let crossOrigin = isCrossOrigin(src);
const crossOrigin = isCrossOrigin(src);
if (crossOrigin) {
opts.cors = crossOrigin;
@ -80,7 +80,7 @@ const loadTrack = function(src, track) {
// NOTE: this is only used for the alt/video.novtt.js build
if (typeof window.WebVTT !== 'function') {
if (track.tech_) {
let loadHandler = () => parseCues(responseBody, track);
const loadHandler = () => parseCues(responseBody, track);
track.tech_.on('vttjsloaded', loadHandler);
track.tech_.on('vttjserror', () => {
@ -129,24 +129,24 @@ class TextTrack extends Track {
throw new Error('A tech was not provided.');
}
let settings = merge(options, {
const settings = merge(options, {
kind: TextTrackKind[options.kind] || 'subtitles',
language: options.language || options.srclang || ''
});
let mode = TextTrackMode[settings.mode] || 'disabled';
let default_ = settings.default;
const default_ = settings.default;
if (settings.kind === 'metadata' || settings.kind === 'chapters') {
mode = 'hidden';
}
// on IE8 this will be a document element
// for every other browser this will be a normal object
let tt = super(settings);
const tt = super(settings);
tt.tech_ = settings.tech;
if (browser.IS_IE8) {
for (let prop in TextTrack.prototype) {
for (const prop in TextTrack.prototype) {
if (prop !== 'constructor') {
tt[prop] = TextTrack.prototype[prop];
}
@ -156,15 +156,17 @@ class TextTrack extends Track {
tt.cues_ = [];
tt.activeCues_ = [];
let cues = new TextTrackCueList(tt.cues_);
let activeCues = new TextTrackCueList(tt.activeCues_);
const cues = new TextTrackCueList(tt.cues_);
const activeCues = new TextTrackCueList(tt.activeCues_);
let changed = false;
let timeupdateHandler = Fn.bind(tt, function() {
const timeupdateHandler = Fn.bind(tt, function() {
// Accessing this.activeCues for the side-effects of updating itself
// due to it's nature as a getter function. Do not remove or cues will
// stop updating!
/* eslint-disable no-unused-expressions */
this.activeCues;
/* eslint-enable no-unused-expressions */
if (changed) {
this.trigger('cuechange');
changed = false;
@ -220,11 +222,11 @@ class TextTrack extends Track {
return activeCues;
}
let ct = this.tech_.currentTime();
let active = [];
const ct = this.tech_.currentTime();
const active = [];
for (let i = 0, l = this.cues.length; i < l; i++) {
let cue = this.cues[i];
const cue = this.cues[i];
if (cue.startTime <= ct && cue.endTime >= ct) {
active.push(cue);
@ -272,7 +274,7 @@ class TextTrack extends Track {
* @method addCue
*/
addCue(cue) {
let tracks = this.tech_.textTracks();
const tracks = this.tech_.textTracks();
if (tracks) {
for (let i = 0; i < tracks.length; i++) {
@ -296,7 +298,7 @@ class TextTrack extends Track {
let removed = false;
for (let i = 0, l = this.cues_.length; i < l; i++) {
let cue = this.cues_[i];
const cue = this.cues_[i];
if (cue === removeCue) {
this.cues_.splice(i, 1);

View File

@ -22,7 +22,7 @@ class TrackList extends EventTarget {
list = this; // eslint-disable-line
if (browser.IS_IE8) {
list = document.createElement('custom');
for (let prop in TrackList.prototype) {
for (const prop in TrackList.prototype) {
if (prop !== 'constructor') {
list[prop] = TrackList.prototype[prop];
}
@ -52,7 +52,7 @@ class TrackList extends EventTarget {
* @private
*/
addTrack_(track) {
let index = this.tracks_.length;
const index = this.tracks_.length;
if (!('' + index in this)) {
Object.defineProperty(this, index, {
@ -117,7 +117,7 @@ class TrackList extends EventTarget {
let result = null;
for (let i = 0, l = this.length; i < l; i++) {
let track = this[i];
const track = this[i];
if (track.id === id) {
result = track;
@ -141,7 +141,7 @@ TrackList.prototype.allowedEvents_ = {
};
// emulate attribute EventHandler support to allow for feature detection
for (let event in TrackList.prototype.allowedEvents_) {
for (const event in TrackList.prototype.allowedEvents_) {
TrackList.prototype['on' + event] = null;
}

View File

@ -23,21 +23,21 @@ class Track extends EventTarget {
if (browser.IS_IE8) {
track = document.createElement('custom');
for (let prop in Track.prototype) {
for (const prop in Track.prototype) {
if (prop !== 'constructor') {
track[prop] = Track.prototype[prop];
}
}
}
let trackProps = {
const trackProps = {
id: options.id || 'vjs_track_' + Guid.newGUID(),
kind: options.kind || '',
label: options.label || '',
language: options.language || ''
};
for (let key in trackProps) {
for (const key in trackProps) {
Object.defineProperty(track, key, {
get() {
return trackProps[key];

View File

@ -59,12 +59,12 @@ class VideoTrackList extends TrackList {
// as it does not support Object.defineProperty properly
if (browser.IS_IE8) {
list = document.createElement('custom');
for (let prop in TrackList.prototype) {
for (const prop in TrackList.prototype) {
if (prop !== 'constructor') {
list[prop] = TrackList.prototype[prop];
}
}
for (let prop in VideoTrackList.prototype) {
for (const prop in VideoTrackList.prototype) {
if (prop !== 'constructor') {
list[prop] = VideoTrackList.prototype[prop];
}

View File

@ -20,17 +20,17 @@ import * as browser from '../utils/browser.js';
*/
class VideoTrack extends Track {
constructor(options = {}) {
let settings = merge(options, {
const settings = merge(options, {
kind: VideoTrackKind[options.kind] || ''
});
// on IE8 this will be a document element
// for every other browser this will be a normal object
let track = super(settings);
const track = super(settings);
let selected = false;
if (browser.IS_IE8) {
for (let prop in VideoTrack.prototype) {
for (const prop in VideoTrack.prototype) {
if (prop !== 'constructor') {
track[prop] = VideoTrack.prototype[prop];
}

View File

@ -25,7 +25,7 @@ export const IS_IPOD = (/iPod/i).test(USER_AGENT);
export const IS_IOS = IS_IPHONE || IS_IPAD || IS_IPOD;
export const IOS_VERSION = (function() {
let match = USER_AGENT.match(/OS (\d+)_/i);
const match = USER_AGENT.match(/OS (\d+)_/i);
if (match && match[1]) {
return match[1];
@ -36,16 +36,14 @@ export const IS_ANDROID = (/Android/i).test(USER_AGENT);
export const ANDROID_VERSION = (function() {
// This matches Android Major.Minor.Patch versions
// ANDROID_VERSION is Major.Minor as a Number, if Minor isn't available, then only Major is returned
let match = USER_AGENT.match(/Android (\d+)(?:\.(\d+))?(?:\.(\d+))*/i);
let major;
let minor;
const match = USER_AGENT.match(/Android (\d+)(?:\.(\d+))?(?:\.(\d+))*/i);
if (!match) {
return null;
}
major = match[1] && parseFloat(match[1]);
minor = match[2] && parseFloat(match[2]);
const major = match[1] && parseFloat(match[1]);
const minor = match[2] && parseFloat(match[2]);
if (major && minor) {
return parseFloat(match[1] + '.' + match[2]);

View File

@ -97,10 +97,10 @@ export function getEl(id) {
* @function createEl
*/
export function createEl(tagName = 'div', properties = {}, attributes = {}) {
let el = document.createElement(tagName);
const el = document.createElement(tagName);
Object.getOwnPropertyNames(properties).forEach(function(propName) {
let val = properties[propName];
const val = properties[propName];
// See #2176
// We originally were accepting both properties and attributes in the
@ -220,7 +220,7 @@ export function hasElData(el) {
* @function removeElData
*/
export function removeElData(el) {
let id = el[elIdAttr];
const id = el[elIdAttr];
if (!id) {
return;
@ -314,7 +314,7 @@ export function toggleElClass(element, classToToggle, predicate) {
// This CANNOT use `classList` internally because IE does not support the
// second parameter to the `classList.toggle()` method! Which is fine because
// `classList` will be used by the add/remove functions.
let has = hasElClass(element, classToToggle);
const has = hasElClass(element, classToToggle);
if (typeof predicate === 'function') {
predicate = predicate(element, classToToggle);
@ -349,7 +349,7 @@ export function toggleElClass(element, classToToggle, predicate) {
*/
export function setElAttributes(el, attributes) {
Object.getOwnPropertyNames(attributes).forEach(function(attrName) {
let attrValue = attributes[attrName];
const attrValue = attributes[attrName];
if (attrValue === null || typeof attrValue === 'undefined' || attrValue === false) {
el.removeAttribute(attrName);
@ -371,25 +371,19 @@ export function setElAttributes(el, attributes) {
* @function getElAttributes
*/
export function getElAttributes(tag) {
let obj;
let knownBooleans;
let attrs;
let attrName;
let attrVal;
obj = {};
const obj = {};
// known boolean attributes
// we can check for matching boolean properties, but older browsers
// won't know about HTML5 boolean attributes that we still read from
knownBooleans = ',' + 'autoplay,controls,loop,muted,default' + ',';
const knownBooleans = ',' + 'autoplay,controls,loop,muted,default' + ',';
if (tag && tag.attributes && tag.attributes.length > 0) {
attrs = tag.attributes;
const attrs = tag.attributes;
for (let i = attrs.length - 1; i >= 0; i--) {
attrName = attrs[i].name;
attrVal = attrs[i].value;
const attrName = attrs[i].name;
let attrVal = attrs[i].value;
// check for known booleans
// the matching element property will return a value for typeof
@ -484,13 +478,13 @@ export function findElPosition(el) {
* @return {Object} This object will have x and y coordinates corresponding to the mouse position
*/
export function getPointerPosition(el, event) {
let position = {};
let box = findElPosition(el);
let boxW = el.offsetWidth;
let boxH = el.offsetHeight;
const position = {};
const box = findElPosition(el);
const boxW = el.offsetWidth;
const boxH = el.offsetHeight;
let boxY = box.top;
let boxX = box.left;
const boxY = box.top;
const boxX = box.left;
let pageY = event.pageY;
let pageX = event.pageX;

View File

@ -21,7 +21,7 @@ import document from 'global/document';
* @method _cleanUpEvents
*/
function _cleanUpEvents(elem, type) {
let data = Dom.getElData(elem);
const data = Dom.getElData(elem);
// Remove the events of a particular type if there are none left
if (data.handlers[type].length === 0) {
@ -91,7 +91,7 @@ export function fixEvent(event) {
// other expected methods like isPropagationStopped. Seems to be a problem
// with the Javascript Ninja code. So we're just overriding all events now.
if (!event || !event.isPropagationStopped) {
let old = event || window.event;
const old = event || window.event;
event = {};
// Clone the old object so that we can modify the values event = {};
@ -99,7 +99,7 @@ export function fixEvent(event) {
// Firefox returns false for event.hasOwnProperty('type') and other props
// which makes copying more difficult.
// TODO: Probably best to create a whitelist of event props
for (let key in old) {
for (const key in old) {
// Safari 6.0.3 warns you if you try to copy deprecated layerX/Y
// Chrome warns you if you try to copy deprecated keyboardEvent.keyLocation
// and webkitMovementX/Y
@ -161,9 +161,9 @@ export function fixEvent(event) {
event.isImmediatePropagationStopped = returnFalse;
// Handle mouse position
if (event.clientX != null) {
let doc = document.documentElement;
let body = document.body;
if (event.clientX !== null && event.clientX !== undefined) {
const doc = document.documentElement;
const body = document.body;
event.pageX = event.clientX +
(doc && doc.scrollLeft || body && body.scrollLeft || 0) -
@ -178,7 +178,7 @@ export function fixEvent(event) {
// Fix button for mouse clicks:
// 0 == left; 1 == middle; 2 == right
if (event.button != null) {
if (event.button !== null && event.button !== undefined) {
// The following is disabled because it does not pass videojs-standard
// and... yikes.
@ -210,7 +210,7 @@ export function on(elem, type, fn) {
return _handleMultipleEvents(on, elem, type, fn);
}
let data = Dom.getElData(elem);
const data = Dom.getElData(elem);
// We need a place to store all our handler data
if (!data.handlers) {
@ -238,11 +238,11 @@ export function on(elem, type, fn) {
event = fixEvent(event);
let handlers = data.handlers[event.type];
const handlers = data.handlers[event.type];
if (handlers) {
// Copy handlers so if handlers are added/removed during the process it doesn't throw everything off.
let handlersCopy = handlers.slice(0);
const handlersCopy = handlers.slice(0);
for (let m = 0, n = handlersCopy.length; m < n; m++) {
if (event.isImmediatePropagationStopped()) {
@ -278,7 +278,7 @@ export function off(elem, type, fn) {
return;
}
let data = Dom.getElData(elem);
const data = Dom.getElData(elem);
// If no events exist, nothing to unbind
if (!data.handlers) {
@ -290,20 +290,20 @@ export function off(elem, type, fn) {
}
// Utility function
let removeType = function(t) {
const removeType = function(t) {
data.handlers[t] = [];
_cleanUpEvents(elem, t);
};
// Are we removing all bound events?
if (!type) {
for (let t in data.handlers) {
for (const t in data.handlers) {
removeType(t);
}
return;
}
let handlers = data.handlers[type];
const handlers = data.handlers[type];
// If no handlers exist, nothing to unbind
if (!handlers) {
@ -341,8 +341,8 @@ export function trigger(elem, event, hash) {
// Fetches element data and a reference to the parent (for bubbling).
// Don't want to add a data object to cache for every parent,
// so checking hasElData first.
let elemData = (Dom.hasElData(elem)) ? Dom.getElData(elem) : {};
let parent = elem.parentNode || elem.ownerDocument;
const elemData = (Dom.hasElData(elem)) ? Dom.getElData(elem) : {};
const parent = elem.parentNode || elem.ownerDocument;
// type = event.type || event,
// handler;
@ -365,7 +365,7 @@ export function trigger(elem, event, hash) {
// If at the top of the DOM, triggers the default action unless disabled.
} else if (!parent && !event.defaultPrevented) {
let targetData = Dom.getElData(event.target);
const targetData = Dom.getElData(event.target);
// Checks if the target has a default action for this event.
if (event.target[event.type]) {
@ -396,7 +396,7 @@ export function one(elem, type, fn) {
if (Array.isArray(type)) {
return _handleMultipleEvents(one, elem, type, fn);
}
let func = function() {
const func = function() {
off(elem, type, func);
fn.apply(this, arguments);
};

View File

@ -21,7 +21,7 @@ export const bind = function(context, fn, uid) {
}
// Create the new function that changes the context
let ret = function() {
const ret = function() {
return fn.apply(context, arguments);
};

View File

@ -10,14 +10,12 @@ function isPlain(obj) {
obj.constructor === Object;
}
let mergeOptions;
/**
* Merge customizer. video.js simply overwrites non-simple objects
* (like arrays) instead of attempting to overlay them.
* @see https://lodash.com/docs#merge
*/
const customizer = function(destination, source) {
function customizer(destination, source) {
// If we're not working with a plain object, copy the value as is
// If source is an array, for instance, it will replace destination
if (!isPlain(source)) {
@ -32,7 +30,7 @@ const customizer = function(destination, source) {
if (!isPlain(destination)) {
return mergeOptions(source);
}
};
}
/**
* Merge one or more options objects, recursively merging **only**
@ -43,10 +41,10 @@ const customizer = function(destination, source) {
* provided objects
* @function mergeOptions
*/
mergeOptions = function() {
export default function mergeOptions() {
// contruct the call dynamically to handle the variable number of
// objects to merge
let args = Array.prototype.slice.call(arguments);
const args = Array.prototype.slice.call(arguments);
// unshift an empty object into the front of the call as the target
// of the merge
@ -59,6 +57,4 @@ mergeOptions = function() {
// return the mutated result object
return args[0];
};
export default mergeOptions;
}

View File

@ -1,14 +1,14 @@
import document from 'global/document';
export let createStyleElement = function(className) {
let style = document.createElement('style');
export const createStyleElement = function(className) {
const style = document.createElement('style');
style.className = className;
return style;
};
export let setTextContent = function(el, content) {
export const setTextContent = function(el, content) {
if (el.styleSheet) {
el.styleSheet.cssText = content;
} else {

View File

@ -22,7 +22,7 @@ export const parseUrl = function(url) {
// IE8 (and 9?) Fix
// ie8 doesn't parse the URL correctly until the anchor is actually
// added to the body, and an innerHTML is needed to trigger the parsing
let addToBody = (a.host === '' && a.protocol !== 'file:');
const addToBody = (a.host === '' && a.protocol !== 'file:');
let div;
if (addToBody) {
@ -37,7 +37,7 @@ export const parseUrl = function(url) {
// Copy the specific URL properties to a new object
// This is also needed for IE8 because the anchor loses its
// properties when it's removed from the dom
let details = {};
const details = {};
for (let i = 0; i < props.length; i++) {
details[props[i]] = a[props[i]];
@ -73,7 +73,7 @@ export const getAbsoluteURL = function(url) {
// Check if absolute URL
if (!url.match(/^https?:\/\//)) {
// Convert to absolute URL. Flash hosted off-site needs an absolute URL.
let div = document.createElement('div');
const div = document.createElement('div');
div.innerHTML = `<a href="${url}">x</a>`;
url = div.firstChild.href;
@ -91,8 +91,8 @@ export const getAbsoluteURL = function(url) {
*/
export const getFileExtension = function(path) {
if (typeof path === 'string') {
let splitPathRe = /^(\/?)([\s\S]*?)((?:\.{1,2}|[^\/]+?)(\.([^\.\/\?]+)))(?:[\/]*|[\?].*)$/i;
let pathParts = splitPathRe.exec(path);
const splitPathRe = /^(\/?)([\s\S]*?)((?:\.{1,2}|[^\/]+?)(\.([^\.\/\?]+)))(?:[\/]*|[\?].*)$/i;
const pathParts = splitPathRe.exec(path);
if (pathParts) {
return pathParts.pop().toLowerCase();
@ -110,15 +110,15 @@ export const getFileExtension = function(path) {
* @method isCrossOrigin
*/
export const isCrossOrigin = function(url) {
let winLoc = window.location;
let urlInfo = parseUrl(url);
const winLoc = window.location;
const urlInfo = parseUrl(url);
// IE8 protocol relative urls will return ':' for protocol
let srcProtocol = urlInfo.protocol === ':' ? winLoc.protocol : urlInfo.protocol;
const srcProtocol = urlInfo.protocol === ':' ? winLoc.protocol : urlInfo.protocol;
// Check if url is for another domain/origin
// IE8 doesn't know location.origin, so we won't rely on it here
let crossOrigin = (srcProtocol + urlInfo.host) !== (winLoc.protocol + winLoc.host);
const crossOrigin = (srcProtocol + urlInfo.host) !== (winLoc.protocol + winLoc.host);
return crossOrigin;
};

View File

@ -106,7 +106,7 @@ if (window.VIDEOJS_NO_DYNAMIC_STYLE !== true) {
if (!style) {
style = stylesheet.createStyleElement('vjs-styles-defaults');
let head = Dom.$('head');
const head = Dom.$('head');
head.insertBefore(style, head.firstChild);
stylesheet.setTextContent(style, `