]> khamidou — GitHub mirrors - popcorn-js.git/commitdiff
[#646] Clean eol and blank line whitespace
authorRick Waldron <waldron.rick@gmail.com>
Fri, 8 Jul 2011 18:07:19 +0000 (14:07 -0400)
committerRick Waldron <waldron.rick@gmail.com>
Fri, 8 Jul 2011 18:07:19 +0000 (14:07 -0400)
popcorn.js
test/popcorn.unit.js

index 33c4926140e9321246bbb5f3e4edd0172f8fc81e..f7a6b6d4d1ca9c16ab18969fe954a101c5840121 100644 (file)
@@ -1,12 +1,12 @@
 (function(global, document) {
 
   //  Cache refs to speed up calls to native utils
-  
+
   var
-  
+
   AP = Array.prototype,
   OP = Object.prototype,
-  
+
   forEach = AP.forEach,
   slice = AP.slice,
   hasOwn = OP.hasOwnProperty,
@@ -22,7 +22,7 @@
 
   //  Non-public internal data object
   internal = {
-    events: { 
+    events: {
       hash: {},
       apis: {}
     }
               while ( tracksByStart[ tracks.startIndex ] && tracksByStart[ tracks.startIndex ].start <= currentTime ) {
                 //  If plugin does not exist on this instance, remove it
                 if ( !tracksByStart[ tracks.startIndex ]._natives || !!that[ tracksByStart[ tracks.startIndex ]._natives.type ] ) {
-                  if ( tracksByStart[ tracks.startIndex ].end > currentTime && 
-                        tracksByStart[ tracks.startIndex ]._running === false && 
+                  if ( tracksByStart[ tracks.startIndex ].end > currentTime &&
+                        tracksByStart[ tracks.startIndex ]._running === false &&
                           that.data.disabled.indexOf( tracksByStart[ tracks.startIndex ]._natives.type ) === -1 ) {
-                          
+
                     tracksByStart[ tracks.startIndex ]._running = true;
                     tracksByStart[ tracks.startIndex ]._natives.start.call( that, event, tracksByStart[ tracks.startIndex ] );
                   }
               while ( tracksByEnd[ tracks.endIndex ] && tracksByEnd[ tracks.endIndex ].end > currentTime ) {
                 // if plugin does not exist on this instance, remove it
                 if ( !tracksByEnd[ tracks.endIndex ]._natives || !!that[ tracksByEnd[ tracks.endIndex ]._natives.type ] ) {
-                  if ( tracksByEnd[ tracks.endIndex ].start <= currentTime && 
-                        tracksByEnd[ tracks.endIndex ]._running === false  && 
+                  if ( tracksByEnd[ tracks.endIndex ].start <= currentTime &&
+                        tracksByEnd[ tracks.endIndex ]._running === false  &&
                           that.data.disabled.indexOf( tracksByEnd[ tracks.endIndex ]._natives.type ) === -1 ) {
 
                     tracksByEnd[ tracks.endIndex ]._running = true;
         bounds[ p ] = Math.round( clientRect[ p ] );
       }
 
-      return Popcorn.extend({}, bounds, { top: top, left: left });     
-    }, 
+      return Popcorn.extend({}, bounds, { top: top, left: left });
+    },
 
     disable: function( instance, plugin ) {
 
       var disabled = instance.data.disabled;
-      
+
       if ( disabled.indexOf( plugin ) === -1 ) {
         disabled.push( plugin );
       }
     },
     enable: function( instance, plugin ) {
 
-      var disabled = instance.data.disabled, 
+      var disabled = instance.data.disabled,
           index = disabled.indexOf( plugin );
 
       if ( index > -1 ) {
     // Toggle a plugin's playback behaviour (on or off) per instance
     toggle: function( plugin ) {
       return Popcorn[ this.data.disabled.indexOf( plugin ) > -1 ? "enable" : "disable" ]( this, plugin );
-    }, 
+    },
 
     // Set default values for plugin options objects per instance
     defaults: function( plugin, defaults ) {
   // Privately compile events table at load time
   (function( events, data ) {
 
-    var apis = internal.events.apiTypes, 
+    var apis = internal.events.apiTypes,
     eventsList = events.Natives.split( /\s+/g ),
     idx = 0, len = eventsList.length, prop;
 
 
       data.apis[ val ] = {};
 
-      var apiEvents = events[ val ].split( /\s+/g ), 
-      len = apiEvents.length, 
+      var apiEvents = events[ val ].split( /\s+/g ),
+      len = apiEvents.length,
       k = 0;
 
       for ( ; k < len; k++ ) {
         return false;
       }
 
-      var eventApi = internal.events, 
+      var eventApi = internal.events,
         apis = eventApi.apiTypes,
-        apihash = eventApi.apis, 
+        apihash = eventApi.apis,
         idx = 0, len = apis.length, api, tmp;
 
       for ( ; idx < len; idx++ ) {
         tmp = apis[ idx ];
-        
+
         if ( apihash[ tmp ][ type ] ) {
           api = tmp;
           break;
       listen: function( type, fn ) {
 
         var self = this,
-            hasEvents = true, 
-            eventHook = Popcorn.events.hooks[ type ], 
-            origType = type, 
+            hasEvents = true,
+            eventHook = Popcorn.events.hooks[ type ],
+            origType = type,
             tmp;
 
         if ( !this.data.events[ type ] ) {
 
     //  Store this definition in an array sorted by times
     var byStart = obj.data.trackEvents.byStart,
-        byEnd = obj.data.trackEvents.byEnd, 
+        byEnd = obj.data.trackEvents.byEnd,
         idx;
 
     for ( idx = byStart.length - 1; idx >= 0; idx-- ) {
     var trackevents = [],
       refs = obj.data.trackEvents.byStart,
       length = refs.length,
-      idx = 0, 
+      idx = 0,
       ref;
 
     for ( ; idx < length; idx++ ) {
     // apply safe, and empty default functions
     methods.forEach(function( method ) {
 
-      definition[ method ] = definition[ method ] || Popcorn.nop;      
+      definition[ method ] = definition[ method ] || Popcorn.nop;
     });
 
     var pluginFn = function( setup, options ) {
 
       //  Storing the plugin natives
       var natives = options._natives = {},
-          compose = "", 
+          compose = "",
           defaults, originalOpts, manifestOpts, mergedSetupOpts;
 
       Popcorn.extend( natives, setup );
 
     options.dataType = options.dataType && options.dataType.toLowerCase() || null;
 
-    if ( options.dataType && 
+    if ( options.dataType &&
          ( options.dataType === "jsonp" || options.dataType === "script" ) ) {
 
       Popcorn.xhr.getJSONP(
index 15178e45b79e3cf212084d69731c962b073c5523..570e76f1f06ce8b312264d53782351a262b80bb1 100644 (file)
@@ -51,21 +51,21 @@ test("API", function () {
 
 test("Popcorn.* Static Methods", function () {
 
-  var statics = [ "forEach", "extend", "error", "guid", "sizeOf", "nop", 
-                  "addTrackEvent", "removeTrackEvent", "getTrackEvents", "getTrackEvent", "position", "disable", "enable" ], 
+  var statics = [ "forEach", "extend", "error", "guid", "sizeOf", "nop",
+                  "addTrackEvent", "removeTrackEvent", "getTrackEvents", "getTrackEvent", "position", "disable", "enable" ],
     substatics = [ "addTrackEvent", "removeTrackEvent", "getTrackEvents", "getTrackEvent"];
 
   expect(statics.length + substatics.length);
-  
+
   statics.forEach(function(val, idx) {
 
-    equals( typeof Popcorn[val], "function" , "Popcorn."+val+"() is a provided static function");  
+    equals( typeof Popcorn[val], "function" , "Popcorn."+val+"() is a provided static function");
 
   });
 
   substatics.forEach(function(val, idx) {
 
-    equals( typeof Popcorn[val].ref, "function" , "Popcorn."+val+".ref() is a private use static function");  
+    equals( typeof Popcorn[val].ref, "function" , "Popcorn."+val+".ref() is a private use static function");
 
   });
 });
@@ -74,9 +74,9 @@ test("Popcorn.forEach", function() {
 
   expect(3);
 
-  var count = 0, 
-    nodelist = document.querySelectorAll("div[id^='qunit-']"), 
-    array = [ 1, 2 ], 
+  var count = 0,
+    nodelist = document.querySelectorAll("div[id^='qunit-']"),
+    array = [ 1, 2 ],
     object = { a: "1", b: "2" };
 
   Popcorn.forEach( nodelist, function() {
@@ -323,10 +323,10 @@ test("isArray", function() {
 
   expect(18);
 
-  var empty = [], 
-      fastSmall = [1], 
+  var empty = [],
+      fastSmall = [1],
       slow = [],
-      slowSmall = [], 
+      slowSmall = [],
       all = null;
 
   slowSmall[999999] = 0;
@@ -335,12 +335,12 @@ test("isArray", function() {
 
   all = [ [], [1], new Array, Array(0),'abc'.match(/(a)/g), slow, slowSmall ];
 
-  all.forEach(function( a ) { 
-    ok( Popcorn.isArray(a), "Popcorn.isArray("+JSON.stringify(a)+")" ); 
+  all.forEach(function( a ) {
+    ok( Popcorn.isArray(a), "Popcorn.isArray("+JSON.stringify(a)+")" );
   });
 
   equal( Popcorn.isArray.length, 1, "Popcorn.isArray.length, 1" );
-  
+
   ok( !Popcorn.isArray(), "!Popcorn.isArray(), false");
   ok( !Popcorn.isArray({}), "!Popcorn.isArray({}), false");
   ok( !Popcorn.isArray(null), "!Popcorn.isArray(null), false");
@@ -375,7 +375,7 @@ test("Protected from removal", function () {
     } catch( e ) {
       ok( true, e.message + " and cannot be used as a plugin name" );
     }
-    
+
     try {
       Popcorn.removePlugin( name );
     } catch( e ) {
@@ -460,7 +460,7 @@ module("Popcorn Static");
 test("Popcorn.[addTrackEvent | removeTrackEvent].ref()", function() {
 
   expect(2);
-  
+
   var popped = Popcorn("#video");
 
   // Calling exec() will create tracks and added them to the
@@ -542,11 +542,11 @@ test("exec", function () {
 });
 
 test( "Popcorn.extend", function () {
-  
+
   QUnit.reset();
-  
+
   expect( 12 );
-  
+
   var dest = {},
       obj1 = {
         "key11" : "value",
@@ -559,19 +559,19 @@ test( "Popcorn.extend", function () {
         "key23" : function() { return false; }
       },
       prop;
-      
+
   Popcorn.extend( dest, obj1 );
-  
+
   for ( prop in obj1 ) {
     equal( dest.hasOwnProperty( prop ), true, "{dest} has property: " + prop );
   }
-  
+
   equal( typeof dest[ "key13" ], "function", "dest[key13] is a function" );
-  
+
   dest = {};
-  
+
   Popcorn.extend( dest, obj1, obj2 );
-  
+
   for ( prop in obj1 ) {
     equal( dest.hasOwnProperty( prop ), true, "{dest} has property: " + prop + ", when extending 2 objects" );
   }
@@ -579,21 +579,21 @@ test( "Popcorn.extend", function () {
   for ( prop in obj2 ) {
     equal( dest.hasOwnProperty( prop ), true, "{dest} has property: " + prop + ", when extending 2 objects" );
   }
-  
+
   equal( typeof dest[ "key13" ], "function","dest[key13] is a function" );
-  
+
   equal( typeof dest[ "key23" ], "function","dest[key23] is a function" );
-  
+
 });
 
 test( "Popcorn.events", function() {
 
   QUnit.reset()
   expect( 43 );
-  
-  var eventTypes = [ "UIEvents", "MouseEvents", "Events" ], 
-      natives = "", 
-      events, 
+
+  var eventTypes = [ "UIEvents", "MouseEvents", "Events" ],
+      natives = "",
+      events,
       eventsReturned,
       idx = 0,
       len,
@@ -626,7 +626,7 @@ test( "Popcorn.events", function() {
 test("Popcorn.events.hooks", function() {
 
   expect(1);
-  
+
   ok( Popcorn.events.hooks, "Popcorn.events.hooks exists" );
 
 });
@@ -635,12 +635,12 @@ test("Popcorn.events.hooks: canplayall", function() {
   //qunit-fixture
 
   var expects = 1,
-    count = 0, 
+    count = 0,
     fired = 0;
 
   expect(expects);
 
-  function plus(){ 
+  function plus(){
     if ( ++count == expects ) {
       start();
     }
@@ -650,8 +650,8 @@ test("Popcorn.events.hooks: canplayall", function() {
 
   var video = document.createElement("video"),
     sources = {
-      mp4: document.createElement("source"), 
-      ogv: document.createElement("source"), 
+      mp4: document.createElement("source"),
+      ogv: document.createElement("source"),
       webm: document.createElement("source")
     },
     url = "http://videos.mozilla.org/serv/webmademovies/popcornplug.";
@@ -683,7 +683,7 @@ test("Popcorn.events.hooks: canplayall", function() {
 });
 
 /*
-<video height="180" width="300" id="video" controls> 
+<video height="180" width="300" id="video" controls>
 <source src="http://videos.mozilla.org/serv/webmademovies/popcornplug.mp4"></source>
 <source src="http://videos.mozilla.org/serv/webmademovies/popcornplug.ogv"></source>
 <source src="http://videos.mozilla.org/serv/webmademovies/popcornplug.webm"></source>
@@ -695,11 +695,11 @@ module("Popcorn Position");
 test("position", function () {
 
   expect(25);
-  
-  var $absolute = $(".absolute"), 
-      $relative = $(".relative"), 
+
+  var $absolute = $(".absolute"),
+      $relative = $(".relative"),
       $fixed = $(".fixed"),
-      $static = $(".static"),  
+      $static = $(".static"),
       tests;
 
   $("#position-tests").show();
@@ -714,7 +714,7 @@ test("position", function () {
     { id: "absolute-1-1-1", top:  2, left:  2 },
     { id: "absolute-2",     top: 19, left: 19 }
   ];
-  
+
   Popcorn.forEach( tests, function( test ) {
     equals( Popcorn( "#vid-" + test.id ).position().top,  test.top,  "Popcorn('#vid-" + test.id + "').position().top" );
     equals( Popcorn( "#vid-" + test.id ).position().left, test.left, "Popcorn('#vid-" + test.id + "').position().left" );
@@ -728,7 +728,7 @@ test("position", function () {
   Popcorn.forEach( tests, function( test ) {
     equals( Popcorn( "#vid-" + test.id ).position().top,  test.top,  "Popcorn('#vid-" + test.id + "').position().top" );
     equals( Popcorn( "#vid-" + test.id ).position().left, test.left, "Popcorn('#vid-" + test.id + "').position().left" );
-  });  
+  });
 
   tests = [
     { id: "fixed-1", top:  0, left:  0 },
@@ -738,7 +738,7 @@ test("position", function () {
   Popcorn.forEach( tests, function( test ) {
     equals( Popcorn( "#vid-" + test.id ).position().top,  test.top,  "Popcorn('#vid-" + test.id + "').position().top" );
     equals( Popcorn( "#vid-" + test.id ).position().left, test.left, "Popcorn('#vid-" + test.id + "').position().left" );
-  });  
+  });
 
   tests = [
     { id: "static-1",     top:  200, left:  0 },
@@ -746,7 +746,7 @@ test("position", function () {
     { id: "static-1-1-1", top:  0, left:  0 },
     { id: "static-2",     top: 300, left: 0 }
   ];
-  
+
   Popcorn.forEach( tests, function( test ) {
     equals( Popcorn( "#vid-" + test.id ).position().top,  test.top,  "Popcorn('#vid-" + test.id + "').position().top" );
     equals( Popcorn( "#vid-" + test.id ).position().left, test.left, "Popcorn('#vid-" + test.id + "').position().left" );
@@ -769,7 +769,7 @@ test("position called from plugin", function () {
 
   expect( expects );
 
-  function plus(){ 
+  function plus(){
     if ( ++count == expects ) {
       start();
       Popcorn.removePlugin("positionPlugin");
@@ -1121,7 +1121,7 @@ test("Manifest", function () {
 });
 
 test("Configurable Defaults", function () {
-  
+
   var expects = 13,
       count   = 0;
 
@@ -1138,7 +1138,7 @@ test("Configurable Defaults", function () {
   }
 
   stop();
-      
+
   Popcorn.plugin( "configurable", function () {
     return {
       _setup: function( options ) {
@@ -1154,7 +1154,7 @@ test("Configurable Defaults", function () {
         plus();
         // target: "foo"
         // text: "bar"
-        // type: "thinger"      
+        // type: "thinger"
         equal( options.target, "foo", 'options.target, "foo" in configurable start');
         plus();
         equal( options.text, "bar", 'options.text, "bar" in configurable start');
@@ -1198,14 +1198,14 @@ test("Configurable Defaults", function () {
       _setup: function( options ) {
         equal( options.text, "hello!", 'options.text, overriden with "hello!" in overridden _setup');
         plus();
-      
+
         equal( options.target, "custom", 'options.target, overriden with "custom" in overridden _setup');
         plus();
       },
       start: function( event, options ) {
         equal( options.text, "hello!", 'options.text, overriden with "hello!" in overridden start');
         plus();
-      
+
         equal( options.target, "custom", 'options.target, overriden with "custom" in overridden start');
         plus();
       },
@@ -1228,19 +1228,19 @@ test("Configurable Defaults", function () {
 
     // set a default element target id
     target: "foo"
-    
-  }).defaults([ 
-    { 
-      multiconfig: { 
-        target: "quux" 
-      } 
+
+  }).defaults([
+    {
+      multiconfig: {
+        target: "quux"
+      }
     },
-    { 
-      configurable: { 
+    {
+      configurable: {
         text: "bar",
         type: "thinger"
-      } 
-    } 
+      }
+    }
   ]).configurable({
 
     // all calls will have:
@@ -1256,7 +1256,7 @@ test("Configurable Defaults", function () {
     // target: "quux"
     start: 4,
     end: 5
-    
+
   }).overridden({
 
     // has a default set
@@ -1445,7 +1445,7 @@ test("Plugin Factory", function () {
   var popped = Popcorn("#video"),
       methods = "load play pause currentTime mute volume roundTime exec removePlugin",
       expects = 34, // 15*2+2+2. executor/complicator each do 15
-      count = 0;    
+      count = 0;
 
   function plus() {
     if ( ++count == expects ) {
@@ -1549,7 +1549,7 @@ test("Plugin Factory", function () {
   plus();
 
   popped.complicator({
-    start: 4, 
+    start: 4,
     end: 5
   });
 
@@ -1578,7 +1578,7 @@ test( "Popcorn Compose", function () {
           setup: 0,
           running: 0
         }
-      };    
+      };
 
   function plus() {
     if ( ++count == expects ) {
@@ -2125,9 +2125,9 @@ test("Protected Names", function () {
 });
 
 test("Defaulting Empty End Values", function() {
-  
+
   expect (2);
-  
+
   Popcorn.plugin("testdefault", {
     _setup: function( options ) {
       equals( options.end, Number.MAX_VALUE, "The end value defaulted to maximum number value");
@@ -2139,9 +2139,9 @@ test("Defaulting Empty End Values", function() {
 
     }
   });
-  
+
   var popped = Popcorn( document.createElement( "audio" ) )
-  .play() 
+  .play()
   .testdefault({
     start: 0, // seconds
     apikey: "CHAyhB5IisvLqqzGYNYbmA",
@@ -2304,7 +2304,7 @@ test("getTrackEvent", function () {
 
 
   trackIds.push( popped.getLastTrackEventId() );
-  
+
   popped.rw({
     start: 5,
     end: 7
@@ -2320,9 +2320,9 @@ test("getTrackEvent", function () {
     var trackEvent = popped.getTrackEvent( id );
     equals( id, trackEvent._id, "returned the correct TrackEvent");
   });
-  
+
   oldId = trackIds[trackIds.length - 1];
-  
+
   popped.removeTrackEvent( oldId );
 
   equals( popped.getTrackEvent( oldId ), undefined,  "returned undefined when id is not found" );
@@ -2457,13 +2457,13 @@ test("Popcorn.disable/enable/toggle", function() {
     plus();
 
     // Test per-instance toggle on
-    $pop.toggle( "toggler" );  
+    $pop.toggle( "toggler" );
     ok( $pop.data.disabled.indexOf("toggler") === -1, "toggle() plugin: toggler is re-enabled" );
     plus();
   });
 
   $pop.toggler({
-    start: 40, 
+    start: 40,
     end: 50
   });
 
@@ -2471,19 +2471,19 @@ test("Popcorn.disable/enable/toggle", function() {
 
   // Test per-instance function call
   $pop.disable( "toggler" );
-  
+
   ok( $pop.data.disabled.indexOf("toggler") > -1, "disable() plugin: toggler is disabled" );
   plus();
 
   // Test per-instance function call
-  $pop.enable( "toggler" );  
-  
+  $pop.enable( "toggler" );
+
   ok( $pop.data.disabled.indexOf("toggler") === -1, "enable() plugin: toggler is enabled" );
   plus();
 
   // Test per-instance toggle off
-  $pop.toggle( "toggler" );  
-  
+  $pop.toggle( "toggler" );
+
   ok( $pop.data.disabled.indexOf("toggler") > -1, "toggle() plugin: toggler is disabled" );
   plus();
 
@@ -3165,7 +3165,7 @@ test("Last Check", function () {
     $("iframe[data-src]").attr( "src", function() {
       return $(this).data("src");
     });
-  
+
   })( jQuery );
 
 });