PageSourceSearch

https://glos.pl/assets/themes/positive/assets/js/carousel.js

js glos.pl collected 2026-10-02 04:03:56 UTC 15,569 bytes, 506 lines download raw bytes

1function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
3function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
4
5function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
6
7/**
8 * --------------------------------------------------------------------------
9 * Bootstrap (v4.0.0): carousel.js
10 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
11 * --------------------------------------------------------------------------
12 */
13var Carousel = function ($) {
14  /**
15   * ------------------------------------------------------------------------
16   * Constants
17   * ------------------------------------------------------------------------
18   */
19  var NAME = 'carousel';
20  var VERSION = '4.0.0';
21  var DATA_KEY = 'bs.carousel';
22  var EVENT_KEY = "." + DATA_KEY;
23  var DATA_API_KEY = '.data-api';
24  var JQUERY_NO_CONFLICT = $.fn[NAME];
25  var TRANSITION_DURATION = 600;
26  var ARROW_LEFT_KEYCODE = 37; // KeyboardEvent.which value for left arrow key
27
28  var ARROW_RIGHT_KEYCODE = 39; // KeyboardEvent.which value for right arrow key
29
30  var TOUCHEVENT_COMPAT_WAIT = 500; // Time for mouse compat events to fire after touch
31
32  var Default = {
33    interval: 5000,
34    keyboard: true,
35    slide: false,
36    pause: 'hover',
37    wrap: true
38  };
39  var DefaultType = {
40    interval: '(number|boolean)',
41    keyboard: 'boolean',
42    slide: '(boolean|string)',
43    pause: '(string|boolean)',
44    wrap: 'boolean'
45  };
46  var Direction = {
47    NEXT: 'next',
48    PREV: 'prev',
49    LEFT: 'left',
50    RIGHT: 'right'
51  };
52  var Event = {
53    SLIDE: "slide" + EVENT_KEY,
54    SLID: "slid" + EVENT_KEY,
55    KEYDOWN: "keydown" + EVENT_KEY,
56    MOUSEENTER: "mouseenter" + EVENT_KEY,
57    MOUSELEAVE: "mouseleave" + EVENT_KEY,
58    TOUCHEND: "touchend" + EVENT_KEY,
59    LOAD_DATA_API: "load" + EVENT_KEY + DATA_API_KEY,
60    CLICK_DATA_API: "click" + EVENT_KEY + DATA_API_KEY
61  };
62  var ClassName = {
63    CAROUSEL: 'carousel',
64    ACTIVE: 'active',
65    SLIDE: 'slide',
66    RIGHT: 'carousel-item-right',
67    LEFT: 'carousel-item-left',
68    NEXT: 'carousel-item-next',
69    PREV: 'carousel-item-prev',
70    ITEM: 'carousel-item'
71  };
72  var Selector = {
73    ACTIVE: '.active',
74    ACTIVE_ITEM: '.active.carousel-item',
75    ITEM: '.carousel-item',
76    NEXT_PREV: '.carousel-item-next, .carousel-item-prev',
77    INDICATORS: '.carousel-indicators',
78    DATA_SLIDE: '[data-slide], [data-slide-to]',
79    DATA_RIDE: '[data-ride="carousel"]'
80    /**
81     * ------------------------------------------------------------------------
82     * Class Definition
83     * ------------------------------------------------------------------------
84     */
85
86  };
87
88  var Carousel =
89  /*#__PURE__*/
90  function () {
91    function Carousel(element, config) {
92      this._items = null;
93      this._interval = null;
94      this._activeElement = null;
95      this._isPaused = false;
96      this._isSliding = false;
97      this.touchTimeout = null;
98      this._config = this._getConfig(config);
99      this._element = $(element)[0];
100      this._indicatorsElement = $(this._element).find(Selector.INDICATORS)[0];
101
102      this._addEventListeners();
103    } // Getters
104
105
106    var _proto = Carousel.prototype;
107
108    // Public
109    _proto.next = function next() {
110      if (!this._isSliding) {
111        this._slide(Direction.NEXT);
112      }
113    };
114
115    _proto.nextWhenVisible = function nextWhenVisible() {
116      // Don't call next when the page isn't visible
117      // or the carousel or its parent isn't visible
118      if (!document.hidden && $(this._element).is(':visible') && $(this._element).css('visibility') !== 'hidden') {
119        this.next();
120      }
121    };
122
123    _proto.prev = function prev() {
124      if (!this._isSliding) {
125        this._slide(Direction.PREV);
126      }
127    };
128
129    _proto.pause = function pause(event) {
130      if (!event) {
131        this._isPaused = true;
132      }
133
134      if ($(this._element).find(Selector.NEXT_PREV)[0] && Util.supportsTransitionEnd()) {
135        Util.triggerTransitionEnd(this._element);
136        this.cycle(true);
137      }
138
139      clearInterval(this._interval);
140      this._interval = null;
141    };
142
143    _proto.cycle = function cycle(event) {
144      if (!event) {
145        this._isPaused = false;
146      }
147
148      if (this._interval) {
149        clearInterval(this._interval);
150        this._interval = null;
151      }
152
153      if (this._config.interval && !this._isPaused) {
154        this._interval = setInterval((document.visibilityState ? this.nextWhenVisible : this.next).bind(this), this._config.interval);
155      }
156    };
157
158    _proto.to = function to(index) {
159      var _this = this;
160
161      this._activeElement = $(this._element).find(Selector.ACTIVE_ITEM)[0];
162
163      var activeIndex = this._getItemIndex(this._activeElement);
164
165      if (index > this._items.length - 1 || index < 0) {
166        return;
167      }
168
169      if (this._isSliding) {
170        $(this._element).one(Event.SLID, function () {
171          return _this.to(index);
172        });
173        return;
174      }
175
176      if (activeIndex === index) {
177        this.pause();
178        this.cycle();
179        return;
180      }
181
182      var direction = index > activeIndex ? Direction.NEXT : Direction.PREV;
183
184      this._slide(direction, this._items[index]);
185    };
186
187    _proto.dispose = function dispose() {
188      $(this._element).off(EVENT_KEY);
189      $.removeData(this._element, DATA_KEY);
190      this._items = null;
191      this._config = null;
192      this._element = null;
193      this._interval = null;
194      this._isPaused = null;
195      this._isSliding = null;
196      this._activeElement = null;
197      this._indicatorsElement = null;
198    }; // Private
199
200
201    _proto._getConfig = function _getConfig(config) {
202      config = _extends({}, Default, config);
203      Util.typeCheckConfig(NAME, config, DefaultType);
204      return config;
205    };
206
207    _proto._addEventListeners = function _addEventListeners() {
208      var _this2 = this;
209
210      if (this._config.keyboard) {
211        $(this._element).on(Event.KEYDOWN, function (event) {
212          return _this2._keydown(event);
213        });
214      }
215
216      if (this._config.pause === 'hover') {
217        $(this._element).on(Event.MOUSEENTER, function (event) {
218          return _this2.pause(event);
219        }).on(Event.MOUSELEAVE, function (event) {
220          return _this2.cycle(event);
221        });
222
223        if ('ontouchstart' in document.documentElement) {
224          // If it's a touch-enabled device, mouseenter/leave are fired as
225          // part of the mouse compatibility events on first tap - the carousel
226          // would stop cycling until user tapped out of it;
227          // here, we listen for touchend, explicitly pause the carousel
228          // (as if it's the second time we tap on it, mouseenter compat event
229          // is NOT fired) and after a timeout (to allow for mouse compatibility
230          // events to fire) we explicitly restart cycling
231          $(this._element).on(Event.TOUCHEND, function () {
232            _this2.pause();
233
234            if (_this2.touchTimeout) {
235              clearTimeout(_this2.touchTimeout);
236            }
237
238            _this2.touchTimeout = setTimeout(function (event) {
239              return _this2.cycle(event);
240            }, TOUCHEVENT_COMPAT_WAIT + _this2._config.interval);
241          });
242        }
243      }
244    };
245
246    _proto._keydown = function _keydown(event) {
247      if (/input|textarea/i.test(event.target.tagName)) {
248        return;
249      }
250
251      switch (event.which) {
252        case ARROW_LEFT_KEYCODE:
253          event.preventDefault();
254          this.prev();
255          break;
256
257        case ARROW_RIGHT_KEYCODE:
258          event.preventDefault();
259          this.next();
260          break;
261
262        default:
263      }
264    };
265
266    _proto._getItemIndex = function _getItemIndex(element) {
267      this._items = $.makeArray($(element).parent().find(Selector.ITEM));
268      return this._items.indexOf(element);
269    };
270
271    _proto._getItemByDirection = function _getItemByDirection(direction, activeElement) {
272      var isNextDirection = direction === Direction.NEXT;
273      var isPrevDirection = direction === Direction.PREV;
274
275      var activeIndex = this._getItemIndex(activeElement);
276
277      var lastItemIndex = this._items.length - 1;
278      var isGoingToWrap = isPrevDirection && activeIndex === 0 || isNextDirection && activeIndex === lastItemIndex;
279
280      if (isGoingToWrap && !this._config.wrap) {
281        return activeElement;
282      }
283
284      var delta = direction === Direction.PREV ? -1 : 1;
285      var itemIndex = (activeIndex + delta) % this._items.length;
286      return itemIndex === -1 ? this._items[this._items.length - 1] : this._items[itemIndex];
287    };
288
289    _proto._triggerSlideEvent = function _triggerSlideEvent(relatedTarget, eventDirectionName) {
290      var targetIndex = this._getItemIndex(relatedTarget);
291
292      var fromIndex = this._getItemIndex($(this._element).find(Selector.ACTIVE_ITEM)[0]);
293
294      var slideEvent = $.Event(Event.SLIDE, {
295        relatedTarget: relatedTarget,
296        direction: eventDirectionName,
297        from: fromIndex,
298        to: targetIndex
299      });
300      $(this._element).trigger(slideEvent);
301      return slideEvent;
302    };
303
304    _proto._setActiveIndicatorElement = function _setActiveIndicatorElement(element) {
305      if (this._indicatorsElement) {
306        $(this._indicatorsElement).find(Selector.ACTIVE).removeClass(ClassName.ACTIVE);
307
308        var nextIndicator = this._indicatorsElement.children[this._getItemIndex(element)];
309
310        if (nextIndicator) {
311          $(nextIndicator).addClass(ClassName.ACTIVE);
312        }
313      }
314    };
315
316    _proto._slide = function _slide(direction, element) {
317      var _this3 = this;
318
319      var activeElement = $(this._element).find(Selector.ACTIVE_ITEM)[0];
320
321      var activeElementIndex = this._getItemIndex(activeElement);
322
323      var nextElement = element || activeElement && this._getItemByDirection(direction, activeElement);
324
325      var nextElementIndex = this._getItemIndex(nextElement);
326
327      var isCycling = Boolean(this._interval);
328      var directionalClassName;
329      var orderClassName;
330      var eventDirectionName;
331
332      if (direction === Direction.NEXT) {
333        directionalClassName = ClassName.LEFT;
334        orderClassName = ClassName.NEXT;
335        eventDirectionName = Direction.LEFT;
336      } else {
337        directionalClassName = ClassName.RIGHT;
338        orderClassName = ClassName.PREV;
339        eventDirectionName = Direction.RIGHT;
340      }
341
342      if (nextElement && $(nextElement).hasClass(ClassName.ACTIVE)) {
343        this._isSliding = false;
344        return;
345      }
346
347      var slideEvent = this._triggerSlideEvent(nextElement, eventDirectionName);
348
349      if (slideEvent.isDefaultPrevented()) {
350        return;
351      }
352
353      if (!activeElement || !nextElement) {
354        // Some weirdness is happening, so we bail
355        return;
356      }
357
358      this._isSliding = true;
359
360      if (isCycling) {
361        this.pause();
362      }
363
364      this._setActiveIndicatorElement(nextElement);
365
366      var slidEvent = $.Event(Event.SLID, {
367        relatedTarget: nextElement,
368        direction: eventDirectionName,
369        from: activeElementIndex,
370        to: nextElementIndex
371      });
372
373      if (Util.supportsTransitionEnd() && $(this._element).hasClass(ClassName.SLIDE)) {
374        $(nextElement).addClass(orderClassName);
375        Util.reflow(nextElement);
376        $(activeElement).addClass(directionalClassName);
377        $(nextElement).addClass(directionalClassName);
378        $(activeElement).one(Util.TRANSITION_END, function () {
379          $(nextElement).removeClass(directionalClassName + " " + orderClassName).addClass(ClassName.ACTIVE);
380          $(activeElement).removeClass(ClassName.ACTIVE + " " + orderClassName + " " + directionalClassName);
381          _this3._isSliding = false;
382          setTimeout(function () {
383            return $(_this3._element).trigger(slidEvent);
384          }, 0);
385        }).emulateTransitionEnd(TRANSITION_DURATION);
386      } else {
387        $(activeElement).removeClass(ClassName.ACTIVE);
388        $(nextElement).addClass(ClassName.ACTIVE);
389        this._isSliding = false;
390        $(this._element).trigger(slidEvent);
391      }
392
393      if (isCycling) {
394        this.cycle();
395      }
396    }; // Static
397
398
399    Carousel._jQueryInterface = function _jQueryInterface(config) {
400      return this.each(function () {
401        var data = $(this).data(DATA_KEY);
402
403        var _config = _extends({}, Default, $(this).data());
404
405        if (typeof config === 'object') {
406          _config = _extends({}, _config, config);
407        }
408
409        var action = typeof config === 'string' ? config : _config.slide;
410
411        if (!data) {
412          data = new Carousel(this, _config);
413          $(this).data(DATA_KEY, data);
414        }
415
416        if (typeof config === 'number') {
417          data.to(config);
418        } else if (typeof action === 'string') {
419          if (typeof data[action] === 'undefined') {
420            throw new TypeError("No method named \"" + action + "\"");
421          }
422
423          data[action]();
424        } else if (_config.interval) {
425          data.pause();
426          data.cycle();
427        }
428      });
429    };
430
431    Carousel._dataApiClickHandler = function _dataApiClickHandler(event) {
432      var selector = Util.getSelectorFromElement(this);
433
434      if (!selector) {
435        return;
436      }
437
438      var target = $(selector)[0];
439
440      if (!target || !$(target).hasClass(ClassName.CAROUSEL)) {
441        return;
442      }
443
444      var config = _extends({}, $(target).data(), $(this).data());
445
446      var slideIndex = this.getAttribute('data-slide-to');
447
448      if (slideIndex) {
449        config.interval = false;
450      }
451
452      Carousel._jQueryInterface.call($(target), config);
453
454      if (slideIndex) {
455        $(target).data(DATA_KEY).to(slideIndex);
456      }
457
458      event.preventDefault();
459    };
460
461    _createClass(Carousel, null, [{
462      key: "VERSION",
463      get: function get() {
464        return VERSION;
465      }
466    }, {
467      key: "Default",
468      get: function get() {
469        return Default;
470      }
471    }]);
472
473    return Carousel;
474  }();
475  /**
476   * ------------------------------------------------------------------------
477   * Data Api implementation
478   * ------------------------------------------------------------------------
479   */
480
481
482  $(document).on(Event.CLICK_DATA_API, Selector.DATA_SLIDE, Carousel._dataApiClickHandler);
483  $(window).on(Event.LOAD_DATA_API, function () {
484    $(Selector.DATA_RIDE).each(function () {
485      var $carousel = $(this);
486
487      Carousel._jQueryInterface.call($carousel, $carousel.data());
488    });
489  });
490  /**
491   * ------------------------------------------------------------------------
492   * jQuery
493   * ------------------------------------------------------------------------
494   */
495
496  $.fn[NAME] = Carousel._jQueryInterface;
497  $.fn[NAME].Constructor = Carousel;
498
499  $.fn[NAME].noConflict = function () {
500    $.fn[NAME] = JQUERY_NO_CONFLICT;
501    return Carousel._jQueryInterface;
502  };
503
504  return Carousel;
505}($);
506//# sourceMappingURL=carousel.js.map

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.