From 02717a8b8f73830bc4404e3a79317c82a34742ff Mon Sep 17 00:00:00 2001 From: ScottDowne Date: Mon, 20 Dec 2010 14:18:43 -0500 Subject: [PATCH] [#159] initial twitter plugin without unit tests --- plugins/twitter/popcorn.twitter.html | 55 ++++++++++++++ plugins/twitter/popcorn.twitter.js | 107 +++++++++++++++++++++++++++ 2 files changed, 162 insertions(+) create mode 100644 plugins/twitter/popcorn.twitter.html create mode 100644 plugins/twitter/popcorn.twitter.js diff --git a/plugins/twitter/popcorn.twitter.html b/plugins/twitter/popcorn.twitter.html new file mode 100644 index 0000000..3dd09ac --- /dev/null +++ b/plugins/twitter/popcorn.twitter.html @@ -0,0 +1,55 @@ + + + + Popcorn Twitter Plug-in Demo + + + + + + + +

Popcorn Twitter Plug-in Demo

+

Twitter widget will appear at 5 seconds and disappear at 15 seconds.

+

More Twitter widget will appear at 20 seconds and disappear at 45 seconds.

+
+ +
+
+ + diff --git a/plugins/twitter/popcorn.twitter.js b/plugins/twitter/popcorn.twitter.js new file mode 100644 index 0000000..9eb5c82 --- /dev/null +++ b/plugins/twitter/popcorn.twitter.js @@ -0,0 +1,107 @@ +// PLUGIN: FLICKR + +(function (Popcorn) { + + /** + * Twitter popcorn plug-in + * Appends a Twitter widget to an element on the page. + * 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 + * Target is the id of the document element that the images are + * appended to, this target element must exist on the DOM + * + * @param {Object} options + * + * Example: + var p = Popcorn('#video') + .twitter({ + start: 5, // seconds, mandatory + end: 15, // seconds, mandatory + source: 'from:stevesong', // mandatory + title: 'title', // optional + subject: 'subject', // optional + height: 200, // optional + width: 250, // optional + target: 'twitterdiv' // mandatory + } ) + * + */ + Popcorn.plugin( "twitter" , { + + _setup: function( options ) { + + // setup widget div that is unique per track + options.container = document.createElement( 'div' ); // create the div to store the widget + options.container.setAttribute('id', Popcorn.guid()); // use this id to connect it to the widget + options.container.style.display = "none"; // display none by default + 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 || "", + title = options.title || null, + subject = options.subject || null, + width = options.width || 250, + height = options.height || 200; + + // 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' + }, + 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(); + }, + + /** + * @member Twitter + * 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.style.display = "inline"; + }, + + /** + * @member Twitter + * 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.style.display = "none"; + } + }); + +})( Popcorn ); -- 2.43.0