4 This is a part of mkgallery.pl suite
5 http://www.average.org/mkgallery/
7 Uses mootools (1.2) http://www.mootools.net/
8 Uses multibox http://www.phatfusion.net/multibox/
9 Inspired by slideshow http://www.phatfusion.net/slideshow/
13 Use slideshow classes with the index generated by mkgallery.pl
16 /* Initialize everything, to be called on domready */
17 function init_gallery() {
19 /* List of lists of img variations. Each image variation is
20 * a three-element array: [width, height, url]. Index of the
21 * outer array is the global ID.
25 * [ width, height, url ]
35 /* resolve string ID to index No which is the index in vimgs[] array */
38 /* Populate images list */
40 $$('div.varimages').each(function(el,i){
43 vimgs[i] = [rel, el.title, []];
44 el.getElements('a').each(function(ael,j){
45 dim = /(\d+)[^\d](\d+)/.exec(ael.rel);
48 vimgs[i][2][j]=[w,h,ael.href];
53 var msg='loaded '+vimgs.length+' image descriptions:';
54 vimgs.each(function(vimg,i){
55 msg+='\nid='+i+' ('+vimg[0]+') title='+vimg[1];
56 vimg[2].each(function(vv,i){
57 msg+='\n w='+vv[0]+' h='+vv[1]+' url='+vv[2];
61 /* end debugging output */
63 /* Initialize objects */
66 ovl = new overlay(ovlparams);
75 descClassName: 'infoBoxDesc'
77 ibox = new multiBox('infoBox', iboxparams);
80 tohide: 'indexContainer'
82 var showwin = new showWindow('slideshowContainer',winparms);
86 var ctl = new Controls('slideshowControls','slideshowContainer',
90 cbStart: function(){ showwin.show(); },
91 cbExit: function(){ showwin.hide(); }
93 var show = new Show(vimgs,showwin,ctl,showparms);
95 document.addEvent('keypress', function(ev){
96 if (ev.key == 'esc') {
98 } else if (ev.key == 'left') {
100 } else if (ev.key == 'right') {
102 } else if (ev.key == 'space') {
105 /* alert('keypress: '+ev.key); */
111 $$('.conceal').each(function(el){
112 el.setStyle('display', 'none');
114 $$('a.infoBox').each(function(el){
115 var url=el.get('href');
116 el.set('href',url+'?conceal');
119 $$('a.showStart').each(function(el){
121 show.start.bind(show,[rimgs[el.get('rel')],1]));
123 $$('a.showImage').each(function(el){
125 show.start.bind(show,[rimgs[el.get('rel')],0]));
128 /* Determine if we need to go directly into show mode */
130 parsedurl = parseUrl(document.URL);
131 /* alert('Anchor: '+parsedurl['anchor']+'\nURL: '+document.URL); */
132 if ($chk(parsedurl['anchor'])){
133 show.start(rimgs[parsedurl['anchor']],0);
138 window.addEvent('domready',init_gallery);