-// PLUGIN: WEBPAGE
+// PLUGIN: Footnote
(function (Popcorn) {
* 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
test("Popcorn Footnote Plugin", function () {
var popped = Popcorn("#video"),
- expects = 5,
+ expects = 7,
count = 0,
interval,
interval2,
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);
});