Commit e8851ea0 authored by Tony Ganch's avatar Tony Ganch

Revert "Fix the getCurrentSlideNumber to return 0 when it fails to find a slide, fixes #152"

This reverts commit 0930bb94.

Conflicts:
	shower.js
parent c4755155
...@@ -599,7 +599,7 @@ window.shower = window.shower || (function(window, document, undefined) { ...@@ -599,7 +599,7 @@ window.shower = window.shower || (function(window, document, undefined) {
/** /**
* Get current slide number. Starts from zero. Warning: when you have * Get current slide number. Starts from zero. Warning: when you have
* slide number 1 in URL this method will return 0. * slide number 1 in URL this method will return 0.
* If something is wrong return 0 to get the first slide. * If something is wrong return -1.
* @returns {Number} * @returns {Number}
*/ */
shower.getCurrentSlideNumber = function() { shower.getCurrentSlideNumber = function() {
...@@ -614,7 +614,7 @@ window.shower = window.shower || (function(window, document, undefined) { ...@@ -614,7 +614,7 @@ window.shower = window.shower || (function(window, document, undefined) {
} }
} }
return 0; return -1;
}; };
/** /**
...@@ -634,6 +634,11 @@ window.shower = window.shower || (function(window, document, undefined) { ...@@ -634,6 +634,11 @@ window.shower = window.shower || (function(window, document, undefined) {
throw new Error('You can\'t scroll to because you in slide mode. Please, switch to list mode.'); throw new Error('You can\'t scroll to because you in slide mode. Please, switch to list mode.');
} }
// @TODO: WTF?
if (-1 === slideNumber) {
return ret;
}
if (shower.slideList[slideNumber]) { if (shower.slideList[slideNumber]) {
currentSlide = document.getElementById(shower.slideList[slideNumber].id); currentSlide = document.getElementById(shower.slideList[slideNumber].id);
window.scrollTo(0, currentSlide.offsetTop); window.scrollTo(0, currentSlide.offsetTop);
...@@ -826,7 +831,7 @@ window.shower = window.shower || (function(window, document, undefined) { ...@@ -826,7 +831,7 @@ window.shower = window.shower || (function(window, document, undefined) {
document.addEventListener('keydown', function(e) { document.addEventListener('keydown', function(e) {
var currentSlideNumber = shower.getCurrentSlideNumber(), var currentSlideNumber = shower.getCurrentSlideNumber(),
slide = shower.slideList[currentSlideNumber], slide = shower.slideList[ currentSlideNumber !== -1 ? currentSlideNumber : 0 ],
slideNumber; slideNumber;
switch (e.which) { switch (e.which) {
...@@ -860,7 +865,7 @@ window.shower = window.shower || (function(window, document, undefined) { ...@@ -860,7 +865,7 @@ window.shower = window.shower || (function(window, document, undefined) {
break; break;
case 13: // Enter case 13: // Enter
if (shower.isListMode() && currentSlideNumber) { if (shower.isListMode() && -1 !== currentSlideNumber) {
e.preventDefault(); e.preventDefault();
shower.enterSlideMode(); shower.enterSlideMode();
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment