Tiggles ツ
2/26/2018 - 5:18 PM

Top Accordion fix

This snippet combines the js needed for an accordion w the "top" setting enabled. (tab-style) the latter half of this snippet makes it possible for client to toggle back n forth from accordion to top "tab" styling.

Place outside the doc.ready.

/* ==========================================================================
SW Tabs
========================================================================== */

$('.nav-tabs-top .tabbedcontent-header').click(function(e){

  e.preventDefault();

  var target = $(this).find('a').attr('href');
  target = target.substring(1, target.length);
  
  $('.nav-tabs-top .tabbedcontent-header').removeClass('active');
  $(this).addClass('active');

  $('.tab-content .tab-pane').removeClass('active');
  $(document.getElementById(target)).addClass('active');

});

// Scroll.js

if ($('.sw-accordion').length >= 1) {
	$(function() {
	  $('a[href*=#]:not([href=#])').click(function() {
	    if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
	      var target = $(this.hash);
	      target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
	      if (target.length) {
	        $('html,body').animate({
	          scrollTop: target.offset().top - 100
	        }, 1000);
	        return false;
	      }
	    }
	  });
	});
}