From d6b7af5fe29cade08a99c87b1959c42296e63ba0 Mon Sep 17 00:00:00 2001 From: secretrobotron Date: Mon, 11 Jun 2012 14:37:11 -0400 Subject: [PATCH 1/2] [t1143] text plugin target can be media element --- plugins/text/popcorn.text.html | 8 ++++++++ plugins/text/popcorn.text.js | 3 +++ plugins/text/popcorn.text.unit.js | 22 ++++++++++++++++++++++ 3 files changed, 33 insertions(+) diff --git a/plugins/text/popcorn.text.html b/plugins/text/popcorn.text.html index a3f384ea..7081a25d 100755 --- a/plugins/text/popcorn.text.html +++ b/plugins/text/popcorn.text.html @@ -68,6 +68,14 @@ multiline: true }) + // Overlay + .text({ + start: 40, + end: 45, + text: 'Text on video' + }) + + .play().volume( 0 ); } ); diff --git a/plugins/text/popcorn.text.js b/plugins/text/popcorn.text.js index 164bcdef..b356c36e 100755 --- a/plugins/text/popcorn.text.js +++ b/plugins/text/popcorn.text.js @@ -171,6 +171,9 @@ if ( !target ) { target = createSubtitleContainer( this, options.target ); } + else if ( [ "VIDEO", "AUDIO" ].indexOf( target.nodeName ) > -1 ) { + target = createSubtitleContainer( this, options.target + "-overlay" ); + } } else if ( !this.container ) { // Creates a div for all subtitles to use diff --git a/plugins/text/popcorn.text.unit.js b/plugins/text/popcorn.text.unit.js index 743cb355..37ca7b03 100755 --- a/plugins/text/popcorn.text.unit.js +++ b/plugins/text/popcorn.text.unit.js @@ -338,3 +338,25 @@ asyncTest( "Subtitle container creation tests", 3, function() { popped.destroy(); start(); }); + +asyncTest( "Media element as target", 2, function() { + + var popped = Popcorn( "#video" ), + containerAfterParse; + + popped.text({ + start: 0, + end: 10, + text: "Text on video", + target: "video" + }); + + containerAfterParse = document.getElementById( "video-overlay" ); + + ok( !!containerAfterParse, "video-overlay container exists" ); + equal( containerAfterParse.children[ 0 ].innerHTML, "Text on video", "Text displayed in created overlay container" ); + + popped.destroy(); + start(); +}); + From ac186fe578a1e5d867e86a6e106b61205ddbd445 Mon Sep 17 00:00:00 2001 From: secretrobotron Date: Mon, 11 Jun 2012 17:45:26 -0400 Subject: [PATCH 2/2] [t1143] review changes --- plugins/text/popcorn.text.html | 1 - 1 file changed, 1 deletion(-) diff --git a/plugins/text/popcorn.text.html b/plugins/text/popcorn.text.html index 7081a25d..7236084b 100755 --- a/plugins/text/popcorn.text.html +++ b/plugins/text/popcorn.text.html @@ -75,7 +75,6 @@ text: 'Text on video' }) - .play().volume( 0 ); } );