Permalink
Browse files

Make timestamp numbers unique per scrolling-text div

  • Loading branch information...
1 parent 11c0389 commit cf435c50ad41cf304526788cbdab0e83f70870fd @noahadler committed Nov 29, 2011
Showing with 22 additions and 21 deletions.
  1. +22 −21 media_timestamp.js
View
@@ -24,19 +24,17 @@ jQuery(document).ready(function() {
// TODO: div.scrollable text should be a text render style ideally - currently implemented directly in theme templates
var currentTime = player.media.currentTime;
jQuery('.scrolling-text').each(function(index, el) {
- var timestamps = jQuery(el).find('a.timestamp');
- var prevTs = null
- var nextTs = null;
- timestamps.each(function(ti,tel) {
+ el.timestamps = jQuery(el).find('a.timestamp');
+ el.prevTs = null;
+ el.timestamps.each(function(ti,tel) {
if (parseInt(jQuery(tel).attr('timestamp')) <= currentTime)
{
- prevTs = jQuery(tel);
-
+ el.prevTs = jQuery(tel);
}
});
- if (prevTs !== null)
+ if (el.prevTs !== null)
{
- jQuery(el).animate({scrollTop: prevTs.position().top + jQuery(el).scrollTop() - jQuery(el).position().top }, 1000);
+ jQuery(el).animate({scrollTop: el.prevTs.position().top + jQuery(el).scrollTop() - jQuery(el).position().top }, 900);
}
});
@@ -49,19 +47,22 @@ jQuery(document).ready(function() {
console.log('duration: ' + duration);
timerail.css('position', 'relative');
- jQuery('span.timestamp').each(function (index) {
- index = index+1 // start from 1 instead of 0
- var time = convertTimestampToTime(jQuery(this).text());
- //console.log('timespan ' + index + ' @ ' + jQuery(this).text() + ' (' + time + ')');
-
- timerail.append('<div id="marker_' + index + '">'+index+'</div>');
- jQuery('.mejs-time-rail #marker_'+index).css({
- 'position': 'absolute',
- 'color': 'white',
- 'left': (time*parseInt(timerail_width)*1.0/duration)+'px',
- 'bottom': '-14px'});
-
- jQuery(this).replaceWith('<a href="#" onclick="jQuery(\'video\')[0].player.setCurrentTime('+time+');return false;" class="timestamp" timestamp="' + time + '">' + index + '</a>');
+ jQuery('div.scrolling-text').each(function (scrollIdx,scrollTextEl) {
+
+ jQuery(scrollTextEl).find('span.timestamp').each(function (index) {
+ index = index+1 // start from 1 instead of 0
+ var time = convertTimestampToTime(jQuery(this).text());
+ //console.log('timespan ' + index + ' @ ' + jQuery(this).text() + ' (' + time + ')');
+
+ timerail.append('<div id="marker_' + index + '">'+index+'</div>');
+ jQuery('.mejs-time-rail #marker_'+index).css({
+ 'position': 'absolute',
+ 'color': 'white',
+ 'left': (time*parseInt(timerail_width)*1.0/duration)+'px',
+ 'bottom': '-14px'});
+
+ jQuery(this).replaceWith('<a href="#" onclick="jQuery(\'video\')[0].player.setCurrentTime('+time+');return false;" class="timestamp" timestamp="' + time + '">' + index + '</a>');
+ });
});
}, 500);
});

0 comments on commit cf435c5

Please sign in to comment.