aboutsummaryrefslogtreecommitdiffstats
path: root/src/js/controls.js
diff options
context:
space:
mode:
authorSam Potts <sam@potts.es>2018-03-28 22:45:11 +1100
committerSam Potts <sam@potts.es>2018-03-28 22:45:11 +1100
commitc4e2e2464326464627c37bdcb203d9f095856bbd (patch)
treec63c8921a8a34415c55a0e5e7776d54b0ac39330 /src/js/controls.js
parent2b7fe9a4f92e0e0065c8f0e5148094e0961ba4c8 (diff)
downloadplyr-c4e2e2464326464627c37bdcb203d9f095856bbd.tar.lz
plyr-c4e2e2464326464627c37bdcb203d9f095856bbd.tar.xz
plyr-c4e2e2464326464627c37bdcb203d9f095856bbd.zip
Bug fixes
Diffstat (limited to 'src/js/controls.js')
-rw-r--r--src/js/controls.js26
1 files changed, 22 insertions, 4 deletions
diff --git a/src/js/controls.js b/src/js/controls.js
index c4cc7531..106dfe67 100644
--- a/src/js/controls.js
+++ b/src/js/controls.js
@@ -706,7 +706,12 @@ const controls = {
},
// Set a list of available captions languages
- setSpeedMenu() {
+ setSpeedMenu(options) {
+ // Do nothing if not selected
+ if (!this.config.controls.includes('settings') || !this.config.settings.includes('speed')) {
+ return;
+ }
+
// Menu required
if (!utils.is.element(this.elements.settings.panes.speed)) {
return;
@@ -714,8 +719,8 @@ const controls = {
const type = 'speed';
- // Set the default speeds
- if (!utils.is.array(this.options.speed) || !this.options.speed.length) {
+ // Set the speed options
+ if (!utils.is.array(options)) {
this.options.speed = [
0.5,
0.75,
@@ -725,6 +730,8 @@ const controls = {
1.75,
2,
];
+ } else {
+ this.options.speed = options;
}
// Set options if passed and filter based on config
@@ -734,6 +741,9 @@ const controls = {
const toggle = !utils.is.empty(this.options.speed);
controls.toggleTab.call(this, type, toggle);
+ // Check if we need to toggle the parent
+ controls.checkMenu.call(this);
+
// If we're hiding, nothing more to do
if (!toggle) {
return;
@@ -755,6 +765,14 @@ const controls = {
controls.updateSetting.call(this, type, list);
},
+ // Check if we need to hide/show the settings menu
+ checkMenu() {
+ const speedHidden = this.elements.settings.tabs.speed.getAttribute('hidden') !== null;
+ const languageHidden = this.elements.settings.tabs.captions.getAttribute('hidden') !== null;
+
+ utils.toggleHidden(this.elements.settings.menu, speedHidden && languageHidden);
+ },
+
// Show/hide menu
toggleMenu(event) {
const { form } = this.elements.settings;
@@ -1159,7 +1177,7 @@ const controls = {
this.elements.controls = container;
- if (this.config.controls.includes('settings') && this.config.settings.includes('speed')) {
+ if (this.isHTML5) {
controls.setSpeedMenu.call(this);
}