<script src="../../popcorn.js"></script>
<script src="popcorn.image.js"></script>
<script>
- document.addEventListener('DOMContentLoaded', function () {
- var p = Popcorn('#video')
- .volume(0)
+ document.addEventListener( "DOMContentLoaded", function() {
+
+ var p = Popcorn( "#video" )
+ .volume( 0 )
.play()
.image({
- start: 5, // seconds
- end: 15, // seconds
- href: 'http://www.drumbeat.org/',
- src: 'https://www.drumbeat.org/media//images/drumbeat-logo-splash.png',
- text: 'DRUMBEAT',
- target: 'imagediv'
- } )
+ // seconds
+ start: 5,
+ // seconds
+ end: 15,
+ href: "http://www.drumbeat.org/",
+ src: "https://www.drumbeat.org/media//images/drumbeat-logo-splash.png",
+ text: "DRUMBEAT",
+ target: "imagediv"
+ })
.image({
- start: 5, // seconds
- end: 45, // seconds
+ // seconds
+ start: 5,
+ // seconds
+ end: 45,
// no href
- src: 'http://patriciabergeron.net/wp-content/uploads/web.made_.movie_marquee.gif',
- target: 'imagediv'
- } );
-
+ src: "http://patriciabergeron.net/wp-content/uploads/web.made_.movie_marquee.gif",
+ target: "imagediv"
+ });
}, false);
</script>
<p> First one (with an overlayed text) will disappear at 15 seconds.</p>
<p> Second one (without an overlayed text) will disappear at 45 seconds.</p>
<div>
- <video id='video'
+ <video id="video"
controls
- width= '250px'
+ width="250px"
poster="../../test/poster.png">
- <source id='mp4'
+ <source id="mp4"
src="../../test/trailer.mp4"
type='video/mp4; codecs="avc1, mp4a"'>
- <source id='ogv'
+ <source id="ogv"
src="../../test/trailer.ogv"
type='video/ogg; codecs="theora, vorbis"'>
// PLUGIN: IMAGE
+
(function (Popcorn) {
+
/**
* Images popcorn plug-in
* Shows an image element
} )
*
*/
-
Popcorn.plugin( "image", {
-
manifest: {
-
about:{
-
- name : "Popcorn image Plugin",
- version : "0.1",
- author : "Scott Downe",
- website : "http://scottdowne.wordpress.com/"
+ name: "Popcorn image Plugin",
+ version: "0.1",
+ author: "Scott Downe",
+ website: "http://scottdowne.wordpress.com/"
},
-
- options:{
- start : {elem:'input', type:'number', label:'In'},
- end : {elem:'input', type:'number', label:'Out'},
- href : {elem:'input', type:'text', label:'Link URL'},
- target : 'Image-container',
- src : {elem:'input', type:'text', label:'Source URL'},
- text : {elem:'input', type:'text', label:'TEXT'}
+ options: {
+ start: {
+ elem: "input",
+ type: "number",
+ label: "In"
+ },
+ end: {
+ elem: "input",
+ type: "number",
+ label: "Out"
+ },
+ href: {
+ elem: "input",
+ type: "text",
+ label: "Link URL"
+ },
+ target: "Image-container",
+ src: {
+ elem: "input",
+ type: "text",
+ label: "Source URL"
+ },
+ text: {
+ elem: "input",
+ type: "text",
+ label: "TEXT"
+ }
}
},
-
_setup: function( options ) {
- var img = document.createElement( 'img' );
+ var img = document.createElement( "img" );
- options.link = document.createElement( 'a' );
+ options.link = document.createElement( "a" );
options.link.style.position = "relative";
options.link.style.textDecoration = "none";
if ( document.getElementById( options.target ) ) {
- document.getElementById( options.target ).appendChild( options.link ); // add the widget's div to the target div
+ // add the widget's div to the target div
+ document.getElementById( options.target ).appendChild( options.link );
}
img.addEventListener( "load", function() {
- img.style.borderStyle = "none"; // borders look really bad, if someone wants it they can put it on their div target
+ // borders look really bad, if someone wants it they can put it on their div target
+ img.style.borderStyle = "none";
if ( options.href ) {
options.link.href = options.href;
}
+
options.link.target = "_blank";
var fontHeight = ( img.height / 12 ) + "px",
Popcorn.extend( divText.style, {
- color : "black",
- fontSize : fontHeight,
- fontWeight : "bold",
- position : "relative",
- textAlign : "center",
- width : img.width + "px",
- zIndex : "10"
+ color: "black",
+ fontSize: fontHeight,
+ fontWeight: "bold",
+ position: "relative",
+ textAlign: "center",
+ width: img.width + "px",
+ zIndex: "10"
});
divText.innerHTML = options.text || "";
divText.style.top = ( img.height / 2 ) - ( divText.offsetHeight / 2 ) + "px";
options.link.style.display = "none";
}, false );
+
img.src = options.src;
},
options.link.style.display = "none";
}
});
-
})( Popcorn );
<ol id="qunit-tests"></ol>
<div id="qunit-fixture"> </div>
- <video id='video'
+ <video id="video"
controls
- width= '250px'
+ width="250px"
poster="../../test/poster.png">
- <source id='mp4'
+ <source id="mp4"
src="../../test/trailer.mp4"
type='video/mp4; codecs="avc1, mp4a"'>
- <source id='ogv'
+ <source id="ogv"
src="../../test/trailer.ogv"
type='video/ogg; codecs="theora, vorbis"'>
test("Popcorn Image Plugin", function () {
- var popped = Popcorn("#video"),
+ var popped = Popcorn( "#video" ),
expects = 5,
count = 0,
- imagediv = document.getElementById('imagediv');
+ imagediv = document.getElementById( "imagediv" );
expect( expects );
stop();
- ok('image' in popped, "image is a method of the popped instance");
+ ok( "image" in popped, "image is a method of the popped instance" );
plus();
- equals ( imagediv.innerHTML, "", "initially, there is nothing inside the imagediv" );
+ equals( imagediv.innerHTML, "", "initially, there is nothing inside the imagediv" );
plus();
popped.image({
- start: 1, // seconds
- end: 3, // seconds
- href: 'http://www.drumbeat.org/',
- src: 'https://www.drumbeat.org/media//images/drumbeat-logo-splash.png',
- text: 'DRUMBEAT',
- target: 'imagediv'
+ // seconds
+ start: 1,
+ // seconds
+ end: 3,
+ href: "http://www.drumbeat.org/",
+ src: "https://www.drumbeat.org/media//images/drumbeat-logo-splash.png",
+ text: "DRUMBEAT",
+ target: "imagediv"
});
popped.exec( 2, function() {
ok( /display: none;/.test( imagediv.innerHTML ), "Div contents are hidden again" );
plus();
});
- popped.volume(0).play();
-
+
+ popped.volume( 0 ).play();
});