mirror of
https://github.com/twbs/bootstrap.git
synced 2025-08-13 09:04:14 +02:00
add simple type checker implementation
This commit is contained in:
19
js/dist/carousel.js
vendored
19
js/dist/carousel.js
vendored
@@ -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));
|
||||
|
Reference in New Issue
Block a user