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){
42 vimgs[i] = [el.id, el.title, []];
43 el.getElements('a').each(function(ael,j){
44 dim = /(\d+)[^\d](\d+)/.exec(ael.text);
47 vimgs[i][2][j]=[w,h,ael.href];
52 var msg='loaded '+vimgs.length+' image descriptions:';
53 vimgs.each(function(vimg,i){
54 msg+='\nid='+i+' ('+vimg[0]+') title='+vimg[1];
55 vimg[2].each(function(vv,i){
56 msg+='\n w='+vv[0]+' h='+vv[1]+' url='+vv[2];
60 /* end debugging output */
62 /* Initialize objects */
65 ovl = new overlay(ovlparams);
74 descClassName: 'infoBoxDesc',
76 ibox = new multiBox('infoBox', iboxparams);
79 tohide: 'indexContainer',
81 var showwin = new showWindow('slideshowContainer',winparms);
85 var ctl = new Controls('slideshowControls','slideshowContainer',
89 cbStart: function(){ showwin.show(); },
90 cbExit: function(){ showwin.hide(); },
92 var show = new Show(vimgs,showwin,ctl,showparms);
94 document.addEvent('keypress', function(ev){
95 if (ev.key == 'esc') {
97 } else if (ev.key == 'left') {
99 } else if (ev.key == 'right') {
101 } else if (ev.key == 'space') {
104 /* alert('keypress: '+ev.key); */
110 $$('.conceal').each(function(el){
111 el.setStyle('display', 'none');
113 $$('a.infoBox').each(function(el){
114 var url=el.get('href');
115 el.set('href',url+'?conceal');
118 $$('a.showStart').each(function(el){
120 show.start.bind(show,[rimgs[el.get('id')],1]));
122 $$('a.showImage').each(function(el){
124 show.start.bind(show,[rimgs[el.get('id')],0]));
127 /* Determine if we need to go directly into show mode */
129 parsedurl = parseUrl(document.URL);
130 /* alert('Anchor: '+parsedurl['anchor']+'\nURL: '+document.URL); */
131 if ($chk(parsedurl['anchor'])){
132 show.start(rimgs[parsedurl['anchor']],0);
137 window.addEvent('domready',init_gallery);