"use strict";

function _instanceof(left, right) { if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) { return !!right[Symbol.hasInstance](left); } else { return left instanceof right; } }

function _classCallCheck(instance, Constructor) { if (!_instanceof(instance, Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

function _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); } }

function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

var Slideshow =
/*#__PURE__*/
function () {
  //nastavení
  //animace v běhu
  //kontejner
  //snímky prezentace
  //číslo aktuálního snímku
  //kontejner přepínacích tlačítek
  //časovač automatického přehrávání
  //seznam obrázků pro velký náhled
  //aktuální číslo velkého náhledu
  //kontejner velkého náhledu
  //obrázek velkého náhledu
  //počítadlo velkého náhledu
  //popisek velkého náhledu

  /**
   constructor
   @sett		(JSON) - nastavení menu
   {				  
   'containerID' : 'slideshow'
   , 'navigation' : {
   'arrows'  : 1
   , 'buttons' : 1
   , 'mouseWheel' : 1
   , 'swipe' : 1
   , 'targetELM' : 'element ID'
   }
   , 'play' : {
   'effect' : 'fade'
   , 'animSpeed' : 0.75
   , 'auto' : {
   'delay' : 8
   , 'autoResumeDelay' : 30
   , 'progressBar' : 1
   }
   }
   , 'changeImage' : {			  
   'targetID' : 'mainImg'
   }
   , 'largePrev' : {
   'startButton' : 'main|all'
   , 'bodyOverflow' : 1
   , 'bodyOverflowBack' : 'x' | 'y' | 'none'
   , 'arrows' : 1
   , 'targetID' : 'mainImg'			
   , 'mouseWheel' : 1
   , 'swipe' : 1
   , 'counter' : 1
   }
   }
   
   containerID - ID kontejneru slideshow
   
   navigation
   arrows - zapnutí / vypnutí ovládacích šipek
   buttons - zapnutí / vypnutí ovládacích tlačítek
   mouseWheel - pokud je nastaveno, bude slideshow reagovat na kolečko myši
   swipe - pokud je nastaveno, bude slideshow reagovat na přejetí po displeji
   targetELM - ID elementu do kterého se umístí ovládání
   
   play
   effect - nastavení druhu efektu (slide-x|slide-y|fade)
   animSpeed - rychlost provedení přechodu (animace) v sekundách
   
   auto
   delay - prodleva v sekundách, kdy se načte další snímek
   autoResumeDelay - prodleva v sekundách, kdy se automaticky obnoví auto přehrávání pokud uživatel ručně změnil snímek
   progressBar - zobrazení zbývajícího času při spuštěném auto play
   
   changeImage	    
   targetID - ID elementu, kam se má vložit obrázek (src)
   
   largePrev
   startButton - nastavení, kde všude se má vygenerovat tlačítko pro spuštění zvětšení
   bodyOverflow - při zobrazení se nastaví document.body.style.overflow = 'hidden'
   bodyOverflowBack - přinastavení x nebo y se použije document.body.style.overflowX(Y) = 'auto', při none se pravidlo overflow vymaže
   arrows - zapnutí / vypnutí ovládacích šipek
   targetID - ID elementu, kam se má vložit tlačítko pro zvětšení (startButton = main)
   mouseWheel - pokud je nastaveno, bude slideshow reagovat na kolečko myši
   swipe - pokud je nastaveno, bude slideshow reagovat na přejetí po displeji
   counter - zobrazení počítadla snímků
  imageStyle - nastavení stylu pro snímky
   --------------------------------------------------------------------
   */
  function Slideshow(sett) {
    _classCallCheck(this, Slideshow);

    _defineProperty(this, "sett", new Object());

    _defineProperty(this, "animInProgress", false);

    _defineProperty(this, "containerELM", void 0);

    _defineProperty(this, "slides", new Array());

    _defineProperty(this, "currentSlide", 0);

    _defineProperty(this, "buttonsContELM", void 0);

    _defineProperty(this, "autoTimer", void 0);

    _defineProperty(this, "autoTimerAutoStart", void 0);

    _defineProperty(this, "largeImgList", new Array());

    _defineProperty(this, "largeImgListTitle", new Array());

    _defineProperty(this, "largeImgNumCurr", 0);

    _defineProperty(this, "largePrevImgCurr", 0);

    _defineProperty(this, "largeImgCont", void 0);

    _defineProperty(this, "largeImg", void 0);

    _defineProperty(this, "largeImgCounter", void 0);

    _defineProperty(this, "largeImgNote", void 0);

    this.sett = sett;
    this.slideshowInit();
  } //------------------------------------------------------------------	

  /**
   slideshowInit		
   --------------------------------------------------------------------
   */


  _createClass(Slideshow, [{
    key: "slideshowInit",
    value: function slideshowInit() {
      this.containerELM = document.getElementById(this.sett['containerID']);
      this.getSlides();
    } //------------------------------------------------------------------

    /**
     getSlides
     Načte snímky.
     --------------------------------------------------------------------
     */

  }, {
    key: "getSlides",
    value: function getSlides() {
      var _this = this;

      //seznam snímků
      if (this.containerELM) {
        var slides = this.containerELM.childNodes;

        for (var sl in slides) {
          if (slides[sl].nodeType == 1) {
            this.slides.push(slides[sl]); //sestavení seznamu snímků

            var mItems = slides[sl].children;

            for (var cm in mItems) {
              if (mItems[cm].nodeType == 1) {
                (function () {
                  if (mItems[cm].hasAttribute('href')) _this.largeImgList.push(mItems[cm].getAttribute('href'));
                  if (mItems[cm].hasAttribute('alt')) _this.largeImgListTitle.push(mItems[cm].getAttribute('alt'));else if (mItems[cm].hasAttribute('title')) _this.largeImgListTitle.push(mItems[cm].getAttribute('title'));
                  var imgNum = _this.largeImgList.length - 1; //nastavení události pro změnu snímku

                  if (_this.sett['changeImage']) {
                    mItems[cm].addEventListener('click', function (e) {
                      e.preventDefault();

                      _this.changeImage(e, imgNum);
                    });
                  } //nastavení tlačítek pro velký náhled


                  if (_this.sett['largePrev']) {
                    if (_this.sett['largePrev']['startButton'] == 'all') {
                      var sButt = document.createElement('span');
                      sButt.setAttribute('class', 'butt_large');
                      sButt.addEventListener('click', function (e) {
                        _this.largeView(e, imgNum);
                      });
                      mItems[cm].appendChild(sButt);
                    }
                  }
                })();
              }
            }
          }
        }
      } //preload obrázků do cache


      this.preloadImages(this.largeImgList); //nastavení tlačítka pro velký náhled u hlavního snímku

      if (this.sett['largePrev'] && this.sett['largePrev']['startButton'] == 'main' && this.sett['largePrev']['targetID']) {
        var mainImgELM = document.getElementById(this.sett['largePrev']['targetID']);

        if (mainImgELM) {
          if (mainImgELM.hasAttribute('alt')) this.largeImgListTitle.push(mainImgELM.getAttribute('alt'));else if (mainImgELM.hasAttribute('title')) this.largeImgListTitle.push(mainImgELM.getAttribute('title'));
          var sButt = document.createElement('span');
          sButt.setAttribute('class', 'butt_large');
          sButt.addEventListener('click', function (e) {
            _this.largeView(e, _this.largePrevImgCurr);
          });
          mainImgELM.parentNode.appendChild(sButt); //přidání do seznamu snímků, pokud nejsou žádné další náhledy

          if (this.largeImgList.length == 0) {
            this.largeImgList.push(mainImgELM.getAttribute('src'));
          }
        }
      }

      if (this.slides.length > 1) {
        //nastavení snímků
        for (var _sl in this.slides) {
          this.slides[_sl].style.zIndex = this.slides.length - _sl;

          if (_sl > 0) {
            if (this.sett['play'] && this.sett['play']['effect'] && this.sett['play']['effect'] == 'slide-x') this.slides[_sl].style.transform = 'translateX(100%)';
            if (this.sett['play'] && this.sett['play']['effect'] && this.sett['play']['effect'] == 'slide-y') this.slides[_sl].style.transform = 'translateY(100%)';

            if (this.sett['play'] && this.sett['play']['effect'] && this.sett['play']['effect'] == 'fade') {
              this.slides[_sl].style.opacity = 0;
              this.slides[_sl].style.transition = 'opacity ' + this.sett['play']['animSpeed'] + 's';
            }
          }
        } //ovládání


        if (this.sett['navigation']) {
          var targetNavELM = this.containerELM;

          if (this.sett['navigation']['targetELM']) {
            var tarELM = document.getElementById(this.sett['navigation']['targetELM']);
            if (tarELM) targetNavELM = tarELM;
          } //nastavení ovládání - šipky


          if (this.sett['navigation']['arrows']) {
            var arrowPrev = document.createElement('div');
            arrowPrev.setAttribute('class', 'arrow_prev');
            arrowPrev.addEventListener('click', function (e) {
              _this.changeSlide(e, 'prev');
            });
            targetNavELM.appendChild(arrowPrev);
            var arrowNext = document.createElement('div');
            arrowNext.setAttribute('class', 'arrow_next');
            arrowNext.addEventListener('click', function (e) {
              _this.changeSlide(e, 'next');
            });
            targetNavELM.appendChild(arrowNext);
          } //nastavení ovládání - tlačítka


          if (this.sett['navigation']['buttons']) {
            this.buttonsContELM = document.createElement('ul');
            this.buttonsContELM.setAttribute('class', 'ul_buttons');

            var _loop = function _loop(_sl2) {
              var buttELM = document.createElement('li');
              buttELM.addEventListener('click', function (e) {
                _this.changeSlide(e, false, _sl2);
              });

              _this.buttonsContELM.appendChild(buttELM);
            };

            for (var _sl2 in this.slides) {
              _loop(_sl2);
            }

            targetNavELM.appendChild(this.buttonsContELM);
            this.settButtons();
          }
        } //nastavení automatického přehrávání


        if (this.sett['play'] && this.sett['play']['auto'] && this.sett['play']['auto']['delay']) {
          this.settTimerDelay(this.sett['play']['auto']['delay']);
        } //nastavení mouseWheel


        if (this.sett['navigation'] && this.sett['navigation']['mouseWheel']) {
          this.containerELM.addEventListener('wheel', function (e) {
            var direction = Math.sign(e.deltaY);
            if (direction > 0) _this.changeSlide(e, 'next');else _this.changeSlide(e, 'prev');
            e.preventDefault();
          });
        } //swipe		


        if (this.sett['navigation'] && this.sett['navigation']['swipe']) {
          var swiper = new Swipe(this.containerELM);

          if (this.sett['play'] && this.sett['play']['effect'] && this.sett['play']['effect'] == 'slide-x') {
            swiper.onLeft(function (e) {
              _this.changeSlide(e, 'next');
            });
            swiper.onRight(function (e) {
              _this.changeSlide(e, 'prev');
            });
          }

          if (this.sett['play'] && this.sett['play']['effect'] && this.sett['play']['effect'] == 'slide-y') {
            swiper.onUp(function (e) {
              _this.changeSlide(e, 'next');
            });
            swiper.onDown(function (e) {
              _this.changeSlide(e, 'prev');
            });
          }

          if (this.sett['play'] && this.sett['play']['effect'] && this.sett['play']['effect'] == 'fade') {
            swiper.onLeft(function (e) {
              _this.changeSlide(e, 'next');
            });
            swiper.onRight(function (e) {
              _this.changeSlide(e, 'prev');
            });
            swiper.onUp(function (e) {
              _this.changeSlide(e, 'next');
            });
            swiper.onDown(function (e) {
              _this.changeSlide(e, 'prev');
            });
          }

          swiper.run();
        }
      }
    } //------------------------------------------------------------------	

    /**
     changeSlide	
     @changeType	(String) - typ změny (prev|next)
     @targetNum		(Integer) - číslo požadovaného snímku
     --------------------------------------------------------------------
     */

  }, {
    key: "changeSlide",
    value: function changeSlide(e, changeType) {
      var targetNum = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;

      if (this.animInProgress == false) {
        this.animInProgress = true;
        var self = this;
        var slideNum = this.currentSlide;

        if (!targetNum) {
          if (changeType == 'prev') {
            self.currentSlide--;
            if (self.currentSlide < 0) self.currentSlide = self.slides.length - 1;
          }

          if (changeType == 'next') {
            self.currentSlide++;
            if (self.currentSlide >= self.slides.length) self.currentSlide = 0;
          }
        } else {
          self.currentSlide = targetNum;
        } //zastavení autoplay


        if (e != null) {
          clearTimeout(this.autoTimer);
          clearTimeout(this.autoTimerAutoStart);
          this.resetProgressBar(); //opětovné spuštění autoplay				

          if (self.sett['play']['auto'] && self.sett['play']['auto']['delay'] && self.sett['play']['auto']['autoResumeDelay']) {
            this.autoTimerAutoStart = setTimeout(function () {
              self.settTimerDelay(self.sett['play']['auto']['delay']);
              clearTimeout(this.autoTimerAutoStart);
            }, self.sett['play']['auto']['autoResumeDelay'] * 1000);
          }
        }

        if (slideNum != self.currentSlide) {
          //--SLIDE X / Y ----------------------------------------------------			
          if (this.sett['play']['effect'] == 'slide-x' || this.sett['play']['effect'] == 'slide-y') {
            var translateType = false;

            switch (this.sett['play']['effect']) {
              case 'slide-x':
                translateType = 'translateX';
                break;

              case 'slide-y':
                translateType = 'translateY';
                break;
            }

            var setVal = false;
            var exeVal = false;

            switch (changeType) {
              case 'prev':
                setVal = -100;
                exeVal = 100;
                break;

              case 'next':
                setVal = 100;
                exeVal = -100;
                break;

              default:
                if (slideNum < self.currentSlide) {
                  setVal = 100;
                  exeVal = -100;
                } else if (slideNum > self.currentSlide) {
                  setVal = -100;
                  exeVal = 100;
                }

                break;
            }

            for (var sl in this.slides) {
              if (sl != slideNum) this.slides[sl].style.transform = translateType + '(' + setVal + '%)';
            }

            var myTT = setTimeout(function () {
              self.slides[slideNum].style.transition = 'transform ' + self.sett['play']['animSpeed'] + 's';
              self.slides[slideNum].style.transform = translateType + '(' + exeVal + '%)';
              var myT = setTimeout(function () {
                self.slides[slideNum].style.transition = 'none';
                self.slides[slideNum].style.transform = 'translateX(100%)';
                self.animInProgress = false;
                self.settButtons();
                clearTimeout(myT);
              }, self.sett['play']['animSpeed'] * 1000);
              self.slides[self.currentSlide].style.transition = 'transform ' + self.sett['play']['animSpeed'] + 's';
              self.slides[self.currentSlide].style.transform = translateType + '(0%)';
              clearTimeout(myTT);
            }, 20);
          } //------------------------------------------------------------------			
          //--FADE------------------------------------------------------------


          if (this.sett['play']['effect'] == 'fade') {
            var slNum = 0;

            for (var _sl3 in this.slides) {
              if (_sl3 != this.currentSlide) {
                this.slides[_sl3].style.zIndex = slNum;
                slNum++;
              }
            }

            this.slides[this.currentSlide].style.zIndex = this.slides.length - 1;
            var myTT = setTimeout(function () {
              self.slides[slideNum].style.transition = 'opacity ' + self.sett['play']['animSpeed'] + 's';
              self.slides[slideNum].style.opacity = 0;
              var myT = setTimeout(function () {
                self.slides[slideNum].style.transition = 'none';
                self.slides[slideNum].style.opacity = 0;
                self.animInProgress = false;
                self.settButtons();
                clearTimeout(myT);
              }, self.sett['play']['animSpeed'] * 1000);
              self.slides[self.currentSlide].style.transition = 'opacity ' + self.sett['play']['animSpeed'] + 's';
              self.slides[self.currentSlide].style.opacity = 1;
              clearTimeout(myTT);
            }, 20);
          } //------------------------------------------------------------------

        } else this.animInProgress = false;
      }
    } //------------------------------------------------------------------

    /**
     changeImage
     @e				(event)
     @imgNum		(integer) - číslo obrázku v seznamu
     --------------------------------------------------------------------
     */

  }, {
    key: "changeImage",
    value: function changeImage(e, imgNum) {
      this.largePrevImgCurr = imgNum;
      var filePath = this.largeImgList[imgNum];

      if (this.imageExist(filePath) && this.sett['changeImage']['targetID']) {
        var targetIMG = document.getElementById(this.sett['changeImage']['targetID']);
        if (targetIMG) targetIMG.src = filePath;
      }
    } //------------------------------------------------------------------

    /**
     settButtons	
     Nsataví zobrazení přepínacích tlačítek snímků.
     --------------------------------------------------------------------
     */

  }, {
    key: "settButtons",
    value: function settButtons() {
      if (this.sett['navigation'] && this.sett['navigation']['buttons'] && this.buttonsContELM) {
        var buttons = this.buttonsContELM.childNodes;

        for (var bK in buttons) {
          if (buttons[bK].nodeType == 1) {
            if (this.currentSlide == bK) {
              buttons[bK].setAttribute('class', 'ac');
            } else {
              if (buttons[bK].hasAttribute('class')) buttons[bK].removeAttribute('class');
            }
          }
        }
      }
    } //------------------------------------------------------------------

    /**
     settTimerDelay
     @duration		(decimal) - čas prodlevy (s)
     --------------------------------------------------------------------
     */

  }, {
    key: "settTimerDelay",
    value: function settTimerDelay(duration) {
      this.autoTimerStartT = new Date().getTime();
      var self = this;
      this.autoTimer = setTimeout(function () {
        self.changeSlide(null, 'next');
        self.settTimerDelay(duration);
      }, duration * 1000);

      if (self.sett['play']['auto']['progressBar']) {
        this.resetProgressBar();
        this.progressBarELM = document.createElement('div');
        this.progressBarELM.setAttribute('class', 'div_progress');
        this.containerELM.appendChild(this.progressBarELM);
        this.progressBarELM.style.transform = 'translateX(-100%)';
        clearTimeout(this.progressTT);
        self.setProgressBar(duration);
      }
    } //------------------------------------------------------------------

    /**
     setProgressBar
     --------------------------------------------------------------------
     */

  }, {
    key: "setProgressBar",
    value: function setProgressBar(duration) {
      var percent = (new Date().getTime() - this.autoTimerStartT) / (duration * 1000) * 100;
      this.progressBarELM.style.transform = 'translateX(' + percent + '%)';
      var self = this;
      this.progressTT = setTimeout(function () {
        self.setProgressBar(duration);
      }, 10);
    } //------------------------------------------------------------------

    /**
     resetProgressBar
     --------------------------------------------------------------------
     */

  }, {
    key: "resetProgressBar",
    value: function resetProgressBar() {
      var contChild = this.containerELM.childNodes;

      for (var cC in contChild) {
        if (this.progressBarELM && this.progressBarELM == contChild[cC]) this.containerELM.removeChild(this.progressBarELM);
      }
    } //------------------------------------------------------------------

    /**
     largeView
     Zobrazí velký náhled
     @e		(event)
     @imgNum	(integer) - číslo obrázku v seznamu
     --------------------------------------------------------------------
     */

  }, {
    key: "largeView",
    value: function largeView(e, imgNum) {
      var _this2 = this;

      e.preventDefault();
      this.largeImgNumCurr = imgNum;
      var filePath = this.largeImgList[this.largeImgNumCurr];
      var baseELM = document.createElement('div');
      baseELM.setAttribute('class', 'div_large_preview');
      this.largeImgCont = baseELM;
      var imageContELM = document.createElement('div');
      imageContELM.setAttribute('class', 'div_img_container');
      imageContELM.addEventListener('click', function (e) {
        _this2.largeViewClose(e);
      });
      baseELM.appendChild(imageContELM);
      var imgELM = document.createElement('img');
      imgELM.setAttribute('src', filePath);
      if (this.sett['largePrev']['imageStyle']) imgELM.setAttribute('style', this.sett['largePrev']['imageStyle']);
      imageContELM.appendChild(imgELM);
      this.largeImg = imgELM; //počítadlo

      if (this.sett['largePrev']['counter'] == 1 && this.largeImgList.length > 1) {
        this.largeImgCounter = document.createElement('p');
        this.largeImgCounter.setAttribute('class', 'p_counter');
        var counterTXT = document.createTextNode(this.largeImgNumCurr + 1 + ' / ' + this.largeImgList.length);
        this.largeImgCounter.appendChild(counterTXT);
        baseELM.appendChild(this.largeImgCounter);
      } //popis


      var noteELM = document.createElement('div');
      noteELM.setAttribute('class', 'div_note');
      if (this.largeImgListTitle[this.largeImgNumCurr] && this.largeImgListTitle[this.largeImgNumCurr] != '') noteELM.innerHTML = '<p>' + this.largeImgListTitle[this.largeImgNumCurr] + '</p>';
      this.largeImgNote = noteELM;
      baseELM.appendChild(noteELM); //tlačítko zavření

      var closeButt = document.createElement('span');
      closeButt.setAttribute('class', 'span_close_butt');
      closeButt.addEventListener('click', function (e) {
        _this2.largeViewClose(e);
      });
      baseELM.appendChild(closeButt); //šipky			

      if (this.sett['largePrev']['arrows'] == 1 && this.largeImgList.length > 1) {
        var prewButtELM = document.createElement('span');
        prewButtELM.setAttribute('class', 'span_arrow_prev');
        prewButtELM.addEventListener('click', function (e) {
          _this2.largeViewChangeImg('prev');
        });
        baseELM.appendChild(prewButtELM);
        var nextButtELM = document.createElement('span');
        nextButtELM.setAttribute('class', 'span_arrow_next');
        nextButtELM.addEventListener('click', function (e) {
          _this2.largeViewChangeImg('next');
        });
        baseELM.appendChild(nextButtELM);
      } //mouseWheel


      if (this.sett['largePrev']['mouseWheel'] == 1 && this.largeImgList.length > 1) {
        baseELM.addEventListener('wheel', function (e) {
          var direction = Math.sign(e.deltaY);
          if (direction > 0) _this2.largeViewChangeImg('next');else _this2.largeViewChangeImg('prev');
          e.preventDefault();
        });
      } //swipe


      if (this.sett['largePrev']['swipe'] == 1 && this.largeImgList.length > 1) {
        var swiper = new Swipe(baseELM);
        swiper.onLeft(function (e) {
          _this2.largeViewChangeImg('next');
        });
        swiper.onRight(function (e) {
          _this2.largeViewChangeImg('prev');
        });
        swiper.run();
      }

      document.body.insertBefore(baseELM, document.body.firstChild);

      if (this.sett['largePrev']['bodyOverflow'] && this.sett['largePrev']['bodyOverflow'] == 1) {
        document.body.style.overflow = 'hidden';

        this.bodyHandlerResize = function (e) {
          document.body.style.overflow = 'hidden';
          console.log('handler');
        };

        window.addEventListener('resize', this.bodyHandlerResize);
        window.addEventListener('orientationchange', this.bodyHandlerResize);
      }

      this.keyHandler = function (e) {
        _this2.checkKey(e);
      };

      document.addEventListener('keyup', this.keyHandler);
    } //------------------------------------------------------------------

    /**
     largeViewClose
     Skryje velký náhled
     @e		(event)
     --------------------------------------------------------------------
     */

  }, {
    key: "largeViewClose",
    value: function largeViewClose() {
      if (this.largeImgCont.parentNode) this.largeImgCont.parentNode.removeChild(this.largeImgCont);
      document.removeEventListener('keyup', this.keyHandler);
      window.removeEventListener('resize', this.bodyHandlerResize);
      window.removeEventListener('orientationchange', this.bodyHandlerResize);

      if (this.sett['largePrev']['bodyOverflowBack']) {
        if (this.sett['largePrev']['bodyOverflowBack'] == 'x') document.body.style.overflowX = 'auto';else if (this.sett['largePrev']['bodyOverflowBack'] == 'y') document.body.style.overflowY = 'auto';else if (this.sett['largePrev']['bodyOverflowBack'] == 'none') document.body.style.overflowY = 'auto';
      } else document.body.style.removeProperty('overflow');
    } //------------------------------------------------------------------

    /**
     largeViewChangeImg
     Zobrazí obrázek
     @changeType	(string) - prev|next
     --------------------------------------------------------------------
     */

  }, {
    key: "largeViewChangeImg",
    value: function largeViewChangeImg(changeType) {
      switch (changeType) {
        case 'prev':
          this.largeImgNumCurr--;
          if (this.largeImgNumCurr < 0) this.largeImgNumCurr = this.largeImgList.length - 1;
          break;

        case 'next':
          this.largeImgNumCurr++;
          if (this.largeImgNumCurr >= this.largeImgList.length) this.largeImgNumCurr = 0;
          break;
      }

      this.largeImg.src = this.largeImgList[this.largeImgNumCurr]; //počítadlo

      if (this.largeImgCounter) this.largeImgCounter.innerHTML = this.largeImgNumCurr + 1 + ' / ' + this.largeImgList.length; //poznámka

      if (this.largeImgNote) {
        if (this.largeImgListTitle[this.largeImgNumCurr] && this.largeImgListTitle[this.largeImgNumCurr] != '') this.largeImgNote.innerHTML = '<p>' + this.largeImgListTitle[this.largeImgNumCurr] + '</p>';else this.largeImgNote.innerHTML = '';
      }
    } //------------------------------------------------------------------

    /**
     checkKey
     Ověří stisknutí tlačítka a provede nastavenou operaci
     @e		(event)
     --------------------------------------------------------------------
     */

  }, {
    key: "checkKey",
    value: function checkKey(e) {
      if (e.key == 'Escape') this.largeViewClose(e);
      if (e.key == 'ArrowLeft') this.largeViewChangeImg('prev');
      if (e.key == 'ArrowRight') this.largeViewChangeImg('next');
    } //------------------------------------------------------------------

    /**
     imageExist
     Otestuje jestli obrázek existuje
     @url	(string) - cesta k souboru
     --------------------------------------------------------------------
     */

  }, {
    key: "imageExist",
    value: function imageExist(url) {
      var img = new Image();
      img.src = url;
      return img.height != 0;
    } //------------------------------------------------------------------

    /**
     preloadImages
     Provede nahrání obrázků do cache
     imageArray	(Array) - seznam url obrázků
     index       (int) - číslo obrázku
     --------------------------------------------------------------------
     */

  }, {
    key: "preloadImages",
    value: function preloadImages(imageArray, index) {
      var _this3 = this;

      index = index || 0;

      if (imageArray && imageArray.length > index) {
        var img = new Image();
        img.addEventListener('load', function (e) {
          _this3.preloadImages(imageArray, index + 1);
        });
        img.src = imageArray[index];
      }
    } //------------------------------------------------------------------

  }]);

  return Slideshow;
}();