PageSourceSearch

https://ecoeleusis.org/wp-content/plugins/gallery-by-supsystic/src/GridGallery/Galleries/assets/js/frontend.js

js ecoeleusis.org collected 2026-10-02 14:19:36 UTC 117,781 bytes, 3,245 lines download raw bytes

1(function ($, undefined) {
2  window.supSocialSharePrintImage = function (img) {
3    var printFrame = document.createElement('iframe');
4    printFrame.style.display = 'none';
5    document.body.appendChild(printFrame);
6    var printDocument = printFrame.contentWindow.document;
7    printDocument.write('<img style="max-width:100%;" src="' + img + '">');
8    printDocument.close();
9    printFrame.contentWindow.print();
10  };
11
12  jQuery('[data-video-source]').attr('rel', 'video');
13
14  var init = false;
15
16  function Gallery(selector, autoInit) {
17    autoInit = autoInit || false;
18    var $deferred = jQuery.Deferred(),
19      self = this;
20    this.loadedFonts = [];
21
22    this.$container = $(selector);
23    if (window.sggIsMobile) {
24      this.$container.attr('data-is-mobile', window.sggIsMobile[0]);
25    }
26    this.$container.addClass('fitvidsignore');
27    this.$elements = this.$container.find('figure.grid-gallery-caption').fadeIn();
28    this.initialMargin = this.$elements.first().css('margin-bottom');
29    this.$navigation = this.$container.find('nav.grid-gallery-nav');
30
31    this.selectedCategory = '';
32
33    this.galleryContainerId = this.$container.attr('id').replace(/[^a-z0-9]/g, '');
34
35    this.$qsData = null;
36    this.$qsDuration = '750';
37    this.$qsEnable = false;
38    this.areaPosition = this.$container.data('area-position'); // I think we wil need this in future
39
40    this.pagination = {
41      currentPage: 1,
42      limit: 0,
43      total: this.$elements.length,
44      pages: 1,
45      $wrapper: this.$container.find('.grid-gallery-pagination-wrap'),
46    };
47
48    this.loadingText = this.$container.data('show-more-loading-text');
49
50    this.popupTranslates = this.$container.data('popup-i18n-words');
51    if (this.$container.data('exif-as-popup') == 1) {
52      this.popupTitleAttribute = 'data-exif-text';
53    } else {
54      this.popupTitleAttribute = this.$container.data('popup-image-text');
55    }
56    this.popupMaxHeight = '90%';
57    this.popupMaxWidth = '90%';
58    this.popup_opened_image = false;
59    this.popupImageDimension = function () {};
60    this.resizeColorbox = function () {};
61
62    this.socialSharing = this.$container.data('social-sharing');
63    this.socialSharingWrapperClass = 'supsystic-grid-gallery-image-sharing';
64    this.socialSharingImageOperators = {
65      pinterest: 'media',
66    };
67    this.socialButtonsUrl = window.location.href.replace(window.location.hash, '');
68    this.socialButtonsUrl = this.removePopUpHashFromUrl(this.socialButtonsUrl);
69    if (this.socialButtonsUrl.indexOf('#') + 1 == this.socialButtonsUrl.length) {
70      this.socialButtonsUrl = this.socialButtonsUrl.substr(0, this.socialButtonsUrl.length - 1);
71    }
72
73    this.disablePopupHistory = !!this.$container.data('popup-disable-history');
74
75    if (this.isFluidHeight()) {
76      this.$elements.addClass('wookmarked');
77    }
78
79    $(document).trigger('GalleryExtend', this);
80
81    if (autoInit) {
82      // Interval check for init gallery when container becomes visible.
83      // This need to properly load gallery from tabs, accordions or any other hidden containers.
84      self.$container.data(
85        'isVisible',
86        setInterval(function () {
87          if (self.$container.is(':visible') || self.$container.hasClass('hidden-item')) {
88            clearInterval(self.$container.data('isVisible'));
89            self.init();
90          }
91        }, 500)
92      );
93    }
94
95    //Add init flag
96    this.$container.addClass('initialized');
97    return $deferred.resolve();
98  }
99
100  Gallery.prototype.isFluidHeight = function () {
101    return this.$container.is('.grid-gallery-fluid-height');
102  };
103
104  Gallery.prototype.isImageOverlay = function () {
105    return this.$container.find('.crop').is('.image-overlay');
106  };
107
108  Gallery.prototype.isMouseShadowShow = function () {
109    return this.$container.find('.grid-gallery-caption').is('.shadow-show');
110  };
111
112  Gallery.prototype.initQuicksand = function () {
113    if (this.$container.data('quicksand') == 'enabled' && this.$container.data('caption-builder-icons') !== 1) {
114      this.$qsEnable = true;
115      this.$qsDuration = this.$container.data('quicksand-duration');
116      this.$qsHolder = this.$container.find('.grid-gallery-photos:first');
117      this.$qsData = this.$container.find('.grid-gallery-photos > a');
118    }
119  };
120
121  Gallery.prototype.showCaption = function () {
122    var isExifCaption = this.$container.data('exif-as-caption');
123    this.$container.find('.grid-gallery-figcaption-wrap').each(function () {
124      if ($.trim($(this).html()) === '' && !$(this).find('img').length && $(this).has('.hi-icon').length === 0) {
125        $(this).closest('figcaption').remove();
126      }
127    });
128
129    this.$container.find('.gg-image-caption').each(function () {
130      var $this = $(this),
131        captionHtmlEntry = '';
132      if (isExifCaption == 1) {
133        var $objExist = $this.find('object');
134        if ($objExist.length) {
135          captionHtmlEntry = $this
136            .find('object')
137            .html()
138            .replace(/<a(.*?)>(.*?)<\/a>/gi, "<object type='none'>$&</object>");
139        } else {
140          captionHtmlEntry = $this.html();
141        }
142      } else {
143        captionHtmlEntry = $this.text().replace(/<a(.*?)>(.*?)<\/a>/gi, "<object type='none'>$&</object>");
144      }
145      $this.html(captionHtmlEntry);
146      $this.find('a').on('click', function (event) {
147        event.stopPropagation();
148      });
149    });
150
151    $(document).on('click', '.sliphover-container object a', function (event) {
152      event.stopPropagation();
153    });
154  };
155
156  Gallery.prototype.initWookmark = function () {
157    var self = this,
158      horizontalScroll = this.$container.data('horizontal-scroll'),
159      isMobile = parseInt($anyGallery.attr('data-is-mobile')),
160      width = this.$container.data('width'),
161      offset = 0,
162      outerOffset = 0,
163      spacing,
164      windowWidth = $(window).width(),
165      isFixedColumn = this.$container.data('gridType') == 3;
166    // if responsive mode = 'one by one' and mobile -> run this method
167    if (horizontalScroll && horizontalScroll.enabled) {
168      if (horizontalScroll.responsiveMode == 1 && isMobile) {
169      } else {
170        return;
171      }
172    }
173    // not for Mosaic Gallery
174    if (this.$container.data('gridType') == 4) {
175      return;
176    }
177
178    if (this.$container.data('offset')) {
179      offset = this.$container.data('offset');
180    }
181
182    if (this.$container.data('padding')) {
183      outerOffset = parseInt(this.$container.data('padding'));
184    }
185
186    if (String(width).indexOf('%') > -1) {
187      var imagesPerRow = Math.floor(100 / parseInt(width));
188
189      spacing = offset * (imagesPerRow - 1) + outerOffset * 2;
190      width = ((this.$container.width() - spacing) / 100) * parseInt(width);
191
192      $.each(this.$container.find('img'), function () {
193        aspectRatio = $(this).width() / $(this).height();
194        $(this).width(width);
195        $(this).height(width / aspectRatio);
196      });
197    }
198
199    if (isFixedColumn) {
200      var defaultWidth = parseInt(width),
201        defaultHeight = parseInt(this.$container.data('height')),
202        koefWidthHeigth = defaultWidth > 0 && defaultHeight > 0 ? defaultHeight / defaultWidth : 1;
203    }
204
205    function resizeColumns() {
206      var columnsNumber = self.getResponsiveColumnsNumber();
207
208      spacing = offset * (columnsNumber - 1) + outerOffset * 2;
209      width = Math.floor(((self.$container.width() - spacing) / 100) * (100 / columnsNumber));
210
211      $.each(self.$elements, function (index, el) {
212        var $el = $(el),
213          $img = $el.find('img');
214        if ($img.length && !$el.hasClass('initialized')) {
215          var imageOriginalSize = self.getOriginalImageSizes($img.get(0)),
216            elWidth = imageOriginalSize.width,
217            elHeight = imageOriginalSize.height,
218            aspectRatio = elWidth > 0 && elHeight > 0 ? elWidth / elHeight : 1,
219            height = width / aspectRatio;
220
221          if (isFixedColumn && $img.attr('data-gg-remote-image') == 1) {
222            height = width * koefWidthHeigth;
223          }
224
225          $el.css({
226            width: width,
227            height: height,
228          });
229          if (!$img.hasClass('ggLazyImg')) {
230            $img.removeClass('ggNotInitImg');
231            self.polaroidCaptionCalculate($el);
232            if ($el.hasClass('initialized')) {
233              setTimeout(function () {
234                $el.trigger('refreshWookmark');
235              }, 350);
236            }
237          }
238        }
239      });
240      self.$container.find('.grid-gallery-photos').removeAttr('data-min-height');
241      return width;
242    }
243
244    if (this.$container.data('columns-number')) {
245      self.$container.find('figure:not(.initialized) img').css({
246        maxWidth: '100%',
247        width: '100%',
248        height: 'auto',
249      });
250
251      resizeColumns();
252    }
253
254    if (this.$container.data('width') !== 'auto' && !this.$qsEnable) {
255      this.wookmark = this.$elements
256        .filter(':visible')
257        .wookmark({
258          autoResize: true,
259          container: this.$container.find('.grid-gallery-photos'),
260          direction: this.areaPosition == 'right' ? 'right' : 'left',
261          fillEmptySpace: false,
262          flexibleWidth: !this.$container.data('columns-number'),
263          itemWidth: width,
264          offset: offset,
265          align: this.areaPosition,
266          outerOffset: outerOffset,
267          onLayoutChanged: function () {
268            setTimeout(function () {
269              self.$container.trigger('wookmark.changed');
270            }, 50);
271          },
272          onResize: function () {
273            if ($(window).width() != windowWidth) {
274              // Fix touchscreen resize event issue see #544
275              windowWidth = $(window).width();
276
277              clearTimeout(self.$container.data('resize.timer'));
278              self.$container.data(
279                'resize.timer',
280                setTimeout(function () {
281                  var overflow = self.$container.css('overflow');
282
283                  self.$container.removeData('resize.timer');
284                  self.$container.css('overflow', 'hidden');
285
286                  if (self.$container.data('columns-number')) {
287                    self.$elements.wookmark({
288                      container: self.$container.find('.grid-gallery-photos'),
289                      itemWidth: resizeColumns(),
290                      offset: offset,
291                    });
292                  }
293
294                  self.$elements.last().one('transitionend webkitTransitionEnd oTransitionEnd', function () {
295                    self.$elements.filter(':visible').trigger('refreshWookmark');
296                  });
297                  self.$elements.filter(':visible').trigger('refreshWookmark');
298                  self.$container.css('overflow', overflow);
299                }, 250)
300              );
301            }
302          },
303        })
304        .css({
305          margin: '0',
306          transition: 'all 0.4s linear',
307        });
308    }
309
310    this.$container.find('.grid-gallery-photos').css('text-align', this.$container.data('area-position'));
311    var minheight = this.$container.find('.grid-gallery-photos').data('min-height');
312    this.$container.find('.grid-gallery-photos').css({
313      'min-height': minheight,
314    });
315    this.$container.filter(':visible').find('.grid-gallery-photos > *').filter(':visible').css({
316      float: 'none',
317      display: 'inline-block',
318      'vertical-align': 'top',
319    });
320  };
321
322  Gallery.prototype.initControll = function () {
323    $(document).on('click', '#cboxRight', function () {
324      $.colorbox.prev();
325    });
326    $(document).on('click', '#cboxLeft', function () {
327      $.colorbox.next();
328    });
329  };
330
331  Gallery.prototype.getPopupDimensions = function (width, height) {
332    var width = $(window).width() < width ? '90%' : width;
333    var height = $(window).height() < height ? '90%' : height;
334
335    if (width == '90%') {
336      width = parseFloat(($(window).width() * parseFloat(width)) / 100);
337    }
338    if (height == '90%') {
339      height = parseFloat(($(window).height() * parseFloat(height)) / 100);
340    }
341
342    return {
343      width: width,
344      height: height,
345    };
346  };
347
348  /**
349   * Get popup title depending on gallery settings
350   * @return string title for popup image
351   */
352  Gallery.prototype.getPopupTitle = function ($element) {
353    var title, $img;
354
355    if ($element.hasClass('hi-icon')) {
356      $img = $element.closest('.grid-gallery-caption').find('img');
357    } else {
358      $img = $element.find('img');
359    }
360
361    title = $img.attr(this.popupTitleAttribute);
362
363    if (!title) {
364      title = $img.attr('title');
365    }
366
367    return title;
368  };
369
370  Gallery.prototype.initPopup = function () {
371    var popupType = (this.popupType = this.$container.data('popup-type')),
372      popupMaxWidth = this.popupMaxWidth,
373      popupMaxHeight = this.popupMaxHeight,
374      sW = this.$container.data('popup-widthsize'),
375      sH = this.$container.data('popup-heightsize'),
376      popupOverlayTransper = this.$container.data('popup-transparency'),
377      popupBackground = this.$container.data('popup-background'),
378      slidePlay = this.$container.data('popup-slideshow') === true,
379      slidePlayAuto = slidePlay && this.$container.data('popup-slideshow-auto') === true,
380      popupHoverStop = slidePlay && this.$container.data('popup-hoverstop') === true,
381      slideshowSpeed = this.$container.data('popup-slideshow-speed'),
382      popupPlacementType = this.$container.data('popup-placement-type'),
383      isLazyLoad = this.$container.data('lazyload-enable') == '1',
384      self = this;
385
386    function generateOverlayColor(selector, background, opacity, optype) {
387      var style = selector + '{',
388        rgb = self.hex2rgb(background);
389      opacity = (100 - opacity) / 100;
390
391      if (background) {
392        color = 'rgba(' + rgb.r + ',' + rgb.g + ',' + rgb.b + ', ' + opacity + ')';
393        style += 'background-image:none!important; background-color:' + color + '!important;';
394      } else {
395        if (optype) {
396          style += 'opacity:' + opacity + '!important;';
397        } else {
398          rgb = self.hex2rgb(self.rgb2hex($(selector).css('backgroundColor')));
399          color = 'rgba(' + rgb.r + ',' + rgb.g + ',' + rgb.b + ', ' + opacity + ')';
400          style += 'background-image:none!important; background-color:' + color + '!important;';
401        }
402      }
403      style += '}';
404      $('<style type="text/css"> ' + style + '</style>').appendTo('head');
405    }
406
407    if (!!sW && sW !== 'auto') {
408      popupMaxWidth = sW;
409    } else {
410      sW = '90%';
411    }
412    if (!!sH && sH !== 'auto') {
413      popupMaxHeight = sH;
414    } else {
415      sH = '90%';
416    }
417
418    var getImageDimension = function () {
419      return self.getPopupDimensions(sW, sH);
420    };
421
422    var getColorboxImageDimension = function () {
423      var response = self.getPopupDimensions(sW, sH);
424      if ($(self.popup_opened_image).children('figure').attr('data-linked-images') || $(self.popup_opened_image).hasClass('linked-element')) {
425        response.width -= 120;
426      }
427      return response;
428    };
429
430    var delayResize = (function () {
431      var timer = 0;
432      return function (callback, ms) {
433        clearTimeout(timer);
434        timer = setTimeout(callback, ms);
435      };
436    })();
437
438    this.resizeColorbox = function () {
439      if (self.popup_opened_image === false) return;
440      var dimensions = getColorboxImageDimension();
441      if (self.popup_opened_image.attr && self.popup_opened_image.attr('rel') == 'video' && dimensions.width >= 0.9 * window.innerWidth) {
442        return;
443      }
444
445      $(self.popup_opened_image).data('colorbox').maxWidth = dimensions.width;
446      $(self.popup_opened_image).data('colorbox').maxHeight = dimensions.height;
447
448      $(document).trigger('beforeResizeColorBoxResponsive', this);
449      delayResize(function () {
450        $.colorbox.resizeResponsive(self.popup_opened_image);
451      }, 500);
452    };
453
454    //Responsive popup if width or height > window.width
455    popupMaxWidth = $(window).width() < popupMaxWidth ? '90%' : popupMaxWidth;
456    popupMaxHeight = $(window).height() < popupMaxHeight ? '90%' : popupMaxHeight;
457
458    this.popupMaxWidth = popupMaxWidth;
459    this.popupMaxHeight = popupMaxHeight;
460    this.popupImageDimension = getImageDimension;
461
462    if (popupType && popupType !== 'disable') {
463      this.$container.parentsUntil('body').each(function () {
464        var events = $._data(this, 'events'),
465          el = this;
466
467        if (events && events.click) {
468          $.each(events.click, function (index, ev) {
469            if (ev.selector && self.$container.has($(ev.selector)).length) {
470              $(el).off('click', ev.selector);
471            }
472          });
473        }
474      });
475    }
476
477    var hideLongTooltipTitles = this.$container.data('hide-long-tltp-title');
478
479    //===========|Popup gallery scripts|===========//
480    if (popupType == 'colorbox') {
481      var $this = this.$container;
482      // simple selector
483      var colorBoxItemSelector =
484        '.grid-gallery-photos > .gg-colorbox[data-ecommerce-restrict],' +
485        '.grid-gallery-photos > .gg-colorbox:visible,' +
486        // mosaic selector
487        ' .grid-gallery-photos .gg-mosaic-wrapper .gg-colorbox,' +
488        // icon selector
489        ' .hi-icon.gg-colorbox[data-ecommerce-restrict],' +
490        ' .hi-icon.gg-colorbox:visible';
491      // for popup "Display only first image"
492      if ($this.hasClass('one-photo') || $this.hasClass('hidden-item')) {
493        colorBoxItemSelector = '.grid-gallery-photos > .gg-colorbox, .hi-icon.gg-colorbox';
494      }
495
496      if (this.initColorbox) {
497        this.$container.find(colorBoxItemSelector).colorbox.remove('#' + this.$container.attr('id'));
498      } else {
499        if (hideLongTooltipTitles == 0) {
500          var $colorboxtooltip = $('<div id="sggCboxTooltip">');
501          $(document).on(
502            {
503              mouseenter: function () {
504                $colorboxtooltip.addClass('active');
505              },
506              mouseleave: function () {
507                setTimeout(function () {
508                  $colorboxtooltip.removeClass('active');
509                }, 400);
510              },
511            },
512            '#colorbox.' + $this.data('popup-theme') + ' #cboxTitle'
513          );
514
515          $(document).one('cbox_complete', function (event) {
516            if (!$('#sggCboxTooltip').length) {
517              $('#cboxWrapper').append($colorboxtooltip);
518            }
519          });
520
521          $(document).on('cbox_complete', function (event) {
522            $colorboxtooltip.html($('#cboxTitle').html());
523            if ($('#colorbox').width() < 300) {
524              $('#colorbox').filter('.theme_1').find('#cboxSlideshow').css('bottom', '30px');
525            }
526          });
527        }
528      }
529
530      this.initColorbox = true;
531      var colorBoxConfig = {
532        fadeOut: this.$container.data('popup-fadeOut'),
533        fixed: true,
534        maxHeight: getImageDimension().height,
535        maxWidth: getImageDimension().width,
536        photo: true,
537        scalePhotos: true,
538        scrolling: false,
539        returnFocus: false,
540        trapFocus: false,
541        slideshow: slidePlay && this.$container.data('popup-slideshow-speed'),
542        slideshowAuto: slidePlayAuto,
543        slideshowSpeed: slideshowSpeed,
544        rel: this.$container.attr('id'),
545        slideshowStart: self.popupTranslates.start_slideshow,
546        slideshowStop: self.popupTranslates.stop_slideshow,
547        current: self.popupTranslates.image + ' {current} ' + self.popupTranslates.of + ' {total}',
548        previous: self.popupTranslates.previous,
549        next: self.popupTranslates.next,
550        close: self.popupTranslates.close,
551        isDisableRightClick: this.$container.attr('data-disable-right-click') == 'true',
552        title: function () {
553          return self.getPopupTitle($(this));
554        },
555        speed: 350,
556        transition: 'elastic',
557        onComplete: function (e) {
558          self.changePopUpHash($(e.el).attr('id') || $(e.el).attr('data-id'));
559          self.addSocialShareToPopUp($(e.el), $('#cboxContent'), 'popup');
560          self.$container.find('.grid-gallery-photos > .gg-colorbox, .hi-icon.gg-colorbox').colorbox.resize();
561          $('#cboxLoadedContent').append("<div id='cboxRight'></div><div id='cboxLeft'></div>");
562          window.setTimeout(function () {
563            if (window.colorboxEcommerceRestrict) {
564              window.colorboxEcommerceRestrict($(e.el));
565            }
566          }, 0);
567        },
568        onLoad: function (e) {
569          if (self.popup_opened_image == e.el) return;
570          self.popup_opened_image = e.el;
571          var dimensions = getColorboxImageDimension();
572          $(self.popup_opened_image).data('colorbox').maxWidth = dimensions.width;
573          $(self.popup_opened_image).data('colorbox').maxHeight = dimensions.height;
574        },
575        onOpen: function (e) {
576          //Enable/Disable stop slideshow on mouse hover
577          if (popupHoverStop) {
578            var timeoutId = 0;
579            $('#cboxContent').hover(
580              function () {
581                clearTimeout(timeoutId);
582                $('.cboxSlideshow_on #cboxSlideshow').click();
583              },
584              function () {
585                if (slidePlayAuto) {
586                  clearTimeout(timeoutId);
587                  timeoutId = setTimeout(function () {
588                    $('.cboxSlideshow_off #cboxSlideshow').click();
589                  }, slideshowSpeed);
590                }
591              }
592            );
593          }
594        },
595        onClosed: function () {
596          self.popup_opened_image = false;
597          $('#colorbox').removeClass('gg-cbox-ecommerce-open');
598          $('#cboxEcommerceRestrict').remove();
599          $('#ggEcommerceAccessOverlay').hide();
600          $(window).off('resize.ggEcommerceColorboxPanel');
601          self.clearPopUpHash();
602        },
603      };
604
605      if (popupPlacementType == 1 || popupPlacementType == 2) {
606        colorBoxConfig['maxWidth'] = '100%';
607        colorBoxConfig['imgPlaceType'] = popupPlacementType;
608      }
609      this.$container.find(colorBoxItemSelector).off('click').colorbox(colorBoxConfig);
610
611      $(window).resize(function () {
612        self.resizeColorbox();
613      });
614
615      $('#cboxOverlay')
616        .removeClass()
617        .addClass($this.data('popup-theme') + '-overlay');
618      $('#colorbox').removeClass().addClass($this.data('popup-theme'));
619
620      generateOverlayColor('#cboxOverlay', popupBackground, popupOverlayTransper, true);
621    }
622
623    if (popupType == 'pretty-photo') {
624      // simple selector
625      var prettyPhotoTheme = this.$container.data('popup-theme'),
626        isPrettyPhotoTheme6 = prettyPhotoTheme == 'theme_6',
627        prettyPhotoThemeClass = isPrettyPhotoTheme6 ? 'light_square sgg-theme-6' : 'light_square',
628        prettyPhotoItemSelector =
629        '.grid-gallery-photos > a[data-rel^="prettyPhoto"][data-ecommerce-restrict],' +
630        '.grid-gallery-photos > a[data-rel^="prettyPhoto"]:visible,' +
631        ' .grid-gallery-photos .gg-mosaic-wrapper a[data-rel^="prettyPhoto"],' + // mosaic selector
632        ' .grid-gallery-photos .hi-icon-wrap > a[data-rel^="prettyPhoto"][data-ecommerce-restrict],' +
633        ' .grid-gallery-photos .hi-icon-wrap > a[data-rel^="prettyPhoto"]:visible'; // icon selector
634      if (isPrettyPhotoTheme6) {
635        prettyPhotoItemSelector =
636          '.grid-gallery-photos > a[data-rel^="prettyPhoto"],' +
637          ' .grid-gallery-photos .gg-mosaic-wrapper a[data-rel^="prettyPhoto"],' +
638          ' .grid-gallery-photos .hi-icon-wrap > a[data-rel^="prettyPhoto"]';
639      }
640      // for popup "Display only first image"
641      if (this.$container.hasClass('one-photo') || this.$container.hasClass('hidden-item')) {
642        prettyPhotoItemSelector =
643          '.grid-gallery-photos > a[data-rel^="prettyPhoto"],' +
644          ' .grid-gallery-photos .gg-mosaic-wrapper a[data-rel^="prettyPhoto"],' + // mosaic selector
645          ' .grid-gallery-photos .hi-icon-wrap > a[data-rel^="prettyPhoto"]'; // icon selector
646      }
647
648      if (!this.$prettyPhoto) {
649        if (hideLongTooltipTitles == 0) {
650          var $prettyPhotoTooltip = $('<div id="sggPrettyPhototooltip">');
651          $(document).on(
652            {
653              mouseenter: function () {
654                $prettyPhotoTooltip.addClass('active');
655              },
656              mouseleave: function () {
657                setTimeout(function () {
658                  $prettyPhotoTooltip.removeClass('active');
659                }, 400);
660              },
661            },
662            '.pp_content_container .pp_description'
663          );
664        }
665
666        if (this.$container.attr('data-show-buttonlink-in-popup') == 1 && window.prettyPhotoDetailLink) {
667          this.loadButtonsFontFamily(this.$container.attr('data-buttonlink-font'), null);
668        }
669
670        this.$prettyPhoto = this.$container
671          .find(prettyPhotoItemSelector)
672          .off('click')
673          .ggPrettyPhoto({
674            hook: 'data-rel',
675            theme: prettyPhotoThemeClass,
676            allow_resize: true,
677            allow_expand: true,
678            deeplinking: false,
679            slideshow: slidePlay && this.$container.data('popup-slideshow-speed'),
680            autoplay_slideshow: slidePlayAuto,
681            social_tools: '',
682            default_width: popupMaxWidth,
683            default_height: popupMaxHeight,
684            getImageDimensions: getImageDimension,
685            is_lazy_load: isLazyLoad,
686            ppTranslates: self.popupTranslates,
687            isDisableRightClick: this.$container.attr('data-disable-right-click') == 'true',
688            isShowRotateBtn: this.$container.attr('data-show-rotate-btn-in-popup') == 1,
689            isShowAttributes: this.$container.attr('data-show-attributes-in-popup') == 1,
690            isShowEcommerceRestrict: true,
691            attributesPosition: this.$container.attr('data-attributes-position'),
692            attributesWidth: this.$container.attr('data-attributes-width') || 200,
693            isShowButtonLink: this.$container.attr('data-show-buttonlink-in-popup') == 1,
694            buttonLinkStyle: this.$container.attr('data-buttonlink-style'),
695            isShowLinkBtn: this.$container.attr('data-show-link-btn-in-popup') == 1,
696            isShowHovThumbnail: this.$container.attr('data-show-thumb-hov-in-popup') == 1,
697            galleryId: this.$container.attr('data-gg-id'),
698            getTitle: function () {},
699            setImageTitleForPrepare: function ($element) {
700              var imgTile = self.getPopupTitle($element);
701              return imgTile;
702            },
703            popup_border_type: this.$container.attr('data-popup-border-type'),
704            popup_border_color: this.$container.attr('data-popup-border-color'),
705            popup_border_width: this.$container.attr('data-popup-border-width'),
706            popup_border_enable: this.$container.attr('data-popup-border-enable') == 'on',
707            changepicturecallback: function (element) {
708              self.changePopUpHash(element.attr('id') || element.attr('data-id'));
709              self.popup_opened_image = element;
710              $('.pp_description').html(self.getPopupTitle(element)).show();
711              //add social share buttons if enabled
712              self.addSocialShareToPopUp(element, $('.pp_hoverContainer'), 'popup');
713              if (!slidePlay) {
714                $('.pp_play').hide();
715              }
716              // change detail link url
717              if (self.$container.attr('data-show-link-btn-in-popup') == 1 && window.prettyPhotoDetailLink) {
718                window.prettyPhotoDetailLink(element);
719              }
720              if (self.$container.attr('data-show-attributes-in-popup') == 1 && window.prettyPhotoAttributes) {
721                window.prettyPhotoAttributes(element, self.$container);
722              }
723              if (window.prettyPhotoEcommerceRestrict) {
724                window.prettyPhotoEcommerceRestrict(element);
725              }
726
727              //Enable/Disable stop slideshow on mouse hover
728              if (popupHoverStop) {
729                $('.pp_hoverContainer').hover(
730                  function () {
731                    $('.pp_nav .pp_pause').click();
732                  },
733                  function () {
734                    if (slidePlayAuto) {
735                      $('.pp_nav .pp_play').click();
736                    }
737                  }
738                );
739              }
740              var $_desc = $('.pp_description'),
741                desc_height = parseInt($_desc.height()),
742                desc_line_height = parseInt($_desc.css('font-size'));
743              if (desc_line_height < desc_height) {
744                $('.pp_content').height($('.pp_fade').outerHeight(true) + $('.pp_details').outerHeight(true));
745              }
746
747              if (hideLongTooltipTitles == 0) {
748                if (!$('#sggPrettyPhototooltip').length) {
749                  $('.pp_content_container .pp_content').append($prettyPhotoTooltip);
750                }
751                $prettyPhotoTooltip.html($('.pp_content_container .pp_description').html());
752              }
753            },
754            callback: function () {
755              self.popup_opened_image = false;
756              self.clearPopUpHash();
757            },
758          });
759        $(window).resize(function () {
760          if (!self.popup_opened_image || !self.$prettyPhoto) return;
761          //if(self.$prettyPhoto[0].closest('div') != self.popup_opened_image[0].closest('div')) return;
762          self.$prettyPhoto.open(self.popup_opened_image);
763        });
764      } else {
765        this.$prettyPhoto.refresh(this.$container.find(prettyPhotoItemSelector));
766      }
767
768      generateOverlayColor('.pp_overlay', popupBackground, popupOverlayTransper, true);
769    }
770
771    if (popupType == 'photobox') {
772      var photoBoxItemSelector = 'a.pbox:visible',
773        photoBoxConfig = null;
774      // for popup "Display only first image"
775      if (this.$container.hasClass('one-photo') || this.$container.hasClass('hidden-item') || this.$container.data('gridType') == '4') {
776        photoBoxItemSelector = 'a.pbox';
777      }
778
779      if (this.initPhotobox) {
780        this.$container.find('.grid-gallery-photos').photobox('destroy');
781      }
782      this.initPhotobox = true;
783      photoBoxConfig = {
784        autoplay: slidePlayAuto,
785        isDisableRightClick: this.$container.attr('data-disable-right-click') == 'true',
786        thumb: function (link) {
787          if (self.$container.data('caption-buider') == '1' && self.$container.data('caption-builder-icons') == 1) {
788            return link.closest('.grid-gallery-caption').find('img')[0];
789          } else if (self.$container.data('icons')) {
790            return link.closest('.grid-gallery-caption').find('img')[0];
791          }
792          return null;
793        },
794        getTitle: function (el) {
795          var nameTitle = self.getPopupTitle($(el));
796          return nameTitle;
797        },
798        beforeShow: function (element) {
799          self.changePopUpHash($(element).attr('id') || $(element).attr('data-id'));
800          self.addSocialShareToPopUp($(element), $('#pbCaption'), 'photobox', true);
801        },
802        afterClose: function () {
803          self.clearPopUpHash();
804        },
805      };
806      if (isLazyLoad) {
807        photoBoxConfig['thumbAttr'] = 'data-gg-real-image-href';
808      }
809
810      this.$container.find('.grid-gallery-photos').off('click').photobox(photoBoxItemSelector, photoBoxConfig);
811
812      //Hide autoplay button when slideshow = false
813      if (!this.$container.data('popup-slideshow')) {
814        $('#pbAutoplayBtn').hide();
815      }
816
817      //Enable/Disable stop slideshow on mouse hover
818      if (popupHoverStop) {
819        $('.pbWrapper img').hover(
820          function () {
821            $('#pbOverlay .playing').click();
822          },
823          function () {
824            if (slidePlayAuto) {
825              $('#pbOverlay .play').click();
826            }
827          }
828        );
829      }
830
831      generateOverlayColor('#pbOverlay', popupBackground, popupOverlayTransper);
832    }
833    //===========|Popup gallery scripts|===========//
834  };
835
836  Gallery.prototype.preventImages = function () {
837    var popupType = this.$container.data('popup-type');
838
839    if (popupType == 'disable') {
840      this.$container.find('a.gg-link').off('click');
841      this.$container.find('a.gg-link:not([data-type=link])').addClass('disabled');
842      this.$container.on('click', 'a.gg-link', function (event) {
843        if ($(this).data('type') !== 'link') {
844          event.preventDefault();
845          event.stopPropagation();
846        }
847      });
848    }
849  };
850
851  Gallery.prototype.getResponsiveColumnsNumber = function () {
852    var columnsData = this.$container.data('responsive-colums'),
853      settings = [],
854      columnsNumber = parseInt(this.$container.data('columns-number'));
855
856    for (var key in columnsData) {
857      settings.push(columnsData[key]);
858    }
859
860    settings.sort(function (a, b) {
861      a.width = Number(a.width);
862      b.width = Number(b.width);
863      if (a.width > b.width) {
864        return 1;
865      } else if (a.width < b.width) {
866        return -1;
867      } else {
868        return 0;
869      }
870    });
871
872    for (var i = 0, len = settings.length, windowWidth = $(window).width(), minBreakpoint = 0; i < len; i++) {
873      if (windowWidth > minBreakpoint && windowWidth <= settings[i].width) {
874        columnsNumber = Number(settings[i].columns);
875        break;
876      }
877      minBreakpoint = settings[i].width;
878    }
879
880    return columnsNumber;
881  };
882
883  Gallery.prototype.initRowsMode = function () {
884    var columnsNumber = parseInt(this.$container.data('columns-number'));
885
886    if (this.$container.data('horizontal-scroll')) {
887      return;
888    }
889
890    if (typeof this.$container.data('responsive-colums') == 'object') {
891      columnsNumber = this.getResponsiveColumnsNumber();
892    }
893
894    if (columnsNumber) {
895      var containerWidth = parseInt(this.$container.width()),
896        spacing = parseInt(this.$container.data('offset')),
897        scaleHeight = parseInt(this.$container.data('width')) / parseInt(this.$container.data('height')),
898        elementWidth = null,
899        elementHeight = null;
900
901      elementWidth = Math.floor((this.$container.width() - (columnsNumber - 1) * spacing) / columnsNumber);
902      elementHeight = Math.floor(elementWidth / scaleHeight);
903
904      this.$elements.each(function () {
905        var $this = $(this);
906        if (!$this.find('.post-feed-crop').length) {
907          $this.css('width', elementWidth);
908          if (!isNaN(elementHeight)) {
909            $this.css('height', elementHeight);
910          } else {
911            $this.css('height', 'auto');
912          }
913        } else {
914          $this.find('figcaption').css('width', elementWidth);
915        }
916      });
917
918      this.$elements.find('.crop').css({
919        width: 'auto',
920        height: 'auto',
921      });
922    }
923  };
924
925  Gallery.prototype.setImagesHeight = function () {
926    var $images = this.$container.find('img');
927
928    if ($images != undefined && $images.length > 0) {
929      $images.each(function () {
930        var $image = $(this),
931          $wrapper = $image.parent();
932
933        if ($image.height() < $wrapper.height()) {
934          $wrapper.css('height', $image.height());
935        }
936      });
937    }
938  };
939
940  Gallery.prototype.setOverlayTransparency = function () {
941    this.$elements.find('figcaption, [class*="caption-with-icons"]').each(function () {
942      var $caption = $(this),
943        alpha = (10 - parseInt($caption.data('alpha'), 10)) / 10,
944        rgb = $caption.css('background-color'),
945        rgba = rgb.replace(')', ', ' + alpha + ')').replace('rgb', 'rgba');
946
947      $caption.css('background', rgba);
948    });
949  };
950
951  Gallery.prototype.setIconsPosition = function () {
952    var self = this;
953    this.$elements.each(function () {
954      var $element = $(this),
955        isCaptionBuilderUsed = self.$container.data('caption-buider'),
956        // polaroid centers its icon wrap with flexbox now (see the
957        // [data-grid-gallery-type='polaroid'] .hi-icon-wrap rules in
958        // grid-gallery.galleries.effects.css) instead of this manual
959        // per-icon margin math - applying both would push icons off-center.
960        isPolaroid = $element.data('grid-gallery-type') == 'polaroid',
961        $wrapper = $element.find('div.hi-icon-wrap'),
962        $icons = $element.find('a.hi-icon'),
963        marginX = $wrapper.data('margin'),
964        iconCount = $icons.length;
965
966      if (!iconCount) {
967        return;
968      }
969
970      // Measured once, before any icon gets a margin - a photo can show more
971      // than one icon at a time (e.g. an external link icon alongside the
972      // popup icon), and for polaroid specifically figcaption is in normal
973      // flow (position: relative, not absolute), so its own height feeds
974      // straight into the card's height:auto. Re-reading $element.height()
975      // inside the loop below (as this used to) means each icon "centers"
976      // itself against a parent the PREVIOUS icon's own margin just made
977      // taller, snowballing into runaway growth with 2+ icons - which is
978      // what was making some cards (and everything positioned after them,
979      // via the masonry packing) taller than their siblings.
980      //
981      // The icon wrap lives inside <figcaption>, so it should center against
982      // figcaption's OWN height, not $element's. For every type but polaroid
983      // figcaption is an absolutely-positioned overlay the size of the photo,
984      // so this is normally the same number as $element.height() - no change
985      // there. For polaroid, figcaption is a separate, much shorter strip
986      // below the photo (normal flow, not an overlay), so using the whole
987      // card's height instead (as this used to) way overshoots the strip's
988      // actual height and pushes icons toward its bottom edge/off it entirely.
989      // A figure sits display:none until Wookmark (or, for a paginated
990      // gallery, page navigation) reveals it - $figcaption.height() and
991      // $icons.first().height() both read 0 for a hidden subtree, which
992      // baked a wrong, height-independent margin-top into every icon on
993      // every not-yet-shown page as soon as this ran once at gallery init.
994      // That inline value then never got recomputed once the page was
995      // actually navigated to, permanently overriding the CSS 33.33% rule
996      // with the wrong number. Skipping margin-top here for a still-hidden
997      // figure leaves that CSS rule in charge - it centers correctly on its
998      // own once the figure is visible - for exactly the single-icon case
999      // this was silently breaking; showCurrentPage() also now re-runs this
1000      // function after revealing a new page, which additionally restores
1001      // the multi-icon stacking math this skip leaves out in the meantime.
1002      var $figcaption = $element.find('figcaption'),
1003        isHidden = $element.is(':hidden'),
1004        elementHeight = $figcaption.length ? $figcaption.height() : $element.height(),
1005        iconHeight = $icons.first().height(),
1006        groupHeight = iconCount * iconHeight,
1007        startMarginTop = Math.abs(elementHeight / 2 - groupHeight / 2 - 10);
1008
1009      $icons.each(function (index) {
1010        var $icon = $(this),
1011          marginData = {};
1012
1013        if (marginX && !isCaptionBuilderUsed && !isPolaroid) {
1014          marginData['margin-left'] = marginX;
1015          marginData['margin-right'] = marginX;
1016        }
1017        if (elementHeight && !isCaptionBuilderUsed && !isPolaroid && !isHidden) {
1018          marginData['margin-top'] = startMarginTop + index * iconHeight;
1019        }
1020        $icon.css(marginData);
1021      });
1022    });
1023  };
1024
1025  Gallery.prototype.initCategories = function () {
1026    var $defaultElement = this.$navigation.find('a[data-tag="__all__"]'),
1027      $elements = this.$navigation.find('a'),
1028      $defaultBackground = $elements.first().css('background-color');
1029
1030    function shadeColor(color, percent) {
1031      var f = parseInt(color.slice(1), 16),
1032        t = percent < 0 ? 0 : 255,
1033        p = percent < 0 ? percent * -1 : percent,
1034        R = f >> 16,
1035        G = (f >> 8) & 0x00ff,
1036        B = f & 0x0000ff;
1037      return '#' + (0x1000000 + (Math.round((t - R) * p) + R) * 0x10000 + (Math.round((t - G) * p) + G) * 0x100 + (Math.round((t - B) * p) + B)).toString(16).slice(1);
1038    }
1039
1040    bg = shadeColor('#' + this.rgb2hex($elements.first().css('borderTopColor')), 0.3);
1041
1042    this.$navigation.find('a').on(
1043      'click',
1044      $.proxy(function (event) {
1045        event.preventDefault();
1046
1047        var $category = $(event.currentTarget),
1048          requested = String($category.data('tag')),
1049          _defaultTag = '__all__',
1050          currentGallery = this.$navigation.parent().attr('id');
1051
1052        $elements.css('background-color', $defaultBackground);
1053        $category.css('background-color', bg);
1054
1055        if (requested == _defaultTag) {
1056          this.$elements
1057            .each(function () {
1058              if ($(this).parent().attr('rel')) {
1059                $(this)
1060                  .parent()
1061                  .attr('rel', 'prettyPhoto[' + currentGallery + ']');
1062              }
1063            })
1064            .fadeIn();
1065
1066          this.correctMargin();
1067          this.initWookmark();
1068
1069          if (!this.isFluidHeight() && this.$qsEnable) {
1070            this.callQuicksand(this.$qsHolder, this.$qsData, this.$qsDuration);
1071          }
1072          return false;
1073        }
1074
1075        if (!this.isFluidHeight() && this.$qsEnable) {
1076          var $filteredData = this.$qsData.filter(function () {
1077            var tags = $(this).children().data('tags');
1078            if (typeof tags !== 'undefined') {
1079              tags = tags.split('|');
1080            }
1081            return $.inArray(requested, tags) > -1;
1082          });
1083          this.callQuicksand(this.$qsHolder, $filteredData, this.$qsDuration);
1084        } else {
1085          $hidden = $();
1086          $visible = $();
1087          this.$elements.each(function () {
1088            var $element = $(this),
1089              tags = $element.data('tags');
1090
1091            if (typeof tags != 'string') {
1092              tags = String(tags);
1093            }
1094
1095            if (tags != undefined) {
1096              tags = tags.split('|');
1097            }
1098            if ($.inArray(requested, tags) > -1) {
1099              if ($element.parent().attr('rel')) {
1100                $element.parent().attr('rel', 'prettyPhoto[' + currentGallery + '-' + requested + ']');
1101              }
1102              $visible.push(this);
1103            } else {
1104              $hidden.push(this);
1105            }
1106          });
1107
1108          $.when($hidden.fadeOut()).done(
1109            $.proxy(function () {
1110              $visible.fadeIn().css({ height: '' });
1111              this.correctMargin();
1112              this.initWookmark();
1113            }, this)
1114          );
1115        }
1116      }, this)
1117    );
1118
1119    var firstTag = $elements.first().data('tag');
1120    this.$container.find('a[data-tag="' + firstTag + '"]').trigger('click');
1121  };
1122
1123  Gallery.prototype.callQuicksand = function ($holder, $filteredData, duration) {
1124    self = this;
1125
1126    $filteredData.find('figure.grid-gallery-caption').css('margin', this.initialMargin).parent().css('clear', 'none');
1127
1128    $holder.quicksand(
1129      $filteredData,
1130      {
1131        duration: Number(duration),
1132        easing: 'swing',
1133        attribute: 'href',
1134      },
1135      function () {
1136        $holder
1137          .css({
1138            width: 'auto',
1139            height: 'auto',
1140          })
1141          .append('<div class="grid-gallery-clearfix"></div>');
1142        self.initPopup();
1143        self.correctMargin();
1144        if (self.$container.data('lazyload-enable') == '1') {
1145          // images area removed and filled new images
1146          self.initLazyLoad();
1147        }
1148      }
1149    );
1150  };
1151
1152  Gallery.prototype.hidePopupCaptions = function () {
1153    //never show alternative text for popup theme 6 on top of popup
1154    $('<style type="text/css">.ppt{ display:none!important; }</style>').appendTo('head');
1155    if (this.$container.data('popup-captions') == 'hide') {
1156      $('<style type="text/css">#cboxTitle, #cboxCurrent, .pbCaptionText, .ppt, .pp_description { display:none!important; }</style>').appendTo('head');
1157    }
1158  };
1159
1160  Gallery.prototype.hidePaginationControls = function () {
1161    return false;
1162  };
1163
1164  Gallery.prototype.setImageOverlay = function () {
1165    if (this.isImageOverlay()) {
1166      this.$container.find('.grid-gallery-caption').each(function () {
1167        var image = $(this).find('img');
1168        var crop = $(this).find('.image-overlay');
1169        image.css('opacity', '0.2');
1170        crop.css('background-color', '#424242');
1171        $(this).on('mouseenter', function () {
1172          image.css('opacity', '1.0');
1173          crop.css('background-color', 'inherit');
1174        });
1175        $(this).on('mouseleave', function () {
1176          image.css('opacity', '0.2');
1177          crop.css('background-color', '#424242');
1178        });
1179      });
1180    }
1181  };
1182
1183  Gallery.prototype.setMouseShadow = function () {
1184    var shadow = null,
1185      $selector = null,
1186      $captions = this.$container.find('.grid-gallery-caption'),
1187      self = this,
1188      showOver = function (event) {
1189        if (event.type === 'mouseenter') {
1190          $(this).css('box-shadow', self.mouseOverBoxShadow);
1191        } else {
1192          $(this).css('box-shadow', 'none');
1193        }
1194      },
1195      hideOver = function (event) {
1196        if (event.type === 'mouseenter') {
1197          $(this).css('box-shadow', 'none');
1198        } else {
1199          $(this).css('box-shadow', self.mouseOverBoxShadow);
1200        }
1201      };
1202    // only first Init elem has correct value
1203    if (!self.mouseOverBoxShadow) {
1204      self.mouseOverBoxShadow = $captions.filter(':first').css('box-shadow');
1205    }
1206
1207    if ($captions.is('.shadow-show')) {
1208      $captions.css('box-shadow', 'none');
1209      // 'hover' is not a real DOM event - jQuery only ever treated it as an
1210      // alias when passed to .bind()/.on(), and that alias was removed in
1211      // jQuery 1.9. With the 3.7.1 bundled here it just registers a listener
1212      // for an event that never fires, so showOver/hideOver never ran.
1213      $captions.off('mouseenter.mouseShadow mouseleave.mouseShadow').on('mouseenter.mouseShadow mouseleave.mouseShadow', showOver);
1214    } else if ($captions.is('.shadow-hide')) {
1215      $captions.off('mouseenter.mouseShadow mouseleave.mouseShadow').on('mouseenter.mouseShadow mouseleave.mouseShadow', hideOver);
1216    }
1217  };
1218
1219  Gallery.prototype.initPagination = function () {
1220    var perPage = parseInt(this.$container.find('.grid-gallery-photos').data('per-page'), 10),
1221      buffer = [],
1222      page = 1,
1223      offset = 0;
1224    self = this;
1225
1226    if (isNaN(perPage)) {
1227      this.$elements.fadeIn();
1228      return false;
1229    }
1230
1231    if (this.$container.data('gridType') == 4 && this.$container.data('show-mosaic-all-img') != 1) {
1232      this.$elements.fadeIn();
1233      this.pagination.wrapper.hide();
1234      return false;
1235    }
1236
1237    var showCurrentPage = function (gallery) {
1238      gallery.$elements.removeClass('current-page').hide(350);
1239
1240      $.each(buffer[gallery.pagination.currentPage], function () {
1241        $(this)
1242          .addClass('current-page')
1243          .css({ height: gallery.$container.data('height'), width: gallery.$container.data('width') })
1244          .show(function () {
1245            gallery.setIconsPosition();
1246            self.correctMargin();
1247          });
1248      });
1249      /*
1250             if (!gallery.isFluidHeight()) {
1251             $('.current-page .crop').css('height', function () {
1252             var height = null;
1253             $('.crop img').each(function () {
1254             if($(this).height() && !height) {
1255             height = $(this).height();
1256             }
1257             });
1258             return height;
1259             });
1260             }
1261             */
1262    };
1263
1264    this.pagination.limit = perPage;
1265
1266    this.$elements
1267      .each(
1268        $.proxy(function (index, el) {
1269          var currentIndex = index + 1;
1270
1271          if (currentIndex - offset <= this.pagination.limit) {
1272            if (!$.isArray(buffer[page])) {
1273              buffer[page] = [];
1274            }
1275
1276            buffer[page].push(el);
1277          } else {
1278            offset += this.pagination.limit;
1279            page += 1;
1280
1281            buffer[page] = [el];
1282          }
1283        }, this)
1284      )
1285      .hide();
1286
1287    this.pagination.pages = Math.ceil(this.pagination.total / this.pagination.limit);
1288
1289    var element = this.pagination.$wrapper.find('a.grid-gallery-page[data-page="1"]');
1290    element.css('font-size', '19pt');
1291
1292    this.pagination.$wrapper.find('a.grid-gallery-page').on(
1293      'click',
1294      $.proxy(function (e) {
1295        e.preventDefault();
1296
1297        var element = $(e.currentTarget);
1298        var galery = Gallery.prototype;
1299        this.pagination.$wrapper.find('a.grid-gallery-page').each(function () {
1300          $(this).css('font-size', 'inherit');
1301        });
1302        galery.selectedCategory = element.data('page');
1303        element.css('font-size', '19pt');
1304
1305        var $anchor = $(e.currentTarget),
1306          requestedPage = $anchor.data('page');
1307
1308        this.pagination.currentPage = requestedPage;
1309
1310        showCurrentPage(this);
1311
1312        return false;
1313      }, this)
1314    );
1315
1316    showCurrentPage(this);
1317  };
1318
1319  Gallery.prototype.hex = function (x) {
1320    return isNaN(x) ? '00' : hexDigits[(x - (x % 16)) / 16] + hexDigits[x % 16];
1321  };
1322
1323  Gallery.prototype.rgb2hex = function (rgb) {
1324    if (rgb) {
1325      rgb = rgb.match(/^rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(0\.\d+))?\)$/);
1326      function hex(x) {
1327        return ('0' + parseInt(x).toString(16)).slice(-2);
1328      }
1329      return hex(rgb[1]) + hex(rgb[2]) + hex(rgb[3]);
1330    }
1331  };
1332
1333  Gallery.prototype.hex2rgb = function (hex) {
1334    var shorthandRegex = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
1335    hex = hex.replace(shorthandRegex, function (m, r, g, b) {
1336      return r + r + g + g + b + b;
1337    });
1338
1339    var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
1340    return result
1341      ? {
1342          r: parseInt(result[1], 16),
1343          g: parseInt(result[2], 16),
1344          b: parseInt(result[3], 16),
1345        }
1346      : null;
1347  };
1348
1349  Gallery.prototype.importFontFamily = function (familyName) {
1350    var styleId = 'sggFontFamilyStyle',
1351      $style = $('#' + styleId);
1352    if (!$style.length) {
1353      $style = $('<style/>', { id: styleId });
1354      $('head').append($style);
1355    }
1356    familyName = familyName.replace(/\s+/g, '+').replace(/"/g, '');
1357
1358    var obj = document.getElementById(styleId),
1359      sheet = obj.sheet || obj.styleSheet;
1360    if (this.loadedFonts.indexOf(familyName) === -1) {
1361      if (sheet.insertRule) {
1362        sheet.insertRule('@import url("//fonts.googleapis.com/css?family=' + familyName + '"); ', 0);
1363      } else if (sheet.addImport) {
1364        sheet.addImport('//fonts.googleapis.com/css?family=' + familyName);
1365      }
1366      this.loadedFonts.push(familyName);
1367    }
1368  };
1369
1370  Gallery.prototype.loadFontFamily = function () {
1371    font = this.$container.data('caption-font-family');
1372    if (typeof font !== 'undefined') {
1373      if (window && window.sggStandartFontsList && $.inArray(font.replace(/\"/g, ''), window.sggStandartFontsList) != -1) {
1374        return false;
1375      }
1376      if (font && font !== 'Default') {
1377        this.importFontFamily(font);
1378      }
1379    } else {
1380      return false;
1381    }
1382  };
1383
1384  Gallery.prototype.initCaptionCalculations = function () {
1385    var self = this;
1386
1387    this.$container.find('.grid-gallery-caption').each(function () {
1388      wrap = $(this).find('div.grid-gallery-figcaption-wrap');
1389      figcaption = $(this).find('figcaption');
1390
1391      wrap.css({
1392        display: 'table-cell',
1393        'text-align': figcaption.css('text-align'),
1394      });
1395
1396      wrap.wrap(
1397        $('<div>', {
1398          css: {
1399            display: 'table',
1400            height: '100%',
1401            width: '100%',
1402          },
1403        })
1404      );
1405    });
1406  };
1407
1408  Gallery.prototype.checkDirection = function ($element, e) {
1409    var w = $element.width(),
1410      h = $element.height(),
1411      x = (e.pageX - $element.offset().left - w / 2) * (w > h ? h / w : 1),
1412      y = (e.pageY - $element.offset().top - h / 2) * (h > w ? w / h : 1);
1413
1414    return Math.round((Math.atan2(y, x) * (180 / Math.PI) + 180) / 90 + 3) % 4;
1415  };
1416
1417  Gallery.prototype.generateOverlayCaptionColor = function (overlayColor, alpha) {
1418    if (typeof overlayColor == 'string') {
1419      overlayColor = overlayColor.split(')');
1420
1421      if (overlayColor.length > 0) {
1422        overlayColor = overlayColor[0].split('(');
1423
1424        if (overlayColor.length > 1) {
1425          var chanels = overlayColor[1].split(',');
1426
1427          if (chanels.length == 4) {
1428            // it is already rgba (fix for IE)
1429            overlayColor[0] = overlayColor[0].replace('a', '');
1430            chanels.splice(-1, 1);
1431            overlayColor[1] = chanels.join(',');
1432          }
1433          return overlayColor[0] + 'a(' + overlayColor[1] + ', ' + (1 - alpha / 10) + ')';
1434        }
1435      }
1436    }
1437    return overlayColor;
1438  };
1439
1440  Gallery.prototype.initCaptionEffects = function () {
1441    var self = this,
1442      allwaysShowCaptionOnMobile = this.$container.data('caption-mobile'),
1443      disableCaptionOnMobile = this.$container.data('caption-disabled-on-mobile'),
1444      isMobile = !!parseInt(this.$container.data('is-mobile'));
1445
1446    if (isMobile && navigator && navigator.userAgent && navigator.userAgent.indexOf('Safari') > -1) {
1447      var $3dCubeCaptions = this.$container.find('.grid-gallery-caption[data-grid-gallery-type="3d-cube"]');
1448      $3dCubeCaptions.attr('data-grid-gallery-type', 'revolving-door-bottom');
1449      $3dCubeCaptions.data('grid-gallery-type', 'revolving-door-bottom');
1450    }
1451
1452    $.each(this.$elements, function (index, el) {
1453      var $el = $(el),
1454        overlayColor = $el.find('figcaption').css('backgroundColor'),
1455        alpha = parseInt($el.find('figcaption').data('alpha'));
1456
1457      if (isMobile && allwaysShowCaptionOnMobile) {
1458        $el.attr('data-grid-gallery-type', 'none');
1459      }
1460
1461      if ($el.data('grid-gallery-type') == 'cube') {
1462        $el.on('mouseenter mouseleave', function (e) {
1463          var $figcaption = $(this).find('figcaption'),
1464            direction = self.checkDirection($(this), e),
1465            classHelper = null;
1466
1467          switch (direction) {
1468            case 0:
1469              classHelper = 'cube-' + (e.type == 'mouseenter' ? 'in' : 'out') + '-top';
1470              break;
1471            case 1:
1472              classHelper = 'cube-' + (e.type == 'mouseenter' ? 'in' : 'out') + '-right';
1473              break;
1474            case 2:
1475              classHelper = 'cube-' + (e.type == 'mouseenter' ? 'in' : 'out') + '-bottom';
1476              break;
1477            case 3:
1478              classHelper = 'cube-' + (e.type == 'mouseenter' ? 'in' : 'out') + '-left';
1479              break;
1480          }
1481
1482          $figcaption.removeClass().addClass(classHelper);
1483        });
1484      }
1485
1486      if ($el.data('grid-gallery-type') == 'direction-aware') {
1487        var color = $el.find('figcaption').css('color'),
1488          isCaptionBuilderUsed = self.$container.data('caption-buider'),
1489          classStr = '',
1490          addAttr = '',
1491          align = $el.find('figcaption').css('text-align');
1492
1493        if (isCaptionBuilderUsed == 1) {
1494          $el.attr('data-caption', '<div style="padding:0px; height: ' + $el.height() + 'px;
1494 font-family:' + self.$container.data('caption-font-family') + '; font-size:' + self.$container.data('caption-text-size') + '">' + ($el.find('figcaption').html() || '') + '</div>');
1495        } else {
1496          var $ggImgCaption = $el.find('.gg-image-caption');
1497          if ($ggImgCaption.hasClass('ggRtlClass')) {
1498            classStr = 'ggRtlClass';
1499            addAttr = 'dir="rtl"';
1500          }
1501          $el.attr('data-caption', '<div class="' + classStr + '" ' + addAttr + ' style="padding:20px;font-family:' + self.$container.data('caption-font-family') + '; font-size:' + self.$container.data('caption-text-size') + ';">' + ($ggImgCaption.html() || '') + '</div>');
1502        }
1503
1504        $el.sliphover({
1505          target: $el,
1506          backgroundColor: self.generateOverlayCaptionColor(overlayColor, alpha),
1507          fontColor: color,
1508          textAlign: align,
1509          caption: 'data-caption',
1510        });
1511      }
1512
1513      if ($el.data('grid-gallery-type') == '3d-cube') {
1514        if (!$el.find('.box-3d-cube-scene').length) {
1515          var cubeWidth = $el.width(),
1516            cubeHeight = $el.height();
1517          // $el.addClass('box-3d-cube-scene');
1518          $el.children('div').addClass('front').addClass('face');
1519          $el.children('figcaption').addClass('back').addClass('face');
1520          $el.html('<div class="box-3d-cube-scene"><div class="box-3d-cube">' + $el.html() + '</div></div>');
1521          // $el.html("<div class='box-3d-cube-scene'><div class='box-3d-cube'><div class='front face'><img src='http://placehold.it/"+cubeWidth+"x"+cubeHeight+"/' alt=''></div><div class='back face'><div>This is back</div></div></div></div>");
1522          self.changeImageHeightFor3dCubeEffect($el, cubeWidth, cubeHeight);
1523        }
1524      }
1525
1526      if ($el.data('grid-gallery-type') == 'polaroid') {
1527        self.polaroidCaptionCalculate($el);
1528      } else {
1529        var topRow = $el.find('.gg-caption-row.top'),
1530          centerRow = $el.find('.gg-caption-row.center');
1531        if (centerRow.length == 1 && topRow.length == 1) {
1532          centerRow.css({ top: topRow.height(), transform: 'initial' });
1533        }
1534      }
1535    });
1536
1537    $(document).on('click', '.sliphover-container', function (event) {
1538      event.preventDefault();
1539      $(this).data('relatedElement').get(0).click();
1540    });
1541
1542    if (isMobile && !disableCaptionOnMobile) {
1543      this.$container.find('.grid-gallery-caption').each(function () {
1544        var caption = this,
1545          $caption = $(caption),
1546          hammer = new Hammer_gg(this),
1547          captionIsMobile = self.$container.attr('data-caption-mobile'),
1548          preventClick = false;
1549
1550        $caption.on('click', function (event) {
1551          if (preventClick) {
1552            event.preventDefault();
1553            event.stopPropagation();
1554          }
1555        });
1556
1557        hammer.on('tap panstart', function (event) {
1558          if (event.type === 'panstart') {
1559            self.$container.find('.grid-gallery-caption').removeClass('hovered');
1560          }
1561
1562          if (event.type === 'tap') {
1563            preventClick = false;
1564            if (!$caption.hasClass('hovered')) {
1565              self.$container.find('.grid-gallery-caption').not(caption).removeClass('hovered');
1566              $(caption).addClass('hovered');
1567              if (captionIsMobile == 'false') {
1568                preventClick = true;
1569              }
1570            }
1571          }
1572        });
1573      });
1574    }
1575
1576    if (isMobile && disableCaptionOnMobile) {
1577      this.$container.find('.grid-gallery-caption figcaption').hide();
1578    }
1579  };
1580
1581  Gallery.prototype.polaroidCaptionCalculate = function ($el) {
1582    if ($el.data('grid-gallery-type') != 'polaroid' || $(this).find('.post-feed-crop').length || $el.hasClass('initialized')) return;
1583    var $img = $el.find('img');
1584
1585    if ($img.hasClass('ggLazyImg') || $img.hasClass('ggNotInitImg')) return;
1586    if ($el.closest('.gg-mw-row').hasClass('sggDisplNone')) return;
1587
1588    $el.addClass('initialized');
1589    $img.finish();
1590    var width = $el.width(),
1591      gridType = this.$container.data('gridType'),
1592      frameWidth = parseInt(this.$container.data('polaroid-frame-width'), 10) || 20,
1593      captionHeight = this.$container.data('polaroid-caption-height'),
1594      clearHeight = captionHeight ? parseInt(captionHeight.toString().match(/\d.?\d*.?\d*/)[0]) : 0,
1595      // When icons are enabled, the user's chosen caption background color
1596      // ends up on the sibling .caption-with-icons div (see helpers.twig's
1597      // figcaption_after block), not on <figcaption> itself, which is left
1598      // transparent in that case. Reading it off <figcaption> unconditionally
1599      // makes overlayColor resolve to transparent black, and
1600      // generateOverlayCaptionColor() below then stamps a fresh opaque-ish
1601      // alpha onto that black RGB, making the whole polaroid frame look
1602      // solid black regardless of the real configured color.
1603      $colorSource = $el.find('.caption-with-icons').length ? $el.find('.caption-with-icons') : $el.find('figcaption'),
1604      overlayColor = $colorSource.css('backgroundColor'),
1605      alpha = parseInt($colorSource.data('alpha')),
1606      $figcaption = $el.find('figcaption'),
1607      scaleRatio = $img.width() / $img.height();
1608
1609    // Neither color source has a real background in every combination of
1610    // settings (e.g. icons enabled, this photo has no caption text and
1611    // "Hide image title" is on, so .caption-with-icons never even renders) -
1612    // overlayColor then comes back fully transparent ("rgba(0, 0, 0, 0)"),
1613    // and generateOverlayCaptionColor() below only replaces the alpha
1614    // channel, so transparent black becomes solid-looking black instead of
1615    // falling through to any sensible color.
1616    if (/rgba?\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*,\s*0\s*\)/.test(overlayColor) || overlayColor === 'transparent') {
1617      overlayColor = '#ededed';
1618    }
1619
1620    if (gridType == 2) {
1621      var imageHeight = $img.height() - frameWidth * 2,
1622        imageWidth = imageHeight * scaleRatio;
1623    } else {
1624      var imageWidth = $img.width() - frameWidth * 2,
1625        imageHeight = imageWidth / scaleRatio;
1626    }
1627    var figcaptionHeight = !isNaN(clearHeight) && clearHeight != 0 ? (captionHeight.toString().indexOf('%') > 0 ? (imageHeight * clearHeight) / 100 : clearHeight) : 0,
1628      figureFullHeight = imageHeight + frameWidth * 2 + figcaptionHeight;
1629
1630    $img.css({
1631      width: imageWidth + 'px',
1632      height: imageHeight + 'px',
1633      margin: frameWidth + 'px auto 0',
1634    });
1635    $el.find('.gg-caption-table').css('height', '1px');
1636
1637    $el.find('.crop').css({
1638      height: imageHeight + frameWidth + 'px',
1639    });
1640    if (gridType == 0) {
1641      $el.find('.crop').css('overflow', 'visible');
1642    } else if (gridType == 2) {
1643      $el.css({
1644        height: figureFullHeight + 'px',
1645        width: imageWidth + frameWidth * 2 + 'px',
1646      });
1647    } else if (gridType == 3) {
1648      $el.css({
1649        height: figureFullHeight + 'px',
1650      });
1651    }
1652
1653    $el.css({
1654      background: overlayColor,
1655    });
1656    $el.css({
1657      width: $el.width(),
1658      background: this.generateOverlayCaptionColor(overlayColor, alpha),
1659    });
1660
1661    $figcaption.css({
1662      background: 'none',
1663      transition: 'none',
1664    });
1665    if (figcaptionHeight) {
1666      figcaptionHeight += 'px';
1667      $figcaption.css('height', figcaptionHeight);
1668      $el.find('.gg-caption-row').css({ 'max-height': figcaptionHeight ? figcaptionHeight : '100%', height: 'auto' });
1669      $el.find('.gg-caption-cell').css('height', '100%');
1670      if (gridType == 3) {
1671        $figcaption.css('margin-top', frameWidth + 'px');
1672      }
1673    } else {
1674      $figcaption.css('padding', frameWidth + 'px');
1675    }
1676
1677    if ($figcaption.find('.grid-gallery-figcaption-wrap').text().length === 0) {
1678      $figcaption.find('.grid-gallery-figcaption-wrap').append('<span></span>');
1679    }
1680
1681    // Icons sit on the photo itself for polaroid (see the [data-grid-gallery-
1682    // type='polaroid'] .hi-icon-wrap rules in grid-gallery.galleries.effects.css
1683    // for the hover-fade/centering) rather than in the always-visible caption
1684    // strip. Positioned against .grid-gallery-figcaption-wrap - its actual
1685    // CSS containing block (nearest position:relative ancestor - NOT
1686    // <figcaption>, which is one level further out) - measured via
1687    // getBoundingClientRect since that div collapses to 0 height once icons
1688    // are pulled out of flow here, so there's no reliable CSS-only anchor
1689    // (e.g. bottom:100%) to size/position against.
1690    var $iconWrap = $el.find('.hi-icon-wrap'),
1691      $iconWrapParent = $el.find('.grid-gallery-figcaption-wrap');
1692    if ($iconWrap.length && $iconWrapParent.length) {
1693      var imgRect = $img[0].getBoundingClientRect(),
1694        parentRect = $iconWrapParent[0].getBoundingClientRect();
1695      $iconWrap.css({
1696        top: imgRect.top - parentRect.top + 'px',
1697        height: imgRect.height + 'px',
1698      });
1699    }
1700
1701    // .caption-with-icons (the fallback title/caption text shown alongside
1702    // icons - see helpers.twig's figcaption_after block) has a hardcoded
1703    // height:35% (of the whole figure) in grid-gallery.galleries.frontend.css,
1704    // !important. For every other effect type figcaption IS the whole
1705    // figure, so that's a reasonable caption-strip proportion - but for
1706    // polaroid the figure is photo + a separate, much shorter figcaption
1707    // strip below it, so 35% of the *combined* height overshoots the real
1708    // strip and rides up onto the photo. First cut just matched
1709    // <figcaption>'s own height, but that's a fixed number unrelated to
1710    // this text's actual padding+line-height - too short for its own
1711    // content overflowed past the box (with overflow:visible) instead of
1712    // sliding fully into view. height:auto - fit to content - and read its
1713    // OWN resulting natural height back for the hidden-state offset instead.
1714    var $captionWithIcons = $el.find('.caption-with-icons');
1715    if ($captionWithIcons.length) {
1716      $captionWithIcons[0].style.setProperty('height', 'auto', 'important');
1717      var chHeight = $captionWithIcons.outerHeight(),
1718        chAlwaysShow = this.$container.data('polaroid-always-show-caption') == true;
1719      if (chAlwaysShow) {
1720        // Pinned resting position should sit centered on the actual
1721        // <figcaption> strip, not flush against the whole figure's bottom
1722        // edge (bottom:0) - the two only coincide when this box's own
1723        // (content-fit) height happens to match the strip's, which isn't
1724        // guaranteed. Centering here uses top (not bottom), computed from
1725        // <figcaption>'s own real position, since .caption-with-icons'
1726        // containing block is the whole figure, not <figcaption> itself.
1727        var figcaptionRect = $figcaption[0].getBoundingClientRect(),
1728          figureRect = $el[0].getBoundingClientRect(),
1729          figcaptionCenterY = figcaptionRect.top + figcaptionRect.height / 2,
1730          cwiTop = figcaptionCenterY - chHeight / 2 - figureRect.top;
1731        $captionWithIcons[0].style.setProperty('top', cwiTop + 'px', 'important');
1732        $captionWithIcons[0].style.setProperty('bottom', 'auto', 'important');
1733      } else {
1734        // Hidden until hover: tucked exactly one (content-fit) height below
1735        // the figure, sliding up via the existing transform:translateY(-100%)
1736        // on hover (relative to this element's own height, so it still lands
1737        // correctly regardless of what that height actually is).
1738        $captionWithIcons[0].style.setProperty('bottom', -chHeight + 'px', 'important');
1739      }
1740    }
1741
1742    if (this.$container.data('polaroid-animation')) {
1743      $el.addClass('polaroid-animation');
1744    }
1745
1746    if (this.$container.data('polaroid-scattering')) {
1747      $el.css({
1748        transform: 'rotate(' + (-3 + Math.random() * (10 - 3)) + 'deg)',
1749      });
1750      $el.addClass('polaroid-scattering');
1751    }
1752    var slimScroll = $el.closest('div.slimScrollDiv');
1753    if (slimScroll.length) {
1754      var scrollHeight = figureFullHeight + 20 + 'px';
1755      slimScroll.css('height', scrollHeight);
1756      slimScroll.find('.grid-gallery-photos').css('height', scrollHeight);
1757    }
1758  };
1759
1760  Gallery.prototype.changeImageHeightFor3dCubeEffect = function ($figure, cubeWidth, cubeHeight) {
1761    // check params
1762    if (!$figure) {
1763      return;
1764    }
1765    // call this function from PRO script
1766    if (!$figure.length) {
1767      if ('figure' in $figure && 'width' in $figure && 'height' in $figure) {
1768        cubeWidth = $figure.width;
1769        cubeHeight = $figure.height;
1770        $figure = $figure.figure;
1771      } else {
1772        return;
1773      }
1774    }
1775
1776    if (!cubeWidth) {
1777      cubeWidth = $figure.width();
1778    }
1779    if (!cubeHeight) {
1780      cubeHeight = $figure.height();
1781    }
1782
1783    var perspective = Math.max(cubeHeight, cubeWidth) * 2 + 'px',
1784      transformOrigin = '50% 50% -' + Math.round(cubeHeight / 2) + 'px';
1785
1786    $figure.find('.box-3d-cube-scene').css({
1787      perspective: perspective,
1788      '-webkit-perspective': perspective,
1789    });
1790    $figure.find('.box-3d-cube').css({
1791      'transform-origin': transformOrigin,
1792      '-ms-transform-origin': transformOrigin,
1793      '-webkit-transform-origin': transformOrigin,
1794    });
1795    $figure.find('.box-3d-cube, .box-3d-cube .face').css({
1796      width: cubeWidth + 'px',
1797      height: cubeHeight + 'px',
1798    });
1799  };
1800
1801  Gallery.prototype.correctMargin = function () {
1802    if (this.$container.data('area-position') == 'right') {
1803      return;
1804    }
1805    if (this.$container.data('gridType') == 4) {
1806      return;
1807    }
1808    // if responsive mode = 'one by one' and mobile -> run this method
1809    var horizontalScroll = this.$container.data('horizontal-scroll'),
1810      isMobile = parseInt($anyGallery.attr('data-is-mobile'));
1811    if (horizontalScroll && horizontalScroll.responsiveMode == 1 && isMobile) {
1812    } else {
1813      return;
1814    }
1815    if (!this.isFluidHeight()) {
1816      if (this.$qsEnable) {
1817        this.$elements = this.$container.find('figure.grid-gallery-caption');
1818      }
1819
1820      var prevElement = null,
1821        totalElements = this.$elements.filter(':visible').length,
1822        rowWidth = 0,
1823        maxRowWidth = this.$container.width(),
1824        initialMargin = this.initialMargin;
1825
1826      this.$elements.css('margin', this.initialMargin);
1827      this.$elements.parent().css('clear', 'none');
1828
1829      this.$elements.filter(':visible').each(function (index) {
1830        if (rowWidth + $(this).outerWidth() > maxRowWidth) {
1831          $(prevElement).css('margin-right', 0);
1832          $(this).css('margin-right', this.initialMargin);
1833          $(this).parent().css('clear', 'left');
1834          rowWidth = $(this).outerWidth() + parseInt(initialMargin);
1835        } else if (rowWidth + $(this).outerWidth() == maxRowWidth) {
1836          $(this).css('margin-right', 0);
1837          rowWidth = 0;
1838        } else {
1839          rowWidth += $(this).outerWidth() + parseInt(initialMargin);
1840        }
1841
1842        if (index == totalElements - 1) {
1843          $(this).css('margin-right', 0);
1844        }
1845
1846        prevElement = this;
1847      });
1848    }
1849  };
1850
1851  Gallery.prototype.hideTitleTooltip = function () {
1852    if (this.$container.data('hide-tooltip') == true) {
1853      title = '';
1854      this.$container
1855        .find('a, img, div:not(.grid-gallery-photos)')
1856        .on('mouseenter', function () {
1857          title = $(this).attr('title');
1858          $(this).attr({ title: ' ' });
1859        })
1860        .mouseout(function () {
1861          $(this).attr({ title: title });
1862        });
1863    }
1864  };
1865
1866  Gallery.prototype.correctFullscreen = function () {
1867    var windowWidth = $(window).width();
1868    this.$elements.each(function () {
1869      var coef = parseInt(windowWidth / $(this).width()),
1870        resultWidth = Math.round(windowWidth / coef);
1871      $(this).width(resultWidth);
1872    });
1873  };
1874
1875  Gallery.prototype.correctFullScreenWidthGallery = function () {
1876    var windowWidth = $(window).width(),
1877      $parentContainer = this.$container.parent(),
1878      containerOffset = $parentContainer.offset(),
1879      containerOffsetLeft = containerOffset.left + parseFloat($parentContainer.css('padding-left'));
1880
1881    this.$container.find('.grid-gallery-photos').css({
1882      width: windowWidth,
1883    });
1884
1885    var cssDirection = this.$container.css('direction');
1886
1887    if ('ltr' == cssDirection) {
1888      this.$container.css({
1889        width: windowWidth,
1890        left: '-' + containerOffsetLeft + 'px',
1891        //'max-width': '100%'
1892      });
1893      this.$container.find('.grid-gallery-nav').css('width', windowWidth + 'px');
1894    } else {
1895      this.$container
1896        .css({
1897          width: windowWidth, //, 'max-width': '100%'
1898        })
1899        .offset(function (i, coords) {
1900          return { top: coords.top, left: 0 };
1901        });
1902    }
1903  };
1904
1905  Gallery.prototype.getOriginalImageSizes = function (img) {
1906    var tempImage = new Image(),
1907      width,
1908      height,
1909      $img = img ? $(img) : $(),
1910      attrWidth = parseFloat($img.attr('data-gg-original-width') || $img.attr('width')),
1911      attrHeight = parseFloat($img.attr('data-gg-original-height') || $img.attr('height'));
1912
1913    if ('naturalWidth' in tempImage && 'naturalHeight' in tempImage) {
1914      width = img ? img.naturalWidth : 0;
1915      height = img ? img.naturalHeight : 0;
1916    } else if (img) {
1917      tempImage.src = img.src;
1918      width = tempImage.width;
1919      height = tempImage.height;
1920    }
1921
1922    if ((!width || isNaN(width)) && attrWidth > 0) {
1923      width = attrWidth;
1924    }
1925
1926    if ((!height || isNaN(height)) && attrHeight > 0) {
1927      height = attrHeight;
1928    }
1929
1930    return {
1931      width: width,
1932      height: height,
1933    };
1934  };
1935
1936  Gallery.prototype.initHorizontalMode = function () {
1937    var horizontalScroll = this.$container.data('horizontal-scroll'),
1938      height = this.$container.data('height'),
1939      width = this.$container.data('width'),
1940      offset = this.$container.data('offset'),
1941      isMobile = parseInt($anyGallery.attr('data-is-mobile')),
1942      mouseWheelStep = 100,
1943      touchStep = 100,
1944      responsiveMode = 0,
1945      tmpValue = 0,
1946      self = this;
1947
1948    if (this.$container.data('gridType') == 4) {
1949      return;
1950    }
1951    if (!horizontalScroll) {
1952      return;
1953    }
1954    if (horizontalScroll) {
1955      // if responsive mode = 'one by one' and mobile -> need to disable "responsive mode"
1956      if (horizontalScroll.responsiveMode == 1 && isMobile) {
1957        return;
1958      }
1959      if (horizontalScroll.mouseWheelStep) {
1960        tmpValue = parseInt(horizontalScroll.mouseWheelStep);
1961        if (!isNaN(tmpValue)) {
1962          mouseWheelStep = tmpValue;
1963        }
1964      }
1965      if (horizontalScroll.touchStep) {
1966        tmpValue = parseInt(horizontalScroll.touchStep);
1967        if (!isNaN(tmpValue)) {
1968          touchStep = tmpValue;
1969        }
1970      }
1971    }
1972
1973    //Calculate max-height and margin
1974    if (!height) {
1975      var elementsHeight = this.$container
1976          .find('.grid-gallery-caption>a')
1977          .map(function () {
1978            return $(this).height();
1979          })
1980          .get(),
1981        height = Math.max.apply(null, elementsHeight);
1982    } else {
1983      if (offset && offset > 0) {
1984        height = height + offset * 2;
1985      }
1986    }
1987
1988    if (width === 'auto') {
1989      this.$elements.each(function (index, el) {
1990        var $figure = $(el),
1991          $image = $figure.find('img');
1992        sizes = self.getOriginalImageSizes($image.get(0));
1993        $image.css('max-width', 'none');
1994        if (!$image.hasClass('ggLazyImg')) $figure.width(Math.floor((height / sizes.height) * sizes.width));
1995      });
1996    }
1997
1998    //Fixed IE9 scroll bug
1999    var isIE9OrBelow = function () {
2000      return /MSIE\s/.test(navigator.userAgent) && parseFloat(navigator.appVersion.split('MSIE')[1]) < 10;
2001    };
2002
2003    if (isIE9OrBelow()) {
2004      this.$container.find('.grid-gallery-photos > *').css('display', 'table-cell');
2005    } else {
2006      this.$container.find('.grid-gallery-photos > *').css('display', 'inline-block');
2007    }
2008
2009    this.$container.find('.grid-gallery-photos > *').css({
2010      margin: 0,
2011      padding: 0,
2012      float: 'none',
2013      animate: true,
2014      'vertical-align': 'middle',
2015      clear: 'right',
2016      //'margin-right': '-5px',
2017      border: 'none',
2018      'max-width': 'none',
2019    });
2020
2021    this.$container.find('.grid-gallery-photos').css({
2022      'font-size': 0,
2023    });
2024
2025    this.$container.find('.grid-gallery-photos .grid-gallery-caption').css({
2026      float: 'none',
2027      'margin-left': 0,
2028    });
2029
2030    // https://github.com/lanre-ade/jQuery-slimScroll
2031    height = height + 7; //This is scrollbar height;
2032    var slimScroll = this.$container.find('.grid-gallery-photos').slimScroll({
2033      height: height,
2034      width: 'auto',
2035      railVisible: true,
2036      alwaysVisible: true,
2037      allowPageScroll: true,
2038      axis: 'x',
2039      animate: true,
2040      color: horizontalScroll.color || '#000',
2041      opacity: (100 - horizontalScroll.transparency) * 0.01,
2042      wheelStep: mouseWheelStep,
2043      touchScrollStep: touchStep,
2044      isMobile: isMobile,
2045      ggSlimscrollHandler: function () {
2046        self.lazyLoadTriggerHandler();
2047      },
2048    });
2049
2050    // Load more height fix
2051    if (slimScroll.height() < height) {
2052      slimScroll.height(height);
2053      slimScroll.parent().height(height);
2054    }
2055  };
2056
2057  Gallery.prototype.initHorizontalGalleryType = function () {
2058    if (this.$container.data('height') && String(this.$container.data('height')).indexOf('%') > -1) {
2059      var height = this.$elements.first().height();
2060      this.$elements.find('img').css({
2061        'max-height': height,
2062        'min-height': height,
2063      });
2064    }
2065    var self = this;
2066    setTimeout(function () {
2067      self.resizeHorizontalElements();
2068    }, 50);
2069  };
2070
2071  Gallery.prototype.hidePreloader = function () {
2072    var preloadEnab = this.$container.attr('data-preloader'),
2073      preloader = this.$container.find('.gallery-loading'),
2074      galleryPhotos = this.$container.find('.grid-gallery-photos');
2075
2076    preloader.hide();
2077    if (preloadEnab !== '' && preloadEnab === 'true') {
2078      setTimeout(function () {
2079        galleryPhotos.show().fadeTo('slow', 1, function () {
2080          galleryPhotos.css('opacity', '1');
2081        });
2082      }, 0);
2083    } else {
2084      galleryPhotos.show().fadeTo('fast', 1, function () {
2085        galleryPhotos.css('opacity', '1');
2086      });
2087    }
2088  };
2089
2090  Gallery.prototype.showGalleryParts = function () {
2091    this.$container.children('.hidden-item').removeClass('hidden-item');
2092  };
2093
2094  Gallery.prototype.$getImagesFigureContainer = function () {
2095    return this.$container.find('figure.grid-gallery-caption');
2096  };
2097
2098  Gallery.prototype.initSocialSharing = function () {
2099    if (!this.socialSharing || !this.socialSharing.enabled) {
2100      return;
2101    }
2102    var newUrl = encodeURIComponent(window.location.href);
2103    var newTitle = encodeURIComponent(document.title);
2104    jQuery('.supSocialIcon').each(function () {
2105      var $this = $(this);
2106      var origUrl = $this.attr('originalurl');
2107      var newUrl2 = origUrl.replace('{url}', newUrl);
2108      newUrl2 = newUrl2.replace('{title}', newTitle);
2109      newUrl2 = newUrl2.replace('{description}', newTitle);
2110      $this.attr('href', newUrl2);
2111    });
2112    this.initGallerySocialSharing();
2113    this.initImageSocialSharing();
2114  };
2115  Gallery.prototype.initGallerySocialSharing = function () {
2116    var gallerySharing = this.socialSharing.gallerySharing;
2117    if (!parseInt(gallerySharing.enabled)) {
2118      return;
2119    }
2120    if (gallerySharing.position == 'top' || gallerySharing.position == 'all') {
2121      this.$container.find('.gallery-sharing-top').fadeIn();
2122    }
2123    if (gallerySharing.position == 'bottom' || gallerySharing.position == 'all') {
2124      this.$container.find('.gallery-sharing-bottom').fadeIn();
2125    }
2126  };
2127  Gallery.prototype.initImageSocialSharing = function () {
2128    var imageSharing = this.socialSharing.imageSharing;
2129    if (!parseInt(imageSharing.enabled)) {
2130      return;
2131    }
2132    var btns = this.$container.find('.gallery-sharing-image').clone();
2133
2134    var $images = this.$getImagesFigureContainer(),
2135      iconsEnabled = this.$container.data('icons');
2136    $images.each(function () {
2137      var $this = $(this),
2138        $el;
2139      var imgLink = jQuery($this).parent().attr('href');
2140      btns.find('.supSocialIcon').each(function () {
2141        var $thisBtn = $(this);
2142        if ($thisBtn.hasClass('supSocialIconprint')) {
2143          $thisBtn.attr('onClick', 'supSocialSharePrintImage("' + imgLink + '")');
2144        }
2145      });
2146
2147      if (!iconsEnabled) {
2148        $el = $this.parent();
2149      } else {
2150        $el = $this.find('a.hi-icon');
2151      }
2152      $this.append(btns.html());
2153    });
2154  };
2155  Gallery.prototype.addSocialShareToPopUp = function ($element, $wrapper, addClass, fixed) {
2156    if (!this.socialSharing.enabled || !parseInt(this.socialSharing.popupSharing.enabled)) {
2157      return;
2158    }
2159    var btns = this.$container.find('.gallery-sharing-popup').clone();
2160    var newUrl = encodeURIComponent($element.get(0).baseURI);
2161    var imgLink = $element.get(0).href;
2162    var newTitle = jQuery($element.get(0)).attr('title');
2163    btns.find('.supSocialIcon').each(function () {
2164      var $this = $(this);
2165      if ($this.hasClass('supSocialIconprint')) {
2166        $this.attr('onClick', 'supSocialSharePrintImage("' + imgLink + '")');
2167      }
2168      $this.attr('title', newTitle);
2169      var origUrl = $this.attr('originalurl');
2170      var newUrl2 = origUrl.replace('{url}', newUrl);
2171      newUrl2 = newUrl2.replace('{title}', newTitle);
2172      newUrl2 = newUrl2.replace('{description}', newTitle);
2173      $this.attr('href', newUrl2);
2174    });
2175    $wrapper.find('.supSocialIconsWrapper').remove();
2176    $wrapper.append(btns.html());
2177  };
2178
2179  // Gallery.prototype.initEvent = function($elements){
2180  //     $elements.find('.supsystic-social-sharing a.social-sharing-button').on('click',function (e) {
2181  // if( !e ) e = window.event;
2182  // e.preventDefault();
2183  // e.stopPropagation();
2184  // e.stopImmediatePropagation();
2185  // $(document).trigger('ssSocialClick', this);
2186  // if (e.currentTarget.href.slice(-1) !== '#') {
2187  //     window.open(e.currentTarget.href, 'mw' + e.timeStamp, 'left=20,top=20,width=500,height=500,toolbar=1,resizable=0');
2188  // }
2189
2190  // var button = $(this)
2191  // ,   figureWrapper = button.closest('.grid-gallery')
2192  // ,   socialHtmlWrapper = figureWrapper.find('#social-share-html')
2193  // // ,   socialHtmlWrapper = figureWrapper.find('.supsystic-social-sharing')
2194  // ,   popupWrapper = socialHtmlWrapper.find('.supsystic-social-sharing-popup');
2195
2196  // if(button.hasClass('trigger-popup')){
2197  // 	if(socialHtmlWrapper.css('display') === 'none'){
2198  //         socialHtmlWrapper.find('a').css('display', 'none');
2199  //         socialHtmlWrapper.css('display','block');
2200  //         popupWrapper.css('display','block');
2201  //     }else{
2202  //         socialHtmlWrapper.css('display','none');
2203  //         popupWrapper.css('display','none');
2204  //     }
2205  // }
2206  // if(button.closest('#pp_full_res').length){
2207  //     var buttonOverlayWrapper = button.closest('#pp_full_res')
2208  //     ,   buttonPopupWrapper = buttonOverlayWrapper.find('.supsystic-social-sharing-popup');
2209  //     if(buttonPopupWrapper.css('display') === 'none'){
2210  //         buttonPopupWrapper.css('display','block');
2211  //     }else{
2212  //         buttonPopupWrapper.css('display','none');
2213  //     }
2214  // }
2215  // $(document).on('click', function (e) {
2216  //     if( !e ) e = window.event;
2217  //     if (!$(e.target).is(".supsystic-social-sharing-popup")) {
2218  //         socialHtmlWrapper.css('display','none');
2219  //         popupWrapper.css('display','none');
2220  //         socialHtmlWrapper.find('a').css('display', 'block');
2221  //     }
2222  // });
2223  //     });
2224  // };
2225
2226  // Gallery.prototype.getSocialButtons = function(wrapper_class, url, img_id, img_src, title, noCounter) {
2227  //     title = title || '';
2228
2229  // 	var html = this.$container.find('#social-share-html').html();
2230
2231  //     if (html !== undefined && html.length){
2232  //         html = html.replace(/{url}/g, url).replace(/{title}/g, title);
2233  //         if(noCounter) {
2234  //             // cut counter div
2235  //             html = html.replace(/<div class="counter-wrap.*?>.*?<\/div>/g, '');
2236  //         }
2237  //     }
2238
2239  //     return $('<div>', {
2240  //         class: wrapper_class,
2241  //         'data-img-thumbnail': img_src,
2242  //         'data-img-id': img_id,
2243  //         'data-img-title': title,
2244  //     }).html(html);
2245  // };
2246
2247  // Gallery.prototype.getSocialButtonsByImage = function(wrapper_class, $element, popup) {
2248
2249  //     var $img = $element.find('img'),
2250  //         imgSrc = $element.attr('href'),
2251  //         title = $element.attr('title'),
2252  //         $captionContainer = $element.find('.gg-image-caption'),
2253  //         url = location.href,
2254  // 		imageId = null;
2255
2256  // 	if($element.attr('data-type') == 'link' || $element.attr('data-video-source') == 'youtube') {
2257  // 		if($img.length) {
2258  // 			if($img.attr('data-gg-real-image-href')) {
2259  // 				imgSrc = $img.attr('data-gg-real-image-href');
2260  // 			} else {
2261  // 				imgSrc = $img.attr('src');
2262  // 			}
2263  // 		}
2264  // 	}
2265
2266  // 	if($element && $element.attr('id') && $element.attr('id').split('-').pop()) {
2267  // 		imageId = $element.attr('id').split('-').pop();
2268  // 	}
2269
2270  //     if ($captionContainer.length) {
2271  //         var caption = $.trim(
2272  //             $captionContainer.clone().html($captionContainer.html()
2273  //                 .replace(/<br\s*[\/]?>/gi, ' '))
2274  //                 .text()
2275  //                 .replace(/\s+/, ' ')
2276  //         );
2277
2278  //         if (caption.length) {
2279  //             title = caption;
2280  //         }
2281  //     }
2282
2283  //     if (imgSrc && imgSrc.indexOf('http') !== 0) {
2284  //         imgSrc = 'http:' + imgSrc;
2285  //     }
2286
2287  //     function updateQueryStringParameter(uri, key, value) {
2288  //         var re = new RegExp("([?&])" + key + "=.*?(&|$)", "i");
2289  //         var separator = uri.indexOf('?') !== -1 ? "&" : "?";
2290  //         if (uri.match(re)) {
2291  //             return uri.replace(re, '$1' + key + "=" + value + '$2');
2292  //         } else {
2293  //             return uri + separator + key + "=" + value;
2294  //         }
2295  //     }
2296
2297  //     if (popup) {
2298  //         url = url.replace('#!', '?');
2299  //     }
2300  // 	if(imageId) {
2301  // 		url = updateQueryStringParameter(url, '_gallery', $element.attr('id'));
2302  // 		url = encodeURIComponent(updateQueryStringParameter(url, 'shared-image', imageId));
2303  // 	}
2304
2305  //     return this.getSocialButtons(wrapper_class, url, $element.attr('id'), imgSrc, title, true);
2306  // };
2307
2308  // Gallery.prototype.correctImageSocialButtons = function($imageSharing){
2309
2310  // if(!$imageSharing.length){
2311  //     return;
2312  // }
2313  // var $example = $imageSharing.eq(0),
2314  //     correctCss = {};
2315
2316  // if($example.hasClass('vertical')){
2317  //     var buttonWidth = $example.find('.social-sharing-button').eq(0).outerWidth();
2318  //     correctCss.width = buttonWidth;
2319  //     $example.width(buttonWidth);
2320  // }
2321
2322  // var width = $example.width();
2323  // var height = $example.height();
2324
2325  // if($example.hasClass('center')){
2326  //     $.extend(correctCss,{'margin-left': '-' + (width/2) + 'px'})
2327  // }
2328  // if($example.hasClass('middle')){
2329  //     $.extend(correctCss,{'margin-top': '-' + (height/2) + 'px'})
2330  // }
2331
2332  // $imageSharing.find('.social-sharing-button.print').on('click',function(){
2333  //     var image_url = $(this).closest('.supsystic-grid-gallery-image-sharing').data('img-url');
2334  //     window.open(image_url).print();
2335  // });
2336
2337  // $imageSharing.find('.social-sharing-button.mail').on('click',function(){
2338  //     var $infoElement = $(this).closest('.supsystic-grid-gallery-image-sharing'),
2339  //         image_id = $infoElement.data('img-id'),
2340  //         image_title = $infoElement.data('img-title');
2341  //     var url = window.location.href.replace(window.location.hash,'') + '#' + image_id + '/';
2342
2343  //     var src = 'mailto:[email protected]?subject=' + encodeURIComponent(document.title) + ',' + image_title + '&body=' + url;
2344  //     var iframe = $('<iframe id="mailtoFrame" src="' + src + '" width="1" height="1" border="0" frameborder="0"></iframe>');
2345
2346  //     $('body').append(iframe);
2347  //     window.setTimeout(function(){
2348  //         iframe.remove();
2349  //     }, 500);
2350  // });
2351
2352  // var self = this;
2353  // $imageSharing.each(function(){
2354
2355  //     $(this).css(correctCss);
2356
2357  //     var thumbnail = $(this).data('img-thumbnail');
2358
2359  //     if (thumbnail) {
2360
2361  //         for(var sharingClass in self.socialSharingImageOperators){
2362  //             var $button = $(this).find('.social-sharing-button.'+sharingClass);
2363  //             if($button.length){
2364  //                 var img_url = $(this).data('img-url'),
2365  //                     img_id = $(this).data('img-id'),
2366  // 					shareUrlObj = self.urlToObject($button.attr('href')),
2367  // 					newHref = '';
2368
2369  // 				// set gallery image for share link
2370  // 				shareUrlObj.params[self.socialSharingImageOperators[sharingClass]] = thumbnail;
2371  // 				newHref = self.objectToUrl(shareUrlObj);
2372
2373  // 				if(img_url) {
2374  // 					newHref = newHref.replace(
2375  // 						img_url,
2376  // 						self.addPopUpHashToUrl(self.socialButtonsUrl, img_id)
2377  // 					);
2378  // 				}
2379
2380  // 				$button.attr('href', newHref);
2381  //             }
2382  //         }
2383  //     }
2384  // });
2385
2386  // };
2387
2388  Gallery.prototype.urlToObject = function (strUrl) {
2389    if (!strUrl) {
2390      return null;
2391    }
2392    var posQ = strUrl.indexOf('?');
2393    if (posQ == -1) {
2394      return null;
2395    }
2396    var strQueryParams = strUrl.substr(posQ + 1),
2397      result = {
2398        url: strUrl.substr(0, posQ),
2399        params: {},
2400      };
2401    strQueryParams.split('&').forEach(function (part) {
2402      var item = part.split('=');
2403      if (item.length >= 2) {
2404        result.params[item[0]] = decodeURIComponent(item[1]);
2405      }
2406    });
2407    return result;
2408  };
2409
2410  Gallery.prototype.objectToUrl = function (specObj) {
2411    if (!specObj) {
2412      return null;
2413    }
2414
2415    var resUrl = '';
2416    if (specObj.url) {
2417      resUrl = specObj.url;
2418    }
2419    if (specObj.params) {
2420      var paramParts = [],
2421        paramKeys = Object.keys(specObj.params),
2422        indX = 0;
2423      for (indX = 0; indX < paramKeys.length; indX++) {
2424        paramParts.push(encodeURIComponent(paramKeys[indX]) + '=' + encodeURIComponent(specObj.params[paramKeys[indX]]));
2425      }
2426      resUrl = resUrl + '?' + paramParts.join('&');
2427    }
2428    return resUrl;
2429  };
2430
2431  Gallery.prototype.removePopUpHashFromUrl = function (url) {
2432    var match = url.match(/gg-\d+-\d+/);
2433    return url.replace(url[url.indexOf(match) - 1] + match, '');
2434  };
2435
2436  Gallery.prototype.addPopUpHashToUrl = function (url, hash) {
2437    if (!hash || !hash.length) {
2438      return url;
2439    }
2440    var prefix = '?';
2441    if (url.indexOf(prefix) != -1) prefix = '&';
2442    return url + prefix + hash;
2443  };
2444
2445  Gallery.prototype.openHashPopUp = function () {
2446    var getElementId = function () {
2447      var search = window.location.search;
2448      if (search.match(/gg-\d+-\d+/)) {
2449        return search.match(/gg-\d+-\d+/);
2450      }
2451
2452      var hash = window.location.hash;
2453      if (hash.match(/gg-\d+-\d+/)) {
2454        return hash.match(/gg-\d+-\d+/);
2455      }
2456    };
2457
2458    var elementId = getElementId(),
2459      $element = this.$container.find('#' + elementId + ', [data-id="' + elementId + '"]').first();
2460
2461    if ($element.length) {
2462      $element.click();
2463      var $figure;
2464
2465      if ($element.hasClass('hi-icon')) {
2466        $figure = $element.closest('figure.grid-gallery-caption');
2467      } else {
2468        $figure = $element.children('figure');
2469      }
2470
2471      if ($figure.length) {
2472        $('html, body').animate(
2473          {
2474            scrollTop: $figure.offset().top,
2475          },
2476          100
2477        );
2478      }
2479    }
2480  };
2481
2482  Gallery.prototype.updateQueryParams = function (url, params) {
2483    for (var param in params) {
2484      var re = new RegExp('[\\?&]' + param + '=([^&#]*)'),
2485        match = re.exec(url),
2486        delimiter,
2487        value = params[param];
2488
2489      if (match === null) {
2490        var hasQuestionMark = /\?/.test(url);
2491        delimiter = hasQuestionMark ? '&' : '?';
2492
2493        if (value) {
2494          url = url + delimiter + param + '=' + value;
2495        }
2496      } else {
2497        delimiter = match[0].charAt(0);
2498
2499        if (value) {
2500          url = url.replace(re, delimiter + param + '=' + value);
2501        } else {
2502          url = url.replace(re, '');
2503          if (delimiter === '?' && url.length) {
2504            url = '?' + url.substr(1);
2505          }
2506        }
2507      }
2508    }
2509
2510    return url;
2511  };
2512
2513  Gallery.prototype.changePopUpHash = function (hash) {
2514    var galleryId = this.$container.attr('data-gg-id'),
2515      galleryOpenPopupHashRegex = new RegExp('gg-' + galleryId + '(?:-(\\d+))*'),
2516      regexFoundGalleryImageId = galleryOpenPopupHashRegex.exec(hash),
2517      changedUrlDisabled = this.$container.attr('data-popup-disable-changed-url');
2518
2519    if (changedUrlDisabled !== 'true') {
2520      // if image id not exits
2521      if (!regexFoundGalleryImageId || regexFoundGalleryImageId.length < 2 || !regexFoundGalleryImageId[1]) {
2522        return;
2523      }
2524      this.popupIsOpened = true;
2525
2526      if (this.ignoreStateChange) {
2527        this.ignoreStateChange = false;
2528        return;
2529      }
2530      var queryParams = this.updateQueryParams(window.location.search, { _gallery: hash }),
2531        stateUrl = window.location.pathname + queryParams;
2532
2533      this.historyStateChange = true;
2534
2535      if (!this.popupIsInit) {
2536        if (queryParams === document.location.search) {
2537          History.replaceState(
2538            {
2539              type: 'sc-gallery',
2540              hash: hash,
2541              state: 'close',
2542            },
2543            document.title,
2544            window.location.pathname + this.updateQueryParams(window.location.search, { _gallery: null })
2545          );
2546
2547          History.pushState(
2548            {
2549              type: 'sc-gallery',
2550              hash: hash,
2551              state: 'init',
2552            },
2553            document.title,
2554            stateUrl
2555          );
2556        } else {
2557          History.replaceState(
2558            {
2559              type: 'sc-gallery',
2560              hash: hash,
2561              state: 'init',
2562            },
2563            document.title,
2564            stateUrl
2565          );
2566        }
2567
2568        this.popupIsInit = true;
2569      } else {
2570        if (this.disablePopupHistory) {
2571          History.replaceState(
2572            {
2573              type: 'sc-gallery',
2574              hash: hash,
2575              state: 'change',
2576            },
2577            document.title,
2578            stateUrl
2579          );
2580        } else {
2581          History.pushState(
2582            {
2583              type: 'sc-gallery',
2584              hash: hash,
2585              state: 'change',
2586            },
2587            document.title,
2588            stateUrl
2589          );
2590        }
2591      }
2592
2593      this.historyStateChange = false;
2594    }
2595  };
2596
2597  Gallery.prototype.clearPopUpHash = function () {
2598    this.historyStateChange = true;
2599
2600    if (this.disablePopupHistory) {
2601      History.replaceState(
2602        {
2603          type: 'sc-gallery',
2604          hash: '',
2605          state: 'close',
2606        },
2607        document.title,
2608        window.location.pathname + this.updateQueryParams(window.location.search, { _gallery: null })
2609      );
2610    } else {
2611      History.pushState(
2612        {
2613          type: 'sc-gallery',
2614          hash: '',
2615          state: 'close',
2616        },
2617        document.title,
2618        window.location.pathname + this.updateQueryParams(window.location.search, { _gallery: null })
2619      );
2620    }
2621
2622    this.historyStateChange = false;
2623    this.popupIsOpened = false;
2624  };
2625
2626  Gallery.prototype.getRealImgSizeInBrowser = function (arguments) {
2627    if (!arguments && !arguments.length) {
2628      return null;
2629    }
2630    if (arguments.length > 1) {
2631      returnType = arguments[1];
2632    }
2633    if (arguments.length) {
2634      $image = arguments[0];
2635    }
2636
2637    var returnData = null,
2638      boundRect = null,
2639      attrWidth = $image && $image.length ? parseFloat($image.attr('data-gg-original-width') || $image.attr('width')) : null,
2640      attrHeight = $image && $image.length ? parseFloat($image.attr('data-gg-original-height') || $image.attr('height')) : null,
2641      cssWidth = null,
2642      cssHeight = null;
2643    if ($image && $image.length && $image[0].getBoundingClientRect) {
2644      boundRect = $image[0].getBoundingClientRect();
2645    }
2646
2647    if (returnType == 'h') {
2648      if (boundRect && boundRect.height) {
2649        returnData = boundRect.height;
2650      } else {
2651        returnData = parseFloat($image.css('height'));
2652      }
2653      if ((!returnData || isNaN(returnData)) && attrWidth > 0 && attrHeight > 0) {
2654        cssWidth = boundRect && boundRect.width ? boundRect.width : parseFloat($image.css('width'));
2655        if ((!cssWidth || isNaN(cssWidth)) && $image.parent().length) {
2656          cssWidth = parseFloat($image.parent().css('width'));
2657        }
2658        if (cssWidth > 0) {
2659          returnData = (cssWidth * attrHeight) / attrWidth;
2660        }
2661      }
2662    } else if (returnType == 'w') {
2663      if (boundRect && boundRect.width) {
2664        returnData = boundRect.width;
2665      } else {
2666        returnData = parseFloat($image.css('width'));
2667      }
2668      if ((!returnData || isNaN(returnData)) && attrWidth > 0 && attrHeight > 0) {
2669        cssHeight = boundRect && boundRect.height ? boundRect.height : parseFloat($image.css('height'));
2670        if ((!cssHeight || isNaN(cssHeight)) && $image.parent().length) {
2671          cssHeight = parseFloat($image.parent().css('height'));
2672        }
2673        if (cssHeight > 0) {
2674          returnData = (cssHeight * attrWidth) / attrHeight;
2675        }
2676      }
2677    }
2678
2679    return returnData;
2680  };
2681
2682  Gallery.prototype.lazyLoadTriggerHandler = function () {
2683    $(window).trigger('scroll');
2684    $(document).trigger('scroll');
2685
2686    if (this.$container && this.$container.length) {
2687      this.$container.trigger('scroll');
2688      this.$container.find('.grid-gallery-photos, .slimScrollDiv').trigger('scroll');
2689    }
2690  };
2691
2692  Gallery.prototype.lazyLoadStableRefresh = function (waitTime) {
2693    var self = this,
2694      galleryType = this.$container.data('gridType'),
2695      baseDelay = parseInt(waitTime, 10);
2696
2697    if (isNaN(baseDelay) || baseDelay < 0) {
2698      baseDelay = 400;
2699    }
2700
2701    $.each([0, 120, baseDelay + 80, baseDelay + 450, 1600], function (index, delay) {
2702      setTimeout(function () {
2703        self.lazyLoadTriggerHandler();
2704
2705        if (galleryType == 4) {
2706          $(document).trigger('ggMosaicResizedEvent');
2707          $(window).trigger('resize');
2708        } else if (self.wookmark) {
2709          self.wookmark.trigger('refreshWookmark');
2710        }
2711      }, delay);
2712    });
2713  };
2714  Gallery.prototype.lazyLoadDistanceRefresh = function (waitTime) {
2715    var self = this,
2716      galleryType = this.$container.data('gridType');
2717
2718    if (typeof waitTime == 'undefined') {
2719      waitTime = 400;
2720    }
2721
2722    // need run function once at every load
2723    if (self.ggLazyTimeOut) {
2724      clearTimeout(self.ggLazyTimeOut);
2725    }
2726    self.ggLazyTimeOut = setTimeout(function () {
2727      setTimeout(function () {
2728        $.each(self.$elements, function (index, el) {
2729          var $el = $(el);
2730          if ($el.data('grid-gallery-type') == 'polaroid') {
2731            self.polaroidCaptionCalculate($el);
2732          }
2733        });
2734      }, waitTime + 50);
2735
2736      switch (galleryType) {
2737        case 4:
2738          $(document).trigger('ggMosaicResizedEvent');
2739          break;
2740        case 0:
2741          if (typeof self.setCaptionOnHoverImage == 'function') {
2742            self.setCaptionOnHoverImage();
2743          }
2744          // if hidden images  not showing
2745          setTimeout(function () {
2746            self.lazyLoadTriggerHandler();
2747            setTimeout(function () {
2748              if (self.wookmark) {
2749                self.wookmark.trigger('refreshWookmark');
2750              }
2751            }, 50);
2752          }, waitTime + 60); //450); // animation transition time
2753          break;
2754        case 1:
2755          if (typeof self.setCaptionOnHoverImage == 'function') {
2756            self.setCaptionOnHoverImage();
2757          }
2758          $.each(self.$elements, function (index, el) {
2759            var $el = $(el);
2760            if ($el.data('grid-gallery-type') == '3d-cube') {
2761              self.changeImageHeightFor3dCubeEffect($el, $el.width(), $el.find('img').length ? $el.find('img').height() : $el.height());
2762            }
2763          });
2764        case 2:
2765        case 3:
2766        default:
2767          //self.initWookmark();
2768          // if hidden images  not showing
2769          setTimeout(function () {
2770            self.lazyLoadTriggerHandler();
2771            self.initWookmark();
2772          }, waitTime + 50); //450); // animation transition time
2773          break;
2774      }
2775    }, 100);
2776  };
2777
2778  Gallery.prototype.initLazyLoad = function () {
2779    var self = this,
2780      hoverImgSrc = this.$container.data('image-on-hover');
2781    /*if(hoverImgSrc && hoverImgSrc.length) {
2782			// lazy load not work for image on hover
2783			return;
2784		}*/
2785    var showMoreCategory = this.$container.find('.showMoreCategory'),
2786      effect = this.$container.data('lazyload-effect'),
2787      duration = this.$container.data('lazyload-effect-duration'),
2788      $lazyImages = this.$container.find('.ggLazyImg');
2789
2790    if (!$lazyImages.length) {
2791      return;
2792    }
2793
2794    if (typeof effect == 'undefined') {
2795      effect = 'show';
2796      duration = 400;
2797    }
2798    var waitTime = effect == 'fadeIn' ? 200 : duration;
2799
2800    self.ggLazyTimeOut = null;
2801    $lazyImages.ggLazyLoad({
2802      data_attribute: 'gg-real-image-href',
2803      threshold: 50,
2804      failure_limit: $lazyImages.length,
2805      effect: effect,
2806      effectspeed: duration,
2807      skip_invisible: showMoreCategory.length > 0,
2808      load: function (event) {
2809        var image = $(this);
2810        self.lazyLoadDistanceRefresh(waitTime);
2811        if (self.$container.data('gridType') != 0) {
2812          image.closest('div .crop').css('height', '');
2813        }
2814        image.closest('figure').css('height', 'auto');
2815        if (self.$container.data('gridType') == 2 && self.$elements) {
2816          setTimeout(function () {
2817            self.resizeElementHeight(image, image.closest('figure'));
2818          }, waitTime + 20); //460); // animation transition time + 20ms
2819        }
2820      },
2821    });
2822
2823    self.lazyLoadStableRefresh(waitTime);
2824  };
2825
2826  Gallery.prototype.refreshLayoutAfterImageLoad = function () {
2827    var galleryType = this.$container.data('gridType');
2828
2829    if (!this.$container || !this.$container.length || !this.$container.is(':visible')) {
2830      return;
2831    }
2832
2833    this.setImagesHeight();
2834    this.resizeHorizontalElements();
2835
2836    if (galleryType == 4) {
2837      $(document).trigger('ggMosaicResizedEvent');
2838      $(window).trigger('resize');
2839    } else if (this.wookmark) {
2840      this.wookmark.trigger('refreshWookmark');
2841    } else {
2842      this.initWookmark();
2843    }
2844
2845    if (typeof this.setCaptionOnHoverImage == 'function') {
2846      this.setCaptionOnHoverImage();
2847    }
2848
2849    this.setIconsPosition();
2850    this.lazyLoadTriggerHandler();
2851  };
2852
2853  Gallery.prototype.initImageLoadLayoutRefresh = function () {
2854    var self = this,
2855      $images = this.$container.find('img.ggImg, figure.grid-gallery-caption img'),
2856      refreshTimer = null;
2857
2858    if (this.imageLoadLayoutRefreshInitialized || !$images.length) {
2859      return;
2860    }
2861
2862    this.imageLoadLayoutRefreshInitialized = true;
2863
2864    function hasPendingLayoutWork() {
2865      return (
2866        $images.filter(function () {
2867          return !this.complete || !this.naturalWidth || !this.naturalHeight;
2868        }).length > 0 ||
2869        self.$container.find('img.ggNotInitImg').length > 0 ||
2870        (self.$container.data('gridType') == 4 && self.$container.height() < 1)
2871      );
2872    }
2873
2874    function refresh() {
2875      clearTimeout(refreshTimer);
2876      refreshTimer = setTimeout(function () {
2877        self.refreshLayoutAfterImageLoad();
2878      }, 60);
2879    }
2880
2881    $images.off('.sggLayoutReady').one('load.sggLayoutReady error.sggLayoutReady', refresh);
2882
2883    $.each([0, 150, 400, 900, 1800, 3600, 6000], function (index, delay) {
2884      setTimeout(function () {
2885        if (hasPendingLayoutWork()) {
2886          refresh();
2887        }
2888      }, delay);
2889    });
2890  };
2891
2892  Gallery.prototype.init = function () {
2893    //this.$container.imagesLoaded().done($.proxy(function () {
2894    var self = this;
2895    this.setImagesHeight();
2896    var galleryBeforeInitId = 'GalleryBeforeInit' + this.galleryContainerId;
2897
2898    setTimeout(() => {
2899      $(document).trigger(galleryBeforeInitId, [this]);
2900    }, 10);
2901
2902    this.hidePreloader();
2903    this.showCaption();
2904    this.initRowsMode();
2905    this.initHorizontalGalleryType();
2906    this.initQuicksand();
2907
2908    if (this.$container.attr('data-fullscreen') == 'true') {
2909      this.correctFullScreenWidthGallery();
2910      $(window).resize(function () {
2911        self.correctFullScreenWidthGallery();
2912      });
2913    }
2914
2915    this.initHorizontalMode();
2916    this.setOverlayTransparency();
2917    this.initCaptionCalculations();
2918    this.initCaptionEffects();
2919    this.hideTitleTooltip();
2920    this.initPagination();
2921
2922    this.initPopup();
2923
2924    this.setMouseShadow();
2925    this.setImageOverlay();
2926
2927    this.loadFontFamily();
2928    this.hidePopupCaptions();
2929    this.preventImages();
2930    this.initWookmark();
2931    this.initCategories();
2932    this.setIconsPosition();
2933
2934    this.correctMargin();
2935    this.initControll();
2936    this.showGalleryParts();
2937    this.initLazyLoad();
2938    this.initImageLoadLayoutRefresh();
2939
2940    this.initSocialSharing();
2941
2942    // iOS Safari fix
2943    setTimeout(function () {
2944      if (self.wookmark) {
2945        self.wookmark.trigger('refreshWookmark');
2946      }
2947    }, 500);
2948
2949    setTimeout(function () {
2950      self.openHashPopUp();
2951    }, 500);
2952
2953    $(document).ready(function () {
2954      $(document).trigger('GalleryAfterInit', self);
2955    });
2956
2957    var galleryId = this.$container.attr('data-gg-id'),
2958      openByLinkRegexp = new RegExp('#gg-open-' + galleryId + '(\\-([\\d]+))*$');
2959
2960    History.Adapter.bind(window, 'statechange', function (event) {
2961      var state = History.getState();
2962
2963      // self.historyStateChange if true means manual update state and we need skip this event
2964      if (!self.historyStateChange) {
2965        if ((state.data.type !== 'sc-gallery' && self.popupIsOpened) || (state.data.type === 'sc-gallery' && (state.data.state === 'close' || state.data.state === 'hashchange') && self.popupIsOpened)) {
2966          if (self.popupType == 'pretty-photo') {
2967            this.$prettyPhoto && this.$prettyPhoto.close();
2968          }
2969
2970          if (self.popupType == 'colorbox') {
2971            $.colorbox && $.colorbox.close();
2972          }
2973
2974          if (self.popupType == 'photobox') {
2975            window._photobox && window._photobox.close();
2976          }
2977        }
2978
2979        // On history open image
2980        if (state.data.type === 'sc-gallery' && state.data.hash && state.data.state !== 'close') {
2981          self.ignoreStateChange = true;
2982
2983          var $el = self.$container.find('#' + state.data.hash + ', [data-id="' + state.data.hash + '"]').first();
2984
2985          if (self.popupIsOpened) {
2986            if (self.popupType == 'pretty-photo' && this.$prettyPhoto) {
2987              var href = $el.attr('href'),
2988                index = this.$prettyPhoto.getImagesList().indexOf(href);
2989              this.$prettyPhoto.changePage(index);
2990            }
2991
2992            if (self.popupType == 'colorbox') {
2993              $.colorbox.resizeResponsive($el);
2994            }
2995
2996            if (self.popupType == 'photobox') {
2997              var images = window._photobox.getImages(),
2998                href = $el.attr('href');
2999
3000              for (var i = 0; i < images.length; i++) {
3001                if (images[i][0] == href || images[i][0] == 'http:' + href || images[i][0] == 'https:' + href) {
3002                  window._photobox.changeImage(i);
3003                }
3004              }
3005            }
3006          } else {
3007            $el.trigger('click');
3008          }
3009        }
3010      }
3011    });
3012
3013    //check url and show popups
3014    //options "Open by link in popup"
3015    function checkUrl() {
3016      var hash = window.location.hash,
3017        matches = openByLinkRegexp.exec(hash);
3018
3019      if (matches) {
3020        History.replaceState(
3021          {
3022            type: 'sc-gallery',
3023            hash: '',
3024            state: 'hashchange',
3025          },
3026          document.title,
3027          window.location.pathname
3028        );
3029
3030        var position = matches[2] ? 'eq(' + (matches[2] - 1) + ')' : 'first';
3031        self.$container.find('.gg-link:' + position + ', .hi-icon:' + position).trigger('click');
3032      }
3033    }
3034
3035    $(window).on('hashchange', function (event) {
3036      checkUrl();
3037    });
3038
3039    $(document).ready(function () {
3040      checkUrl();
3041    });
3042
3043    //}, this));
3044
3045    $(window).on(
3046      'resize',
3047      $.proxy(function () {
3048        this.correctMargin();
3049        this.resizeHorizontalElements();
3050        this.initHorizontalMode();
3051      }, this)
3052    );
3053  };
3054
3055  Gallery.prototype.resizeHorizontalElements = function () {
3056    var self = this;
3057    if (this.$container.data('gridType') == 2 && this.$elements) {
3058      this.$elements.each(function () {
3059        var element = $(this),
3060          image = element.find('img');
3061        if (image) {
3062          self.resizeElementHeight(image, element);
3063        }
3064      });
3065    }
3066  };
3067
3068  Gallery.prototype.resizeElementHeight = function (image, element) {
3069    var imageHeight = parseInt(image.css('height'));
3070    if (!isNaN(imageHeight) && !element.hasClass('initialized')) {
3071      element.css('height', Math.floor(imageHeight - 1) + 'px');
3072    }
3073    if (!image.hasClass('ggLazyImg')) {
3074      image.removeClass('ggNotInitImg');
3075      this.polaroidCaptionCalculate(element);
3076    }
3077  };
3078
3079  window.initGridGallery = function (el, autoInit) {
3080    var makeSelector = function (el) {
3081      return '#' + el.id;
3082    };
3083    return new Gallery(makeSelector(el), autoInit);
3084  };
3085
3086  window.contentLoaded = function () {
3087    var $galleries = $(".grid-gallery:not('.initialized')"),
3088      $promise = new $.Deferred().resolve();
3089
3090    if ($galleries.length > 0) {
3091      $.each($galleries, function (i, el) {
3092        $promise = $promise.then(function () {
3093          return new Gallery(el, true);
3094        });
3095      });
3096    }
3097
3098    $('.crop').css('display', 'block');
3099  };
3100
3101  if (!init) {
3102    var hammer = new Hammer_gg(document),
3103      $anyGallery = $('.grid-gallery:first'),
3104      isMobile = parseInt($anyGallery.attr('data-is-mobile'));
3105    // only if mobile, because "mouse dragg" include for this event
3106    if (!isNaN(isMobile) && isMobile) {
3107      // On swipe click next prev button in active popup
3108      hammer.on('swipeleft swiperight', function (event) {
3109        if (event.type == 'swipeleft') {
3110          $('#colorbox:visible #cboxNext, .pp_pic_holder a.pp_arrow_next, #cboxOverlay:visible #pbNextBtn').click();
3111        } else {
3112          $('#colorbox:visible #cboxPrevious, .pp_pic_holder a.pp_arrow_previous, #cboxOverlay:visible #pbPrevBtn').click();
3113        }
3114      });
3115    }
3116    init = true;
3117  }
3118
3119  $(document)
3120    .ready(function () {
3121      contentLoaded();
3122    })
3123    .ajaxComplete(function () {
3124      contentLoaded();
3125    });
3126
3127  if (jQuery('body').hasClass('oceanwp-theme')) {
3128    function oceanwpFixedFooter() {
3129      $('#main').css('min-height', '0px');
3130    }
3131    jQuery(window).resize(function () {
3132      oceanwpFixedFooter();
3133    });
3134    jQuery(document).ready(function () {
3135      setTimeout(function () {
3136        oceanwpFixedFooter();
3137      }, 3000);
3138    });
3139  }
3140
3141  // added Gallery initialization by trigger
3142  $(document).on('ggFirInitialize', function () {
3143    contentLoaded();
3144  });
3145
3146  (function initThumbnailDescriptionTooltip() {
3147    var $tooltip = $('<div class="gg-thumbnail-description-tooltip" role="tooltip">').appendTo('body').hide();
3148
3149    function placeTooltip($trigger) {
3150      var text = $trigger.attr('data-tooltip') || '';
3151      var offset = $trigger.offset();
3152      var left;
3153      var top;
3154
3155      if (!text || !offset) {
3156        $tooltip.hide();
3157        return;
3158      }
3159
3160      $tooltip.text(text).show();
3161      left = offset.left + $trigger.outerWidth() / 2 - $tooltip.outerWidth() / 2;
3162      top = offset.top - $tooltip.outerHeight() - 10;
3163
3164      left = Math.max(8, Math.min(left, $(window).scrollLeft() + $(window).width() - $tooltip.outerWidth() - 8));
3165      if (top < $(window).scrollTop() + 8) {
3166        top = offset.top + $trigger.outerHeight() + 10;
3167      }
3168
3169      $tooltip.css({ left: left, top: top });
3170    }
3171
3172    $(document)
3173      .on('mouseenter mouseover focus', '.gg-thumbnail-description-help', function () {
3174        placeTooltip($(this));
3175      })
3176      .on('click touchstart', '.gg-thumbnail-description-help', function (event) {
3177        event.preventDefault();
3178        event.stopPropagation();
3179        placeTooltip($(this));
3180      })
3181      .on('mouseleave blur', '.gg-thumbnail-description-help', function () {
3182        $tooltip.hide();
3183      });
3184
3185    $(window).on('scroll resize', function () {
3186      $tooltip.hide();
3187    });
3188  })();
3189
3190  //if a customer enter an e-mail for image link in gallery he'll get a mailto: link
3191  $('a.gg-link').each(function () {
3192    var gLink = $(this).attr('href');
3193    var reg = /[0-9a-z_]+@[0-9a-z_]+\.[a-z]{2,5}/i;
3194    if (gLink) {
3195      var isEmail = gLink.match(reg);
3196      if (isEmail) {
3197        $(this).attr('href', 'mailto:' + isEmail[0]);
3198      }
3199    }
3200  });
3201
3202  jQuery(document).ready(function () {
3203    jQuery('.supSocialIconBookmarkBtn').click(function () {
3204      alert('Please press Ctrl+D (Cmd+D on Mac) to add this page to your bookmarks.');
3205    });
3206    setTimeout(function () {
3207      jQuery('body')
3208        .find('.supsystic-social-sharing')
3209        .each(function (key, value) {
3210          var summary = 0;
3211          jQuery(this)
3212            .find('.social-sharing-button')
3213            .each(function (key2, value2) {
3214              if (jQuery(this).parent().hasClass('supsystic-social-sharing-popup')) return;
3215              var networks = jQuery(this).attr('data-networks');
3216              networks = jQuery.parseJSON(networks);
3217              var attachId = jQuery('.supsystic-social-sharing').eq(key).closest('[data-attachment-id]').attr('data-attachment-id');
3218              if (typeof attachId != 'undefined') {
3219                var nid = jQuery(this).attr('data-nid');
3220                var counter = networks[attachId][nid];
3221                if (parseInt(counter) && !isNaN(counter)) {
3222                  summary = summary + parseInt(counter);
3223                }
3224                var counterWrapper = '';
3225                if (jQuery(this).hasClass('counter-standard')) {
3226                  jQuery(this).find('.counter-wrap.standard').remove('');
3227                  counterWrapper = '<div class="counter-wrap standard"><span class="counter">' + counter + '</span></div>';
3228                }
3229                if (jQuery(this).hasClass('counter-arrowed')) {
3230                  jQuery(this).find('.counter-wrap.arrowed').remove('');
3231                  counterWrapper = '<div class="counter-wrap arrowed"><span class="counter">' + counter + '</span></div>';
3232                }
3233                if (jQuery(this).hasClass('counter-white-arrowed')) {
3234                  jQuery(this).find('.counter-wrap.white-arrowed').remove('');
3235                  counterWrapper = '<div class="counter-wrap white-arrowed"><span class="counter">' + counter + '</span></div>';
3236                }
3237                var attachId = jQuery(this).append(counterWrapper);
3238              }
3239            });
3240          summary = '<span>Shares</span> <span>' + summary + '</span>';
3241          jQuery(this).closest('a').find('.supsystic-social-sharing-total-counter.counter-wrap').html(summary);
3242        });
3243    }, 1000);
3244  });
3245})(jQuery);

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.