From: Anna Sobiepanek Date: Fri, 10 Dec 2010 17:16:03 +0000 (-0500) Subject: initial google map plugin [#171] X-Git-Tag: v0.2~22^2~4^2~7 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=087521adbf38ee68af314cf11eec4386776f7bb0;p=popcorn-js.git initial google map plugin [#171] --- diff --git a/plugins/googleMap/popcorn.googleMap.html b/plugins/googleMap/popcorn.googleMap.html new file mode 100644 index 0000000..4a52b64 --- /dev/null +++ b/plugins/googleMap/popcorn.googleMap.html @@ -0,0 +1,50 @@ + + + + Popcorn google Map Plug-in Demo + + + + + + +

Popcorn google Map Plug-in Demo

+

A footnote displaying This video made exclusively for drumbeat.org' will appear at 5 seconds and disappear at 15 seconds.

+

A footnote displaying 'Visit webmademovies.org for more details' will appear at 20 seconds and disappear at 45 seconds.

+
+ +
+
+
+ + diff --git a/plugins/googleMap/popcorn.googleMap.js b/plugins/googleMap/popcorn.googleMap.js new file mode 100644 index 0000000..e357260 --- /dev/null +++ b/plugins/googleMap/popcorn.googleMap.js @@ -0,0 +1,87 @@ +// PLUGIN: Google Maps + +(function (Popcorn) { + + /** + * googleMap popcorn plug-in + * Adds a map to the target div centered on the location specified + * by the user + * Options parameter will need a start, end, target, lat and long, zoom + * Start is the time that you want this plug-in to execute + * End is the time that you want this plug-in to stop executing + * Target is the id of the document element that the text needs to be + * Type either: HYBRID (default), ROADMAP, SATELLITE, TERRAIN + * attached to, this target element must exist on the DOM + * Src [optional] + * MapInfo [optional] + * Note: + * @param {Object} options + * + * Example: + var p = Popcorn('#video') + .googleMap({ + start: 5, // seconds + end: 15, // seconds + type: 'ROADMAP', + target: 'map' + } ) + * + */ + Popcorn.plugin( "googleMap" , (function(){ + + var temp,head, script,location, map, link; + + return { + _setup : function( event, options ) { + // check if google map api is already loaded + head = document.getElementsByTagName('head')[0]; + script = document.createElement('script'); + script.onload = function() { + alert("he"); + location = new google.maps.LatLng(options.lat, options.long); + map = new google.maps.Map(document.getElementById(options.target), {mapTypeId: options.type | google.maps.MapTypeId.HYBRID }); + + } + script.src = "http://maps.google.com/maps/api/js?sensor=false"; + script.type = 'text/javascript'; + head.appendChild(script) + //head.insertBefore( script, head.firstChild ); + // setup isready + + }, + /** + * @member webpage + * 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; + + map.setCenter(location); + map.setZoom(options.zoom); + if (options.src && options.mapinfo) { + link = document.createElement("a"); + link.setAttribute("href", options.src); + link.setAttribute("target", "_blank"); + link.appendChild(document.createTextNode(options.description||options.src)); + document.getElementById(options.mapinfo).appendChild(link); + } + }, + /** + * @member webpage + * 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 = ""; + //figure out how to delete map + } + + }; + + })()); + +})( Popcorn ); \ No newline at end of file diff --git a/plugins/googleMap/popcorn.googleMap.unit.html b/plugins/googleMap/popcorn.googleMap.unit.html new file mode 100644 index 0000000..21e2c4f --- /dev/null +++ b/plugins/googleMap/popcorn.googleMap.unit.html @@ -0,0 +1,43 @@ + + + + Popcorn API + + + + + + + + + + +

Popcorn Google Map Plugin

+

+
+

+
    +
    + + +
    + + diff --git a/plugins/googleMap/popcorngoogleMap.unit.js b/plugins/googleMap/popcorngoogleMap.unit.js new file mode 100644 index 0000000..7877ca1 --- /dev/null +++ b/plugins/googleMap/popcorngoogleMap.unit.js @@ -0,0 +1,66 @@ +test("Popcorn Google Map Plugin", function () { + + var popped = Popcorn("#video"), + expects = 5, + count = 0, + iframeInterval, + iframeInterval2, + iframeInterval3, + iframeInterval4; + + expect(expects); + + function plus() { + if ( ++count===expects) { + start(); + } + } + + stop(); + + ok ('footnote' in popped, "footnote is a mehtod of the popped instance"); + plus(); + + ok ( document.getElementById('footnotediv').innerHTML === "", "initially, there is nothing inside the footnotediv" ); + plus(); + //equals( actual, expected, message ) instead of ok( boolean true, message ) + popped.footnote({ + start: 5, // seconds + end: 15, // seconds + text: 'This video made exclusively for drumbeat.org', + target: 'footnotediv' + } ) + .footnote({ + start: 35, // seconds + end: 45, // seconds + text: 'Visit webmademovies.org for more details', + target: 'footnotediv' + } ) + .play(); + + + interval = setInterval( function() { + if( popped.currentTime() > 5 && popped.currentTime() <= 15 ) { + ok (document.getElementById('footnotediv').innerHTML === "This video made exclusively for drumbeat.org", "footnote displaing correct information" ); + plus(); + clearInterval( interval ); + } + }, 5000); + + interval2 = setInterval( function() { + if( popped.currentTime() > 15 && popped.currentTime() < 35 ) { + ok (document.getElementById('footnotediv').innerHTML === "", "footnote cleared properly" ); + plus(); + clearInterval( interval2 ); + } + }, 5000); + + interval3 = setInterval( function() { + if( popped.currentTime() > 35 && popped.currentTime() < 45 ) { + ok (document.getElementById('footnotediv').innerHTML === "Visit webmademovies.org for more details", "footnote displaing correct information" ); + plus(); + clearInterval( interval3 ); + } + }, 5000); + +});