From 80d0943b95984bfaf4997d2198d467876d294bd8 Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Sat, 16 Dec 2017 14:00:38 +0200 Subject: Comply to the new rules. --- js/src/carousel.js | 48 +++++++++++++++--------------------------------- 1 file changed, 15 insertions(+), 33 deletions(-) (limited to 'js/src/carousel.js') 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 -- cgit v1.2.3