app/assets/javascripts/semantic-ui/embed.js in semantic-ui-sass-2.1.8.0 vs app/assets/javascripts/semantic-ui/embed.js in semantic-ui-sass-2.2.0.0
- old
+ new
@@ -1,20 +1,26 @@
/*!
- * # Semantic UI - Video
+ * # Semantic UI - Embed
* http://github.com/semantic-org/semantic-ui/
*
*
- * Copyright 2015 Contributors
* Released under the MIT license
* http://opensource.org/licenses/MIT
*
*/
;(function ($, window, document, undefined) {
"use strict";
+window = (typeof window != 'undefined' && window.Math == Math)
+ ? window
+ : (typeof self != 'undefined' && self.Math == Math)
+ ? self
+ : Function('return this')()
+;
+
$.fn.embed = function(parameters) {
var
$allModules = $(this),
@@ -138,10 +144,16 @@
;
settings.onCreate.call(element, url);
module.debug('Creating embed object', $embed);
},
+ changeEmbed: function(url) {
+ $embed
+ .html( module.generate.embed(url) )
+ ;
+ },
+
createAndShow: function() {
module.createEmbed();
module.show();
},
@@ -149,13 +161,23 @@
change: function(source, id, url) {
module.debug('Changing video to ', source, id, url);
$module
.data(metadata.source, source)
.data(metadata.id, id)
- .data(metadata.url, url)
;
- module.create();
+ if(url) {
+ $module.data(metadata.url, url);
+ }
+ else {
+ $module.removeData(metadata.url);
+ }
+ if(module.has.embed()) {
+ module.changeEmbed();
+ }
+ else {
+ module.create();
+ }
},
// clears embed
reset: function() {
module.debug('Clearing embed and showing placeholder');
@@ -331,10 +353,13 @@
return module.encode.parameters(parameters);
}
},
has: {
+ embed: function() {
+ return ($embed.length > 0);
+ },
placeholder: function() {
return settings.placeholder || $module.data(metadata.placeholder);
}
},
@@ -357,11 +382,16 @@
module.debug('Changing setting', name, value);
if( $.isPlainObject(name) ) {
$.extend(true, settings, name);
}
else if(value !== undefined) {
- settings[name] = value;
+ if($.isPlainObject(settings[name])) {
+ $.extend(true, settings[name], value);
+ }
+ else {
+ settings[name] = value;
+ }
}
else {
return settings[name];
}
},
@@ -375,34 +405,36 @@
else {
return module[name];
}
},
debug: function() {
- if(settings.debug) {
+ if(!settings.silent && settings.debug) {
if(settings.performance) {
module.performance.log(arguments);
}
else {
module.debug = Function.prototype.bind.call(console.info, console, settings.name + ':');
module.debug.apply(console, arguments);
}
}
},
verbose: function() {
- if(settings.verbose && settings.debug) {
+ if(!settings.silent && settings.verbose && settings.debug) {
if(settings.performance) {
module.performance.log(arguments);
}
else {
module.verbose = Function.prototype.bind.call(console.info, console, settings.name + ':');
module.verbose.apply(console, arguments);
}
}
},
error: function() {
- module.error = Function.prototype.bind.call(console.error, console, settings.name + ':');
- module.error.apply(console, arguments);
+ if(!settings.silent) {
+ module.error = Function.prototype.bind.call(console.error, console, settings.name + ':');
+ module.error.apply(console, arguments);
+ }
},
performance: {
log: function(message) {
var
currentTime,
@@ -535,10 +567,11 @@
$.fn.embed.settings = {
name : 'Embed',
namespace : 'embed',
+ silent : false,
debug : false,
verbose : false,
performance : true,
icon : false,
@@ -596,11 +629,11 @@
url : '//www.youtube.com/embed/{id}',
parameters: function(settings) {
return {
autohide : !settings.brandedUI,
autoplay : settings.autoplay,
- color : settings.colors || undefined,
+ color : settings.color || undefined,
hq : settings.hd,
jsapi : settings.api,
modestbranding : !settings.brandedUI
};
}
@@ -614,22 +647,26 @@
parameters: function(settings) {
return {
api : settings.api,
autoplay : settings.autoplay,
byline : settings.brandedUI,
- color : settings.colors || undefined,
+ color : settings.color || undefined,
portrait : settings.brandedUI,
title : settings.brandedUI
};
}
}
},
templates: {
iframe : function(url, parameters) {
+ var src = url;
+ if (parameters) {
+ src += '?' + parameters;
+ }
return ''
- + '<iframe src="' + url + '?' + parameters + '"'
+ + '<iframe src="' + src + '"'
+ ' width="100%" height="100%"'
+ ' frameborder="0" scrolling="no" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>'
;
},
placeholder : function(image, icon) {
@@ -645,10 +682,10 @@
return html;
}
},
// NOT YET IMPLEMENTED
- api : true,
+ api : false,
onPause : function() {},
onPlay : function() {},
onStop : function() {}
};