Skip to content

Commit

Permalink
hack to hide the captions 'language selector' popup when toggleCaptio…
Browse files Browse the repository at this point in the history
…nsButtonWhenOnlyOne is enabled - it doesn't update when the button is clicked and clicking the languages in it has no effect. fixes adaptlearning/adapt_framework#1883
  • Loading branch information
moloko committed Nov 30, 2018
1 parent 66d7e7b commit 52a3d70
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
20 changes: 16 additions & 4 deletions js/adapt-contrib-media.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ define([
* Default shortcut keys trap a screen reader user inside the player once in focus. These keys are unnecessary
* as one may traverse the player in a linear fashion without needing to know or use shortcut keys. Below is
* the removal of the default shortcut keys.
*
* The default seek interval functions are passed two different data types from mejs which they handle incorrectly. One
* is a duration integer the other is the player object. The default functions error on slider key press and so break
*
* The default seek interval functions are passed two different data types from mejs which they handle incorrectly. One
* is a duration integer the other is the player object. The default functions error on slider key press and so break
* accessibility. Below is a correction.
*/
_.extend(mejs.MepDefaults, {
Expand All @@ -57,6 +57,15 @@ define([
"click .js-skip-to-transcript": "onSkipToTranscript"
},

className: function() {
var classes = ComponentView.prototype.className.call(this);
var playerOptions = this.model.get('_playerOptions');
if (playerOptions && playerOptions.toggleCaptionsButtonWhenOnlyOne) {
classes += " toggle-captions";
}
return classes;
},

preRender: function() {
this.listenTo(Adapt, {
'device:resize': this.onScreenSizeChanged,
Expand Down Expand Up @@ -110,7 +119,10 @@ define([
}

/*
Unless we are on Android/iOS and using native controls, when MediaElementJS initializes the player it will invoke the success callback prior to performing one last call to setPlayerSize. This call to setPlayerSize is deferred by 50ms so we add a delay of 100ms here to ensure that we don't invoke setReadyStatus until the player is definitely finished rendering.
Unless we are on Android/iOS and using native controls, when MediaElementJS initializes the player
it will invoke the success callback prior to performing one last call to setPlayerSize.
This call to setPlayerSize is deferred by 50ms so we add a delay of 100ms here to ensure that
we don't invoke setReadyStatus until the player is definitely finished rendering.
*/

modelOptions.success = _.debounce(this.onPlayerReady.bind(this), 100);
Expand Down
8 changes: 8 additions & 0 deletions less/media.less
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,14 @@
-webkit-clip-path: polygon(0px 0px, 0px 0px,0px 0px, 0px 0px); // required for Safari/Chrome iOS 11. Ref: https://caniuse.com/#feat=css-clip-path
}
// ==============================

// Bug fix for CC button language selector still appearing when toggleCaptionsButtonWhenOnlyOne: true
// see https://github.com/adaptlearning/adapt_framework/issues/1883
// ==============================
&.toggle-captions .mejs-captions-selector {
display: none !important;
}
// ==============================
}


Expand Down

0 comments on commit 52a3d70

Please sign in to comment.