X-Git-Url: http://www.average.org/gitweb/?p=mkgallery.git;a=blobdiff_plain;f=include%2Fgallery.js;h=39d8d846b4aa9ed7759c98195daada2942311c85;hp=3c2e1f3d2445326ec22164102ca839dcd6b602fb;hb=d9858398daebccc17dff00309c0f96a94a98e1f2;hpb=f04746d096a80eab7143900e50f02ab0660e1975 diff --git a/include/gallery.js b/include/gallery.js index 3c2e1f3..39d8d84 100644 --- a/include/gallery.js +++ b/include/gallery.js @@ -1,35 +1,139 @@ -function showIbox(iboxid) { - var ibox = document.getElementById(iboxid); - var wwidth; - var wheight; - var bwidth = 400; - var bheight = 300; - if (self.innerWidth) - { - wwidth = self.innerWidth; - wheight = self.innerHeight; - } - else if (document.documentElement && document.documentElement.clientWidth) - { - wwidth = document.documentElement.clientWidth; - wheight = document.documentElement.clientHeight; - } - else if (document.body) - { - wwidth = document.body.clientWidth; - wheight = document.body.clientHeight; - } - ibox.style.width = bwidth + "px"; - ibox.style.height = bheight + "px"; - ibox.style.left = ((wwidth - bwidth) / 2) + "px"; - ibox.style.top = ((wheight - bheight) / 2) + "px"; - // alert('wwidth='+wwidth+'; bwidth='+bwidth+'; wheight='+wheight+'; bheight='+bheight); - ibox.zIndex = '0'; - ibox.style.display = 'block'; - return false; -} -function HideIbox(iboxid) { - var ibox = document.getElementById(iboxid); - ibox.zIndex = '1000'; - ibox.style.display = 'none'; +/* + $Id$ + + This is a part of mkgallery.pl suite + http://www.average.org/mkgallery/ + + Uses mootools (1.2) http://www.mootools.net/ + Uses multibox http://www.phatfusion.net/multibox/ + Inspired by slideshow http://www.phatfusion.net/slideshow/ +*/ + +/* + Use slideshow classes with the index generated by mkgallery.pl +*/ + +/* 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. + * + * [ + * [ id, title, [ + * [ width, height, url ] + * ... + * ] + * ... + * ] + * ... + * ] + */ + var vimgs=[]; + + /* resolve string ID to index No which is the index in vimgs[] array */ + var rimgs=[]; + + /* Populate images list */ + + $$('div.varimages').each(function(el,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.rel); + w = dim[1]; + h = dim[2]; + 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[0]+') title='+vimg[1]; + vimg[2].each(function(vv,i){ + msg+='\n w='+vv[0]+' h='+vv[1]+' url='+vv[2]; + }); + }); + alert(msg); + /* end debugging output */ + + /* Initialize objects */ + + var ovlparams = {}; + ovl = new overlay(ovlparams); + + var iboxparams = { + overlay: ovl, + showNumbers: false, + showControls: true, + openFromLink: false, + movieWidth: 640, + movieHeight: 480, + descClassName: 'infoBoxDesc' + }; + ibox = new multiBox('infoBox', iboxparams); + + var winparms = { + tohide: 'indexContainer' + }; + var showwin = new showWindow('slideshowContainer',winparms); + + var ctlparams = { + }; + var ctl = new Controls('slideshowControls','slideshowContainer', + ctlparams); + + var showparms = { + cbStart: function(){ showwin.show(); }, + 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){ + el.setStyle('display', 'none'); + }); + $$('a.infoBox').each(function(el){ + var url=el.get('href'); + el.set('href',url+'?conceal'); + }); + + $$('a.showStart').each(function(el){ + el.addEvent('click', + show.start.bind(show,[rimgs[el.get('rel')],1])); + }); + $$('a.showImage').each(function(el){ + el.addEvent('click', + show.start.bind(show,[rimgs[el.get('rel')],0])); + }); + + /* Determine if we need to go directly into show mode */ + + parsedurl = parseUrl(document.URL); + /* alert('Anchor: '+parsedurl['anchor']+'\nURL: '+document.URL); */ + if ($chk(parsedurl['anchor'])){ + show.start(rimgs[parsedurl['anchor']],0); + } } + +/* Initialization */ +window.addEvent('domready',init_gallery); +