]> khamidou — GitHub mirrors - popcorn-js.git/commitdiff
fixed footnote div webpage was fine [#237 state:peer-review-requested]
authorAnna Sobiepanek <annaopensource@gmail.com>
Thu, 23 Dec 2010 21:31:57 +0000 (16:31 -0500)
committerAnna Sobiepanek <annaopensource@gmail.com>
Thu, 23 Dec 2010 21:31:57 +0000 (16:31 -0500)
plugins/footnote/popcorn.footnote.js
plugins/footnote/popcorn.footnote.unit.js

index f1d799cd515032322922f5f8d9c3995b0a1793cf..960ba7d8c2ee48972ffd40b0cb0400a3dadc8a0f 100644 (file)
@@ -1,4 +1,4 @@
-// PLUGIN: WEBPAGE
+// PLUGIN: Footnote
 
 (function (Popcorn) {
   
@@ -12,8 +12,6 @@
    * Target is the id of the document element that the text needs to be 
    * attached to, this target element must exist on the DOM
    * 
-   * Note: anything in the target element will be overwritten by the text 
-   * specified by the user
    * @param {Object} options
    * 
    * Example:
         } )
    *
    */
-  Popcorn.plugin( "footnote" , (function(){
-      
-    var temp;
+  Popcorn.plugin( "footnote" , {
     
-    return {
-      manifest: {
-        about:{
-          name: "Popcorn Footnote Plugin",
-          version: "0.1",
-          author: "@annasob",
-          website: "annasob.wordpress.com"
-        },
-        options:{
-          start    : {elem:'input', type:'text', label:'In'},
-          end      : {elem:'input', type:'text', label:'Out'},
-          target   : 'map-container',
-          text     : {elem:'input', type:'text', label:'Text'}
-        }
+    manifest: {
+      about:{
+        name: "Popcorn Footnote Plugin",
+        version: "0.1",
+        author: "@annasob",
+        website: "annasob.wordpress.com"
       },
-      /**
-       * @member footnote 
-       * The start function will be executed when the currentTime 
-       * of the video  reaches the start time provided by the 
-       * options variable
-       */
-      start: function(event, options){
-        temp  = document.getElementById( options.target );
-        temp.innerHTML  = options.text;
-      },
-      /**
-       * @member footnote 
-       * The end function will be executed when the currentTime 
-       * of the video  reaches the end time provided by the 
-       * options variable
-       */
-      end: function(event, options){
-        temp.innerHTML  = "";
+      options:{
+        start    : {elem:'input', type:'text', label:'In'},
+        end      : {elem:'input', type:'text', label:'Out'},
+        target   : 'footnote-container',
+        text     : {elem:'input', type:'text', label:'Text'}
       }
-      
-    };
-    
-  })());
+    },
+    _setup: function(options) {
+      options._container = document.createElement( 'div' );
+      options._container.style.display = "none";
+      options._container.innerHTML  = options.text;
+      options.target =  document.getElementById( options.target );
+      options.target.appendChild( options._container );
+    },
+    /**
+     * @member footnote 
+     * The start function will be executed when the currentTime 
+     * of the video  reaches the start time provided by the 
+     * options variable
+     */
+    start: function(event, options){
+      options._container.style.display = "inline";
+    },
+    /**
+     * @member footnote 
+     * The end function will be executed when the currentTime 
+     * of the video  reaches the end time provided by the 
+     * options variable
+     */
+    end: function(event, options){
+      options._container.style.display = "none";
+    }
+   
+  });
 
 })( Popcorn );
\ No newline at end of file
index c685888e1ff5675e75ac63cf2874f79a27352c38..6c44e002b40cacb263234c42f27843a8261d367a 100644 (file)
@@ -1,7 +1,7 @@
 test("Popcorn Footnote Plugin", function () {
   
   var popped = Popcorn("#video"),
-      expects = 5, 
+      expects = 7, 
       count = 0,
       interval,
       interval2,
@@ -21,46 +21,51 @@ test("Popcorn Footnote Plugin", function () {
   ok ('footnote' in popped, "footnote is a mehtod of the popped instance");
   plus();
   
-  equals ( footnotediv.innerHTML, "", "initially, there is nothing inside the footnotediv" );
+  equals ( footnotediv.childElementCount, 0, "initially, there is nothing inside the footnotediv" );
   plus();
   
   popped.footnote({
-      start: 5, // seconds
-      end: 15, // seconds
+      start: 0, // seconds
+      end: 5, // seconds
       text: 'This video made exclusively for drumbeat.org',
       target: 'footnotediv'
     } )
     .footnote({
-      start: 35, // seconds
-      end: 45, // seconds
+      start: 7, // seconds
+      end: 14, // seconds
       text: 'Visit webmademovies.org for more details',
       target: 'footnotediv'
     } )
+    .volume(0)
     .play();
   
   
   interval = setInterval( function() {
-    if( popped.currentTime() > 5 && popped.currentTime() <= 15 ) {
-      equals (footnotediv.innerHTML , "This video made exclusively for drumbeat.org", "footnote displaing correct information" );
+    if( popped.currentTime() > 0 && popped.currentTime() <= 5 ) {
+      equals ( footnotediv.childElementCount, 2, "footnotediv now has two inner elements" );
+      plus();
+      equals (footnotediv.children[0].innerHTML , "This video made exclusively for drumbeat.org", "footnote displaing correct information" );
+      plus();
+      equals (footnotediv.children[0].style.display , "inline", "footnote is visible on the page" );
       plus();
       clearInterval( interval );
     }
-  }, 5000);
+  }, 2000);
   
   interval2 = setInterval( function() {
-    if( popped.currentTime() > 15 && popped.currentTime() < 35  ) {
-      equals (footnotediv.innerHTML , "", "footnote cleared properly" );
+    if( popped.currentTime() > 7 && popped.currentTime() < 14  ) {
+      equals (footnotediv.children[1].style.display , "inline", "second footnote is visible on the page" );
       plus();
       clearInterval( interval2 );
     }
-  }, 5000);
+  }, 3000);
   
   interval3 = setInterval( function() {
-    if( popped.currentTime() > 35 && popped.currentTime() < 45 ) {
-      equals (footnotediv.innerHTML ,"Visit webmademovies.org for more details", "footnote displaing correct information" );
+    if( popped.currentTime() > 14) {
+      ok (footnotediv.children[1].style.display === 'none' &&  footnotediv.children[0].style.display === 'none', "footnote are no longer vidible on the page" );
       plus();
       clearInterval( interval3 );
     }
-  }, 5000);
+  }, 15000);
   
 });