-
-
Save frye-guy/2297608 to your computer and use it in GitHub Desktop.
Embedded Facebook Page Photo Gallery with jQuery
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE HTML> | |
<html> | |
<head> | |
<style> | |
#photo-thumbs{ | |
width: 150px; | |
float: left; | |
height:600px; | |
overflow:auto; | |
} | |
#photo-viewer-cont{ | |
width: 600px; | |
float: right; | |
} | |
</style> | |
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> | |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> | |
<title>test</title> | |
<script type="text/javascript"> | |
$(document).ready(function() { | |
$("#fb-photo-gallery").fbphotogallery('352411828128688'); | |
}); | |
(function($){ | |
$.fn.fbphotogallery= function (gallery){ | |
(this).html('<h2 id=\"photo-title\"></h2><div style=\"width: 952px; height: 360px;\"><div class=\"float-menu-css\" id=\"float-menu\"><center><div id=\"photo-thumbs\"></div></center></div><div id=\"photo-viewer-cont\" style=\"float: right; width:600px; margin-left:auto; margin-right:auto;\"><center><img id=\"photo-viewer\" src=\"http://i42.tinypic.com/nwdhc8.gif\"></center></div></div>'); | |
var title = $('#photo-title'), | |
viewer = $('#photo-viewer'), | |
thumbs = $('#photo-thumbs') | |
gallery_id=gallery; | |
// album info | |
$.getJSON('http://graph.facebook.com/' + gallery_id + '?callback=?', function(json, status, xhr) { | |
title.html('<a href="' + json.link + '">' + json.name + '</a> from ' + json.from.name); | |
}); | |
// images | |
$.getJSON('http://graph.facebook.com/' + gallery_id + '/photos/?limit=1000&callback=?', function(json, status, xhr) { | |
var imgs = json.data; | |
viewer.attr('src', imgs[0].source) | |
viewer.attr('alt', imgs[0].name) | |
for (var i = 0, l = imgs.length - 1; i < l; i++) { | |
$('<img src="' + imgs[i].picture + '" alt="' + imgs[i].name + '" data-fullsize="' + imgs[i].source + '">').appendTo(thumbs); | |
} | |
$("#float-menu").removeClass("float-menu-css").addClass("float-menu-css"); | |
$('img', thumbs).bind('click', function(e) { | |
e.preventDefault(); | |
$("#photo-viewer-cont").html('<center><img id=\"photo-viewer\" src=\"http://i42.tinypic.com/nwdhc8.gif\"></center>'); | |
var viewer = $('#photo-viewer'); | |
viewer.attr('src', $(this).attr('data-fullsize')); | |
viewer.attr('alt', $(this).attr('alt')); | |
}); | |
}); | |
}; | |
})(jQuery); | |
</script></head> | |
<body> | |
<div id="fb-photo-gallery"></div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment