jQuery(document).ready(function() {
setTimeout(function() {
window.fbAsyncInit = function() {
FB.init({
appId: '113522725337988',
status: true,
xfbml: true
});
};
(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) {
return;
}
js = d.createElement(s);
js.id = id;
js.src = "//connect.facebook.net/en_US/all.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
}, 3000);
$('.change-language-js').on('change', function(e) {
e.preventDefault();
e.stopPropagation();
document.location.href = $(this).val();
});
$('.close-modal-js').on('click', function() {
$('.modal').modal('hide');
});
$('.btn-show-modal-js').on('click', function() {
$('.modal .after-submit').hide();
$('.modal .hide-on-sent').show();
$('.painting_id').val($(this).data('id'));
$('.js-question-painting-name').html($(this).data('title'));
$('.modal').modal('show');
return false;
});
$('.btn-submit-query').on('click', function(e) {
if ($('#questionform-email').val() != '') {
$('.modal .hide-on-sent').hide();
$('.modal .after-submit').show();
$.post( "/site/question/", $('#question-form').serializeArray())
.done(function( data ) {
return false;
});
return false;
}
});
$(document).on('scroll', function() {
if ($(window).scrollTop() > 400) {
$('.back-to-top').fadeIn(1000);
} else {
$('.back-to-top').fadeOut(1000);
}
});
$('.filter-btn').on('click', function(e) {
e.preventDefault();
e.stopPropagation();
return false;
});
$('#date-range-filter').on('click', function() {
$('#date-filter-input').val($('#reportrange span').html());
});
$('#price-range-filter').on('click', function() {
//$('#price-filter-input').val($('#amount').val($('#amount-text').html()));
});
$('.fb-btn').click(function(e) {
var $this = $(this);
e.preventDefault();
FB.ui({
method: 'feed',
name: $this.data("name"),
link: $this.data("url"),
picture: $this.data("picture"),
caption: $this.data("description"),
description: $this.data("description"),
message: ''
});
});
$('.fb-btn-fav-user').click(function(e) {
var $this = $(this);
e.preventDefault();
FB.ui({
method: 'feed',
name: $this.data("name"),
link: $this.data("url"),
picture: $this.data("picture"),
caption: $this.data("description"),
description: $this.data("description"),
message: ''
});
});
$('.uncheck-all').on('click', function() {
$(this).parent().find('.form-check-input').prop('checked', false);
});
$('.show-popular-sub-menu').on('click', function() {
$('.popular-sub-menu').toggle();
});
$(document).on('click', '.box-faq-title', function(e) {
e.preventDefault();
e.stopPropagation();
$(this).parent().find('.box-faq-content').toggle();
return false;
});
// autocomplete
function autocompleteSearch(inp, arr) {
var currentFocus;
inp.addEventListener("input", function(e) {
var a, b, i, val = this.value;
closeAllListsSearch();
if (!val) { return false;}
currentFocus = -1;
a = document.createElement("DIV");
a.setAttribute("id", this.id + "autocomplete-list");
a.setAttribute("class", "autocomplete-items");
a.setAttribute("tabindex", "2");
this.parentNode.appendChild(a);
listElement = document.createElement("UL");
a.appendChild(listElement);
const letters = ['ą', 'ć', 'ę', 'ł', 'ń', 'ó', 'ś', 'ź', 'ż'];
const replacement = ['a', 'c', 'e', 'l', 'n', 'o', 's', 'z', 'z'];
let counter = 0;
for (i = 0; i < arr.length; i++) {
let nameNoPl = arr[i]["name"].toLocaleLowerCase();
let valNoPl = val;
for (let z = 0; z < letters.length; ++z) {
nameNoPl = nameNoPl.replaceAll(letters[z], replacement[z]);
valNoPl = valNoPl.replaceAll(letters[z], replacement[z]);
}
if (nameNoPl.toUpperCase().indexOf(valNoPl.toUpperCase()) !== -1) {
let index = nameNoPl.toUpperCase().indexOf(valNoPl.toUpperCase());
let name = arr[i]['name'].substring(0, index)+""+arr[i]['name'].substring(index, index+valNoPl.length)+""+arr[i]['name'].substring(index+valNoPl.length);
b = document.createElement("LI");
//if (counter == 0) {
// b.classList.add('js-hover');
//}
b.innerHTML = ""+name+"";
b.innerHTML += "";
b.addEventListener("click", function(e) {
inp.value = this.getElementsByTagName("input")[0].value;
closeAllListsSearch();
});
listElement.appendChild(b);
counter++;
}
}
});
function closeAllListsSearch(elmnt) {
var x = document.getElementsByClassName("autocomplete-items");
for (var i = 0; i < x.length; i++) {
if (elmnt != x[i] && elmnt != inp) {
x[i].parentNode.removeChild(x[i]);
}
}
}
document.addEventListener("click", function (e) {
closeAllListsSearch(e.target);
});
}
/*An array containing all the country names in the world:*/
$.ajax({
url: '/ajax/artists/?type=1&lang='+$('html').attr('lang'),
type: 'get',
dataType: 'json',
success: function(data) {
autocompleteSearch(document.getElementById("search-query"), data);
},
error: function() {
}
});
$('#search-query').on('keydown', function(ev) {
let activeDiv = $(document).find("#search-queryautocomplete-list .js-hover");
var keycode = (ev.keyCode ? ev.keyCode : ev.which);
if (activeDiv.length == 0) {
activeDiv = $(document).find("#search-queryautocomplete-list li:first-child");
if (keycode == 40) {
ev.stopPropagation();
ev.preventDefault();
activeDiv.addClass('js-hover');
return false;
}
}
if (keycode == 13) {
activeDiv = $(document).find("#search-queryautocomplete-list .js-hover");
if (activeDiv.length > 0) {
ev.stopPropagation();
ev.preventDefault();
document.location.href = activeDiv.find('a').attr('href');
}
return true;
}
if (keycode == 38) {
ev.stopPropagation();
ev.preventDefault();
let prevPosition = $(document).find("#search-queryautocomplete-list .js-hover").prev();
if (prevPosition.length > 0) {
prevPosition.addClass('js-hover');
activeDiv.removeClass('js-hover');
$('#search-queryautocomplete-list').scrollTop(0).scrollTop($('.js-hover').position().top);
}
}
else if (keycode == 40) {
ev.stopPropagation();
ev.preventDefault();
let nextPosition = $(document).find("#search-queryautocomplete-list .js-hover").next();
if (nextPosition.length > 0) {
nextPosition.addClass('js-hover');
activeDiv.removeClass('js-hover');
$('#search-queryautocomplete-list').scrollTop(0).scrollTop($('.js-hover').position().top);
}
}
return true;
});
});