]> khamidou — GitHub mirrors - popcorn-js.git/commitdiff
[#t484] teardown functions for plugins that need it + tests
authorScottDowne <sdowne@learn.senecac.on.ca>
Fri, 13 May 2011 20:01:03 +0000 (16:01 -0400)
committerScottDowne <sdowne@learn.senecac.on.ca>
Fri, 13 May 2011 20:01:03 +0000 (16:01 -0400)
25 files changed:
plugins/attribution/popcorn.attribution.js
plugins/attribution/popcorn.attribution.unit.js
plugins/flickr/popcorn.flickr.js
plugins/flickr/popcorn.flickr.unit.js
plugins/footnote/popcorn.footnote.js
plugins/footnote/popcorn.footnote.unit.js
plugins/googlefeed/popcorn.googlefeed.js
plugins/googlefeed/popcorn.googlefeed.unit.js
plugins/googlemap/popcorn.googlemap.unit.js
plugins/googlenews/popcorn.googlenews.js
plugins/googlenews/popcorn.googlenews.unit.js
plugins/image/popcorn.image.js
plugins/image/popcorn.image.unit.js
plugins/lastfm/popcorn.lastfm.js
plugins/lastfm/popcorn.lastfm.unit.js
plugins/mustache/popcorn.mustache.js
plugins/openmap/popcorn.openmap.js
plugins/openmap/popcorn.openmap.unit.js
plugins/tagthisperson/popcorn.tagthisperson.js
plugins/twitter/popcorn.twitter.js
plugins/twitter/popcorn.twitter.unit.js
plugins/webpage/popcorn.webpage.js
plugins/webpage/popcorn.webpage.unit.js
plugins/wikipedia/popcorn.wikipedia.js
plugins/wikipedia/popcorn.wikipedia.unit.js

index 96bd15efaf7801a5f686e8d03b7a94f0e84209ef..733122889968f89775eaa1e45ed7e10121264ae7 100644 (file)
        */
       end: function(event, options){
         options._container.style.display = "none";
+      },
+      _teardown: function( options ) {
+        document.getElementById( options.target ).removeChild( options._container );
       }
     };
   })());
index 2dc49a86a68ca79ea357afa58a854e9a4072f2cb..bb5bb16623ce962648f87a7f3d0a9dae4b30b31a 100644 (file)
@@ -1,8 +1,9 @@
 test("Popcorn attribution Plugin", function () {
   
   var popped = Popcorn("#video"),
-      expects = 7, 
+      expects = 8, 
       count = 0,
+      setupId,
       attributiondiv = document.getElementById('attribdiv');
 
   expect(expects);
@@ -24,7 +25,7 @@ test("Popcorn attribution Plugin", function () {
   
   popped.attribution({
       start: 0, // seconds
-      end: 5, // seconds
+      end: 0.5, // seconds
       nameofwork: "A Shared Culture",
       copyrightholder:"Jesse Dylan",
       license: "CC-BY-N6",
@@ -32,8 +33,8 @@ test("Popcorn attribution Plugin", function () {
       target: 'attribdiv'
     } )
     .attribution({
-      start: 3, // seconds
-      end: 10, // seconds
+      start: 0.5, // seconds
+      end: 1, // seconds
       nameofwork: "Internet",
       nameofworkurl:"http://www.archive.org/details/CC1232_internet",
       copyrightholder:"The Computer Chronicles",
@@ -43,22 +44,28 @@ test("Popcorn attribution Plugin", function () {
     } )
     .volume(0);
 
-  popped.exec( 1, function() {
+  setupId = popped.getLastTrackEventId();
+
+  popped.exec( 0, function() {
     equals ( attributiondiv.childElementCount, 2, "attributiondiv now has two inner elements" );
     plus();
     equals (attributiondiv.children[0].style.display , "inline", "attribution is visible on the page" );
     plus();
   });
   
-  popped.exec( 4, function() {
+  popped.exec( 0.5, function() {
     equals (attributiondiv.children[1].style.display , "inline", "second attribution is visible on the page" );
     plus();
   });
   
-  popped.exec( 11, function() {
-    equals (attributiondiv.children[1].style.display , "none", "second attribution is no longer visible on the page" );
+  popped.exec( 1, function() {
+    equals(attributiondiv.children[1].style.display , "none", "second attribution is no longer visible on the page" );
     plus();
-    equals (attributiondiv.children[0].style.display , "none", "first attribution is no longer visible on the page" );
+    equals(attributiondiv.children[0].style.display , "none", "first attribution is no longer visible on the page" );
+    plus();
+
+    popped.pause().removeTrackEvent( setupId );
+    ok( !attributiondiv.children[1], "removed attribution was properly destroyed"  );
     plus();
   });
   
index 6fba54886b9074fa26ed18eb7556fc7dac0fb522..37977bd8049270cdb99280fff01e1aaa1f396898 100644 (file)
        */
       end: function( event, options ){      
           containerDiv.style.display = "none";       
+      },
+      _teardown: function( options ) {
+        document.getElementById( options.target ).removeChild( containerDiv );
       }
     };
   },
index 74e6758306016efacdfd060634b9058bb08b98eb..d510f207987ff1db699437d69082c5781a630a74 100644 (file)
@@ -1,8 +1,9 @@
 test("Popcorn Flickr Plugin", function () {
   
   var popped = Popcorn("#video"),
-      expects = 7, 
+      expects = 8, 
       count = 0,
+      setupId,
       flickrdiv = document.getElementById('flickrdiv');
   
   expect( expects );
@@ -22,40 +23,45 @@ test("Popcorn Flickr Plugin", function () {
   plus();
   
   popped.flickr({
-    start: 1, // seconds
-    end: 3,   // seconds
+    start: 0, // seconds
+    end: 1,   // seconds
     userid: '35034346917@N01',
     numberofimages: '1',
     target: 'flickrdiv'
   } )
   .flickr({
-    start: 4, // seconds
-    end: 7,   // seconds
+    start: 1, // seconds
+    end: 2,   // seconds
     username: 'AniaSob',
     apikey: 'd1d249260dd1673ec8810c8ce5150ae1',
     numberofimages: '1',
     target: 'flickrdiv'
-  } );;
+  });
 
-  popped.exec( 2, function() {
+  setupId = popped.getLastTrackEventId();
+
+  popped.exec( 0.5, function() {
     ok( /display: inline;/.test( flickrdiv.innerHTML ), "Div contents are displayed" );
     plus();
     ok( /img/.test( flickrdiv.innerHTML ), "An image exists" );
     plus();
   });
   
-  popped.exec( 5, function() {
+  popped.exec( 1.5, function() {
     ok( /display: inline;/.test( flickrdiv.innerHTML ), "Div contents are displayed" );
     plus();
     ok( /img/.test( flickrdiv.innerHTML ), "An image exists" );
     plus();
   });
 
-  popped.exec( 7, function() {
+  popped.exec( 2, function() {
     ok( /display: none;/.test( flickrdiv.innerHTML ), "Div contents are hidden again" );
     plus();
+
+    popped.pause().removeTrackEvent( setupId );
+    ok( !flickrdiv.children[1], "removed flickr was properly destroyed"  );
+    plus();
   });
-  popped.volume(0);
-  popped.play();
+  popped.volume(0).play();
   
 });
index 1f52dec252b6089a6e999df9ba12d6f0663cb63f..981d94aabdbf2192940c0243823df6db63e73cbf 100644 (file)
      */
     end: function(event, options){
       options._container.style.display = "none";
+    },
+    _teardown: function( options ) {
+      document.getElementById( options.target ).removeChild( options._container );
     }
-   
   });
 
-})( Popcorn );
\ No newline at end of file
+})( Popcorn );
index 7693bec0e95406893bc7cc55a7b69a6caa8fd6a7..22df71cfde20bdfdd617b8aeded7fa9a6a978231 100644 (file)
@@ -1,8 +1,9 @@
 test("Popcorn Footnote Plugin", function () {
   
   var popped = Popcorn("#video"),
-      expects = 7, 
+      expects = 8, 
       count = 0,
+      setupId,
       footnotediv = document.getElementById('footnotediv');
   
   expect(expects);
@@ -23,19 +24,20 @@ test("Popcorn Footnote Plugin", function () {
   
   popped.footnote({
     start: 0, // seconds
-    end: 2, // seconds
+    end: 1, // seconds
     text: 'This video made exclusively for drumbeat.org',
     target: 'footnotediv'
-  } )
+  })
   .footnote({
-    start: 2, // seconds
-    end: 4, // seconds
+    start: 1, // seconds
+    end: 2, // seconds
     text: 'Visit webmademovies.org for more details',
     target: 'footnotediv'
-  } )
-  .volume(0);
+  });
 
-  popped.exec( 1, function() {
+  setupId = popped.getLastTrackEventId();
+
+  popped.exec( 0, function() {
     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" );
@@ -44,15 +46,19 @@ test("Popcorn Footnote Plugin", function () {
     plus();
   });
 
-  popped.exec( 3, function() {
+  popped.exec( 1, function() {
     equals (footnotediv.children[1].style.display , "inline", "second footnote is visible on the page" );
     plus();
   });
 
-  popped.exec( 5, function() {
+  popped.exec( 2, function() {
     ok (footnotediv.children[1].style.display === 'none' &&  footnotediv.children[0].style.display === 'none', "footnote are no longer vidible on the page" );
     plus();
+
+    popped.pause().removeTrackEvent( setupId );
+    ok( !footnotediv.children[1], "removed footnote was properly destroyed"  );
+    plus();
   });
-  popped.play();
+  popped.play().volume(0);
   
 });
index acc919f93a4930f14cd8ad05f9fc955695583419..4d24794dcd492c0574ab62256ed56a0455cdf795 100644 (file)
        */
       end: function(event, options){
         newdiv.setAttribute( "style", "display:none" );
+      },
+      _teardown: function( options ) {
+        document.getElementById( options.target ).removeChild( newdiv );
       }
     };
   },
index 83369b5b8c172d0e7769c11ab608f42fd9787f71..b2778c247bf3f886008c1cdd2b21bae3ebb0f8e6 100644 (file)
@@ -1,7 +1,8 @@
 test("Popcorn Google Feed Plugin", function () {
   
   var popped = Popcorn("#video"),
-      expects = 10, 
+      expects = 11,
+      setupId, 
       count = 0;
   
   expect(expects);
@@ -22,43 +23,49 @@ test("Popcorn Google Feed Plugin", function () {
     plus();
   
   popped.googlefeed({
-        start: 0, // seconds
-        end: 5, // seconds
-        target: "feed",
-        url: "http://zenit.senecac.on.ca/~chris.tyler/planet/rss20.xml",
-        title: "Planet Feed",
-        orientation: "Vertical"
-         } )
-         .googlefeed({
-        start: 0, // seconds
-        end: 5, // seconds
-        target: "feed1",
-        url: "http://blog.pikimal.com/geek/feed/",
-        title: "pikiGeek",
-        orientation: "Horizontal"
-      } )
-    .volume(0);
+    start: 0, // seconds
+    end: 1, // seconds
+    target: "feed",
+    url: "http://zenit.senecac.on.ca/~chris.tyler/planet/rss20.xml",
+    title: "Planet Feed",
+    orientation: "Vertical"
+       })
+       .googlefeed({
+    start: 0, // seconds
+    end: 2, // seconds
+    target: "feed1",
+    url: "http://blog.pikimal.com/geek/feed/",
+    title: "pikiGeek",
+    orientation: "Horizontal"
+  })
+  .volume(0);
+
+  setupId = popped.getLastTrackEventId();
   
+  popped.exec( 0, function() {
+    ok(google.load, "Google Feed is available");
+    plus();
+    ok(GFdynamicFeedControl, "Dynamic Feed Control Available");
+    plus();
+    ok (document.getElementById('_feed1'), "First feed is on the page" );
+    plus();
+    equals (document.getElementById('_feed1').offsetParent.id, "feed", "First feed is inside the 'feed' div" );
+    plus();
+  });
   popped.exec( 1, function() {
-      ok(google.load, "Google Feed is available");
-      plus();
-      ok(GFdynamicFeedControl, "Dynamic Feed Control Available");
-      plus();
-      ok (document.getElementById('_feed1'), "First feed is on the page" );
-      plus();
-      equals (document.getElementById('_feed1').offsetParent.id, "feed", "First feed is inside the 'feed' div" );
-      plus();
+    ok (document.getElementById('_feed2'), "Second feed is on the page" );
+    plus();
+    equals (document.getElementById('_feed2').offsetParent.id, "feed1", "Second feed is inside the 'feed2' div" );
+    plus();
   });
   popped.exec( 2, function() {
-      ok (document.getElementById('_feed2'), "Second feed is on the page" );
-      plus();
-      equals (document.getElementById('_feed2').offsetParent.id, "feed1", "Second feed is inside the 'feed2' div" );
-      plus();
-  });
-  popped.exec( 6, function() {
-      ok (document.getElementById('_feed2').style.display === "none" && 
-          document.getElementById('_feed1').style.display === "none", "Both feeds are no lnger visible" );
-                 plus();
+    ok (document.getElementById('_feed2').style.display === "none" && 
+        document.getElementById('_feed1').style.display === "none", "Both feeds are no lnger visible" );
+         plus();
+
+    popped.pause().removeTrackEvent( setupId );
+    ok( !document.getElementById('feed1').children[0], "removed footnote was properly destroyed"  );
+    plus();
   });
   
   popped.play();
index 778a59d285abdf7a93a2ae3c42e47561e4e9fe30..515bce63a4b23bd719a2d0c01cfa56449441bfce 100644 (file)
@@ -76,9 +76,7 @@ test("Popcorn Google Map Plugin", function () {
     ok (document.getElementById('actualmap2').style.display === "none" && 
         document.getElementById('actualmap1').style.display === "none", "Both maps are no longer visible" );
     plus();
-    popped.pause();
-
-    popped.removeTrackEvent( setupId );
+    popped.pause().removeTrackEvent( setupId );
 
     ok( !document.getElementById('actualmap3'), "removed map was properly destroyed"  );
     plus();
index d381795a5bddfb16fbebccc35d117aa6f4e17787..e12e0bf0b4b71c35782d42141e12e0d4b42a2434 100644 (file)
         }
 
         options.container = document.createElement( 'div' );
+        var container = document.createElement( 'div' );
         if ( document.getElementById( options.target ) ) {
           document.getElementById( options.target ).appendChild( options.container );
+          options.container.appendChild( container );
         }
 
         var readyCheck = setInterval(function() {
           if ( !scriptLoaded ) {
             return;
           }
-          clearInterval(readyCheck);
+          clearInterval( readyCheck );
 
-          var newsShow = new google.elements.NewsShow( options.container, {
+          options.newsShow = new google.elements.NewsShow( container, {
             format : "300x250",
             queryList : [
               { q: options.topic || "Top Stories" }
        */
       end: function( event, options ){
         options.container.setAttribute( 'style', 'display:none' );
+      },
+      _teardown: function( options ) {
+        // google news does not like this, throws an error "a is null"
+        // doesn't hurt popcorn, and only happens once
+        document.getElementById( options.target ).removeChild( options.container );
+        options.newsShow = null;
       }
-
   });
 
 })( Popcorn );
index 7cdfee81df25dbd3832240c0a1031d38c2a0e350..b067de09298e37e17f0fb4401ada93cc20576901 100644 (file)
@@ -1,8 +1,9 @@
 test( "Popcorn google news Plugin", function () {
   
   var popped = Popcorn( "#video" ),
-      expects = 7, 
+      expects = 8, 
       count = 0,
+      setupId,
       googlenewsdiv = document.getElementById( "googlenewsdiv" );
 
   expect(expects);
@@ -23,37 +24,43 @@ test( "Popcorn google news Plugin", function () {
   
   popped.googlenews({
     start: 0, // seconds
-    end: 5, // seconds
+    end: 1, // seconds
     topic: "Oil Spill",
     target: "googlenewsdiv"
   })
   .googlenews({
-    start: 3, // seconds
-    end: 10, // seconds
+    start: 1, // seconds
+    end: 2, // seconds
     topic: "Village Telco",
     target: "googlenewsdiv"
   })
   .volume( 0 );
+
+  setupId = popped.getLastTrackEventId();
     
-  popped.exec( 1, function() {
+  popped.exec( 0, function() {
     equals( googlenewsdiv.childElementCount, 2, "googlenewsdiv now has two inner elements" );
     plus();
     equals( googlenewsdiv.children[0].style.display , "inline", "first googlenews is visible on the page" );
     plus();
   });
   
-  popped.exec( 4, function() {
+  popped.exec( 1, function() {
     equals( googlenewsdiv.children[1].style.display , "inline", "second googlenews is visible on the page" );
     plus();
   });
   
-  popped.exec( 11, function() {
+  popped.exec( 2, function() {
     equals( googlenewsdiv.children[1].style.display , "none", "second googlenews is no longer visible on the page" );
     plus();
     equals( googlenewsdiv.children[0].style.display , "none", "first googlenews is no longer visible on the page" );
     plus();
+
+    popped.pause().removeTrackEvent( setupId );
+    ok( !googlenewsdiv.children[1], "removed google news was properly destroyed" );
+    plus();
   });
   
   popped.play();
 
-});
\ No newline at end of file
+});
index d83b658cb76bcc810e3d07a37f8f01072cac655b..2b77387a09c67dcc12c689bc7396aabc42667fe0 100644 (file)
        */
       end: function( event, options ) {
         options.link.style.display = "none";
+      },
+      _teardown: function( options ) {
+        document.getElementById( options.target ).removeChild( options.link );
       }
-          
   });
 
 })( Popcorn );
index f9102a48147fd76cdcfa53a0cfa9f38690b056a7..29b82a12331e46a29a855c188e57a1cfb148a6c7 100644 (file)
@@ -1,8 +1,9 @@
 test("Popcorn Image Plugin", function () {
   
   var popped = Popcorn("#video"),
-      expects = 5,
+      expects = 6,
       count = 0,
+      setupId,
       imagediv = document.getElementById('imagediv');
   
   expect( expects );
@@ -30,16 +31,22 @@ test("Popcorn Image Plugin", function () {
     target: 'imagediv'
   });
 
+  setupId = popped.getLastTrackEventId();
+
   popped.exec( 2, function() {
-      ok( /display: block;/.test( imagediv.innerHTML ), "Div contents are displayed" );
-      plus();
-      ok( /img/.test( imagediv.innerHTML ), "An image exists" );
-      plus();
+    ok( /display: block;/.test( imagediv.innerHTML ), "Div contents are displayed" );
+    plus();
+    ok( /img/.test( imagediv.innerHTML ), "An image exists" );
+    plus();
   });
   
   popped.exec( 4, function() {
-      ok( /display: none;/.test( imagediv.innerHTML ), "Div contents are hidden again" );
-      plus();
+    ok( /display: none;/.test( imagediv.innerHTML ), "Div contents are hidden again" );
+    plus();
+
+    popped.pause().removeTrackEvent( setupId );
+    ok( !imagediv.children[0], "removed image was properly destroyed" );
+    plus();
   });
   popped.volume(0).play();  
   
index d0b3babf3d21f8e0aeb7b6c9c9366171ecd5a6c5..b17b60392ad61591b45efe20d338284eef1edea6 100644 (file)
@@ -2,10 +2,12 @@
 
 (function (Popcorn) {
 
-  var _artists = [],
+  var _artists = {},
       lastFMcallback = function(data){
         if (data.artist) {
-          var htmlString = '<h3>'+data.artist.name+'</h3>';
+          var htmlString = "";
+
+          htmlString = '<h3>'+data.artist.name+'</h3>';
           htmlString += '<a href="'+data.artist.url+'" target="_blank" style="float:left;margin:0 10px 0 0;"><img src="'+ data.artist.image[2]['#text'] +'" alt=""></a>';
           htmlString += '<p>'+ data.artist.bio.summary +'</p>';
           htmlString += '<hr /><p><h4>Tags</h4><ul>';
@@ -23,7 +25,7 @@
 
           htmlString += '</ul></p>';
 
-          _artists[data.artist.name.toLowerCase()] = htmlString;
+          _artists[data.artist.name.toLowerCase()].htmlString = htmlString;
         }
       };
 
         
         if(!_artists[options.artist]) {
 
-          _artists[options.artist] = "Unknown Artist";
+          _artists[options.artist] = {
+            count: 0,
+            htmlString: "Unknown Artist"
+          };
           Popcorn.getJSONP("http://ws.audioscrobbler.com/2.0/?method=artist.getinfo&artist="+ options.artist +"&api_key="+options.apikey+"&format=json&callback=lastFMcallback", lastFMcallback, false );
-          
         }
+        _artists[options.artist].count++;
         
       },
       /**
        * options variable
        */
       start: function( event, options ) {
-        options._container.innerHTML = _artists[options.artist];
+        options._container.innerHTML = _artists[options.artist].htmlString;
         options._container.style.display = "inline";
       },
       /**
       end: function( event, options ) {
         options._container.style.display = "none";
         options._container.innerHTML = "";
+      },
+      _teardown: function( options ) {
+        // cleaning possible reference to _artist array;
+        --_artists[ options.artist ].count || delete _artists[ options.artist ];
+        document.getElementById( options.target ).removeChild( options._container );
       }
     };
   })());
index c66b009d169442f851897852ca7fb18abcccc9a3..f02c13ae441ecee27652c93d8652710c511d0023 100644 (file)
@@ -6,8 +6,9 @@ test("Popcorn LastFM Plugin", function () {
     plugin. Please do not use it for other purposes.
   */
   var popped = Popcorn("#video"),
-      expects = 8, 
+      expects = 9, 
       count = 0,
+      setupId,
       lastfmdiv = document.getElementById('lastfmdiv');
   
   expect( expects );
@@ -48,6 +49,8 @@ test("Popcorn LastFM Plugin", function () {
     apikey: '30ac38340e8be75f9268727cb4526b3d'
   });
 
+  setupId = popped.getLastTrackEventId();
+
   popped.exec( 2, function() {
     equals ( lastfmdiv.childElementCount, 3, "lastfmdiv now has three inner elements" );
     plus();
@@ -67,6 +70,10 @@ test("Popcorn LastFM Plugin", function () {
   popped.exec( 5, function() {
     equals (lastfmdiv.children[2].innerHTML , "Unknown Artist", "Artist information could not be found" );
     plus();
+
+    popped.pause().removeTrackEvent( setupId );
+    ok( !lastfmdiv.children[2], "removed artist was properly destroyed" );
+    plus();
   });
   
   popped.volume(0).play();
index 3ae5cf52807752c15827542c27f0e2241fec6c61..86f318fdae2cc99fcbe555f389fc369d7ec017de 100644 (file)
 
       end: function( event, options ) {
         document.getElementById( options.target ).innerHTML = '';
+      },
+      _teardown: function( options ) {
+        getData, data, getTemplate, template = null;
       }
     };
   },
index 988354ea4b9fc9acba017b823b634d54c67a1263..ad7262e428749d58b20bbf9797f55c7fb060d21f 100644 (file)
@@ -250,8 +250,12 @@ var openmapCallback;
         if ( map ) {
           map.div.style.display = 'none';          
         }
-      }
+      },
+      _teardown: function( options ) {
 
+        document.getElementById( options.target ).removeChild( newdiv );
+        newdiv = map = centerlonlat = projection = displayProjection = pointLayer = selectControl = popup = null;
+      }
     };
   },
   {
index 2be25a2916ef82f222b40cf6396ac8e7c59431cd..2f38431a9a9bfe9f2d89b8ff580f9849e01e347c 100644 (file)
@@ -1,12 +1,13 @@
 test("Popcorn OpenMap Plugin", function () {
   
   var popped = Popcorn("#video"),
-    expects = 12, 
-    count = 0,
-    mapInterval,
-    mapInterval2,
-    mapInterval3,
-    mapInterval4;
+      expects = 13, 
+      count = 0,
+      setupId,
+      mapInterval,
+      mapInterval2,
+      mapInterval3,
+      mapInterval4;
   
   expect(expects);
   
@@ -60,6 +61,8 @@ test("Popcorn OpenMap Plugin", function () {
   .volume(0)
   .play();
 
+  setupId = popped.getLastTrackEventId();
+
   mapInterval = popped.exec( 4, function() {
     if( popped.currentTime() > 3 && popped.currentTime() <= 5 ) {
       ok(OpenLayers, "OpenLayers is available");
@@ -96,6 +99,10 @@ test("Popcorn OpenMap Plugin", function () {
           document.getElementById('actualmap1').style.display === "none", "All three maps are no longer visible" );
       plus();
       clearInterval( mapInterval4 );
+
+      popped.pause().removeTrackEvent( setupId );
+      ok( !document.getElementById('actualmap3'), "removed map was properly destroyed"  );
+      plus();
     }
   } );
-} );
\ No newline at end of file
+} );
index 0ac95eb4e475bc57ce2b2e5554a8cbc5ecd4ce7a..029e50026a9d91239627c3a108ef21f5e129c457 100644 (file)
@@ -1,6 +1,22 @@
 // PLUGIN: tagthisperson
 
 (function (Popcorn) {
+    
+  var peopleArray = [];
+  // one People object per options.target
+  var People = function() {
+    this.name = "";
+    this.contains = { };
+    this.toString = function() {
+      var r = [];
+      for ( var j in this.contains ) {
+        if ( this.contains.hasOwnProperty( j ) ) {
+          r.push( " " + this.contains[ j ] );
+        }
+      }
+      return r.toString();
+    };
+  };
   
   /**
    * tagthisperson popcorn plug-in 
    */
   Popcorn.plugin( "tagthisperson" , ( function() {
     
-    var peopleArray = [];
-    // one People object per options.target
-    var People = function() {
-      this.name = "";
-      this.contains = { };
-      this.toString = function() {
-        var r = [];
-        for ( var j in this.contains ) {
-          if ( this.contains.hasOwnProperty( j ) ) {
-            r.push( " " + this.contains[ j ] );
-          }
-        }
-        return r.toString();
-      };
-    };
-    
     return {
       manifest: {
         about:{
index 5106b3b0ccf110a99dd2508db2b3cd453955e112..8cdfe5e0af8848b2a227701ae506e6fbb8c6c4cb 100644 (file)
        */
       end: function( event, options ) {
         options.container.style.display = "none";
+      },
+      _teardown: function( options ) {
+
+        document.getElementById( options.target ).removeChild( options.container );
       }
     });
 
index 3b6a026c6158d730fd4144f370cf43fe3df71fc0..9ec9d7b802e4b3e4e661ffb40ea1fb6526e589a2 100644 (file)
@@ -1,8 +1,9 @@
 test("Popcorn Twitter Plugin", function () {
   
   var popped = Popcorn("#video"),
-      expects = 6, 
+      expects = 7, 
       count = 0,
+      setupId,
       twitterdiv = document.getElementById('twitterdiv');
   
   expect( expects );
@@ -34,7 +35,9 @@ test("Popcorn Twitter Plugin", function () {
     title: 'Steve Song',
     src: '@stevesong',
     target: 'twitterdiv',
-  } );
+  });
+
+  setupId = popped.getLastTrackEventId();
 
   popped.exec( 1, function() {
     ok( /display: inline;/.test( twitterdiv.innerHTML ), "Div contents are displayed" );
@@ -46,6 +49,10 @@ test("Popcorn Twitter Plugin", function () {
   popped.exec( 2, function() {
     ok( /display: none;/.test( twitterdiv.innerHTML ), "Div contents are hidden again" );
     plus();
+
+    popped.pause().removeTrackEvent( setupId );
+    ok( !twitterdiv.children[0], "removed twitter was properly destroyed" );
+    plus();
   });
   
   popped.play();
index d37e57fd8092cf7de08ec26f076aeef00f9502bf..ecfabda9e5f7592542facf8e15a2ebe7701c95bc 100644 (file)
     end: function(event, options){
       // make the iframe invisible
       options._iframe.style.display = 'none';
+    },
+    _teardown: function( options ) {
+
+      document.getElementById( options.target ).removeChild( options._iframe );
     }
-    
   });
 })( Popcorn );
index 91b46501499f2333832a798949ebe12c9899b48b..beaf6f29238b4f001f429d86a1654cbb45495805 100644 (file)
@@ -1,8 +1,9 @@
 test("Popcorn Webpage Plugin", function () {
   
   var popped = Popcorn("#video"),
-      expects = 10, 
+      expects = 11, 
       count = 0,
+      setupId,
       theiFrame = document.getElementsByTagName('iframe');
 
   expect(expects);
@@ -37,6 +38,8 @@ test("Popcorn Webpage Plugin", function () {
   })
   .volume(0);
 
+  setupId = popped.getLastTrackEventId();
+
   popped.exec( 0, function() {
     ok (!!theiFrame[0], "iframe was created" );
     plus();
@@ -48,11 +51,6 @@ test("Popcorn Webpage Plugin", function () {
     plus();
   });
 
-  popped.exec( 2, function() {
-    ok (theiFrame[0].style.display === 'none' && theiFrame[1].style.display === 'none', "both iframes are hidden" );
-    plus();
-  });
-
   popped.exec( 1, function() {
     ok (!!theiFrame[1], "iframe was created" );
     plus();
@@ -62,6 +60,15 @@ test("Popcorn Webpage Plugin", function () {
     plus();
   });
 
+  popped.exec( 2, function() {
+    ok (theiFrame[0].style.display === 'none' && theiFrame[1].style.display === 'none', "both iframes are hidden" );
+    plus();
+
+    popped.pause().removeTrackEvent( setupId );
+    ok( !theiFrame[1], "removed webpage was properly destroyed" );
+    plus();
+  });
+
   popped.play();
 
 });
index e0a50cf510de40880703e6324d694d2f378d24f1..726d368d7ecfb91e9f15d77c559bc342cc3c7963 100644 (file)
@@ -136,7 +136,6 @@ var wikiCallback;
         document.getElementById( options.target ).removeChild( options._desc );
       }
     }
-     
   });
 
 })( Popcorn );
index 03b64f931f48d86cc70bfa79b9ece0771172ec1d..487f11de29205163255979a3813cc3398a13c78d 100644 (file)
@@ -42,9 +42,9 @@ test("Popcorn wikipedia Plugin", function () {
     plus();
     equals (theArticle.childElementCount, 2, "wikidiv now contains two child elements" );
     plus();
-    equals (theArticle.childNodes[0].innerHTML, "this is an article", "wikidiv has the right title" );
+    equals (theArticle.children[0].innerHTML, "this is an article", "wikidiv has the right title" );
     plus();
-    ok (theArticle.childNodes[1].innerHTML !=="", "wikidiv has some content" );
+    ok (theArticle.children[1].innerHTML !=="", "wikidiv has some content" );
     plus();
   });
   
@@ -58,7 +58,7 @@ test("Popcorn wikipedia Plugin", function () {
     plus();
     equals (theArticle.childElementCount, 2, "wikidiv now contains two child elements" );
     plus();
-    ok (theArticle.childNodes[1].innerHTML !== "", "wikidiv has the right content" );
+    ok (theArticle.children[1].innerHTML !== "", "wikidiv has the right content" );
     plus();
   });
 });