]> khamidou — GitHub mirrors - popcorn-js.git/commitdiff
Merge branch '0.6' of git://github.com/annasob/popcorn-js into t485
authorMohammed Buttu <mohammedbuttu@gmail.com>
Wed, 18 May 2011 17:08:03 +0000 (13:08 -0400)
committerMohammed Buttu <mohammedbuttu@gmail.com>
Wed, 18 May 2011 17:08:03 +0000 (13:08 -0400)
Conflicts:
plugins/image/popcorn.image.js
plugins/image/popcorn.image.unit.js

1  2 
plugins/image/popcorn.image.js
plugins/image/popcorn.image.unit.js

index 0a25623aa07ff0e2da56f1777975661505010917,3a8b2926b327d9e9b50d21033d56a81de1ec33e4..6c5005f5b372014de0c6581c7881b05cea6168af
          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";
  
-               divText    = document.createElement( "div" );
 +          var fontHeight = ( img.height / 12 ) + "px", 
++              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 );
         */
        end: function( event, options ) {
          options.link.style.display = "none";
+       },
+       _teardown: function( options ) {
+         document.getElementById( options.target ) && document.getElementById( options.target ).removeChild( options.link );
        }
    });
 -
  })( Popcorn );
index a50957f89f7e18ea92b9b8330647de77953f6188,29b82a12331e46a29a855c188e57a1cfb148a6c7..43857be113919e83a12acf82a7cfe8e0f773ab66
@@@ -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,
 -      imagediv = document.getElementById('imagediv');
+       setupId,
 +      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 );
    
    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();
    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();  
  });