]> www.average.org Git - mkgallery.git/blob - include/controls.js
f27ac2a0e832248a380e836557735c1f221f86f9
[mkgallery.git] / include / controls.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 controls
13
14   - First, initialize "controls" without hooks to the "show".
15   - Then, initialize "show" passing "controls" object as an argument to
16     the constructor.
17   - From the "show" constructuor, call "controls"'s "complete initialization"
18     method passing them "this", so that they will be able to access "show"'s
19     methods.
20   - Because this is slightly simpler than symmetric "co-routine" approach,
21     and arguably better suits the task at hand.
22 */
23
24 var Controls = new Class({
25
26         getOptions: function(){
27                 return {
28                         onClick: $empty,
29                 }
30         },
31
32         initialize: function(container, options){
33                 this.setOptions(this.getOptions(), options);
34                 this.container = $(container);
35                 var buttons = ['prev','stop','play','next','exit','comm'];
36                 buttons.each(function(el){
37                         var sub = new Element('div');
38                         sub.addClass('controlButton').setProperties({
39                                 id: el,
40                                 name: el,
41                         }).injectInside(this.container);
42                         this[el] = sub;
43                 },this);
44         },
45
46         registershow: function(show){
47                 alert('controls.registershow called');
48                 this.show = show;
49                 var buttons = ['prev','stop','play','next','exit'];
50                 buttons.each(function(el){
51                         var sub = new Element('div');
52                         sub.addEvent('click', function() {
53                                 this.show[el]();
54                         }.bind(this.show));
55                 },this);
56         },
57
58
59 });
60 Controls.implement(new Options);
61