ignore *.css.map
[wolnelektury.git] / src / catalogue / static / player / player.js
index 69dceed..a41d2c0 100755 (executable)
@@ -1,34 +1,53 @@
 (function($) {
     $(function() {
 
 (function($) {
     $(function() {
 
-      $("#jplayer").each(function() {
+      $(".jp-jplayer").each(function() {
        var $self = $(this);
        var $self = $(this);
+        var $root = $self.parent();
+        var $number = $('.number', $root);
         $self.jPlayer({
             swfPath: "/static/jplayer/",
             solution: "html,flash",
             supplied: $self.attr('data-supplied'),
         $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();
             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 = {}
                     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);
                 };
                     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)