Merge pull request #124 from Patternslib/init-api
Using showing without automatic triggering
This commit is contained in:
commit
79843ed10f
28
shower.js
28
shower.js
|
@ -7,12 +7,11 @@ window.shower = window.shower || (function(window, document, undefined) {
|
|||
var shower = {},
|
||||
url = window.location,
|
||||
body = document.body,
|
||||
slides = document.querySelectorAll('.slide'),
|
||||
progress = document.querySelector('div.progress div'),
|
||||
slides = [],
|
||||
progress = [],
|
||||
slideList = [],
|
||||
timer,
|
||||
isHistoryApiSupported = !!(window.history && history.pushState),
|
||||
l = slides.length, i;
|
||||
isHistoryApiSupported = !!(window.history && history.pushState);
|
||||
|
||||
/**
|
||||
* Get value at named data store for the DOM element.
|
||||
|
@ -25,7 +24,21 @@ window.shower = window.shower || (function(window, document, undefined) {
|
|||
return element.dataset ? element.dataset[name] : element.getAttribute('data-' + name);
|
||||
};
|
||||
|
||||
for (i = 0; i < l; i++) {
|
||||
/**
|
||||
* Init
|
||||
* @param {String} slideSelector
|
||||
* @param {String} progressBarSelector
|
||||
* @returns {Object} shower
|
||||
*/
|
||||
shower.init = function(slideSelector, progressSelector) {
|
||||
slideSelector = slideSelector || '.slide';
|
||||
progressSelector = progressSelector || 'div.progress div';
|
||||
|
||||
slides = document.querySelectorAll(slideSelector);
|
||||
progress = document.querySelector(progressSelector);
|
||||
slideList = [];
|
||||
|
||||
for (var i = 0; i < slides.length; i++) {
|
||||
// Slide IDs are optional. In case of missing ID we set it to the
|
||||
// slide number
|
||||
if ( ! slides[i].id) {
|
||||
|
@ -38,6 +51,9 @@ window.shower = window.shower || (function(window, document, undefined) {
|
|||
hasTiming: (shower._getData(slides[i], 'timing') && shower._getData(slides[i], 'timing').indexOf(':') !== -1)
|
||||
});
|
||||
}
|
||||
return shower;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Get slide scale value.
|
||||
|
@ -684,6 +700,8 @@ window.shower = window.shower || (function(window, document, undefined) {
|
|||
}
|
||||
}, false);
|
||||
|
||||
shower.init();
|
||||
|
||||
document.addEventListener('click', function(e) {
|
||||
var slideNumber = shower.getSlideNumber(shower._getSlideIdByEl(e.target));
|
||||
|
||||
|
|
Loading…
Reference in New Issue