end: 10, // seconds
person: 'Anna Sob',
image: 'http://newshour.s3.amazonaws.com/photos%2Fspeeches%2Fguests%2FRichardNSmith_thumbnail.jpg',
+ href: 'http://annasob.wordpress.com',
target: 'tagdiv'
} )
.tagthisperson({
start: 5, // seconds
end: 15, // seconds
person: 'Scott',
+ href: 'http://scottdowne.wordpress.com/',
target: 'tagdiv'
} )
.tagthisperson({
start: 0, // seconds
end: 15, // seconds
- person: 'Scott',
+ person: 'Mike',
target: 'tagdiv2'
} )
}, false);
</head>
<body>
<h1 id="qunit-header">Popcorn tagthisperson Plug-in Demo</h1>
- <p> A tag displaying Scott will appear at 0 seconds and disappear at 15 seconds.</p>
- <p> A separate tag displaying Anna Sob with an image will appear at 0 seconds and disappear at 10 seconds. At 5 seconds Scott will be appended to this tag.</p>
+ <p> A tag displaying Mike will appear at 0 seconds and disappear at 15 seconds.</p>
+ <p> A separate tag displaying Anna Sob with an image and a URL attached will appear at 0 seconds and disappear at 10 seconds.</p>
+ <p> At 5 seconds Scott with a URL attached will be appended to this tag and disappear at 15 seconds.</p>
<div>
<video id='video'
controls preload='none'
* End is the time that you want this plug-in to stop executing
* Person is the name of the person who you want to tag
* Image is the url to the image of the person - optional
+ * href is the url to the webpage of the person - optional
* Target is the id of the document element that the text needs to be
* attached to, this target element must exist on the DOM
*
start: 5, // seconds
end: 15, // seconds
person: '@annasob',
+ image: 'http://newshour.s3.amazonaws.com/photos%2Fspeeches%2Fguests%2FRichardNSmith_thumbnail.jpg',
+ href: 'http://annasob.wordpress.com',
target: 'tagdiv'
} )
*
end : {elem:'input', type:'text', label:'Out'},
target : 'tag-container',
person : {elem:'input', type:'text', label:'Name'},
- image : {elem:'input', type:'text', label:'Image Src'}
+ image : {elem:'input', type:'text', label:'Image Src'},
+ href : {elem:'input', type:'text', label:'URL'}
}
},
_setup: function( options ) {
var exists = false;
// loop through the existing objects to ensure no duplicates
// the idea here is to have one object per unique options.target
- for ( var i = 0; i< peopleArray.length; i++ ) {
+ for ( var i = 0; i < peopleArray.length; i++ ) {
if ( peopleArray[ i ].name === options.target ) {
options._p = peopleArray[ i ];
exists = true;
* options variable
*/
start: function( event, options ){
- if ( options.image ) {
- options._p.contains[ options.person ] = " <img src='" + options.image + "'/> " + options.person;
- } else {
- options._p.contains[ options.person ] = options.person;
- }
- //options._p.contains[options.person] = options.person;
+ options._p.contains[ options.person ] = ( options.image ) ? "<img src='" + options.image + "'/> " : "" ;
+ options._p.contains[ options.person ] += ( options.href ) ? "<a href='" + options.href + "' target='_blank'> " + options.person + "</a>" : options.person ;
+
if ( document.getElementById( options.target ) ) {
- document.getElementById( options.target ).innerHTML = options._p.toString();
+ document.getElementById( options.target ).innerHTML = options._p.toString();
}
},
/**
* of the video reaches the end time provided by the
* options variable
*/
- end: function(event, options){
+ end: function( event, options ){
delete options._p.contains[ options.person ];
if ( document.getElementById( options.target ) ) {
- document.getElementById( options.target ).innerHTML = options._p.toString();
+ document.getElementById( options.target ).innerHTML = options._p.toString();
}
}
};
</video>
<div id="tagdiv"></div>
+ <div id="tagdiv2"></div>
</body>
</html>
test("Popcorn tagthisperson Plugin", function () {
var popped = Popcorn( "#video" ),
- expects = 7,
+ expects = 8,
count = 0,
interval,
interval2,
interval3,
+ interval4,
tagdiv = document.getElementById( 'tagdiv' );
+ tagdiv2 = document.getElementById( 'tagdiv2' );
expect(expects);
function plus() {
- if ( ++count===expects ) {
+ if ( ++count === expects ) {
start();
}
}
end: 5, // seconds
person: 'Anna Sob',
image: 'http://newshour.s3.amazonaws.com/photos%2Fspeeches%2Fguests%2FRichardNSmith_thumbnail.jpg',
+ href: 'http://annasob.wordpress.com',
target: 'tagdiv'
} )
.tagthisperson({
start: 3, // seconds
end: 10, // seconds
person: 'Scott',
+ href: 'http://scottdowne.wordpress.com/',
target: 'tagdiv'
} )
+ .tagthisperson({
+ start: 6, // seconds
+ end: 10, // seconds
+ person: 'Mike',
+ target: 'tagdiv2'
+ } )
+ .tagthisperson({
+ start: 7, // seconds
+ end: 12, // seconds
+ person: 'Daniel',
+ target: 'tagdiv2'
+ } )
.volume(0)
.play();
interval = setInterval( function() {
if( popped.currentTime() > 0 && popped.currentTime() <= 5 ) {
- equals ( tagdiv.childElementCount, 1, "tagdiv now contains one child elements" );
+ equals ( tagdiv.childElementCount, 2, "tagdiv now contains two child elements" );
plus();
equals ( tagdiv.textContent.trim() , "Anna Sob" ,"tagdiv shows the first tag" );
plus();
}, 2000);
interval2 = setInterval( function() {
- if( popped.currentTime() > 3 && popped.currentTime() < 5 ) {
- equals ( tagdiv.textContent.trim() , "Anna Sob, Scott", "tagdiv shows the first & second tag" );
+ if( popped.currentTime() > 5 ) {
+ equals ( tagdiv.innerHTML.search( "<a href" ) , 1 ,"second tag in tagdiv has a url" );
+ plus();
+ equals ( tagdiv2.textContent.trim(), "Mike, Daniel" ,"tagdiv2 shows the first & second tag" );
plus();
clearInterval( interval2 );
}
- }, 2000);
+ }, 4000);
interval3 = setInterval( function() {
- if( popped.currentTime() > 5 ) {
- equals ( tagdiv.innerHTML.trim() , "Scott" ,"tagdiv shows the second tag only" );
- plus();
- clearInterval( interval3 );
- }
- }, 5000);
- interval4 = setInterval( function() {
- if( popped.currentTime() > 10 ) {
+ if( popped.currentTime() > 12 ) {
equals ( tagdiv.innerHTML , "" ,"tagdiv is now cleared" );
plus();
- clearInterval( interval4 );
+ equals ( tagdiv2.innerHTML , "" ,"tagdiv2 is now cleared" );
+ plus();
+ clearInterval( interval3 );
}
}, 4000);
+
});