$(document).ready(function () {
if ($('.main-header .FH').length){
// BASE MENU
$('ul.base-menu').show();
};
// LEVEL DEPTH FOR MOBILE
if($(window).width() < 1090) {
var fullMenu = '';
$('ul.base-menu li.ifDrop').each(function(){
fullMenu = fullMenu + '
'+$(this).html()+'';
});
$('ul.base-menu li.all-product-button').remove();
$('.nav-menu.base-menu').prepend(fullMenu);
}
// FIXED HEADER
function fixNav(){
if (!$('.cart-menu').length && !$('.-g-template-black-friday').length){
var nav = $('.main-header');
var pos = nav.height();
var posDelay = nav.height()*2;
var prevScroll = 0;
nav.addClass('fix-nav');
$(window).scroll(function () {
var fix = ($(this).scrollTop() > posDelay) ? true : false;
if(fix){
nav.addClass('fade-menu', fix);
setTimeout(function() {
nav.addClass('animate-menu');
}, 250);
$('body').css('margin-top', pos);
if($(this).scrollTop() > prevScroll){
nav.removeClass('active-menu');
}else{
nav.addClass('active-menu');
}
}else{
$('body').css('margin-top', 0);
nav.removeClass('fade-menu active-menu animate-menu', fix);
}
prevScroll = $(this).scrollTop();
});
}
}
$.Gomag.bind('Widget/Add/After', function(){
fixNav();
// BF SIDEBAR + MENU STICKY
if($('.-g-template-black-friday').length){
$('.main-header').css({'top' : '-' + ($('.discount-tape').height() + $('.top-head-bg').height()) + 'px'});
}
if($( window ).width() > 991 && $('.-g-template-black-friday').length){
$('.landing-h .side-menu.fixed').css({'top' : $('#navigation').outerHeight() + 20 + 'px'});
}
})
// ITC MENU ==========
function buildMenu(){
$('.main-header .__ignoreSubmenu').each(function() {
var $this = $(this);
if ($this.find('li').length > 20){
$this.addClass('col3');
}else if ($this.find('li').length >= 11){
$this.addClass('col2');
}else if ($this.find('li').length < 10){
$this.addClass('col1');
}else{}
});
};
buildMenu();
$('.main-header .menu-drop').hover(function() {
$(this).find('.menu-dd').addClass('visible');
if ( $('.slide-item-menu').length ) {
$('.slide-item-menu').owlCarousel({items:1,navigation:!0,pagination:!1});
var owl = $('.slide-item-menu'); // get owl element
var owlInstance = owl.data('owlCarousel'); // get owl instance from element
if(owlInstance != null) // if instance is existing
owlInstance.reinit();
$.Gomag.eqProductRow();
};
}, function(){
$(this).find('.menu-dd').removeClass('visible');
});
$('.main-header ul.nav-menu li.ifDrop').has('ul.drop-list').addClass('drop-parent');
$('.main-header .drop-parent').hover(function() {
$(this).find('.drop-list').addClass('visible');
$(this).find('.drop-list').show();
var itemNumber = $(this).find('.col').length,
itemWidth = $(this).find('.col').outerWidth(),
elemCount = $(this).find('.drop-list li a').length,
imgCount = $(this).find('.drop-list .image').length;
if(elemCount < 10 && imgCount == 0){
$('.menu-dd').css({"padding-right" : "0px", "width" : itemWidth + 258 + "px"});
}
else{
$('.menu-dd').css({"padding-right" : "0px", "width" : itemNumber * itemWidth + 258 + "px"});
}
},function() {
$(this).find('.drop-list').removeClass('visible');
$(this).find('.drop-list').hide();
$('.menu-dd').css({"width" : 255 + "px"});
})
});
/* GoMag micostore js */
var ww = $(window).width();
var wlh = window.location.href;
var theDomain = window.location.origin;
if(wlh.indexOf('demo=speed') > -1){
$('body').addClass('demo-speed');
}else{
$('body').addClass('no-demo-speed');
}
if(!$('body').hasClass('demo-speed')){
function pTypeDetect(){
if($('#category-page').length){
$('body').addClass('cat-p');
}
if($('#product-page').length){
$('body').addClass('prod-p');
}
if($('.checkout').length){
$('body').addClass('check-p');
}
if($('.testimonial-row').length){
$('body').addClass('testim-p');
}
if($('#shoppingcart').length){
$('body').addClass('shopcart-p');
}
if($('#register-page').length){
$('body').addClass('register-p');
}
if($('#succes-page').length){
$('body').addClass('succes-p');
}
if(
$('#main-bnn').length &&
$('.homepage').length
){
$('body').addClass('home-p');
}
if($('.container-h > h1.title').length){
if(
$('.container-h > h1.title').text().toLowerCase().indexOf('ne pare rău') > -1 &&
$('.container-h > h1.title').text().toLowerCase().indexOf('nu am găsit produse') > -1
){
$('body').addClass('not-found-p');
}
}
}
pTypeDetect();
function fontsInclude(){
var fontInc =
''+
'';
$(fontInc).prependTo('head');
}
fontsInclude();
/*
function equalBanner(){
if(
ww > 1090 &&
$('#main-bnn').length &&
$('.main-header .all-product-button .menu-dd').length &&
$('#category-page').length < 1
){
$('#main-bnn, .main-header .all-product-button .menu-dd').removeAttr('style');
var getHeightMenu = $('.main-header .all-product-button .menu-dd').height();
var getHeightBanner = $('#main-bnn').height();
if(getHeightMenu >= getHeightBanner){
$('#main-bnn').removeAttr('style').css('min-height',getHeightMenu).addClass('new-main-bnn');
}else if(getHeightBanner > getHeightMenu){
$('.main-header .all-product-button .menu-dd').css('min-height',getHeightBanner).addClass('new-menu-bnn');
var getTheSTyle = $('.main-header .all-product-button .menu-dd').attr('style');
if(typeof getTheSTyle !== 'undefined'){
getTheSTyle = getTheSTyle.replace('min-height: '+getHeightBanner+'px;','min-height: '+getHeightBanner+'px !important;');
$('.main-header .all-product-button .menu-dd').attr('style',getTheSTyle);
}
}
}else if(
ww <= 1090 &&
$('#main-bnn').length
){
$('#main-bnn, .main-header .all-product-button .menu-dd').removeAttr('style').removeClass('new-main-bnn new-menu-bnn');
}
}
*/
function imgLazyInHome(){
if($('.-g-component-banner-group .pin-home .pin img').length){
$('.-g-component-banner-group .pin-home .pin img').each(function(e){
var dataSrc = $(this).attr('data-src');
if(typeof dataSrc != 'undefined'){
$(this).attr('src',dataSrc).removeClass('lazyload').addClass('load-data-src');
}
$(this).parents('.-g-component-banner-group').eq(0).addClass('banner-group-loaded');
});
}
}
imgLazyInHome();
function moveElementInHome(){
if($('.container-h.container-bg.gomagComponent').length){
$('.container-h.container-bg.gomagComponent').each(function(e){
$(this).addClass('component-'+(e+1));
})
}
if(
$('.slider_promo_h').length &&
$('.pinGrid').length
){
$('.pinGrid').parent().insertAfter('.slider_promo_h');
}
if(
$('.component-2').length &&
$('.slider_recomend_h').length
){
$('.component-2').insertAfter('.slider_recomend_h');
}
if(
$('.component-2').length &&
$('.slider_new_h').length
){
$('.slider_new_h').insertAfter('.component-2');
}
if(
$('.landing-content.component-5').length &&
$('.__recentProducts').length
){
$('.landing-content.component-5').insertAfter('.__recentProducts');
}
}
//moveElementInHome();
function moveElementInclient(){
if($('#register-page').length){
$('Creare cont nou sau autentificare').prependTo('#register-page');
}
if(
$('.new-client-section > .title-carousel').length &&
$('.new-client-section .form-box .register-form').length
){
$('.new-client-section > .title-carousel').prependTo('.new-client-section .form-box .register-form');
}
if(
$('.new-client-section > .regular-text').length &&
$('.new-client-section .form-box .register-form > .title-carousel').length
){
$('.new-client-section > .regular-text').insertAfter('.new-client-section .form-box .register-form > .title-carousel');
}
if(
$('.old-client-section-h > .title-carousel').length &&
$('.old-client-section-h .register-form').length
){
$('.old-client-section-h > .title-carousel').prependTo('.old-client-section-h .register-form');
}
if(
$('.old-client-section-h .register-form > .title-carousel').length &&
$('.old-client-section-h > .regular-text').length
){
$('.old-client-section-h > .regular-text').insertAfter('.old-client-section-h .register-form > .title-carousel');
}
if($('.register-form .label-s').length){
$('.register-form .label-s').each(function(){
if($(this).parent().find('input').length){
$(this).parent().find('input').attr('placeholder',$(this).text().trim());
}
});
}
}
moveElementInclient();
function moveElemProdDetails(){
if($('.detail-prod-attr .add-section.clearfix').length){
$('.detail-prod-attr .add-section.clearfix').appendTo('.detail-prod-attr');
}
if($('.detail-prod-attr .detail-product-atributes').length){
$('.detail-prod-attr .detail-product-atributes').each(function(e){
if(!$(this).hasClass('atrib-n')){
$(this).addClass('atrib-n atrib-'+(e+1));
}
})
}
if($('.detail-prod-attr .atrib-2').length){
$('.detail-prod-attr .atrib-2').insertBefore('.detail-prod-attr .detail-price');
}
if($('.detail-sld-similar .title-carousel .title').length){
$('.detail-recomended .title-carousel .title').text('Frecvent cumparate impreuna');
}
if(
$('.product-code .code').length &&
$('#product-page .atrib-2').length
){
$('.product-code .code').prependTo('#product-page .atrib-2');
}
if(
$('.wish-section .wish-btn').length &&
$('.detail-prod-attr .add-section').length
){
$('.wish-section .wish-btn').prependTo('.detail-prod-attr .add-section');
}
}
if ($(window).width() > 480){
moveElemProdDetails();
} else {
$('.detail-price, .detail-product-atributes:has(.short-description)').insertBefore('.add-section');
$('.detail-price').addClass('full');
}
function thumbProduct(){
if($('.product-box').length){
$('.product-box').each(function(){
if(
$(this).find('.price-full').length &&
$(this).find('.icon.discount').length
){
if($(this).find('.price-full .percent').length < 1){
var getTheSClass = $(this).find('.price-full').attr('class');
var getTheSHtml = $(this).find('.price-full').html();
$(this).find('.price-full').replaceWith(''+getTheSHtml+'');
$('('+$(this).find('.icon.discount').text()+')').appendTo($(this).find('.price-full'));
}
}else{
if($(this).find('.price-full .percent').length){
$(this).find('.price-full .percent').remove();
}
}
});
}
}
var slideTmChange = "";
function caroChange(){
if($('.slide-item-component').length){
$('.slide-item-component').addClass('slide-item-6').removeClass('slide-item-2');
}
if($('.slide-item-2').length){
$('.slide-item-2').addClass('slide-item-6').removeClass('slide-item-2');
}
if($('.slide-item-4').length){
$('.slide-item-4').addClass('slide-item-6').removeClass('slide-item-4');
// $('.slide-item-4').data('owlCarousel').destroy();
}
if(
$('.extra-offer .slide-item-4').length ||
$('.extra-offer .slide-item-6').length
){
$('.extra-offer .slide-item-6').removeClass('slide-item-6').addClass('slide-item-4 n-slide-item-4');
$('.extra-offer').addClass('container-h container-bg');
}
if($('.slide-item-6').length){
$('.slide-item-6').owlCarousel({
items: 6,
navigation:true,
pagination:true,
itemsCustom : [
[0,2],
[479,2],
[768,3],
[979,4],
[1099,5],
[1199,6]
]
});
}
clearTimeout(slideTmChange);
slideTmChange = setTimeout(function(){
if($('.slide-item-recent').length){
$('.slide-item-recent').addClass('slide-item-recent-6');
if($('.slide-item-recent .owl-item').length){
$('.slide-item-recent').data('owlCarousel').destroy();
}
$('.slide-item-recent-6').owlCarousel({
items: 6,
navigation:true,
pagination:true,
itemsCustom : [
[0,2],
[479,2],
[768,3],
[979,4],
[1099,5],
[1199,6]
]
});
}
},1000);
}
/* https://gomagg.atlassian.net/browse/GOMK-40846
caroChange(); */
function logoFunc(){
var folderPath = theDomain.replace('www.','').replace('http://','').replace('https://','').replace('.gomag.ro','').replace('.ro','');
if(folderPath.indexOf('micostore.ro') > -1){
folderPath = theDomain.replace('www.','').replace('http://','').replace('https://','').replace('.gomag.ro','');
}
// 'https://www.micostore.ro/domains/micostore.ro/files/files/micostore-cut-3898-5795.png';
var footerLogoUrl = '/domains/'+folderPath+'/files/files/logomico-footer-4863.png';
if($('.main-footer .col-right #logo').length < 1){
$('#logo').clone().appendTo('.main-footer .col-right')
$('.main-footer .col-right #logo').addClass('f-l');
$('.main-footer .col-right #logo img').attr('src',footerLogoUrl).css('content','url('+footerLogoUrl+')'); // on load only
$('.main-footer .col-right #logo').attr('id','logo-footer');
$('.main-footer .col-right #logo-footer img').attr('loading','lazy');
}
}
var detectElement = $('.bottom-section .newsletter .title');
function stickerNews(){
if($('.bottom-section .flex-box .col').length){
$('.bottom-section').addClass('cols-'+$('.bottom-section .flex-box .col').length);
}
if(detectElement.length){
var folderPath = theDomain.replace('www.','').replace('http://','').replace('https://','').replace('.gomag.ro','').replace('.ro','');
if(folderPath.indexOf('micostore.ro') > -1){
folderPath = theDomain.replace('www.','').replace('http://','').replace('https://','').replace('.gomag.ro','');
}
// 'https://www.micostore.ro/domains/micostore.ro/files/files/micostore-cut-3898-5795.png';
var imgPath = '/domains/'+folderPath+'/files/files/micostore-cut-3898-5795.png';
var dinTxt = detectElement.find('span').text();
var dinHtml = detectElement.find('span').html();
var stickerBox =
''+
'
'+
'
'+
'
'+
'
ABONEAZA-TE LA NEWSLETTERUL MICOSTORE!'+
'
'+
'
'+
'
';
if($('body .n-s').length < 1){
$(stickerBox).appendTo('body');
}
setTimeout(function(){
if(
document.cookie.indexOf('nws_on_off=true') > -1 ||
document.cookie.indexOf('nws_on_off=') < 0
){
$('.n-s').addClass('act');
}
},1000);
}
}
$(document).on('click','.n-s-t, .n-s-b',function(){
$('html, body').animate({scrollTop: $(detectElement).offset().top - 100},1000);
detectElement.parent().addClass('p-s');
setTimeout(function(){
detectElement.parent().removeClass('p-s');
},3000);
});
$(document).on('click','.n-s .cl',function(){
$(this).parent().toggleClass('act');
if($(this).parent().hasClass('act')){
document.cookie = "nws_on_off=true; Max-Age=28800; SameSite=Strict; Secure; Domain=micostore.ro; path=/";
}else{
document.cookie = "nws_on_off=false; Max-Age=28800; SameSite=Strict; Secure; Domain=micostore.ro; path=/";
}
});
function catItemCount(){
if($('.category-content .result-section .result span').length){
$('.category-content .result-section .result span').each(function(e){
$(this).addClass('result_'+(e+1));
});
}
if(
$('.category-content .result-section .result .result_4').length ||
$('.category-content .result-section .result').text().indexOf(' din ') > -1
){
$('['+$('.category-content .result-section .result .result_4').text()+']').appendTo('.category-content .catTitle');
}
}
function categoryDesc(){
if($('.catDesc').length){
$('.catDesc').each(function(){
if($(this).text().trim().length < 1){
$(this).addClass('no-catDesc');
}
});
}
}
function catListfilterFix(){
if($('.option-imageAndText-group label').length){
$('.option-imageAndText-group label').each(function(e){
var createId = 'inp_id_'+(e+1);
var getThisInpId = $(this).find('input[type="checkbox"]').attr('id');
var getThisLbFor = $(this).attr('for');
if(typeof getThisInpId == "undefined"){
$(this).find('input[type="checkbox"]').attr('id',createId);
}
if(
typeof getThisLbFor !== "undefined" &&
getThisLbFor.length < 1
){
$(this).attr('for',createId);
}
})
}
}
catListfilterFix();
// catItemCount();
$('.filter.box .title-h').click(function(){
$(this).parent().toggleClass('close');
if($(this).parent().hasClass('close')){
$(this).parent().find('ul').stop().slideUp(200);
if($(this).parent().find('.more-filter.visible')){
$(this).parent().find('.more-filter.visible').stop().slideUp();
}
}else{
$(this).parent().find('ul').stop().slideDown(200);
if($(this).parent().find('.more-filter.visible')){
$(this).parent().find('.more-filter.visible').stop().slideDown();
}
}
});
function contactFix(){
if(
$('.contact-header').length &&
$('#main-menu .nav-menu-hh .contact-header').length < 1
){
var headPhoneHtml = '';
$('.acount-section .contact-header').remove();
$(headPhoneHtml).appendTo('#main-menu .nav-menu-hh');
}
}
contactFix();
$(document).on('click','.n-c-h a',function(e){
$('html, body').animate({scrollTop: $('.bottom-section .support').offset().top - 100},1000);
$('.bottom-section .support').addClass('p-s');
setTimeout(function(){
$('.bottom-section .support').removeClass('p-s');
},3000);
e.preventDefault();
});
function closeIcon(){
if(
$('.-g-category-filter-remove').length &&
$('.-g-category-filter-remove').text().indexOf('x') > -1
){
$('.-g-category-filter-remove').text($('.-g-category-filter-remove').text().replace('x','×'));
}
}
closeIcon();
function productBgFix(){
if(
$('.icon-group').length &&
$('.product-bottom').length
){
$('.icon-group').insertBefore('.product-bottom');
}
}
productBgFix();
function thumbsSlideMove(){
if($('.thumb-h').length){
$('.thumb-h').addClass('horizontal').insertAfter('.vertical-slide-img');
}
}
thumbsSlideMove();
function menuIcons(){
if($('.menu-dd .ifDrop > a > img').length > 0){
$('.menu-dd .ifDrop > a > img').each(function(){
var deThisImgSrc = '';
$(this).replaceWith('');
});
}
if($('.mm-mobile-menu .nav-menu li > a > img').length > 0){
$('.mm-mobile-menu .nav-menu li > a > img').each(function(){
var deThisImgSrc = '';
$(this).replaceWith('');
});
}
}
function accountFix(){
if($('body #result-page').length){
$('body').addClass('result-p');
}
if($('.account-h .account-section').length){
$('body').addClass('account-p');
}
if(
$('.account-section > form .title.account').length &&
wlh.indexOf('/status-comanda') > -1
){
$('.account-section > form .title.account').insertBefore($('.account-section > form'));
}
// remove if element iz empty
if(
$('.account-h .account-section .user-cover div').length < 1 ||
$('.account-h .account-section .user-cover p').length < 1 ||
$('.account-h .account-section .user-cover a').length < 1 ||
$('.account-h .account-section .user-cover ol').length < 1 ||
$('.account-h .account-section .user-cover ul').length < 1
){
$('.account-h .account-section .user-cover').remove();
}
}
accountFix();
function foofterAffiliateFix(){
if($('.-g-footer-affiliate-block').length){
$('.-g-footer-affiliate-block').insertAfter('.-g-footer-copyright-block');
}
}
foofterAffiliateFix();
function prodBoxSetup(){
if($('.product-box .box-holder').length){
$('.product-box .box-holder').each(function(){
if(!$('.-g-one-time-offers-holder').length){
var theUrl = $(this).find('.image-holder a').attr('href');
if(typeof theUrl != "undefined" && theUrl.length < 10){
theUrl = $(this).find('.figcaption h2 a').attr('href');
}
}
else
{
var theUrl = $(this).find('a.image').attr('href');
}
if($(this).find('.cl-r').length < 1 && !$(this).hasClass('-g-download-file-holder')){
$('').appendTo($(this));
}
});
}
}
prodBoxSetup();
function orderSentPg(){
if($('#succes-page .order-succes-info').length){
// fix the title position
if($('#succes-page > .row > .order-succes-info > h1').length){
$('#succes-page > .row > .order-succes-info > h1').insertBefore('#succes-page > .row');
}
// fix some links in the description
if($('#succes-page .order-succes-info ._descriptionTab a').length){
$('#succes-page .order-succes-info ._descriptionTab a').each(function(e){
var deThisLink = $(this);
var getHref = deThisLink.attr('href').trim();
var getTxt = deThisLink.text().trim();
if(getHref.indexOf('facebook.com/micostore.ro') > -1){
deThisLink.addClass('social-link fb-icon fb-page-icon');
}
if(getHref.indexOf('facebook.com/groups/doadot') > -1){
deThisLink.addClass('social-link fb-icon fb-groups-icon');
}
if(getHref.indexOf('instagram.com/micostore.ro') > -1){
deThisLink.addClass('social-link insta-icon insta-page-icon');
}
if(getHref.indexOf('.youtube.com/channel') > -1){
deThisLink.addClass('social-link yt-icon yt-channel-icon');
}
if (
deThisLink.hasClass('social-link') &&
deThisLink.closest('ul').length
) {
deThisLink.addClass('link-in-ul');
deThisLink.closest('ul').addClass('social-ul');
}
});
}
// move to top the entire description
if($('.succes-top-intro').length < 1){
$('').prependTo('#succes-page .order-succes-info > .row');
// if($('#succes-page .order-succes-info .about-cmd .titleComponent')){
// $('#succes-page .order-succes-info .about-cmd .titleComponent').appendTo('.succes-top-intro');
// }
if($('#succes-page .order-succes-info .about-cmd ._descriptionTab')){
$('#succes-page .order-succes-info .about-cmd ._descriptionTab').appendTo('.succes-top-intro');
}
}
}
// newsletter fix duplicates
if(
$('.order-succes-info .about-cmd .newsletter-h').length &&
$('.bottom-section .holder .newsletter').length
){
$('.order-succes-info .about-cmd .newsletter-h').remove();
}
}
orderSentPg();
$(document).ready(function(){
$('body').addClass('bdy-r');
$.Gomag.bind('Product/Preview/After/Ajax/Load', function(event, data){
thumbsSlideMove();
});
categoryDesc();
})
$(document).ajaxComplete(function(){
$('body').addClass('bdy-ajx');
prodBoxSetup();
caroChange();
productBgFix();
if ($(window).width() > 480){
moveElemProdDetails();
} else {
$('.detail-price, .detail-product-atributes:has(.short-description)').insertBefore('.add-section');
$('.detail-price').addClass('full');
}
});
$(window).load(function(){
$('body').addClass('bdy-l');
logoFunc();
//stickerNews();
menuIcons();
//equalBanner();
})
var timeTo = 0;
$(window).resize(function(){
ww = $(window).width();
clearTimeout(timeTo);
timeTo = setTimeout(function(){
caroChange();
productBgFix();
//equalBanner();
},500);
});
}