Skip to content

Commit

Permalink
refactor: player.controls() (#4731)
Browse files Browse the repository at this point in the history
  • Loading branch information
kocoten1992 authored and gkatsev committed Nov 16, 2017
1 parent c16fedf commit d447e9f
Showing 1 changed file with 33 additions and 33 deletions.
66 changes: 33 additions & 33 deletions src/js/player.js
Expand Up @@ -2651,46 +2651,46 @@ class Player extends Component {
* The current value of controls when getting
*/
controls(bool) {
if (bool !== undefined) {
bool = !!bool;
if (bool === undefined) {
return !!this.controls_;
}

// Don't trigger a change event unless it actually changed
if (this.controls_ !== bool) {
this.controls_ = bool;
bool = !!bool;

if (this.usingNativeControls()) {
this.techCall_('setControls', bool);
}
// Don't trigger a change event unless it actually changed
if (this.controls_ === bool) {
return;
}

if (bool) {
this.removeClass('vjs-controls-disabled');
this.addClass('vjs-controls-enabled');
/**
* @event Player#controlsenabled
* @type {EventTarget~Event}
*/
this.trigger('controlsenabled');
this.controls_ = bool;

if (!this.usingNativeControls()) {
this.addTechControlsListeners_();
}
} else {
this.removeClass('vjs-controls-enabled');
this.addClass('vjs-controls-disabled');
/**
* @event Player#controlsdisabled
* @type {EventTarget~Event}
*/
this.trigger('controlsdisabled');
if (this.usingNativeControls()) {
this.techCall_('setControls', bool);
}

if (!this.usingNativeControls()) {
this.removeTechControlsListeners_();
}
}
if (this.controls_) {
this.removeClass('vjs-controls-disabled');
this.addClass('vjs-controls-enabled');
/**
* @event Player#controlsenabled
* @type {EventTarget~Event}
*/
this.trigger('controlsenabled');
if (!this.usingNativeControls()) {
this.addTechControlsListeners_();
}
} else {
this.removeClass('vjs-controls-enabled');
this.addClass('vjs-controls-disabled');
/**
* @event Player#controlsdisabled
* @type {EventTarget~Event}
*/
this.trigger('controlsdisabled');
if (!this.usingNativeControls()) {
this.removeTechControlsListeners_();
}
return;
}
return !!this.controls_;
}

/**
Expand Down

0 comments on commit d447e9f

Please sign in to comment.