From 44547e8dd7cd7197c04f2f96ae09d56e5c5dc60f Mon Sep 17 00:00:00 2001 From: sanj Date: Sat, 5 Jun 2010 04:21:48 +0530 Subject: [PATCH] added showSubtitle and hideSubtitle as optional callbacks to opts --- jquery.srt.js | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/jquery.srt.js b/jquery.srt.js index 935dcb6..d046015 100644 --- a/jquery.srt.js +++ b/jquery.srt.js @@ -80,21 +80,33 @@ } if(subtitle > 0) { if(subtitle != currentSubtitle) { - subtitleElement.html(subtitles[subtitle].t); + opts.showSubtitle(subtitles[subtitle].t, subtitleElement); +// subtitleElement.html(subtitles[subtitle].t); currentSubtitle=subtitle; } else if(subtitles[subtitle].o < currentTime) { - subtitleElement.html(''); + opts.hideSubtitle(subtitleElement); +// subtitleElement.html(''); } } }, opts.interval); } + function showSubtitle(txt, elem) { + elem.html(txt); + } + + function hideSubtitle(elem) { + elem.html(''); + } + jQuery.fn.srt = function(o) { var that = this; var opts = $.extend({ 'interval': 100, 'id': that.attr('data-video'), - 'url': that.attr('data-srt') + 'url': that.attr('data-srt'), + 'showSubtitle': showSubtitle, + 'hideSubtitle': hideSubtitle }, o); this.each(function() { var subtitleElement = $(this);