diff --git a/v3/slides/slides3.js b/v3/slides/slides3.js index 640b42c..b343609 100644 --- a/v3/slides/slides3.js +++ b/v3/slides/slides3.js @@ -11,31 +11,46 @@ var Slides = { }, next: function(skipSections) { - var result = this.current.next(); - if (!result || skipSections) { - var index = this.slides.indexOf(this.current) + 1; - if (index == this.slides.length) { return; } - this.show(this.slides[index]); + var index = this.slides.indexOf(this.current); + var section = 0; + + if (skipSections) { + index++; + } else { + section = this.current.index+1; + if (section == this.current.sections.length) { + index++; + section = 0; + } } + + if (index < this.slides.length) { this.show(this.slides[index], section); } }, prev: function(skipSections) { - var result = this.current.prev(); - if (!result || skipSections) { - var index = this.slides.indexOf(this.current) - 1; - if (index == -1) { return; } - this.show(this.slides[index], true); + var index = this.slides.indexOf(this.current); + var section = 0; + + if (skipSections) { + index--; + } else { + section = this.current.index-1; + if (section < 0) { + index--; + if (index > -1) { section = this.slides[index].sections.length-1; } + } } + if (index > -1) { this.show(this.slides[index], section); } }, - show: function(slide, expandAll) { + show: function(slide, section) { this.current = slide; for (var i=0;i= this._sections.length) { return false; } - this._index++; - this._syncSections(); - return true; -} - -Slide.prototype.prev = function() { - if (this._index <= 0) { return false; } - this._index--; - this._syncSections(); - return true; + return this; } Slide.prototype._findSections = function(node) { if (node.classList.contains("section")) { - this._sections.push(node); + this.sections.push(node); } var hasSections = node.classList.contains("sections"); @@ -195,14 +201,14 @@ Slide.prototype._findSections = function(node) { } Slide.prototype._syncSections = function() { - for (var i=0;i