X-Git-Url: http://www.average.org/gitweb/?p=mkgallery.git;a=blobdiff_plain;f=include%2Fgallery.js;h=08097589d49f25d9a5647556e9a46c9ae6d89e15;hp=a9d52999ae40cfb32fac05e17c386aff405abec4;hb=b55242bcbdfa5ab5bea3b3391cee28b79ce59762;hpb=d7c0a397220f9f171f4fc677b96ea1f6655e7e02 diff --git a/include/gallery.js b/include/gallery.js index a9d5299..0809758 100644 --- a/include/gallery.js +++ b/include/gallery.js @@ -1,23 +1,122 @@ -function showIbox(iboxid) { - var ibox = document.getElementById(iboxid); - var bwidth = 400; - var bheight = 300; - - var wwidth = window.getWidth(); - var wheight = window.getHeight(); - - ibox.style.top = window.getScrollTop() + ((wheight - bheight) / 2) + 'px'; - ibox.style.left = ((wwidth - bwidth) / 2) + "px"; - ibox.style.width = bwidth + "px"; - ibox.style.height = bheight + "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){ + rimgs[el.id] = i; + vimgs[i] = []; + el.getElements('a').each(function(ael,j){ + dim = /(\d+)[^\d](\d+)/.exec(ael.text); + w = dim[1]; + h = dim[2]; + vimgs[i][j]=[w,h,ael.href,el.id,el.title]; + }); + }); + + /* 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]; + }); + }); + 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); + + /* 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('id')],1])); + }); + $$('a.showImage').each(function(el){ + el.addEvent('click', + show.start.bind(show,[rimgs[el.get('id')],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)