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,6 +1,7 @@
|
||||||
jquery.soundcloud
|
# jquery.soundcloud
|
||||||
=================
|
|
||||||
|
|
||||||
jQuery plugin to inject the SoundCloud player.
|
jQuery plugin to inject the SoundCloud player.
|
||||||
|
|
||||||
Check `example.html` for more information.
|
Check [example.html][example] for more information.
|
||||||
|
|
||||||
|
[example]: https://github.com/joshtronic/jquery.soundcloud/blob/master/example.html
|
||||||
|
|
54
example.html
54
example.html
|
@ -1,32 +1,32 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>jQuery SoundCloud Plugin</title>
|
<title>jQuery SoundCloud Plugin</title>
|
||||||
<script src="http://cdnjs.cloudflare.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
<script src="http://cdnjs.cloudflare.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
||||||
<script src="./jquery.soundcloud.js" charset="utf-8"></script>
|
<script src="./jquery.soundcloud.js" charset="utf-8"></script>
|
||||||
<script>
|
<script>
|
||||||
$(function()
|
$(function()
|
||||||
{
|
{
|
||||||
$('.soundcloud').soundcloud({ client_id: 'b0d6766e74d8b02f74459447c186b12e' });
|
$('.soundcloud').soundcloud({ client_id: 'b0d6766e74d8b02f74459447c186b12e' });
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<h1>jQuery SoundCloud Plugin</h1>
|
<h1>jQuery SoundCloud Plugin</h1>
|
||||||
|
|
||||||
<h2>Maximum Config</h2>
|
<h2>Maximum Config</h2>
|
||||||
<div
|
<div
|
||||||
class="soundcloud"
|
class="soundcloud"
|
||||||
data-url="https://soundcloud.com/joshtronic/baby-got-back"
|
data-url="https://soundcloud.com/joshtronic/baby-got-back"
|
||||||
data-auto_play="true"
|
data-auto_play="true"
|
||||||
data-color="336699"
|
data-color="336699"
|
||||||
data-iframe="false"
|
data-iframe="false"
|
||||||
data-maxheight="81px"
|
data-maxheight="81px"
|
||||||
data-max-width="500px"
|
data-max-width="500px"
|
||||||
data-show_comments="true"
|
data-show_comments="true"
|
||||||
></div>
|
></div>
|
||||||
|
|
||||||
<h2>Minimal Config</h2>
|
<h2>Minimal Config</h2>
|
||||||
<div class="soundcloud" data-url="https://soundcloud.com/joshtronic/baby-got-back"></div>
|
<div class="soundcloud" data-url="https://soundcloud.com/joshtronic/baby-got-back"></div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -1,66 +1,66 @@
|
||||||
(function($)
|
(function($)
|
||||||
{
|
{
|
||||||
$.fn.soundcloud = function(options)
|
$.fn.soundcloud = function(options)
|
||||||
{
|
{
|
||||||
// Default settings
|
// Default settings
|
||||||
var defaults = {
|
var defaults = {
|
||||||
auto_play: false,
|
auto_play: false,
|
||||||
//callback: false,
|
//callback: false,
|
||||||
client_id: false,
|
client_id: false,
|
||||||
color: false,
|
color: false,
|
||||||
iframe: true,
|
iframe: true,
|
||||||
maxheight: false,
|
maxheight: false,
|
||||||
maxwidth: false,
|
maxwidth: false,
|
||||||
show_comments: true,
|
show_comments: true,
|
||||||
url: false
|
url: false
|
||||||
};
|
};
|
||||||
|
|
||||||
// Overrides the defaults with passed in options
|
// Overrides the defaults with passed in options
|
||||||
options = $.extend({}, defaults, options);
|
options = $.extend({}, defaults, options);
|
||||||
|
|
||||||
var elements = this;
|
var elements = this;
|
||||||
var protocol = document.location.protocol == 'https:' ? 'https://' : 'http://';
|
var protocol = document.location.protocol == 'https:' ? 'https://' : 'http://';
|
||||||
|
|
||||||
if (typeof SC === 'undefined')
|
if (typeof SC === 'undefined')
|
||||||
{
|
{
|
||||||
$.getScript(
|
$.getScript(
|
||||||
protocol + 'connect.soundcloud.com/sdk.js',
|
protocol + 'connect.soundcloud.com/sdk.js',
|
||||||
function()
|
function()
|
||||||
{
|
{
|
||||||
elements.each(function(index, element)
|
elements.each(function(index, element)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Overrides the options with the data attributes
|
// Overrides the options with the data attributes
|
||||||
parameters = $.extend({}, options, $(this).data());
|
parameters = $.extend({}, options, $(this).data());
|
||||||
|
|
||||||
// Checks that we have a client ID
|
// Checks that we have a client ID
|
||||||
if (!parameters.client_id)
|
if (!parameters.client_id)
|
||||||
{
|
{
|
||||||
throw 'Missing client ID.';
|
throw 'Missing client ID.';
|
||||||
}
|
}
|
||||||
|
|
||||||
SC.initialize({ client_id: parameters.client_id });
|
SC.initialize({ client_id: parameters.client_id });
|
||||||
|
|
||||||
// Request the embed HTML
|
// Request the embed HTML
|
||||||
SC.oEmbed(
|
SC.oEmbed(
|
||||||
parameters.url,
|
parameters.url,
|
||||||
parameters,
|
parameters,
|
||||||
function(oEmbed)
|
function(oEmbed)
|
||||||
{
|
{
|
||||||
$(element).replaceWith(oEmbed.html.replace("https://", protocol));
|
$(element).replaceWith(oEmbed.html.replace("https://", protocol));
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
catch (error)
|
catch (error)
|
||||||
{
|
{
|
||||||
console.log('[jQuery.SoundCloud] [error] ' + error);
|
console.log('[jQuery.SoundCloud] [error] ' + error);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
})(jQuery);
|
})(jQuery);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue