This commit is contained in:
Sam Potts 2015-02-15 23:23:01 +11:00
parent 56c6e92f37
commit 500e37688b

View File

@ -216,16 +216,16 @@
// Get click position relative to parent // Get click position relative to parent
// http://www.kirupa.com/html5/getting_mouse_click_position.htm // http://www.kirupa.com/html5/getting_mouse_click_position.htm
function getClickPosition(e) { function _getClickPosition(event) {
var parentPosition = fullscreen.isFullScreen() ? { x: 0, y: 0 } : getPosition(e.currentTarget); var parentPosition = _fullscreen().isFullScreen() ? { x: 0, y: 0 } : _getPosition(event.currentTarget);
return { return {
x: e.clientX - parentPosition.x, x: event.clientX - parentPosition.x,
y: e.clientY - parentPosition.y y: event.clientY - parentPosition.y
}; };
} }
// Get element position // Get element position
function getPosition(element) { function _getPosition(element) {
var xPosition = 0; var xPosition = 0;
var yPosition = 0; var yPosition = 0;
@ -244,11 +244,11 @@
// Deep extend/merge two Objects // Deep extend/merge two Objects
// http://andrewdupont.net/2009/08/28/deep-extending-objects-in-javascript/ // http://andrewdupont.net/2009/08/28/deep-extending-objects-in-javascript/
// Removed call to arguments.callee (used explicit function name instead) // Removed call to arguments.callee (used explicit function name instead)
function extend(destination, source) { function _extend(destination, source) {
for (var property in source) { for (var property in source) {
if (source[property] && source[property].constructor && source[property].constructor === Object) { if (source[property] && source[property].constructor && source[property].constructor === Object) {
destination[property] = destination[property] || {}; destination[property] = destination[property] || {};
extend(destination[property], source[property]); _extend(destination[property], source[property]);
} }
else { else {
destination[property] = source[property]; destination[property] = source[property];
@ -257,22 +257,8 @@
return destination; return destination;
} }
// Our internal function that executes handlers with a given name
function executeHandlers(eventName){
// Get all handlers with the selected name
var handler = handlers[eventName] || [],
len = handler.length,
i;
// Execute each
for(i = 0; i< len; i++){
// You can use apply to specify what "this" and parameters the callback gets
handler[i].apply(player.media,[]);
}
}
// Fullscreen API // Fullscreen API
function fullscreenApi() { function _fullscreen() {
var fullscreen = { var fullscreen = {
supportsFullScreen: false, supportsFullScreen: false,
isFullScreen: function() { return false; }, isFullScreen: function() { return false; },
@ -335,6 +321,21 @@
return fullscreen; return fullscreen;
} }
// Our internal function that executes handlers with a given name
function executeHandlers(eventName){
// Get all handlers with the selected name
var handler = handlers[eventName] || [],
len = handler.length,
i;
// Execute each
for(i = 0; i< len; i++){
// You can use apply to specify what "this" and parameters the callback gets
handler[i].apply(player.media,[]);
}
}
// Insert controls // Insert controls
function injectControls() { function injectControls() {
// Insert custom video controls // Insert custom video controls
@ -675,7 +676,6 @@
console.warn("Fullscreen not supported"); console.warn("Fullscreen not supported");
} }
} }
} }
// Listen for events // Listen for events
@ -793,8 +793,8 @@
}, false); }, false);
// Skip when clicking progress bar // Skip when clicking progress bar
player.progress.bar.addEventListener("click", function(e) { player.progress.bar.addEventListener("click", function(event) {
player.pos = getClickPosition(e).x / this.offsetWidth; player.pos = _getClickPosition(event).x / this.offsetWidth;
player.media.currentTime = player.pos * player.media.duration; player.media.currentTime = player.pos * player.media.duration;
// Special handling for "manual" captions // Special handling for "manual" captions
@ -822,15 +822,6 @@
}); });
} }
// Our "on" function which collects handlers
api.on = function(eventName, handler){
// If no handler collection exists, create one
if(!handlers[eventName]){
handlers[eventName] = [];
}
handlers[eventName].push(handler);
}
function setupPlayer(element) { function setupPlayer(element) {
player.container = element; player.container = element;
@ -862,10 +853,19 @@
listeners(); listeners();
} }
// Our "on" function which collects handlers
api.on = function(eventName, handler){
// If no handler collection exists, create one
if(!handlers[eventName]){
handlers[eventName] = [];
}
handlers[eventName].push(handler);
}
// Expose setup function // Expose setup function
api.setup = function(options){ api.setup = function(options){
// Extend the default options with user specified // Extend the default options with user specified
config = extend(defaults, options); config = _extend(defaults, options);
// If enabled carry on // If enabled carry on
if(!config.enabled) { if(!config.enabled) {
@ -873,7 +873,7 @@
} }
// Setup the fullscreen api // Setup the fullscreen api
fullscreen = fullscreenApi(); fullscreen = _fullscreen();
// Sniff // Sniff
player.browserInfo = browserSniff(); player.browserInfo = browserSniff();