Skip to content

Commit

Permalink
Export event helpers on videojs object
Browse files Browse the repository at this point in the history
  • Loading branch information
gkatsev committed Aug 19, 2015
1 parent 06f16d9 commit 873bb38
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions src/js/video.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import document from 'global/document';
import * as setup from './setup';
import Component from './component';
import EventTarget from './event-target';
import * as Events from './utils/events.js';
import Player from './player';
import plugin from './plugins.js';
import mergeOptions from '../../src/js/utils/merge-options.js';
Expand Down Expand Up @@ -428,6 +429,50 @@ videojs.parseUrl = Url.parseUrl;
*/
videojs.EventTarget = EventTarget;

/**
* Add an event listener to element
* It stores the handler function in a separate cache object
* and adds a generic handler to the element's event,
* along with a unique id (guid) to the element.
*
* @param {Element|Object} elem Element or object to bind listeners to
* @param {String|Array} type Type of event to bind to.
* @param {Function} fn Event listener.
* @method on
*/
videojs.on = Events.on;

/**
* Trigger a listener only once for an event
*
* @param {Element|Object} elem Element or object to
* @param {String|Array} type Name/type of event
* @param {Function} fn Event handler function
* @method one
*/
videojs.one = Events.one;

/**
* Removes event listeners from an element
*
* @param {Element|Object} elem Object to remove listeners from
* @param {String|Array=} type Type of listener to remove. Don't include to remove all events from element.
* @param {Function} fn Specific listener to remove. Don't include to remove listeners for an event type.
* @method off
*/
videojs.off = Events.off;

/**
* Trigger an event for an element
*
* @param {Element|Object} elem Element to trigger an event on
* @param {Event|Object|String} event A string (the type) or an event object with a type attribute
* @param {Object} [hash] data hash to pass along with the event
* @return {Boolean=} Returned only if default was prevented
* @method trigger
*/
videojs.trigger = Events.trigger;

// REMOVING: We probably should add this to the migration plugin
// // Expose but deprecate the window[componentName] method for accessing components
// Object.getOwnPropertyNames(Component.components).forEach(function(name){
Expand Down

0 comments on commit 873bb38

Please sign in to comment.