Skip to content

Commit

Permalink
Linter v5 Compatibility (videojs#3478)
Browse files Browse the repository at this point in the history
  • Loading branch information
misteroneill committed Aug 3, 2016
1 parent ae2ab52 commit 99724c6
Show file tree
Hide file tree
Showing 39 changed files with 297 additions and 309 deletions.
4 changes: 2 additions & 2 deletions src/js/button.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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.`);

Expand Down
2 changes: 1 addition & 1 deletion src/js/clickable-component.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
52 changes: 26 additions & 26 deletions src/js/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()}`;
}
Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -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`);
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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_ = [];
Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);`
Expand All @@ -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);
};

Expand All @@ -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];
}
Expand Down
2 changes: 1 addition & 1 deletion src/js/error-display.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) : '';
}
Expand Down
6 changes: 3 additions & 3 deletions src/js/event-target.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -28,15 +28,15 @@ 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);
this.addEventListener = ael;
};

EventTarget.prototype.trigger = function(event) {
let type = event.type || event;
const type = event.type || event;

if (typeof event === 'string') {
event = {type};
Expand Down
2 changes: 1 addition & 1 deletion src/js/extend.js
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
Expand Down
4 changes: 2 additions & 2 deletions src/js/fullscreen-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -60,7 +60,7 @@ const apiMap = [
]
];

let specApi = apiMap[0];
const specApi = apiMap[0];
let browserApi;

// determine the supported set of functions
Expand Down
2 changes: 1 addition & 1 deletion src/js/media-error.js
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand Down
14 changes: 7 additions & 7 deletions src/js/modal-dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -242,15 +242,15 @@ 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.
if (closeable && !close) {

// 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'});
Expand Down Expand Up @@ -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;
Expand Down
Loading

0 comments on commit 99724c6

Please sign in to comment.