From 728d8165b40f6f11952bc324a08a58edac2f8e21 Mon Sep 17 00:00:00 2001 From: David Seifried Date: Mon, 6 Jun 2011 16:19:53 -0400 Subject: [PATCH] [#384] Initial version of the timeline plugin --- plugins/timeline/popcorn.timeline.css | 49 ++-------------- plugins/timeline/popcorn.timeline.html | 31 +++++----- plugins/timeline/popcorn.timeline.js | 60 +++++++++++++++---- plugins/timeline/popcorn.timeline.unit.html | 43 ++++++++++++++ plugins/timeline/popcorn.timeline.unit.js | 65 +++++++++++++++++++++ 5 files changed, 177 insertions(+), 71 deletions(-) create mode 100644 plugins/timeline/popcorn.timeline.unit.html create mode 100644 plugins/timeline/popcorn.timeline.unit.js diff --git a/plugins/timeline/popcorn.timeline.css b/plugins/timeline/popcorn.timeline.css index cb94c54..5835c3a 100644 --- a/plugins/timeline/popcorn.timeline.css +++ b/plugins/timeline/popcorn.timeline.css @@ -1,52 +1,11 @@ -@charset "UTF-8"; -body { -font-family: "Helvetica Neue", Helvetica, Arial; -font-size:12px; -} - -#footer { -width: 100%; -height: 20px; -position: fixed; -text-align:right; -right: 0px; -overflow: hidden; -background-color:#000000; -color: white; -top: 0; -border-bottom: 1px solid #333; -padding: 10px; -} -#playback { -width: 700px; -left: 0px; -top: 0px; -z-index:100; -} - -#details2 { -color: #fff; -padding: 7px; -right: 0px; -top: 0px; -line-height: 180%; -} -#details3 { -padding: 7px; -right: 0px; -top: 0px; -line-height: 180%; -border-top: 1px solid #333; -} #big { -font-size:24px; -line-height: 130%; + font-size:24px; + line-height: 130%; } + #mid { -font-size: 16px; + font-size: 16px; } -// Thanks again to Nic for this css - diff --git a/plugins/timeline/popcorn.timeline.html b/plugins/timeline/popcorn.timeline.html index 498162e..6507655 100644 --- a/plugins/timeline/popcorn.timeline.html +++ b/plugins/timeline/popcorn.timeline.html @@ -5,7 +5,6 @@ - @@ -84,7 +87,7 @@
-

Vertical Feed:

+
diff --git a/plugins/timeline/popcorn.timeline.js b/plugins/timeline/popcorn.timeline.js index 7d98c0c..de3a8a7 100644 --- a/plugins/timeline/popcorn.timeline.js +++ b/plugins/timeline/popcorn.timeline.js @@ -1,13 +1,38 @@ // PLUGIN: Timeline (function (Popcorn) { - var i = 0; + /** + * timeline popcorn plug-in + * Adds data associated with a certain time in the video, which creates a scrolling view of each item as the video progresses + * Options parameter will need a start, target, title, and text + * -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, tho for this plugin an end time may not be needed ( optional ) + * -Target is the id of the DOM element that you want the map to appear in. This element must be in the DOM + * -Title is the title of the current timeline box + * -Text is text is simply related text that will be displayed + * -innerHTML gives the user the option to add things such as links, buttons and so on + * @param {Object} options + * + * Example: + var p = Popcorn("#video") + .timeline( { + start: 5, // seconds + target: "timeline", + title: "Seneca", + text: "Welcome to seneca", + innerHTML: "Click this link Google" + } ) + * + */ + + var i = 1; - var head = document.getElementsByTagName("head")[0]; - var css = document.createElement('link'); + // Included simple css to make it look a bit nicer + var head = document.getElementsByTagName( "head" )[ 0 ]; + var css = document.createElement( 'link' ); css.type = "text/css"; css.rel = "stylesheet"; - css.href = "asdf.css"; + css.href = "popcorn.timeline.css"; head.insertBefore( css, head.firstChild ); @@ -32,10 +57,12 @@ } i++; - + + // Default to empty if not used + //options.innerHTML = options.innerHTML || ""; + newdiv.innerHTML = "

" + options.title + "
" + - "" + options.text + "
" + - "
" + options.links + "

"; + "" + options.text + "
" + options.innerHTML; return { @@ -43,8 +70,15 @@ newdiv.setAttribute( "style", "display:block" ); }, - end: function(event, options){ + end: function( event, options ){ newdiv.setAttribute( "style", "display:none" ); + }, + + _teardown: function( options ) { + while ( document.getElementById( options.target ).childNodes.length >= 1 ) + { + document.getElementById( options.target ).removeChild( document.getElementById( options.target ).firstChild ); + } } }; }, @@ -58,10 +92,12 @@ }, options: { - start : { elem:"input", type:"text", label:"In" }, - end : { elem:"input", type:"text", label:"Out" }, - target : "feed-container", - text : { elem:"input", type:"text", label:"text" } + start : { elem:"input", type:"text", label:"In" }, + end : { elem:"input", type:"text", label:"Out" }, + target : "feed-container", + title : { elem:"input", type:"text", label:"title" }, + text : { elem:"input", type:"text", label:"text" }, + innerHTML: { elem:"input", type:"text", label:"innerHTML" } } }); diff --git a/plugins/timeline/popcorn.timeline.unit.html b/plugins/timeline/popcorn.timeline.unit.html new file mode 100644 index 0000000..8adf467 --- /dev/null +++ b/plugins/timeline/popcorn.timeline.unit.html @@ -0,0 +1,43 @@ + + + + Popcorn API + + + + + + + + + + +

Popcorn Timeline Plugin

+

+
+

+
    +
    + + +
    + + diff --git a/plugins/timeline/popcorn.timeline.unit.js b/plugins/timeline/popcorn.timeline.unit.js new file mode 100644 index 0000000..852ba78 --- /dev/null +++ b/plugins/timeline/popcorn.timeline.unit.js @@ -0,0 +1,65 @@ +test("Popcorn Timeline Plugin", function () { + + var popped = Popcorn("#video"), + expects = 8, + setupId, + count = 0; + + expect(expects); + + function plus() { + if ( ++count===expects) { + start(); + } + } + + stop(); + + ok ('timeline' in popped, "timeline is a method of the popped instance"); + plus(); + ok ( document.getElementById('timeline').innerHTML === "", "initially, there is nothing inside the feed" ); + plus(); + + popped.timeline({ + start: 1, // seconds + target: "timeline", + title: "This is a title", + text: "this is some interesting text that goes inside", + innerHTML: "Click here for Google" + } ) + .timeline({ + start: 2, // seconds + target: "timeline", + title: "double as interesting", + text: "this is some interesting text that goes inside", + innerHTML: "Maybe a button? " + } ) + .volume(0); + + setupId = popped.getLastTrackEventId(); + + popped.exec( 2, function() { + ok (document.getElementById('timelineDiv1'), "First timeline is on the page" ); + plus(); + equals (document.getElementById('timelineDiv1').parentNode.id, "timeline", "First timeline is inside the 'timeline' div" ); + plus(); + }); + popped.exec( 3, function() { + ok (document.getElementById('timelineDiv2'), "Second timeline is on the page" ); + plus(); + equals (document.getElementById('timelineDiv2').parentNode.id, "timeline", "Second timelineDiv2 is inside the 'timeline' div" ); + plus(); + }); + popped.exec( 4, function() { + ok (document.getElementById('timelineDiv1').style.display !== "none" && + document.getElementById('timelineDiv2').style.display !== "none", "Both timelines are not visible" ); + plus(); + + popped.pause().removeTrackEvent( setupId ); + ok( !document.getElementById('timeline').children[0], "removed timeline was properly destroyed" ); + plus(); + }); + + popped.play(); + +}); -- 2.43.0