jQuery(document).ready(function($){
  $(document).on("click keypress", ".sifency-tab-title", function(e){
    if(e.type === "click" || e.which === 13 || e.which === 32){
      e.preventDefault();
      var $this    = $(this);
      if(!$this.hasClass("active")){
        var tabId   = $this.data("tab"),
            $wrapper = $this.closest(".sifency-tabs-wrapper");

        $wrapper.find(".sifency-tab-title").removeClass("active");
        $this.addClass("active");

        $wrapper.find(".sifency-tab-content").removeClass("active").hide();

        var $target = $wrapper.find('.sifency-tab-content[data-tab="'+tabId+'"]');
        $target.addClass("active").fadeIn(300);

        var $inner = $target.find(".sifency-tabs-inner");
        if($inner.length){
          $inner.html();
          $inner.removeClass("sifency-tabs-inner");
          $inner.get(0).offsetWidth;
          $inner.addClass("sifency-tabs-inner");
        }
      }
    }
  });
});
