default.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. $(document).ready(function() {
  2. // JSON highlighting.
  3. prettyPrint();
  4. // Bootstrap tooltips.
  5. $('.js-tooltip').tooltip({
  6. delay: 1000,
  7. container: 'body'
  8. });
  9. // Deal with rounded tab styling after tab clicks.
  10. $('a[data-toggle="tab"]:first').on('shown', function(e) {
  11. $(e.target).parents('.tabbable').addClass('first-tab-active');
  12. });
  13. $('a[data-toggle="tab"]:not(:first)').on('shown', function(e) {
  14. $(e.target).parents('.tabbable').removeClass('first-tab-active');
  15. });
  16. $('a[data-toggle="tab"]').click(function() {
  17. document.cookie = "tabstyle=" + this.name + "; path=/";
  18. });
  19. // Store tab preference in cookies & display appropriate tab on load.
  20. var selectedTab = null;
  21. var selectedTabName = getCookie('tabstyle');
  22. if (selectedTabName) {
  23. selectedTabName = selectedTabName.replace(/[^a-z-]/g, '');
  24. }
  25. if (selectedTabName) {
  26. selectedTab = $('.form-switcher a[name=' + selectedTabName + ']');
  27. }
  28. if (selectedTab && selectedTab.length > 0) {
  29. // Display whichever tab is selected.
  30. selectedTab.tab('show');
  31. } else {
  32. // If no tab selected, display rightmost tab.
  33. $('.form-switcher a:first').tab('show');
  34. }
  35. $(window).on('load', function() {
  36. $('#errorModal').modal('show');
  37. });
  38. });