start "new" slideshow functionality
[mkgallery.git] / include / controls.js
1 /*
2         This is a part of mkgallery.pl suite
3         http://www.average.org/mkgallery/
4
5         Uses mootools (1.2) http://www.mootools.net/
6         Inspired by slideshow http://www.phatfusion.net/slideshow/
7 */
8
9 /*
10         Slideshow controls
11
12   - First, initialize "controls" without hooks to the "show".
13   - Then, initialize "show" passing "controls" object as an argument to
14     the constructor.
15   - From the "show" constructuor, call "controls"'s "complete initialization"
16     method passing them "this", so that they will be able to access "show"'s
17     methods.
18   - Because this is slightly simpler than symmetric "co-routine" approach,
19     and arguably better suits the task at hand.
20 */
21
22 var Controls = new Class({
23
24         getOptions: function(){
25                 return {
26                         onClick: $empty,
27                 }
28         },
29
30         initialize: function(container, options){
31                 this.setOptions(this.getOptions(), options);
32                 this.container = $(container);
33                 var buttons = ['prev','stop','play','next','exit','comm'];
34                 buttons.each(function(el){
35                         var sub = new Element('div');
36                         sub.addClass('controlButton').setProperties({
37                                 id: el,
38                                 name: el,
39                         }).injectInside(this.container);
40                         this[el] = sub;
41                 },this);
42         },
43
44         registershow: function(show){
45                 alert('controls.registershow called');
46                 this.show = show;
47                 var buttons = ['prev','stop','play','next','exit'];
48                 buttons.each(function(el){
49                         var sub = new Element('div');
50                         sub.addEvent('click', function() {
51                                 this.show[el]();
52                         }.bind(this.show));
53                 },this);
54         },
55
56
57 });
58 Controls.implement(new Options);
59