X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/357027375ff8867f42ca34bcbfb5a78b5b185fc3..b9dc6590aa12ae1b04e11dbb57684c5630c1e3bd:/src/catalogue/static/player/player.js diff --git a/src/catalogue/static/player/player.js b/src/catalogue/static/player/player.js index 69dceed55..a41d2c0ae 100755 --- a/src/catalogue/static/player/player.js +++ b/src/catalogue/static/player/player.js @@ -1,34 +1,53 @@ (function($) { $(function() { - $("#jplayer").each(function() { + $(".jp-jplayer").each(function() { var $self = $(this); + var $root = $self.parent(); + var $number = $('.number', $root); $self.jPlayer({ swfPath: "/static/jplayer/", solution: "html,flash", supplied: $self.attr('data-supplied'), - + cssSelectorAncestor: "#" + $self.attr("data-player"), + ready: function() { var player = $(this); var setMedia = function(elem) { var li = $(elem).parent(); - $('.jp-playlist-current').removeClass('jp-playlist-current'); - $(li).addClass('jp-playlist-current'); var media = {} - - $('.mp3', li).each(function() {media['mp3'] = $(this).attr('href')}); - $('.ogg', li).each(function() {media['oga'] = $(this).attr('href')}); - + + media['mp3'] = li.attr('data-mp3'); + media['oga'] = li.attr('data-ogg'); + + $(".title", $root).html(li.html()); return player.jPlayer("setMedia", media); }; - setMedia($('.play').first()).jPlayer("play"); - - $('.play').click(function() { - setMedia(this).jPlayer("play"); + + $('.play-next', $root).click(function() { + var next = parseInt($number.text()) + 1; + var p = $('.play:eq(' + next + ')', $root); + if (p.length) { + setMedia(p).jPlayer("play"); + $number.text(next) + } + }); + $('.play-prev', $root).click(function() { + var next = parseInt($number.text()) - 1; + if (next < 1) + return; + var p = $('.play:eq(' + next + ')', $root); + setMedia(p).jPlayer("play"); + $number.text(next) }); + + setMedia($('.play', $root).first()); + } }); }); + + }); -})(jQuery) \ No newline at end of file +})(jQuery)