-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpluspics.js
67 lines (61 loc) · 2.24 KB
/
pluspics.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
/*
jQuery plugin to retrieve images from Google+ and display with hover effect.
Author: Dan Aktinson (www.danatkinson.com)
Usage:
-----
$(document).ready(function() {
$('#myContainer').plusPics({
userId: 'your_user_id',
albumId: 'the_album_id',
numImages: 3,
title: 'Latest photos'
});
});
*/
(function($){
$.fn.plusPics = function(options) {
options = $.extend( {
'url' : "http://picasaweb.google.com/data/feed/api/user/"+options.userId+"/albumid/"+options.albumId+"?alt=json",
'title' : 'Images'
}, options);
return this.each(function() {
var cont = $(this);
$.getJSON(options.url+'&max-results='+options.numImages, function(data) {
var items = [];
$.each(data.feed.entry, function(i,item) {
url = item.media$group.media$content[0].url;
title = item.media$group.media$title.$t;
items.push('<li class="pluspic-'+i+'"><a title="'+title+'"><span><img src="' +url+ '" alt="'+title+'"/></span></a></li>');
});
$('<ul/>', {
'class': 'pluspics',
html: '<h3>'+options.title+'</h3>'+items.join('')+'<div class="clear"></div>'
}).appendTo(cont);
$($(cont).children('.pluspics').children('li').children('a').children('span').children('img')).load(function(){
css = {
"margin-left": '-' + ( parseInt( $(this).width() ) / 2 ) + 'px',
"margin-top": '-' + ( parseInt( $(this).height() ) / 2 ) + 'px'
};
$(this).css(css);
$(this).fadeIn(1000, function() {
$(this).parent().hover(function() {
$(this).addClass("hover");
var img = $(this).children('img');
$(this).css({ "z-index": "1000"});
$(this).stop().animate({
width: img.width(),
height: img.height(),
left: '-'+(parseInt(img.width()-$(this).width())/2)+'px',
top: '-'+(parseInt(img.height()-$(this).height())/2)+'px'
}, 500);
},
function() {
$(this).removeClass("hover");
$(this).stop().css({ left: "", top: "", width: "", height: "", "z-index": "0"});
});
});
})
});
});
};
})(jQuery);