1
0
mirror of https://github.com/videojs/video.js.git synced 2024-12-25 02:42:10 +02:00

@mmcc updated the hide/show functions to use a class instead of inline styles. closes #1681

This commit is contained in:
Matthew McClure 2014-12-22 09:38:54 -08:00 committed by heff
parent a048468100
commit a67201f913
6 changed files with 9 additions and 12 deletions

View File

@ -3,6 +3,7 @@ CHANGELOG
## HEAD (Unreleased)
* @PeterDaveHello added a Traditional Chinese translation ([view](https://github.com/videojs/video.js/pull/1729))
* @mmcc updated the hide/show functions to use a class instead of inline styles ([view](https://github.com/videojs/video.js/pull/1681))
--------------------

View File

@ -990,7 +990,7 @@ body.vjs-full-window {
.video-js.vjs-fullscreen .vjs-text-track { font-size: 3em; }
/* Hide disabled or unsupported controls */
.vjs-default-skin .vjs-hidden { display: none; }
.vjs-hidden { display: none !important; }
.vjs-lock-showing {
display: block !important;

View File

@ -845,7 +845,7 @@ vjs.Component.prototype.removeClass = function(classToRemove){
* @return {vjs.Component}
*/
vjs.Component.prototype.show = function(){
this.el_.style.display = 'block';
this.removeClass('vjs-hidden');
return this;
};
@ -855,7 +855,7 @@ vjs.Component.prototype.show = function(){
* @return {vjs.Component}
*/
vjs.Component.prototype.hide = function(){
this.el_.style.display = 'none';
this.addClass('vjs-hidden');
return this;
};

View File

@ -60,10 +60,7 @@ vjs.PosterImage.prototype.update = function(){
// If there's no poster source we should display:none on this component
// so it's not still clickable or right-clickable
if (url) {
// Remove the display style property that hide() adds
// as opposed to show() which sets display to block
// In the future it might be worth creating an `unhide` component method
this.el_.style.display = '';
this.show();
} else {
this.hide();
}

View File

@ -373,9 +373,9 @@ test('should show and hide an element', function(){
var comp = new vjs.Component(getFakePlayer(), {});
comp.hide();
ok(comp.el().style.display === 'none');
ok(comp.hasClass('vjs-hidden') === true);
comp.show();
ok(comp.el().style.display === 'block');
ok(comp.hasClass('vjs-hidden') === false);
});
test('dimension() should treat NaN and null as zero', function() {

View File

@ -60,12 +60,12 @@ test('should remove itself from the document flow when there is no poster', func
// Update with an empty string
this.mockPlayer.poster_ = '';
this.mockPlayer.trigger('posterchange');
equal(posterImage.el().style.display, 'none', 'Poster image hides with an empty source');
equal(posterImage.hasClass('vjs-hidden'), true, 'Poster image hides with an empty source');
// Updated with a valid source
this.mockPlayer.poster_ = this.poster2;
this.mockPlayer.trigger('posterchange');
equal(posterImage.el().style.display, '', 'Poster image shows again when there is a source');
equal(posterImage.hasClass('vjs-hidden'), false, 'Poster image shows again when there is a source');
});
test('should hide the poster in the appropriate player states', function(){
@ -88,4 +88,3 @@ test('should hide the poster in the appropriate player states', function(){
playerDiv.className = 'video-js vjs-has-started vjs-audio';
equal(TestHelpers.getComputedStyle(el, 'display'), 'block', 'The poster continues to show when playing audio');
});