PageSourceSearch

https://uniqlogistic.pl/en/js/opSlider.js

js uniqlogistic.pl collected 2026-10-08 02:41:42 UTC 21,011 bytes, 670 lines download raw bytes

1/*!
2  * Bootstrap opSlider.js v4.3.1 (https://getbootstrap.com/)
3  * Copyright 2011-2019 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
4  * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
5  */
6(function (global, factory) {
7  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('jquery'), require('util.js')) :
8    typeof define === 'function' && define.amd ? define(['jquery', 'util.js'], factory) :
9      (global = global || self, global.opSlider = factory(global.jQuery, global.Util));
10}(this, function ($, Util) {
11  'use strict';
12
13  $ = $ && $.hasOwnProperty('default') ? $['default'] : $;
14  Util = Util && Util.hasOwnProperty('default') ? Util['default'] : Util;
15
16  function _defineProperties(target, props) {
17    for (var i = 0; i < props.length; i++) {
18      var descriptor = props[i];
19      descriptor.enumerable = descriptor.enumerable || false;
20      descriptor.configurable = true;
21      if ("value" in descriptor) descriptor.writable = true;
22      Object.defineProperty(target, descriptor.key, descriptor);
23    }
24  }
25
26  function _createClass(Constructor, protoProps, staticProps) {
27    if (protoProps) _defineProperties(Constructor.prototype, protoProps);
28    if (staticProps) _defineProperties(Constructor, staticProps);
29    return Constructor;
30  }
31
32  function _defineProperty(obj, key, value) {
33    if (key in obj) {
34      Object.defineProperty(obj, key, {
35        value: value,
36        enumerable: true,
37        configurable: true,
38        writable: true
39      });
40    } else {
41      obj[key] = value;
42    }
43
44    return obj;
45  }
46
47  function _objectSpread(target) {
48    for (var i = 1; i < arguments.length; i++) {
49      var source = arguments[i] != null ? arguments[i] : {};
50      var ownKeys = Object.keys(source);
51
52      if (typeof Object.getOwnPropertySymbols === 'function') {
53        ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) {
54          return Object.getOwnPropertyDescriptor(source, sym).enumerable;
55        }));
56      }
57
58      ownKeys.forEach(function (key) {
59        _defineProperty(target, key, source[key]);
60      });
61    }
62
63    return target;
64  }
65
66  /**
67   * ------------------------------------------------------------------------
68   * Constants
69   * ------------------------------------------------------------------------
70   */
71
72  var NAME = 'opSlider';
73  var VERSION = '4.3.1';
74  var DATA_KEY = 'bs.opSlider';
75  var EVENT_KEY = "." + DATA_KEY;
76  var DATA_API_KEY = '.data-api';
77  var JQUERY_NO_CONFLICT = $.fn[NAME];
78  var ARROW_LEFT_KEYCODE = 37; // KeyboardEvent.which value for left arrow key
79
80  var ARROW_RIGHT_KEYCODE = 39; // KeyboardEvent.which value for right arrow key
81
82  var TOUCHEVENT_COMPAT_WAIT = 500; // Time for mouse compat events to fire after touch
83
84  var SWIPE_THRESHOLD = 40;
85  var Default = {
86    interval: 5000,
87    keyboard: true,
88    slide: false,
89    pause: 'hover',
90    wrap: true,
91    touch: true
92  };
93  var DefaultType = {
94    interval: '(number|boolean)',
95    keyboard: 'boolean',
96    slide: '(boolean|string)',
97    pause: '(string|boolean)',
98    wrap: 'boolean',
99    touch: 'boolean'
100  };
101  var Direction = {
102    NEXT: 'next',
103    PREV: 'prev',
104    LEFT: 'left',
105    RIGHT: 'right'
106  };
107  var Event = {
108    SLIDE: "slide" + EVENT_KEY,
109    SLID: "slid" + EVENT_KEY,
110    KEYDOWN: "keydown" + EVENT_KEY,
111    MOUSEENTER: "mouseenter" + EVENT_KEY,
112    MOUSELEAVE: "mouseleave" + EVENT_KEY,
113    TOUCHSTART: "touchstart" + EVENT_KEY,
114    TOUCHMOVE: "touchmove" + EVENT_KEY,
115    TOUCHEND: "touchend" + EVENT_KEY,
116    POINTERDOWN: "pointerdown" + EVENT_KEY,
117    POINTERUP: "pointerup" + EVENT_KEY,
118    DRAG_START: "dragstart" + EVENT_KEY,
119    LOAD_DATA_API: "load" + EVENT_KEY + DATA_API_KEY,
120    CLICK_DATA_API: "click" + EVENT_KEY + DATA_API_KEY
121  };
122  var ClassName = {
123    opSlider: 'opSlider',
124    ACTIVE: 'active',
125    SLIDE: 'slide',
126    RIGHT: 'opSlider-item-right',
127    LEFT: 'opSlider-item-left',
128    NEXT: 'opSlider-item-next',
129    PREV: 'opSlider-item-prev',
130    ITEM: 'opSlider-item',
131    POINTER_EVENT: 'pointer-event'
132  };
133  var Selector = {
134    ACTIVE: '.active',
135    ACTIVE_ITEM: '.active.opSlider-item',
136    ITEM: '.opSlider-item',
137    ITEM_IMG: '.opSlider-item img',
138    NEXT_PREV: '.opSlider-item-next, .opSlider-item-prev',
139    INDICATORS: '.opSlider-indicators',
140    DATA_SLIDE: '[data-slide], [data-slide-to]',
141    DATA_RIDE: '[data-ride="opSlider"]'
142  };
143  var PointerType = {
144    TOUCH: 'touch',
145    PEN: 'pen'
146    /**
147     * ------------------------------------------------------------------------
148     * Class Definition
149     * ------------------------------------------------------------------------
150     */
151
152  };
153
154  var opSlider =
155    /*#__PURE__*/
156    function () {
157      function opSlider(element, config) {
158        this._items = null;
159        this._interval = null;
160        this._activeElement = null;
161        this._isPaused = false;
162        this._isSliding = false;
163        this.touchTimeout = null;
164        this.touchStartX = 0;
165        this.touchDeltaX = 0;
166        this._config = this._getConfig(config);
167        this._element = element;
168        this._indicatorsElement = this._element.querySelector(Selector.INDICATORS);
169        this._touchSupported = 'ontouchstart' in document.documentElement || navigator.maxTouchPoints > 0;
170        this._pointerEvent = Boolean(window.PointerEvent || window.MSPointerEvent);
171
172        this._addEventListeners();
173      } // Getters
174
175
176      var _proto = opSlider.prototype;
177
178      // Public
179      _proto.next = function next() {
180        if (!this._isSliding) {
181          this._slide(Direction.NEXT);
182        }
183      };
184
185      _proto.nextWhenVisible = function nextWhenVisible() {
186        // Don't call next when the page isn't visible
187        // or the opSlider or its parent isn't visible
188        if (!document.hidden && $(this._element).is(':visible') && $(this._element).css('visibility') !== 'hidden') {
189          this.next();
190        }
191      };
192
193      _proto.prev = function prev() {
194        if (!this._isSliding) {
195          this._slide(Direction.PREV);
196        }
197      };
198
199      _proto.pause = function pause(event) {
200        if (!event) {
201          this._isPaused = true;
202        }
203
204        if (this._element.querySelector(Selector.NEXT_PREV)) {
205          Util.triggerTransitionEnd(this._element);
206          this.cycle(true);
207        }
208
209        clearInterval(this._interval);
210        this._interval = null;
211      };
212
213      _proto.cycle = function cycle(event) {
214        if (!event) {
215          this._isPaused = false;
216        }
217
218        if (this._interval) {
219          clearInterval(this._interval);
220          this._interval = null;
221        }
222
223        if (this._config.interval && !this._isPaused) {
224          this._interval = setInterval((document.visibilityState ? this.nextWhenVisible : this.next).bind(this), this._config.interval);
225        }
226      };
227
228      _proto.to = function to(index) {
229        var _this = this;
230
231        this._activeElement = this._element.querySelector(Selector.ACTIVE_ITEM);
232
233        var activeIndex = this._getItemIndex(this._activeElement);
234
235        if (index > this._items.length - 1 || index < 0) {
236          return;
237        }
238
239        if (this._isSliding) {
240          $(this._element).one(Event.SLID, function () {
241            return _this.to(index);
242          });
243          return;
244        }
245
246        if (activeIndex === index) {
247          this.pause();
248          this.cycle();
249          return;
250        }
251
252        var direction = index > activeIndex ? Direction.NEXT : Direction.PREV;
253
254        this._slide(direction, this._items[index]);
255      };
256
257      _proto.dispose = function dispose() {
258        $(this._element).off(EVENT_KEY);
259        $.removeData(this._element, DATA_KEY);
260        this._items = null;
261        this._config = null;
262        this._element = null;
263        this._interval = null;
264        this._isPaused = null;
265        this._isSliding = null;
266        this._activeElement = null;
267        this._indicatorsElement = null;
268      } // Private
269      ;
270
271      _proto._getConfig = function _getConfig(config) {
272        config = _objectSpread({}, Default, config);
273        Util.typeCheckConfig(NAME, config, DefaultType);
274        return config;
275      };
276
277      _proto._handleSwipe = function _handleSwipe() {
278        var absDeltax = Math.abs(this.touchDeltaX);
279
280        if (absDeltax <= SWIPE_THRESHOLD) {
281          return;
282        }
283
284        var direction = absDeltax / this.touchDeltaX; // swipe left
285
286        if (direction > 0) {
287          this.prev();
288        } // swipe right
289
290
291        if (direction < 0) {
292          this.next();
293        }
294      };
295
296      _proto._addEventListeners = function _addEventListeners() {
297        var _this2 = this;
298
299        if (this._config.keyboard) {
300          $(this._element).on(Event.KEYDOWN, function (event) {
301            return _this2._keydown(event);
302          });
303        }
304
305        if (this._config.pause === 'hover') {
306          $(this._element).on(Event.MOUSEENTER, function (event) {
307            return _this2.pause(event);
308          }).on(Event.MOUSELEAVE, function (event) {
309            return _this2.cycle(event);
310          });
311        }
312
313        if (this._config.touch) {
314          this._addTouchEventListeners();
315        }
316      };
317
318      _proto._addTouchEventListeners = function _addTouchEventListeners() {
319        var _this3 = this;
320
321        if (!this._touchSupported) {
322          return;
323        }
324
325        var start = function start(event) {
326          if (_this3._pointerEvent && PointerType[event.originalEvent.pointerType.toUpperCase()]) {
327            _this3.touchStartX = event.originalEvent.clientX;
328          } else if (!_this3._pointerEvent) {
329            _this3.touchStartX = event.originalEvent.touches[0].clientX;
330          }
331        };
332
333        var move = function move(event) {
334          // ensure swiping with one touch and not pinching
335          if (event.originalEvent.touches && event.originalEvent.touches.length > 1) {
336            _this3.touchDeltaX = 0;
337          } else {
338            _this3.touchDeltaX = event.originalEvent.touches[0].clientX - _this3.touchStartX;
339          }
340        };
341
342        var end = function end(event) {
343          if (_this3._pointerEvent && PointerType[event.originalEvent.pointerType.toUpperCase()]) {
344            _this3.touchDeltaX = event.originalEvent.clientX - _this3.touchStartX;
345          }
346
347          _this3._handleSwipe();
348
349          if (_this3._config.pause === 'hover') {
350            // If it's a touch-enabled device, mouseenter/leave are fired as
351            // part of the mouse compatibility events on first tap - the opSlider
352            // would stop cycling until user tapped out of it;
353            // here, we listen for touchend, explicitly pause the opSlider
354            // (as if it's the second time we tap on it, mouseenter compat event
355            // is NOT fired) and after a timeout (to allow for mouse compatibility
356            // events to fire) we explicitly restart cycling
357            _this3.pause();
358
359            if (_this3.touchTimeout) {
360              clearTimeout(_this3.touchTimeout);
361            }
362
363            _this3.touchTimeout = setTimeout(function (event) {
364              return _this3.cycle(event);
365            }, TOUCHEVENT_COMPAT_WAIT + _this3._config.interval);
366          }
367        };
368
369        $(this._element.querySelectorAll(Selector.ITEM_IMG)).on(Event.DRAG_START, function (e) {
370          return e.preventDefault();
371        });
372
373        if (this._pointerEvent) {
374          $(this._element).on(Event.POINTERDOWN, function (event) {
375            return start(event);
376          });
377          $(this._element).on(Event.POINTERUP, function (event) {
378            return end(event);
379          });
380
381          this._element.classList.add(ClassName.POINTER_EVENT);
382        } else {
383          $(this._element).on(Event.TOUCHSTART, function (event) {
384            return start(event);
385          });
386          $(this._element).on(Event.TOUCHMOVE, function (event) {
387            return move(event);
388          });
389          $(this._element).on(Event.TOUCHEND, function (event) {
390            return end(event);
391          });
392        }
393      };
394
395      _proto._keydown = function _keydown(event) {
396        if (/input|textarea/i.test(event.target.tagName)) {
397          return;
398        }
399
400        switch (event.which) {
401          case ARROW_LEFT_KEYCODE:
402            event.preventDefault();
403            this.prev();
404            break;
405
406          case ARROW_RIGHT_KEYCODE:
407            event.preventDefault();
408            this.next();
409            break;
410
411          default:
412        }
413      };
414
415      _proto._getItemIndex = function _getItemIndex(element) {
416        this._items = element && element.parentNode ? [].slice.call(element.parentNode.querySelectorAll(Selector.ITEM)) : [];
417        return this._items.indexOf(element);
418      };
419
420      _proto._getItemByDirection = function _getItemByDirection(direction, activeElement) {
421        var isNextDirection = direction === Direction.NEXT;
422        var isPrevDirection = direction === Direction.PREV;
423
424        var activeIndex = this._getItemIndex(activeElement);
425
426        var lastItemIndex = this._items.length - 1;
427        var isGoingToWrap = isPrevDirection && activeIndex === 0 || isNextDirection && activeIndex === lastItemIndex;
428
429        if (isGoingToWrap && !this._config.wrap) {
430          return activeElement;
431        }
432
433        var delta = direction === Direction.PREV ? -1 : 1;
434        var itemIndex = (activeIndex + delta) % this._items.length;
435        return itemIndex === -1 ? this._items[this._items.length - 1] : this._items[itemIndex];
436      };
437
438      _proto._triggerSlideEvent = function _triggerSlideEvent(relatedTarget, eventDirectionName) {
439        var targetIndex = this._getItemIndex(relatedTarget);
440
441        var fromIndex = this._getItemIndex(this._element.querySelector(Selector.ACTIVE_ITEM));
442
443        var slideEvent = $.Event(Event.SLIDE, {
444          relatedTarget: relatedTarget,
445          direction: eventDirectionName,
446          from: fromIndex,
447          to: targetIndex
448        });
449        $(this._element).trigger(slideEvent);
450        return slideEvent;
451      };
452
453      _proto._setActiveIndicatorElement = function _setActiveIndicatorElement(element) {
454        if (this._indicatorsElement) {
455          var indicators = [].slice.call(this._indicatorsElement.querySelectorAll(Selector.ACTIVE));
456          //console.log('RemoveClassSelector');
457          $(indicators).removeClass(ClassName.ACTIVE);
458
459          var nextIndicator = this._indicatorsElement.children[this._getItemIndex(element)];
460
461          if (nextIndicator) {
462            $(nextIndicator).addClass(ClassName.ACTIVE);
463          }
464        }
465      };
466
467      _proto._slide = function _slide(direction, element) {
468        var _this4 = this;
469
470        var activeElement = this._element.querySelector(Selector.ACTIVE_ITEM);
471
472        var activeElementIndex = this._getItemIndex(activeElement);
473
474        var nextElement = element || activeElement && this._getItemByDirection(direction, activeElement);
475
476        var nextElementIndex = this._getItemIndex(nextElement);
477
478        var isCycling = Boolean(this._interval);
479        var directionalClassName;
480        var orderClassName;
481        var eventDirectionName;
482
483        if (direction === Direction.NEXT) {
484          directionalClassName = ClassName.LEFT;
485          orderClassName = ClassName.NEXT;
486          eventDirectionName = Direction.LEFT;
487        } else {
488          directionalClassName = ClassName.RIGHT;
489          orderClassName = ClassName.PREV;
490          eventDirectionName = Direction.RIGHT;
491        }
492
493        if (nextElement && $(nextElement).hasClass(ClassName.ACTIVE)) {
494          this._isSliding = false;
495          return;
496        }
497
498        var slideEvent = this._triggerSlideEvent(nextElement, eventDirectionName);
499
500        if (slideEvent.isDefaultPrevented()) {
501          return;
502        }
503
504        if (!activeElement || !nextElement) {
505          // Some weirdness is happening, so we bail
506          return;
507        }
508
509        this._isSliding = true;
510
511        if (isCycling) {
512          this.pause();
513        }
514
515        this._setActiveIndicatorElement(nextElement);
516
517        var slidEvent = $.Event(Event.SLID, {
518          relatedTarget: nextElement,
519          direction: eventDirectionName,
520          from: activeElementIndex,
521          to: nextElementIndex
522        });
523
524        if ($(this._element).hasClass(ClassName.SLIDE)) {
525          $(nextElement).addClass(orderClassName);
526          Util.reflow(nextElement);
527          $(activeElement).addClass(directionalClassName);
528          $(nextElement).addClass(directionalClassName);
529          var nextElementInterval = parseInt(nextElement.getAttribute('data-interval'), 10);
530
531          if (nextElementInterval) {
532            this._config.defaultInterval = this._config.defaultInterval || this._config.interval;
533            this._config.interval = nextElementInterval;
534          } else {
535            this._config.interval = this._config.defaultInterval || this._config.interval;
536          }
537
538          var transitionDuration = Util.getTransitionDurationFromElement(activeElement);
539          $(activeElement).one(Util.TRANSITION_END, function () {
540            $(nextElement).removeClass(directionalClassName + " " + orderClassName).addClass(ClassName.ACTIVE);
541            $(activeElement).removeClass(ClassName.ACTIVE + " " + orderClassName + " " + directionalClassName);
542            _this4._isSliding = false;
543            setTimeout(function () {
544              return $(_this4._element).trigger(slidEvent);
545            }, 0);
546          }).emulateTransitionEnd(transitionDuration);
547        } else {
548          $(activeElement).removeClass(ClassName.ACTIVE);
549          $(nextElement).addClass(ClassName.ACTIVE);
550          this._isSliding = false;
551          $(this._element).trigger(slidEvent);
552        }
553
554        if (isCycling) {
555          this.cycle();
556        }
557      } // Static
558      ;
559
560      opSlider._jQueryInterface = function _jQueryInterface(config) {
561        return this.each(function () {
562          var data = $(this).data(DATA_KEY);
563
564          var _config = _objectSpread({}, Default, $(this).data());
565
566          if (typeof config === 'object') {
567            _config = _objectSpread({}, _config, config);
568          }
569
570          var action = typeof config === 'string' ? config : _config.slide;
571
572          if (!data) {
573            data = new opSlider(this, _config);
574            $(this).data(DATA_KEY, data);
575          }
576
577          if (typeof config === 'number') {
578            data.to(config);
579          } else if (typeof action === 'string') {
580            if (typeof data[action] === 'undefined') {
581              throw new TypeError("No method named \"" + action + "\"");
582            }
583
584            data[action]();
585          } else if (_config.interval && _config.ride) {
586            data.pause();
587            data.cycle();
588          }
589        });
590      };
591
592      opSlider._dataApiClickHandler = function _dataApiClickHandler(event) {
593        var selector = Util.getSelectorFromElement(this);
594
595        if (!selector) {
596          return;
597        }
598
599        var target = $(selector)[0];
600
601        if (!target || !$(target).hasClass(ClassName.opSlider)) {
602          return;
603        }
604
605        var config = _objectSpread({}, $(target).data(), $(this).data());
606
607        var slideIndex = this.getAttribute('data-slide-to');
608
609        if (slideIndex) {
610          config.interval = false;
611        }
612
613        opSlider._jQueryInterface.call($(target), config);
614
615        if (slideIndex) {
616          $(target).data(DATA_KEY).to(slideIndex);
617        }
618
619        event.preventDefault();
620      };
621
622      _createClass(opSlider, null, [{
623        key: "VERSION",
624        get: function get() {
625          return VERSION;
626        }
627      }, {
628        key: "Default",
629        get: function get() {
630          return Default;
631        }
632      }]);
633
634      return opSlider;
635    }();
636  /**
637   * ------------------------------------------------------------------------
638   * Data Api implementation
639   * ------------------------------------------------------------------------
640   */
641
642
643  $(document).on(Event.CLICK_DATA_API, Selector.DATA_SLIDE, opSlider._dataApiClickHandler);
644  $(window).on(Event.LOAD_DATA_API, function () {
645    var opSliders = [].slice.call(document.querySelectorAll(Selector.DATA_RIDE));
646
647    for (var i = 0, len = opSliders.length; i < len; i++) {
648      var $opSlider = $(opSliders[i]);
649
650      opSlider._jQueryInterface.call($opSlider, $opSlider.data());
651    }
652  });
653  /**
654   * ------------------------------------------------------------------------
655   * jQuery
656   * ------------------------------------------------------------------------
657   */
658
659  $.fn[NAME] = opSlider._jQueryInterface;
660  $.fn[NAME].Constructor = opSlider;
661
662  $.fn[NAME].noConflict = function () {
663    $.fn[NAME] = JQUERY_NO_CONFLICT;
664    return opSlider._jQueryInterface;
665  };
666
667  return opSlider;
668
669}));
670//# sourceMappingURL=opSlider.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.