(function($,window,undefined){$.fn.backstretch=function(images,options){if(images===undefined||images.length===0)$.error("No images were supplied for Backstretch");if($(window).scrollTop()===0)window.scrollTo(0,0);return this.each(function(){var $this=$(this),obj=$this.data("backstretch");if(obj){options=$.extend(obj.options,options);obj.destroy(true)}obj=new Backstretch(this,images,options);$this.data("backstretch",obj)})};$.backstretch=function(images,options){return $("body").backstretch(images,
options).data("backstretch")};$.expr[":"].backstretch=function(elem){return $(elem).data("backstretch")!==undefined};$.fn.backstretch.defaults={centeredX:true,centeredY:true,duration:5E3,fade:0};var styles={wrap:{left:0,top:0,overflow:"hidden",margin:0,padding:0,height:"100%",width:"100%",zIndex:-999999},img:{position:"absolute",display:"none",margin:0,padding:0,border:"none",width:"auto",height:"auto",maxWidth:"none",zIndex:-999999}};var Backstretch=function(container,images,options){this.options=
$.extend({},$.fn.backstretch.defaults,options||{});this.images=$.isArray(images)?images:[images];$.each(this.images,function(){$("")[0].src=this});this.isBody=container===document.body;this.$container=$(container);this.$root=this.isBody?supportsFixedPosition?$(window):$(document):this.$container;var $existing=this.$container.children(".backstretch").first();this.$wrap=$existing.length?$existing:$('
').css(styles.wrap).appendTo(this.$container);if(!this.isBody){var position=
this.$container.css("position"),zIndex=this.$container.css("zIndex");this.$container.css({position:position==="static"?"relative":position,zIndex:zIndex==="auto"?0:zIndex,background:"none"});this.$wrap.css({zIndex:-999998})}this.$wrap.css({position:this.isBody&&supportsFixedPosition?"fixed":"absolute"});this.index=0;this.show(this.index);$(window).on("resize.backstretch",$.proxy(this.resize,this)).on("orientationchange.backstretch",$.proxy(function(){if(this.isBody&&window.pageYOffset===0){window.scrollTo(0,
1);this.resize()}},this))};Backstretch.prototype={resize:function(){try{var bgCSS={left:0,top:0},rootWidth=this.isBody?this.$root.width():this.$root.innerWidth(),bgWidth=rootWidth,rootHeight=this.isBody?window.innerHeight?window.innerHeight:this.$root.height():this.$root.innerHeight(),bgHeight=bgWidth/this.$img.data("ratio"),bgOffset;if(bgHeight>=rootHeight){bgOffset=(bgHeight-rootHeight)/2;if(this.options.centeredY)bgCSS.top="-"+bgOffset+"px"}else{bgHeight=rootHeight;bgWidth=bgHeight*this.$img.data("ratio");
bgOffset=(bgWidth-rootWidth)/2;if(this.options.centeredX)bgCSS.left="-"+bgOffset+"px"}this.$wrap.css({width:rootWidth,height:rootHeight}).find("img:not(.deleteable)").css({width:bgWidth,height:bgHeight}).css(bgCSS)}catch(err){}return this},show:function(index){if(Math.abs(index)>this.images.length-1)return;else this.index=index;var self=this,oldImage=self.$wrap.find("img").addClass("deleteable"),evt=$.Event("backstretch.show",{relatedTarget:self.$container[0]});clearInterval(self.interval);self.$img=
$("").css(styles.img).bind("load",function(e){var imgWidth=this.width||$(e.target).width(),imgHeight=this.height||$(e.target).height();$(this).data("ratio",imgWidth/imgHeight);$(this).fadeIn(self.options.speed||self.options.fade,function(){oldImage.remove();if(!self.paused)self.cycle();self.$container.trigger(evt,self)});self.resize()}).appendTo(self.$wrap);self.$img.attr("src",self.images[index]);return self},next:function(){return this.show(this.index1){clearInterval(this.interval);this.interval=setInterval($.proxy(function(){if(!this.paused)this.next()},this),this.options.duration)}return this},destroy:function(preserveBackground){$(window).off("resize.backstretch orientationchange.backstretch");clearInterval(this.interval);
if(!preserveBackground)this.$wrap.remove();this.$container.removeData("backstretch")}};var supportsFixedPosition=function(){var ua=navigator.userAgent,platform=navigator.platform,wkmatch=ua.match(/AppleWebKit\/([0-9]+)/),wkversion=!!wkmatch&&wkmatch[1],ffmatch=ua.match(/Fennec\/([0-9]+)/),ffversion=!!ffmatch&&ffmatch[1],operammobilematch=ua.match(/Opera Mobi\/([0-9]+)/),omversion=!!operammobilematch&&operammobilematch[1],iematch=ua.match(/MSIE ([0-9]+)/),ieversion=!!iematch&&iematch[1];return!((platform.indexOf("iPhone")>
-1||(platform.indexOf("iPad")>-1||platform.indexOf("iPod")>-1))&&(wkversion&&wkversion<534)||(window.operamini&&{}.toString.call(window.operamini)==="[object OperaMini]"||(operammobilematch&&omversion<7458||(ua.indexOf("Android")>-1&&(wkversion&&wkversion<533)||(ffversion&&ffversion<6||("palmGetResource"in window&&(wkversion&&wkversion<534)||(ua.indexOf("MeeGo")>-1&&ua.indexOf("NokiaBrowser/8.5.0")>-1||ieversion&&ieversion<=6)))))))}()})(jQuery,window);/****** Premium Media Grid Handler ******/
(function ($) {
$(window).on('elementor/frontend/init', function () {
var PremiumGridWidgetHandler = elementorModules.frontend.handlers.Base.extend({
settings: {},
getDefaultSettings: function () {
return {
selectors: {
galleryElement: '.premium-gallery-container',
filters: '.premium-gallery-cats-container li',
gradientLayer: '.premium-gallery-gradient-layer',
loadMore: '.premium-gallery-load-more',
loadMoreDiv: '.premium-gallery-load-more div',
vidWrap: '.premium-gallery-video-wrap',
}
}
},
getDefaultElements: function () {
var selectors = this.getSettings('selectors'),
elements = {
$galleryElement: this.$element.find(selectors.galleryElement),
$filters: this.$element.find(selectors.filters),
$gradientLayer: this.$element.find(selectors.gradientLayer),
$vidWrap: this.$element.find(selectors.vidWrap)
};
elements.$loadMore = elements.$galleryElement.parent().find(selectors.loadMore)
elements.$loadMoreDiv = elements.$galleryElement.parent().find(selectors.loadMoreDiv)
return elements;
},
bindEvents: function () {
this.getGlobalSettings();
this.run();
var self = this;
$(document).on('elementor/popup/show', function () {
self.run();
});
},
getGlobalSettings: function () {
var $galleryElement = this.elements.$galleryElement,
settings = $galleryElement.data('settings');
this.settings = {
layout: settings.img_size,
loadMore: settings.load_more,
columnWidth: null,
filter: null,
isFilterClicked: false,
minimum: settings.minimum,
imageToShow: settings.click_images,
counter: settings.minimum,
ltrMode: settings.ltr_mode,
shuffle: settings.shuffle,
active_cat: settings.active_cat,
theme: settings.theme,
overlay: settings.overlay,
sort_by: settings.sort_by,
light_box: settings.light_box,
flag: settings.flag,
lightbox_type: settings.lightbox_type
}
},
updateCounter: function () {
if (this.settings.isFilterClicked) {
this.settings.counter = this.settings.minimum;
this.settings.isFilterClicked = false;
} else {
this.settings.counter = this.settings.counter;
}
this.settings.counter = this.settings.counter + this.settings.imageToShow;
},
updateGrid: function (gradHeight, $isotopeGallery, $loadMoreDiv) {
$.ajax({
url: this.appendItems(this.settings.counter, gradHeight, $isotopeGallery),
beforeSend: function () {
$loadMoreDiv.removeClass("premium-gallery-item-hidden");
},
success: function () {
$loadMoreDiv.addClass("premium-gallery-item-hidden");
}
});
},
loadMore: function (gradHeight, $isotopeGallery) {
var $galleryElement = this.elements.$galleryElement,
$loadMoreDiv = this.elements.$loadMoreDiv,
$loadMore = this.elements.$loadMore,
_this = this;
$loadMoreDiv.addClass("premium-gallery-item-hidden");
if ($galleryElement.find(".premium-gallery-item").length > this.settings.minimum) {
$loadMore.removeClass("premium-gallery-item-hidden");
$galleryElement.parent().on("click", ".premium-gallery-load-less", function () {
_this.settings.counter = _this.settings.counter - _this.settings.imageToShow;
});
$galleryElement.parent().on("click", ".premium-gallery-load-more-btn:not(.premium-gallery-load-less)", function () {
_this.updateCounter();
_this.updateGrid(gradHeight, $isotopeGallery, $loadMoreDiv);
});
}
},
getItemsToHide: function (instance, imagesToShow) {
var items = instance.filteredItems.slice(imagesToShow, instance
.filteredItems.length).map(function (item) {
return item.element;
});
return items;
},
appendItems: function (imagesToShow, gradHeight, $isotopeGallery) {
var $galleryElement = this.elements.$galleryElement,
$gradientLayer = this.elements.$gradientLayer,
instance = $galleryElement.data("isotope"),
itemsToHide = this.getItemsToHide(instance, imagesToShow);
$gradientLayer.outerHeight(gradHeight);
$galleryElement.find(".premium-gallery-item-hidden").removeClass("premium-gallery-item-hidden");
$galleryElement.parent().find(".premium-gallery-load-more").removeClass("premium-gallery-item-hidden");
$(itemsToHide).addClass("premium-gallery-item-hidden");
$isotopeGallery.isotope("layout");
if (0 == itemsToHide) {
$gradientLayer.addClass("premium-gallery-item-hidden");
$galleryElement.parent().find(".premium-gallery-load-more").addClass("premium-gallery-item-hidden");
}
},
triggerFilerTabs: function (url) {
var filterIndex = url.searchParams.get(this.settings.flag),
$filters = this.elements.$filters;
if (filterIndex) {
var $targetFilter = $filters.eq(filterIndex).find("a");
$targetFilter.trigger('click');
}
},
onReady: function ($isotopeGallery) {
var _this = this;
$isotopeGallery.isotope("layout");
// $isotopeGallery.isotope({
// filter: _this.settings.active_cat
// });
var url = new URL(window.location.href);
if (url)
_this.triggerFilerTabs(url);
//Show the widget after making sure everything is ready.
_this.$element.find(".category.active").trigger('click');
_this.$element.find(".elementor-invisible").removeClass("elementor-invisible");
},
onResize: function ($isotopeGallery) {
var _this = this;
_this.setMetroLayout();
$isotopeGallery.isotope({
itemSelector: ".premium-gallery-item",
masonry: {
columnWidth: _this.settings.columnWidth
},
});
},
lightBoxDisabled: function () {
var _this = this,
$vidWrap = this.elements.$vidWrap;
$vidWrap.each(function (index, item) {
var type = $(item).data("type");
$(".pa-gallery-video-icon").keypress(function () {
$(this).closest(".premium-gallery-item").trigger('click');
});
$(item).closest(".premium-gallery-item").on("click", function () {
var $this = $(this);
$this.find(".pa-gallery-img-container").css("background", "#000");
$this.find("img, .pa-gallery-icons-caption-container, .pa-gallery-icons-wrapper").css("visibility", "hidden");
if ("style3" !== _this.settings.skin)
$this.find(".premium-gallery-caption").css("visibility", "hidden");
if ("hosted" !== type) {
_this.playVid($this);
} else {
_this.playHostedVid(item);
}
});
});
},
playVid: function ($this) {
var $iframeWrap = $this.find(".premium-gallery-iframe-wrap"),
src = $iframeWrap.data("src");
src = src.replace("&mute", "&autoplay=1&mute");
var $iframe = $("");
$iframe.attr({
"src": src,
"frameborder": "0",
"allowfullscreen": "1",
"allow": "autoplay;encrypted-media;"
});
$iframeWrap.html($iframe);
$iframe.css("visibility", "visible");
},
playHostedVid: function (item) {
var $video = $(item).find("video");
$video.get(0).play();
$video.css("visibility", "visible");
},
run: function () {
var $galleryElement = this.elements.$galleryElement,
$vidWrap = this.elements.$vidWrap,
$filters = this.elements.$filters,
_this = this;
if ('metro' === this.settings.layout) {
this.setMetroLayout();
this.settings.layout = "masonry";
$(window).resize(function () { _this.onResize($isotopeGallery); });
}
var $isotopeGallery = $galleryElement.isotope(this.getIsoTopeSettings());
$isotopeGallery.imagesLoaded().progress(function () {
$isotopeGallery.isotope("layout");
});
$(document).ready(function () { _this.onReady($isotopeGallery); });
if (this.settings.loadMore) {
var $gradientLayer = this.elements.$gradientLayer,
gradHeight = null;
setTimeout(function () {
gradHeight = $gradientLayer.outerHeight();
}, 200);
this.loadMore(gradHeight, $isotopeGallery);
}
if ("yes" !== this.settings.light_box)
this.lightBoxDisabled();
$filters.find("a").click(function (e) {
e.preventDefault();
_this.isFilterClicked = true;
$filters.find(".active").removeClass("active");
$(this).addClass("active");
_this.settings.filter = $(this).attr("data-filter");
$isotopeGallery.isotope({
filter: _this.settings.filter
});
if (_this.settings.shuffle) $isotopeGallery.isotope("shuffle");
if (_this.settings.loadMore) _this.appendItems(_this.settings.minimum, gradHeight, $isotopeGallery);
return false;
});
if ("default" === this.settings.lightbox_type)
this.$element.find(".premium-img-gallery a[data-rel^='prettyPhoto']").prettyPhoto(this.getPrettyPhotoSettings());
},
getPrettyPhotoSettings: function () {
return {
theme: this.settings.theme,
hook: "data-rel",
opacity: 0.7,
show_title: false,
deeplinking: false,
overlay_gallery: this.settings.overlay,
custom_markup: "",
default_width: 900,
default_height: 506,
social_tools: ""
}
},
getIsoTopeSettings: function () {
return {
itemSelector: '.premium-gallery-item',
percentPosition: true,
animationOptions: {
duration: 750,
easing: 'linear'
},
filter: this.settings.active_cat,
layoutMode: this.settings.layout,
originLeft: this.settings.ltrMode,
masonry: {
columnWidth: this.settings.columnWidth
},
sortBy: this.settings.sort_by
}
},
getRepeaterSettings: function () {
return this.getElementSettings('premium_gallery_img_content');
},
setMetroLayout: function () {
var $galleryElement = this.elements.$galleryElement,
gridWidth = $galleryElement.width(),
cellSize = Math.floor(gridWidth / 12),
deviceType = elementorFrontend.getCurrentDeviceMode(),
suffix = 'desktop' === deviceType ? '' : '_' + deviceType,
repeater = this.getRepeaterSettings();
$galleryElement.find(".premium-gallery-item").each(function (index, item) { //should be added to selectors and elements
var cells = repeater[index]['premium_gallery_image_cell' + suffix].size,
vCells = repeater[index]['premium_gallery_image_vcell' + suffix].size;
if ("" === cells || undefined == cells) {
cells = repeater[index].premium_gallery_image_cell;
}
if ("" === vCells || undefined == vCells) {
vCells = repeater[index].premium_gallery_image_vcell;
}
$(item).css({
width: Math.ceil(cells * cellSize),
height: Math.ceil(vCells * cellSize)
});
});
this.settings.columnWidth = cellSize;
}
});
elementorFrontend.elementsHandler.attachHandler('premium-img-gallery', PremiumGridWidgetHandler);
});
})(jQuery);