javascript, jbgallery, jquery, plugins
jbgallery 3.0
19 December 2010 | Comments (143)DEMO SITE – (UPDATED 2011-05-16)
WHAT’S NEW
- New option! – fullscreen : false
(resize box & refresh to test. use menu on bottom.) - Many gallery
- Randomize your galleries
- Try new API to push/pop, shift/unshift images from outside (mandatory one image in markup)
- See a basic push example
- See how push hundreds images from outside (my picasa feed)
- See an example of adapter that use new API
- Test zoom, centered and original style option
- Caption simplified and improved (see html markup)
jbgallery is a UI widget webpage written in javascript on top of the jQuery library.
Its function is to show a single big image, multiple images, multiple galleries, slideshows, as a site’s background, in a “dialog” mode or as a common pop-up.
jbgallery has two basic menus: the first one has music player buttons while the other one links directly to single images.
I added a “complex” menu on the 2.0 version, which is inspired by the flickr slider-equipped slideshow that allows to scroll the thumbnail previews.
jbgallery provides a pubblic API to remote control the component, so it would be easier to bind also with a more complex menu.
Examples:
- Option “fullscreen” – default true (jQuery UI resizable only for test):
- box gallery (NEW option! fullscreen : false)
- multi box gallery (NEW option! fullscreen : false)
- Option “style” – default “centered”:
- Option “menu” – default “simple”:
- Option “caption” – default true:
- caption (see html markup)
- no caption (caption disabled)
- Option “timers”:
- interval
- No fade effect (menu simple)
- No fade effect (menu slider)
- Option “autohide” – default false:
- Option “randomize” – default 0:
- randomize first image – randomize : 1
- randomize slideshow – randomize : 2
- custom labels
- clickable – option clickable (default : false)
- Debug style (debug style)
- Option “popup” – default 0:
- multiple gallery same page
- “overlay” vs window.open (see “permalink”)
- “Old Hack” – deprecated (use caption):
- API & Advanced options for developers/designers:
- callback (basic callback)
- api (menu slider)
- api (menu numbers)
- api (menu simple)
- callback on push/pop/unshift/shift
- API demo (hundreds images push via yql & picasa):
- slider
- simple
- numbers – note the limitations of this menu
- basic example of push
- ADAPTERS (picasa):
- all album – new version with api
- filter by album – new version with api
- all album – old version
- filter by album – old version
Installation
Download and extract
Download single files :
- jbgallery-3.0.js : source | min
- jbgallery-3.0.css
- ajax-loader.gif
- sprite.png
- opacity.png
- jquery-1.4.4.min.js
Extra files :
- jbpicasa.js : source – new version.
- jbpicasa.js : source – test adapter that you can use building an html structure, getting data from an external rss feed.
Usage
js and css (include in head tag)
<link href="jbgallery-3.0.css" rel="stylesheet" media="screen" /> <script type="text/javascript" src="jquery.1.4.2.min.js"></script> <script type="text/javascript" src="jbgallery-3.0.js"></script>
HTML structure (minimal menu)
<div class="jbgallery"> <ul> <li><a href="1.jpg" >1</a></li> <li><a href="2.jpg" >2</a></li> <!-- etc --> </ul> </div>
HTML structure (thumbnails – menu with slider)
<div class="jbgallery"> <ul> <li><a href="big1.jpg"><img src="small1.jpg" alt="" /></a></li> <li><a href="big2.jpg"><img src="small2.jpg" alt="" /></a></li> <!-- etc --> </ul> </div>
HTML structure (caption)
[/html] <div class="jbgallery"> <ul> <li> <a href="big.jpg" title="Caption title" rel="Caption title link"><img src="small.jpg" alt="" /></a> <div class="caption">Long long long text</div> </li> <!-- etc --> </ul> </div> 1
JS
<script type="text/javascript">
jQuery(document).ready(function(){
jQuery(".jbgallery").jbgallery();
});
</script>
OPTIONS & DEFAULTS
Write options HERE :
jQuery('.jbgallery').jbgallery({HERE});
{
//option : default value //see docs/demo for usage - PLEASE FIX MY ENGLISH IF YOU CAN & SEND ME (thanks!)
style : "centered", //"centered"|"zoom"|"original" - image style
menu : "slider", //false|"numbers"|"simple"|"slider" - menu type
shortcuts: [37, 39], //[prev,next] - keyboard code shortcuts
slideshow: false, //true|false - autostart slideshow
fade : true, //true|false - disable all fade effects
popup : false, //true|false - modal box & traditional popup hack to display multiple gallery (3.0 : fullscreen:false)
randomize: 0, //0|1|2 - randomize first image (1) or randomize "slideshow" (2) - blackout: http://www.grayhats.org
caption : true, //true|false - show/disable internal caption system
autohide : false, //true|false - auto hide menu & caption
clickable: false, //true|false - "image click & go"
current : 1, //number - set initial photo (modal "hack" - see demo. don't use "hash". jbgallery use "location.hash" only in popup mode)
webkit : (navigator.userAgent.toLowerCase().search(/webkit/) != -1), //boolean - used for specific browser hack. if you want, you can force disable this flag & try to find crossbrowser solution
ie6 : (/MSIE 6/i.test(navigator.userAgent)), //boolean - IDEM
ie7 : (/MSIE 7/i.test(navigator.userAgent)), //boolean - IDEM
labels : { //labels of internal menu
play : "play",
next : "next",
prev : "prev",
stop : "stop",
close: "close",
info : "info"
},
timers : { //timers
fade : 400, //fade duration
interval: 7000, //slideshow interval
autohide: 7000 //autohide timeout
},
delays: { //delays (timers) to improve usability and reduce events
mousemove: 200, //used by autohide. cancel autohide timeout every XXXms.
resize : 500, //used by ie6 to reduce events handled by window.resize
mouseover: 800 //used by tooltip. show tooltip only if the mouse STAY over thumb for XXXms
},
close : function(){}, //callback handled by menu's button close. see demo. example : close : function(){window.close()}
before : function(){}, //callback handled BEFORE image gallery loaded
after : function(ev){}, //callback(ev) handled AFTER image gallery loaded. receive the native load event.
load : function(ev){}, //callback(ev) handled AFTER native image load event. receive the native load event.
ready : function(el){}, //callback(el) handled AFTER jbgallery render. receive the HTML element.
//WHAT'S NEW - 3.0
fullscreen: true, //true|false : the most important feature of jbgallery 3.0. now jbgallery can "stay in a box" and have multiple istance in one page.
push : function(o){}, //callback handled by push public method (JBGALLERY API). receive the object/string/array of objects/array of strings passed from external. useful for external menu system
unshift : function(o){}, //callback handled by unshift public method (JBGALLERY API). receive the object/string/array of objects/array of strings passed from external.
shift : function(){}, //callback handled by shift public method
pop : function(){}, //callback handled by pop public method
empty : function(){} //callback handled by empty public method
}
API (developers/designers)
var obj = jQuery("#jbg").jbgallery({menu : "slider"}, true);//GET API
obj.left();
obj.right();
obj.go(3);
obj.current();
obj.play(4000);
obj.stop();
obj.push(single);//single = 'http://url'
obj.push(aobj);//aobj is array of object
obj.unshift(obj);//obj is a single object
obj.unshift(arr);//arr is an array of string (url)
obj.shift();
obj.pop();
obj.empty();
obj.destroy();
EXAMPLE
var images = {
single : 'http://lh5.ggpht.com/_JJJpzXdPAI4/SpzvbyPhCHI/AAAAAAAAA-w/rf8dATWiOK8/100_2274.jpg',
arr : ['http://lh3.ggpht.com/_JJJpzXdPAI4/SpzvrjvU83I/AAAAAAAABAU/8tbAipa9wgk/P1020533.jpg','http://lh5.ggpht.com/_JJJpzXdPAI4/SpzuSpC-0zI/AAAAAAAAA48/M2GPV81K4Ak/100_2090.jpg'],
obj : {
href : 'http://lh5.ggpht.com/_JJJpzXdPAI4/SpzvjOmg5-I/AAAAAAAAA_g/S8wow3zLays/P1020744.jpg',
title: 'Hiroshima',
rel : 'http://en.wikipedia.org/wiki/Hiroshima',
caption : 'Hiroshima (広島市, Hiroshima-shi?) (About this sound listen (help·info)) is the capital of Hiroshima Prefecture, and the largest city in the Chūgoku region of western Honshū',
caption_css : 'custom'
},
aobj : [{
href : 'http://lh5.ggpht.com/_JJJpzXdPAI4/SpzvjOmg5-I/AAAAAAAAA_g/S8wow3zLays/P1020744.jpg',
thumb: 'http://lh5.ggpht.com/_JJJpzXdPAI4/SpzvjOmg5-I/AAAAAAAAA_g/S8wow3zLays/s288/P1020744.jpg',
title: 'Hiroshima',
rel : 'http://en.wikipedia.org/wiki/Hiroshima',
caption : 'Hiroshima (広島市, Hiroshima-shi?) (About this sound listen (help·info)) is the capital of Hiroshima Prefecture, and the largest city in the Chūgoku region of western Honshū',
caption_css : 'custom'
},{
href : 'http://lh5.ggpht.com/_JJJpzXdPAI4/SpzvbyPhCHI/AAAAAAAAA-w/rf8dATWiOK8/100_2274.jpg',
title: 'Magome-juku'
}]
};
obj = jQuery("#jbgallery-api").jbgallery({menu : "slider"}, true);//GET API
jQuery("#mm-empty").click(function(){
obj.empty();
});
jQuery("#mm-push").click(function(){
obj.push(images.single);
});
jQuery("#mm-pushmany").click(function(){
obj.push(images.aobj);
});
jQuery("#mm-shift").click(function(){
obj.shift();
});
jQuery("#mm-pop").click(function(){
obj.pop();
});
jQuery("#mm-unshift").click(function(){
obj.unshift(images.obj);
});
jQuery("#mm-unshiftmany").click(function(){
obj.unshift(images.arr);
});
NOTES
BROWSERS TESTED
- Firefox 3.6
- Chrome 8,9
- IE6,7,8,9
- Opera
- Safari
DESIGN
This component is published with two graphic layout.
You are free to customize css and to ask me any change to add classes to the menus edited by me.
If you use API or design more complex menus, or if you write plugins populating html lists pushing images
(see picasa 3.0 adapter) via ajax by flickr
or similar services, please share with me for the next version of this plugin.
CREDITS
This work is inspired by http://www.ringvemedia.com/ and Chicca
The slider is inspired by http://www.flickr.com/search/show/
Depends on jQuery (1.4.4) by John Resig.
Thanks to Carlo Denaro, Simone Parato, Aaron Hutten, Alain Bourgeoa, Steffen Wenzel
CONTACTS
Post a comment on this post.
LICENSE
Copyright (c) 2010 Massimiliano Balestrieri
Licensed GPL licenses:
http://www.gnu.org/licenses/gpl.html


