X-Git-Url: http://www.average.org/gitweb/?p=mkgallery.git;a=blobdiff_plain;f=include%2Fcontrols.js;fp=include%2Fcontrols.js;h=8823d6c12c553149deed5a030493832c4ccff1d6;hp=0000000000000000000000000000000000000000;hb=a84dd4b65779d3d35693db3f1d732505cb933938;hpb=3ddb4582854c4bad0f577a754df4e1b5909e2a49 diff --git a/include/controls.js b/include/controls.js new file mode 100644 index 0000000..8823d6c --- /dev/null +++ b/include/controls.js @@ -0,0 +1,59 @@ +/* + This is a part of mkgallery.pl suite + http://www.average.org/mkgallery/ + + Uses mootools (1.2) http://www.mootools.net/ + Inspired by slideshow http://www.phatfusion.net/slideshow/ +*/ + +/* + Slideshow controls + + - First, initialize "controls" without hooks to the "show". + - Then, initialize "show" passing "controls" object as an argument to + the constructor. + - From the "show" constructuor, call "controls"'s "complete initialization" + method passing them "this", so that they will be able to access "show"'s + methods. + - Because this is slightly simpler than symmetric "co-routine" approach, + and arguably better suits the task at hand. +*/ + +var Controls = new Class({ + + getOptions: function(){ + return { + onClick: $empty, + } + }, + + initialize: function(container, options){ + this.setOptions(this.getOptions(), options); + this.container = $(container); + var buttons = ['prev','stop','play','next','exit','comm']; + buttons.each(function(el){ + var sub = new Element('div'); + sub.addClass('controlButton').setProperties({ + id: el, + name: el, + }).injectInside(this.container); + this[el] = sub; + },this); + }, + + registershow: function(show){ + alert('controls.registershow called'); + this.show = show; + var buttons = ['prev','stop','play','next','exit']; + buttons.each(function(el){ + var sub = new Element('div'); + sub.addEvent('click', function() { + this.show[el](); + }.bind(this.show)); + },this); + }, + + +}); +Controls.implement(new Options); +