|
@ -63,6 +63,7 @@ $.fn.embed = function(parameters) { |
|
|
|
|
|
|
|
|
initialize: function() { |
|
|
initialize: function() { |
|
|
module.debug('Initializing embed'); |
|
|
module.debug('Initializing embed'); |
|
|
|
|
|
module.determine.autoplay(); |
|
|
module.create(); |
|
|
module.create(); |
|
|
module.bind.events(); |
|
|
module.bind.events(); |
|
|
module.instantiate(); |
|
|
module.instantiate(); |
|
@ -94,7 +95,7 @@ $.fn.embed = function(parameters) { |
|
|
|
|
|
|
|
|
bind: { |
|
|
bind: { |
|
|
events: function() { |
|
|
events: function() { |
|
|
if( module.is.video() ) { |
|
|
|
|
|
|
|
|
if( module.has.placeholder() ) { |
|
|
module.debug('Adding placeholder events'); |
|
|
module.debug('Adding placeholder events'); |
|
|
$module |
|
|
$module |
|
|
.on('click' + eventNamespace, selector.placeholder, module.createAndShow) |
|
|
.on('click' + eventNamespace, selector.placeholder, module.createAndShow) |
|
@ -135,6 +136,7 @@ $.fn.embed = function(parameters) { |
|
|
.html( module.generate.embed(url) ) |
|
|
.html( module.generate.embed(url) ) |
|
|
.appendTo($module) |
|
|
.appendTo($module) |
|
|
; |
|
|
; |
|
|
|
|
|
settings.onCreate.call(element, url); |
|
|
module.debug('Creating embed object', $embed); |
|
|
module.debug('Creating embed object', $embed); |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
@ -152,7 +154,6 @@ $.fn.embed = function(parameters) { |
|
|
.data(metadata.url, url) |
|
|
.data(metadata.url, url) |
|
|
; |
|
|
; |
|
|
module.create(); |
|
|
module.create(); |
|
|
settings.onChange.call(element); |
|
|
|
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
// clears embed
|
|
|
// clears embed
|
|
@ -223,6 +224,11 @@ $.fn.embed = function(parameters) { |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
determine: { |
|
|
determine: { |
|
|
|
|
|
autoplay: function() { |
|
|
|
|
|
if(module.should.autoplay()) { |
|
|
|
|
|
settings.autoplay = true; |
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
source: function(url) { |
|
|
source: function(url) { |
|
|
var |
|
|
var |
|
|
matchedSource = false |
|
|
matchedSource = false |
|
@ -313,13 +319,13 @@ $.fn.embed = function(parameters) { |
|
|
}, |
|
|
}, |
|
|
parameters: function(source, extraParameters) { |
|
|
parameters: function(source, extraParameters) { |
|
|
var |
|
|
var |
|
|
sourceParameters = (sources[source].parameters !== undefined) |
|
|
|
|
|
|
|
|
parameters = (sources[source] && sources[source].parameters !== undefined) |
|
|
? sources[source].parameters(settings) |
|
|
? sources[source].parameters(settings) |
|
|
: {}, |
|
|
|
|
|
parameters |
|
|
|
|
|
|
|
|
: {} |
|
|
; |
|
|
; |
|
|
|
|
|
extraParameters = extraParameters || settings.parameters; |
|
|
if(extraParameters) { |
|
|
if(extraParameters) { |
|
|
parameters = $.extend({}, sourceParameters, extraParameters); |
|
|
|
|
|
|
|
|
parameters = $.extend({}, parameters, extraParameters); |
|
|
} |
|
|
} |
|
|
parameters = settings.onEmbed(parameters); |
|
|
parameters = settings.onEmbed(parameters); |
|
|
return module.encode.parameters(parameters); |
|
|
return module.encode.parameters(parameters); |
|
@ -332,13 +338,16 @@ $.fn.embed = function(parameters) { |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
is: { |
|
|
|
|
|
|
|
|
should: { |
|
|
autoplay: function() { |
|
|
autoplay: function() { |
|
|
return (settings.autoplay === 'auto') |
|
|
return (settings.autoplay === 'auto') |
|
|
? ($module.data('image') !== undefined) |
|
|
|
|
|
|
|
|
? (settings.placeholder || $module.data(metadata.placeholder) !== undefined) |
|
|
: settings.autoplay |
|
|
: settings.autoplay |
|
|
; |
|
|
; |
|
|
}, |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
is: { |
|
|
video: function() { |
|
|
video: function() { |
|
|
return module.get.type() == 'video'; |
|
|
return module.get.type() == 'video'; |
|
|
} |
|
|
} |
|
@ -538,30 +547,22 @@ $.fn.embed.settings = { |
|
|
id : false, |
|
|
id : false, |
|
|
|
|
|
|
|
|
// standard video settings
|
|
|
// standard video settings
|
|
|
autoplay : 'auto', |
|
|
|
|
|
color : '#444444', |
|
|
|
|
|
hd : true, |
|
|
|
|
|
showUI : false, |
|
|
|
|
|
|
|
|
autoplay : 'auto', |
|
|
|
|
|
color : '#444444', |
|
|
|
|
|
hd : true, |
|
|
|
|
|
brandedUI : false, |
|
|
|
|
|
|
|
|
|
|
|
// additional parameters to include with the embed
|
|
|
|
|
|
parameters: false, |
|
|
|
|
|
|
|
|
onDisplay : function() {}, |
|
|
onDisplay : function() {}, |
|
|
onPlaceholderDisplay : function() {}, |
|
|
onPlaceholderDisplay : function() {}, |
|
|
onReset : function() {}, |
|
|
onReset : function() {}, |
|
|
onChange : function() {}, |
|
|
|
|
|
|
|
|
onCreate : function(url) {}, |
|
|
onEmbed : function(parameters) { |
|
|
onEmbed : function(parameters) { |
|
|
return parameters; |
|
|
return parameters; |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
width : 'auto', |
|
|
|
|
|
height : 'auto', |
|
|
|
|
|
|
|
|
|
|
|
// additional parameters to include with the embed
|
|
|
|
|
|
parameters: false, |
|
|
|
|
|
|
|
|
|
|
|
// callbacks not coded yet (needs to use jsapi)
|
|
|
|
|
|
api : true, |
|
|
|
|
|
onPause : function() {}, |
|
|
|
|
|
onStop : function() {}, |
|
|
|
|
|
|
|
|
|
|
|
metadata : { |
|
|
metadata : { |
|
|
id : 'id', |
|
|
id : 'id', |
|
|
icon : 'icon', |
|
|
icon : 'icon', |
|
@ -584,67 +585,75 @@ $.fn.embed.settings = { |
|
|
embed : '.embed', |
|
|
embed : '.embed', |
|
|
placeholder : '.placeholder', |
|
|
placeholder : '.placeholder', |
|
|
play : '.play' |
|
|
play : '.play' |
|
|
} |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
$.fn.embed.settings.sources = { |
|
|
|
|
|
youtube: { |
|
|
|
|
|
name : 'youtube', |
|
|
|
|
|
type : 'video', |
|
|
|
|
|
icon : 'video play', |
|
|
|
|
|
domain : 'youtube.com', |
|
|
|
|
|
url : '//www.youtube.com/embed/{id}', |
|
|
|
|
|
parameters: function(settings) { |
|
|
|
|
|
return { |
|
|
|
|
|
autohide : !settings.showUI, |
|
|
|
|
|
autoplay : settings.autoplay, |
|
|
|
|
|
color : settings.colors || undefined, |
|
|
|
|
|
hq : settings.hd, |
|
|
|
|
|
jsapi : settings.api, |
|
|
|
|
|
modestbranding : 1 |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
sources: { |
|
|
|
|
|
youtube: { |
|
|
|
|
|
name : 'youtube', |
|
|
|
|
|
type : 'video', |
|
|
|
|
|
icon : 'video play', |
|
|
|
|
|
domain : 'youtube.com', |
|
|
|
|
|
url : '//www.youtube.com/embed/{id}', |
|
|
|
|
|
parameters: function(settings) { |
|
|
|
|
|
return { |
|
|
|
|
|
autohide : !settings.brandedUI, |
|
|
|
|
|
autoplay : settings.autoplay, |
|
|
|
|
|
color : settings.colors || undefined, |
|
|
|
|
|
hq : settings.hd, |
|
|
|
|
|
jsapi : settings.api, |
|
|
|
|
|
modestbranding : !settings.brandedUI |
|
|
|
|
|
}; |
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
|
|
|
vimeo: { |
|
|
|
|
|
name : 'vimeo', |
|
|
|
|
|
type : 'video', |
|
|
|
|
|
icon : 'video play', |
|
|
|
|
|
domain : 'vimeo.com', |
|
|
|
|
|
url : '//www.youtube.com/embed/{id}', |
|
|
|
|
|
parameters: function(settings) { |
|
|
|
|
|
return { |
|
|
|
|
|
api : settings.api, |
|
|
|
|
|
autoplay : settings.autoplay, |
|
|
|
|
|
byline : settings.brandedUI, |
|
|
|
|
|
color : settings.colors || undefined, |
|
|
|
|
|
portrait : settings.brandedUI, |
|
|
|
|
|
title : settings.brandedUI |
|
|
|
|
|
}; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
vimeo: { |
|
|
|
|
|
name : 'vimeo', |
|
|
|
|
|
type : 'video', |
|
|
|
|
|
icon : 'video play', |
|
|
|
|
|
domain : 'vimeo.com', |
|
|
|
|
|
url : '//www.youtube.com/embed/{id}', |
|
|
|
|
|
parameters: function(settings) { |
|
|
|
|
|
return { |
|
|
|
|
|
api : settings.api, |
|
|
|
|
|
autoplay : settings.autoplay, |
|
|
|
|
|
byline : settings.showUI, |
|
|
|
|
|
color : settings.colors || undefined, |
|
|
|
|
|
portrait : settings.showUI, |
|
|
|
|
|
title : settings.showUI |
|
|
|
|
|
}; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
$.fn.embed.settings.templates = { |
|
|
|
|
|
iframe : function(url, parameters) { |
|
|
|
|
|
return '' |
|
|
|
|
|
+ '<iframe src="' + url + '?=' + parameters + '"' |
|
|
|
|
|
+ ' width="100%" height="100%"' |
|
|
|
|
|
+ ' frameborder="0" scrolling="no" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>' |
|
|
|
|
|
; |
|
|
|
|
|
}, |
|
|
|
|
|
placeholder : function(image, icon) { |
|
|
|
|
|
var |
|
|
|
|
|
html = '' |
|
|
|
|
|
; |
|
|
|
|
|
if(icon) { |
|
|
|
|
|
html += '<i class="' + icon + ' icon"></i>'; |
|
|
|
|
|
} |
|
|
|
|
|
if(image) { |
|
|
|
|
|
html += '<img class="placeholder" src="' + image + '">'; |
|
|
|
|
|
|
|
|
templates: { |
|
|
|
|
|
iframe : function(url, parameters) { |
|
|
|
|
|
return '' |
|
|
|
|
|
+ '<iframe src="' + url + '?=' + parameters + '"' |
|
|
|
|
|
+ ' width="100%" height="100%"' |
|
|
|
|
|
+ ' frameborder="0" scrolling="no" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>' |
|
|
|
|
|
; |
|
|
|
|
|
}, |
|
|
|
|
|
placeholder : function(image, icon) { |
|
|
|
|
|
var |
|
|
|
|
|
html = '' |
|
|
|
|
|
; |
|
|
|
|
|
if(icon) { |
|
|
|
|
|
html += '<i class="' + icon + ' icon"></i>'; |
|
|
|
|
|
} |
|
|
|
|
|
if(image) { |
|
|
|
|
|
html += '<img class="placeholder" src="' + image + '">'; |
|
|
|
|
|
} |
|
|
|
|
|
return html; |
|
|
} |
|
|
} |
|
|
return html; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
// NOT YET IMPLEMENTED
|
|
|
|
|
|
api : true, |
|
|
|
|
|
onPause : function() {}, |
|
|
|
|
|
onPlay : function() {}, |
|
|
|
|
|
onStop : function() {} |
|
|
|
|
|
|
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
})( jQuery, window , document ); |
|
|
})( jQuery, window , document ); |