]> khamidou — GitHub mirrors - popcorn-js.git/commitdiff
updated text position for image plugin, more than one image can be displayed now...
authorunknown <minoo@.(none)>
Thu, 14 Apr 2011 19:48:49 +0000 (15:48 -0400)
committerunknown <minoo@.(none)>
Thu, 14 Apr 2011 19:48:49 +0000 (15:48 -0400)
plugins/image/popcorn.image.html
plugins/image/popcorn.image.js
plugins/image/popcorn.image.unit.js

index 4003d3206717351980cf0f1f4c7879d3c4781a11..e045124ebe74f3546108dbe85ffd67c05d666c41 100644 (file)
         target: 'imagediv'
       } )
       .image({
-        start: 20, // seconds
+        start: 5, // seconds
         end: 45, // seconds
         // no href
         src: 'http://patriciabergeron.net/wp-content/uploads/web.made_.movie_marquee.gif',
-        text: 'WEB MADE MOVIES',
         target: 'imagediv'
       } );
 
@@ -33,8 +32,9 @@
 </head>
 <body>
   <h1 id="qunit-header">Popcorn Image Plug-in Demo</h1>
-  <p> An image will appear at 5 seconds and disappear at 15 seconds.</p>
-  <p> An image will appear at 20 seconds and disappear at 45 seconds.</p>
+  <p> Two images will appear at 5 seconds.</p>
+  <p> First one (with an overlayed text) will disappear at 15 seconds.</p>
+  <p> Second one (without an overlayed text) will disappear at 45 seconds.</p>
   <div>
     <video id='video' 
       controls
index dd97911007fbeceb2e05b4bcdf9f977436f6c3a9..c6b03d5d59199435ea4c1733e3ca930cbea4a541 100644 (file)
       _setup: function( options ) {
 
         options.link = document.createElement( 'a' );
-        options.link.style.display = "none"; // display none by default
         options.link.style.position = "relative";
-        options.link.style.height = "100%";
-        //options.link.style.width = "100%";
+        options.link.style.textDecoration = "none";
 
+        var img = document.createElement( 'img' );
+        img.src = options.src;
+        img.style.borderStyle = "none"; // borders look really bad, if someone wants it they can put it on their div target
+        
         if ( options.href ) {
           options.link.href = options.href;
         }
           document.getElementById( options.target ).appendChild( options.link ); // add the widget's div to the target div
         }
         
-        var img = document.createElement( 'img' );
-        img.src = options.src;
-        img.style.position = "absolute";
-        img.style.height = "100%";
-        //img.style.width = "100%";
-        img.style.borderStyle = "none"; // borders look really bad, if someone wants it they can put it on their div target
-        
-        var fontHeight = ((document.getElementById( options.target ).offsetHeight) / 12) + "px";
+        var fontHeight = ( img.height / 12 ) + "px";
         
         var divText = document.createElement( 'div' );
         divTextStyle = {
-            position: "absolute",
-            top: "50%",
+            position: "relative",
+            width: img.width + "px",
             textAlign: "center",
-            left: 0,
-            right: 0,
             fontSize: fontHeight,
             color: "black",
             fontWeight : "bold",
         for ( st in divTextStyle ) {
           divText.style[ st ] = divTextStyle[ st ];
         }
-        divText.innerHTML = options.text;
         
+        divText.innerHTML = options.text || "";
         options.link.appendChild( divText );
         options.link.appendChild( img );
+        divText.style.top = ( img.height / 2 ) - ( divText.offsetHeight / 2 ) + "px"; 
+        options.link.style.display = "none";
       },
 
       /**
index d6dd8cf75f35381b86bfbeadc582b31bcb978ca8..79b96bc6b1be384b406d4982074addc1585723ec 100644 (file)
@@ -34,7 +34,7 @@ test("Popcorn Image Plugin", function () {
 
   interval = setInterval( function() {
     if( popped.currentTime() > 1 && popped.currentTime() < 3 ) {
-      ok( /display: inline;/.test( imagediv.innerHTML ), "Div contents are displayed" );
+      ok( /display: block;/.test( imagediv.innerHTML ), "Div contents are displayed" );
       plus();
       ok( /img/.test( imagediv.innerHTML ), "An image exists" );
       plus();