From: ScottDowne Date: Thu, 9 Dec 2010 18:49:12 +0000 (-0500) Subject: [#116] update to current 0.2 X-Git-Tag: v0.2~52^2~16 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=437b3c40563beef7dc936a37f99a76db1ff56573;p=popcorn-js.git [#116] update to current 0.2 --- 437b3c40563beef7dc936a37f99a76db1ff56573 diff --cc popcorn.js index bb2937d,36e2b66..7f7318b --- a/popcorn.js +++ b/popcorn.js @@@ -336,27 -391,22 +403,22 @@@ // 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; } diff --cc test/popcorn.unit.js index 6e5020e,0d2ddf6..4cf645f --- a/test/popcorn.unit.js +++ b/test/popcorn.unit.js @@@ -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(); @@@ -441,26 -401,18 +442,25 @@@ // 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 () {