Skip to content
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
42 changes: 26 additions & 16 deletions build/ableplayer.dist.js
Original file line number Diff line number Diff line change
Expand Up @@ -7542,8 +7542,6 @@ if (typeof module !== "undefined" && module.exports) {
if (options && typeof options.volume !== 'undefined') {
if ( this.signVideo ) {
this.signVideo.volume = 0;
} else {
this.youTubeSignPlayer.setVolume(0);
}
}
}
Expand Down Expand Up @@ -7749,7 +7747,6 @@ if (typeof module !== "undefined" && module.exports) {
this.captionsOn,
ariaLabelOff,
ariaLabelOn,
'buttonOff',
ariaPressed
);
}
Expand Down Expand Up @@ -8019,7 +8016,7 @@ if (typeof module !== "undefined" && module.exports) {
AblePlayer.prototype.handleCaptionToggle = function() {

var thisObj = this;
var captions;
var captions, ariaPressed;
if (this.hidingPopup) {
this.hidingPopup = false;
return false;
Expand All @@ -8030,7 +8027,7 @@ if (typeof module !== "undefined" && module.exports) {
if (this.captionsOn === true) {
this.captionsOn = false;
this.prefCaptions = 0;
this.$ccButton.attr('aria-pressed', 'false');
ariaPressed = false;
this.updateCookie('prefCaptions');
if (this.usingYouTubeCaptions) {
this.youTubePlayer.unloadModule('captions');
Expand All @@ -8042,7 +8039,7 @@ if (typeof module !== "undefined" && module.exports) {
} else {
this.captionsOn = true;
this.prefCaptions = 1;
this.$ccButton.attr('aria-pressed', 'true');
ariaPressed = true;
this.updateCookie('prefCaptions');
if (this.usingYouTubeCaptions) {
this.youTubePlayer.loadModule('captions');
Expand Down Expand Up @@ -8074,7 +8071,6 @@ if (typeof module !== "undefined" && module.exports) {
this.selectedDescriptions = this.descriptions[0];
}
}
this.refreshControls('captions');
} else {
if (this.captionsPopup && this.captionsPopup.is(':visible')) {
this.captionsPopup.hide();
Expand All @@ -8096,6 +8092,16 @@ if (typeof module !== "undefined" && module.exports) {
}
}
}
var ariaLabelOn = ( captions.length > 1 ) ? this.tt.captions : this.tt.showCaptions;
var ariaLabelOff = ( captions.length > 1 ) ? this.tt.captions : this.tt.hideCaptions;

this.toggleButtonState(
this.$ccButton,
this.captionsOn,
ariaLabelOff,
ariaLabelOn,
ariaPressed
);
};

AblePlayer.prototype.waitThenFocus = function($el, timeout) {
Expand Down Expand Up @@ -8198,7 +8204,7 @@ if (typeof module !== "undefined" && module.exports) {
var visible = this.$transcriptDiv.is(':visible');
if ( visible ) {
this.$transcriptArea.hide();
this.toggleButtonState( this.$transcriptButton, visible, this.tt.hideTranscript, this.tt.showTranscript );
this.toggleButtonState( this.$transcriptButton, ! visible, this.tt.hideTranscript, this.tt.showTranscript );
this.prefTranscript = 0;
if ( this.transcriptType === 'popup' ) {
this.$transcriptButton.trigger('focus').addClass('able-focus');
Expand All @@ -8211,15 +8217,15 @@ if (typeof module !== "undefined" && module.exports) {
this.positionDraggableWindow('transcript');
this.$transcriptArea.show();
this.$transcriptPopup.hide();
this.toggleButtonState( this.$transcriptButton, visible, this.tt.hideTranscript, this.tt.showTranscript );
this.toggleButtonState( this.$transcriptButton, ! visible, this.tt.hideTranscript, this.tt.showTranscript );
this.prefTranscript = 1;
this.focusNotClick = true;
this.$transcriptArea.find('button').first().trigger('focus');
setTimeout(function() {
thisObj.focusNotClick = false;
}, 100);
} else {
this.toggleButtonState( this.$transcriptButton, visible, this.tt.hideTranscript, this.tt.showTranscript );
this.toggleButtonState( this.$transcriptButton, ! visible, this.tt.hideTranscript, this.tt.showTranscript );
this.$transcriptArea.show();
}
}
Expand All @@ -8232,7 +8238,7 @@ if (typeof module !== "undefined" && module.exports) {
var visible = this.$signWindow.is(':visible');
if ( visible ) {
this.$signWindow.hide();
this.toggleButtonState( this.$signButton, visible, this.tt.hideSign, this.tt.showSign );
this.toggleButtonState( this.$signButton, ! visible, this.tt.hideSign, this.tt.showSign );
this.prefSign = 0;
this.$signButton.trigger('focus').addClass('able-focus');
setTimeout(function() {
Expand All @@ -8242,7 +8248,7 @@ if (typeof module !== "undefined" && module.exports) {
this.positionDraggableWindow('sign');
this.$signWindow.show();
this.$signPopup.hide();
this.toggleButtonState( this.$signButton, visible, this.tt.hideSign, this.tt.showSign );
this.toggleButtonState( this.$signButton, ! visible, this.tt.hideSign, this.tt.showSign );
this.prefSign = 1;
this.focusNotClick = true;
this.$signWindow.find('button').first().trigger('focus');
Expand Down Expand Up @@ -8440,9 +8446,13 @@ if (typeof module !== "undefined" && module.exports) {
$button.append($buttonLabel);
};

AblePlayer.prototype.toggleButtonState = function($button, isOn, onLabel, offLabel, offClass = 'buttonOff', ariaPressed = false, ariaExpanded = false) {
if (isOn) {
$button.addClass(offClass).attr('aria-label', offLabel);
AblePlayer.prototype.toggleButtonState = function($button, isOn, onLabel, offLabel, ariaPressed = false, ariaExpanded = false) {
let buttonOff = ( $button.hasClass( 'buttonOff' ) ) ? true : false;
if ( buttonOff && ! isOn || ! buttonOff && isOn ) {
return;
}
if (! isOn) {
$button.addClass('buttonOff').attr('aria-label', offLabel);
$button.find('span.able-clipped').text(offLabel);
if ( ariaPressed ) {
$button.attr('aria-pressed', 'false');
Expand All @@ -8451,7 +8461,7 @@ if (typeof module !== "undefined" && module.exports) {
$button.attr( 'aria-expanded', 'false' );
}
} else {
$button.removeClass(offClass).attr('aria-label', onLabel);
$button.removeClass('buttonOff').attr('aria-label', onLabel);
$button.find('span.able-clipped').text(onLabel);
if ( ariaPressed ) {
$button.attr('aria-pressed', 'true');
Expand Down
45 changes: 28 additions & 17 deletions build/ableplayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -9173,8 +9173,6 @@ if (typeof module !== "undefined" && module.exports) {
if (options && typeof options.volume !== 'undefined') {
if ( this.signVideo ) {
this.signVideo.volume = 0;
} else {
this.youTubeSignPlayer.setVolume(0);
}
}
}
Expand Down Expand Up @@ -9446,7 +9444,6 @@ if (typeof module !== "undefined" && module.exports) {
this.captionsOn,
ariaLabelOff,
ariaLabelOn,
'buttonOff',
ariaPressed
);
}
Expand Down Expand Up @@ -9762,7 +9759,7 @@ if (typeof module !== "undefined" && module.exports) {
AblePlayer.prototype.handleCaptionToggle = function() {

var thisObj = this;
var captions;
var captions, ariaPressed;
if (this.hidingPopup) {
// stopgap to prevent spacebar in Firefox from reopening popup
// immediately after closing it
Expand All @@ -9777,7 +9774,7 @@ if (typeof module !== "undefined" && module.exports) {
// turn them off
this.captionsOn = false;
this.prefCaptions = 0;
this.$ccButton.attr('aria-pressed', 'false');
ariaPressed = false;
this.updateCookie('prefCaptions');
if (this.usingYouTubeCaptions) {
this.youTubePlayer.unloadModule('captions');
Expand All @@ -9790,7 +9787,7 @@ if (typeof module !== "undefined" && module.exports) {
// captions are off. Turn them on.
this.captionsOn = true;
this.prefCaptions = 1;
this.$ccButton.attr('aria-pressed', 'true');
ariaPressed = true;
this.updateCookie('prefCaptions');
if (this.usingYouTubeCaptions) {
this.youTubePlayer.loadModule('captions');
Expand Down Expand Up @@ -9828,7 +9825,6 @@ if (typeof module !== "undefined" && module.exports) {
this.selectedDescriptions = this.descriptions[0];
}
}
this.refreshControls('captions');
} else {
// there is more than one caption track.
// clicking on a track is handled via caption.js > getCaptionClickFunction()
Expand All @@ -9854,6 +9850,16 @@ if (typeof module !== "undefined" && module.exports) {
}
}
}
var ariaLabelOn = ( captions.length > 1 ) ? this.tt.captions : this.tt.showCaptions;
var ariaLabelOff = ( captions.length > 1 ) ? this.tt.captions : this.tt.hideCaptions;

this.toggleButtonState(
this.$ccButton,
this.captionsOn,
ariaLabelOff,
ariaLabelOn,
ariaPressed
);
};

/**
Expand Down Expand Up @@ -9983,7 +9989,7 @@ if (typeof module !== "undefined" && module.exports) {
var visible = this.$transcriptDiv.is(':visible');
if ( visible ) {
this.$transcriptArea.hide();
this.toggleButtonState( this.$transcriptButton, visible, this.tt.hideTranscript, this.tt.showTranscript );
this.toggleButtonState( this.$transcriptButton, ! visible, this.tt.hideTranscript, this.tt.showTranscript );
this.prefTranscript = 0;
if ( this.transcriptType === 'popup' ) {
this.$transcriptButton.trigger('focus').addClass('able-focus');
Expand All @@ -10002,7 +10008,7 @@ if (typeof module !== "undefined" && module.exports) {
// showing transcriptArea has a cascading effect of showing all content *within* transcriptArea
// need to re-hide the popup menu
this.$transcriptPopup.hide();
this.toggleButtonState( this.$transcriptButton, visible, this.tt.hideTranscript, this.tt.showTranscript );
this.toggleButtonState( this.$transcriptButton, ! visible, this.tt.hideTranscript, this.tt.showTranscript );
this.prefTranscript = 1;
// move focus to first focusable element (window options button)
this.focusNotClick = true;
Expand All @@ -10012,7 +10018,7 @@ if (typeof module !== "undefined" && module.exports) {
thisObj.focusNotClick = false;
}, 100);
} else {
this.toggleButtonState( this.$transcriptButton, visible, this.tt.hideTranscript, this.tt.showTranscript );
this.toggleButtonState( this.$transcriptButton, ! visible, this.tt.hideTranscript, this.tt.showTranscript );
this.$transcriptArea.show();
}
}
Expand All @@ -10025,7 +10031,7 @@ if (typeof module !== "undefined" && module.exports) {
var visible = this.$signWindow.is(':visible');
if ( visible ) {
this.$signWindow.hide();
this.toggleButtonState( this.$signButton, visible, this.tt.hideSign, this.tt.showSign );
this.toggleButtonState( this.$signButton, ! visible, this.tt.hideSign, this.tt.showSign );
this.prefSign = 0;
this.$signButton.trigger('focus').addClass('able-focus');
// wait briefly before resetting stopgap var
Expand All @@ -10039,7 +10045,7 @@ if (typeof module !== "undefined" && module.exports) {
// showing signWindow has a cascading effect of showing all content *within* signWindow
// need to re-hide the popup menu
this.$signPopup.hide();
this.toggleButtonState( this.$signButton, visible, this.tt.hideSign, this.tt.showSign );
this.toggleButtonState( this.$signButton, ! visible, this.tt.hideSign, this.tt.showSign );
this.prefSign = 1;
this.focusNotClick = true;
this.$signWindow.find('button').first().trigger('focus');
Expand Down Expand Up @@ -10282,10 +10288,15 @@ if (typeof module !== "undefined" && module.exports) {
$button.append($buttonLabel);
};

AblePlayer.prototype.toggleButtonState = function($button, isOn, onLabel, offLabel, offClass = 'buttonOff', ariaPressed = false, ariaExpanded = false) {
// isOn means "the feature is currently on".
if (isOn) {
$button.addClass(offClass).attr('aria-label', offLabel);
AblePlayer.prototype.toggleButtonState = function($button, isOn, onLabel, offLabel, ariaPressed = false, ariaExpanded = false) {
// isOn means "the feature is being turned on".
let buttonOff = ( $button.hasClass( 'buttonOff' ) ) ? true : false;
if ( buttonOff && ! isOn || ! buttonOff && isOn ) {
// Only toggle state if button state does not match feature state.
return;
}
if (! isOn) {
$button.addClass('buttonOff').attr('aria-label', offLabel);
$button.find('span.able-clipped').text(offLabel);
if ( ariaPressed ) {
$button.attr('aria-pressed', 'false');
Expand All @@ -10294,7 +10305,7 @@ if (typeof module !== "undefined" && module.exports) {
$button.attr( 'aria-expanded', 'false' );
}
} else {
$button.removeClass(offClass).attr('aria-label', onLabel);
$button.removeClass('buttonOff').attr('aria-label', onLabel);
$button.find('span.able-clipped').text(onLabel);
if ( ariaPressed ) {
$button.attr('aria-pressed', 'true');
Expand Down
2 changes: 1 addition & 1 deletion build/ableplayer.min.js

Large diffs are not rendered by default.

Loading