]> khamidou — GitHub mirrors - popcorn-js.git/commitdiff
[#t366] created applyclass effect, appied applyclass to semantic demo
authorScottDowne <sdowne@learn.senecac.on.ca>
Tue, 21 Jun 2011 23:08:16 +0000 (19:08 -0400)
committerScottDowne <sdowne@learn.senecac.on.ca>
Tue, 21 Jun 2011 23:08:16 +0000 (19:08 -0400)
demos/semantic_video/index.html
demos/semantic_video/style.css
demos/semantic_video/xml/webMadeMovies.xml
effects/applyclass/popcorn.applyclass.html [moved from effects/expand/popcorn.expand.html with 63% similarity, mode: 0644]
effects/applyclass/popcorn.applyclass.js [new file with mode: 0644]
effects/applyclass/style.css [new file with mode: 0644]
effects/expand/popcorn.expand.js [deleted file]
effects/flash/popcorn.flash.html [deleted file]
effects/flash/popcorn.flash.js [deleted file]

index aa7c2439f807f315cd6bec86c75096e1ec84b870..8a6cccf647bdfa58730393c253046265e0779a49 100644 (file)
@@ -17,6 +17,7 @@
   <script src="../../plugins/flickr/popcorn.flickr.js"></script>
   <script src="../../plugins/attribution/popcorn.attribution.js"></script>
   <script src="../../plugins/lastfm/popcorn.lastfm.js"></script>
+  <script src="../../effects/applyclass/popcorn.applyclass.js"></script>
 
   <script src="../../parsers/parserXML/popcorn.parserXML.js"></script>
 
           <div class="left-content">
             <!-- Start Video Div -->
             <div id="videoContainer" class="video-div">
-              <div id="credits" style="display:none">
-                <div id="credit_inner">
-                </div>
-              </div>
-                <script>
-/*
-                ////////////////////////////////////////////////////////////////////////////
-                // Credits
-                ////////////////////////////////////////////////////////////////////////////
-
-                  $("#credits")
-                      .width(530)
-                      .height(299);
-                  var displayCredits = function() {
-                      $("#credits").show();
-                      $("#choices").animate({ right:'+=200px' }, 1000);
-                      add( [
-                          { 
-                              text: "Play Again",
-                              click:function() {
-                                  killCol(0);
-                                  $('video')[0].currentTime=0;
-                              }
-                          },
-                          {
-                              text: "People",
-                              next :[
-                                  {
-                                      text: "Steve Song", href: "http://www.google.ca/"
-                                  },
-                                  {
-                                      text: "Jeffrey Warren"
-                                  },
-                                  {
-                                      text: "Michael Adeyeye"
-                                  },
-                                  {
-                                      text: "Charlie Schmidt"
-                                  },
-                                  {
-                                      text: "Jonathan Zittrain"
-                                  },
-                                  {
-                                      text: "Mona Kasra"
-                                  },
-                                  {
-                                      text: "Noah Workman"
-                                  },
-                                  {
-                                      text: "Wilken Sanches"
-                                  },
-                                  {
-                                      text: "Keechang Kim"
-                                  },
-                                  {
-                                      text: "Celine Celines"
-                                  }
-                              ]
-                          },
-                          {
-                              text: "Places",
-                              next: [
-                                  {
-                                      text: "Sao Paulo", href: "http://en.wikipedia.org/wiki/S%C3%A3o_Paulo"
-                                  },
-                                  {
-                                      text: "Cape Town", href: "http://en.wikipedia.org/wiki/Cape_Town"
-                                  },
-                                  {
-                                      text: "Grande Isle, Louisiana", href: "http://en.wikipedia.org/wiki/Grand_Isle,_Louisiana"
-                                  },
-                                  {
-                                      text: "MIT Media Lab", href: "http://www.media.mit.edu/"
-                                  },
-                                  {
-                                      text: "Austin, Texas", href: "http://en.wikipedia.org/wiki/Austin,_Texas"
-                                  },
-                                  {
-                                      text: "New York, New York", href: "http://en.wikipedia.org/wiki/New_York_City"
-                                  },
-                                  {
-                                      text: "Seoul, Republic of South Korea", href: "http://en.wikipedia.org/wiki/Seoul"
-                                  },
-                                  {
-                                      text: "Montreal, Quebec", href: "http://en.wikipedia.org/wiki/Montreal"
-                                  },
-                                  {
-                                      text: "Harvard Law School", href: "http://www.law.harvard.edu/index.html"
-                                  }
-                              ]
-                          },
-                          {
-                              text: "Articles",
-                              next: [
-                                  {
-                                      text: "The Internet", href: "http://en.wikipedia.org/wiki/internet"
-                                  },
-                                  {
-                                      text: "The Village Telco", href: "http://en.wikipedia.org/wiki/Village_telco"
-                                  },
-                                  {
-                                      text: "Deepwater Horizon Oil Spill", href: "http://en.wikipedia.org/wiki/Deepwater_Horizon_oil_spill"
-                                  },
-                                  {
-                                      text: "Jonathan Zittrain", href: "http://en.wikipedia.org/wiki/Jonathan_Zittrain"
-                                  },
-                                  {
-                                      text: "Compuserve", href: "http://en.wikipedia.org/wiki/Compuserve"
-                                  },
-                                  {
-                                      text: "AOL", href: "http://en.wikipedia.org/wiki/AOL"
-                                  },
-                                  {
-                                      text: "Prodigy", href: "http://en.wikipedia.org/wiki/Prodigy_%28online_service%29"
-                                  },
-                                  {
-                                      text: "Internet Protocol", href: "http://en.wikipedia.org/wiki/Internet_Protocol"
-                                  },
-                                  {
-                                      text: "Tim Berners-Lee", href: "http://en.wikipedia.org/wiki/Tim_Berners-Lee"
-                                  },
-                                  {
-                                      text: "World Wide Web", href: "http://en.wikipedia.org/wiki/World_wide_web"
-                                  },
-                                  {
-                                      text: "Wikipedia", href: "http://en.wikipedia.org/wiki/Wikipedia"
-                                  },
-                                  {
-                                      text: "Open Standards", href: "http://en.wikipedia.org/wiki/Open_Standards"
-                                  }
-                              ]    
-                          },
-                          {
-                              text: "Developers",
-                              next: [
-                                  {
-                                      text: "Brett Gaylor",
-                                      next: [
-                                          { text: "Twitter", href: "http://twitter.com/remixmanifesto"},
-                                          { text: "Email", href: "mailto:brett@eyesteelfilm.com"}
-                                      ]
-                                  },
-                                  {
-                                       text: "Scott Downe",
-                                       next:  [{ text: "Email", href: "mailto:scott.downe@senecac.on.ca" }]
-                                  },
-                                  
-                                  {
-                                      text: "Nick Cammarata",
-                                      next: [
-                                          { text: "Twitter", href: "http://twitter.com/nicklovescode"},
-                                          { text: "Email", href: "mailto:nick@nickcammarata.com"}
-                                      ]
-                                  },
-                                  {
-                                      text: "Anna Sobiepanek",
-                                      next: [
-                                          { text: "Twitter", href: "http://twitter.com/annasob"},
-                                          { text: "Email", href: "mailto:anna.sobiepanek@gmail.com"}
-                                      ]
-                                  },
-                                  {
-                                      text: "Daniel Hodgin",
-                                      next: [
-                                          { text: "Twitter", href: "http://twitter.com/dhhodgin"},
-                                          { text: "Email", href: "mailto:daniel.hodgin@senecac.on.ca"}
-                                      ]
-                                  },
-                                  {
-                                      text: "David Humphrey",
-                                      next: [
-                                          { text: "Twitter", href: "http://twitter.com/humphd"},
-                                          { text: "Email", href: "mailto:david.humphrey@senecac.on.ca"}
-                                      ]
-                                  }
-                              ]
-                          },
-                          { 
-                              text: "Sources",
-                              next: [
-                                  
-                              ]
-                          }
-                      ]);
-                  };
-                  var removeCredits = function() {
-                      $("#choices").css("right","-200px");
-                      $("#credits").hide();
-                  };
-                  var colIndex = 0;
-                  var 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();
-                    }
-                  };
-
-                  var add =  function(items) {
-                        colIndex++;
-                        var ul = $("<ul></ul>")
-                            .addClass('column')
-                            .attr('colindex',parseInt(colIndex, 10));
-                        $.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 colIndex2 = $(this).parent().attr('colindex');
-                                    if (colIndex>colIndex2) {
-                                        killCol(colIndex2);
-                                        colIndex = colIndex2;
-                                    }
-                                    var hasClass = $(this).hasClass('selected');
-                                    if (!hasClass) {
-                                        if (val.click) {
-                                          val.click();
-                                        }
-                                        if (val.next) {
-                                          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 - colIndex)
-                            .css("left",-ul.outerWidth())
-                            .animate({ 
-                                left: width + "px"
-                            },750);
-                  };*/
-              </script>
               <video id="webmademovies" width="530" height="299" data-timeline-sources="xml/webMadeMovies.xml" controls loop>
                 <source src="http://webmademovies.etherworks.ca/popcorndemo/wmmjuly6.ogv" type='video/ogg; codecs="theora, vorbis"'>
                 <source src="http://webmademovies.etherworks.ca/popcorndemo/wmmjuly6.mp4" type='video/mp4; codecs="avc1.42E01E, mp4a.40.2"'>
               </video>
               <div id="overlaydiv" style="position:absolute;top:1px;left:1px"></div>
-              <script>
-                /*overlayDiv = document.getElementById("overlaydiv");
-                var createImage = function(src) {
-                  var image = document.createElement('img');
-                  image.setAttribute('src', src);
-                  image.setAttribute('style', "display:none");
-                  overlayDiv.appendChild(image);
-                  return image;
-                };
-                popcorn.VideoManager.prototype.loaded = function() {
-                  for (var i in this.commandObjects) {
-                    if (this.commandObjects[i].name === 'flickr' || this.commandObjects[i].name === 'footnote' || this.commandObjects[i].name === 'location' || this.commandObjects[i].name === 'twitter' || this.commandObjects[i].name === 'wiki' || this.commandObjects[i].name === 'lastfm') {
-                      this.commandObjects[i].extension.image = createImage("images/overlay/" + this.commandObjects[i].name + ".png");
-                      this.commandObjects[i].extension.onIn = function() {
-                        this.image.setAttribute('style', "display:inline");
-                      };
-                      this.commandObjects[i].extension.onOut = function() {
-                        this.image.setAttribute('style', "display:none");
-                      };
-                    }
-                  }
-                };*/
-              </script>
               <!-- Start Video Info -->
               <div class="video-info">
                 <!-- Start Choose Language -->
index ed2a3293e9d3de1933a8572579a6fb97351c3a57..a1cbb482c85e014d2c89ce04870d007904f1a0ad 100644 (file)
@@ -423,9 +423,8 @@ border: 1px solid #d9d9d9;
 margin-bottom: 15px;
 }
 
-.overlay{
+.applyoverlay{
 z-index: 9001;
-display: none;
 top: 0px;
 left: 0px;
 opacity: 0.2;
index c13a4a4d562badaa42efbe52626c0f064ff494a9..36b9821728cb9d5ff4b95bf2be6c5ba1e40a24e1 100644 (file)
@@ -81,7 +81,7 @@
     </articles>
   </manifest>
 
-  <timeline>
+  <timeline applyclass=".overlay: applyoverlay, parent: hover" effect="applyclass">
 
     <footnotes>
       <footnote in="00:00:00" out="00:14:00" target="footnotediv">Look around the page as info is updated!</footnote>
old mode 100755 (executable)
new mode 100644 (file)
similarity index 63%
rename from effects/expand/popcorn.expand.html
rename to effects/applyclass/popcorn.applyclass.html
index ca26d8b..a34052b
@@ -5,28 +5,29 @@
   
   <script src="../../popcorn.js"></script>
   <script src="../../plugins/footnote/popcorn.footnote.js"></script>
-  <script src="popcorn.flash.js"></script>
+  <script src="popcorn.applyclass.js"></script>
+  <link href="style.css" rel="stylesheet" type="text/css" />
   <script>
-    document.addEventListener('DOMContentLoaded', function () {
+    document.addEventListener( "DOMContentLoaded", function () {
 
-      var p = Popcorn('#video')
+      var p = Popcorn( "#video" )
       .play() 
       .footnote({
         start: 5, // seconds
         end: 15, // seconds
-        target: "footenotediv",
-        text: 'This video made exclusively for drumbeat.org',
-        effect: "flash"
+        target: "footnotediv",
+        text: "This video made exclusively for drumbeat.org",
+        effect: "applyclass",
+        applyclass: ".overlay: applyoverlay, parent: hover"
       })
       .footnote({
         start: 20, // seconds
         end: 45, // seconds
-        target: "footenotediv",
-        text: 'Visit webmademovies.org for more details',
-        effect: "flash",
-        flashcolor: "green"
-      })
-
+        target: "footnotediv",
+        text: "Visit webmademovies.org for more details",
+        effect: "applyclass",
+        applyclass: ".overlay: applyoverlay, parent: hover"
+      });
     }, false);
 
   </script>
@@ -38,7 +39,7 @@
   <div>
     <video id='video' 
       controls preload='none' 
-      width= '250px'
+      width='250px'
       poster="../../test/poster.png"> 
 
       <source id='mp4'
@@ -53,6 +54,8 @@
 
     </video> 
   </div>
-  <div id="footenotediv"></div>
+    <section>
+      <div id="footnotediv"><div class="overlay"></div></div>
+    </section>
 </body>
 </html>
diff --git a/effects/applyclass/popcorn.applyclass.js b/effects/applyclass/popcorn.applyclass.js
new file mode 100644 (file)
index 0000000..3718409
--- /dev/null
@@ -0,0 +1,88 @@
+// EFFECT: applyclass
+
+(function (Popcorn) {
+
+  /**
+   * apply css class to jquery selector
+   * selector is relative to plugin target's id
+   * so .overlay is actually $( "#target .overlay")
+   *
+   * @param {Object} options
+   * 
+   * Example:
+     var p = Popcorn('#video')
+        .footnote({
+          start: 5, // seconds
+          end: 15, // seconds
+          text: 'This video made exclusively for drumbeat.org',
+          target: 'footnotediv',
+          effect: 'applyclass',
+          applyclass: 'selector: class'
+        })
+   *
+   */
+
+  var startFunction = Popcorn.nop,
+      applyFunction = function() {
+
+        startFunction = function( event, options ) {
+
+          Popcorn.forEach( options.classes, function( val, key ) {
+
+            var obj;
+            if ( key === "parent" ) {
+
+              obj = $("#" + options.target ).parent();
+            } else {
+
+              obj = $("#" + options.target + " " + key );
+            }
+
+            obj.addClass( val );
+            setTimeout( function() {
+
+              obj.removeClass( val );
+            }, 250 );
+          });
+        };
+      };
+
+  if ( typeof $ !== "undefined" ) {
+
+    applyFunction();
+  } else {
+
+    Popcorn.getScript( "http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js", applyFunction );
+  }
+
+  Popcorn.compose( "applyclass", {
+    
+    manifest: {
+      about: {
+        name: "Popcorn applyclass Effect",
+        version: "0.1",
+        author: "@scottdowne",
+        website: "scottdowne.wordpress.com"
+      },
+      options: {}
+    },
+    _setup: function( options ) {
+
+      options.classes = {};
+
+      var array = options.applyclass.replace( /\s/g, "" ).split( "," ),
+          item = [],
+          idx = 0, len = array.length;
+
+      for ( ; idx < len; idx++ ) {
+
+        item = array[ idx ].split( ":");
+        options.classes[ item[ 0 ] ] = item[ 1 ];
+      }
+    },
+    start: function( event, options ) {
+
+      startFunction.call( this, event, options );
+    }
+  });
+})( Popcorn );
diff --git a/effects/applyclass/style.css b/effects/applyclass/style.css
new file mode 100644 (file)
index 0000000..acfaa28
--- /dev/null
@@ -0,0 +1,26 @@
+.applyoverlay {
+  z-index: 9001;
+  top: 0px;
+  left: 0px;
+  opacity: 0.2;
+  filter: alpha(opacity=20);
+  height: 100%;
+  width: 100%;
+  background: red;
+  position: absolute;
+}
+
+section {
+  display: inline-block;
+}
+
+section.hover {
+  -webkit-box-shadow: -1px 1px 1px #bdc7c6;
+  -moz-box-shadow: -1px 1px 1px #bdc7c6;
+  box-shadow:  -1px 1px 1px #bdc7c6;
+  border: 1px solid #333;
+  -moz-transform: scale(1.02);-webkit-transform: scale(1.02);
+  z-index: 999;
+  background: #FFF;
+}
+
diff --git a/effects/expand/popcorn.expand.js b/effects/expand/popcorn.expand.js
deleted file mode 100755 (executable)
index 6c77e09..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-// EFFECT: flash
-
-(function (Popcorn) {
-
-  /**
-   * Flash effect 
-   * Adds a coloured flash to the background of plugins.
-   * Optional parameters are flashcolor, which accepts a css colour. Defaults to red.
-   * 
-   * @param {Object} options
-   * 
-   * Example:
-     var p = Popcorn('#video')
-        .footnote({
-          start: 5, // seconds
-          end: 15, // seconds
-          text: 'This video made exclusively for drumbeat.org',
-          target: 'footnotediv',
-          effect: 'flash',
-          flashcolor: "green"
-        } )
-   *
-   */
-
-  var startFunction = Popcorn.nop,
-      endFunction = Popcorn.nop;
-
-  Popcorn.getScript( "http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js", function() {
-    startFunction = function( event, options ) {
-
-      $( options.redDiv ).css( "display", "inline" ).css( "left", 0 ).fadeOut( 250 );
-    };
-  });
-
-  Popcorn.compose( "flash" , {
-    
-    manifest: {
-      about:{
-        name: "Popcorn flash Effect",
-        version: "0.1",
-        author: "@scottdowne",
-        website: "scottdowne.wordpress.com"
-      },
-      options:{
-        effect: true
-      }
-    },
-    _setup: function( options ) {
-
-      options.redDiv = document.createElement( "span" );
-      options.redDiv.style.position = "absolute";
-      options.redDiv.style.opacity = 0.8;
-      options.redDiv.style.backgroundColor = options.flashcolor || "red";
-      options.redDiv.style.height = "100%";
-      options.redDiv.style.width = "100%";
-      options.redDiv.style.zindex = options._container.style.zIndex + 1;
-      options.redDiv.style.display = "none";
-
-      options._container.style.position = "relative";
-      options._container.appendChild( options.redDiv );
-    },
-    start: function( event, options ) {
-
-      startFunction.call( this, event, options );
-    },
-    _teardown: function( options ) {
-
-      options.redDiv.parentNode && options._container.removeChild( options.redDiv );
-    }
-  });
-})( Popcorn );
diff --git a/effects/flash/popcorn.flash.html b/effects/flash/popcorn.flash.html
deleted file mode 100644 (file)
index ca26d8b..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
-  <title>Popcorn flash effect Demo</title>
-  
-  <script src="../../popcorn.js"></script>
-  <script src="../../plugins/footnote/popcorn.footnote.js"></script>
-  <script src="popcorn.flash.js"></script>
-  <script>
-    document.addEventListener('DOMContentLoaded', function () {
-
-      var p = Popcorn('#video')
-      .play() 
-      .footnote({
-        start: 5, // seconds
-        end: 15, // seconds
-        target: "footenotediv",
-        text: 'This video made exclusively for drumbeat.org',
-        effect: "flash"
-      })
-      .footnote({
-        start: 20, // seconds
-        end: 45, // seconds
-        target: "footenotediv",
-        text: 'Visit webmademovies.org for more details',
-        effect: "flash",
-        flashcolor: "green"
-      })
-
-    }, false);
-
-  </script>
-</head>
-<body>
-  <h1 id="qunit-header">Popcorn flash effect Demo</h1>
-  <p> A footnote with a red flash displaying This video made exclusively for drumbeat.org' will appear at 5 seconds and disappear at 15 seconds.</p>
-  <p> A footnote with a green flash displaying 'Visit webmademovies.org for more details' will appear at 20 seconds and disappear at 45 seconds.</p>
-  <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>
-  <div id="footenotediv"></div>
-</body>
-</html>
diff --git a/effects/flash/popcorn.flash.js b/effects/flash/popcorn.flash.js
deleted file mode 100644 (file)
index 6c77e09..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-// EFFECT: flash
-
-(function (Popcorn) {
-
-  /**
-   * Flash effect 
-   * Adds a coloured flash to the background of plugins.
-   * Optional parameters are flashcolor, which accepts a css colour. Defaults to red.
-   * 
-   * @param {Object} options
-   * 
-   * Example:
-     var p = Popcorn('#video')
-        .footnote({
-          start: 5, // seconds
-          end: 15, // seconds
-          text: 'This video made exclusively for drumbeat.org',
-          target: 'footnotediv',
-          effect: 'flash',
-          flashcolor: "green"
-        } )
-   *
-   */
-
-  var startFunction = Popcorn.nop,
-      endFunction = Popcorn.nop;
-
-  Popcorn.getScript( "http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js", function() {
-    startFunction = function( event, options ) {
-
-      $( options.redDiv ).css( "display", "inline" ).css( "left", 0 ).fadeOut( 250 );
-    };
-  });
-
-  Popcorn.compose( "flash" , {
-    
-    manifest: {
-      about:{
-        name: "Popcorn flash Effect",
-        version: "0.1",
-        author: "@scottdowne",
-        website: "scottdowne.wordpress.com"
-      },
-      options:{
-        effect: true
-      }
-    },
-    _setup: function( options ) {
-
-      options.redDiv = document.createElement( "span" );
-      options.redDiv.style.position = "absolute";
-      options.redDiv.style.opacity = 0.8;
-      options.redDiv.style.backgroundColor = options.flashcolor || "red";
-      options.redDiv.style.height = "100%";
-      options.redDiv.style.width = "100%";
-      options.redDiv.style.zindex = options._container.style.zIndex + 1;
-      options.redDiv.style.display = "none";
-
-      options._container.style.position = "relative";
-      options._container.appendChild( options.redDiv );
-    },
-    start: function( event, options ) {
-
-      startFunction.call( this, event, options );
-    },
-    _teardown: function( options ) {
-
-      options.redDiv.parentNode && options._container.removeChild( options.redDiv );
-    }
-  });
-})( Popcorn );