From: Mohammed Buttu Date: Wed, 18 May 2011 17:08:03 +0000 (-0400) Subject: Merge branch '0.6' of git://github.com/annasob/popcorn-js into t485 X-Git-Tag: v0.6~6^2~3 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=786b7d89d9d6d8a4352e852918d828e9e5cc6dca;p=popcorn-js.git Merge branch '0.6' of git://github.com/annasob/popcorn-js into t485 Conflicts: plugins/image/popcorn.image.js plugins/image/popcorn.image.unit.js --- 786b7d89d9d6d8a4352e852918d828e9e5cc6dca diff --cc plugins/image/popcorn.image.js index 0a25623,3a8b292..6c5005f --- a/plugins/image/popcorn.image.js +++ b/plugins/image/popcorn.image.js @@@ -72,36 -53,36 +72,38 @@@ options.link.style.position = "relative"; options.link.style.textDecoration = "none"; - var img = document.createElement( 'img' ); + if ( document.getElementById( options.target ) ) { + // add the widget's div to the target div + document.getElementById( options.target ).appendChild( options.link ); + } + img.addEventListener( "load", function() { - // borders look really bad, if someone wants it they can put it on their div target - img.style.borderStyle = "none"; + // borders look really bad, if someone wants it they can put it on their div target + img.style.borderStyle = "none"; if ( options.href ) { options.link.href = options.href; } + options.link.target = "_blank"; + var fontHeight = ( img.height / 12 ) + "px", - divText = document.createElement( "div" ); ++ divText = document.createElement( "div" ); + // add the widget's div to the target div + document.getElementById( options.target ) && document.getElementById( options.target ).appendChild( options.link ); - var fontHeight = ( img.height / 12 ) + "px"; - - var divText = document.createElement( 'div' ); - divTextStyle = { - position: "relative", - width: img.width + "px", - textAlign: "center", - fontSize: fontHeight, - color: "black", - fontWeight : "bold", - zIndex: "10" - }; - for ( var st in divTextStyle ) { - divText.style[ st ] = divTextStyle[ st ]; - } - + Popcorn.extend( divText.style, { + + color: "black", + fontSize: fontHeight, + fontWeight: "bold", + position: "relative", + textAlign: "center", + width: img.width + "px", + zIndex: "10" + }); + divText.innerHTML = options.text || ""; options.link.appendChild( divText ); options.link.appendChild( img ); @@@ -129,6 -109,10 +131,9 @@@ */ end: function( event, options ) { options.link.style.display = "none"; + }, + _teardown: function( options ) { + document.getElementById( options.target ) && document.getElementById( options.target ).removeChild( options.link ); } }); - })( Popcorn ); diff --cc plugins/image/popcorn.image.unit.js index a50957f,29b82a1..43857be --- a/plugins/image/popcorn.image.unit.js +++ b/plugins/image/popcorn.image.unit.js @@@ -1,14 -1,10 +1,15 @@@ test("Popcorn Image Plugin", function () { -- - var popped = Popcorn("#video"), - expects = 6, ++ + var popped = Popcorn( "#video" ), + expects = 8, count = 0, + setupId, - imagediv = document.getElementById('imagediv'); + imagediv = document.getElementById( "imagediv" ), + sources = [ + "https://www.drumbeat.org/media//images/drumbeat-logo-splash.png", + "http://www.petmountain.com/category/mini/organic-dog-supplies/520/organic-dog-supplies.jpg", + "http://www.botskool.com/sites/default/files/images/javascript.png" + ]; expect( expects ); @@@ -27,34 -23,16 +28,36 @@@ plus(); popped.image({ - start: 1, // seconds - end: 3, // seconds - href: 'http://www.drumbeat.org/', - src: 'https://www.drumbeat.org/media//images/drumbeat-logo-splash.png', - text: 'DRUMBEAT', - target: 'imagediv' + // seconds + start: 1, + // seconds + end: 3, + href: "http://www.drumbeat.org/", + src: sources[0], + text: "DRUMBEAT", + target: "imagediv" + }) + .image({ + // seconds - start: 4, ++ start: 5, + // seconds - end: 6, ++ end: 7, + // no href + src: sources[1], + target: "imagediv" + }) + .image({ + // seconds - start: 4, ++ start: 5, + // seconds - end: 6, ++ end: 7, + // no href + src: sources[2], + target: "imagediv" }); + setupId = popped.getLastTrackEventId(); + popped.exec( 2, function() { ok( /display: block;/.test( imagediv.innerHTML ), "Div contents are displayed" ); plus(); @@@ -65,14 -43,11 +68,19 @@@ popped.exec( 4, function() { ok( /display: none;/.test( imagediv.innerHTML ), "Div contents are hidden again" ); plus(); - + }); + - popped.exec( 5, function() { ++ popped.exec( 6, function() { + [].forEach.call( document.querySelectorAll( "#imagediv a img" ), function( img, idx ) { + ok( img.src === sources[ idx ], "Image " + idx + " is in the right order" ); + plus(); - }); ++ }); ++ ++ popped.exec( 8, function() { + popped.pause().removeTrackEvent( setupId ); + ok( !imagediv.children[0], "removed image was properly destroyed" ); + plus(); }); - popped.volume(0).play(); + popped.volume( 0 ).play(); });