Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dotsunited/jquery-twitter-timeline
DEPRECATED. jQuery plugin to display the recent tweets of a twitter user.
https://github.com/dotsunited/jquery-twitter-timeline
Last synced: about 21 hours ago
JSON representation
DEPRECATED. jQuery plugin to display the recent tweets of a twitter user.
- Host: GitHub
- URL: https://github.com/dotsunited/jquery-twitter-timeline
- Owner: dotsunited
- License: mit
- Created: 2012-03-06T16:41:15.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2012-10-02T13:46:08.000Z (about 12 years ago)
- Last Synced: 2024-03-26T00:05:13.788Z (8 months ago)
- Language: JavaScript
- Homepage:
- Size: 139 KB
- Stars: 7
- Watchers: 11
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.markdown
- License: LICENSE
Awesome Lists containing this project
README
twitterTimeline
================twitterTimeline is a jQuery plugin to display the recent tweets of a twitter user that comes with a lot of configuration options.
Instead of the twitter search API this plugin uses the `GET statuses/user_timeline` from the API as the search does not return tweets older than a week.If localStorage is supported by the client, the fetched tweets will be cached within the localStorage to ensure, that tweets are displayed as soon as possible.
Basic usage
-----------To use twitterTimeline you have to include the latest jQuery build and the twitterTimeline source inside the `head` tag of your HTML document:
The second step is to add a container element to your HTML where you want the tweets to appear, e.g. `div`:
Finally you have to initialize the plugin with your desired parameters:
$(function() {
$('#tweetContainer').twitterTimeline({
//your configuration goes here
});
});
Configuration options
---------------------You can pass a set of these options to the initialize function to set a custom behaviour for the plugin.
Property (Type)
Default
Description
ajax (object)
{
url: 'http://api.twitter.com/1/statuses/user_timeline.json',
data: {
screen_name : 'twitter',
since_id : null,
max_id : null,
page : 1,
trim_user : true,
include_rts : false,
exclude_replies : true
},
dataType: 'jsonp'
}
Options passed to$.ajax()
. For thedata
part, you can find a complete list of valid parameters here: https://dev.twitter.com/docs/api/1/get/statuses/user_timeline
count (integer)
5
Specifies the number of tweets that are displayed by the plugin.
refresh (boolean|integer)
false
If set to a numeric value, the timeline will be refreshed every x milliseconds. New tweets will be prepended to the list, and old tweets will be deleted to maintain the maximum number specified with thecount
option.
tweetTemplate (object)
function(item) {
return '' + TwitterTimeline.parseTweet(item.text) + '
';
}
Function to render each tweet. The tweet data is passed as an argument, and the plugin is accessible via thethis
variable.
animateAdd (object)
function(el) { return el; }
Animate method to add elements. This method has to return the new element. If not, the element will not be added to the DOM.
animateRemove (object)
function(el) { el.remove(); }
Animate method to remove elements. This method has to remove the element from the DOM!
Methods
------------------The tweetTimeline plugin provieds the following public methods:
Method name
Parameter
Description
fetch(options)
(optional) ajax options
Fetch new Tweets from the API and add them to the containert. The optional ajax parameter extends the plugins ajax options.
update(items)
array items
Manually add tweets to the container.
If you want to manually refresh the tweet list for example, you can use the following line to fetch new tweets:
$('#tweetContainer').twitterTimeline('fetch');
Example settings
----------------The following example is used for the tweet box you can find on our [website](http://dotsunited.de).
$(function() {
$('#tweetContainer').twitterTimeline({
ajax: {
data: {
screen_name: 'dotsunited',
count: 1
}
},
count: 1,
tweetTemplate: function(item) {
var dateRegEx = /^(Mon|Tue|Wed|Thu|Fri|Sat|Sun) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) ([0-9]{2}) ([0-9]{2}):([0-9]{2}):([0-9]{2}) \+([0-9]{4}) ([0-9]{4})$/;
var date = dateRegEx.exec(item.created_at);
var tweet = '<p><div class="date">' + date[3] + ' ' + date[2] + ' ' + date[8] + '</div><p>' + $.twitterTimeline.parseTweet() + '</p></p>';
return tweet;
},
animateAdd: function(el) {
return el.hide().delay(300).slideDown(500);
},
animateRemove: function(el) {
el.slideUp(300, function() {
el.remove();
});
}
});
});
License
-------Copyright (c) 2012 Dots United GmbH.
Licensed under the MIT license.