]> khamidou — GitHub mirrors - popcorn-js.git/commitdiff
Got credits working
authorNick Cammarata <nick@nick-laptop.(none)>
Wed, 30 Jun 2010 19:55:10 +0000 (15:55 -0400)
committerNick Cammarata <nick@nick-laptop.(none)>
Wed, 30 Jun 2010 19:55:10 +0000 (15:55 -0400)
index.html
popcorn.js
xml/webMadeMovies.xml

index 032be81bf0a99c231df6f8f40027bc36e7778dea..dd43170bc8641b48f54860de3de5792a64398720 100644 (file)
@@ -4,6 +4,7 @@
     <script src="http://widgets.twimg.com/j/2/widget.js"></script>
     <script src="popcorn.js"></script>
     <script src="http://code.jquery.com/jquery.js"></script> 
+    <script src="ihttp://twitter.com/statuses/user_timeline/dharmmotyar.json?callback=showAvatar&count=1"></script>
     <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
     <script src="http://google.com/jsapi"></script>
     <script>google.load("language","1");</script>
@@ -11,6 +12,7 @@
       body { 
         background-color:#eee; 
       }
+
       #container {
         width:850px;
         margin:auto 50px;
         padding:20px;
         position:relative;
       }
+
       #sub { 
         position:absolute;
         top:435px;
         left:40px;
-        color:white;
+        color:#eee;
         font-weight:bold;
         font-family:sans-serif;        
         text-shadow:black 1px 1px 3px;
         width:820px;   
         font-size:25px;
       }
+
       #map {
           border: solid 1px #000;
           width: 200px;
           height: 200px;
       }
+
+      #credits {
+        position:absolute;   
+        overflow:hidden;
+        background-color:#333;
+        border-left:1px solid #333;
+      }
+        
+      #credits .column {
+        float:left;
+        position:absolute;
+        height:100%;
+        top:0px;
+        margin:0px;
+        padding:0px;
+        background-color:#555;
+        overflow:auto;
+        border-right:1px #666 solid;
+      }
+        
+        .play { 
+            background:url('play.png') left center no-repeat;
+        }
+
+        #credits li {
+            list-style-type:none;
+        }
+            #credits li.selected { border-left:2px solid #FADBAF; }
+
+            #credits li a {
+                display:block;
+                text-decoration:none;
+                color:#efefef;
+                font-weight:bold;
+                font-family:sans-serif;        
+                text-shadow:black 1px 1px 3px;
+                padding:12px 14px;
+                border-bottom:1px solid #666;
+            }
+
+            #credits li a:hover {
+                color:#FADBAF;
+            }
     </style> 
   </head> 
   <body> 
     <div id="container">
-      <video src="http://a52.video2.blip.tv/7320003802153/Etherworks-WebMadeMovies3BuildingABetterInternet799.ogg" data-timeline-sources="xml/webMadeMovies.xml" controls></video>
+      <div id="credits" style="display:none">
+        <div id="credit_inner">
+        </div>
+      </div>
+      <video src="video.ogg" data-timeline-sources="xml/webMadeMovies.xml" controls></video>
       <select id="language">
         <option val="en">English</option>
         <option val="es">Spanish</option>
     </div>
   </body> 
 </html> 
-
index 03621ae126a20da5b77049598c42075c022d9b85..48f98a5114d8c0228feda2c1c017a831f3acbbd8 100644 (file)
@@ -1,7 +1,6 @@
 /*global google: false */ // This global comment is read by jslint
 
 (function() {
-
   // The video manager manages a single video element, and all it's commands.
   var VideoManager = this.VideoManager = function(videoElement) {
     this.commandObjects  = {};
     };
   };
 
+  ////////////////////////////////////////////////////////////////////////////
+  // Credits Command
+  ////////////////////////////////////////////////////////////////////////////
+  var credits = {
+    add: function() {
+        
+    }
+  }
+  var CreditsCommand = function(name, params, text, videoManager) {
+    VideoCommand.call(this, name, params, text, videoManager);
+    $("#credits")
+        .width(this.videoManager.videoElement.clientWidth)
+        .height(this.videoManager.videoElement.clientHeight)
+    this.params["in"]=this.videoManager.videoElement.duration-.1;
+    this.params["out"]=this.videoManager.videoElement.duration+.1;
+    var that = this;
+    this.onIn = function() {
+        $("#credits").show();
+        $("#choices").animate({ right:'+=200px' }, 1000);
+        CreditsCommand.add( [
+            { 
+                text: "Play Again",
+                click:function() {
+                    CreditsCommand.killCol(0)
+                    $('video')[0].currentTime=0;
+                }
+            },
+            { 
+                text: "People",
+                next:[
+                    {
+                        text: "Nick Cammarata",
+                        next: [
+                            { text: "Twitter", href: "http://twitter.com/nicklovescode" },
+                            { text: "Flickr", href: "http://flickr.com/nicklovescode" }
+                        ] 
+                    },
+                    {
+                        text: "Celine Celine",
+                        href: "http://twitter.com/celinecelines"    
+                    }
+                ]
+            },
+            { text: "Places" },
+            { text: "Articles" }
+        ]);
+    };
+    this.onOut = function() {
+        $("#choices").css("right","-200px");
+        $("#credits").hide();
+    };
+  };
+  CreditsCommand.colIndex = 0;
+  CreditsCommand.killCol = function(index, callback) {
+     $(".column").each(function() {
+        if ($(this).attr("colindex")>index) {
+           $(this).addClass("removing").animate( { left: -$(this).outerWidth() + "px" }, 1200, function() {
+               $(this).remove(); 
+           });
+        }
+     });
+     if (callback) callback();
+  }
+
+  CreditsCommand.add =  function(items) {
+        CreditsCommand.colIndex++;
+        var ul = $("<ul></ul>")
+            .addClass('column')
+            .attr('colindex',parseInt(CreditsCommand.colIndex))
+        $.each(items, function(i, val) {
+            var li = $(document.createElement('li'))
+                .append($(document.createElement('a'))
+                    .text(val.text)
+                    .attr("href",val.href||"#")
+                    .attr("target",val.href?"_blank":""))
+                .appendTo(ul)
+                .addClass('play')
+                .click(function() {
+                    if (val.href) return true;
+                    var colIndex = $(this).parent().attr('colindex');
+                    if (CreditsCommand.colIndex>colIndex) { 
+                        CreditsCommand.killCol(colIndex);
+                        CreditsCommand.colIndex = colIndex;
+                    }
+                    var hasClass = $(this).hasClass('selected');
+                    if (!hasClass) {
+                        if (val.click) val.click();
+                        if (val.next) CreditsCommand.add(val.next); 
+                    }  
+                    $(this)
+                       .parent()
+                       .find('.selected')
+                       .removeClass('selected')
+                    if (!hasClass) $(this).addClass('selected');
+                })
+        });
+        var width = 0;
+        $(".column:not(.removing)").each(function() {
+            width+=$(this).outerWidth();    
+        })
+        ul
+            .appendTo("#credit_inner")
+            .css("z-index",1000-CreditsCommand.colIndex)
+            .css("left",-ul.outerWidth())
+            .animate({ 
+                left: width + "px"
+            },750)
+  }
+
   ////////////////////////////////////////////////////////////////////////////
   // TagThisPerson Command
   ////////////////////////////////////////////////////////////////////////////
   
   var FlickrCommand = function(name, params, text, videoManager) {
     VideoCommand.call(this, name, params, text, videoManager);
-
     // Setup a default, hidden div to hold the images
     var target = document.createElement('div');
     target.setAttribute('id', this.id);
         return new SubtitleCommand(name, params, text, videoManager);
       }
     },
+    credits: {
+      create: function(name, params, text, videoManager) {
+        return new CreditsCommand(name, params, text, videoManager);
+      }
+    },
+    flickr: {
+      create: function(name, params, text, videoManager) {
+        return new FlickrCommand(name, params, text, videoManager);
+      }
+    },
     videotag: {
       create: function(name, params, text, videoManager) {
         return new TagCommand(name, params, text, videoManager);
       create: function(name, params, text, videoManager) {
         return new AttributionCommand(name, params, text, videoManager);
       }
-    },
-    flickr: {
-      create: function(name, params, text, videoManager) {
-        return new FlickrCommand(name, params, text, videoManager);
-      }
     }
   };
 
index 33ca285766df8025c2d5606a82ae1fcad8ba5f32..b4870210f49b1aa80d1fd1d5524702a02c8c8735 100644 (file)
@@ -79,5 +79,8 @@
     <flick>
       <flickr in="00:01:00" out="00:20:00" target="flickr" userid="13072070" numberofimages="10"/>
     </flick>
+    <credit>
+        <credits>test</credits>
+    </credit>
   </timeline>
 </popcorn>