aboutsummaryrefslogtreecommitdiff
path: root/js/dist/carousel.js
diff options
context:
space:
mode:
authorfat <[email protected]>2015-05-13 14:46:50 -0700
committerfat <[email protected]>2015-05-13 14:46:50 -0700
commiteaab1def7af7d7e1ab32ff69d043b46e2815ca22 (patch)
tree495965eef95b6c7e1ca485c04311e6e451695b29 /js/dist/carousel.js
parentc2ced2292a6467b9c8a9fec3151982fd7ac8a239 (diff)
downloadbootstrap-eaab1def7af7d7e1ab32ff69d043b46e2815ca22.tar.xz
bootstrap-eaab1def7af7d7e1ab32ff69d043b46e2815ca22.zip
add simple type checker implementation
Diffstat (limited to 'js/dist/carousel.js')
-rw-r--r--js/dist/carousel.js19
1 files changed, 17 insertions, 2 deletions
diff --git a/js/dist/carousel.js b/js/dist/carousel.js
index 87b5cc086..d12b95331 100644
--- a/js/dist/carousel.js
+++ b/js/dist/carousel.js
@@ -35,6 +35,14 @@ var Carousel = (function ($) {
wrap: true
};
+ var DefaultType = {
+ interval: '(number|boolean)',
+ keyboard: 'boolean',
+ slide: '(boolean|string)',
+ pause: 'string',
+ wrap: 'boolean'
+ };
+
var Direction = {
NEXT: 'next',
PREVIOUS: 'prev'
@@ -86,7 +94,7 @@ var Carousel = (function ($) {
this._isPaused = false;
this._isSliding = false;
- this._config = config;
+ this._config = this._getConfig(config);
this._element = $(element)[0];
this._indicatorsElement = $(this._element).find(Selector.INDICATORS)[0];
@@ -187,10 +195,17 @@ var Carousel = (function ($) {
this._indicatorsElement = null;
}
}, {
- key: '_addEventListeners',
+ key: '_getConfig',
// private
+ value: function _getConfig(config) {
+ config = $.extend({}, Default, config);
+ Util.typeCheckConfig(NAME, config, DefaultType);
+ return config;
+ }
+ }, {
+ key: '_addEventListeners',
value: function _addEventListeners() {
if (this._config.keyboard) {
$(this._element).on(Event.KEYDOWN, $.proxy(this._keydown, this));