]> khamidou — GitHub mirrors - popcorn-js.git/commitdiff
[#470] inherit options object
authorScottDowne <sdowne@learn.senecac.on.ca>
Tue, 12 Apr 2011 17:58:06 +0000 (13:58 -0400)
committerScottDowne <sdowne@learn.senecac.on.ca>
Tue, 12 Apr 2011 17:58:06 +0000 (13:58 -0400)
popcorn.js
test/popcorn.unit.js

index 42b1feee11f239711bf91befcdbff767574c3b4b..62665390a57bd50c15503caaecd63841f8478475 100644 (file)
   Popcorn.plugin.delegate = function( instance, name, plugins ) {
 
     return function() {
+      var args = arguments;
       plugins.forEach( function( plugin ) {
         // The new plugin simply calls the delegated methods on
         // all of its parents in the order they were specified.
-        plugin[ name ] && plugin[ name ].apply( instance, arguments );
+        plugin[ name ] && plugin[ name ].apply( instance, args );
       });
     };
   };
index e60e8f27c14f06f2cec377b13634ea005b2737e4..e1e5a2c38c8f8a0cbb9edc13922b82c08aeca965 100644 (file)
@@ -817,7 +817,7 @@ test("Plugin Factory", function () {
 
   var popped = Popcorn("#video"),
       methods = "load play pause currentTime mute volume roundTime exec removePlugin",
-      expects = 80, // 15*2+16*2+6+12. executor/complicator each do 15
+      expects = 96, // 15*2+16*2+6+12. executor/complicator each do 15
       count = 0;    
 
   function plus() {
@@ -832,6 +832,8 @@ test("Plugin Factory", function () {
       Popcorn.removePlugin("D");
       Popcorn.removePlugin("E");
       Popcorn.removePlugin("F");
+      Popcorn.removePlugin("optionTest1");
+      Popcorn.removePlugin("optionTest2");
       start();
     }
   }
@@ -1008,6 +1010,59 @@ test("Plugin Factory", function () {
     plus();    
   }, 10000);
 
+  Popcorn.plugin( "optionTest1", {
+    _setup: function( options ) {
+      options.item = "exist";
+      equals( options.data[ 0 ], "parent", "parent plugin _setup options.data" );
+      plus();
+    },
+    start: function( event, options ) {
+      equals( options.item, "exist", "parent plugin start options.item" );
+      plus();
+      equals( options.data[ 0 ], "parent", "parent plugin start options.data" );
+      plus();
+    },
+    end: function( event, options ) {
+      equals( options.item, "exist", "parent plugin end options.item" );
+      plus();
+      equals( options.data[ 0 ], "parent", "parent plugin end options.data" );
+      plus();
+    }
+  });
+
+  Popcorn.inherit( "optionTest2", "optionTest1", {
+    _setup: function( options ) {
+      equals( options.item, "exist", "child plugin _setup options.item" );
+      plus();
+      equals( options.data[ 1 ], "child", "child plugin _setup options.data" );
+      plus();
+    },
+    start: function( event, options ) {
+      equals( options.item, "exist", "child plugin start options.item" );
+      plus();
+      equals( options.data[ 1 ], "child", "child plugin start options.data" );
+      plus();
+    },
+    end: function( event, options ) {
+      equals( options.item, "exist", "child plugin end options.item" );
+      plus();
+      equals( options.data[ 1 ], "child", "child plugin end options.data" );
+      plus();
+    }
+  });
+
+  popped.optionTest1({
+    start: 6,
+    end: 7,
+    data: [ "parent" ]
+  })
+  .optionTest2({
+    start: 7,
+    end: 8,
+    data: [ "parent", "child" ]
+  })
+  
+
   popped.currentTime(0).play();
 
 });