From: David Seifried Date: Mon, 20 Jun 2011 20:52:27 +0000 (-0400) Subject: [#384] Added another option to specify the direction of the timeline X-Git-Tag: v0.7^2~27^2~6 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=60a436d4446ab11b3f4f1d102c7a4df1eb6a1396;p=popcorn-js.git [#384] Added another option to specify the direction of the timeline --- diff --git a/plugins/timeline/popcorn.timeline.html b/plugins/timeline/popcorn.timeline.html index 0dfcc7e..e6dc422 100644 --- a/plugins/timeline/popcorn.timeline.html +++ b/plugins/timeline/popcorn.timeline.html @@ -15,14 +15,16 @@ target: "timeline", title: "This is a title", text: "this is some interesting text that goes inside", - innerHTML: "Click here for Google" + innerHTML: "Click here for Google" , + direction: "down" } ) .timeline({ start: 3, // seconds target: "timeline", title: "double as interesting", text: "this is some interesting text that goes inside", - innerHTML: "Maybe a button? " + innerHTML: "Maybe a button? ", + direction: "down" } ) .timeline({ start: 7, // seconds @@ -30,7 +32,8 @@ target: "timeline", title: "3x as interesting", text: "this is some interesting text that goes inside", - innerHTML: "" + innerHTML: "", + direction: "down" } ) .timeline({ start: 9, // seconds @@ -46,21 +49,24 @@ "row 2, cell 1" + " row 2, cell 2" + "" + - "" + "", + direction: "down" } ) .timeline({ start: 14, // seconds target: "timeline", title: "5x as interesting", text: "this is some interesting text that goes inside", - innerHTML: "Click here for Apple" + innerHTML: "Click here for Apple", + direction: "down" } ) .timeline({ start: 18, // seconds target: "timeline", title: "6x as interesting", text: "this is some interesting text that goes inside", - innerHTML: "" + innerHTML: "", + direction: "down" } ); }, false); diff --git a/plugins/timeline/popcorn.timeline.js b/plugins/timeline/popcorn.timeline.js index dd693a2..4160964 100644 --- a/plugins/timeline/popcorn.timeline.js +++ b/plugins/timeline/popcorn.timeline.js @@ -11,6 +11,7 @@ * -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 + * -direction specifies whether the timeline will grow from the top or the bottom, receives input as "UP" or "DOWN" * @param {Object} options * * Example: @@ -39,7 +40,6 @@ Popcorn.plugin( "timeline" , function( options ) { var target = document.getElementById( options.target ); - target.style.float = "left"; target.style.width = "400px"; target.style.height = "200px"; target.style.overflow = "auto"; @@ -48,18 +48,22 @@ // that already exists in the parent div gets overwritten var newdiv = document.createElement( "div" ); newdiv.style.display = "none"; - newdiv.id = "timelineDiv"+i; + newdiv.id = "timelineDiv" + i; + + options.direction = ( options.direction.toLowerCase() === "up" || options.direction.toLowerCase() === "down" ) + ? options.direction : "up"; if ( target ) { target.appendChild( newdiv ); // if this isnt the first div added to the target div - if( i ){ - + if( i && options.direction.length === 2 ){ // insert the current div before the previous div inserted target.insertBefore( newdiv, document.getElementById( "timelineDiv" + ( i - 1 ) ) ); - } + } + + target.scrollTop = options.direction.toLowerCase() === "down" ? 0 : target.scrollHeight; } i++; @@ -72,11 +76,11 @@ return { - start: function( event, options ){ + start: function( event, options ) { newdiv.style.display = "block"; }, - end: function( event, options ){ + end: function( event, options ) { newdiv.style.display = "none"; },