Merge pull request #138 from pepelsbey/timing
Fixes #132 parsing issue for data-timing
This commit is contained in:
commit
da1f95ea08
27
shower.js
27
shower.js
|
@ -179,7 +179,6 @@ window.shower = window.shower || (function(window, document, undefined) {
|
|||
return element.dataset ? element.dataset[name] : element.getAttribute('data-' + name);
|
||||
};
|
||||
|
||||
|
||||
shower.slideList = [];
|
||||
|
||||
/**
|
||||
|
@ -198,29 +197,35 @@ window.shower = window.shower || (function(window, document, undefined) {
|
|||
progress = document.querySelector(progressSelector);
|
||||
|
||||
for (var i = 0; i < slides.length; i++) {
|
||||
// Slide IDs are optional. In case of missing ID we set it to the
|
||||
// slide number
|
||||
// Slide IDs are optional.
|
||||
// In case of missing ID we set it to the slide number
|
||||
if ( ! slides[i].id) {
|
||||
slides[i].id = i + 1;
|
||||
}
|
||||
|
||||
timing = shower._getData(slides[i], 'timing');
|
||||
|
||||
if (timing && timing.indexOf(':') !== -1) {
|
||||
timing = timing.split(':');
|
||||
// Compute number of milliseconds from format "mm:ss"
|
||||
timing = (parseInt(timing[0], 10) * 60 + parseInt(timing[1], 10)) * 1000;
|
||||
|
||||
if (slides[i].querySelector('.next')) {
|
||||
timing = timing / (slides[i].querySelectorAll('.next').length + 1);
|
||||
// Parsing timing in [S] or [M:S] format
|
||||
// and returning it in milliseconds
|
||||
if (timing && /^(\d{1,2}:)?\d{1,3}$/.test(timing)) {
|
||||
if (timing.indexOf(':') !== -1) {
|
||||
timing = timing.split(':');
|
||||
timing = (parseInt(timing[0], 10) * 60 + parseInt(timing[1], 10)) * 1000;
|
||||
} else {
|
||||
timing = parseInt(timing, 10) * 1000;
|
||||
}
|
||||
if (timing === 0) {
|
||||
timing = false;
|
||||
}
|
||||
} else {
|
||||
timing = false;
|
||||
}
|
||||
|
||||
shower.slideList.push(new Slide({
|
||||
id : slides[i].id,
|
||||
number : i,
|
||||
hasInnerNavigation : null !== slides[i].querySelector('.next'),
|
||||
timing : parseInt(timing, 10) || undefined,
|
||||
timing : timing,
|
||||
innerLength : slides[i].querySelectorAll('.next').length,
|
||||
innerComplete : 0
|
||||
}));
|
||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue