]> khamidou — GitHub mirrors - popcorn-js.git/commitdiff
[#t366] review changes
authorScottDowne <sdowne@learn.senecac.on.ca>
Wed, 22 Jun 2011 13:31:20 +0000 (09:31 -0400)
committerScottDowne <sdowne@learn.senecac.on.ca>
Wed, 22 Jun 2011 13:31:20 +0000 (09:31 -0400)
effects/applyclass/popcorn.applyclass.js
popcorn.js

index 3718409b0f4f87a8cee0c7071fff4d3613993ef8..e063a4be1bfef76cd58f6150c31cca8a17959310 100644 (file)
   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 ) {
         };
       };
 
-  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", {
     
index 447b788377b378cfeb00b97f186d9b9c23892740..2eea9f7920c0ec04b32d561a254e857eaf8b6cf3 100644 (file)
     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 ) {
     }
 
     // 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 ) {
 
         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