]> khamidou — GitHub mirrors - popcorn-js.git/commitdiff
#332 Added unit tests and added/modified documentation
authorMohammed Buttu <mohammedbuttu@gmail.com>
Mon, 16 May 2011 02:21:14 +0000 (22:21 -0400)
committerMohammed Buttu <mohammedbuttu@gmail.com>
Mon, 16 May 2011 02:21:14 +0000 (22:21 -0400)
plugins/linkedin/popcorn.linkedin.html
plugins/linkedin/popcorn.linkedin.js
plugins/linkedin/popcorn.linkedin.unit.html [new file with mode: 0644]
plugins/linkedin/popcorn.linkedin.unit.js [new file with mode: 0644]

index 145309ce1074224bf1ccbe79c9e3432cd40e84f1..e37e22d2ecb96c1227d0ce96575928ef5da8444e 100644 (file)
@@ -2,6 +2,14 @@
 <html>
 <head>
   <title>Popcorn LinkedIn Plug-in Demo</title>
+    <!--
+    ATTENTION
+  
+    This demo uses an API key obtained for testing the LinkedIn Popcorn.js
+    plugin. Please do not use it for other purposes. This API key is meant
+    to be used on localhost (port 80). For other purposes, please obtain an API key
+    from https://www.linkedin.com/secure/developer.
+  -->
   <script src="http://platform.linkedin.com/in.js" type="text/javascript"></script>
   <script src="../../popcorn.js"></script>
   <script src="popcorn.linkedin.js"></script>
@@ -15,7 +23,7 @@
         counter   : 'right',
         url       : "http://www.google.ca",
         target    : "sharediv",
-        api_key   : 'ZOLRI2rzQS_oaXELpPF0aksxwFFEvoxAFZRLfHjaAhcGPfOX0Ds4snkJpWwKs8gk',
+        apikey   : 'ZOLRI2rzQS_oaXELpPF0aksxwFFEvoxAFZRLfHjaAhcGPfOX0Ds4snkJpWwKs8gk',
         start     : 1,
         end       : 3
       } )
@@ -25,7 +33,7 @@
         target    : "recommenddiv",
         companyid : 'LinkedIn',
         productid : '201714',
-        api_key   : 'ZOLRI2rzQS_oaXELpPF0aksxwFFEvoxAFZRLfHjaAhcGPfOX0Ds4snkJpWwKs8gk',
+        apikey   : 'ZOLRI2rzQS_oaXELpPF0aksxwFFEvoxAFZRLfHjaAhcGPfOX0Ds4snkJpWwKs8gk',
         start     : 4,
         end       : 7
       } )
@@ -34,7 +42,7 @@
         memberid  : '/in/jeffweiner08',
         format    : 'inline',
         target    : "memberprofilediv",
-        api_key   : 'ZOLRI2rzQS_oaXELpPF0aksxwFFEvoxAFZRLfHjaAhcGPfOX0Ds4snkJpWwKs8gk',
+        apikey   : 'ZOLRI2rzQS_oaXELpPF0aksxwFFEvoxAFZRLfHjaAhcGPfOX0Ds4snkJpWwKs8gk',
         start     : 9,
         end       : 11
       } )
@@ -42,7 +50,7 @@
         type      : 'companyinsider',
         companyid : '1441',
         target    : "bottomdiv",
-        api_key   : 'ZOLRI2rzQS_oaXELpPF0aksxwFFEvoxAFZRLfHjaAhcGPfOX0Ds4snkJpWwKs8gk',
+        apikey   : 'ZOLRI2rzQS_oaXELpPF0aksxwFFEvoxAFZRLfHjaAhcGPfOX0Ds4snkJpWwKs8gk',
         start     : 9,
         end       : 11
       } )
@@ -51,7 +59,7 @@
         companyid : '1441',
         format    : 'inline',
         target    : "bottomdiv",
-        api_key   : 'ZOLRI2rzQS_oaXELpPF0aksxwFFEvoxAFZRLfHjaAhcGPfOX0Ds4snkJpWwKs8gk',
+        apikey   : 'ZOLRI2rzQS_oaXELpPF0aksxwFFEvoxAFZRLfHjaAhcGPfOX0Ds4snkJpWwKs8gk',
         start     : 13,
         end       : 17
       } )
@@ -63,7 +71,8 @@
 <h1 id="qunit-header">Popcorn LinkedIn Plug-in Demo</h1>
   <p>Right of video: share button, recommend button, member profile. <br />
      Below video: company insider, company profile.<br />
-     For a description of each plugin's purpose, go to: <a href="http://developer.linkedin.com/community/plugins">LinkedIn Plugins</a></p>
+     For a description of each plugin's purpose, go to: <a href="http://developer.linkedin.com/community/plugins">LinkedIn Plugins</a><br/>
+  </p>
   
   <div>
     <video id='video' 
index 20ca09b95b73892804bbab357a4894983a623a82..96fe8d50f6783f3788ebb0ddddd6adb8acff65d0 100644 (file)
@@ -1,22 +1,18 @@
 //PLUGIN: linkedin
 (function (Popcorn){
 /**
-   * LinkedIn Popcorn plug-in 
-   * An api_key must be specified before the linkedin.js script
+   * LinkedIn Popcorn plug-in
    * Places a  LinkedIn plugin 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. Either share, memberprofile, companyinsider, companyprofile, or recommendproduct
-   * Target is the id of the document element that the plugin needs to be 
-   * attached to, this target element must exist on the DOM
-   * 
+   * Options parameter will need a start, end, target, type, and an api key
+   * 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
+   * Target is the id of the document element that the plugin needs to be attached to, this target element must exist on the DOM
+   * Type is the name of the plugin: share, memberprofile, companyinsider, companyprofile, or recommendproduct  
+   * Apikey is your own api key from obtained from https://www.linkedin.com/secure/developer
+   *
    * @param {Object} options
    * 
    * Example:
-   * // This api_key is valid for the matrix.senecac.on.ca domain
-   * <script>
-   *   var api_key = 'ND1uSIEUBH8MkI8E7g41kgGlWUexzvFL9uB2ihJbIrFuqunFq8aVmUrxyfAqxCBX';
-   * </script>
    * <script src="popcorn.linkedin.js"></script>
    * ...
    * var p = Popcorn('#video')
    *       url     : "http://www.google.ca",
    *       counter : "right",
    *       target  : 'sharediv'
+   *       api_key : 'ZOLRI2rzQS_oaXELpPF0aksxwFFEvoxAFZRLfHjaAhcGPfOX0Ds4snkJpWwKs8gk',
+   *       start   : 1,
+   *       end     : 3
    *     } )
    *
-   * This will show how many people have "shared" Google (default url is current page, if non specified) via LinkedIn.
+   * This will show how many people have "shared" Google (default url is current page, if none specified) via LinkedIn.
    * Will show number of people (counter) to the right of the share plugin.
    */
    
@@ -46,7 +45,7 @@
     },
     
     _setup: function( options ) {
-      var api_key = options.api_key,
+      var api_key = options.apikey,
                     target = document.getElementById( options.target );
    
       options._container = document.createElement( 'script' );
       }
       target.style.display = 'none';
     },
-
+    
+    /**
+     * @member linkedin
+     * 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.parentNode.style.display = 'block';
     },
     
+    /**
+     * @member linkedin
+     * 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.parentNode.style.display = 'none';
     }
diff --git a/plugins/linkedin/popcorn.linkedin.unit.html b/plugins/linkedin/popcorn.linkedin.unit.html
new file mode 100644 (file)
index 0000000..8fd8059
--- /dev/null
@@ -0,0 +1,43 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <title>Popcorn API</title>
+  <link rel="stylesheet" href="../../test/qunit/qunit.css" type="text/css" media="screen">
+  <script src="../../test/qunit/qunit.js"></script>
+  <!-- 
+    do not move - this must be called immediately prior to 
+    popcorn-api-draft.js
+  -->
+  
+  <script src="../../popcorn.js"></script>
+  <script src="popcorn.linkedin.js"></script>
+
+  <script src="popcorn.linkedin.unit.js"></script>
+</head>
+<body>
+  <h1 id="qunit-header">Popcorn Image Plugin</h1>
+  <h2 id="qunit-banner"></h2>
+  <div id="qunit-testrunner-toolbar"></div>
+  <h2 id="qunit-userAgent"></h2>
+  <ol id="qunit-tests"></ol>
+  <div id="qunit-fixture">  </div>
+  
+  <video id='video' 
+    controls
+    width= '250px'
+    poster="../../test/poster.png"> 
+
+    <source id='mp4'
+      src="../../test/trailer.mp4"
+      type='video/mp4; codecs="avc1, mp4a"'> 
+
+    <source id='ogv'
+      src="../../test/trailer.ogv"
+      type='video/ogg; codecs="theora, vorbis"'> 
+
+    <p>Your user agent does not support the HTML5 Video element.</p> 
+
+  </video> 
+  <div id="linkedindiv"></div>  
+</body>
+</html>
diff --git a/plugins/linkedin/popcorn.linkedin.unit.js b/plugins/linkedin/popcorn.linkedin.unit.js
new file mode 100644 (file)
index 0000000..105a444
--- /dev/null
@@ -0,0 +1,48 @@
+test("Popcorn LinkedIn Plugin", function () {
+  
+  var popped = Popcorn("#video"),
+      expects = 5,
+      count = 0,
+      linkedin = document.getElementById('linkedindiv');
+  
+  expect( expects );
+  
+  function plus() {
+    if ( ++count === expects) {
+      start();
+    }
+  }
+
+  stop();
+ 
+  ok('linkedin' in popped, "linkedin is a method of the popped instance");
+  plus();
+
+  equals ( linkedin.innerHTML, "", "initially, there is nothing inside the linkedin div" );
+  plus();
+  
+  
+  popped.linkedin({
+    type      : 'share',
+    counter   : 'right',
+    url       : "http://www.google.ca",
+    target    : "linkedindiv",
+    apikey   : 'ZOLRI2rzQS_oaXELpPF0aksxwFFEvoxAFZRLfHjaAhcGPfOX0Ds4snkJpWwKs8gk',
+    start     : 1,
+    end       : 3
+  } );
+
+  popped.exec( 2, function() {
+      ok( /block/.test( linkedin.style.display ), "Div contents are displayed" );
+      plus();
+      ok( /script/.test( linkedin.innerHTML ), "LinkedIn plugin exists" );
+      plus();
+  });
+  
+  popped.exec( 4, function() {
+      ok( /none/.test( linkedin.style.display ), "Div contents are hidden again" );
+      plus();
+  });
+  popped.volume(0).play();  
+  
+});