gray out inactive controls
[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 */
34
35 var Show = new Class({
36
37         getOptions: function(){
38                 return {
39                         cbStart: function(){ alert('show start undefined'); },
40                         cbExit: function(){ alert('show exit undefined'); },
41                 }
42         },
43
44         initialize: function(vimgs, container, controls, options){
45                 this.setOptions(this.getOptions(), options);
46                 this.vimgs = vimgs;
47                 this.container = $(container);
48                 this.controls = controls;
49                 this.controls.registershow(this);
50
51                 window.addEvent('resize', this.resizer.bind(this))
52                 window.addEvent('scroll', this.scroller.bind(this))
53         },
54
55         resizer: function(){
56                 alert('show.resizer called');
57         },
58
59         scroller: function(){
60                 alert('show.scroller called');
61         },
62
63         prev: function(){
64                 this.controls.info(-1,this.vimgs.length,
65                                 '<ref>','prev called');
66         },
67
68         stop: function(){
69                 this.controls.info(0,this.vimgs.length,
70                                 '<ref>','stop called');
71                 this.controls.running(0);
72         },
73
74         play: function(){
75                 this.controls.info(999,this.vimgs.length,
76                                 '<ref>','play called');
77                 this.controls.running(1);
78         },
79
80         next: function(){
81                 this.controls.info(1,this.vimgs.length,
82                                 '<ref>','next called');
83         },
84
85         start: function(id, play){
86                 this.options.cbStart();
87                 /* real job here */
88                 return false; /* tao make it usable from href links */
89         },
90
91         exit: function(){
92                 this.options.cbExit();
93         },
94
95         comm: function(){
96                 alert('show.comm called, do nothing');
97         },
98
99 });
100 Show.implement(new Options);
101 Show.implement(new Events);
102