]> khamidou — GitHub mirrors - popcorn-js.git/commitdiff
[#t366] simplified the applyclass signature for most use cases
authorScottDowne <sdowne@learn.senecac.on.ca>
Wed, 22 Jun 2011 15:27:00 +0000 (11:27 -0400)
committerScottDowne <sdowne@learn.senecac.on.ca>
Wed, 22 Jun 2011 15:27:00 +0000 (11:27 -0400)
demos/semantic_video/xml/webMadeMovies.xml
effects/applyclass/popcorn.applyclass.html
effects/applyclass/popcorn.applyclass.js

index 36b9821728cb9d5ff4b95bf2be6c5ba1e40a24e1..21145bc8b52a0c75199930a8ea98aaf77cb7a5c1 100644 (file)
@@ -81,7 +81,7 @@
     </articles>
   </manifest>
 
-  <timeline applyclass=".overlay: applyoverlay, parent: hover" effect="applyclass">
+  <timeline applyclass="applyoverlay: .overlay, hover: parent" effect="applyclass">
 
     <footnotes>
       <footnote in="00:00:00" out="00:14:00" target="footnotediv">Look around the page as info is updated!</footnote>
index a34052b075f0387d7c94d370fb9fdf66a0bf5a06..3b0903d02828d9dc6be423f16be8d689755149f5 100644 (file)
         target: "footnotediv",
         text: "This video made exclusively for drumbeat.org",
         effect: "applyclass",
-        applyclass: ".overlay: applyoverlay, parent: hover"
+        applyclass: "applyoverlay: .overlay, hover: parent"
       })
       .footnote({
         start: 20, // seconds
         end: 45, // seconds
-        target: "footnotediv",
+        target: "footnotediv2",
         text: "Visit webmademovies.org for more details",
         effect: "applyclass",
-        applyclass: ".overlay: applyoverlay, parent: hover"
+        applyclass: "applyoverlay: .overlay, hover: parent"
       });
     }, false);
 
index c045295279b5280c568175d27a1765ae338193bb..cc76fdc2416341f8f29a785e64fdc1fb7e254bfa 100644 (file)
    *
    */
 
-  var startFunction = Popcorn.nop,
-      applyFunction = function() {
+  var toggleClass = function( event, options ) {
 
-        if ( !window.jQuery ) {
+    var idx = 0, len = 0, elements;
 
-          Popcorn.getScript( "http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js", applyFunction );
-          return;
-        }
+    Popcorn.forEach( options.classes, function( key, val ) {
 
-        startFunction = function( event, options ) {
+      elements = [];
 
-          Popcorn.forEach( options.classes, function( val, key ) {
+      if ( key === "parent" ) {
 
-            var obj;
-            if ( key === "parent" ) {
+        elements[ 0 ] = document.querySelectorAll("#" + options.target )[ 0 ].parentNode;
+      } else {
 
-              obj = jQuery("#" + options.target ).parent();
-            } else {
-
-              obj = jQuery("#" + options.target + " " + key );
-            }
+        elements = document.querySelectorAll("#" + options.target + " " + key );
+      }
 
-            obj.addClass( val );
-            setTimeout( function() {
+      for ( idx = 0, len = elements.length; idx < len; idx++ ) {
 
-              obj.removeClass( val );
-            }, 250 );
-          });
-        };
-      };
+        var element = elements[ idx ];
 
-  applyFunction();
+        element.classList.toggle( val );
+      }
+    });
+  };
 
   Popcorn.compose( "applyclass", {
     
       for ( ; idx < len; idx++ ) {
 
         item = array[ idx ].split( ":");
-        options.classes[ item[ 0 ] ] = item[ 1 ];
+        options.classes[ item[ 0 ] ] = item[ 1 ] || "";
       }
     },
-    start: function( event, options ) {
-
-      startFunction.call( this, event, options );
-    }
+    start: toggleClass,
+    end: toggleClass
   });
 })( Popcorn );