1
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-09-26 21:39:08 +02:00

Comply to the new rules.

This commit is contained in:
XhmikosR
2017-12-16 14:00:38 +02:00
parent 6d336502c7
commit 80d0943b95
32 changed files with 1798 additions and 1760 deletions

View File

@@ -1,7 +1,6 @@
import $ from 'jquery'
import Util from './util'
/**
* --------------------------------------------------------------------------
* Bootstrap (v4.0.0-beta.3): carousel.js
@@ -10,8 +9,6 @@ import Util from './util'
*/
const Carousel = (($) => {
/**
* ------------------------------------------------------------------------
* Constants
@@ -84,7 +81,6 @@ const Carousel = (($) => {
DATA_RIDE : '[data-ride="carousel"]'
}
/**
* ------------------------------------------------------------------------
* Class Definition
@@ -92,7 +88,6 @@ const Carousel = (($) => {
*/
class Carousel {
constructor(element, config) {
this._items = null
this._interval = null
@@ -110,8 +105,7 @@ const Carousel = (($) => {
this._addEventListeners()
}
// getters
// Getters
static get VERSION() {
return VERSION
@@ -121,8 +115,7 @@ const Carousel = (($) => {
return Default
}
// public
// Public
next() {
if (!this._isSliding) {
@@ -198,9 +191,9 @@ const Carousel = (($) => {
return
}
const direction = index > activeIndex ?
Direction.NEXT :
Direction.PREV
const direction = index > activeIndex
? Direction.NEXT
: Direction.PREV
this._slide(direction, this._items[index])
}
@@ -219,8 +212,7 @@ const Carousel = (($) => {
this._indicatorsElement = null
}
// private
// Private
_getConfig(config) {
config = {
@@ -242,7 +234,7 @@ const Carousel = (($) => {
.on(Event.MOUSEENTER, (event) => this.pause(event))
.on(Event.MOUSELEAVE, (event) => this.cycle(event))
if ('ontouchstart' in document.documentElement) {
// if it's a touch-enabled device, mouseenter/leave are fired as
// If it's a touch-enabled device, mouseenter/leave are fired as
// part of the mouse compatibility events on first tap - the carousel
// would stop cycling until user tapped out of it;
// here, we listen for touchend, explicitly pause the carousel
@@ -275,7 +267,6 @@ const Carousel = (($) => {
this.next()
break
default:
return
}
}
@@ -299,11 +290,10 @@ const Carousel = (($) => {
const delta = direction === Direction.PREV ? -1 : 1
const itemIndex = (activeIndex + delta) % this._items.length
return itemIndex === -1 ?
this._items[this._items.length - 1] : this._items[itemIndex]
return itemIndex === -1
? this._items[this._items.length - 1] : this._items[itemIndex]
}
_triggerSlideEvent(relatedTarget, eventDirectionName) {
const targetIndex = this._getItemIndex(relatedTarget)
const fromIndex = this._getItemIndex($(this._element).find(Selector.ACTIVE_ITEM)[0])
@@ -368,7 +358,7 @@ const Carousel = (($) => {
}
if (!activeElement || !nextElement) {
// some weirdness is happening, so we bail
// Some weirdness is happening, so we bail
return
}
@@ -389,7 +379,6 @@ const Carousel = (($) => {
if (Util.supportsTransitionEnd() &&
$(this._element).hasClass(ClassName.SLIDE)) {
$(nextElement).addClass(orderClassName)
Util.reflow(nextElement)
@@ -408,10 +397,8 @@ const Carousel = (($) => {
this._isSliding = false
setTimeout(() => $(this._element).trigger(slidEvent), 0)
})
.emulateTransitionEnd(TRANSITION_DURATION)
} else {
$(activeElement).removeClass(ClassName.ACTIVE)
$(nextElement).addClass(ClassName.ACTIVE)
@@ -425,12 +412,11 @@ const Carousel = (($) => {
}
}
// static
// Static
static _jQueryInterface(config) {
return this.each(function () {
let data = $(this).data(DATA_KEY)
let data = $(this).data(DATA_KEY)
let _config = {
...Default,
...$(this).data()
@@ -454,7 +440,7 @@ const Carousel = (($) => {
data.to(config)
} else if (typeof action === 'string') {
if (typeof data[action] === 'undefined') {
throw new Error(`No method named "${action}"`)
throw new TypeError(`No method named "${action}"`)
}
data[action]()
} else if (_config.interval) {
@@ -495,10 +481,8 @@ const Carousel = (($) => {
event.preventDefault()
}
}
/**
* ------------------------------------------------------------------------
* Data Api implementation
@@ -515,22 +499,20 @@ const Carousel = (($) => {
})
})
/**
* ------------------------------------------------------------------------
* jQuery
* ------------------------------------------------------------------------
*/
$.fn[NAME] = Carousel._jQueryInterface
$.fn[NAME] = Carousel._jQueryInterface
$.fn[NAME].Constructor = Carousel
$.fn[NAME].noConflict = function () {
$.fn[NAME].noConflict = function () {
$.fn[NAME] = JQUERY_NO_CONFLICT
return Carousel._jQueryInterface
}
return Carousel
})($)
export default Carousel