From c91530cf71c7220ff25f6409e3954148192db024 Mon Sep 17 00:00:00 2001 From: ScottDowne Date: Wed, 6 Jul 2011 15:28:01 -0400 Subject: [PATCH] [#t644] fixed subtitle bug in multiple instance and tests --- plugins/subtitle/popcorn.subtitle.js | 17 +++--- plugins/subtitle/popcorn.subtitle.unit.html | 16 ++++++ plugins/subtitle/popcorn.subtitle.unit.js | 64 ++++++++++++++++----- 3 files changed, 72 insertions(+), 25 deletions(-) diff --git a/plugins/subtitle/popcorn.subtitle.js b/plugins/subtitle/popcorn.subtitle.js index db24f5d..bb3235f 100755 --- a/plugins/subtitle/popcorn.subtitle.js +++ b/plugins/subtitle/popcorn.subtitle.js @@ -22,9 +22,10 @@ } }, createDefaultContainer = function( context ) { - - // clear this function from future calls; we are done - createDefaultContainer = Popcorn.nop; + + var ctxContainer = context.container = document.createElement( "div" ), + style = ctxContainer.style, + media = context.media; var updatePosition = function() { var position = context.position(); @@ -37,11 +38,7 @@ setTimeout( updatePosition, 10 ); }; - var ctxContainer = context.container = document.createElement( "div" ), - style = ctxContainer.style, - media = context.media; - - ctxContainer.id = "subtitlediv"; + ctxContainer.id = Popcorn.guid(); style.position = "absolute"; style.color = "white"; style.textShadow = "black 2px 2px 6px"; @@ -157,7 +154,7 @@ i++; // Creates a div for all subtitles to use - ( !this.container && !options.target || options.target === "subtitle-container" ) && + ( !this.container && ( !options.target || options.target === "subtitle-container" ) ) && createDefaultContainer( this ); // if a target is specified, use that @@ -167,7 +164,7 @@ // use shared default container options.container = this.container; } - + document.getElementById( options.container.id ).appendChild( newdiv ); options.innerContainer = newdiv; diff --git a/plugins/subtitle/popcorn.subtitle.unit.html b/plugins/subtitle/popcorn.subtitle.unit.html index 1a02e3e..05ff6db 100755 --- a/plugins/subtitle/popcorn.subtitle.unit.html +++ b/plugins/subtitle/popcorn.subtitle.unit.html @@ -37,6 +37,22 @@

Your user agent does not support the HTML5 Video element.

+ +

Choose your language