Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/twbs/bootstrap.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXhmikosR <xhmikosr@gmail.com>2017-12-16 15:00:38 +0300
committerXhmikosR <xhmikosr@gmail.com>2018-01-11 19:48:46 +0300
commit80d0943b95984bfaf4997d2198d467876d294bd8 (patch)
treefa2eb4c869753b6e20c771a928da460587f38fdf /js/src/carousel.js
parent6d336502c7e26c4cc5b35f1d7a19c067b774cb1f (diff)
Comply to the new rules.
Diffstat (limited to 'js/src/carousel.js')
-rw-r--r--js/src/carousel.js48
1 files changed, 15 insertions, 33 deletions
diff --git a/js/src/carousel.js b/js/src/carousel.js
index 083f2548e4..895d4dd3bf 100644
--- a/js/src/carousel.js
+++ b/js/src/carousel.js
@@ -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