From: Dan Ventura Date: Wed, 11 May 2011 02:20:15 +0000 (-0400) Subject: Fixed activity feed href bug, added more documentation, added start and end functions... X-Git-Tag: v0.6~4^2~1^2~6 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=54eaf54ffcb4aa8f2de3bf260d11ec3f5b41d089;p=popcorn-js.git Fixed activity feed href bug, added more documentation, added start and end functions, revised facebook unit tests --- diff --git a/plugins/facebook/popcorn.facebook.html b/plugins/facebook/popcorn.facebook.html index 499be86..3e12cd8 100644 --- a/plugins/facebook/popcorn.facebook.html +++ b/plugins/facebook/popcorn.facebook.html @@ -11,25 +11,35 @@ .volume(0) .play() .facebook({ - type: "LIKE", - target: "likediv" + type : "LIKE", + target: "likediv", + start : 5, + end : 10 } ) .facebook({ - href: "http://www.facebook.com/senecacollege", - type: "LIKE-BOX", - show_faces: "true", + href : "http://www.facebook.com/senecacollege", + type : "LIKE-BOX", + show_faces : "true", header: "false", - target: "likeboxdiv" + target: "likeboxdiv", + start : 3, + end : 8 } ) .facebook({ - href: "http://popcornjs.org/", - type: "ACTIVITY", - target: "activitydiv" + site : "http://popcornjs.org/", + type : "ACTIVITY", + target: "activitydiv", + header: true, + start : 9, + end : 13 } ) .facebook({ - href: "http://www.facebook.com/senecacollege", - type: "FACEPILE", - target: "facepilediv" + href : "http://www.facebook.com/senecacollege", + type : "FACEPILE", + target: "facepilediv", + width : 300, + start : 5, + end : 15 } ); }, false); @@ -61,6 +71,7 @@
+
diff --git a/plugins/facebook/popcorn.facebook.js b/plugins/facebook/popcorn.facebook.js index 58f5b6a..9d850bc 100644 --- a/plugins/facebook/popcorn.facebook.js +++ b/plugins/facebook/popcorn.facebook.js @@ -5,25 +5,42 @@ * 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 + * Options parameter will need a target, type, start and end time * Type is the name of the plugin in fbxml format. Options: LIKE (default), LIKE-BOX, ACTIVITY, FACEPILE - * Target is the id of the document element that the text needs to be - * attached to, this target element must exist on the DOM + * Target is the id of the document element that the text needs to be attached to. This target element must exist on the DOM + * Start is the time that you want this plug-in to execute + * End is the time that you want this plug-in to stop executing * * @param {Object} options * * Example: var p = Popcorn('#video') .facebook({ - href: "http://www.facebook.com/senecacollege", - type: "LIKE-BOX", + type : "LIKE-BOX", + target: "likeboxdiv", + start : 3, + end : 10, + href : "http://www.facebook.com/senecacollege", show_faces: "true", - header: "false", - target: "likeboxdiv" + header: "false" } ) - - This will show how many people "like" Seneca College's Facebook page, and show their profile pictures (show_faces) + * This will show how many people "like" Seneca College's Facebook page, and show their profile pictures (show_faces) * + Other than the mandatory four parameters, there are several optional parameters (Some options are only applicable to certain plugins) + * Font - the font of the text contained in the plugin. Options: arial / segoe ui / tahoma / trebuchet ms / verdana / lucida grande + * Action - like button will either "Like" or "Recommend". Options: recommend / like(default) + * Recommendations - shows recommendations, if any, in the bottom half of activity feed. Options: true / false(default) + * Border_color - border color of the activity feed. Names (i.e: "white") and html color codes are valid + * Max_rows - number of rows to disperse pictures in facepile. Default is 1 + * Stream - displays a the latest posts from the specified page's wall. Options: true / false(default) + * Header - displays the title of like-box or activity feed. Options: true / false(default) + * Colorscheme - changes the color of almost all plugins. Options: light(default) / dark + * Layout - changes the format of the 'like' count (written in english or a number in a callout). + Options: box_count / button_count / standard(default) + * Show_faces - show pictures beside like button and like-box. Options: true / false(default) + * Href - url to apply to the plugin. Default is current page + * Site - href for activity feed. No idea why it must be "site". Default is current page + * Type - determines which plugin to create */ Popcorn.plugin( "facebook" , { manifest:{ @@ -34,9 +51,25 @@ website: "dsventura.blogspot.com" }, options:{ - id : {elem:"input", type:"text", label:"Id"}, - type : {elem:"input", type:"text", label:"Type"}, - target : "facebook-container" + type : {elem:"select", options:["LIKE", "LIKE-BOX", "ACTIVITY", "FACEPILE"], label:"Type"}, + target : "facebook-container", + start : {elem:'input', type:'number', label:'In'}, + end : {elem:'input', type:'number', label:'Out'}, + // optional parameters: + font : {elem:"input", type:"text", label:"font"}, + action : {elem:"select", options:["like", "recommend"], label:"Action"}, + recommendations : {elem:"select", options:["false", "true"], label:"Recommendations"}, + border_color : {elem:"input", type:"text", label:"Border_color"}, + height : {elem:"input", type:"text", label:"Height"}, + width : {elem:"input", type:"text", label:"Width"}, + max_rows : {elem:"input", type:"text", label:"Max_rows"}, + stream : {elem:"select", options:["false", "true"], label:"Stream"}, + header : {elem:"select", options:["false", "true"], label:"Header"}, + colorscheme : {elem:"select", options:["light", "dark"], label:"Colorscheme"}, + layout : {elem:"select", options:["standard", "button_count", "box_count"], label:"Layout"}, + show_faces : {elem:"select", options:["false", "true"], label:"Showfaces"}, + href : {elem:"input", type:"text", label:"Href"}, + site : {elem:"input", type:"text", label:"Site"} } }, @@ -80,48 +113,79 @@ return; } - options._container = document.createElement( "fb:" + ( options.type.toLowerCase() || "like" ) ); + options.type = options.type.toLowerCase(); + options._container = document.createElement( "fb:" + options.type ); // setOptions property list doesn't accept dashes - if( options.type === "LIKE-BOX" ) { + if( options.type === "like-box" ) { options.type = "likebox"; } var setOptions = (function ( options ) { - options._container.setAttribute( "href", ( options.href || document.URL ) ); + options._container.style.display = "none"; + // activity feed uses 'site' rather than 'href' + if ( options.type === "activity" ) { + options._container.setAttribute( "site", ( options.site || document.URL)); + } else { + 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( "width", options.width ); + options._container.setAttribute( "show_faces", options.show_faces ); + options._container.setAttribute( "layout", options.layout ); options._container.setAttribute( "font", options.font ); + options._container.setAttribute( "colorscheme", options.colorscheme ); }, 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" ) ); + options._container.setAttribute( "height", ( options.height || 250 ) ); + options._container.setAttribute( "width", options.width ); + options._container.setAttribute( "show_faces", options.show_faces ); + options._container.setAttribute( "stream", options.stream ); + options._container.setAttribute( "header", options.header ); + options._container.setAttribute( "colorscheme", options.colorscheme ); }, facepile: function () { - options._container.setAttribute( "width", ( options.width || "200" ) ); - options._container.setAttribute( "max_rows", ( options.max_rows || "1" ) ); + options._container.setAttribute( "height", options.height ); + options._container.setAttribute( "width", options.width ); + 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( "width", options.width ); + options._container.setAttribute( "height", options.height ); + options._container.setAttribute( "header", options.header ); + options._container.setAttribute( "border_color", options.border_color ); + options._container.setAttribute( "recommendations", options.recommendations ); options._container.setAttribute( "font", options.font ); + options._container.setAttribute( "colorscheme", options.colorscheme ); } }; })( options ); - - setOptions[ options.type.toLowerCase() ] && setOptions[ options.type.toLowerCase() ](); + + setOptions[ options.type ](); if ( document.getElementById( options.target ) ) { document.getElementById( options.target ).appendChild( options._container ); } + }, + /** + * @member facebook + * The start function will be executed when the currentTime + * of the video reaches the start time provided by the + * options variable + */ + start: function( event, options ){ + options._container.style.display = "inline"; + }, + /** + * @member facebook + * The end function will be executed when the currentTime + * of the video reaches the end time provided by the + * options variable + */ + end: function( event, options ){ + options._container.style.display = "none"; } }); diff --git a/plugins/facebook/popcorn.facebook.unit.js b/plugins/facebook/popcorn.facebook.unit.js index 9426f63..733fccf 100644 --- a/plugins/facebook/popcorn.facebook.unit.js +++ b/plugins/facebook/popcorn.facebook.unit.js @@ -23,36 +23,51 @@ test("Popcorn Facebook Plugin", function () { plus(); popped.facebook({ - type:"LIKE", - target: "likediv" + target: "likediv", + start : 1, + end : 7 } ) .facebook({ href : "http://www.facebook.com/senecacollege", type : "LIKE_BOX", - show_faces : "true", - header: "false", - target: "likeboxdiv" + target: "likeboxdiv", + start : 2, + end : 7 } ) .facebook({ - href : "http://popcornjs.org/", + site : "http://popcornjs.org/", type : "ACTIVITY", - target : "activitydiv" + target : "activitydiv", + start : 3, + end : 7 } ) .facebook({ href : "http://www.facebook.com/senecacollege", type : "FACEPILE", - target : "facepilediv" + target : "facepilediv", + start : 4, + end : 7, + width : 300 } ) .volume(0) .play(); - popped.exec( 5, function() { + popped.exec( 2, function() { ok ( document.getElementById( "likediv" ).innerHTML.length > 0, "No type specified. Like button added to div" ); plus(); + }); + + popped.exec( 3, function() { ok ( document.getElementById( "likeboxdiv" ).innerHTML.length === 0, "Like box is not added to div" ); plus(); + }); + + popped.exec( 4, function() { ok ( document.getElementById( "activitydiv" ).innerHTML.length > 0, "Activity feed is added to div" ); plus(); + }); + + popped.exec( 5, function() { ok ( document.getElementById( "facepilediv" ).innerHTML.length > 0, "Facepile is added to div" ); plus(); });