4 This is a part of mkgallery.pl suite
5 http://www.average.org/mkgallery/
7 Uses mootools (1.2) http://www.mootools.net/
8 Inspired by slideshow http://www.phatfusion.net/slideshow/
14 - First, initialize "controls" without hooks to the "show".
15 - Then, initialize "show" passing "controls" object as an argument to
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
20 - Because this is slightly simpler than symmetric "co-routine" approach,
21 and arguably better suits the task at hand.
24 var Controls = new Class({
26 getOptions: function(){
30 buttonClass: 'controlButton'
34 initialize: function(name, parent, options){
35 this.setOptions(this.getOptions(), options);
36 this.parent = $(parent);
37 this.container = new Element('div').addClass(name).
42 zIndex: this.options.zIndex
43 }).addEvent('click', function(){
44 this.options.onClick()
45 }.bind(this)).injectInside(this.parent);
46 var buttons = ['prev','stop','play','next','exit','comm'];
47 buttons.each(function(el){
48 var sub = new Element('div');
49 sub.addClass(this.options.buttonClass).setProperties({
53 }).addEvent('click', function(){
55 }.bind(this)).injectInside(this.container);
58 this.posbox = new Element('span').
59 addClass('controlPosition').setProperties({
61 }).injectInside(this.commbox);
62 this.refbox = new Element('a', {
63 href: 'javascript: void(1);',
65 }).addClass('controlRef').setProperties({
67 }).injectInside(this.commbox);
70 registershow: function(show){
75 if (this.prevdisabled) { return; }
76 if (this.show.prev) { this.show.prev() }
77 else { alert('no method for "prev", file complaint with UN') }
81 if (this.show.stop) { this.show.stop() }
82 else { alert('no method for "stop", file complaint with UN') }
86 if (this.show.play) { this.show.play() }
87 else { alert('no method for "play", file complaint with UN') }
91 if (this.nextdisabled) { return; }
92 if (this.show.next) { this.show.next() }
93 else { alert('no method for "next", file complaint with UN') }
97 if (this.show.exit) { this.show.exit() }
98 else { alert('no method for "exit", file complaint with UN') }
102 if (this.show.comm) { this.show.comm() }
103 else { alert('no method for "comm", file complaint with UN') }
106 info: function(pos, max, ref, txt){
108 this.refbox.set('html',txt);
109 this.refbox.set('href',ref);
110 this.posbox.set('text',p1+' of '+max);
112 this.prevbox.set('id', 'prevDisabled');
113 this.prevdisabled = true;
115 this.prevbox.set('id', 'prev');
116 this.prevdisabled = false;
119 this.nextbox.set('id', 'nextDisabled');
120 this.nextdisabled = true;
122 this.nextbox.set('id', 'next');
123 this.nextdisabled = false;
127 running: function(isrunning){
129 this.playbox.setStyle('display', 'none');
130 this.stopbox.setStyle('display', 'block');
132 this.stopbox.setStyle('display', 'none');
133 this.playbox.setStyle('display', 'block');
138 Controls.implement(new Options);