]> khamidou — GitHub mirrors - popcorn-js.git/commitdiff
Popcorn.prototype.defaults() implementation complete
authorrwldrn <waldron.rick@gmail.com>
Thu, 23 Jun 2011 16:58:29 +0000 (12:58 -0400)
committerrwldrn <waldron.rick@gmail.com>
Thu, 23 Jun 2011 16:58:29 +0000 (12:58 -0400)
popcorn.js

index b2d55125df81e8c52c2d8ec607060c40115f4489..507edbc745c06c163c8a2ade4b02b2ea5db83be5 100644 (file)
       listen: function( type, fn ) {
 
         var self = this,
-                       hasEvents = true, 
-                       eventHook = Popcorn.events.hooks[ type ], 
-                       origType = type, 
-                       tmp;
+            hasEvents = true, 
+            eventHook = Popcorn.events.hooks[ type ], 
+            origType = type, 
+            tmp;
 
         if ( !this.data.events[ type ] ) {
           this.data.events[ type ] = {};
       //  Storing the plugin natives
       var natives = options._natives = {},
           compose = "", 
-          defaults = this.options.defaults && this.options.defaults[ options._natives && options._natives.type ],
-          originalOpts, manifestOpts, mergedSetupOpts;
+          defaults, originalOpts, manifestOpts, mergedSetupOpts;
 
       Popcorn.extend( natives, setup );
 
       options._natives.type = name;
       options._running = false;
 
+      // Check for previously set default options
+      defaults = this.options.defaults && this.options.defaults[ options._natives && options._natives.type ];
+
       // default to an empty string if no effect exists
       // split string into an array of effects
       options.compose = options.compose && options.compose.split( " " ) || [];
         options.end = this.duration() || Number.MAX_VALUE;
       }
 
-      // Store original options object as a restore point
-      originalOpts = options;
-      
       // Merge with defaults if they exist, make sure per call is prioritized
       mergedSetupOpts = defaults ? Popcorn.extend( {}, defaults, options ) :
                           options;
 
         mergedSetupOpts.target = manifestOpts && "target" in manifestOpts && manifestOpts.target;
       }
-      
-      // Resolves 239, 241, 242
-      if ( !mergedSetupOpts.target ) {
-
-        //  Sometimes the manifest may be missing entirely
-        //  or it has an options object that doesn't have a `target` property
-        manifestOpts = "options" in manifest && manifest.options;
-
-        mergedSetupOpts.target = manifestOpts && "target" in manifestOpts && manifestOpts.target;
-      }
 
+      // Trigger _setup method if exists
       options._natives._setup && options._natives._setup.call( this, mergedSetupOpts );
 
-      Popcorn.addTrackEvent( this, originalOpts );
+      // Create new track event for this instance
+      Popcorn.addTrackEvent( this, options );
 
       //  Future support for plugin event definitions
       //  for all of the native events