if (map) {
map.getDiv().style.display = "none";
}
+ },
+ _cleanup: function( options ) {
+ // the map must be manually removed
+ document.getElementById( options.target ).removeChild( newdiv );
}
};
},
test("Popcorn Google Map Plugin", function () {
var popped = Popcorn("#video"),
- expects = 10,
+ expects = 11,
count = 0;
expect(expects);
lat: 43.665429,
lng: -79.403323,
zoom: 10
- } )
+ })
.googlemap({
start: 0, // seconds
end: 5, // seconds
target: 'map2',
location:'boston',
zoom: 15
- } )
+ })
.volume(0);
+ popped.googlemap({
+ start: 0, // seconds
+ end: 10, // seconds
+ type: 'SATELLITE',
+ target: 'map2',
+ location:'toronto',
+ zoom: 15
+ });
+
+var setupId = popped.getLastTrackEventId();
+
popped.exec( 4, function() {
ok(google.maps, "Google maps is available");
plus();
popped.exec( 6, function() {
ok (document.getElementById('actualmap2').style.display === "none" &&
- document.getElementById('actualmap1').style.display === "none", "Both maps are no lnger visible" );
+ document.getElementById('actualmap1').style.display === "none", "Both maps are no longer visible" );
+ plus();
+ popped.pause();
+
+ popped.removeTrackEvent( setupId );
+
+ ok( !document.getElementById('actualmap3'), "removed map was properly destroyed" );
plus();
});
// Capture the position of the track being removed.
if ( o._id === trackId ) {
indexWasAt = i;
+ o._natives._cleanup && o._natives._cleanup.call( obj, o );
}
}
});
p2 = Popcorn("#video"),
rlen = Popcorn.registry.length,
count = 0,
- expects = 19,
+ expects = 21,
interval;
function plus() {
clearInterval( interval );
}
}, 1);
+
+ Popcorn.plugin( "cleanup", {
+
+ _setup: function( options ) {
+
+ options.exist = true;
+ },
+ _cleanup: function( options ) {
+
+ ok( true, "cleanup function is called during removal" );
+ plus();
+
+ ok( options.exist, "options object exists at time of cleanup" );
+ plus();
+ }
+ });
+
+ p2.cleanup({
+ start: 2,
+ end: 3
+ });
+ p2.removeTrackEvent( p2.getLastTrackEventId() );
+
p2.currentTime( 2 ).play();
});