app.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. $(document).ready(function () {
  2. /* Use this js doc for all application specific JS */
  3. /* TABS --------------------------------- */
  4. /* Remove if you don't need :) */
  5. function activateTab($tab) {
  6. var $activeTab = $tab.closest('dl').find('a.active'),
  7. contentLocation = $tab.attr("href") + 'Tab';
  8. //Make Tab Active
  9. $activeTab.removeClass('active');
  10. $tab.addClass('active');
  11. //Show Tab Content
  12. $(contentLocation).closest('.tabs-content').children('li').hide();
  13. $(contentLocation).show();
  14. }
  15. $('dl.tabs').each(function () {
  16. //Get all tabs
  17. var tabs = $(this).children('dd').children('a');
  18. tabs.click(function (e) {
  19. activateTab($(this));
  20. });
  21. });
  22. if (window.location.hash) {
  23. activateTab($('a[href="' + window.location.hash + '"]'));
  24. }
  25. /* ALERT BOXES ------------ */
  26. $(".alert-box").delegate("a.close", "click", function(event) {
  27. event.preventDefault();
  28. $(this).closest(".alert-box").fadeOut(function(event){
  29. $(this).remove();
  30. });
  31. });
  32. /* PLACEHOLDER FOR FORMS ------------- */
  33. /* Remove this and jquery.placeholder.min.js if you don't need :) */
  34. $('input, textarea').placeholder();
  35. /* UNCOMMENT THE LINE YOU WANT BELOW IF YOU WANT IE6/7/8 SUPPORT AND ARE USING .block-grids */
  36. // $('.block-grid.two-up>li:nth-child(2n+1)').css({clear: 'left'});
  37. // $('.block-grid.three-up>li:nth-child(3n+1)').css({clear: 'left'});
  38. // $('.block-grid.four-up>li:nth-child(4n+1)').css({clear: 'left'});
  39. // $('.block-grid.five-up>li:nth-child(5n+1)').css({clear: 'left'});
  40. /* DROPDOWN NAV ------------- */
  41. var currentFoundationDropdown = null;
  42. $('.nav-bar li a').each(function() {
  43. $(this).data('clicks', 0);
  44. });
  45. $('.nav-bar li a').on('click', function(e) {
  46. e.preventDefault();
  47. if (currentFoundationDropdown !== $(this).index() || currentFoundationDropdown === null) {
  48. $(this).data('clicks', 0);
  49. currentFoundationDropdown = $(this).index();
  50. }
  51. $(this).data('clicks', ($(this).data('clicks') + 1));
  52. var f = $(this).siblings('.flyout');
  53. if (!f.is(':visible') && $(this).parent('.has-flyout').length > 1) {
  54. $('.nav-bar li .flyout').hide();
  55. f.show();
  56. } else if (($(this).data('clicks') > 1) || ($(this).parent('.has-flyout').length < 1)) {
  57. window.location = $(this).attr('href');
  58. }
  59. });
  60. $('.nav-bar').on('click', function(e) {
  61. e.stopPropagation();
  62. if ($(e.target).parents().is('.flyout') || $(e.target).is('.flyout')) {
  63. e.preventDefault();
  64. }
  65. });
  66. // $('body').bind('touchend', function(e) {
  67. // if (!$(e.target).parents().is('.nav-bar') || !$(e.target).is('.nav-bar')) {
  68. // $('.nav-bar li .flyout').is(':visible').hide();
  69. // }
  70. // });
  71. /* DISABLED BUTTONS ------------- */
  72. /* Gives elements with a class of 'disabled' a return: false; */
  73. });