Sha256: 071a84f995dc75d357db2d2a25fa90bd176d5b9e4edd13f9c12fa8809f58af6b

Contents?: true

Size: 774 Bytes

Versions: 30

Compression:

Stored size: 774 Bytes

Contents

$(document).ready(function() {
  var $tab_with_error = $(".form-control.is-invalid").first().closest('.tab-pane');

  if ($tab_with_error.length > 0) {
    $(".nav.nav-tabs").find("a[href^='#" + $tab_with_error.attr('id') + "']").tab('show');
  } else if (document.location.hash.length > 0) {
    var $tab_from_url = $(".nav.nav-tabs").find("a[href^='" + document.location.hash + "']");

    if ($tab_from_url.length > 0) {
      document.location.hash = ""; // This prevents scrolling to the wrong place in the page
      $tab_from_url.tab("show");
    }
  }
});

$(document).on('click', '[data-click-tab]', function(event) {
  event.preventDefault();

  var href = $(event.currentTarget).attr('href');
  $('.nav.nav-tabs').find("a[href^='" + href + "']").tab('show');
});

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
effective_bootstrap-0.9.35 app/assets/javascripts/effective_bootstrap/tabs.js
effective_bootstrap-0.9.34 app/assets/javascripts/effective_bootstrap/tabs.js
effective_bootstrap-0.9.33 app/assets/javascripts/effective_bootstrap/tabs.js
effective_bootstrap-0.9.32 app/assets/javascripts/effective_bootstrap/tabs.js
effective_bootstrap-0.9.31 app/assets/javascripts/effective_bootstrap/tabs.js
effective_bootstrap-0.9.30 app/assets/javascripts/effective_bootstrap/tabs.js
effective_bootstrap-0.9.29 app/assets/javascripts/effective_bootstrap/tabs.js
effective_bootstrap-0.9.28 app/assets/javascripts/effective_bootstrap/tabs.js
effective_bootstrap-0.9.27 app/assets/javascripts/effective_bootstrap/tabs.js
effective_bootstrap-0.9.26 app/assets/javascripts/effective_bootstrap/tabs.js