]> khamidou — GitHub mirrors - popcorn-js.git/commitdiff
[#116] update to current 0.2
authorScottDowne <sdowne@learn.senecac.on.ca>
Thu, 9 Dec 2010 18:49:12 +0000 (13:49 -0500)
committerScottDowne <sdowne@learn.senecac.on.ca>
Thu, 9 Dec 2010 18:49:12 +0000 (13:49 -0500)
1  2 
popcorn.js
test/popcorn.unit.js

diff --cc popcorn.js
index bb2937df4864ca2208fd4d23850554e31bf58d9f,36e2b66b7803206a2c3fc437228dfdf28c74a3d3..7f7318b63162d89c442b17a6e214b637ef8df7a2
      //  the definition into Popcorn.p 
      
      var natives = Popcorn.events.all, 
-         reserved = [ "start", "end", "timeupdate" ], 
-         plugin = {}, 
++
+         reserved = [ "start", "end"], 
+         plugin = {},
 +        pluginFn, 
          setup;
      
 -    
 -    
      if ( typeof definition === "object" ) {
        
        setup = definition;
        
-       if ( !( "timeupdate" in setup ) ) {
+       /*if ( !( "timeupdate" in setup ) ) {
          setup.timeupdate = Popcorn.nop;
-       }         
+       }*/        
  
 -      definition  = function ( options ) {
 -
 +      pluginFn  = function ( options ) {
 +        
-         var self = this, 
-             fired = {
-               start: 0, 
-               end: 0
-             };
-         
          if ( !options ) {
            return this;
          } 
index 6e5020e0f452d21cb8e08941f5aee534c7f484fa,0d2ddf68252edcd133856634475d058cc868ba2d..4cf645f2b904ce6e21e9dfbe4973b76d498655d4
@@@ -368,61 -350,40 +368,62 @@@ test("Plugin Factory", function () 
    // needs expectation
  
    var popped = Popcorn("#video"), 
 -      methods = "load play pause currentTime mute volume";
 -      
 -  
 -  stop();
 +      methods = "load play pause currentTime mute volume roundTime exec",
 +      expects = 22, 
 +      count = 0;
    
 +  //expect(expects);
    
 -  Popcorn.plugin("subtitles", function () {
 -    
 -    var self = this;
 -    
 -    // These ensure that a popcorn instance is the value of `this` inside a plugin definition
 +  function plus() { 
 +    console.log(count);
 +    if ( ++count == expects ) {
 +      start(); 
 +    }
 +  }
 +
 +  stop();
 +
 +  Popcorn.plugin("executor", function () {
      
 -    methods.split(/\s+/g).forEach(function (k,v) {
 -      ok( k in self, "instance has method: " + k );
 -    });
 +    return {
 +      
 +      start: function () {
 +        var self = this;
  
 -    ok( "video" in this, "instance has `video` property" );
 -    ok( Object.prototype.toString.call(popped.video) === "[object HTMLVideoElement]", "video property is a HTMLVideoElement" );
 +        // These ensure that a popcorn instance is the value of `this` inside a plugin definition
  
 -    ok( "data" in this, "instance has `data` property" );
 -    ok( Object.prototype.toString.call(popped.data) === "[object Object]", "data property is an object" );
 +        methods.split(/\s+/g).forEach(function (k,v) {
 +          ok( k in self, "executor instance has method: " + k );
 +          
 +          plus();
 +        });
 +
 +        ok( "video" in this, "executor instance has `video` property" );
 +        plus();
 +        ok( Object.prototype.toString.call(popped.video) === "[object HTMLVideoElement]", "video property is a HTMLVideoElement" );
 +        plus();
 +
 +        ok( "data" in this, "executor instance has `data` property" );
 +        plus();
 +        ok( Object.prototype.toString.call(popped.data) === "[object Object]", "data property is an object" );
 +        plus();
 +
 +        ok( "tracks" in this.data, "executor instance has `tracks` property" );
 +        plus();
 +        ok( Object.prototype.toString.call(popped.data.tracks) === "[object Array]", "executor tracks property is an array" )      
 +        plus();      
 +      }, 
 +      end: function () {
 +      
 +      }
 +    };
+ 
 -    ok( "tracks" in this.data, "instance has `tracks` property" );
 -    ok( Object.prototype.toString.call(popped.data.tracks) === "[object Object]", "tracks property is an object" )
    });
 -  
 -  
 -  //  Call plugin to test scope within 
 -  popped.subtitles();
 -  
 -  
 -  
 -  ok( "subtitles" in popped, "subtitles plugin is now available to instance" );
 + 
 +  ok( "executor" in popped, "executor plugin is now available to instance" );
 +  plus();
    ok( Popcorn.registry.length === 1, "One item in the registry");
 +  plus();    
    
    
    
        // These ensure that a popcorn instance is the value of `this` inside a plugin definition
  
        methods.split(/\s+/g).forEach(function (k,v) {
 -        ok( k in self, "instance has method: " + k );
 +        ok( k in self, "complicator instance has method: " + k );
 +        
 +        plus();
        });
  
 -      ok( "video" in this, "instance has `video` property" );
 +      ok( "video" in this, "complicator instance has `video` property" );
 +      plus();
        ok( Object.prototype.toString.call(popped.video) === "[object HTMLVideoElement]", "video property is a HTMLVideoElement" );
 +      plus();
  
 -      ok( "data" in this, "instance has `data` property" );
 -      ok( Object.prototype.toString.call(popped.data) === "[object Object]", "data property is an object" );
 +      ok( "data" in this, "complicator instance has `data` property" );
 +      plus();
 +      ok( Object.prototype.toString.call(popped.data) === "[object Object]", "complicator data property is an object" );
 +      plus();
  
 -      ok( "tracks" in this.data, "instance has `tracks` property" );
 -      ok( Object.prototype.toString.call(popped.data.tracks) === "[object Object]", "tracks property is an object" )      
 -      
 +      ok( "tracks" in this.data, " complicatorinstance has `tracks` property" );
 +      plus();
 +      ok( Object.prototype.toString.call(popped.data.tracks) === "[object Array]", "complicator tracks property is an array" )      
-       plus();
-       
++      plus();     
      },
      end: function () {