Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove method Chaining from videojs #3860

Merged
merged 4 commits into from
Jan 18, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 1 addition & 12 deletions src/js/clickable-component.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,8 @@ class ClickableComponent extends Component {
* @param {Element} [el=this.el()]
* Element to set the title on.
*
* @return {string|ClickableComponent}
* @return {string}
* - The control text when getting
* - Returns itself when setting; method can be chained.
*/
controlText(text, el = this.el()) {
if (!text) {
Expand All @@ -122,8 +121,6 @@ class ClickableComponent extends Component {
this.controlText_ = text;
this.controlTextEl_.innerHTML = localizedText;
el.setAttribute('title', localizedText);

return this;
}

/**
Expand All @@ -138,9 +135,6 @@ class ClickableComponent extends Component {

/**
* Enable this `Component`s element.
*
* @return {ClickableComponent}
* Returns itself; method can be chained.
*/
enable() {
this.removeClass('vjs-disabled');
Expand All @@ -152,14 +146,10 @@ class ClickableComponent extends Component {
this.on('click', this.handleClick);
this.on('focus', this.handleFocus);
this.on('blur', this.handleBlur);
return this;
}

/**
* Disable this `Component`s element.
*
* @return {ClickableComponent}
* Returns itself; method can be chained.
*/
disable() {
this.addClass('vjs-disabled');
Expand All @@ -171,7 +161,6 @@ class ClickableComponent extends Component {
this.off('click', this.handleClick);
this.off('focus', this.handleFocus);
this.off('blur', this.handleBlur);
return this;
}

/**
Expand Down
85 changes: 10 additions & 75 deletions src/js/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -573,9 +573,6 @@ class Component {
* The event handler if `first` is a `Component` and `second` is an event name
* or an Array of event names.
*
* @return {Component}
* Returns itself; method can be chained.
*
* @listens Component#dispose
*/
on(first, second, third) {
Expand Down Expand Up @@ -618,8 +615,6 @@ class Component {
target.on('dispose', cleanRemover);
}
}

return this;
}

/**
Expand All @@ -635,9 +630,6 @@ class Component {
* @param {EventTarget~EventListener} [third]
* The event handler if `first` is a `Component` and `second` is an event name
* or an Array of event names.
*
* @return {Component}
* Returns itself; method can be chained.
*/
off(first, second, third) {
if (!first || typeof first === 'string' || Array.isArray(first)) {
Expand All @@ -662,8 +654,6 @@ class Component {
target.off('dispose', fn);
}
}

return this;
}

/**
Expand All @@ -678,9 +668,6 @@ class Component {
* @param {EventTarget~EventListener} [third]
* The event handler if `first` is a `Component` and `second` is an event name
* or an Array of event names.
*
* @return {Component}
* Returns itself; method can be chained.
*/
one(first, second, third) {
if (typeof first === 'string' || Array.isArray(first)) {
Expand All @@ -700,8 +687,6 @@ class Component {

this.on(target, type, newFunc);
}

return this;
}

/**
Expand All @@ -713,13 +698,9 @@ class Component {
*
* @param {Object} [hash]
* Data hash to pass along with the event
*
* @return {Component}
* Returns itself; method can be chained.
*/
trigger(event, hash) {
Events.trigger(this.el_, event, hash);
return this;
}

/**
Expand All @@ -731,9 +712,6 @@ class Component {
*
* @param {boolean} [sync=false]
* Execute the listener synchronously if `Component` is ready.
*
* @return {Component}
* Returns itself; method can be chained.
*/
ready(fn, sync = false) {
if (fn) {
Expand All @@ -749,7 +727,6 @@ class Component {
this.readyQueue_.push(fn);
}
}
return this;
}

/**
Expand Down Expand Up @@ -847,27 +824,19 @@ class Component {
*
* @param {string} classToAdd
* CSS class name to add
*
* @return {Component}
* Returns itself; method can be chained.
*/
addClass(classToAdd) {
Dom.addElClass(this.el_, classToAdd);
return this;
}

/**
* Remove a CSS class name from the `Component`s element.
*
* @param {string} classToRemove
* CSS class name to remove
*
* @return {Component}
* Returns itself; method can be chained.
*/
removeClass(classToRemove) {
Dom.removeElClass(this.el_, classToRemove);
return this;
}

/**
Expand All @@ -880,65 +849,45 @@ class Component {
*
* @param {boolean|Dom~predicate} [predicate]
* An {@link Dom~predicate} function or a boolean
*
* @return {Component}
* Returns itself; method can be chained.
*/
toggleClass(classToToggle, predicate) {
Dom.toggleElClass(this.el_, classToToggle, predicate);
return this;
}

/**
* Show the `Component`s element if it is hidden by removing the
* 'vjs-hidden' class name from it.
*
* @return {Component}
* Returns itself; method can be chained.
*/
show() {
this.removeClass('vjs-hidden');
return this;
}

/**
* Hide the `Component`s element if it is currently showing by adding the
* 'vjs-hidden` class name to it.
*
* @return {Component}
* Returns itself; method can be chained.
*/
hide() {
this.addClass('vjs-hidden');
return this;
}

/**
* Lock a `Component`s element in its visible state by adding the 'vjs-lock-showing'
* class name to it. Used during fadeIn/fadeOut.
*
* @return {Component}
* Returns itself; method can be chained.
*
* @private
*/
lockShowing() {
this.addClass('vjs-lock-showing');
return this;
}

/**
* Unlock a `Component`s element from its visible state by removing the 'vjs-lock-showing'
* class name from it. Used during fadeIn/fadeOut.
*
* @return {Component}
* Returns itself; method can be chained.
*
* @private
*/
unlockShowing() {
this.removeClass('vjs-lock-showing');
return this;
}

/**
Expand Down Expand Up @@ -969,14 +918,10 @@ class Component {
* @param {string} value
* Value to set the attribute to.
*
* @return {Component}
* Returns itself; method can be chained.
*
* @see [DOM API]{@link https://developer.mozilla.org/en-US/docs/Web/API/Element/setAttribute}
*/
setAttribute(attribute, value) {
Dom.setAttribute(this.el_, attribute, value);
return this;
}

/**
Expand All @@ -985,14 +930,10 @@ class Component {
* @param {string} attribute
* Name of the attribute to remove.
*
* @return {Component}
* Returns itself; method can be chained.
*
* @see [DOM API]{@link https://developer.mozilla.org/en-US/docs/Web/API/Element/removeAttribute}
*/
removeAttribute(attribute) {
Dom.removeAttribute(this.el_, attribute);
return this;
}

/**
Expand All @@ -1005,10 +946,9 @@ class Component {
* @param {boolean} [skipListeners]
* Skip the resize event trigger
*
* @return {Component|number|string}
* - The width when getting, zero if there is no width. Can be a string
* @return {number|string}
* The width when getting, zero if there is no width. Can be a string
* postpixed with '%' or 'px'.
* - Returns itself when setting; method can be chained.
*/
width(num, skipListeners) {
return this.dimension('width', num, skipListeners);
Expand All @@ -1024,10 +964,9 @@ class Component {
* @param {boolean} [skipListeners]
* Skip the resize event trigger
*
* @return {Component|number|string}
* - The width when getting, zero if there is no width. Can be a string
* postpixed with '%' or 'px'.
* - Returns itself when setting; method can be chained.
* @return {number|string}
* The width when getting, zero if there is no width. Can be a string
* postpixed with '%' or 'px'.
*/
height(num, skipListeners) {
return this.dimension('height', num, skipListeners);
Expand All @@ -1041,13 +980,11 @@ class Component {
*
* @param {number|string} height
* Height to set the `Component`s element to.
*
* @return {Component}
* Returns itself; method can be chained.
*/
dimensions(width, height) {
// Skip resize listeners on width for optimization
return this.width(width, true).height(height);
this.width(width, true);
this.height(height);
}

/**
Expand Down Expand Up @@ -1075,9 +1012,8 @@ class Component {
* @param {boolean} [skipListeners]
* Skip resize event trigger
*
* @return {Component}
* - the dimension when getting or 0 if unset
* - Returns itself when setting; method can be chained.
* @return {number}
* The dimension when getting or 0 if unset
*/
dimension(widthOrHeight, num, skipListeners) {
if (num !== undefined) {
Expand Down Expand Up @@ -1106,8 +1042,7 @@ class Component {
this.trigger('resize');
}

// Return component
return this;
return;
}

// Not setting a value, so getting it
Expand Down
11 changes: 2 additions & 9 deletions src/js/menu/menu-button.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,9 +245,6 @@ class MenuButton extends ClickableComponent {

/**
* Disable the `MenuButton`. Don't allow it to be clicked.
*
* @return {MenuButton}
* Returns itself; method can be chained.
*/
disable() {
// Unpress, but don't force focus on this button
Expand All @@ -257,19 +254,15 @@ class MenuButton extends ClickableComponent {

this.enabled_ = false;

return super.disable();
super.disable();
}

/**
* Enable the `MenuButton`. Allow it to be clicked.
*
* @return {MenuButton}
* Returns itself; method can be chained.
*/
enable() {
this.enabled_ = true;

return super.enable();
super.enable();
}
}

Expand Down
Loading