Help with js

0

I'm editing a template and I need to remove a hover from the start logo, even though I try not to know how to do it, the guy did it in js and I do not master it well. Can you help me?

function menuHideExtraElements() {

  //cleaneng changed elements
  jQuery('.sf-more-li, .sf-logo-li').remove();
  var windowWidth = jQuery('body').innerWidth();

  jQuery('.sf-menu').each(function () {
    var $thisMenu = jQuery(this);
    var $menuWraper = $thisMenu.closest('.mainmenu_wrapper');
    $menuWraper.attr('style', '');
    if (windowWidth > 991) {
      //grab all main menu first level items 
      var $menuLis = $menuWraper.find('.sf-menu > li');
      $menuLis.removeClass('sf-md-hidden');

      var $headerLogoCenter = $thisMenu.closest('.header_logo_center');
      var logoWidth = 0;
      var summaryLiWidth = 0;

      if ($headerLogoCenter.length) {
        var $logo = $headerLogoCenter.find('.logo');
        // 30/2 - left and right margins
        logoWidth = $logo.outerWidth(true) + 70;
      }

      // var wrapperWidth = jQuery('.sf-menu').width();
      var wrapperWidth = $menuWraper.outerWidth(true);
      $menuLis.each(function (index) {
        var elementWidth = jQuery(this).outerWidth();
        summaryLiWidth += elementWidth;
        if (summaryLiWidth >= (wrapperWidth - logoWidth)) {
          var $newLi = jQuery('<li class="sf-more-li"><a>...</a><ul></ul></li>');
          jQuery($menuLis[index - 1]).before($newLi);
          var newLiWidth = jQuery($newLi).outerWidth(true);
          var $extraLiElements = $menuLis.filter(':gt(' + (index - 2) + ')');
          $extraLiElements.clone().appendTo($newLi.find('ul'));
          $extraLiElements.addClass('sf-md-hidden');
          return false;
        }
      });

      if ($headerLogoCenter.length) {
        var $menuLisVisible = $headerLogoCenter.find('.sf-menu > li:not(.sf-md-hidden)');
        var menuLength = $menuLisVisible.length;
        var summaryLiVisibleWidth = 0;
        $menuLisVisible.each(function () {
          summaryLiVisibleWidth += jQuery(this).outerWidth();
        });

        var centerLi = Math.floor(menuLength / 2);
        if ((menuLength % 2 === 0)) {
          centerLi--;
        }
        var $liLeftFromLogo = $menuLisVisible.eq(centerLi);
        $liLeftFromLogo.after('<li class="sf-logo-li"></li>');
        $headerLogoCenter.find('.sf-logo-li').width(logoWidth);
        var liLeftRightDotX = $liLeftFromLogo.offset().left + $liLeftFromLogo.outerWidth();
        var logoLeftDotX = windowWidth / 2 - logoWidth / 2;
        var menuLeftOffset = liLeftRightDotX - logoLeftDotX;
        $menuWraper.css({ 'left': -menuLeftOffset })
      }

    }// > 991
  }); //sf-menu each
} //menuHideExtraElements

function initMegaMenu() {
  var $megaMenu = jQuery('.mainmenu_wrapper .mega-menu');
  if ($megaMenu.length) {
    var windowWidth = jQuery('body').innerWidth();
    if (windowWidth > 991) {
      $megaMenu.each(function () {
        var $thisMegaMenu = jQuery(this);
        //temporary showing mega menu to propper size calc
        $thisMegaMenu.css({ 'display': 'block', 'left': 'auto' });
        var thisWidth = $thisMegaMenu.outerWidth();
        var thisOffset = $thisMegaMenu.offset().left;
        var thisLeft = (thisOffset + (thisWidth / 2)) - windowWidth / 2;
        $thisMegaMenu.css({ 'left': -thisLeft, 'display': 'none' });
        if (!$thisMegaMenu.closest('ul').hasClass('nav')) {
          $thisMegaMenu.css('left', '');
        }
      });
    }
  }
}


function affixSidebarInit() {
  var $affixAside = jQuery('.affix-aside');
  if ($affixAside.length) {

    //on stick and unstick event
    $affixAside.on('affix.bs.affix', function (e) {
      var affixWidth = $affixAside.width() - 1;
      var affixLeft = $affixAside.offset().left;
      $affixAside
        .width(affixWidth)
        .css("left", affixLeft);
    }).on('affix-top.bs.affix affix-bottom.bs.affix', function (e) {
      $affixAside.css({ "width": "", "left": "" });
    });

    //counting offset
    var offsetTop = $affixAside.offset().top - jQuery('.page_header').height();
    var offsetBottom = jQuery('.page_footer').outerHeight(true) + jQuery('.page_copyright').outerHeight(true);

    $affixAside.affix({
      offset: {
        top: offsetTop,
        bottom: offsetBottom
      },
    });

    jQuery(window).on('resize', function () {
      $affixAside.css({ "width": "", "left": "" });

      if ($affixAside.hasClass('affix')) {
        //returning sidebar in top position if it is sticked because of unexpacted behavior
        $affixAside.removeClass("affix").css("left", "").addClass("affix-top");
      }

      var offsetTop = jQuery('.page_topline').outerHeight(true)
        + jQuery('.page_toplogo').outerHeight(true)
        + jQuery('.page_header').outerHeight(true)
        + jQuery('.page_breadcrumbs').outerHeight(true)
        + jQuery('.blog_slider').outerHeight(true);
      var offsetBottom = jQuery('.page_footer').outerHeight(true)
        + jQuery('.page_copyright').outerHeight(true);

      $affixAside.data('bs.affix').options.offset.top = offsetTop;
      $affixAside.data('bs.affix').options.offset.bottom = offsetBottom;

      $affixAside.affix('checkPosition');

    });

  }//eof checking of affix sidebar existing
}

//helper functions to init elements only when they appears in viewport (jQUery.appear plugin)
function initAnimateElement(self, index) {
  var animationClass = !self.data('animation') ? 'fadeInUp' : self.data('animation');
  var animationDelay = !self.data('delay') ? 150 : self.data('delay');
  setTimeout(function () {
    self.addClass("animated " + animationClass);
  }, index * animationDelay);
}
function initCounter(self) {
  if (self.hasClass('counted')) {
    return;
  } else {
    self.countTo().addClass('counted');
  }
}
function initProgressbar(el) {
  el.progressbar({
    transition_delay: 300
  });
}
function initChart(el) {
  var data = el.data();
  var size = data.size ? data.size : 270;
  var line = data.line ? data.line : 20;
  var bgcolor = data.bgcolor ? data.bgcolor : '#ffffff';
  var trackcolor = data.trackcolor ? data.trackcolor : '#c14240';
  var speed = data.speed ? data.speed : 3000;

  el.easyPieChart({
    barColor: trackcolor,
    trackColor: bgcolor,
    scaleColor: false,
    scaleLength: false,
    lineCap: 'butt',
    lineWidth: line,
    size: size,
    rotate: 0,
    animate: speed,
    onStep: function (from, to, percent) {
      jQuery(this.el).find('.percent').text(Math.round(percent));
    }
  });
}

//function that initiating template plugins on window.load event
function windowLoadInit() {

  ////////////
  //mainmenu//
  ////////////
  if (jQuery().scrollbar) {
    jQuery('[class*="scrollbar-"]').scrollbar();
  }
  if (jQuery().superfish) {
    jQuery('ul.sf-menu').superfish({
      popUpSelector: 'ul:not(.mega-menu ul), .mega-menu ',
      delay: 700,
      animation: { opacity: 'show', marginTop: 0 },
      animationOut: { opacity: 'hide', marginTop: 5 },
      speed: 200,
      speedOut: 200,
      disableHI: false,
      cssArrows: true,
      autoArrows: true

    });
    jQuery('ul.sf-menu-side').superfish({
      popUpSelector: 'ul:not(.mega-menu ul), .mega-menu ',
      delay: 500,
      animation: { opacity: 'show', height: 100 + '%' },
      animationOut: { opacity: 'hide', height: 0 },
      speed: 400,
      speedOut: 300,
      disableHI: false,
      cssArrows: true,
      autoArrows: true
    });
  }


  //toggle mobile menu
  jQuery('.toggle_menu').on('click', function () {
    jQuery(this)
      .toggleClass('mobile-active')
      .closest('.page_header')
      .toggleClass('mobile-active')
      .end()
      .closest('.page_toplogo')
      .next()
      .find('.page_header')
      .toggleClass('mobile-active');
  });

  jQuery('.mainmenu a').on('click', function () {
    var $this = jQuery(this);
    //If this is a local link or item with sumbenu - not toggling menu
    if (($this.hasClass('sf-with-ul')) || !($this.attr('href').charAt(0) === '#')) {
      return;
    }
    $this
      .closest('.page_header')
      .toggleClass('mobile-active')
      .find('.toggle_menu')
      .toggleClass('mobile-active');
  });

  //side header processing
  var $sideHeader = jQuery('.page_header_side');
  // toggle sub-menus visibility on menu-click
  jQuery('ul.menu-click').find('li').each(function () {
    var $thisLi = jQuery(this);
    //toggle submenu only for menu items with submenu
    if ($thisLi.find('ul').length) {
      $thisLi
        .append('<span class="activate_submenu"></span>')
        //adding anchor
        .find('.activate_submenu, > a')
        .on('click', function (e) {
          var $thisSpanOrA = jQuery(this);
          //if this is a link and it is already opened - going to link
          if (($thisSpanOrA.attr('href') === '#') || !($thisSpanOrA.parent().hasClass('active-submenu'))) {
            e.preventDefault();
          }
          if ($thisSpanOrA.parent().hasClass('active-submenu')) {
            $thisSpanOrA.parent().removeClass('active-submenu');
            return;
          }
          $thisLi.addClass('active-submenu').siblings().removeClass('active-submenu');
        });
    } //eof sumbenu check
  });
  if ($sideHeader.length) {
    jQuery('.toggle_menu_side').on('click', function () {
      var $thisToggler = jQuery(this);
      if ($thisToggler.hasClass('header-slide')) {
        $sideHeader.toggleClass('active-slide-side-header');
      } else {
        if ($thisToggler.parent().hasClass('header_side_right')) {
          $body.toggleClass('active-side-header slide-right');
        } else {
          $body.toggleClass('active-side-header');
        }
      }
    });
    //hidding side header on click outside header
    $body.on('click', function (e) {
      if (!(jQuery(e.target).closest('.page_header_side').length) && !($sideHeader.hasClass('page_header_side_sticked'))) {
        $sideHeader.removeClass('active-slide-side-header');
        $body.removeClass('active-side-header slide-right');
      }
    });
  } //sideHeader check

  //1 and 2/3/4th level mainmenu offscreen fix
  var MainWindowWidth = jQuery(window).width();
  var boxWrapperWidth = jQuery('#box_wrapper').width();
  jQuery(window).on('resize', function () {
    MainWindowWidth = jQuery(window).width();
    boxWrapperWidth = jQuery('#box_wrapper').width();
  });
  //2/3/4 levels
  jQuery('.mainmenu_wrapper .sf-menu').on('mouseover', 'ul li', function () {
    // jQuery('.mainmenu').on('mouseover', 'ul li', function(){
    if (MainWindowWidth > 991) {
      var $this = jQuery(this);
      // checks if third level menu exist         
      var subMenuExist = $this.find('ul').length;
      if (subMenuExist > 0) {
        var subMenuWidth = $this.find('ul, div').first().width();
        var subMenuOffset = $this.find('ul, div').first().parent().offset().left + subMenuWidth;
        // if sub menu is off screen, give new position
        if ((subMenuOffset + subMenuWidth) > boxWrapperWidth) {
          var newSubMenuPosition = subMenuWidth + 0;
          $this.find('ul, div').first().css({
            left: -newSubMenuPosition,
          });
        } else {
          $this.find('ul, div').first().css({
            left: '100%',
          });
        }
      }
    }
    //1st level
  }).on('mouseover', '> li', function () {
    if (MainWindowWidth > 991) {
      var $this = jQuery(this);
      var subMenuExist = $this.find('ul').length;
      if (subMenuExist > 0) {
        var subMenuWidth = $this.find('ul').width();
        var subMenuOffset = $this.find('ul').parent().offset().left - (jQuery(window).width() / 2 - boxWrapperWidth / 2);
        // if sub menu is off screen, give new position
        if ((subMenuOffset + subMenuWidth) > boxWrapperWidth) {
          var newSubMenuPosition = boxWrapperWidth - (subMenuOffset + subMenuWidth);
          $this.find('ul').first().css({
            left: newSubMenuPosition,
          });
        }
      }
    }
  });

  /////////////////////////////////////////
  //single page localscroll and scrollspy//
  /////////////////////////////////////////
  var navHeight = jQuery('.page_header').outerHeight(true);
  //if sidebar nav exists - binding to it. Else - to main horizontal nav
  if (jQuery('.mainmenu_side_wrapper').length) {
    $body.scrollspy({
      target: '.mainmenu_side_wrapper',
      offset: navHeight
    });
  } else if (jQuery('.mainmenu_wrapper').length) {
    $body.scrollspy({
      target: '.mainmenu_wrapper',
      offset: navHeight
    })
  }
  if (jQuery().localScroll) {
    jQuery('.mainmenu_wrapper > ul, .mainmenu_side_wrapper > ul, #land, .scroll_button_wrap').localScroll({
      duration: 900,
      easing: 'easeInOutQuart',
      offset: -navHeight + 40
    });
  }

  //background image teaser and secitons with half image bg
  //put this before prettyPhoto init because image may be wrapped in prettyPhoto link
  jQuery(".bg_teaser, .image_cover").each(function () {
    var $teaser = jQuery(this);
    var $image = $teaser.find("img").first();
    if (!$image.length) {
      $image = $teaser.parent().find("img").first();
    }
    if (!$image.length) {
      return;
    }
    var imagePath = $image.attr("src");
    $teaser.css("background-image", "url(" + imagePath + ")");
    var $imageParent = $image.parent();
    //if image inside link - adding this link, removing gallery to preserve duplicating gallery items
    if ($imageParent.is('a')) {
      $teaser.prepend($image.parent().clone().html(''));
      $imageParent.attr('data-gal', '');
    }
  });

  //toTop
  if (jQuery().UItoTop) {
    jQuery().UItoTop({ easingType: 'easeInOutQuart' });
  }

  //parallax
  if (jQuery().parallax) {
    jQuery('.parallax').parallax("50%", 0.01);
  }

  //prettyPhoto
  if (jQuery().prettyPhoto) {
    jQuery("a[data-gal^='prettyPhoto']").prettyPhoto({
      hook: 'data-gal',
      theme: 'facebook', /* light_rounded / dark_rounded / light_square / dark_square / facebook / pp_default*/
      social_tools: false
    });
  }

  ////////////////////////////////////////
  //init Bootstrap JS components//
  ////////////////////////////////////////
  //bootstrap carousel
  if (jQuery().carousel) {
    jQuery('.carousel').carousel();
  }
  //bootstrap tab - show first tab 
  jQuery('.nav-tabs').each(function () {
    jQuery(this).find('a').first().tab('show');
  });
  jQuery('.tab-content').each(function () {
    jQuery(this).find('.tab-pane').first().addClass('fade in');
  });
  //bootstrap collapse - show first tab 
  jQuery('.panel-group').each(function () {
    jQuery(this).find('a').first().filter('.collapsed').trigger('click');
  });
  //tooltip
  if (jQuery().tooltip) {
    jQuery('[data-toggle="tooltip"]').tooltip();
  }



  //comingsoon counter
  if (jQuery().countdown) {
    //today date plus month for demo purpose
    var demoDate = new Date();
    demoDate.setMonth(demoDate.getMonth() + 1);
    jQuery('#comingsoon-countdown').countdown({ until: demoDate });
  }

  /////////////////////////////////////////////////
  //PHP widgets - contact form, search, MailChimp//
  /////////////////////////////////////////////////

  //contact form processing
  jQuery('form.contact-form').on('submit', function (e) {
    e.preventDefault();
    var $form = jQuery(this);
    jQuery($form).find('span.contact-form-respond').remove();

    //checking on empty values
    jQuery($form).find('[aria-required="true"], [required]').each(function (index) {
      var $thisRequired = jQuery(this);
      if (!$thisRequired.val().length) {
        $thisRequired
          .addClass('invalid')
          .on('focus', function () {
            $thisRequired
              .removeClass('invalid');
          });
      }
    });
    //if one of form fields is empty - exit
    if ($form.find('[aria-required="true"], [required]').hasClass('invalid')) {
      return;
    }

    //sending form data to PHP server if fields are not empty
    var request = $form.serialize();
    var ajax = jQuery.post("contact-form.php", request)
      .done(function (data) {
        jQuery($form).find('[type="submit"]').attr('disabled', false).parent().append('<span class="contact-form-respond highlight">' + data + '</span>');
        //cleaning form
        var $formErrors = $form.find('.form-errors');
        if (!$formErrors.length) {
          $form[0].reset();
        }
      })
      .fail(function (data) {
        jQuery($form).find('[type="submit"]').attr('disabled', false).parent().append('<span class="contact-form-respond highlight">Mail cannot be sent. You need PHP server to send mail.</span>');
      })
  });


  //search modal
  jQuery(".search_modal_button").on('click', function (e) {
    e.preventDefault();
    jQuery('#search_modal').modal('show').find('input').first().focus();
  });
  //search form processing
  jQuery('form.searchform').on('submit', function (e) {

    e.preventDefault();
    var $form = jQuery(this);
    var $searchModal = jQuery('#search_modal');
    $searchModal.find('div.searchform-respond').remove();

    //checking on empty values
    jQuery($form).find('[type="text"]').each(function (index) {
      var $thisField = jQuery(this);
      if (!$thisField.val().length) {
        $thisField
          .addClass('invalid')
          .on('focus', function () {
            $thisField.removeClass('invalid')
          });
      }
    });
    //if one of form fields is empty - exit
    if ($form.find('[type="text"]').hasClass('invalid')) {
      return;
    }

    $searchModal.modal('show');
    //sending form data to PHP server if fields are not empty
    var request = $form.serialize();
    var ajax = jQuery.post("search.php", request)
      .done(function (data) {
        $searchModal.append('<div class="searchform-respond">' + data + '</div>');
      })
      .fail(function (data) {
        $searchModal.append('<div class="searchform-respond">Search cannot be done. You need PHP server to search.</div>');

      })
  });

  //MailChimp subscribe form processing
  jQuery('.signup').on('submit', function (e) {
    e.preventDefault();
    var $form = jQuery(this);
    // update user interface
    $form.find('.response').html('Adding email address...');
    // Prepare query string and send AJAX request
    jQuery.ajax({
      url: 'mailchimp/store-address.php',
      data: 'ajax=true&email=' + escape($form.find('.mailchimp_email').val()),
      success: function (msg) {
        $form.find('.response').html(msg);
      }
    });
  });

  //twitter
  if (jQuery().tweet) {
    jQuery('.twitter').tweet({
      modpath: "./twitter/",
      count: 1,
      avatar_size: 48,
      loading_text: 'loading twitter feed...',
      join_text: 'auto',
      username: 'michaeljackson',
      template: "<span class=\"darklinks\">{user}</span><span class=\"tweet_text\">{tweet_text}</span><span class=\"highlightlinks\">{time}</span>"
    });
  }


  //adding CSS classes for elements that needs different styles depending on they widht width
  //see 'plugins.js' file
  jQuery('#mainteasers .col-lg-4').addWidthClass({
    breakpoints: [500, 600]
  });

  // init timetable
  var $timetable = jQuery('#timetable');
  if ($timetable.length) {
    // bind filter click
    jQuery('#timetable_filter').on('click', 'a', function (e) {
      e.preventDefault();
      e.stopPropagation();
      var $thisA = jQuery(this);
      if ($thisA.hasClass('selected')) {
        // return false;
        return;
      }
      var selector = $thisA.attr('data-filter');
      $timetable
        .find('tbody td')
        .removeClass('current')
        .end()
        .find(selector)
        .closest('td')
        .addClass('current');
      $thisA.closest('ul').find('a').removeClass('selected');
      $thisA.addClass('selected');
    });
  }

  /////////
  //SHOP///
  /////////
  jQuery('#toggle_shop_view').on('click', function (e) {
    e.preventDefault();
    jQuery(this).toggleClass('grid-view');
    jQuery('#products').toggleClass('grid-view list-view');
  });
  //zoom image
  if (jQuery().elevateZoom) {
    jQuery('#product-image').elevateZoom({
      gallery: 'product-image-gallery',
      cursor: 'pointer',
      galleryActiveClass: 'active',
      responsive: true,
      loadingIcon: 'img/AjaxLoader.gif'
    });
  }
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="container">
  <div class="row">
    <div class="col-sm-12 display_table">
      <div class="header_left_logo display_table_cell">
        <a href="index.html" class="logo top_logo text-left">
          <img src="images/logo.png" alt="">
        </a>
      </div>
    </div>
  </div>
</div>
    
asked by Natalia Camacho 02.02.2018 в 17:08
source

1 answer

0

Good day, try to place l $(element).removeClass('hover'); at the end of your script.

Try this:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<div class="container">
  <div class="row">
    <div class="col-sm-12 display_table">
      <div class="header_left_logo display_table_cell">
        <a href="index.html" class="logo top_logo text-left">
          <img src="images/logo.png" alt="">
        </a>
      </div>
    </div>
  </div>
</div>

<script type="text/javascript">
$( document ).ready(function() {
  $(".container").removeClass('hover');
  $(".row").removeClass('hover');
  $(".col-sm-12 display_table").removeClass('hover');
  $(".header_left_logo display_table_cell").removeClass('hover');
  $(".logo top_logo text-left").removeClass('hover');
});
</script>
    
answered by 02.02.2018 в 17:49