From: Matthew Schranz Date: Wed, 28 Sep 2011 16:26:06 +0000 (-0400) Subject: [#734] Removed setOptions function as it was not needed. Fixed destruction of object... X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=2a717cfa0017c018f51a8327257c16b7e26cad8d;p=popcorn-js.git [#734] Removed setOptions function as it was not needed. Fixed destruction of object. Added _teardown --- diff --git a/plugins/facebook/popcorn.facebook.js b/plugins/facebook/popcorn.facebook.js index 57e2f37..dc36766 100755 --- a/plugins/facebook/popcorn.facebook.js +++ b/plugins/facebook/popcorn.facebook.js @@ -207,27 +207,23 @@ // 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. - var setOptions = function() { - // activity feed uses 'site' rather than 'href' - var attr = _type === "activity" ? "site" : "href"; + // activity feed uses 'site' rather than 'href' + var attr = _type === "activity" ? "site" : "href"; - options._container.setAttribute( attr, ( options[ attr ] || document.URL ) ); + options._container.setAttribute( attr, ( options[ attr ] || document.URL ) ); - // create an array of Facebook widget attributes - var fbAttrs = ( - "width height layout show_faces stream header colorscheme" + - " maxrows border_color recommendations font always_post_to_friends xid" - ).split(" "); + // create an array of Facebook widget attributes + var fbAttrs = ( + "width height layout show_faces stream header colorscheme" + + " maxrows border_color recommendations font always_post_to_friends xid" + ).split(" "); - Popcorn.forEach( fbAttrs, function( attr ) { - // Test for null/undef. Allows 0, false & "" - if ( options[ attr ] != null ) { - options._container.setAttribute( attr, options[ attr ] ); - } - }); - }; - - setOptions(); + Popcorn.forEach( fbAttrs, function( attr ) { + // Test for null/undef. Allows 0, false & "" + if ( options[ attr ] != null ) { + options._container.setAttribute( attr, options[ attr ] ); + } + }); if ( !target && Popcorn.plugin.debug ) { throw new Error( "Facebook target container doesn't exist" ); @@ -251,7 +247,9 @@ */ end: function( event, options ){ options._container.style.display = "none"; - options._container.innerHTML = ""; + }, + _teardown: function( event, options ){ + target && target.removeChild( options._container ); } }); diff --git a/plugins/facebook/popcorn.facebook.unit.js b/plugins/facebook/popcorn.facebook.unit.js index 9201ab2..00b03c0 100755 --- a/plugins/facebook/popcorn.facebook.unit.js +++ b/plugins/facebook/popcorn.facebook.unit.js @@ -30,7 +30,7 @@ test( "Popcorn Facebook Plugin", function () { end: 6 }) .facebook({ - href: "http://www.facebook.com/senecacollege", + href: "https://www.facebook.com/boardwalkempire", type: "FACEPILE", target: "facepilediv", start: 4,