X-Git-Url: http://www.average.org/gitweb/?p=mkgallery.git;a=blobdiff_plain;f=include%2Fgallery.js;h=39d8d846b4aa9ed7759c98195daada2942311c85;hp=08097589d49f25d9a5647556e9a46c9ae6d89e15;hb=7a52825ce5f25653945b6f1ba8f1aa0098f95863;hpb=b55242bcbdfa5ab5bea3b3391cee28b79ce59762 diff --git a/include/gallery.js b/include/gallery.js index 0809758..39d8d84 100644 --- a/include/gallery.js +++ b/include/gallery.js @@ -16,8 +16,9 @@ /* Initialize everything, to be called on domready */ function init_gallery() { - /* List of lists of img variations. Each image variation is a three-element - * array: [width, height, url]. Index of the outer array is the global ID. + /* List of lists of img variations. Each image variation is + * a three-element array: [width, height, url]. Index of the + * outer array is the global ID. * * [ * [ id, title, [ @@ -37,22 +38,23 @@ function init_gallery() { /* Populate images list */ $$('div.varimages').each(function(el,i){ - rimgs[el.id] = i; - vimgs[i] = []; + var rel=el.get('id'); + rimgs[rel] = i; + vimgs[i] = [rel, el.title, []]; el.getElements('a').each(function(ael,j){ - dim = /(\d+)[^\d](\d+)/.exec(ael.text); + dim = /(\d+)[^\d](\d+)/.exec(ael.rel); w = dim[1]; h = dim[2]; - vimgs[i][j]=[w,h,ael.href,el.id,el.title]; + vimgs[i][2][j]=[w,h,ael.href]; }); }); /* debugging output var msg='loaded '+vimgs.length+' image descriptions:'; vimgs.each(function(vimg,i){ - msg+='\nid='+i; - vimg.each(function(vimg,i){ - msg+='\n w='+vimg[0]+' h='+vimg[1]+' url='+vimg[2]; + msg+='\nid='+i+' ('+vimg[0]+') title='+vimg[1]; + vimg[2].each(function(vv,i){ + msg+='\n w='+vv[0]+' h='+vv[1]+' url='+vv[2]; }); }); alert(msg); @@ -70,12 +72,12 @@ function init_gallery() { openFromLink: false, movieWidth: 640, movieHeight: 480, - descClassName: 'infoBoxDesc', + descClassName: 'infoBoxDesc' }; ibox = new multiBox('infoBox', iboxparams); var winparms = { - tohide: 'indexContainer', + tohide: 'indexContainer' }; var showwin = new showWindow('slideshowContainer',winparms); @@ -86,10 +88,24 @@ function init_gallery() { var showparms = { cbStart: function(){ showwin.show(); }, - cbExit: function(){ showwin.hide(); }, + cbExit: function(){ showwin.hide(); } }; var show = new Show(vimgs,showwin,ctl,showparms); + document.addEvent('keypress', function(ev){ + if (ev.key == 'esc') { + show.exit(); + } else if (ev.key == 'left') { + show.prev(); + } else if (ev.key == 'right') { + show.next(); + } else if (ev.key == 'space') { + show.toggleplay(); + } else { + /* alert('keypress: '+ev.key); */ + } + }); + /* Update HTML */ $$('.conceal').each(function(el){ @@ -102,11 +118,11 @@ function init_gallery() { $$('a.showStart').each(function(el){ el.addEvent('click', - show.start.bind(show,[rimgs[el.get('id')],1])); + show.start.bind(show,[rimgs[el.get('rel')],1])); }); $$('a.showImage').each(function(el){ el.addEvent('click', - show.start.bind(show,[rimgs[el.get('id')],0])); + show.start.bind(show,[rimgs[el.get('rel')],0])); }); /* Determine if we need to go directly into show mode */ @@ -119,4 +135,5 @@ function init_gallery() { } /* Initialization */ -window.addEvent('domready',init_gallery) +window.addEvent('domready',init_gallery); +