Popcorn.plugin( name , {
manifest: {
- about:{
+ about: {
name: "Popcorn " + name + " Plugin",
version: "0.2",
author: "@annasob, @rwaldron",
website: "annasob.wordpress.com"
},
- options:{
- start : {elem:'input', type:'text', label:'In'},
- end : {elem:'input', type:'text', label:'Out'},
- target : name + '-container',
- text : {elem:'input', type:'text', label:'Text'}
+ options: {
+ start: { elem: "input", type: "text", label: "In" },
+ end: { elem: "input", type: "text", label: "Out" },
+ text: { elem: "input", type: "text", label: "Text" },
+ target: name + "-container"
}
},
- _setup: function(options) {
- options._container = document.createElement( 'div' );
+ _setup: function( options ) {
+ options._container = document.createElement( "div" );
options._container.style.display = "none";
options._container.innerHTML = options.text;
* of the video reaches the start time provided by the
* options variable
*/
- start: function(event, options){
+ start: function( event, options ) {
options._container.style.display = "inline";
},
/**
* of the video reaches the end time provided by the
* options variable
*/
- end: function(event, options){
+ end: function( event, options ) {
options._container.style.display = "none";
},
_teardown: function( options ) {
<title>Popcorn API</title>
<link rel="stylesheet" href="../../test/qunit/qunit.css" type="text/css" media="screen">
<script src="../../test/qunit/qunit.js"></script>
- <!--
- do not move - this must be called immediately prior to
+ <!--
+ do not move - this must be called immediately prior to
popcorn-api-draft.js
-->
-
+
<script src="../../popcorn.js"></script>
<script src="popcorn.footnote.js"></script>
<h2 id="qunit-userAgent"></h2>
<ol id="qunit-tests"></ol>
<div id="qunit-fixture"> </div>
-
- <video id='video'
- controls preload='none'
+
+ <video id='video'
+ controls preload='none'
width= '250px'
- poster="../../test/poster.png">
+ poster="../../test/poster.png">
<source id='mp4'
src="../../test/trailer.mp4"
- type='video/mp4; codecs="avc1, mp4a"'>
+ type='video/mp4; codecs="avc1, mp4a"'>
<source id='ogv'
src="../../test/trailer.ogv"
- type='video/ogg; codecs="theora, vorbis"'>
+ type='video/ogg; codecs="theora, vorbis"'>
- <p>Your user agent does not support the HTML5 Video element.</p>
+ <p>Your user agent does not support the HTML5 Video element.</p>
- </video>
- <div id="footnotediv"></div>
+ </video>
+ <div id="footnotediv"></div>
+ <div id="textdiv"></div>
</body>
</html>
test("Popcorn Footnote Plugin", function () {
-
+
var popped = Popcorn("#video"),
- expects = 8,
+ expects = 8,
count = 0,
setupId,
- footnotediv = document.getElementById('footnotediv');
-
+ footnotediv = document.getElementById("footnotediv");
+
expect(expects);
-
+
function plus() {
if ( ++count===expects) {
start();
}
}
-
+
stop();
-
- ok ('footnote' in popped, "footnote is a mehtod of the popped instance");
+
+ ok ("footnote" in popped, "footnote is a mehtod of the popped instance");
plus();
-
+
equals ( footnotediv.childElementCount, 0, "initially, there is nothing inside the footnotediv" );
plus();
-
+
popped.footnote({
start: 0, // seconds
end: 2, // seconds
- text: 'This video made exclusively for drumbeat.org',
- target: 'footnotediv'
+ text: "This video made exclusively for drumbeat.org",
+ target: "footnotediv"
})
.footnote({
start: 2, // seconds
end: 4, // seconds
- text: 'Visit webmademovies.org for more details',
- target: 'footnotediv'
+ text: "Visit webmademovies.org for more details",
+ target: "footnotediv"
});
setupId = popped.getLastTrackEventId();
plus();
});
popped.play().volume(0);
-
+
+});
+
+
+test("Popcorn Text Plugin", function () {
+
+ var popped = Popcorn("#video"),
+ expects = 2,
+ count = 0,
+ setupId,
+ textdiv = document.getElementById( "textdiv" );
+
+ expect(expects);
+
+ function plus() {
+ if ( ++count===expects) {
+ start();
+ }
+ }
+
+ ok( "text" in popped, "text is a method of the popped instance" );
+ plus();
+
+ popped.text({
+ start: 0, // seconds
+ end: 3, // seconds
+ text: "I am an alias",
+ target: "textdiv"
+ });
+
+ stop();
+
+ popped.exec( 2, function() {
+
+ equal( textdiv.children[0].innerHTML , "I am an alias", "I am an alias set by Popcorn.p.text" );
+ plus();
+
+ }).currentTime(1).play();
});