From: Dan Ventura Date: Thu, 7 Apr 2011 17:40:00 +0000 (-0400) Subject: added linkedin plugin (unstable. hasnt been tested) X-Git-Tag: v0.6~29^2~3 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=fc40bb2248741ba68d5a3cfd8ce15d65ed8fc79a;p=popcorn-js.git added linkedin plugin (unstable. hasnt been tested) --- diff --git a/plugins/linkedin/linkedin.html b/plugins/linkedin/linkedin.html new file mode 100644 index 0000000..7e05105 --- /dev/null +++ b/plugins/linkedin/linkedin.html @@ -0,0 +1,50 @@ + + + + Popcorn LinkedIn Plug-in Demo + + + + + + +

Popcorn Facebook Plug-in Demo

+ + +
+ +
+ + + \ No newline at end of file diff --git a/plugins/linkedin/linkedin.js b/plugins/linkedin/linkedin.js new file mode 100644 index 0000000..5eb2d1f --- /dev/null +++ b/plugins/linkedin/linkedin.js @@ -0,0 +1,160 @@ +//PLUGIN: linkedin + +(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( "linkedin" , { + manifest:{ + about:{ + name : "Popcorn LinkedIn 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 : 'linkedin-container' + } + }, + + _setup: function( options ) { + // similar to facebook script load idea + if ( !document.getElementById("linkedin-root") ) { + var r = document.createElement( 'div' ); + r.setAttribute( 'div', "linkedin-root" ); + document.body.appendChild( r ); + + (function() { + var s = document.createElement( 'script' ); + s.setAttribute( 'src', "http://platform.linkedin.com/in.js" ); + s.setAttribute( 'type', "text/javascript" ); + s.setAttribute( 'async', 'true' ); + document.getElementById( 'linkedin-root' ).appendChild( s ); + }()); + } + + options._container = document.createElement( 'script' ); + options.type = options.type.toLowerCase(); + + var setOptions = (function ( options ) { + return { + share: function () { + options._container.setAttribute( 'type', "IN/Share" ); + if ( !!options.data-counter ) { + options._container.setAttribute( 'data-counter', options.data-counter ); + } + if ( !!options.data-url ) { + options._container.setAttribute( 'data-url', options.data-url); + } + /* + SHARE BTN + + options: + data-url (default = this. no element) + data-counter (top/right/null. no element) + */ + }, + memberprofile: function () { + options._container.setAttribute( 'type', "IN/MemberProfile" ); + options._container.setAttribute( 'data-format', "IN/MemberProfile" ); + options._container.setAttribute( 'data-counter', options.data-counter ); + if ( !!options.data-text && options.data-counter.toLowerCase() !== "inline" ) { + options._container.setAttribute( 'data-text', options.data-text ); + } + /* + MEMBER PROFILE + + options: + data-id (profile page) + data-format (inline/hover/click) + data-text (optional. no element) + */ + }, + companyinsider: function () { + options._container.setAttribute( 'type', "IN/CompanyInsider" ); + options._container.setAttribute( 'data-id', ( options.data-id || "LinkedIn" ) ); + if( !!options.data-modules ) { + options._container.setAttribute( 'data-modules', options.data-modules ); + } + /* + COMPANY INSIDER + + options: + data-id="LinkedIn" <- requires some string of numbers. possibly available to comapny site? + data-modules="innetwork,newhires,jobchanges" [no element = all? wtf?] + */ + }, + companyprofile: function () { + options._container.setAttribute( 'type', "IN/CompanyProfile" ); + options._container.setAttribute( 'data-id', ( options.data-id || "LinkedIn" ) ); + options._container.setAttribute( 'data-format', options.data-format ); + if ( !!options.data-text && options.data-format.toLowerCase() !== "inline" ) { + options._container.setAttribute( 'data-text', options.data-text ); + } + if ( options.data-related != undefined ) { + options._container.setAttribute( 'data-related', options.data-related ); + } + /* + COMPANY PROFILE + + options: + data-id="LinkedIn" <- again, needs some fucked up number + data-format="inline/hover/click" + data-text (optional. no element) + data-related="false" (no element for true) + */ + }, + recommendproduct: function () { + options._container.setAttribute( 'type', "IN/RecommendProduct" ); + options._container.setAttribute( 'data-company', ( options.data-id || "LinkedIn" ) ); + options._container.setAttribute( 'data-company', ( options.data-product || "201714" ) ); + options._container.setAttribute( 'data-format', options.data-format ); + if ( !!options.data-counter ) { + options._container.setAttribute( 'data-counter', options.data-counter ); + } + /* + RECOMMEND BTN + + options: + data-company="LinkedIn" <- number + data-product="201714" <- number + data-counter="top/right/null. no element" + */ + } + }; + })( options ); + + setOptions[ options.type ] && setOptions[ options.type ](); + + if ( document.getElementById( options.target ) ) { + document.getElementById( options.target ).appendChild( options._container ); + } + } + }); + +})( Popcorn ); \ No newline at end of file