$( window ).resize(function() {
ChooseGallery();
});
$(document).ready(function() {
ChooseGallery();
});
function ChooseGallery(){
var width = $(window).width();
var IS_IPAD = navigator.userAgent.match(/iPad/i) != null;
var IS_IPHONE = (navigator.userAgent.match(/iPhone/i) != null) || (navigator.userAgent.match(/iPod/i) != null);
if (IS_IPAD) { IS_IPHONE = false;}
if ( width <= 1024 || IS_IPAD || IS_IPHONE) {
deviceGallery();
} else {
fullScreenGallery();
}
}
function fullScreenGallery(){
$('#pictures').removeClass('hide');
$('#MobileGallery').removeAttr('style');
$('#MobileGallery').addClass('hide');
(function(e) {
var t = e(window);
TLG.pictures = {
init: function() {
var n = this.$container = e("#pictures-wrap"),
r = this,
i = n.parent().find(".next:first"),
s = n.parent().find(".prev:first"),
o = n.find(".photo");
this.windowWidth = parseFloat(t.width());
var u, a = 440,
f = 248,
l = 640,
c = 480;
o.each(function() {
var t = e(this).find("img").attr("alt");
if (t !== undefined) {
e(this).append('' + t + "")
}
});
var h = o.length * 10 + o.filter(".w1").length * a + o.filter(".w2").length * f + o.filter(".w3").length * 400,
p = function() {
var e = 0;
for (var t = 0; t < o.length; t++) {
e += o.eq(t).hasClass("w1") ? a + 10 : o.eq(t).hasClass("w2") ? f + 10 : 410;
if (e >= h / 2) return e
}
};
this.tiledWidth = p();
this.largeWidth = o.length * 20 + o.filter(".w1").length * l + o.filter(".w2").length * c + o.filter(".w3").length * 800;
this.currentWidth = TLG.isTablet ? this.largeWidth : this.tiledWidth;
n.css({
width: r.currentWidth + "px"
});
this.minLeft = this.windowWidth - this.currentWidth;
t.resize(function() {
r.resize()
});
if (TLG.isTablet) {
n.css("visibility", "visible");
n.owlCarousel({
navigation: !0,
slideSpeed: 300,
paginationSpeed: 400,
singleItem: !0
})
} else {
n.isotope({
itemSelector: ".photo",
layoutMode: "fitRows",
containerStyle: null,
getSortData: {
category: "[data-category]"
}
});
n.isotope("once", "layoutComplete", function() {
n.css("visibility", "visible")
});
n.isotope("layout")
}
n.find("img.lazyload").unveil(800, function() {
var t = e('
').appendTo(e(this).parent());
e(this).load(function() {
t.remove()
})
});
var d = function() {
n.addClass("pictures-large");
if ( $('#content-section > div').hasClass('container')){
n.addClass("test");
}
n.css({
width: r.largeWidth + "px"
});
r.currentWidth = r.largeWidth;
r.resize();
n.isotope("layout");
v.show()
};
if (!TLG.isMobile) {
var v = e("#pictures-contols nav");
v.hide();
if (v.find('ul').length == 0){
v.append("");
o.each(function(t) {
var n = e(this).data("category"),
r = v.find("li[data-controls=" + n + "]");
r.length || v.find("ul").append('- ' + n + "
")
});
if (v.find("ul").find('li').hasClass('pictures-tiled')){
} else {
v.find("ul").append('- Tiled
');
}
}
u = e("#pictures-contols nav li")
}
TLG.isMobile || e("#pictures-tiled").on("click", function() {
n.removeClass("pictures-large");
n.css({
width: r.tiledWidth + "px"
});
r.currentWidth = r.tiledWidth;
r.resize();
n.css("left", "0px");
n.isotope("layout");
u.removeClass("active").eq(0).addClass("active");
v.hide()
});
o.click(function() {
var t = e(this),
i;
if (!TLG.isMobile) {
o.removeClass("active");
t.addClass("active")
}
if (n.is(".pictures-large")) {
i = -(parseFloat(t.position().left) - r.windowWidth / 2 + parseFloat(t.width()) / 2);
n.css("left", i + "px")
}
if (n.is(".pictures-large.test")) {
i = -(parseFloat(t.position().left) - r.windowWidth / 2 + parseFloat(t.width()) / 1.16);
n.css("left", i + "px")
}
else {
d();
setTimeout(function() {
i = -(parseFloat(t.position().left) - r.windowWidth / 2 + parseFloat(t.width()) / 2);
if (n.is(".pictures-large")) {
n.css("left", i + "px")
}
if (n.is(".pictures-large.test")) {
n.css("left", i/2 + "px")
}
}, 750)
}
});
i.on("click", function() {
if (!TLG.isMobile && o.filter(".active").length && n.hasClass("pictures-large")) o.filter(".active").next().click();
else {
var e = 300 > r.windowWidth * .33 ? 300 : r.windowWidth * .33,
t = parseFloat(n.css("left")) - e;
t = Math.abs(r.minLeft) < Math.abs(t) ? r.minLeft : t;
n.css("left", t + "px")
}
});
s.on("click", function() {
if (!TLG.isMobile && n.hasClass("pictures-large")) o.filter(".active").prev().click();
else {
var e = 300 > r.windowWidth * .33 ? 300 : r.windowWidth * .33,
t = parseFloat(n.css("left")) + e;
t = t < 0 ? t : 0;
n.css("left", t + "px")
}
});
/*TLG.isTablet || u.click(function(t) {
if (!e(this).is("#pictures-tiled")) {
t.preventDefault();
o.filter("[data-category=" + e(this).data("controls") + "]:first").click()
}
})*/
},
resize: function() {
this.windowWidth = parseFloat(t.width());
this.minLeft = this.windowWidth - this.currentWidth;
this.maxLeft = 0;
this.$container.not(".pictures-large") || Math.abs(parseFloat(this.$container.css("left"))) > Math.abs(this.minLeft) && this.$container.css("left", this.minLeft + "px")
}
}
})(jQuery);
(function(e) {
var t;
if (TLG.isTablet) {
var n = e("#pictures-wrap");
n.css("visibility", "visible").addClass("pictures-full");
n.find(".lazyload").removeAttr("src").addClass("lazyOwl");
var r = parseFloat(e(window).height());
n.height(r + "px");
t = new TLG.Loader;
t.require(["http://templates.yardirportal.net/cases/tiled-gallery/js/carousel.min.js"], function() {
n.owlCarousel({
slideSpeed: 300,
paginationSpeed: 400,
singleItem: !0,
lazyLoad: !0,
pagintation: !1
});
var e = n.data("owlCarousel");
n.parent().find(".next").click(function(t) {
console.log(e);
e.next()
});
n.parent().find(".prev").click(function(t) {
e.prev()
})
})
} else {
t = new TLG.Loader;
t.require(["http://templates.yardirportal.net/cases/tiled-gallery/js/isotope.js"], function() {
TLG.pictures.init()
})
}
})(jQuery, window, document);
}
function deviceGallery() {
$('#pictures').addClass('hide');
$('#MobileGallery').attr('style','opacity: 1; display:block');
if ($('#MobileGallery').children().length == 0){
var allImages = $("#pictures-wrap img").map(function() {
return $(this).attr("src");
}).get();
for (i = 0; i < allImages.length; i++) {
var myImage = new Image();
myImage.src = allImages[i];
$('#MobileGallery').append(myImage);
}
}
$("#MobileGallery").owlCarousel({
itemsTablet : [768, 1],
singleItem : true,
navigation : true,
slideSpeed : 300,
paginationSpeed : 400
});
}