]> khamidou — GitHub mirrors - popcorn-js.git/commitdiff
Adding timeline stuff
authorunknown <dAve@.(none)>
Tue, 22 Mar 2011 15:45:28 +0000 (11:45 -0400)
committerunknown <dAve@.(none)>
Tue, 22 Mar 2011 15:45:28 +0000 (11:45 -0400)
plugins/timeline/asdf.css [new file with mode: 0644]
plugins/timeline/popcorn.timeline.html [new file with mode: 0644]
plugins/timeline/popcorn.timeline.js [new file with mode: 0644]
plugins/timeline/popcorn.timeline.unit.html [new file with mode: 0644]
plugins/timeline/popcorn.timeline.unit.js [new file with mode: 0644]

diff --git a/plugins/timeline/asdf.css b/plugins/timeline/asdf.css
new file mode 100644 (file)
index 0000000..46e5e66
--- /dev/null
@@ -0,0 +1,48 @@
+@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%;
+}
+#mid {
+font-size: 16px;
+}
+
diff --git a/plugins/timeline/popcorn.timeline.html b/plugins/timeline/popcorn.timeline.html
new file mode 100644 (file)
index 0000000..1aed87d
--- /dev/null
@@ -0,0 +1,89 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <title>Popcorn Google Feed Plug-in Demo</title>
+  
+  <script src="../../popcorn.js"></script>
+  <script src="popcorn.timeline.js"></script>
+  <script>
+    document.addEventListener('DOMContentLoaded', function () {
+      var p = Popcorn('#video')
+      .volume(0)
+      .play()
+      .timeline({
+        start: 1, // seconds
+        end: 700,
+        target: "timeline",
+        title: "This is a title",
+        text: "this is some interesting text that goes inside",
+        links: "and heres a link"
+         } )
+         .timeline({
+        start: 3, // seconds
+        end: 700,
+        target: "timeline",
+        title: "and more interesting shit",
+        text: "this is some interesting text that goes inside",
+        links: "and heres a link"
+      } )
+      .timeline({
+        start: 7, // seconds
+        end: 700,
+        target: "timeline",
+        title: "3x as interesting",
+        text: "this is some interesting text that goes inside",
+        links: "and heres a link"
+         } )
+    .timeline({
+        start: 9, // seconds
+        end: 700,
+        target: "timeline",
+        title: "!!4x as interesting",
+        text: "this is some interesting text that goes inside",
+        links: "and heres a link"
+         } )
+    .timeline({
+        start: 10, // seconds
+        end: 700,
+        target: "timeline",
+        title: "This is a title",
+        text: "this is some interesting text that goes inside",
+        links: "and heres a link"
+         } )
+    .timeline({
+        start: 12, // seconds
+        end: 700,
+        target: "timeline",
+        title: "This is a title",
+        text: "this is some interesting text that goes inside",
+        links: "and heres a link"
+         } );
+    }, false);
+  </script>
+</head>
+<body>
+  <h1 id="qunit-header">Popcorn Timeline Plug-in Demo</h1>
+  <p>Continuos timeline elements will be added to the div throughout the video</p>
+  <div>
+    <video id='video'
+      controls
+      width= '250px'
+      poster="../../test/poster.png">
+
+      <source id='mp4'
+        src="../../test/trailer.mp4"
+        type='video/mp4; codecs="avc1, mp4a"'>
+
+      <source id='ogv'
+        src="../../test/trailer.ogv"
+        type='video/ogg; codecs="theora, vorbis"'>
+
+      <p>Your user agent does not support the HTML5 Video element.</p>
+
+    </video>
+  </div>
+  <div style="width:1000px">
+    <div id="timeline" style="position:relative;float:left;width:400px;height:200px;overflow:auto"><p>Vertical Feed:</p></div>
+  </div>
+</body>
+</html>
\ No newline at end of file
diff --git a/plugins/timeline/popcorn.timeline.js b/plugins/timeline/popcorn.timeline.js
new file mode 100644 (file)
index 0000000..53ec5fe
--- /dev/null
@@ -0,0 +1,96 @@
+// PLUGIN: Timeline
+(function (Popcorn) {
+
+  /**
+   * googlefeed popcorn plug-in
+   * Adds a feed from the specified blog url at the target div
+   * Options parameter will need a start, end, target, url and title
+   * -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 DOM element that you want the map to appear in. This element must be in the DOM
+   * -Url is the url of the blog's feed you are trying to access
+   * -Title is the title of the blog you want displayed above the feed
+   * -Orientation is the orientation of the blog, accepts either Horizontal or Vertical, defaults to Vertical
+   * @param {Object} options
+   *
+   * Example:
+    var p = Popcorn("#video")
+      .googlefeed({
+       start: 5, // seconds
+       end: 15, // seconds
+       target: "map",
+       url: "http://zenit.senecac.on.ca/~chris.tyler/planet/rss20.xml",
+       title: "Planet Feed"
+    } )
+  *
+  */
+
+  var i = 0;
+   
+    var head = document.getElementsByTagName("head")[0];
+    var css = document.createElement('link');
+    css.type = "text/css";
+    css.rel = "stylesheet";
+    css.href =  "asdf.css";
+    head.insertBefore( css, head.firstChild ); 
+
+
+  Popcorn.plugin( "timeline" , function( options ) {
+    // create a new div and append it to the parent div so nothing
+    // that already exists in the parent div gets overwritten
+    var newdiv = document.createElement( "div" );
+    newdiv.style.display = "none";
+    newdiv.id = "asdf"+i;
+
+    if ( document.getElementById( options.target ) ) {
+      document.getElementById( options.target ).appendChild( newdiv );
+      // if this isnt the first div added to the target div
+      if( i ){
+        // insert the current div before the previous div inserted
+        document.getElementById( options.target ).insertBefore( newdiv, document.getElementById( "asdf" + ( i - 1 ) ) );
+       }
+    }
+    
+    i++;
+    
+    newdiv.innerHTML = "<p><span id='big'>" + options.title + "</span><br />" +
+    "<span id='mid'>" + options.text + "<br />" +
+"</span><a href='#'>" + options.links + "</a></p>";
+    
+    return {
+      /**
+       * @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 ){
+        newdiv.setAttribute( "style", "display:block" );       
+      },
+      /**
+       * @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){
+        newdiv.setAttribute( "style", "display:none" );
+      }
+    };
+  },
+  {
+    about: {
+      name: "Popcorn Timeline Plugin",
+      version: "0.1",
+      author: "David Seifried",
+      website: "dseifried.wordpress.com"
+    },
+    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" }
+    }
+  });
+  
+})( Popcorn );
diff --git a/plugins/timeline/popcorn.timeline.unit.html b/plugins/timeline/popcorn.timeline.unit.html
new file mode 100644 (file)
index 0000000..15ad19a
--- /dev/null
@@ -0,0 +1,44 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <title>Popcorn API</title>
+  <link rel="stylesheet" href="../../test/qunit/qunit.css" type="text/css" media="screen">
+  <script src="../../test/qunit/qunit.js"></script>
+  <!-- 
+    do not move - this must be called immediately prior to 
+    popcorn-api-draft.js
+  -->
+  
+  <script src="../../popcorn.js"></script>
+  <script src="popcorn.googlefeed.js"></script>
+
+  <script src="popcorn.googlefeed.unit.js"></script>
+</head>
+<body>
+  <h1 id="qunit-header">Popcorn Google Feed Plugin</h1>
+  <h2 id="qunit-banner"></h2>
+  <div id="qunit-testrunner-toolbar"></div>
+  <h2 id="qunit-userAgent"></h2>
+  <ol id="qunit-tests"></ol>
+  <div id="qunit-fixture">  </div>
+  
+  <video id='video' 
+    controls preload='none' 
+    width= '250px'
+    poster="../../test/poster.png"> 
+
+    <source id='mp4'
+      src="../../test/trailer.mp4"
+      type='video/mp4; codecs="avc1, mp4a"'> 
+
+    <source id='ogv'
+      src="../../test/trailer.ogv"
+      type='video/ogg; codecs="theora, vorbis"'> 
+
+    <p>Your user agent does not support the HTML5 Video element.</p> 
+
+  </video> 
+  <div id="feed" style="position:relative;float:left;width:400px;height:600px"></div> 
+  <div id="feed1" style="position:relative;float:left;width:600px;height:200px"></div>   
+</body>
+</html>
diff --git a/plugins/timeline/popcorn.timeline.unit.js b/plugins/timeline/popcorn.timeline.unit.js
new file mode 100644 (file)
index 0000000..83369b5
--- /dev/null
@@ -0,0 +1,66 @@
+test("Popcorn Google Feed Plugin", function () {
+  
+  var popped = Popcorn("#video"),
+      expects = 10, 
+      count = 0;
+  
+  expect(expects);
+  
+  function plus() {
+    if ( ++count===expects) {
+      start();
+    }
+  }
+  
+  stop();
+
+    ok ('googlefeed' in popped, "googlefeed is a method of the popped instance");
+    plus();
+    ok ( document.getElementById('feed').innerHTML === "", "initially, there is nothing inside the feed" );
+    plus();
+    ok ( document.getElementById('feed1').innerHTML === "", "initially, there is nothing inside the feed1" );
+    plus();
+  
+  popped.googlefeed({
+        start: 0, // seconds
+        end: 5, // seconds
+        target: "feed",
+        url: "http://zenit.senecac.on.ca/~chris.tyler/planet/rss20.xml",
+        title: "Planet Feed",
+        orientation: "Vertical"
+         } )
+         .googlefeed({
+        start: 0, // seconds
+        end: 5, // seconds
+        target: "feed1",
+        url: "http://blog.pikimal.com/geek/feed/",
+        title: "pikiGeek",
+        orientation: "Horizontal"
+      } )
+    .volume(0);
+  
+  popped.exec( 1, function() {
+      ok(google.load, "Google Feed is available");
+      plus();
+      ok(GFdynamicFeedControl, "Dynamic Feed Control Available");
+      plus();
+      ok (document.getElementById('_feed1'), "First feed is on the page" );
+      plus();
+      equals (document.getElementById('_feed1').offsetParent.id, "feed", "First feed is inside the 'feed' div" );
+      plus();
+  });
+  popped.exec( 2, function() {
+      ok (document.getElementById('_feed2'), "Second feed is on the page" );
+      plus();
+      equals (document.getElementById('_feed2').offsetParent.id, "feed1", "Second feed is inside the 'feed2' div" );
+      plus();
+  });
+  popped.exec( 6, function() {
+      ok (document.getElementById('_feed2').style.display === "none" && 
+          document.getElementById('_feed1').style.display === "none", "Both feeds are no lnger visible" );
+                 plus();
+  });
+  
+  popped.play();
+  
+});