From 8516b4e6871463b82585a107246e4b8407d3e535 Mon Sep 17 00:00:00 2001 From: "Rick Waldron waldron.rick@gmail.com" Date: Mon, 5 Mar 2012 10:52:44 -0500 Subject: [PATCH 1/4] [#935] Log warnings for deprecated methods. listen=>on, unlisten=>off Signed-off-by: Rick Waldron waldron.rick@gmail.com --- popcorn.js | 24 +++++++-- test/popcorn.unit.js | 118 ++++++++++++++++++++++++------------------- 2 files changed, 88 insertions(+), 54 deletions(-) diff --git a/popcorn.js b/popcorn.js index 0b949f06..a7ab9339 100644 --- a/popcorn.js +++ b/popcorn.js @@ -1476,7 +1476,7 @@ if ( reserved.indexOf( type ) === -1 ) { - this.listen( type, callback ); + this.on( type, callback ); } } @@ -1488,11 +1488,11 @@ // Extend Popcorn.p with new named definition // Assign new named definition Popcorn.p[ name ] = plugin[ name ] = function( options ) { - + // Merge with defaults if they exist, make sure per call is prioritized var defaults = ( this.options.defaults && this.options.defaults[ name ] ) || {}, mergedSetupOpts = Popcorn.extend( {}, defaults, options ); - + return pluginFn.call( this, isfn ? definition.call( this, mergedSetupOpts ) : definition, mergedSetupOpts ); }; @@ -1889,6 +1889,24 @@ }) }; + // Setup logging for deprecated methods + Popcorn.forEach({ + // Deprecated: Recommended + "listen": "on", + "unlisten": "off" + + }, function( recommend, api ) { + var _saved = Popcorn.p[ api ]; + + Popcorn.p[ api ] = function() { + if ( console && console.warn ) { + console.warn( "Deprecated method '" + api + "', use '" + recommend + "' instead." ); + } + return Popcorn.p[ recommend ].apply( this, [].slice.call( arguments ) ); + }; + }); + + // Exposes Popcorn to global context global.Popcorn = Popcorn; diff --git a/test/popcorn.unit.js b/test/popcorn.unit.js index ea43ebd6..2e28fcc3 100644 --- a/test/popcorn.unit.js +++ b/test/popcorn.unit.js @@ -740,6 +740,22 @@ test( "Popcorn.[addTrackEvent | removeTrackEvent].ref()", function() { module( "Popcorn Prototype Methods" ); +test( "deprecated method warning", function() { + expect( 2 ); + + var $pop = Popcorn( "#video" ), + handler = function() {}, + oldwarn = console.warn; + + // Intercept console.warn messages + console.warn = function() { + ok( true, "warning logged: " + arguments[0] ); + return oldwarn.apply( console, [].slice.call(arguments) ); + }; + + $pop.listen( "foo", handler).trigger( "foo" ).unlisten( "foo", handler ); +}); + test( "roundTime", function() { QUnit.reset(); @@ -748,8 +764,8 @@ test( "roundTime", function() { var popped = Popcorn( "#video" ); - popped.listen( "canplayall", function() { - popped.unlisten( "canplayall" ); + popped.on( "canplayall", function() { + popped.off( "canplayall" ); popped.play().pause().currentTime( 0.98 ); equal( 1, popped.roundTime(), ".roundTime() returns 1 when currentTime is 0.98s" ); @@ -822,27 +838,27 @@ test( "mute", function() { stop(); - video.listen( "muted", function() { + video.on( "muted", function() { equal( this.media.muted, true, "Video `muted` attribute is true when muted" ); plus(); this.unmute(); - }).listen( "unmuted", function() { + }).on( "unmuted", function() { equal( this.media.muted, false, "Video `muted` attribute is false when unmuted" ); plus(); }); - audio.listen( "muted", function() { + audio.on( "muted", function() { equal( this.media.muted, true, "Audio `muted` attribute is true when muted" ); plus(); this.unmute(); - }).listen( "unmuted", function() { + }).on( "unmuted", function() { equal( this.media.muted, false, "Audio `muted` attribute is false when unmuted" ); plus(); @@ -875,21 +891,21 @@ test( "play(n)/pause(n) as shorthand to currentTime(n).play()/pause()", function // this should trigger immediately var firstSeekedEvent = function() { - $pop.unlisten( "seeked", firstSeekedEvent ); + $pop.off( "seeked", firstSeekedEvent ); equal( Math.round( $pop.currentTime() ), 10, "play(n) sets currentTime to 10" ); plus(); - - $pop.listen( "seeked", secondSeekedEvent ); + + $pop.on( "seeked", secondSeekedEvent ); $pop.pause( 5 ); }, secondSeekedEvent = function() { - $pop.unlisten( "seeked", secondSeekedEvent ); + $pop.off( "seeked", secondSeekedEvent ); equal( Math.round( $pop.currentTime() ), 5, "pause(n) sets currentTime to 5" ); plus(); }; - - $pop.listen( "seeked", firstSeekedEvent ); + + $pop.on( "seeked", firstSeekedEvent ); $pop.play( 10 ).pause(); } else { setTimeout( poll, 10 ); @@ -926,7 +942,7 @@ test( "play(n)/pause(n) custom stop()", function() { if ( ++count === expects ) { // Remove custom stop() method delete Popcorn.p.stop; - $pop.unlisten( "canplayall" ); + $pop.off( "canplayall" ); $pop.destroy(); start(); } @@ -934,7 +950,7 @@ test( "play(n)/pause(n) custom stop()", function() { stop( 8000 ); - $pop.listen( "canplayall", function() { + $pop.on( "canplayall", function() { this.exec( 4, function() { @@ -1052,8 +1068,8 @@ test( "Popcorn.events.hooks: canplayall", function() { function plus(){ if ( ++count == expects ) { - $pop.unlisten( "canplayall"); - $pop.unlisten( "canplaythrough" ); + $pop.off( "canplayall"); + $pop.off( "canplaythrough" ); $pop.destroy(); start(); } @@ -1084,12 +1100,12 @@ test( "Popcorn.events.hooks: canplayall", function() { $pop = Popcorn( "#event-fixture" ); - $pop.listen( "canplayall", function( event ) { + $pop.on( "canplayall", function( event ) { equal( ++fired, 1, "canplayall is fired only once" ); plus(); }); - $pop.listen( "canplaythrough", function( event ) { + $pop.on( "canplaythrough", function( event ) { // this should trigger re-fires of the original event this.currentTime( 0 ); }); @@ -1117,8 +1133,8 @@ test( "Popcorn.events.hooks: canplayall fires immediately if ready", function() function poll() { if ( $pop.media.readyState >= 2 ) { // this should trigger immediately - $pop.listen( "canplayall", function( event ) { - this.unlisten( "canplayall" ); + $pop.on( "canplayall", function( event ) { + this.off( "canplayall" ); equal( ++fired, 1, "canplayall is fired immediately if readyState permits" ); plus(); }); @@ -1339,7 +1355,7 @@ test( "Stored By Type", function() { equal( fired, wants, "Number of callbacks fired from 1 handler" ); - p.unlisten( "play" ); + p.off( "play" ); ok( !p.data.events[ "play" ], "play handlers removed" ); @@ -1351,28 +1367,28 @@ test( "Stored By Type", function() { stop( 10000 ); - p.listen( "play", function() { + p.on( "play", function() { fired++; ok( true, "Play fired " + fired ); plus(); }); - p.listen( "play", function() { + p.on( "play", function() { fired++; ok( true, "Play fired " + fired ); plus(); }); - p.listen( "play", function() { + p.on( "play", function() { fired++; ok( true, "Play fired " + fired ); plus(); }); - p.listen( "play", function() { + p.on( "play", function() { fired++; ok( true, "Play fired " + fired ); @@ -1385,7 +1401,7 @@ test( "Stored By Type", function() { start(); } - p.unlisten( "play" ); + p.off( "play" ); }); @@ -1411,13 +1427,13 @@ test( "Simulated", function() { stop( 10000 ); Setup.events.forEach(function( name ) { - p.listen( name, function( event ) { + p.on( name, function( event ) { if ( completed.indexOf( name ) === -1 ) { ok( true, name + " fired" ); plus(); completed.push( name ); - this.unlisten( name ); + this.off( name ); } }); }); @@ -1448,18 +1464,18 @@ test( "Real", function() { [ "play", "pause", "volumechange", "seeking", "seeked" ].forEach(function( name ) { - p.listen( name, function( event ) { + p.on( name, function( event ) { if ( completed.indexOf( name ) === -1 ) { ok( true, name + " fired" ); plus(); completed.push( name ); - p.unlisten( name ); + p.off( name ); } }); }); - p.listen( "canplayall", function() { - this.unlisten( "canplayall" ); + p.on( "canplayall", function() { + this.off( "canplayall" ); this.pause(); this.play(); this.volume( 0.9 ); @@ -1477,7 +1493,7 @@ test( "Custom", function() { function plus(){ if ( ++count == expects ) { - p.unlisten( "eventz0rz" ); + p.off( "eventz0rz" ); p.destroy() start(); } @@ -1488,7 +1504,7 @@ test( "Custom", function() { p = Popcorn( "#video" ); - p.listen( "eventz0rz", function( event ) { + p.on( "eventz0rz", function( event ) { ok( true, "Custom event fired" ); plus(); @@ -1526,7 +1542,7 @@ test( "UI/Mouse", function() { function plus(){ if ( ++count == expects ) { - p.unlisten( "click" ); + p.off( "click" ); p.destroy(); start(); } @@ -1536,7 +1552,7 @@ test( "UI/Mouse", function() { p = Popcorn( "#video" ); - p.listen( "click", function( event ) { + p.on( "click", function( event ) { ok( true, "click event fired" ); plus(); @@ -1766,7 +1782,7 @@ test( "Configurable Defaults", function() { p.defaults( "funtionInitDefaults", { defaultItem: "foo bar" }); - + p.funtionInitDefaults({}); p.defaults( "configurable", { @@ -1888,7 +1904,7 @@ test( "Exceptions", function() { } }); - $pop.listen( "canplayall", function() { + $pop.on( "canplayall", function() { this.exceptions({ start: 1, end: 2 @@ -1897,7 +1913,7 @@ test( "Exceptions", function() { plus(); }).currentTime( 0 ).play(); - this.listen( "error", function( errors ) { + this.on( "error", function( errors ) { ok( errors.length, "`errors` array has error objects" ); plus(); ok( errors[ 0 ].thrown, "`errors[ 0 ].thrown` property exists" ); @@ -1974,7 +1990,7 @@ test( "Special track event listeners: trackstart, trackend", function() { $pop.emitter({ start: 1, end: 3 - }).listen( "trackstart", function( event ) { + }).on( "trackstart", function( event ) { equal( event.type, "trackstart", "Special trackstart event object includes correct type" ); plus(); @@ -1983,7 +1999,7 @@ test( "Special track event listeners: trackstart, trackend", function() { equal( event.plugin, "emitter", "Special trackstart event object includes correct plugin name" ); plus(); - }).listen( "trackend", function( event ) { + }).on( "trackend", function( event ) { equal( event.type, "trackend", "Special trackend event object includes correct type" ); plus(); @@ -2557,8 +2573,8 @@ test( "Popcorn Compose", function() { } }; - popped.listen( "seeked", function() { - this.unlisten( "seeked" ); + popped.on( "seeked", function() { + this.off( "seeked" ); this.play( 0 ); }); @@ -2864,7 +2880,7 @@ test( "Teardown end noise", function() { stop( 15000 ); Popcorn.plugin( "noise", {}); - + Popcorn.plugin( "teardownEndTester", { _setup: function( options ) { options.endCalled = false; @@ -3077,8 +3093,8 @@ test( "Remove Plugin", function() { expect( expects ); stop( 10000 ); - p.listen( "seeked", function() { - this.unlisten( "seeked" ); + p.on( "seeked", function() { + this.off( "seeked" ); equal( rlen, 0, "Popcorn.registry.length is empty" ); plus(); @@ -3297,8 +3313,8 @@ test( "In/Out aliases", function() { out: 3 }); - popcorn.listen( "seeked", function() { - this.unlisten( "seeked" ).play( 0 ); + popcorn.on( "seeked", function() { + this.off( "seeked" ).play( 0 ); }) popcorn.currentTime( 0 ).pause(); @@ -3527,7 +3543,7 @@ test( "Index Integrity ( removing tracks )", function() { plus(); }); - $pop.listen( "canplayall", function() { + $pop.on( "canplayall", function() { this.volume( 0 ).play( 0 ); }); }); @@ -3571,7 +3587,7 @@ test( "Index Integrity ( timeUpdate )", function() { equal( $pop.data.trackEvents.startIndex, 1, "$pop.data.trackEvents.startIndex is 1" ); plus(); - $pop.listen( "canplayall", function() { + $pop.on( "canplayall", function() { $pop.ff({ id: "removeable-track-event", @@ -3642,7 +3658,7 @@ test( "Index Integrity (frameAnimation)", function() { equal( $pop.data.trackEvents.startIndex, 1, "$pop.data.trackEvents.startIndex is 1" ); plus(); - $pop.listen( "canplayall", function() { + $pop.on( "canplayall", function() { $pop.ff({ id: "removeable-track-event", From 6e8a75b4c13585952fdde8162414e7aede610e1c Mon Sep 17 00:00:00 2001 From: "Rick Waldron waldron.rick@gmail.com" Date: Mon, 5 Mar 2012 10:58:27 -0500 Subject: [PATCH 2/4] [#935] Cleanup, adds comments about approach Signed-off-by: Rick Waldron waldron.rick@gmail.com --- popcorn.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/popcorn.js b/popcorn.js index a7ab9339..e7ecbb57 100644 --- a/popcorn.js +++ b/popcorn.js @@ -1896,8 +1896,8 @@ "unlisten": "off" }, function( recommend, api ) { - var _saved = Popcorn.p[ api ]; - + // Override the deprecated api method with a method of the same name + // that logs a warning and defers to the new recommended method Popcorn.p[ api ] = function() { if ( console && console.warn ) { console.warn( "Deprecated method '" + api + "', use '" + recommend + "' instead." ); From fbbf3133e3c17c2fc22fb930d7b8ea62cf5a561c Mon Sep 17 00:00:00 2001 From: "Rick Waldron waldron.rick@gmail.com" Date: Mon, 5 Mar 2012 11:59:41 -0500 Subject: [PATCH 3/4] [#935] Add null handler; trigger=>emit,exec=>cue; Signed-off-by: Rick Waldron waldron.rick@gmail.com --- popcorn.js | 11 +++-- test/popcorn.unit.js | 98 ++++++++++++++++++++++++-------------------- 2 files changed, 61 insertions(+), 48 deletions(-) diff --git a/popcorn.js b/popcorn.js index e7ecbb57..6b297d60 100644 --- a/popcorn.js +++ b/popcorn.js @@ -545,7 +545,7 @@ _natives: { start: fn || Popcorn.nop, end: Popcorn.nop, - type: "exec" + type: "cue" } }); @@ -1893,14 +1893,19 @@ Popcorn.forEach({ // Deprecated: Recommended "listen": "on", - "unlisten": "off" + "unlisten": "off", + "trigger": "emit", + "exec": "cue" }, function( recommend, api ) { // Override the deprecated api method with a method of the same name // that logs a warning and defers to the new recommended method Popcorn.p[ api ] = function() { if ( console && console.warn ) { - console.warn( "Deprecated method '" + api + "', use '" + recommend + "' instead." ); + console.warn( + "Deprecated method '" + api + "', " + + (recommend == null ? "do not use." : "use '" + recommend + "' instead." ) + ); } return Popcorn.p[ recommend ].apply( this, [].slice.call( arguments ) ); }; diff --git a/test/popcorn.unit.js b/test/popcorn.unit.js index 2e28fcc3..48348238 100644 --- a/test/popcorn.unit.js +++ b/test/popcorn.unit.js @@ -133,7 +133,7 @@ test( "Popcorn.getTrackEvents", function() { equal( Popcorn.getTrackEvents( popcorn ).length, 0, "Popcorn.getTrackEvents() currently has no trackEvents" ); - popcorn.exec( 1, function(){ }); + popcorn.cue( 1, function(){ }); equal( Popcorn.getTrackEvents( popcorn ).length, 1, "Currently only one track event" ); @@ -725,9 +725,9 @@ test( "Popcorn.[addTrackEvent | removeTrackEvent].ref()", function() { // Calling exec() will create tracks and added them to the // trackreference internally - popped.exec( 1, function() { /* ... */ }); - popped.exec( 3, function() { /* ... */ }); - popped.exec( 5, function() { /* ... */ }); + popped.cue( 1, function() { /* ... */ }); + popped.cue( 3, function() { /* ... */ }); + popped.cue( 5, function() { /* ... */ }); equal( Popcorn.sizeOf( popped.data.trackRefs ), 3, "There are 3 trackRefs in popped.data.trackRefs" ); @@ -741,16 +741,21 @@ test( "Popcorn.[addTrackEvent | removeTrackEvent].ref()", function() { module( "Popcorn Prototype Methods" ); test( "deprecated method warning", function() { - expect( 2 ); + expect( 3 ); var $pop = Popcorn( "#video" ), handler = function() {}, - oldwarn = console.warn; + oldwarn = console.warn, + count = 0; // Intercept console.warn messages console.warn = function() { - ok( true, "warning logged: " + arguments[0] ); - return oldwarn.apply( console, [].slice.call(arguments) ); + if ( ++count <= 3 ) { + ok( true, "warning logged: " + arguments[0] ); + return oldwarn.apply( console, [].slice.call(arguments) ); + } else { + console.warn = oldwarn; + } }; $pop.listen( "foo", handler).trigger( "foo" ).unlisten( "foo", handler ); @@ -791,8 +796,8 @@ test( "exec", function() { setTimeout(function() { - equal( loop, expects, "exec callback repeat check, only called twice" ); - Popcorn.removePlugin( popped, "exec" ); + equal( loop, expects, "cue callback repeat check, only called twice" ); + Popcorn.removePlugin( popped, "cue" ); start(); }, 1000 ); @@ -801,8 +806,8 @@ test( "exec", function() { stop( 10000 ); - popped.exec( 4, function() { - ok( loop < 2, "exec callback fired " + ++loop ); + popped.cue( 4, function() { + ok( loop < 2, "cue callback fired " + ++loop ); plus(); if ( !hasLooped ) { @@ -815,10 +820,13 @@ test( "exec", function() { }); test( "cue (alias of exec)", function() { - expect( 3 ); + expect( 2 ); ok( Popcorn.p.cue, "Popcorn.p.cue exists" ); equal( typeof Popcorn.p.cue, "function", "Popcorn.p.cue is a function" ); - deepEqual( Popcorn.p.cue, Popcorn.p.exec, "Popcorn.p.cue equals Popcorn.p.exec" ); + + // Sing exec is being overwritten with a function that inlines + // a deprecated warning message, this test is no longer valid + // deepEqual( Popcorn.p.cue, Popcorn.p.exec, "Popcorn.p.cue equals Popcorn.p.exec" ); }); test( "mute", function() { @@ -952,9 +960,9 @@ test( "play(n)/pause(n) custom stop()", function() { $pop.on( "canplayall", function() { - this.exec( 4, function() { + this.cue( 4, function() { - this.exec( 0, function() { + this.cue( 0, function() { equal( this.currentTime(), 0, "currentTime is 0" ); plus(); @@ -1395,7 +1403,7 @@ test( "Stored By Type", function() { plus(); }); - p.trigger( "play" ); + p.emit( "play" ); if ( fired < 4 ) { start(); @@ -1439,7 +1447,7 @@ test( "Simulated", function() { }); Setup.events.forEach( function( name ) { - p.trigger( name ); + p.emit( name ); }); }); @@ -1510,7 +1518,7 @@ test( "Custom", function() { plus(); }); - p.trigger( "eventz0rz" ); + p.emit( "eventz0rz" ); }); test( "on/off/emit", function() { @@ -1558,7 +1566,7 @@ test( "UI/Mouse", function() { plus(); }); - p.trigger( "click" ); + p.emit( "click" ); }); module( "Popcorn Plugin" ); @@ -1908,7 +1916,7 @@ test( "Exceptions", function() { this.exceptions({ start: 1, end: 2 - }).exec( 3, function() { + }).cue( 3, function() { equal( Popcorn.plugin.errors.length, 1, "Popcorn.plugin.errors has one item" ); plus(); }).currentTime( 0 ).play(); @@ -2172,7 +2180,7 @@ test( "Update Timer (timeupdate)", function() { wrapper: "two" }) // checking wrapper 2's start - .exec( 5, function() { + .cue( 5, function() { if ( execCount === 0 ) { @@ -2184,7 +2192,7 @@ test( "Update Timer (timeupdate)", function() { } }) // checking wrapper 1's start - .exec( 6, function() { + .cue( 6, function() { if ( execCount === 1 ) { @@ -2196,7 +2204,7 @@ test( "Update Timer (timeupdate)", function() { } }) // checking wrapper 1's end - .exec( 7, function() { + .cue( 7, function() { if ( execCount === 2 ) { @@ -2208,7 +2216,7 @@ test( "Update Timer (timeupdate)", function() { } }) // checking wrapper 2's end - .exec( 8, function() { + .cue( 8, function() { if ( execCount === 3 ) { @@ -2350,7 +2358,7 @@ test( "Update Timer (frameAnimation)", function() { wrapper: "two" }) // checking wrapper 2's start - .exec( 5, function() { + .cue( 5, function() { if ( execCount === 0 ) { @@ -2362,7 +2370,7 @@ test( "Update Timer (frameAnimation)", function() { } }) // checking wrapper 1's start - .exec( 6, function() { + .cue( 6, function() { if ( execCount === 1 ) { @@ -2374,7 +2382,7 @@ test( "Update Timer (frameAnimation)", function() { } }) // checking wrapper 1's end - .exec( 7, function() { + .cue( 7, function() { if ( execCount === 2 ) { @@ -2386,7 +2394,7 @@ test( "Update Timer (frameAnimation)", function() { } }) // checking wrapper 2's end - .exec( 8, function() { + .cue( 8, function() { if ( execCount === 3 ) { @@ -2683,49 +2691,49 @@ test( "Popcorn Compose", function() { equal( test.two.setup, 3, "three compose two setup" ); plus(); - popped.exec( 0, function() { + popped.cue( 0, function() { equal( test.one.running, 1, "one compose running" ); plus(); equal( test.two.running, 1, "one effect running" ); plus(); }) - .exec( 1, function() { + .cue( 1, function() { equal( test.one.running, 0, "no compose running" ); plus(); equal( test.two.running, 0, "no effect running" ); plus(); }) - .exec( 2, function() { + .cue( 2, function() { equal( test.one.running, 1, "one compose running" ); plus(); equal( test.two.running, 0, "no effect running" ); plus(); }) - .exec( 3, function() { + .cue( 3, function() { equal( test.one.running, 2, "two compose one running" ); plus(); equal( test.two.running, 1, "one compose two running" ); plus(); }) - .exec( 4, function() { + .cue( 4, function() { equal( test.one.running, 0, "no compose one running" ); plus(); equal( test.two.running, 0, "no compose two running" ); plus(); }) - .exec( 5, function() { + .cue( 5, function() { equal( test.one.running, 1, "one effect running" ); plus(); equal( test.two.running, 0, "no compose running" ); plus(); }) - .exec( 6, function() { + .cue( 6, function() { equal( test.one.running, 1, "one effect one running" ); plus(); equal( test.two.running, 1, "one effect two running" ); plus(); }) - .exec( 7, function() { + .cue( 7, function() { popped.removeTrackEvent( effectTrackOne ); popped.removeTrackEvent( effectTrackTwo ); popped.removeTrackEvent( effectTrackThree ); @@ -3328,12 +3336,12 @@ test( "In/Out aliases", function() { equal( counter, 0, "Counter is at 0, neither in or out have been called" ); plus(); - popcorn.exec( 2, function() { + popcorn.cue( 2, function() { equal( counter, 1, "Counter is at 1, in has been called" ); plus(); }); - popcorn.exec( 4, function() { + popcorn.cue( 4, function() { equal( counter, 2, "Counter is at 2, out has been called" ); plus(); }); @@ -3525,20 +3533,20 @@ test( "Index Integrity ( removing tracks )", function() { tId = $pop.getLastTrackEventId(); - $pop.exec( 1, function() { + $pop.cue( 1, function() { equal( fired.one === false && fired.two === false && fired.three === false, true, "nothing fired yet" ); plus(); fired.one = true; $pop.removeTrackEvent( tId ); }); - $pop.exec( 2, function() { + $pop.cue( 2, function() { equal( fired.one === true && fired.two === false && fired.three === false, true, "One fired, Three has not fired" ); plus(); fired.two = true; }); - $pop.exec( 3, function() { + $pop.cue( 3, function() { equal( fired.one === true && fired.two === true && fired.three === false, true, "One and Two fired, three not fired"); plus(); }); @@ -3595,7 +3603,7 @@ test( "Index Integrity ( timeUpdate )", function() { end: 41 }); - $pop.exec( 42, function() { + $pop.cue( 42, function() { // 4 track events: startpad, endpad, ff and exec equal( $pop.data.trackEvents.byStart.length, 4, "$pop.data.trackEvents.byStart.length is 4 - after play, before removeTrackEvent" ); plus(); @@ -3666,7 +3674,7 @@ test( "Index Integrity (frameAnimation)", function() { end: 41 }); - $pop.exec( 42, function() { + $pop.cue( 42, function() { // 4 track events: startpad, endpad, ff and exec equal( $pop.data.trackEvents.byStart.length, 4, "$pop.data.trackEvents.byStart.length is 4 - after play, before removeTrackEvent" ); plus(); @@ -3720,7 +3728,7 @@ test( "Popcorn.disable/enable/toggle (timeupdate)", function() { }; }); - $pop.exec( 40, function() { + $pop.cue( 40, function() { // make sure toggler never happened // look for: "toggler-test" From 5b180618f809c225999b0689d941abfcd4485d25 Mon Sep 17 00:00:00 2001 From: "Rick Waldron waldron.rick@gmail.com" Date: Mon, 5 Mar 2012 15:54:52 -0500 Subject: [PATCH 4/4] [#935] Restore deprecated method after first use Signed-off-by: Rick Waldron waldron.rick@gmail.com --- popcorn.js | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/popcorn.js b/popcorn.js index 6b297d60..3b90bb57 100644 --- a/popcorn.js +++ b/popcorn.js @@ -288,7 +288,7 @@ Popcorn.timeUpdate( self, {} ); - self.trigger( "timeupdate" ); + self.emit( "timeupdate" ); !self.isDestroyed && requestAnimFrame( self.data.timeUpdate ); }; @@ -572,7 +572,7 @@ } // Trigger either muted|unmuted event - this.trigger( event ); + this.emit( event ); return this; }, @@ -1116,7 +1116,7 @@ byEnd._running = false; natives.end.call( obj, event, byEnd ); - obj.trigger( trackend, + obj.emit( trackend, Popcorn.extend({}, byEnd, { plugin: type, type: trackend @@ -1150,7 +1150,7 @@ byStart._running = true; natives.start.call( obj, event, byStart ); - obj.trigger( trackstart, + obj.emit( trackstart, Popcorn.extend({}, byStart, { plugin: type, type: trackstart @@ -1207,7 +1207,7 @@ byStart._running = false; natives.end.call( obj, event, byStart ); - obj.trigger( trackend, + obj.emit( trackend, Popcorn.extend({}, byEnd, { plugin: type, type: trackend @@ -1240,7 +1240,7 @@ byEnd._running = true; natives.start.call( obj, event, byEnd ); - obj.trigger( trackstart, + obj.emit( trackstart, Popcorn.extend({}, byStart, { plugin: type, type: trackstart @@ -1540,7 +1540,7 @@ // Trigger an error that the instance can listen for // and react to - this.trigger( "error", Popcorn.plugin.errors ); + this.emit( "error", Popcorn.plugin.errors ); } }; } @@ -1898,6 +1898,7 @@ "exec": "cue" }, function( recommend, api ) { + var original = Popcorn.p[ api ]; // Override the deprecated api method with a method of the same name // that logs a warning and defers to the new recommended method Popcorn.p[ api ] = function() { @@ -1906,6 +1907,9 @@ "Deprecated method '" + api + "', " + (recommend == null ? "do not use." : "use '" + recommend + "' instead." ) ); + + // Restore api after first warning + Popcorn.p[ api ] = original; } return Popcorn.p[ recommend ].apply( this, [].slice.call( arguments ) ); };