]> www.average.org Git - mkgallery.git/blob - include/gallery.js
outline strategy on window resize
[mkgallery.git] / include / gallery.js
1 /*
2         $Id$
3
4         This is a part of mkgallery.pl suite
5         http://www.average.org/mkgallery/
6
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/
10 */
11
12 /*
13         Use slideshow classes with the index generated by mkgallery.pl
14 */
15
16 /* Initialize everything, to be called on domready */
17 function init_gallery() {
18
19         /* List of lists of img variations. Each image variation is a three-element
20          * array: [width, height, url]. Index of the outer array is the global ID.
21          *
22          * [
23          *  [ id, title, [
24          *                [ width, height, url ]
25          *                ...
26          *               ]
27          *   ...
28          *  ]
29          *  ...
30          * ]
31         */
32         var vimgs=[];
33
34         /* resolve string ID to index No which is the index in vimgs[] array */
35         var rimgs=[];
36
37         /* Populate images list */
38
39         $$('div.varimages').each(function(el,i){
40                 rimgs[el.id] = i;
41                 vimgs[i] = [];
42                 el.getElements('a').each(function(ael,j){
43                         dim = /(\d+)[^\d](\d+)/.exec(ael.text);
44                         w = dim[1];
45                         h = dim[2];
46                         vimgs[i][j]=[w,h,ael.href,el.id,el.title];
47                 });
48         });
49
50                         /* debugging output
51         var msg='loaded '+vimgs.length+' image descriptions:';
52         vimgs.each(function(vimg,i){
53                 msg+='\nid='+i;
54                 vimg.each(function(vimg,i){
55                         msg+='\n     w='+vimg[0]+' h='+vimg[1]+' url='+vimg[2];
56                 });
57         });
58         alert(msg);
59                         /* end debugging output */
60
61         /* Initialize objects */
62
63         var ovlparams = {};
64         ovl = new overlay(ovlparams);
65
66         var iboxparams = {
67                 overlay: ovl,
68                 showNumbers: false,
69                 showControls: true,
70                 openFromLink: false,
71                 movieWidth: 640,
72                 movieHeight: 480,
73                 descClassName: 'infoBoxDesc',
74         };
75         ibox = new multiBox('infoBox', iboxparams);
76
77         var winparms = {
78                 tohide: 'indexContainer',
79         };
80         var showwin = new showWindow('slideshowContainer',winparms);
81
82         var ctlparams = {
83         };
84         var ctl = new Controls('slideshowControls','slideshowContainer',
85                                 ctlparams);
86
87         var showparms = {
88                 cbStart: function(){ showwin.show(); },
89                 cbExit: function(){ showwin.hide(); },
90         };
91         var show = new Show(vimgs,showwin,ctl,showparms);
92
93         /* Update HTML */
94
95         $$('.conceal').each(function(el){
96                 el.setStyle('display', 'none');
97         });
98         $$('a.infoBox').each(function(el){
99                 var url=el.get('href');
100                 el.set('href',url+'?conceal');
101         });
102
103         $$('a.showStart').each(function(el){
104                 el.addEvent('click',
105                                 show.start.bind(show,[rimgs[el.get('id')],1]));
106         });
107         $$('a.showImage').each(function(el){
108                 el.addEvent('click',
109                                 show.start.bind(show,[rimgs[el.get('id')],0]));
110         });
111
112         /* Determine if we need to go directly into show mode */
113
114         parsedurl = parseUrl(document.URL);
115         /* alert('Anchor: '+parsedurl['anchor']+'\nURL: '+document.URL); */
116         if ($chk(parsedurl['anchor'])){
117                 show.start(rimgs[parsedurl['anchor']],0);
118         }
119 }
120
121 /* Initialization */
122 window.addEvent('domready',init_gallery)