From: ScottDowne Date: Wed, 22 Jun 2011 13:31:20 +0000 (-0400) Subject: [#t366] review changes X-Git-Tag: v0.7^2~22^2~6 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=6eecd03bf618b50321669491e6a2789d8a54778b;p=popcorn-js.git [#t366] review changes --- diff --git a/effects/applyclass/popcorn.applyclass.js b/effects/applyclass/popcorn.applyclass.js index 3718409..e063a4b 100644 --- a/effects/applyclass/popcorn.applyclass.js +++ b/effects/applyclass/popcorn.applyclass.js @@ -25,6 +25,12 @@ var startFunction = Popcorn.nop, applyFunction = function() { + if ( !window.jQuery ) { + + Popcorn.getScript( "http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js", applyFunction ); + return; + } + startFunction = function( event, options ) { Popcorn.forEach( options.classes, function( val, key ) { @@ -47,13 +53,7 @@ }; }; - if ( typeof $ !== "undefined" ) { - - applyFunction(); - } else { - - Popcorn.getScript( "http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js", applyFunction ); - } + applyFunction(); Popcorn.compose( "applyclass", { diff --git a/popcorn.js b/popcorn.js index 447b788..2eea9f7 100644 --- a/popcorn.js +++ b/popcorn.js @@ -843,7 +843,8 @@ var reserved = [ "start", "end" ], plugin = {}, setup, - isfn = typeof definition === "function"; + isfn = typeof definition === "function", + methods = [ "_setup", "_teardown", "start", "end" ]; // combines calls of two function calls into one var combineFn = function( first, second ) { @@ -865,10 +866,10 @@ } // apply safe, and empty default functions - definition._setup = definition._setup || Popcorn.nop; - definition._teardown = definition._teardown || Popcorn.nop; - definition.start = definition.start || Popcorn.nop; - definition.end = definition.end || Popcorn.nop; + methods.forEach(function( method ) { + + definition[ method ] = definition[ method ] || Popcorn.nop; + }); var pluginFn = function( setup, options ) { @@ -899,10 +900,10 @@ compose = Popcorn.compositions[ options.compose[ i ] ] || {}; // extends previous functions with compose function - natives._setup = combineFn( natives._setup, compose._setup ); - natives._teardown = combineFn( natives._teardown, compose._teardown ); - natives.start = combineFn( natives.start, compose.start ); - natives.end = combineFn( natives.end, compose.end ); + methods.forEach(function( method ) { + + natives[ method ] = combineFn( natives[ method ], compose[ method ] ); + }); } // Ensure a manifest object, an empty object is a sufficient fallback