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',
31 buttons: ['prev','stop','play','next','exit','comm'],
35 initialize: function(name, parent, options){
36 this.setOptions(this.getOptions(), options);
37 this.parent = $(parent);
38 this.container = new Element('div').addClass(name).
43 zIndex: this.options.zIndex,
44 }).addEvent('click', function(){
45 this.options.onClick()
46 }.bind(this)).injectInside(this.parent);
47 this.options.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({
60 id: 'controlPosition',
61 }).injectInside(this.commbox);
62 this.refbox = new Element('a', {
63 href: 'javascript: void();',
65 }).addClass('controlRef').setProperties({
67 }).injectInside(this.commbox);
70 registershow: function(show){
75 if (this.show.prev) { this.show.prev() }
76 else { alert('no method for "prev", file complaint with UN') }
80 if (this.show.stop) { this.show.stop() }
81 else { alert('no method for "stop", file complaint with UN') }
85 if (this.show.play) { this.show.play() }
86 else { alert('no method for "play", file complaint with UN') }
90 if (this.show.next) { this.show.next() }
91 else { alert('no method for "next", file complaint with UN') }
95 if (this.show.exit) { this.show.exit() }
96 else { alert('no method for "exit", file complaint with UN') }
100 if (this.show.comm) { this.show.comm() }
101 else { alert('no method for "comm", file complaint with UN') }
104 info: function(pos, max, ref, txt){
105 var msg = 'pos='+pos+', max='+max+', ref='+ref+', txt='+txt;
106 this.refbox.set('html',txt);
107 this.refbox.set('href',ref);
108 this.posbox.set('text',pos+' of '+max);
111 running: function(isrunning){
113 this.playbox.setStyle('display', 'none');
114 this.stopbox.setStyle('display', 'block');
116 this.stopbox.setStyle('display', 'none');
117 this.playbox.setStyle('display', 'block');
121 Controls.implement(new Options);