]> khamidou — GitHub mirrors - popcorn-js.git/commitdiff
[#734]Each plugin in it's own div. Trying to get one test working
authorMatthew Schranz <schranz.m@gmail.com>
Wed, 28 Sep 2011 20:40:32 +0000 (16:40 -0400)
committerMatthew Schranz <schranz.m@gmail.com>
Wed, 28 Sep 2011 20:40:32 +0000 (16:40 -0400)
plugins/facebook/popcorn.facebook.html
plugins/facebook/popcorn.facebook.js
plugins/facebook/popcorn.facebook.unit.js

index 4a4fbbdd759fdaef5cd2846cb1a1765fc8cc0cb9..4da79261880fc48a4b763f8a8bf72980818ea02c 100755 (executable)
@@ -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
       })
         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/",
         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);
 
index dc36766301a341cd3d1ad6f994d6306657d4a50f..55256ce45ba3ce343ffcf54980dcca6242768c4a 100755 (executable)
@@ -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: {
     _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" );
       }
 
 
-      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 = (
       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
     * options variable
     */
     start: function( event, options ){
-      options._container.style.display = "";
+      options.container.style.display = "";
     },
     /**
     * @member facebook
     * 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
index 00b03c0196563cfbff2effc30d7c6e2a1dd148e1..5d70e653036c445bb01b9e4096e577e31ec29367 100755 (executable)
@@ -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();
   });
+  
 });