From e01aea8b63f2f5165aab808aab42acc2a1ba1926 Mon Sep 17 00:00:00 2001 From: David Seifried Date: Wed, 14 Sep 2011 11:23:41 -0400 Subject: [PATCH] Added in alias for in/out and added tests to support it --- popcorn.js | 9 +++++++ test/popcorn.unit.js | 60 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+) diff --git a/popcorn.js b/popcorn.js index a177982..8c04fb2 100644 --- a/popcorn.js +++ b/popcorn.js @@ -1232,6 +1232,15 @@ // Ensure a manifest object, an empty object is a sufficient fallback options._natives.manifest = manifest; + + + if ( options[ "in" ] ) { + options.start = options[ "in" ]; + } + + if ( options[ "out" ] ) { + options.end = options[ "out" ]; + } // Checks for expected properties if ( !( "start" in options ) ) { diff --git a/test/popcorn.unit.js b/test/popcorn.unit.js index 89855e7..f3fd67a 100644 --- a/test/popcorn.unit.js +++ b/test/popcorn.unit.js @@ -2578,6 +2578,66 @@ test("Defaulting Empty End Values", function() { }); }); +test( "In/Out aliases", function() { + var popcorn = Popcorn( "#video" ), + expects = 3, + count = 0, + aliasDiv = document.createElement( "div" ); + + document.body.appendChild( aliasDiv ); + + expect( expects ); + stop( 5000 ); + + function plus() { + if ( ++count === expects ) { + Popcorn.removePlugin( "aliasTester" ); + document.body.removeChild( aliasDiv ); + start(); + } + } + + aliasDiv.id = "aliasDiv"; + + Popcorn.plugin( "aliasTester", function() { + + return { + start: function() { + var div = document.getElementById( "aliasDiv" ); + div.style.display = "inline"; + div.innerHTML = "Showing"; + }, + end: function() { + var div = document.getElementById( "aliasDiv" ); + div.innerHTML = ""; + div.style.display = "none"; + } + }; + }); + + popcorn.aliasTester({ + in: 1, + out: 3 + }); + + popcorn.currentTime( 0 ).pause(); + + equals( aliasDiv.innerHTML, "", "Container is initially empty" ); + plus(); + + popcorn.exec( 2, function() { + equals( aliasDiv.innerHTML, "Showing", "Container is displaying 'Showing', in alias is working" ); + plus(); + }); + + popcorn.exec( 4, function() { + equals( aliasDiv.innerHTML, "", "Container is displaying nothing again, out alias is working" ); + plus(); + }); + + popcorn.play(); +}); + module("Popcorn TrackEvents"); test("Functions", function() { -- 2.43.0