]> www.average.org Git - mkgallery.git/blob - include/show.js
hide scroll bars when going to show mode; some rearrangement
[mkgallery.git] / include / show.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         Inspired by slideshow http://www.phatfusion.net/slideshow/
9 */
10
11 /*
12         Slideshow
13
14   - On show image: find this and next urls; put in place
15     those that are already here; free unneeded; initiate download of
16     the rest; if needed image is ready then initiate "transitioning", else
17     initiate "loading".
18   - On load complete: if this is the target image, initiate "transitioning".
19   - On "loading": show "loading" image
20   - On "transitioning": hide "loading" image; initiate FX animation to the
21     needed image.
22   - On animation complete: blank previous image; if "playing" then schedule
23     autoswitch to next image in the future.
24   - On autoswitch to next image: if "playing" then switch to next image.
25   - On switch to next image: if next exists, show next image, else show
26     "last image" message.
27   - On switch to prev image: if prev exists, show prev image, else show
28     "first image" message.
29   - On "play": make "playing"; switch to next image.
30   - On "stop": if "playing" cancel autoswitch; break "playing".
31   - On "start show": set up things; set "playing" state; show needed image.
32   - On "stop show": cancel any schedules, hide things.
33   - On resize: recalculate existing image size and position; determine
34     what image is needed; if it is not the one on display then request
35     "show image" for the new image.
36 */
37
38 var Show = new Class({
39
40         getOptions: function(){
41                 return {
42                         cbStart: function(){ alert('show start undefined'); },
43                         cbExit: function(){ alert('show exit undefined'); },
44                 }
45         },
46
47         initialize: function(vimgs, container, controls, options){
48                 this.setOptions(this.getOptions(), options);
49                 this.vimgs = vimgs;
50                 this.container = $(container);
51                 this.controls = controls;
52                 this.controls.registershow(this);
53
54                 window.addEvent('resize', this.resizer.bind(this))
55         },
56
57         /* event handler for window resize */
58
59         resizer: function(){
60                 alert('show.resizer called');
61         },
62
63         /* prev, play, stop, next, exit, comm are methods for button presses */
64
65         prev: function(){
66                 this.controls.info(-1,this.vimgs.length,
67                                 '<ref>','prev called');
68         },
69
70         stop: function(){
71                 this.controls.info(0,this.vimgs.length,
72                                 '<ref>','stop called');
73                 this.controls.running(0);
74         },
75
76         play: function(){
77                 this.controls.info(999,this.vimgs.length,
78                                 '<ref>','play called');
79                 this.controls.running(1);
80         },
81
82         next: function(){
83                 this.controls.info(1,this.vimgs.length,
84                                 '<ref>','next called');
85         },
86
87         exit: function(){
88                 this.options.cbExit();
89         },
90
91         comm: function(){
92                 /* alert('show.comm called, do nothing'); */
93         },
94
95         /* Entry point: called to start doing things */
96
97         start: function(id, play){
98                 this.options.cbStart();
99                 alert('starting at '+id+', play='+play);
100                 /* real job here */
101                 return false; /* to make it usable from href links */
102         },
103
104         /* "Private" methods to do the real job */
105
106 });
107 Show.implement(new Options);
108 Show.implement(new Events);
109