From: Matthew Schranz Date: Wed, 28 Sep 2011 20:40:32 +0000 (-0400) Subject: [#734]Each plugin in it's own div. Trying to get one test working X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=b27d151ae6e39cbf7ff7a79a5c7bb9015a87105c;p=popcorn-js.git [#734]Each plugin in it's own div. Trying to get one test working --- diff --git a/plugins/facebook/popcorn.facebook.html b/plugins/facebook/popcorn.facebook.html index 4a4fbbd..4da7926 100755 --- a/plugins/facebook/popcorn.facebook.html +++ b/plugins/facebook/popcorn.facebook.html @@ -14,7 +14,7 @@ type: "live-stream", target: "activitydiv", start: 1, - end: 10, + end: 50, // id is from example http://developers.facebook.com/docs/reference/plugins/live-stream/ event_app_id: 174243249296725 }) @@ -23,13 +23,13 @@ target: "likediv", layout: "box_count", start: 5, - end: 10 + end: 50 }) .facebook({ type: "send", target: "likediv", start: 1, - end: 5 + end: 15 }) .facebook({ href: "http://www.facebook.com/senecacollege", @@ -38,7 +38,7 @@ header: "false", target: "likeboxdiv", start: 6, - end: 10 + end: 50 }) .facebook({ site: "http://popcornjs.org/", @@ -46,15 +46,15 @@ target: "activitydiv", header: true, start: 11, - end: 15 + end: 50 }) .facebook({ - href: "http://www.facebook.com/senecacollege", + href: "https://www.facebook.com/boardwalkempire", type: "FACEPILE", target: "facepilediv", width: 300, start: 10, - end: 15 + end: 50 }); }, false); diff --git a/plugins/facebook/popcorn.facebook.js b/plugins/facebook/popcorn.facebook.js index dc36766..55256ce 100755 --- a/plugins/facebook/popcorn.facebook.js +++ b/plugins/facebook/popcorn.facebook.js @@ -46,7 +46,7 @@ * This will show how many people "like" Seneca College's Facebook page, and show their profile pictures */ - var ranOnce = false; + var ranOnce = false, idx = 0; Popcorn.plugin( "facebook" , { manifest: { @@ -165,8 +165,17 @@ _setup: function( options ) { var target = document.getElementById( options.target ), - _type = options.type; - + _type = options.type, + facebookdiv; + + /* + // Ensure target container chosen by user exists + if ( !target && Popcorn.plugin.debug ) { + throw new Error( "Facebook target container doesn't exist" ); + } + target && target.appendChild( containerDiv ); + */ + // facebook script requires a div named fb-root if ( !document.getElementById( "fb-root" ) ) { var fbRoot = document.createElement( "div" ); @@ -203,14 +212,17 @@ } - options._container = document.createElement( "fb:" + _type ); + options.container = document.createElement( "div" ); + options.container.id = "facebookdiv-" + Popcorn.guid(); + facebookdiv = document.createElement( "fb:" + _type ); + options.container.appendChild( facebookdiv ); // All the the "types" for facebook share largely identical attributes, for loop suffices. // ** Credit to Rick Waldron, it's essentially all his code in this function. // activity feed uses 'site' rather than 'href' var attr = _type === "activity" ? "site" : "href"; - options._container.setAttribute( attr, ( options[ attr ] || document.URL ) ); + facebookdiv.setAttribute( attr, ( options[ attr ] || document.URL ) ); // create an array of Facebook widget attributes var fbAttrs = ( @@ -221,14 +233,14 @@ Popcorn.forEach( fbAttrs, function( attr ) { // Test for null/undef. Allows 0, false & "" if ( options[ attr ] != null ) { - options._container.setAttribute( attr, options[ attr ] ); + facebookdiv.setAttribute( attr, options[ attr ] ); } }); if ( !target && Popcorn.plugin.debug ) { throw new Error( "Facebook target container doesn't exist" ); } - target && target.appendChild( options._container ); + target && target.appendChild( options.container ); }, /** * @member facebook @@ -237,7 +249,7 @@ * options variable */ start: function( event, options ){ - options._container.style.display = ""; + options.container.style.display = ""; }, /** * @member facebook @@ -246,11 +258,11 @@ * options variable */ end: function( event, options ){ - options._container.style.display = "none"; + options.container.style.display = "none"; }, _teardown: function( event, options ){ - target && target.removeChild( options._container ); + target && target.removeChild( facebookdiv ); } }); -})( Popcorn, this ); +})( Popcorn, this ); \ No newline at end of file diff --git a/plugins/facebook/popcorn.facebook.unit.js b/plugins/facebook/popcorn.facebook.unit.js index 00b03c0..5d70e65 100755 --- a/plugins/facebook/popcorn.facebook.unit.js +++ b/plugins/facebook/popcorn.facebook.unit.js @@ -1,7 +1,7 @@ test( "Popcorn Facebook Plugin", function () { var popped = Popcorn( "#video" ), - expects = 5, + expects = 6, count = 0, interval, interval2, @@ -39,7 +39,8 @@ test( "Popcorn Facebook Plugin", function () { }) .volume( 0 ) .play(); - + + setupId = popped.getLastTrackEventId(); ok ( document.getElementById( "activitydiv" ), "activitydiv exists on the page" ); plus(); @@ -56,7 +57,12 @@ test( "Popcorn Facebook Plugin", function () { popped.exec( 5, function() { ok( document.getElementById( "facepilediv" ).innerHTML, "Facepilediv is not empty at 0:05 (expected)" ); plus(); + + popped.pause().removeTrackEvent( setupId ); + ok( !facepilediv, "removed facebook social plugin was properly destroyed" ); + plus(); }); + });