no background for banner
[wolnelektury.git] / src / catalogue / static / player / player.js
1 (function($) {
2     $(function() {
3
4       $(".jp-jplayer").each(function() {
5         var $self = $(this);
6         var $root = $self.parent();
7         var $number = $('.number', $root);
8         $self.jPlayer({
9             swfPath: "/static/jplayer/",
10             solution: "html,flash",
11             supplied: $self.attr('data-supplied'),
12             cssSelectorAncestor: "#" + $self.attr("data-player"),
13
14             ready: function() {
15                 var player = $(this);
16                 var setMedia = function(elem) {
17                     var li = $(elem).parent();
18                     var media = {}
19
20                     media['mp3'] = li.attr('data-mp3');
21                     media['oga'] = li.attr('data-ogg');
22
23                     $(".title", $root).html(li.html());
24                     return player.jPlayer("setMedia", media);
25                 };
26
27                 $('.play-next', $root).click(function() {
28                     var next = parseInt($number.text()) + 1;
29                     var p = $('.play:eq(' + next + ')', $root);
30                     if (p.length) {
31                         setMedia(p).jPlayer("play");
32                         $number.text(next)
33                     }
34                 });
35                 $('.play-prev', $root).click(function() {
36                     var next = parseInt($number.text()) - 1;
37                     if (next < 1)
38                         return;
39                     var p = $('.play:eq(' + next + ')', $root);
40                     setMedia(p).jPlayer("play");
41                     $number.text(next)
42                 });
43
44                 setMedia($('.play', $root).first());
45
46             }
47         });
48       });
49
50
51
52     });
53 })(jQuery)