From cf5dda48a8954c438851a5f72ad39af000a46fb7 Mon Sep 17 00:00:00 2001 From: Mohammed Buttu Date: Wed, 18 May 2011 12:07:37 -0400 Subject: [PATCH] #332 Fixed styling and a typos. Added _teardown function. Made a unit test for _teardown. Changed timing of videos in demo and added more information in the page comments --- plugins/linkedin/popcorn.linkedin.html | 41 ++++++++++------ plugins/linkedin/popcorn.linkedin.js | 54 ++++++++++++--------- plugins/linkedin/popcorn.linkedin.unit.html | 4 +- plugins/linkedin/popcorn.linkedin.unit.js | 11 ++++- 4 files changed, 67 insertions(+), 43 deletions(-) diff --git a/plugins/linkedin/popcorn.linkedin.html b/plugins/linkedin/popcorn.linkedin.html index 04b2678..cf141a3 100644 --- a/plugins/linkedin/popcorn.linkedin.html +++ b/plugins/linkedin/popcorn.linkedin.html @@ -26,7 +26,7 @@ target: "sharediv", apikey: "ZOLRI2rzQS_oaXELpPF0aksxwFFEvoxAFZRLfHjaAhcGPfOX0Ds4snkJpWwKs8gk", start: 1, - end: 3 + end: 4 }) .linkedin({ type: "recommendproduct", @@ -35,8 +35,8 @@ companyid: "LinkedIn", productid: "201714", apikey: "ZOLRI2rzQS_oaXELpPF0aksxwFFEvoxAFZRLfHjaAhcGPfOX0Ds4snkJpWwKs8gk", - start: 4, - end: 7 + start: 5, + end: 8 }) .linkedin({ type: "memberprofile", @@ -45,32 +45,42 @@ target: "memberprofilediv", apikey: "ZOLRI2rzQS_oaXELpPF0aksxwFFEvoxAFZRLfHjaAhcGPfOX0Ds4snkJpWwKs8gk", start: 9, - end: 11 + end: 15 }) .linkedin({ type: "companyinsider", companyid: "1441", - target: "bottomdiv", + target: "companyinsiderdiv", apikey: "ZOLRI2rzQS_oaXELpPF0aksxwFFEvoxAFZRLfHjaAhcGPfOX0Ds4snkJpWwKs8gk", start: 9, - end: 11 + end: 15 }) .linkedin({ type: "companyprofile", companyid: "1441", format: "inline", - target: "bottomdiv", + target: "companyprofilediv", apikey: "ZOLRI2rzQS_oaXELpPF0aksxwFFEvoxAFZRLfHjaAhcGPfOX0Ds4snkJpWwKs8gk", - start: 13, - end: 17 + start: 16, + end: 27 }); }, false );

Popcorn LinkedIn Plug-in Demo

-

Right of video: share button, recommend button, member profile.
- Below video: company insider, company profile.
+ Right of video: +

+ Below video: + +

For a description of each plugin's purpose, go to: LinkedIn Plugins

@@ -92,9 +102,10 @@ -
-
-
-
+
+
+
+
+
diff --git a/plugins/linkedin/popcorn.linkedin.js b/plugins/linkedin/popcorn.linkedin.js index 1ecce9a..991fe64 100644 --- a/plugins/linkedin/popcorn.linkedin.js +++ b/plugins/linkedin/popcorn.linkedin.js @@ -2,7 +2,7 @@ (function (Popcorn){ -/** + /** * LinkedIn Popcorn plug-in * Places a LinkedIn plugin inside a div ( http://developers.facebook.com/docs/plugins/ ) * Options parameter will need a start, end, target, type, and an api key @@ -15,7 +15,7 @@ * Url is the desired url to share via LinkedIn. Defaults to the current page if no url is specified * Counter is the position where the counter will be positioned. This is used if the type is "share" or "recommendproduct" * The options are right and top (don't include this option if you do not want a counter) - * Format is is the data format of the member and company profile plugins. The options are inlined, hover, and click. Defaults to inline + * Format is the data format of the member and company profile plugins. The options are inlined, hover, and click. Defaults to inline * Companyid must be specified if the type is "companyprofile," "companyinsider," or "recommendproduct" * Productid must be specified if the type is "recommendproduct" * @@ -33,7 +33,7 @@ * apikey: "ZOLRI2rzQS_oaXELpPF0aksxwFFEvoxAFZRLfHjaAhcGPfOX0Ds4snkJpWwKs8gk", * start: 1, * end: 3 - * } ) + * }) * * This plugin will be displayed between 1 and 3 seconds, inclusive, in the video. This will show how many people have "shared" Google via LinkedIn, * with the number of people (counter) displayed to the right of the share plugin. @@ -58,14 +58,16 @@ _setup: function( options ) { var apikey = options.apikey, - target = document.getElementById( options.target ); + target = document.getElementById( options.target ), + script = document.createElement( "script" ); Popcorn.getScript("http://platform.linkedin.com/in.js"); - options._container = document.createElement( "script" ); + options._container = document.createElement( "div" ); + options._container.appendChild( script ); if ( apikey ) { - options._container.innerHTML = "api_key: " + apikey; + script.innerHTML = "api_key: " + apikey; } options.type = options.type.toLowerCase(); @@ -83,29 +85,29 @@ return { share: function () { - options._container.setAttribute( "type", "IN/Share" ); + script.setAttribute( "type", "IN/Share" ); if ( options.counter ) { - options._container.setAttribute( "data-counter", options.counter ); + script.setAttribute( "data-counter", options.counter ); } if ( options.url ) { - options._container.setAttribute( "data-url", options.url ); + script.setAttribute( "data-url", options.url ); } }, memberprofile: function () { - options._container.setAttribute( "type", "IN/MemberProfile" ); - options._container.setAttribute( "data-id", ( options.memberid ) ); - options._container.setAttribute( "data-format", ( options.format || "inline" ) ); + script.setAttribute( "type", "IN/MemberProfile" ); + script.setAttribute( "data-id", ( options.memberid ) ); + script.setAttribute( "data-format", ( options.format || "inline" ) ); if ( options.text && options.format.toLowerCase() !== "inline" ) { - options._container.setAttribute( "data-text", options.text ); + script.setAttribute( "data-text", options.text ); } }, companyinsider: function () { - options._container.setAttribute( "type", "IN/CompanyInsider" ); - options._container.setAttribute( "data-id", options.companyid ); + script.setAttribute( "type", "IN/CompanyInsider" ); + script.setAttribute( "data-id", options.companyid ); if( options.modules ) { options._container.setAttribute( "data-modules", options.modules ); @@ -113,25 +115,25 @@ }, companyprofile: function () { - options._container.setAttribute( "type", "IN/CompanyProfile" ); - options._container.setAttribute( "data-id", ( options.companyid ) ); - options._container.setAttribute( "data-format", ( options.format || "inline" ) ); + script.setAttribute( "type", "IN/CompanyProfile" ); + script.setAttribute( "data-id", ( options.companyid ) ); + script.setAttribute( "data-format", ( options.format || "inline" ) ); if ( options.text && options.format.toLowerCase() !== "inline" ) { - options._container.setAttribute( "data-text", options.text ); + script.setAttribute( "data-text", options.text ); } if ( options.related !== undefined ) { - options._container.setAttribute( "data-related", options.related ); + script.setAttribute( "data-related", options.related ); } }, recommendproduct: function () { - options._container.setAttribute( "type", "IN/RecommendProduct" ); - options._container.setAttribute( "data-company", ( options.companyid || "LinkedIn" ) ); - options._container.setAttribute( "data-product", ( options.productid || "201714" ) ); + script.setAttribute( "type", "IN/RecommendProduct" ); + script.setAttribute( "data-company", ( options.companyid || "LinkedIn" ) ); + script.setAttribute( "data-product", ( options.productid || "201714" ) ); if ( options.counter ) { - options._container.setAttribute( "data-counter", options.counter ); + script.setAttribute( "data-counter", options.counter ); } } }; @@ -166,6 +168,10 @@ */ end: function( event, options ) { options._container.parentNode.style.display = "none"; + }, + _teardown: function( options ) { + var tar = document.getElementById( options.target ); + tar && tar.removeChild( options._container ); } }); })( Popcorn ); diff --git a/plugins/linkedin/popcorn.linkedin.unit.html b/plugins/linkedin/popcorn.linkedin.unit.html index e474a95..c9adf62 100644 --- a/plugins/linkedin/popcorn.linkedin.unit.html +++ b/plugins/linkedin/popcorn.linkedin.unit.html @@ -1,7 +1,7 @@ - Popcorn API + Popcorn LinkedIn Plugin Test