mirror of
https://github.com/videojs/video.js.git
synced 2024-11-28 08:58:46 +02:00
Don't use minifiable player methods in fullscreenToggle
Use string literals to lookup fullscreen-related methods on the player object in the fullscreenToggle component. Otherwise, closure compiler replaces them with minified method names and makes it impossible to supply a simpler "player" object with customized fullscreen logic for the fullscreenToggle to interact with.
This commit is contained in:
parent
cb9447b2c3
commit
c69290c39f
@ -23,11 +23,11 @@ vjs.FullscreenToggle.prototype.buildCSSClass = function(){
|
||||
};
|
||||
|
||||
vjs.FullscreenToggle.prototype.onClick = function(){
|
||||
if (!this.player_.isFullScreen) {
|
||||
this.player_.requestFullScreen();
|
||||
if (!this.player_['isFullScreen']) {
|
||||
this.player_['requestFullScreen']();
|
||||
this.el_.children[0].children[0].innerHTML = 'Non-Fullscreen'; // change the button text to "Non-Fullscreen"
|
||||
} else {
|
||||
this.player_.cancelFullScreen();
|
||||
this.player_['cancelFullScreen']();
|
||||
this.el_.children[0].children[0].innerHTML = 'Fullscreen'; // change the button to "Fullscreen"
|
||||
}
|
||||
};
|
||||
|
@ -103,3 +103,33 @@ test('videojs.players should be available after minification', function() {
|
||||
|
||||
player.dispose();
|
||||
});
|
||||
|
||||
test('fullscreenToggle does not depend on minified player methods', function(){
|
||||
var noop, player, fullscreen, requestFullScreen, cancelFullScreen;
|
||||
noop = function(){};
|
||||
requestFullScreen = false;
|
||||
cancelFullScreen = false;
|
||||
player = {
|
||||
id: noop,
|
||||
on: noop,
|
||||
ready: noop
|
||||
};
|
||||
|
||||
player['requestFullScreen'] = function(){
|
||||
requestFullScreen = true;
|
||||
};
|
||||
player['cancelFullScreen'] = function(){
|
||||
cancelFullScreen = true;
|
||||
};
|
||||
player['isFullScreen'] = false;
|
||||
|
||||
fullscreen = new videojs.FullscreenToggle(player);
|
||||
fullscreen.trigger('click');
|
||||
|
||||
ok(requestFullScreen, 'requestFullScreen called');
|
||||
|
||||
player.isFullScreen = true;
|
||||
fullscreen.trigger('click');
|
||||
|
||||
ok(cancelFullScreen, 'cancelFullScreen called');
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user