]> khamidou — GitHub mirrors - popcorn-js.git/commitdiff
[#159] small tweak with proper profile widget vs search widget
authorScottDowne <sdowne@learn.senecac.on.ca>
Mon, 20 Dec 2010 21:24:25 +0000 (16:24 -0500)
committerScottDowne <sdowne@learn.senecac.on.ca>
Mon, 20 Dec 2010 21:24:25 +0000 (16:24 -0500)
plugins/twitter/popcorn.twitter.html
plugins/twitter/popcorn.twitter.js

index 2d9990e7ba239e223072e20aeeadf82e5cd1854c..725cac7a0291ed5cf7170e346485c6bf17e6746c 100644 (file)
         start: 5, // seconds
         end: 15, // seconds
         title: 'Steve Song',
-        source: '@stevesong',
+        src: '@stevesong',
         target: 'twitterdiv',
       } )
       .twitter({
         start: 20, // seconds
         end: 45, // seconds
         title: 'Oil Spill',
-        source: '#oilspill',
+        src: '#oilspill',
         target: 'twitterdiv'
       } )
       .play();
index 0f2bc4decf1004bc1cde39cd6c162e8bf8884a3a..6b2be5076eebc6967a85282cf9940987cc79fdab 100644 (file)
@@ -8,7 +8,7 @@
    * Options parameter will need a start, end, target and source.
    * 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
-   * Source is the hash tag or twitter user to get tweets from
+   * Src is the hash tag or twitter user to get tweets from
    * Target is the id of the document element that the images are
    *  appended to, this target element must exist on the DOM
    * 
@@ -19,9 +19,7 @@
         .twitter({
           start:          5,                // seconds, mandatory
           end:            15,               // seconds, mandatory
-          source:         '@stevesong', // mandatory
-          title:          'title',          // optional
-          subject:        'subject',        // optional
+          src:            '@stevesong',     // mandatory, also accepts hash tags
           height:         200,              // optional
           width:          250,              // optional
           target:         'twitterdiv'      // mandatory
         document.getElementById( options.target ).appendChild( options.container ); // add the widget's div to the target div
 
         // setup info for the widget
-        var source  = options.source.replace(/^@/, "from:") || "",
-            title   = options.title || null,
-            subject   = options.subject || null,
+        var src  = options.src || "",
             width = options.width || 250,
-            height  = options.height || 200;
+            height  = options.height || 200,
+            profile = /^@/.test( src ),
+            hash = /^#/.test( src );
 
         // create widget
-        var widget = new TWTR.Widget({
-          version: 2,
-          type: 'search',
-          id: options.container.getAttribute('id'),  // use this id to connect it to the div
-          search: source,
-          title: title,
-          subject: subject,
-          rpp: 30,
-          width: width,
-          height: height,
-          interval: 6000,
-
-          theme: {
-            shell: {
-              background: '#ffffff',
-              color: '#000000'
+        if ( profile ) {
+
+          var widget = new TWTR.Widget({
+            version: 2,
+            type: 'profile',
+            id: options.container.getAttribute( 'id' ),  // use this id to connect it to the div
+            rpp: 30,
+            width: width,
+            height: height,
+            interval: 6000,
+
+            theme: {
+              shell: {
+                background: '#ffffff',
+                color: '#000000'
+              },
+              tweets: {
+                background: '#ffffff',
+                color: '#444444',
+                links: '#1985b5'
+              }
             },
-            tweets: {
-              background: '#ffffff',
-              color: '#444444',
-              links: '#1985b5'
+
+            features: {
+              loop: true,
+              timestamp: true,
+              avatars: true,
+              hashtags: true,
+              toptweets: true,
+              live: true,
+              scrollbar: false,
+              behavior: 'default'
             }
-          },
-
-          features: {
-            loop: true,
-            timestamp: true,
-            avatars: true,
-            hashtags: true,
-            toptweets: true,
-            live: true,
-            scrollbar: false,
-            behavior: 'default'
-          }
-        }).render().start();
+          }).render().setUser( src.replace( /^@/, "" ) ).start();
+
+        } else if ( hash ) {    
+      
+          var widget = new TWTR.Widget({
+            version: 2,
+            type: 'search',
+            id: options.container.getAttribute( 'id' ),  // use this id to connect it to the div
+            search: src,
+            subject: src,
+            rpp: 30,
+            width: width,
+            height: height,
+            interval: 6000,
+
+            theme: {
+              shell: {
+                background: '#ffffff',
+                color: '#000000'
+              },
+              tweets: {
+                background: '#ffffff',
+                color: '#444444',
+                links: '#1985b5'
+              }
+            },
+
+            features: {
+              loop: true,
+              timestamp: true,
+              avatars: true,
+              hashtags: true,
+              toptweets: true,
+              live: true,
+              scrollbar: false,
+              behavior: 'default'
+            }
+          }).render().start();
+
+        }
       },
 
       /**