]> khamidou — GitHub mirrors - popcorn-js.git/commitdiff
Recreated tagthispersonNew branch based on the latest tagthisperson plugin code -#91
authorMinoo <minoo.ziaei@gmail.com>
Thu, 3 Mar 2011 02:23:44 +0000 (21:23 -0500)
committerMinoo <minoo.ziaei@gmail.com>
Thu, 3 Mar 2011 02:23:44 +0000 (21:23 -0500)
plugins/tagthisperson/popcorn.tagthisperson.html
plugins/tagthisperson/popcorn.tagthisperson.js
plugins/tagthisperson/popcorn.tagthisperson.unit.html
plugins/tagthisperson/popcorn.tagthisperson.unit.js

index f843588cbae912d863d9cbaf78c7b76fedca8256..bc5afee055df9fcf8ee4f97522c7bba5a4dced36 100644 (file)
         end: 10, // seconds
         person: 'Anna Sob',
         image: 'http://newshour.s3.amazonaws.com/photos%2Fspeeches%2Fguests%2FRichardNSmith_thumbnail.jpg',
+        href: 'http://annasob.wordpress.com',   
         target: 'tagdiv'
       } )
       .tagthisperson({
         start: 5, // seconds
         end: 15, // seconds
         person: 'Scott',
+        href: 'http://scottdowne.wordpress.com/',
         target: 'tagdiv'
       } )
       .tagthisperson({
         start: 0, // seconds
         end: 15, // seconds
-        person: 'Scott',
+        person: 'Mike',
         target: 'tagdiv2'
       } )
     }, false);
@@ -35,8 +37,9 @@
 </head>
 <body>
   <h1 id="qunit-header">Popcorn tagthisperson Plug-in Demo</h1>
-  <p> A tag displaying Scott will appear at 0 seconds and disappear at 15 seconds.</p>
-  <p> A separate tag displaying Anna Sob  with an image will appear at 0 seconds and disappear at 10 seconds. At 5 seconds Scott will be appended to this tag.</p>
+  <p> A tag displaying Mike will appear at 0 seconds and disappear at 15 seconds.</p>
+  <p> A separate tag displaying Anna Sob  with an image and a URL attached will appear at 0 seconds and disappear at 10 seconds.</p>
+  <p> At 5 seconds Scott with a URL attached will be appended to this tag and disappear at 15 seconds.</p>
   <div>
     <video id='video' 
       controls preload='none' 
index 1d06a79f496feeddf5b924ee9ee0910dae5244a6..0ac95eb4e475bc57ce2b2e5554a8cbc5ecd4ce7a 100644 (file)
@@ -10,6 +10,7 @@
    * End is the time that you want this plug-in to stop executing 
    * Person is the name of the person who you want to tag
    * Image is the url to the image of the person - optional
+   * href is the url to the webpage of the person - optional   
    * Target is the id of the document element that the text needs to be 
    * attached to, this target element must exist on the DOM
    * 
@@ -21,6 +22,8 @@
           start: 5, // seconds
           end: 15, // seconds
           person: '@annasob',
+          image:  'http://newshour.s3.amazonaws.com/photos%2Fspeeches%2Fguests%2FRichardNSmith_thumbnail.jpg',
+          href:   'http://annasob.wordpress.com',
           target: 'tagdiv'
         } )
    *
           end      : {elem:'input', type:'text', label:'Out'},
           target   : 'tag-container',
           person   : {elem:'input', type:'text', label:'Name'},
-          image    : {elem:'input', type:'text', label:'Image Src'}
+          image    : {elem:'input', type:'text', label:'Image Src'},
+          href     : {elem:'input', type:'text', label:'URL'}   
         }
       },
       _setup: function( options ) {
         var exists = false;
         // loop through the existing objects to ensure no duplicates
         // the idea here is to have one object per unique options.target
-        for ( var i = 0; i< peopleArray.length; i++ ) {
+        for ( var i = 0; i < peopleArray.length; i++ ) {
           if ( peopleArray[ i ].name === options.target ) {
             options._p = peopleArray[ i ];  
             exists = true;
        * options variable
        */
       start: function( event, options ){
-        if ( options.image ) {
-          options._p.contains[ options.person ] = " <img src='" + options.image + "'/> " + options.person;
-        } else {
-          options._p.contains[ options.person ] = options.person;
-        }
-        //options._p.contains[options.person] = options.person;
+        options._p.contains[ options.person ] = ( options.image ) ? "<img src='" + options.image + "'/> " : "" ;
+        options._p.contains[ options.person ] += ( options.href ) ? "<a href='" + options.href + "' target='_blank'> " + options.person + "</a>" : options.person ;
+
         if ( document.getElementById( options.target ) ) {
-          document.getElementById( options.target ).innerHTML  = options._p.toString();
+          document.getElementById( options.target ).innerHTML = options._p.toString();
         }
       },
       /**
        * of the video  reaches the end time provided by the 
        * options variable
        */
-      end: function(event, options){
+      end: function( event, options ){
         delete options._p.contains[ options.person ];
         if ( document.getElementById( options.target ) ) {
-          document.getElementById( options.target ).innerHTML  = options._p.toString();
+          document.getElementById( options.target ).innerHTML = options._p.toString();
         }
       }
    };
index 43cea3fa8b955fbc78b57639a64dca1541c9a211..f5c181245ffb0c19aaf27100fbcecfcb9553351c 100644 (file)
@@ -39,5 +39,6 @@
 
   </video> 
   <div id="tagdiv"></div>  
+  <div id="tagdiv2"></div>    
 </body>
 </html>
index abba1793fdd028a28f7a3d0b45f2466b0358b1fa..e9332dad034490cea064c7f9c311fee65883587c 100644 (file)
@@ -1,17 +1,19 @@
 test("Popcorn tagthisperson Plugin", function () {
   
   var popped = Popcorn( "#video" ),
-      expects = 7, 
+      expects = 8, 
       count = 0,
       interval,
       interval2,
       interval3,
+      interval4,
       tagdiv = document.getElementById( 'tagdiv' );
+      tagdiv2 = document.getElementById( 'tagdiv2' );
   
   expect(expects);
   
   function plus() {
-    if ( ++count===expects ) {
+    if ( ++count === expects ) {
       start();
     }
   }
@@ -29,21 +31,35 @@ test("Popcorn tagthisperson Plugin", function () {
       end: 5, // seconds
       person: 'Anna Sob',
       image: 'http://newshour.s3.amazonaws.com/photos%2Fspeeches%2Fguests%2FRichardNSmith_thumbnail.jpg',
+      href: 'http://annasob.wordpress.com',           
       target: 'tagdiv'
     } )
     .tagthisperson({
       start: 3, // seconds
       end: 10, // seconds
       person: 'Scott',
+      href: 'http://scottdowne.wordpress.com/',
       target: 'tagdiv'
     } )
+    .tagthisperson({
+      start: 6, // seconds
+      end: 10, // seconds
+      person: 'Mike',
+      target: 'tagdiv2'
+    } )    
+    .tagthisperson({
+      start: 7, // seconds
+      end: 12, // seconds
+      person: 'Daniel',
+      target: 'tagdiv2'
+    } )     
     .volume(0)
     .play();
   
   
   interval = setInterval( function() {
     if( popped.currentTime() > 0 && popped.currentTime() <= 5 ) {
-      equals ( tagdiv.childElementCount, 1, "tagdiv now contains one child elements" );
+      equals ( tagdiv.childElementCount, 2, "tagdiv now contains two child elements" );
       plus();
       equals ( tagdiv.textContent.trim() , "Anna Sob" ,"tagdiv shows the first tag" );
       plus();
@@ -52,25 +68,23 @@ test("Popcorn tagthisperson Plugin", function () {
   }, 2000);
   
   interval2 = setInterval( function() {
-    if( popped.currentTime() > 3 && popped.currentTime() < 5  ) {
-      equals ( tagdiv.textContent.trim() , "Anna Sob, Scott", "tagdiv shows the first & second tag" );
+    if( popped.currentTime() > 5  ) {
+      equals ( tagdiv.innerHTML.search( "<a href" ) , 1 ,"second tag in tagdiv has a url" );
+      plus();
+      equals ( tagdiv2.textContent.trim(), "Mike, Daniel" ,"tagdiv2 shows the first & second tag" );
       plus();
       clearInterval( interval2 );
     }
-  }, 2000);
+  }, 4000);
   
   interval3 = setInterval( function() {
-    if( popped.currentTime() > 5 ) {
-      equals ( tagdiv.innerHTML.trim() , "Scott" ,"tagdiv shows the second tag only" );
-      plus();
-      clearInterval( interval3 );
-    }
-  }, 5000);
-  interval4 = setInterval( function() {
-    if( popped.currentTime() > 10 ) {
+    if( popped.currentTime() > 12 ) {
       equals ( tagdiv.innerHTML , "" ,"tagdiv is now cleared" );
       plus();
-      clearInterval( interval4 );
+      equals ( tagdiv2.innerHTML , "" ,"tagdiv2 is now cleared" );
+      plus();
+      clearInterval( interval3 );
     }
   }, 4000);
+
 });