/* <----------------------------------------------------------------------------------------------------------- */
/* <----- DEFAULT SETTINGS ----------------------------------------------------------------------------------- */
/* <----------------------------------------------------------------------------------------------------------- */
var widhtWindow = parseInt( $(window).width() );
var heightWindow = parseInt( $(window).height() );
$( document ).ready( function(){
/* <--------------------------------------------------------------------------------------------------- */
/* <----- ROZBALOVANI BLOKU VE FILTRU ----------------------------------------------------------------- */
/* <--------------------------------------------------------------------------------------------------- */
$(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','.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;
});
/* <--------------------------------------------------------------------------------------------------- */
/* <----- SCROLL BANNERU V PRAVEM SLOUPCI ------------------------------------------------------------- */
/* <--------------------------------------------------------------------------------------------------- */
fixedBanner();
function fixedBanner() {
var sirkaOkna = parseInt($(window).width());
var vyskaOkna = parseInt($(window).height());
var scrollBoxu = function(){
var obal = $('.boxmodel-list-main');
var content = $(".boxmodel-list-bn-content");
var vyskatop = $('.boxmodel-bn-item-notfloating').height() + 40;
var plovouci = $('.boxmodel-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);
$('.boxmodel-bn-item-floating').css('top','0px');
}
}
/* <--------------------------------------------------------------------------------------------------- */
/* <----- RESIZE -------------------------------------------------------------------------------------- */
/* <--------------------------------------------------------------------------------------------------- */
$(window).bind('resize',function() {
widhtWindow = parseInt( $(window).width() );
heightWindow = parseInt( $(window).height() );
fixedFiltrButton();
fixedBanner();
});
/* <--------------------------------------------------------------------------------------------------- */
/* <----- SCROLL TLACITKA PRO ODESLANI FILTRU --------------------------------------------------------- */
/* <--------------------------------------------------------------------------------------------------- */
$(window).scroll(function () {
myWindowScroll(this);
});
myWindowScroll(window);
/* <--------------------------------------------------------------------------------------------------- */
/* <----- 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 );
}
});
});
});
function myWindowScroll(th) {
var vyskaObalu = parseInt( $( '.filter-sidebar' ).height() );
var offset = $( '.filter-sidebar' ).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-sidebar' ).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-sidebar' ).data('st_mez', 'vetsi');
} else {
if ( $( '.filter-sidebar' ).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-sidebar' ).data('st_mez', 'mensi');
}
fixedFiltrButton();
}
/* <--------------------------------------------------------------------------------------------------- */
/* <----- 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);
}