Permalink
Browse files

refactor: player.controls() (#4731)

  • Loading branch information...
kocoten1992 authored and gkatsev committed Nov 16, 2017
1 parent c16fedf commit d447e9fe11ce4176b5b500751a6de1777f52f4ff
Showing with 33 additions and 33 deletions.
  1. +33 −33 src/js/player.js
View
@@ -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_;
}
/**

0 comments on commit d447e9f

Please sign in to comment.