From fea97e2a4f7a31504a649b8ceddcc0fe54310c26 Mon Sep 17 00:00:00 2001 From: Rick Waldron Date: Fri, 8 Jul 2011 14:07:19 -0400 Subject: [PATCH] [#646] Clean eol and blank line whitespace --- popcorn.js | 56 +++++++-------- test/popcorn.unit.js | 162 +++++++++++++++++++++---------------------- 2 files changed, 109 insertions(+), 109 deletions(-) diff --git a/popcorn.js b/popcorn.js index 33c4926..f7a6b6d 100644 --- a/popcorn.js +++ b/popcorn.js @@ -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: {} } @@ -235,10 +235,10 @@ 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 ] ); } @@ -271,8 +271,8 @@ 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; @@ -399,13 +399,13 @@ 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 ); } @@ -414,7 +414,7 @@ }, enable: function( instance, plugin ) { - var disabled = instance.data.disabled, + var disabled = instance.data.disabled, index = disabled.indexOf( plugin ); if ( index > -1 ) { @@ -504,7 +504,7 @@ // 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 ) { @@ -553,7 +553,7 @@ // 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; @@ -565,8 +565,8 @@ 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++ ) { @@ -586,14 +586,14 @@ 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; @@ -637,9 +637,9 @@ 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 ] ) { @@ -768,7 +768,7 @@ // 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-- ) { @@ -871,7 +871,7 @@ var trackevents = [], refs = obj.data.trackEvents.byStart, length = refs.length, - idx = 0, + idx = 0, ref; for ( ; idx < length; idx++ ) { @@ -975,7 +975,7 @@ // 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 ) { @@ -986,7 +986,7 @@ // Storing the plugin natives var natives = options._natives = {}, - compose = "", + compose = "", defaults, originalOpts, manifestOpts, mergedSetupOpts; Popcorn.extend( natives, setup ); @@ -1284,7 +1284,7 @@ options.dataType = options.dataType && options.dataType.toLowerCase() || null; - if ( options.dataType && + if ( options.dataType && ( options.dataType === "jsonp" || options.dataType === "script" ) ) { Popcorn.xhr.getJSONP( diff --git a/test/popcorn.unit.js b/test/popcorn.unit.js index 15178e4..570e76f 100644 --- a/test/popcorn.unit.js +++ b/test/popcorn.unit.js @@ -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() { }); /* -