That spaces life. Linked file from README
This commit is contained in:
parent
fea34835e1
commit
92f93fe325
3 changed files with 87 additions and 86 deletions
|
@ -1,66 +1,66 @@
|
|||
(function($)
|
||||
{
|
||||
$.fn.soundcloud = function(options)
|
||||
{
|
||||
// Default settings
|
||||
var defaults = {
|
||||
auto_play: false,
|
||||
//callback: false,
|
||||
client_id: false,
|
||||
color: false,
|
||||
iframe: true,
|
||||
maxheight: false,
|
||||
maxwidth: false,
|
||||
show_comments: true,
|
||||
url: false
|
||||
};
|
||||
$.fn.soundcloud = function(options)
|
||||
{
|
||||
// Default settings
|
||||
var defaults = {
|
||||
auto_play: false,
|
||||
//callback: false,
|
||||
client_id: false,
|
||||
color: false,
|
||||
iframe: true,
|
||||
maxheight: false,
|
||||
maxwidth: false,
|
||||
show_comments: true,
|
||||
url: false
|
||||
};
|
||||
|
||||
// Overrides the defaults with passed in options
|
||||
options = $.extend({}, defaults, options);
|
||||
// Overrides the defaults with passed in options
|
||||
options = $.extend({}, defaults, options);
|
||||
|
||||
var elements = this;
|
||||
var protocol = document.location.protocol == 'https:' ? 'https://' : 'http://';
|
||||
var elements = this;
|
||||
var protocol = document.location.protocol == 'https:' ? 'https://' : 'http://';
|
||||
|
||||
if (typeof SC === 'undefined')
|
||||
{
|
||||
$.getScript(
|
||||
protocol + 'connect.soundcloud.com/sdk.js',
|
||||
function()
|
||||
{
|
||||
elements.each(function(index, element)
|
||||
{
|
||||
try
|
||||
{
|
||||
// Overrides the options with the data attributes
|
||||
parameters = $.extend({}, options, $(this).data());
|
||||
if (typeof SC === 'undefined')
|
||||
{
|
||||
$.getScript(
|
||||
protocol + 'connect.soundcloud.com/sdk.js',
|
||||
function()
|
||||
{
|
||||
elements.each(function(index, element)
|
||||
{
|
||||
try
|
||||
{
|
||||
// Overrides the options with the data attributes
|
||||
parameters = $.extend({}, options, $(this).data());
|
||||
|
||||
// Checks that we have a client ID
|
||||
if (!parameters.client_id)
|
||||
{
|
||||
throw 'Missing client ID.';
|
||||
}
|
||||
// Checks that we have a client ID
|
||||
if (!parameters.client_id)
|
||||
{
|
||||
throw 'Missing client ID.';
|
||||
}
|
||||
|
||||
SC.initialize({ client_id: parameters.client_id });
|
||||
SC.initialize({ client_id: parameters.client_id });
|
||||
|
||||
// Request the embed HTML
|
||||
SC.oEmbed(
|
||||
parameters.url,
|
||||
parameters,
|
||||
function(oEmbed)
|
||||
{
|
||||
$(element).replaceWith(oEmbed.html.replace("https://", protocol));
|
||||
}
|
||||
);
|
||||
}
|
||||
catch (error)
|
||||
{
|
||||
console.log('[jQuery.SoundCloud] [error] ' + error);
|
||||
}
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
// Request the embed HTML
|
||||
SC.oEmbed(
|
||||
parameters.url,
|
||||
parameters,
|
||||
function(oEmbed)
|
||||
{
|
||||
$(element).replaceWith(oEmbed.html.replace("https://", protocol));
|
||||
}
|
||||
);
|
||||
}
|
||||
catch (error)
|
||||
{
|
||||
console.log('[jQuery.SoundCloud] [error] ' + error);
|
||||
}
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
})(jQuery);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue