Skip to content

Instantly share code, notes, and snippets.

@iammerrick
Created February 14, 2011 19:17
Show Gist options
  • Save iammerrick/826380 to your computer and use it in GitHub Desktop.
Save iammerrick/826380 to your computer and use it in GitHub Desktop.
SlideShow.Controls = new Class({
Extends: SlideShow,
options: {
controlsSelector: '',
controlSyntax: 'li a[href=#]'
},
setupSlides: function(){
this.controlsContainer = document.id(this.options.controlsSelector);
this.slides.each(function(slide, index){
this.addControl(slide, index);
slide.store('slideshow-index', index);
this.storeData(slide);
if (this.current || index == 0) return;
this.reset(slide);
slide.setStyle('display', 'none');
}, this);
this.fireEvent('setupComplete');
return this;
},
addControl: function(slide, index){
var control = Elements.fromSelector(this.options.controlSyntax);
control.getElement('a').set('text', (index + 1));
control.addEvent('click', function(){
this.show(slide);
this.pause();
return false;
}.bind(this));
this.controlsContainer.adopt(control);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment