From e445006abd1014216f9df47af8ffb5e218a4dd4a Mon Sep 17 00:00:00 2001 From: Deirdre Connolly Date: Thu, 30 Apr 2015 15:15:41 -0400 Subject: [PATCH 1/2] Expose videojs.plugin() So that plugins can be registered with the same api! Also a unit test module for the video.js entrypoint. Fixes #2102 --- src/js/video.js | 3 +++ test/unit/video.js | 23 +++++++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 test/unit/video.js diff --git a/src/js/video.js b/src/js/video.js index 7b709efdd3..b5f47d2298 100644 --- a/src/js/video.js +++ b/src/js/video.js @@ -17,6 +17,7 @@ import * as Lib from './lib'; import * as Util from './util.js'; import Player from './player'; import extendsFn from './extends.js'; +import plugin from './Plugins.js'; if (typeof HTMLVideoElement === 'undefined') { document.createElement('video'); @@ -41,6 +42,8 @@ videojs.players = Player.players; videojs.extends = extendsFn; +videojs.plugin = plugin; + // REMOVING: We probably should not include this in 5.0 thought it would make it // more backwards compatible // // Expose but deprecate the window[componentName] method for accessing components diff --git a/test/unit/video.js b/test/unit/video.js new file mode 100644 index 0000000000..7b389019cd --- /dev/null +++ b/test/unit/video.js @@ -0,0 +1,23 @@ +import videojs from '../../src/js/video.js'; +import TestHelpers from './test-helpers.js'; + +q.module('video.js'); + +test('should expose plugin registry function', function() { + var pluginName, pluginFunction, player; + + pluginName = 'foo'; + pluginFunction = function(options) { + console.log(this); + }; + + ok(videojs.plugin, 'should exist'); + + videojs.plugin(pluginName, pluginFunction); + + player = TestHelpers.makePlayer(); + + ok(player.foo, 'should exist'); + equal(player.foo, pluginFunction, 'should be equal'); + +}); From 051eb2cf1cbf978a5f5b8a48a9d91015a6c8a5f0 Mon Sep 17 00:00:00 2001 From: Deirdre Connolly Date: Thu, 30 Apr 2015 15:39:56 -0400 Subject: [PATCH 2/2] Import the correctly-cased plugins.js --- src/js/video.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/js/video.js b/src/js/video.js index b5f47d2298..12e536e114 100644 --- a/src/js/video.js +++ b/src/js/video.js @@ -17,7 +17,7 @@ import * as Lib from './lib'; import * as Util from './util.js'; import Player from './player'; import extendsFn from './extends.js'; -import plugin from './Plugins.js'; +import plugin from './plugins.js'; if (typeof HTMLVideoElement === 'undefined') { document.createElement('video');