$(document).ready(function () {
if ($('.main-header .FH').length){
// FASHION DEPTH ==========
var fullMenu = '';
$('ul.base-menu li.ifDrop').each(function(){
fullMenu = fullMenu + '
';
});
$('.nav-menu.base-menu').addClass('container-h');
$('ul.base-menu li.all-product-button').remove();
$('ul.base-menu').prepend(fullMenu);
$('ul.base-menu li > a > i').removeClass('fa-angle-right');
$('ul.base-menu li > a > i').addClass('fa-angle-down');
$('ul.base-menu ul.drop-list').each(function(){
if(!$(this).parent('div.menu-dd').length){
$('').insertBefore($(this));
}
})
$('div.menu-dd').each(function(){
var image = $(this).next('ul.drop-list').find('li.image').html();
var slider = $(this).next('ul.drop-list').find('li.slider-menu').html();
$(this).next('ul.drop-list').find('li.image').remove();
$(this).next('ul.drop-list').find('li.slider-menu').remove();
var subcat = $(this).next('ul.drop-list').html();
if(subcat != undefined){
var w = $(this).next('ul.drop-list').hasClass('w60') ? 'w60' : 'w100';
$(this).next('ul.drop-list').remove();
$(this).append('');
if ( $(image).length ) {
$(this).append(''+image+'
');
}
if ( $(slider).length ) {
$(this).append('');
}
}
});
// BASE MENU ==========
$('ul.base-menu').show();
};
// FASHION MENU ==========
function Menu(){
$('.menu-dd').each(function() {
var $this = $(this);
var Nli = $this.find('li').length;
var Nlink = $this.find('a').length;
var Ncol = Math.ceil(Nlink / 15);
var Mbanner = $this.find('.cat-img').length;
Ncol = Ncol == 0 ? 1 : Ncol;
col = Nli > Ncol ? Ncol : Nli;
col = (col + (Mbanner ? 1 : 0) > 4) ? 4 : col;
$this.addClass('column' + col);
if (Mbanner){$this.addClass('banner');};
if ($this.find('li span > a').length == 0){
$this.addClass('no-sub');
};
if ($this.hasClass('column4')){
$this.parent().addClass('initial-h');
};
});
};
Menu();
$('.main-header .menu-drop').hover(function() {
$('.main-header .menu-drop .menu-dd').removeClass('open');
$(this).children('.menu-dd').stop().addClass('open');
if ( $('.slide-item-menu').length ) {
$('.slide-item-menu').owlCarousel({items:1,navigation:!0,pagination:!1});
// get owl element
var owl = $('.slide-item-menu');
// get owl instance from element
var owlInstance = owl.data('owlCarousel');
// if instance is existing
if(owlInstance != null)
owlInstance.reinit();
};
},function() {
$('.main-header .menu-drop .menu-dd').removeClass('open');
});
if ( $('.discount-tape').length){
var hellobar = $('.discount-tape').detach();
$('.main-header #navigation').prepend(hellobar);
}
if($('.main.search-form-box').length){
var logo = $('#logo').detach();
if($('.logo-h .btn').length){
var backToHome = $('.logo-h .btn').detach();
$('.menu-trg').after('');
$('.-g-logo-btn-holder').append(logo, backToHome);
}else{
logo.insertAfter('.menu-trg');
}
$('.cart-header-btn').insertAfter('.cart-m');
}
if($('.-g-pagetype-homepage').length){
$('#navigation').addClass('over-top');
}
if($('.category-sld').length){
$('.category-sld').insertBefore('#category-page');
};
// HEADER
if($( window ).width() > 1090 && $('.-g-pagetype-homepage').length){
var nav = $('#navigation');
var pos = nav.height();
$(window).scroll(function () {
var fix = ($(this).scrollTop() > pos) ? true : false;
nav.toggleClass("fix-nav", fix);
if(fix){
$('#logo svg #logo-fill').css('fill', '#000');
} else {
$('#logo svg #logo-fill').css('fill', '#fff');
}
});
};
// BF SIDEBAR + MENU STICKY
$.Gomag.bind('Widget/Add/After', function(){
if($('.-g-template-black-friday').length){
$('.main-header').css({'top' : '-' + $('.discount-tape').height() + 'px'});
}
if($( window ).width() > 991 && $('.-g-template-black-friday').length){
$('.landing-h .side-menu.fixed').css({'top' : $('#navigation .main-menu').outerHeight() + 20 + 'px'});
}
});
//GRID LIST PIN
function grid(){
setTimeout(function(){
// MANSORY PRINGRID CATEGORY
var $grid = $('.product-listing').masonry({
itemSelector: '.product-box',
percentPosition: true
});
// MANSORY IMAGES LOAD
$grid.imagesLoaded().progress( function() {
$grid.masonry('layout');
});
//RELOAD NEW ITEMS
$grid.masonry('reloadItems');
}, 250);
}
$(window).load(function() {
if ($('.product-listing').length){
grid();
}
});
$(window).scroll(function() {
if ($('.product-listing').length){
grid();
};
if ($('#product-page').length && $(this).scrollTop() > 100) {
$('#product-page').addClass('fade');
} else {
$('#product-page').removeClass('fade');
}
});
if($('.categoryPagination').length){
$('.categoryPagination').insertAfter('.product-listing');
}
//DETAIL
$('.detail-tabs h2').removeClass('resp-accordion');
$('.breadcrumbs-default').insertBefore('.detail-title .title').show();
$('#product-page .product-bottom').after('');
if($('#product-page').length && $(window).width() > 991){
var titleD = $('.detail-title').detach();
var priceD = $('.detail-prod-attr').detach();
$('.detail-slider-holder').after('');
$('.detail-fixed .fix-scroll').append(titleD, priceD);
}
if($('.vertical-slide-img .prod-gallery').length){
$('.prod-gallery').each(function(){
var img = $(this).attr('href');
$(this).find('img').attr('src', img);
})
}
$('.detail-share').insertAfter('.wish-section');
if($('.extra-offer').length){
$('.extra-offer').insertBefore('.detail-tabs').addClass('moved');
$('.extra-offer .slide-item-4').each(function(){
$(this).data('owlCarousel').destroy();
$(this).owlCarousel({items:3,navigation:!0,pagination:!1,itemsCustom : [[0,2],[479,3],[768,4],[979,3],[1099,3],[1199,3]]});
})
};
// After AJAX Complete
$.Gomag.bind('Product/Details/After/Ajax/Load/Complete', function(response){
//DETAIL
if($('.extra-offer').length){
$('.extra-offer').insertBefore('.detail-tabs').addClass('moved');
$('.extra-offer .slide-item-4').each(function(){
$(this).data('owlCarousel').destroy();
$(this).owlCarousel({items:3,navigation:!0,pagination:!1,itemsCustom : [[0,2],[479,3],[768,4],[979,3],[1099,3],[1199,3]]});
})
};
});
$.Gomag.bind('Category/Loaded/More/Items', function(response){
//category-page
if ($('.product-listing').length){
grid();
}
});
});
if($('.detail-recomended').length){
$('.detail-recomended').insertAfter('.product-page-holder').removeClass('col-sm-6').addClass('container-h container-bg');
}