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

Use externs to prevent obfuscation

Instead of using string literals, create an externs file for the player and use that to ensure fullscreen functionality is never minified.
This commit is contained in:
David LaPalomento 2013-11-26 18:42:37 -05:00
parent c69290c39f
commit 7efcbd5e19
3 changed files with 16 additions and 5 deletions

View File

@ -52,12 +52,12 @@ module.exports = function(grunt) {
minify: {
source:{
src: ['build/files/combined.video.js', 'build/compiler/goog.base.js', 'src/js/exports.js'],
externs: ['src/js/media/flash.externs.js'],
externs: ['src/js/player.externs.js', 'src/js/media/flash.externs.js'],
dest: 'build/files/minified.video.js'
},
tests: {
src: ['build/files/combined.video.js', 'build/compiler/goog.base.js', 'src/js/exports.js', 'test/unit/*.js', '!test/unit/api.js'],
externs: ['src/js/media/flash.externs.js', 'test/qunit/qunit-externs.js'],
externs: ['src/js/player.externs.js', 'src/js/media/flash.externs.js', 'test/qunit/qunit-externs.js'],
dest: 'build/files/test.minified.video.js'
}
},

View File

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

11
src/js/player.externs.js Normal file
View File

@ -0,0 +1,11 @@
/**
* @fileoverview Externs for videojs.Player. Externs are functions that the
* compiler shouldn't obfuscate.
*/
/**
* Fullscreen functionality
*/
videojs.Player.prototype.isFullScreen = undefined;
videojs.Player.prototype.requestFullScreen = function(){};
videojs.Player.prototype.cancelFullScreen = function(){};