1
0
mirror of https://github.com/videojs/video.js.git synced 2024-12-12 11:15:04 +02:00

Merge pull request #399 from dmlap/issue398

Fix #398
This commit is contained in:
Steve Heffernan 2013-04-04 13:02:43 -07:00
commit a9352922d9
3 changed files with 23 additions and 29 deletions

View File

@ -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; }

12
src/js/controls.js vendored
View File

@ -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');
}
}));
};

36
test/unit/controls.js vendored
View File

@ -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');
});