Add init API method to help with shower/shower#124
This commit is contained in:
parent
e1b49a76b9
commit
e1443282ac
23
shower.js
23
shower.js
|
@ -7,8 +7,8 @@ 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),
|
||||
|
@ -25,6 +25,20 @@ window.shower = window.shower || (function(window, document, undefined) {
|
|||
return element.dataset ? element.dataset[name] : element.getAttribute('data-' + name);
|
||||
};
|
||||
|
||||
/**
|
||||
* 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 (i = 0; i < l; i++) {
|
||||
// Slide IDs are optional. In case of missing ID we set it to the
|
||||
// slide number
|
||||
|
@ -39,6 +53,9 @@ window.shower = window.shower || (function(window, document, undefined) {
|
|||
});
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Get slide scale value.
|
||||
* @private
|
||||
|
@ -723,6 +740,8 @@ window.shower = window.shower || (function(window, document, undefined) {
|
|||
}
|
||||
}, false);
|
||||
|
||||
shower.init();
|
||||
|
||||
return shower;
|
||||
|
||||
})(this, this.document);
|
Loading…
Reference in New Issue