diff --git a/src/css/video-js.css b/src/css/video-js.css index ec7fe1e06..9fcfc62ab 100644 --- a/src/css/video-js.css +++ b/src/css/video-js.css @@ -97,6 +97,8 @@ body.vjs-full-window { -o-transition: visibility 0s linear 1.5s,opacity 1.5s linear; transition: visibility 0s linear 1.5s,opacity 1.5s linear; } +/* Hide disabled or unsupported controls */ +.vjs-default-skin .vjs-hidden { display: none; } /* DEFAULT SKIN (override in another file to create new skins) ================================================================================ @@ -144,8 +146,6 @@ so you can upgrade to newer versions easier. You can remove all these styles by /* Hide control text visually, but have it available for screenreaders: h5bp.com/v */ .vjs-default-skin .vjs-control-text { border: 0; clip: rect(0 0 0 0); height: 1px; margin: -1px; overflow: hidden; padding: 0; position: absolute; width: 1px; } - - /* Play/Pause -------------------------------------------------------------------------------- */ .vjs-default-skin .vjs-play-control { width: 5em; cursor: pointer !important; } diff --git a/src/js/controls.js b/src/js/controls.js index 7902cbbcd..8335cfa49 100644 --- a/src/js/controls.js +++ b/src/js/controls.js @@ -853,13 +853,13 @@ vjs.VolumeControl = function(player, options){ // hide volume controls when they're not supported by the current tech if (player.tech && player.tech.features.volumeControl === false) { - this.hide(); + this.addClass('vjs-hidden'); } player.on('loadstart', vjs.bind(this, function(){ if (player.tech.features.volumeControl === false) { - this.hide(); + this.addClass('vjs-hidden'); } else { - this.show(); + this.removeClass('vjs-hidden'); } })); }; @@ -982,13 +982,13 @@ vjs.MuteToggle = function(player, options){ // hide mute toggle if the current tech doesn't support volume control if (player.tech && player.tech.features.volumeControl === false) { - this.hide(); + this.addClass('vjs-hidden'); } player.on('loadstart', vjs.bind(this, function(){ if (player.tech.features.volumeControl === false) { - this.hide(); + this.addClass('vjs-hidden'); } else { - this.show(); + this.removeClass('vjs-hidden'); } })); }; diff --git a/test/unit/controls.js b/test/unit/controls.js index fee1eec96..b64c24045 100644 --- a/test/unit/controls.js +++ b/test/unit/controls.js @@ -1,6 +1,6 @@ module('Controls'); -test('should hide volume control if it\'s not supported', function() { +test('should hide volume control if it\'s not supported', function(){ var noop, player, volumeControl, muteToggle; noop = function(){}; player = { @@ -16,8 +16,8 @@ test('should hide volume control if it\'s not supported', function() { volumeControl = new vjs.VolumeControl(player); muteToggle = new vjs.MuteToggle(player); - equal(volumeControl.el().style.display, 'none', 'volumeControl is not hidden'); - equal(muteToggle.el().style.display, 'none', 'muteToggle is not hidden'); + ok(volumeControl.el().className.indexOf('vjs-hidden') >= 0, 'volumeControl is not hidden'); + ok(muteToggle.el().className.indexOf('vjs-hidden') >= 0, 'muteToggle is not hidden'); }); test('should test and toggle volume control on `loadstart`', function(){ @@ -45,34 +45,28 @@ test('should test and toggle volume control on `loadstart`', function(){ volumeControl = new vjs.VolumeControl(player); muteToggle = new vjs.MuteToggle(player); - equal(volumeControl.el().style.display, - '', - 'volumeControl is hidden initially'); - equal(muteToggle.el().style.display, - '', - 'muteToggle is hidden initially'); + ok(volumeControl.el().className.indexOf('vjs-hidden') < 0, + 'volumeControl is hidden initially'); + ok(muteToggle.el().className.indexOf('vjs-hidden') < 0, + 'muteToggle is hidden initially'); player.tech.features.volumeControl = false; listeners.forEach(function(listener) { listener(); }); - equal(volumeControl.el().style.display, - 'none', - 'volumeControl does not hide itself'); - equal(muteToggle.el().style.display, - 'none', - 'muteToggle does not hide itself'); + ok(volumeControl.el().className.indexOf('vjs-hidden') >= 0, + 'volumeControl does not hide itself'); + ok(muteToggle.el().className.indexOf('vjs-hidden') >= 0, + 'muteToggle does not hide itself'); player.tech.features.volumeControl = true; listeners.forEach(function(listener) { listener(); }); - equal(volumeControl.el().style.display, - 'block', - 'volumeControl does not show itself'); - equal(muteToggle.el().style.display, - 'block', - 'muteToggle does not show itself'); + ok(volumeControl.el().className.indexOf('vjs-hidden') < 0, + 'volumeControl does not show itself'); + ok(muteToggle.el().className.indexOf('vjs-hidden') < 0, + 'muteToggle does not show itself'); });