Skip to content

Instantly share code, notes, and snippets.

@coolniikou
Created May 30, 2009 15:04
Show Gist options
  • Save coolniikou/120527 to your computer and use it in GitHub Desktop.
Save coolniikou/120527 to your computer and use it in GitHub Desktop.
$.fn.slidergallery = function(options) {
var defaults = {
baseurl: 'http://example.com/jsondata_address',
speed: 'slow',
timeout: 1500,
type: 'sequence'
};
var options = $.extend(defaults, options);
return this.each(function() {
var obj = $(this);
var tabs = $('ul li a', obj);
var tabContent = $('div',obj);
tabs.bind('click', onclick).filter(':first').click();
function onclick(tabs){
var tag = $(this).text();
$('li.selected', obj).removeClass();
$(this).parent().addClass('selected');
get_image(tag);
};
function show_image(data){
var list = '<ul class="gallerylist">';
$.each(data.items, function(i,item){
var title = (item.title) ? item.title : "none";
var url = item.url;
var img = item.thumbnail;
list += '<li><div class="image"><a href="'+url+'" class="highslide" onclick="return hs.expand(this)"><img src="';
list += img+'" alt="Highslide JS" title="Click to enlarge" height="100px" /></a></div>';
list += '<div class="highslide-caption"><p>';
list += title+'</p><ul class="exif">';
$.each(item.exifinfo, function(key,value){
list+='<li>'+key+':'+ value+'</li>';
});
list+= '</ul></div></li>';
});
list+= '</ul>';
tabContent.empty().append(list);
$('ul.gallerylist',tabContent).innerfade({
speed: options.speed,
timeout: options.timeout,
type: options.type
});
};
function get_image(tag){
var url = options.baseurl+tag+'.json';
$.getJSON(url, function(data){show_image(data);});
return false;
};
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment