]> khamidou — GitHub mirrors - popcorn-js.git/commitdiff
[#159] tightened up twitter widget
authorScottDowne <sdowne@learn.senecac.on.ca>
Thu, 23 Dec 2010 18:38:40 +0000 (13:38 -0500)
committerScottDowne <sdowne@learn.senecac.on.ca>
Thu, 23 Dec 2010 18:38:40 +0000 (13:38 -0500)
plugins/twitter/popcorn.twitter.js

index c30ff91b81ec5c795fbe076adebe754ecd821997..ed1df8ffe30eefe0fd71a03cfb7663aa4a773805 100644 (file)
             width   = options.width || 250,
             height  = options.height || 200,
             profile = /^@/.test( src ),
-            hash    = /^#/.test( src );
+            hash    = /^#/.test( src ),
+            widgetOptions = {
+              version: 2,
+              type: ( profile ? 'profile' : 'search' ),
+              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'
+                }
+              },
+              features: {
+                loop: true,
+                timestamp: true,
+                avatars: true,
+                hashtags: true,
+                toptweets: true,
+                live: true,
+                scrollbar: false,
+                behavior: 'default'
+              }
+            };
 
         // create widget
         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'
-              }
-            },
-
-            features: {
-              loop: true,
-              timestamp: true,
-              avatars: true,
-              hashtags: true,
-              toptweets: true,
-              live: true,
-              scrollbar: false,
-              behavior: 'default'
-            }
-          }).render().setUser( src.replace( /^@/, "" ) ).start();
+          new TWTR.Widget( widgetOptions ).render().setUser( src ).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,
+        } else if ( hash ) {
 
-            theme: {
-              shell: {
-                background: '#ffffff',
-                color: '#000000'
-              },
-              tweets: {
-                background: '#ffffff',
-                color: '#444444',
-                links: '#1985b5'
-              }
-            },
+          widgetOptions.search = src;
+          widgetOptions.subject = src;
 
-            features: {
-              loop: true,
-              timestamp: true,
-              avatars: true,
-              hashtags: true,
-              toptweets: true,
-              live: true,
-              scrollbar: false,
-              behavior: 'default'
-            }
-          }).render().start();
+          new TWTR.Widget( widgetOptions ).render().start();
 
         }
       },