-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathjquery.boastful.js
68 lines (64 loc) · 2.42 KB
/
jquery.boastful.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
(function ($) {
$.fn.boastful = function(options){
var output = $(this)
var defaults = {
location: location.href,
empty_message: 'No one\'s mentioned this page on Twitter yet. '+
'<a href="http://twitter.com?status='+ location.href +'">'
+'You could be the first</a>.',
limit: 50
}
options = $.extend({}, defaults, options)
function format_tweetback(tweetback) {
formatted = ''
formatted += '<div class="boastful">'
formatted += '<a href="'+tweetback.permalink_url+'">'
formatted += '<img src="'+tweetback.author.photo_url+'" />'
formatted += '</a>'
formatted += '<div class="boastful_pointer"></div>'
formatted += '<div class="boastful_tweet" style="display: none">'
formatted += '<div class="boastful_handle">@'+tweetback.author.url.split('/').pop()+'</div>'
formatted += '<div class="boastful_content">'+tweetback.content+'</div>'
formatted += '</div>'
formatted += '</div>'
return formatted
}
var parse_request = function(data){
var author_urls = []
if(data.response.list.length > 0) {
$.each(data.response.list, function(i,tweetback){
if($.inArray(tweetback.author.url,author_urls) > -1) {
return true
}
author_urls.push(tweetback.author.url)
output.append(format_tweetback(tweetback))
})
$('.boastful').mouseover(function(){ $(this).children('.boastful_tweet, .boastful_pointer').show() })
$('.boastful').mousemove(function(kmouse){
$(this).children('.boastful_tweet').css({
left:$(this).position().left-105,
top:$(this).position().top+25
})
$(this).children('.boastful_pointer').css({
left:$(this).position().left+18,
top:$(this).position().top+15
})
})
$('.boastful').mouseout(function(){ $(this).children('.boastful_tweet, .boastful_pointer').hide() })
} else {
output.append(options.empty_message)
}
}
$.ajax({
url:'http://otter.topsy.com/trackbacks.js',
data:
{
url: options.location,
perpage: options.limit
},
success:parse_request,
dataType:'jsonp'}
)
return this
}
})(jQuery)