'use strict';
/*
Version: 2019/35
Author: AVIZO, a.s. http://www.avizo.cz
*/
/* <----------------------------------------------------------------------------------------------------------- */
/* <----- DEFAULT SETTINGS ----------------------------------------------------------------------------------- */
/* <----------------------------------------------------------------------------------------------------------- */
var widhtWindow = parseInt( $(window).width() );
var heightWindow = parseInt( $(window).height() );
var lokalita_conf = {
"item" : "lokalita_search",
"item_id" : "lokalita_id"
};
$(document).ready(function(){
/* strankovani VIP */
$( document ).on( "swipeleft swiperight", ".vip-list-slider", function( event ) {
if ( event.type == 'swipeleft' )
{
var newPage = parseInt($('#VIPpage').val())+1;
if ( newPage > $('#VIPpages').val() )
{
newPage = 1;
}
}
else
{
var newPage = parseInt($('#VIPpage').val())-1;
if ( newPage < 1 )
{
newPage = $('#VIPpages').val();
}
}
$('#VIPpage').val(newPage);
$.ajax({
type: 'post',
data: { page: newPage, pages: $('#VIPpages').val(), ids: $('#VIPids').val(),rubrikaId: $("#rubrikaId").val(), rand: Math.random()},
url: '/vipSlider.php',
success: function( response ) {
//$('#VIPactualPage').text('');
//$('#VIPactualPage').text($('#VIPpage').val());
$('.vip-list-slider-item').html(response);
$('.vip-list-slider').slick('unslick');
$('.vip-list-slider').slick({
dots: false,
arrows: false,
prevArrow: '
',
nextArrow: '
',
infinite: true,
fade: false,
cssEase: 'ease-in',
autoplay: false,
pauseOnFocus: true,
swipe: false,
slidesToShow: 1,
slidesToScroll: 1
});
}
});
});
$(document).on('click',"#VIPprev, #VIPnext", function(event){
event.preventDefault();
if ( $(this).attr('id') == 'VIPnext' )
{
var newPage = parseInt($('#VIPpage').val())+1;
if ( newPage > $('#VIPpages').val() )
{
newPage = 1;
}
}
else
{
var newPage = parseInt($('#VIPpage').val())-1;
if ( newPage < 1 )
{
newPage = $('#VIPpages').val();
}
}
$('#VIPpage').val(newPage);
$.ajax({
type: 'post',
data: { page: newPage, pages: $('#VIPpages').val(), ids: $('#VIPids').val(),rubrikaId: $("#rubrikaId").val(), rand: Math.random()},
url: '/vipSlider.php',
success: function( response ) {
//$('#VIPactualPage').text('');
//$('#VIPactualPage').text($('#VIPpage').val());
$('.vip-list-slider-item').html(response);
$('.vip-list-slider').slick('unslick');
$('.vip-list-slider').slick({
dots: false,
arrows: false,
prevArrow: '
',
nextArrow: '
',
infinite: true,
fade: false,
cssEase: 'ease-in',
autoplay: false,
pauseOnFocus: true,
swipe: false,
slidesToShow: 1,
slidesToScroll: 1
});
$.imgLazy();
}
});
});
/* PES */
$(document).on('click',"#pesSave", function(e)
{
e.preventDefault();
var email = $("#pesEmail").val();
if ( validateEmail($("#pesEmail").val()) == false )
{
alert("Email není ve správném formátu.");
return false;
}
var name = ($("#pesName").val()).trim();
if ( name == '' )
{
alert("Zadejte název hlídacího psa.");
return false;
}
var get = $("#pesGet").val();
if ( $("#pesGet").val() == '' )
{
alert("Prázdný filtr nelze uložit.");
return false;
}
$.ajax({
type: "POST",
url: "/psi/",
data: { name: name, "new": "1", pes: "1", email: email, get: get, rubrika: $("#rubrikaId").val()}
}).done(function( msg ) {
var status = msg.substring(0, 2);
var message = msg.substring(2, msg.length);
if ( status == "OK" ) {
$("#avizoPesForm").hide();
$("#pesMessage").text('');
$("#pesMessage").append(message);
$("#pesMessage").show();
ga.push(['_trackEvent', 'vypis_inzeratu', 'hlidaci_pes']);
}
else
{
alert("Chyba: " + msg);
}
});
});
/* <--------------------------------------------------------------------------------------------------- */
/* <----- SLIDERY ------------------------------------------------------------------------------------- */
/* <--------------------------------------------------------------------------------------------------- */
$( '.ntip-slider' ).slick({
dots: true,
arrows: true,
prevArrow: '
',
nextArrow: '
',
infinite: true,
fade: false,
cssEase: 'ease-in',
autoplay: false,
pauseOnFocus: true,
swipe: true,
slidesToShow: 2,
slidesToScroll: 2,
responsive: [{
breakpoint: 950,
settings: {
slidesToShow: 2,
slidesToScroll: 2
}
},{
breakpoint: 720,
settings: {
slidesToShow: 1,
slidesToScroll: 1,
arrows: true,
dots: false,
adaptiveHeight: true,
}
}],
});
$('.vip-list-slider').slick({
dots: false,
arrows: false,
prevArrow: '
',
nextArrow: '
',
infinite: false,
fade: false,
cssEase: 'ease-in',
autoplay: false,
pauseOnFocus: true,
swipe: false,
slidesToShow: 1,
slidesToScroll: 1
});
/* <--------------------------------------------------------------------------------------------------- */
/* <----- RESIZE -------------------------------------------------------------------------------------- */
/* <--------------------------------------------------------------------------------------------------- */
$(window).bind('resize',function() {
widhtWindow = parseInt( $(window).width() );
heightWindow = parseInt( $(window).height() );
if ($( '.frm-selectbox' ).length ){
$( '.frm-selectbox ul' ).stop( true, true );
$( '.frm-selectbox ul' ).hide();
}
if ( widhtWindow > 960 ) {
$( '.filter-container' ).removeClass( 'filter-container-visible' );
$( '.filter-container-desktop' ).css( 'display', '' );
if ( $( '.filter-container-mobile .arrow').hasClass('icon-arrow-circle-light-up') ) {
$( '.filter-container-mobile .arrow').removeClass('icon-arrow-circle-light-up');
$( '.filter-container-mobile .arrow').addClass('icon-arrow-circle-light-down');
}
}
if ( widhtWindow > 767 ) {
$( '.viewi-head-search-labels-more-link' ).removeClass( 'mlink-show' );
$( '.viewi-head-search-labels-more-link' ).html( 'Více ' );
$( '.viewi-head-search-labels-more-content' ).css( 'display' , '' );
}
fixedFiltrButton();
});
$(document).on('mouseenter','.frm-selectbox',function() {
$( this ).find( '.frm-selectbox-label' ).addClass( 'frm-selectbox-label-hover' );
$( '.frm-selectbox ul' ).stop( true, true );
if (widhtWindow > 990) {
$( this ).find( 'ul' ).fadeIn();
}
return false;
});
$(document).on('click','.mlink',function() {
var $this = $( this );
var url = $this.attr( 'href' );
if ( $this.hasClass( 'mlink-show' ) ){
$( url ).slideUp();
$this.removeClass( 'mlink-show' );
$this.find( 'i' ).removeClass( 'icon-minus-circle' );
$this.find( 'i' ).addClass( 'icon-plus-circle' );
} else {
$( url ).slideDown();
$this.addClass( 'mlink-show' );
$this.find( 'i' ).removeClass( 'icon-plus-circle' );
$this.find( 'i' ).addClass( 'icon-minus-circle' );
}
return false;
});
$(document).on('click','.viewi-head-search-labels-more-link',function() {
var $this = $( this );
if ( $this.hasClass( 'mlink-show' ) ){
$this.html( 'Více ' );
$this.parents( '.label-links' ).find( '.viewi-head-search-labels-more-content' ).hide();
$this.removeClass( 'mlink-show' );
} else {
$this.html( 'Méně ' );
$this.parents( '.label-links' ).find( '.viewi-head-search-labels-more-content' ).show();
$this.addClass( 'mlink-show' );
}
return false;
});
/* <--------------------------------------------------------------------------------------------------- */
/* <----- SELECTBOX ----------------------------------------------------------------------------------- */
/* <--------------------------------------------------------------------------------------------------- */
$(document).on('mouseenter','.frm-selectbox',function() {
$( this ).find( '.frm-selectbox-label' ).addClass( 'frm-selectbox-label-hover' );
$( '.frm-selectbox ul' ).stop( true, true );
if (widhtWindow > 990) {
$( this ).find( 'ul' ).fadeIn();
}
return false;
});
$(document).on('mouseleave','.frm-selectbox',function() {
$( '.frm-selectbox ul' ).stop( true, true );
$( this ).find( '.frm-selectbox-label' ).removeClass( 'frm-selectbox-label-hover' );
if (widhtWindow > 990) {
$( this ).find( 'ul' ).hide();
}
return false;
});
$(document).on('click','.frm-selectbox-label, .frm-selectbox-icon',function() {
$( '.frm-selectbox ul' ).stop( true, true );
if (widhtWindow < 991) {
$( this ).parents( '.frm-selectbox' ).find( 'ul' ).slideToggle();
}
return false;
});
$(document).on('click','.frm-selectbox ul label',function() {
var $this = $( this );
var vybranHodnota = $this.parent( 'li').find( 'input' ).val();
var vybranPopis = $this.text();
var label = $this.parents( '.frm-selectbox' ).find( '.frm-selectbox-label' ).data( 'default-label' );
$this.parents( 'ul' ).find( 'label' ).removeClass( 'current' );
$this.addClass( 'current' );
$this.parents( 'ul' ).hide();
$this.parents( '.frm-selectbox' ).find( '.frm-selectbox-label' ).html( ''+ label + ' ' + vybranPopis );
/* <- defaultni formularovy prvek - */
$this.parents( 'ul').find( 'input' ).each(function() {
if ( $( this ).val() === vybranHodnota ) {
$( this ).attr('checked', 'checked');
$( this ).trigger('change');
}
});
return false;
});
$( '.frm-selectbox' ).each(function() {
var $this;
$( this ).find( 'label' ).each(function() {
$this = $( this );
var label = $this.parents( '.frm-selectbox' ).find( '.frm-selectbox-label' ).data( 'default-label' );
var vybranPopis = '';
if ( $this.parent( 'li').find( 'input' ).is(':checked') ) {
$this.parents( 'ul' ).find( 'label' ).removeClass( 'current' );
$this.addClass( 'current' );
$this.parents( 'ul' ).hide();
vybranPopis = $this.text();
$this.parents( '.frm-selectbox' ).find( '.frm-selectbox-label' ).html( ''+ label + ' ' + vybranPopis );
}
});
});
/* <--------------------------------------------------------------------------------------------------- */
/* <----- ROZBALENI FILTRU ---------------------------------------------------------------------------- */
/* <--------------------------------------------------------------------------------------------------- */
$(document).on('click','.filter-container-mobile',function() {
var $this = $( this );
if ( $this.hasClass( 'filter-mobile-button' ) === true ) {
$( 'body' ).addClass( 'modal-body' );
$( '#modalfilter' ).fadeIn();
var e = $(".modal-filter-iframe");
e.attr("src", e.data("src"));
} else {
if( $this.parents( '.filter-container' ).hasClass('filter-container-visible') ) {
$( '.filter-container-desktop' ).slideUp( function(){
$this.parents( '.filter-container' ).removeClass('filter-container-visible');
});
$this.children( '.arrow').removeClass('icon-arrow-circle-light-up');
$this.children( '.arrow').addClass('icon-arrow-circle-light-down');
} else {
$( '.filter-container-desktop' ).slideDown();
$this.parents( '.filter-container' ).addClass('filter-container-visible');
$this.children( '.arrow').removeClass('icon-arrow-circle-light-down');
$this.children( '.arrow').addClass('icon-arrow-circle-light-up');
}
}
return false;
});
$( '.filter-group' ).each( function(){
var $this = $( this );
if ( $this.hasClass( 'current') === true ) {
$this.find( '.filter-title-link i').removeClass( 'icon-plus-circle-light' );
$this.find( '.filter-title-link i').addClass( 'icon-minus-circle-light' );
}
});
$(document).on('click','.filter-title-link',function() {
var $this = $( this );
if( $this.parents( '.filter-group' ).hasClass( 'current' ) ) {
$this.parents( '.filter-group' ).find( '.filter-group-more' ).slideUp( function(){
fixedFilterButtonMoreClick();
});
$this.children( 'i' ).removeClass( 'icon-minus-circle-light' );
$this.children( 'i' ).addClass( 'icon-plus-circle-light' );
$this.parents( '.filter-group' ).removeClass( 'current' );
} else {
$this.parents( '.filter-group' ).find( '.filter-group-more' ).slideDown( function(){
fixedFilterButtonMoreClick();
});
$this.children( 'i' ).removeClass( 'icon-plus-circle-light' );
$this.children( 'i' ).addClass( 'icon-minus-circle-light' );
$this.parents( '.filter-group' ).addClass( 'current' );
}
return false;
});
$(document).on('click','.modal-filter-close',function() {
$( 'body' ).removeClass( 'modal-body' );
$( '#modalfilter' ).fadeOut();
return false;
});
/* <--------------------------------------------------------------------------------------------------- */
/* <----- ROZBALENI PSA ------------------------------------------------------------------------------- */
/* <--------------------------------------------------------------------------------------------------- */
$(document).on('click','.filter-dog-button',function() {
$( this ).hide();
$( '#avizopes' ).slideDown();
return false;
});
$(document).on('click','.filter-dog-close',function() {
$( '#avizopes' ).hide();
$( '.filter-dog-button' ).show();
return false;
});
/* <--------------------------------------------------------------------------------------------------- */
/* <----- SCROLL TLACITKA PRO ODESLANI FILTRU --------------------------------------------------------- */
/* <--------------------------------------------------------------------------------------------------- */
$(window).scroll(function () {
myWindowScroll(this);
});
/*
$(document).on('click','.filter-title',function() {
var vyskaObalu = parseInt( $( '.filter-container-desktop' ).height() );
var offset = $( '.filter-container-desktop' ).offset();
var poziceObalu = offset.top;
var mez = vyskaObalu + poziceObalu - heightWindow - 30;
var st = $( $(window) ).scrollTop();
console.log ( st );
if ( st > mez ) {
if ( $( '.filter-container-desktop' ).data('st_mez') != 'vetsi' )
if ( widhtWindow > 960 ) {
$("#filtbutton").css( { 'position' : 'absolute', 'bottom' : 'auto', right: 'auto', left: 'auto', translate: 'none' } );
$("#filtbutton").css( { 'top' : vyskaObalu - 60} );
} else {
$("#filtbutton").css( { 'position' : 'relative', 'bottom' : 'auto' } );
$("#filtbutton").css( { 'top' : 'auto', right: 'auto', left: 'auto', translate: 'none' } );
}
$( '.filter-container-desktop' ).data('st_mez', 'vetsi');
}
return false;
}); */
myWindowScroll(window);
/* <--------------------------------------------------------------------------------------------------- */
/* <----- SCROLL BANNERU V PRAVEM SLOUPCI ------------------------------------------------------------- */
/* <--------------------------------------------------------------------------------------------------- */
fixedBanner();
function fixedBanner() {
var sirkaOkna = parseInt($(window).width());
var vyskaOkna = parseInt($(window).height());
var scrollBoxu = function(){
var obal = $('.viewi-main');
var content = $(".viewi-bn-content");
var vyskatop = $('.viewi-bn-item-nofloating').height() + 40;
var plovouci = $('.viewi-bn-item-floating');
var topFixed = Math.round(obal.offset().top);
var contFixed = Math.round(content.offset().top) + vyskatop;
var plouvouciHeight = plovouci.height();
var obalHeight = obal.height();
var obalTop = $(window).scrollTop() + 10;
if (obalTop < contFixed) {
plovouci.offset({ top: contFixed });
} else {
var np = obalTop;
if ( (plouvouciHeight + obalTop) > content.height()+contFixed-vyskatop ) {
np = np - ( (plouvouciHeight + obalTop) - (content.height() + contFixed-vyskatop));
}
plovouci.offset({ top: np });
}
};
if (sirkaOkna > 767) {
$(window).scroll(scrollBoxu);
} else {
$(window).off("scroll", scrollBoxu);
$('.viewi-bn-item-floating').css('top','0px');
}
}
if ( $('.ntip-slider').length > 0) {
var countZobrPocetTipu = $('.ntip-slider').get(0).slick.options.slidesToShow;
var valTipy = $('.ntip-slider-container').attr('data-stat');
var url = '/assets/js/tipy/zapis_statistik.php?pocet='+countZobrPocetTipu+'&valtipy='+valTipy;
var el = createScriptEl(url, 'js_tipy', 0 );
el.async = 'async';
insertScriptEl( el );
//$.get(url);
}
if ( $('#lokalita_search').length > 0) {
var object = $("#"+lokalita_conf.item);
$( "#"+lokalita_conf.item).on( "change", function(){
//podivam se na hodnotu, ktera byla uzivatelem vybrana
var current_ui_item = object.data('selected');
if (current_ui_item != object.val()) {
//$("#"+ostatni_conf.item_kod).val('');
$("#"+lokalita_conf.item_id).val('');
}
});
object.autocomplete( {
source: function( request, response ) {
$.getJSON( "/assets/js/lokalita.ostatni.get.php", {term: request.term, c: Date.parse(Date())}, function( data, status, xhr ) {
response( data );
});
}
,select: function( event, ui ) {
nastavLokalituNaseptavac(ui.item.label , ui.item.value, ui.item.id);
return false;
}
,minlength: 1
});
}
$.imgLazy();
});
function myWindowScroll(th) {
var vyskaObalu = parseInt( $( '.filter-container-desktop' ).height() );
var offset = $( '.filter-container-desktop' ).offset();
var poziceObalu = offset.top;
var mez = vyskaObalu + poziceObalu - heightWindow - 30;
var st = $( th ).scrollTop();
$( '.filter-button-container' ).css( 'position', 'relative' );
if ( st > mez ) {
if ( $( '.filter-container-desktop' ).data('st_mez') != 'vetsi' )
if ( widhtWindow > 960 ) {
$("#filtbutton").css( { 'position' : 'absolute', 'bottom' : 'auto', right: 'auto', left: 'auto', translate: 'none' } );
//$("#filtbutton").css( { 'top' : vyskaObalu - 60} );
$("#filtbutton").css( { 'top' : '10px' } );
$("#filtbutton").removeClass( 'filtbutton-position-relative' );
$("#filtbutton").removeClass( 'filtbutton-position-fixed' );
$("#filtbutton").addClass( 'filtbutton-position-absolute' );
} else {
$("#filtbutton").css( { 'position' : 'relative', 'bottom' : 'auto' } );
$("#filtbutton").css( { 'top' : 'auto', right: 'auto', left: 'auto', translate: 'none' } );
$("#filtbutton").removeClass( 'filtbutton-position-fixed' );
$("#filtbutton").removeClass( 'filtbutton-position-absolute' );
$("#filtbutton").addClass( 'filtbutton-position-relative' );
}
$( '.filter-container-desktop' ).data('st_mez', 'vetsi');
} else {
if ( $( '.filter-container-desktop' ).data('st_mez') != 'mensi' ) {
if ( widhtWindow > 960 ) {
$("#filtbutton").css( { 'top' : 'auto', 'position' : 'fixed', 'bottom' : 15 });
} else {
$("#filtbutton").css( { 'top' : 'auto', 'position' : 'fixed', 'bottom' : 15 });
$("#filtbutton").css( { 'left' : '30px', 'right' : '40px' });
}
$("#filtbutton").removeClass( 'filtbutton-position-relative' );
$("#filtbutton").removeClass( 'filtbutton-position-absolute' );
$("#filtbutton").addClass( 'filtbutton-position-fixed' );
}
$( '.filter-container-desktop' ).data('st_mez', 'mensi');
}
fixedFiltrButton();
}
function nastavLokalituNaseptavac(label, kod, id) {
var object = $("#"+lokalita_conf.item);
object.val( label );
object.data('selected', label);
$("#"+lokalita_conf.item_id).val(id);
}
/* <--------------------------------------------------------------------------------------------------- */
/* <----- FUNKCE SCROLL TLACITKA PRO ODESLANI FILTRU -------------------------------------------------- */
/* <--------------------------------------------------------------------------------------------------- */
function fixedFiltrButton(){
var sirkaObalu = parseInt( $( '#filtbutton-container' ).width() );
var s_limit = sirkaObalu - 10;
//console.log("so: " + sirkaObalu+", l:" + s_limit +", fb:" + $( '#filtbutton' ).css( 'width') )
if ( $( '#filtbutton' ).css( 'width') != s_limit+'px') {
$( '#filtbutton' ).css( 'width', s_limit );
}
}
function fixedFilterButtonMoreClick() {
if ( $( '#filtbutton' ).hasClass( 'filtbutton-position-absolute') ) {
//var vyskaObalu = parseInt( $( '.filter-container-desktop' ).height() );
$("#filtbutton").css( { 'position' : 'absolute', 'bottom' : 'auto', right: 'auto', left: 'auto', translate: 'none' } );
$("#filtbutton").css( { 'top' : '10px' } );
}
setTimeout( function(){
myWindowScroll(window);
}, 10);
}
function setLogTip(id, toto)
{
var url = "https://www.avizo.cz/settiplog.php?id="+id;
$.get(url);
}