From: Dan Ventura Date: Wed, 16 Mar 2011 17:56:22 +0000 (-0400) Subject: added a facebook plugin to popcorn X-Git-Tag: v0.6~4^2~1^2~15 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=171084a1a77f028541f8d36f5e3501a1bebceecd;p=popcorn-js.git added a facebook plugin to popcorn --- diff --git a/plugins/facebook/popcorn.facebook.html b/plugins/facebook/popcorn.facebook.html new file mode 100644 index 0000000..3a02e1f --- /dev/null +++ b/plugins/facebook/popcorn.facebook.html @@ -0,0 +1,76 @@ + + + + Popcorn WebPage Plug-in Demo + + + + + + +

Popcorn Facebook Plug-in Demo

+

"Like" plugin directly below video. href is the page it's on. "Like box" is below "like". href is set to Seneca College's Facebook page
+ "Facepile" is to the right of the video (must be logged into facebook). href is also set to Seneca College's Facebook page.
+ "Activity feed" is below "Facepile". href is set to popcornjs.org.

+ +
+ +
+
+
+
+
+
+
+
+
+ + diff --git a/plugins/facebook/popcorn.facebook.js b/plugins/facebook/popcorn.facebook.js new file mode 100644 index 0000000..d6b71ac --- /dev/null +++ b/plugins/facebook/popcorn.facebook.js @@ -0,0 +1,117 @@ +//PLUGIN: facebook + +(function (Popcorn){ +/** + * Facebook Popcorn plug-in + * Places Facebook's "social plugins" inside a div ( http://developers.facebook.com/docs/plugins/ ) + * Sets options according to user input or default values + * Options parameter will need a target and a type + * Type is the name of the plugin in fbxml format. i.e: would have a type of like, respectively + * Target is the id of the document element that the text needs to be + * attached to, this target element must exist on the DOM + * + * @param {Object} options + * + * Example: + var p = Popcorn('#video') + .facebook({ + id: "fb-likebox", + href: "http://www.facebook.com/senecacollege", + type: "LIKE-BOX", + show_faces: "true", + header: "false", + target: 'likeboxdiv' + } ) + + This will show how many people "like" Seneca College's Facebook page, and show their profile pictures (show_faces) + * + */ + Popcorn.plugin( "facebook" , { + manifest:{ + about:{ + name : "Popcorn Facebook Plugin", + version: "0.1", + author : "Dan Ventura", + website: "dsventura.blogspot.com" + }, + options:{ + id : {elem:'input', type:'text', label:'Id'}, + type : {elem:"input", type:'text', label:"Type"}, + target : 'facebook-container' + } + }, + + _setup: function( options ) { + + // facebook script requires a div named fb-root + if( !document.getElementById('fb-root') ) { + var fbRoot = document.createElement( 'div' ); + fbRoot.id = "fb-root"; + document.body.appendChild( fbRoot ); + //initialize facebook JS SDK + window.fbAsyncInit = function() { + FB.init({ + appId : 'YOUR APP ID', + status : true, + cookie : true, + xfbml : true + }); + }; + //load facebook script asynchronously + (function() { + var e = document.createElement( 'script' ); + e.setAttribute( 'src', 'http://connect.facebook.net/en_US/all.js' ); + e.setAttribute( 'async', 'true' ); + document.getElementById( 'fb-root' ).appendChild( e ); + }()); + } + + options._container = document.createElement( 'fb:' + options.type.toLowerCase() ); + + //setOptions property list doesn't accept dashes + if(options.type === "LIKE-BOX") { + console.log(options.type); + options.type = "likebox"; + console.log(options.type); + } + + // + var setOptions = (function ( options ) { + options._container.setAttribute( 'href', ( options.href || document.URL ) ); + return { + like: function () { + options._container.setAttribute( 'width', ( options.width || "450" ) ); + options._container.setAttribute( 'show_faces', ( options.show_faces || "false" ) ); + options._container.setAttribute( 'layout', ( options.layout || "standard" ) ); + options._container.setAttribute( 'font', options.font ); + }, + likebox: function () { + options._container.setAttribute( 'width', ( options.width || "292" ) ); + options._container.setAttribute( 'show_faces', ( options.show_faces || "false" ) ); + options._container.setAttribute( 'stream', ( options.stream || "false" ) ); + options._container.setAttribute( 'header', ( options.header || "true" ) ); + }, + facepile: function () { + options._container.setAttribute( 'width', ( options.width || "200" ) ); + options._container.setAttribute( 'max_rows', ( options.max_rows || "1" ) ); + }, + activity: function () { + options._container.setAttribute( 'width', ( options.width || "300" ) ); + options._container.setAttribute( 'height', ( options.height || "300" ) ); + options._container.setAttribute( 'header', ( options.header || "true" ) ); + options._container.setAttribute( 'border_color', ( options.border_color || "#000000" ) ); + options._container.setAttribute( 'recommendations', ( options.recommendations || "false" ) ); + options._container.setAttribute( 'font', options.font ); + }, + }; + })( options ); + + setOptions[ options.type.toLowerCase() ] && setOptions[ options.type.toLowerCase() ](); + + if ( document.getElementById( options.target ) ) { + document.getElementById( options.target ).appendChild( options._container ); + } + } + }); + +})( Popcorn ); \ No newline at end of file