2017-06-20 11:10:41 +00:00
|
|
|
function SlideSelect(config){
|
|
|
|
|
|
|
|
var self = this;
|
|
|
|
self.config = config;
|
|
|
|
|
|
|
|
// DOM
|
|
|
|
self.dom = config.dom;
|
|
|
|
|
|
|
|
// Slides
|
|
|
|
self.slides = config.slides;
|
|
|
|
|
|
|
|
// Create a dot, and onclick
|
|
|
|
self.addDot = function(slide){
|
|
|
|
var dot = new SlideSelectDot(slide);
|
|
|
|
self.dom.appendChild(dot.dom);
|
|
|
|
};
|
|
|
|
|
|
|
|
// Populate dots
|
2017-06-26 19:52:49 +00:00
|
|
|
for(var i=0; i<self.slides.length; i++) self.addDot(self.slides[i]);
|
2017-06-20 11:10:41 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
function SlideSelectDot(slide){
|
|
|
|
|
|
|
|
var self = this;
|
|
|
|
self.slide = slide;
|
|
|
|
|
|
|
|
// DOM
|
|
|
|
self.dom = document.createElement("div");
|
|
|
|
self.dom.className = "dot";
|
|
|
|
|
|
|
|
// On Click
|
|
|
|
self.dom.onclick = function(){
|
|
|
|
publish("slideshow/goto", [slide.id]);
|
|
|
|
};
|
|
|
|
|
|
|
|
// Listen to when the slide changes
|
|
|
|
subscribe("slideshow/slideChange", function(id){
|
|
|
|
if(id==slide.id){
|
|
|
|
self.dom.setAttribute("selected","yes");
|
|
|
|
}else{
|
|
|
|
self.dom.removeAttribute("selected");
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|