This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

[#924] Added a toString option for the majority of our plugins. Disre…

…garded typically unused plugins as well as ones that are broken
  • Loading branch information...
dseif committed Jul 18, 2012
1 parent 13e84fa commit f4b273ca9eb0a5c0a060c332a3e19cddc5d9fdc3
@@ -221,6 +221,10 @@ api - https://github.com/documentcloud/document-viewer/blob/master/public/javasc
readyCheck();
}

options.toString = function() {
// use the default option if it doesn't exist
return options.src || options._natives.manifest.options.src[ "default" ];
};
},

start: function( event, options ) {
@@ -96,4 +96,24 @@
});
});

})( Popcorn, document );
asyncTest( "Overriding default toString", 2, function() {
var p = Popcorn( "#video" ),
testSrc = "Test Source",
lastEvent;

function testLastEvent( compareText, message ) {
lastEvent = p.getTrackEvent( p.getLastTrackEventId() );
equal( lastEvent.toString(), compareText, message );
}

p.documentcloud({
src: testSrc
});
testLastEvent( testSrc, "Custom text displayed with toString" );

p.documentcloud({});
testLastEvent( "http://www.documentcloud.org/documents/70050-urbina-day-1-in-progress.html", "Custom text displayed with toString using default" );

start();
});
})( Popcorn, document );
@@ -137,6 +137,11 @@
_userid = options.userid;
getFlickrData();
}

options.toString = function() {
return options.tags || options.username || "Flickr";
};

return {
/**
* @member flickr
@@ -89,3 +89,31 @@ test( "Popcorn Flickr Plugin", function() {
popped.volume( 0 ).play();

});

asyncTest( "Overriding default toString", 3, function() {
var p = Popcorn( "#video" ),
tagsText = "Work Work",
usernameText = "Some sweet license text",
lastEvent;

function testLastEvent( compareText, message ) {
lastEvent = p.getTrackEvent( p.getLastTrackEventId() );
equal( lastEvent.toString(), compareText, message );
}

p.flickr({
tags: tagsText,
username: usernameText
});
testLastEvent( tagsText, "Custom text displayed with toString using tags" );

p.flickr({
username: usernameText
});
testLastEvent( usernameText, "Custom text displayed with toString using username" );

p.flickr({});
testLastEvent( "Flickr", "Flickr displayed if nothing exists" );

start();
});
@@ -117,6 +117,10 @@

initialize();

options.toString = function() {
return options.url || options._natives.manifest.options.url[ "default" ];
};

return {
/**
* @member webpage
@@ -76,3 +76,24 @@ test( "Popcorn Google Feed Plugin", function() {
popped.play();

});

asyncTest( "Overriding default toString", 2, function() {
var p = Popcorn( "#video" ),
urlText = "http://zenit.senecac.on.ca/~chris.tyler/planet/rss20.xml",
lastEvent;

function testLastEvent( compareText, message ) {
lastEvent = p.getTrackEvent( p.getLastTrackEventId() );
equal( lastEvent.toString(), compareText, message );
}

p.googlefeed({
url: urlText
});
testLastEvent( urlText, "Custom text displayed with toString" );

p.googlefeed({});
testLastEvent( "http://planet.mozilla.org/rss20.xml", "Custom text displayed with toString using default" );

start();
});
@@ -175,6 +175,10 @@ var googleCallback;

isMapReady();

options.toString = function() {
return options.location || ( ( options.lat && options.lng ) ? options.lat + ", " + options.lng : options._natives.manifest.options.location[ "default" ] );
};

return {
/**
* @member webpage
@@ -149,3 +149,42 @@ test( "Popcorn Google Map Plugin", function() {

popped.play();
});

asyncTest( "Overriding default toString", 3, function() {
var p = Popcorn( "#video" ),
locationText = "London, England",
latText = "43.665429",
lngText = "-79.403323",
lastEvent;

function testLastEvent( compareText, message ) {
lastEvent = p.getTrackEvent( p.getLastTrackEventId() );
equal( lastEvent.toString(), compareText, message );
}

p.googlemap({
location: locationText,
target: "height3",
height: "100px",
width: "120px"
});
testLastEvent( locationText, "Custom text displayed with toString using location" );

p.googlemap({
lat: latText,
lng: lngText,
target: "height3",
height: "100px",
width: "120px"
});
testLastEvent( latText + ", " + lngText, "Custom text displayed with toString using lat and lng" );

p.googlemap({
target: "height3",
height: "100px",
width: "120px"
});
testLastEvent( "Toronto, Ontario, Canada", "Custom text displayed with toString using default" );

start();
});
@@ -182,6 +182,12 @@
}, false );

img.src = options.src;

options.toString = function() {
var string = options.src || options._natives.manifest.options.src[ "default" ],
match = string.replace( /.*\//g, "" );
return match.length ? match : string;
};
},

/**
@@ -173,3 +173,31 @@ asyncTest( "media element target test", 2, function() {
});

});

asyncTest( "Overriding default toString", 3, function() {
var p = Popcorn( "#video" ),
srcText = "http://www.stirinoi.com/wp-content/uploads/2012/05/grass-5.jpg",
fullURLText = "http://www.testing.com/asdf/",
lastEvent;

function testLastEvent( compareText, message ) {
lastEvent = p.getTrackEvent( p.getLastTrackEventId() );
equal( lastEvent.toString(), compareText, message );
}

p.image({
src: srcText,
target: "imagediv"
});
testLastEvent( srcText.replace( /.*\//, "" ), "Custom text displayed with toString" );
p.image({
src: fullURLText,
target: "imagediv"
});
testLastEvent( fullURLText, "Custom text displayed with toString" );

p.image({});
testLastEvent( "for_developers.png", "Custom text displayed with toString using default" );

start();
});
@@ -199,6 +199,9 @@
isPlayerReady();
}

options.toString = function() {
return options.source || options._natives.manifest.options.source[ "default" ];
};
},
start: function( event, options ) {
if( options._capCont ) {
@@ -104,3 +104,24 @@ asyncTest( "Test Initialized MediaSpawner Blocks throwing Errors", 4, function()
ok( true, "No target container specified." );
}
});

asyncTest( "Overriding default toString", 2, function() {
var p = Popcorn( "#video" ),
sourceText = "http://www.youtube.com/watch?v=B-N1yJyrQRY",
lastEvent;

function testLastEvent( compareText, message ) {
lastEvent = p.getTrackEvent( p.getLastTrackEventId() );
equal( lastEvent.toString(), compareText, message );
}

p.mediaspawner({
source: sourceText
});
testLastEvent( sourceText, "Custom text displayed with toString" );

p.mediaspawner({});
testLastEvent( "http://www.youtube.com/watch?v=CXDstfD9eJ0", "Custom text displayed with toString using default" );

start();
});
@@ -196,6 +196,11 @@
container.innerHTML = text || "";

target.appendChild( container );

options.toString = function() {
// use the default option if it doesn't exist
return options.text || options._natives.manifest.options.text[ "default" ];
};
},

/**
@@ -217,7 +222,6 @@
end: function( event, options ) {
options._container.style.display = "none";
},

_teardown: function( options ) {
var target = options._target;
if ( target ) {
@@ -360,3 +360,23 @@ asyncTest( "Media element as target", 2, function() {
start();
});

asyncTest( "Overriding default toString", 2, function() {
var p = Popcorn( "#video" ),
testText = "This is some test text",
lastEvent;

function testLastEvent( compareText, message ) {
lastEvent = p.getTrackEvent( p.getLastTrackEventId() );
equal( lastEvent.toString(), compareText, message );
}

p.text({
text: testText
});
testLastEvent( testText, "Custom text displayed with toString" );

p.text({});
testLastEvent( "Popcorn.js", "Custom text displayed with toString using default" );

start();
});
@@ -155,6 +155,10 @@
}
};

options.toString = function() {
return options.src || options._natives.manifest.options.src[ "default" ];
};

isReady( this );
},

@@ -114,3 +114,25 @@ asyncTest( "Popcorn Twitter Plugin", function() {
popped.play( 4 );

});

asyncTest( "Overriding default toString", 2, function() {
var p = Popcorn( "#video" ),
srcText = "#asdf",
lastEvent;

Popcorn.plugin.debug = false;
function testLastEvent( compareText, message ) {
lastEvent = p.getTrackEvent( p.getLastTrackEventId() );
equal( lastEvent.toString(), compareText, message );
}

p.twitter({
src: srcText
});
testLastEvent( srcText, "Custom text displayed with toString" );

p.twitter({});
testLastEvent( "@popcornjs", "Custom text displayed with toString using default" );

start();
});
@@ -132,6 +132,9 @@ var wikiCallback;
options.src.slice( options.src.lastIndexOf( "/" ) + 1 ) + "&format=json&callback=wikiCallback" + _guid );
}

options.toString = function() {
return options.src || options._natives.manifest.options.src[ "default" ];
};
},
/**
* @member wikipedia
@@ -90,3 +90,24 @@ test( "Popcorn wikipedia Plugin", function() {
Popcorn.plugin.debug = true;
popped.wikipedia({});
});

asyncTest( "Overriding default toString", 2, function() {
var p = Popcorn( "#video" ),
srcText = "http://en.wikipedia.org/wiki/Jungle",
lastEvent;

function testLastEvent( compareText, message ) {
lastEvent = p.getTrackEvent( p.getLastTrackEventId() );
equal( lastEvent.toString(), compareText, message );
}

p.wikipedia({
src: srcText
});
testLastEvent( srcText, "Custom text displayed with toString" );

p.wikipedia({});
testLastEvent( "http://en.wikipedia.org/wiki/Cat", "Custom text displayed with toString using default" );

start();
});

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
Oops, something went wrong.

0 comments on commit f4b273c

Please sign in to comment.