From d74e8e3c9e9cca3eee765a7c31f3a1bb83f10a91 Mon Sep 17 00:00:00 2001 From: luk Date: Wed, 15 May 2013 13:06:11 +0200 Subject: [PATCH] Make it possible to click a playlist item to pause it Don't know if this addition is worth to merge, but as we have long playlists it's not very convenient to always have to scroll up to the main player. Like this it's possible to click on the playing playlist item to pause the player. --- add-on/jplayer.playlist.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/add-on/jplayer.playlist.js b/add-on/jplayer.playlist.js index b8b208b6..fbe6abdd 100644 --- a/add-on/jplayer.playlist.js +++ b/add-on/jplayer.playlist.js @@ -270,10 +270,20 @@ // Create live handlers for the playlist items $(this.cssSelector.playlist).off("click", "a." + this.options.playlistOptions.itemClass).on("click", "a." + this.options.playlistOptions.itemClass, function() { var index = $(this).parent().parent().index(); + var playing = $(this).is('.jp-playlist-playing'); + if(self.current !== index) { - self.play(index); + if ( playing ) { + self.pause(); + } else { + self.play(index); + } } else { - $(self.cssSelector.jPlayer).jPlayer("play"); + if ( playing ) { + $(self.cssSelector.jPlayer).jPlayer("pause"); + } else { + $(self.cssSelector.jPlayer).jPlayer("play"); + } } $(this).blur(); return false;