PageSourceSearch

https://www.lup-ag.de/wp-content/plugins/gallery-by-supsystic/src/…/assets/js/frontend.js?ver=1.15.29

js lup-ag.de collected 2026-10-05 19:18:03 UTC 104,660 bytes, 2,863 lines download raw bytes

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

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.