]> khamidou — GitHub mirrors - popcorn-js.git/commitdiff
updated spacing and comment per review [#294]
authorAnna Sobiepanek <annaopensource@gmail.com>
Fri, 4 Feb 2011 18:31:06 +0000 (13:31 -0500)
committerAnna Sobiepanek <annaopensource@gmail.com>
Fri, 4 Feb 2011 18:31:06 +0000 (13:31 -0500)
plugins/tagthisperson/popcorn.tagthisperson.html
plugins/tagthisperson/popcorn.tagthisperson.js
plugins/tagthisperson/popcorn.tagthisperson.unit.js

index 94821a761287c44331c0af24b9c1a93b5465fcf7..f843588cbae912d863d9cbaf78c7b76fedca8256 100644 (file)
@@ -36,7 +36,7 @@
 <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 will appear at 0 seconds and disappear at 10 seconds. At 5 seconds Scott will be appended to this tag.</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>
   <div>
     <video id='video' 
       controls preload='none' 
index dcb78e954b0d8817c7ce6951a936ac2cfdb48e2e..aae6a32b860d4dcfe722613dc3a9c96c9f3f1659 100644 (file)
@@ -5,10 +5,11 @@
   /**
    * tagthisperson popcorn plug-in 
    * Adds people's names to an element on the page.
-   * Options parameter will need a start, end, target and person.
+   * Options parameter will need a start, end, target, image and person.
    * Start is the time that you want this plug-in to execute
    * 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
    * Target is the id of the document element that the text needs to be 
    * attached to, this target element must exist on the DOM
    * 
         } )
    *
    */
-  Popcorn.plugin( "tagthisperson" , (function(){
+  Popcorn.plugin( "tagthisperson" , ( function() {
     
     var peopleArray = [];
     // one People object per options.target
-    var People = function(){
+    var People = function() {
       this.name = "";
-      this.contains = {};
+      this.contains = { };
       this.toString = function() {
         var r = [];
         for ( var j in this.contains ) {
-          if ( this.contains.hasOwnProperty(j) ) {
-            r.push( " " + this.contains[j] );
+          if ( this.contains.hasOwnProperty( j ) ) {
+            r.push( " " + this.contains[ j ] );
           }
         }
         return r.toString();
@@ -62,7 +63,7 @@
         // 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++ ) {
-          if ( peopleArray[i].name === options.target ) {
+          if ( peopleArray[ i ].name === options.target ) {
             options._p = peopleArray[ i ];  
             exists = true;
             break;
@@ -87,7 +88,7 @@
           options._p.contains[ options.person ] = options.person;
         }
         //options._p.contains[options.person] = options.person;
-        if (document.getElementById( options.target )) {
+        if ( document.getElementById( options.target ) ) {
           document.getElementById( options.target ).innerHTML  = options._p.toString();
         }
       },
index 55895c9b7ef00f6d16200152b79f517310721f7e..abba1793fdd028a28f7a3d0b45f2466b0358b1fa 100644 (file)
@@ -1,24 +1,24 @@
 test("Popcorn tagthisperson Plugin", function () {
   
-  var popped = Popcorn("#video"),
+  var popped = Popcorn( "#video" ),
       expects = 7, 
       count = 0,
       interval,
       interval2,
       interval3,
-      tagdiv = document.getElementById('tagdiv');
+      tagdiv = document.getElementById( 'tagdiv' );
   
   expect(expects);
   
   function plus() {
-    if ( ++count===expects) {
+    if ( ++count===expects ) {
       start();
     }
   }
   
   stop();
    
-  ok ('tagthisperson' in popped, "tagthisperson is a method of the popped instance");
+  ok ( 'tagthisperson' in popped, "tagthisperson is a method of the popped instance" );
   plus();
   
   equals ( tagdiv.innerHTML, "", "initially, there is nothing inside the tagdiv" );
@@ -43,7 +43,7 @@ test("Popcorn tagthisperson Plugin", function () {
   
   interval = setInterval( function() {
     if( popped.currentTime() > 0 && popped.currentTime() <= 5 ) {
-      equals (tagdiv.childElementCount, 1, "tagdiv now contains one child elements" );
+      equals ( tagdiv.childElementCount, 1, "tagdiv now contains one child elements" );
       plus();
       equals ( tagdiv.textContent.trim() , "Anna Sob" ,"tagdiv shows the first tag" );
       plus();
@@ -60,14 +60,14 @@ test("Popcorn tagthisperson Plugin", function () {
   }, 2000);
   
   interval3 = setInterval( function() {
-    if( popped.currentTime() > 5) {
+    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() > 10 ) {
       equals ( tagdiv.innerHTML , "" ,"tagdiv is now cleared" );
       plus();
       clearInterval( interval4 );