add ZURB foundation html5 framework
[disclosr.git] / javascripts / app.js
blob:a/javascripts/app.js -> blob:b/javascripts/app.js
/* Foundation v2.1.4 http://foundation.zurb.com */ /* Foundation v2.1.4 http://foundation.zurb.com */
$(document).ready(function () { $(document).ready(function () {
   
/* Use this js doc for all application specific JS */ /* Use this js doc for all application specific JS */
   
/* TABS --------------------------------- */ /* TABS --------------------------------- */
/* Remove if you don't need :) */ /* Remove if you don't need :) */
   
function activateTab($tab) { function activateTab($tab) {
var $activeTab = $tab.closest('dl').find('a.active'), var $activeTab = $tab.closest('dl').find('a.active'),
contentLocation = $tab.attr("href") + 'Tab'; contentLocation = $tab.attr("href") + 'Tab';
   
//Make Tab Active //Make Tab Active
$activeTab.removeClass('active'); $activeTab.removeClass('active');
$tab.addClass('active'); $tab.addClass('active');
   
//Show Tab Content //Show Tab Content
$(contentLocation).closest('.tabs-content').children('li').hide(); $(contentLocation).closest('.tabs-content').children('li').hide();
$(contentLocation).show(); $(contentLocation).show();
} }
   
$('dl.tabs').each(function () { $('dl.tabs').each(function () {
//Get all tabs //Get all tabs
var tabs = $(this).children('dd').children('a'); var tabs = $(this).children('dd').children('a');
tabs.click(function (e) { tabs.click(function (e) {
activateTab($(this)); activateTab($(this));
}); });
}); });
   
if (window.location.hash) { if (window.location.hash) {
activateTab($('a[href="' + window.location.hash + '"]')); activateTab($('a[href="' + window.location.hash + '"]'));
} }
   
/* ALERT BOXES ------------ */ /* ALERT BOXES ------------ */
$(".alert-box").delegate("a.close", "click", function(event) { $(".alert-box").delegate("a.close", "click", function(event) {
event.preventDefault(); event.preventDefault();
$(this).closest(".alert-box").fadeOut(function(event){ $(this).closest(".alert-box").fadeOut(function(event){
$(this).remove(); $(this).remove();
}); });
}); });
   
   
/* PLACEHOLDER FOR FORMS ------------- */ /* PLACEHOLDER FOR FORMS ------------- */
/* Remove this and jquery.placeholder.min.js if you don't need :) */ /* Remove this and jquery.placeholder.min.js if you don't need :) */
   
$('input, textarea').placeholder(); //$('input, textarea').placeholder();
   
   
   
/* UNCOMMENT THE LINE YOU WANT BELOW IF YOU WANT IE6/7/8 SUPPORT AND ARE USING .block-grids */ /* UNCOMMENT THE LINE YOU WANT BELOW IF YOU WANT IE6/7/8 SUPPORT AND ARE USING .block-grids */
// $('.block-grid.two-up>li:nth-child(2n+1)').css({clear: 'left'}); // $('.block-grid.two-up>li:nth-child(2n+1)').css({clear: 'left'});
// $('.block-grid.three-up>li:nth-child(3n+1)').css({clear: 'left'}); // $('.block-grid.three-up>li:nth-child(3n+1)').css({clear: 'left'});
// $('.block-grid.four-up>li:nth-child(4n+1)').css({clear: 'left'}); // $('.block-grid.four-up>li:nth-child(4n+1)').css({clear: 'left'});
// $('.block-grid.five-up>li:nth-child(5n+1)').css({clear: 'left'}); // $('.block-grid.five-up>li:nth-child(5n+1)').css({clear: 'left'});
   
   
   
/* DROPDOWN NAV ------------- */ /* DROPDOWN NAV ------------- */
   
var currentFoundationDropdown = null; var currentFoundationDropdown = null;
$('.nav-bar li a, .nav-bar li a:after').each(function() { $('.nav-bar li a, .nav-bar li a:after').each(function() {
$(this).data('clicks', 0); $(this).data('clicks', 0);
}); });
$('.nav-bar li a, .nav-bar li a:after').live('click', function(e) { $('.nav-bar li a, .nav-bar li a:after').live('click', function(e) {
e.preventDefault(); e.preventDefault();
if (currentFoundationDropdown !== $(this).index() || currentFoundationDropdown === null) { if (currentFoundationDropdown !== $(this).index() || currentFoundationDropdown === null) {
$(this).data('clicks', 0); $(this).data('clicks', 0);
currentFoundationDropdown = $(this).index(); currentFoundationDropdown = $(this).index();
} }
$(this).data('clicks', ($(this).data('clicks') + 1)); $(this).data('clicks', ($(this).data('clicks') + 1));
var f = $(this).siblings('.flyout'); var f = $(this).siblings('.flyout');
if (!f.is(':visible') && $(this).parent('.has-flyout').length > 1) { if (!f.is(':visible') && $(this).parent('.has-flyout').length > 1) {
$('.nav-bar li .flyout').hide(); $('.nav-bar li .flyout').hide();
f.show(); f.show();
} else if (($(this).data('clicks') > 1) || ($(this).parent('.has-flyout').length < 1)) { } else if (($(this).data('clicks') > 1) || ($(this).parent('.has-flyout').length < 1)) {
window.location = $(this).attr('href'); window.location = $(this).attr('href');
} }
}); });
$('.nav-bar').live('click', function(e) { $('.nav-bar').live('click', function(e) {
e.stopPropagation(); e.stopPropagation();
if ($(e.target).parents().is('.flyout') || $(e.target).is('.flyout')) { if ($(e.target).parents().is('.flyout') || $(e.target).is('.flyout')) {
e.preventDefault(); e.preventDefault();
} }
}); });
// $('body').bind('touchend', function(e) { // $('body').bind('touchend', function(e) {
// if (!$(e.target).parents().is('.nav-bar') || !$(e.target).is('.nav-bar')) { // if (!$(e.target).parents().is('.nav-bar') || !$(e.target).is('.nav-bar')) {
// $('.nav-bar li .flyout').is(':visible').hide(); // $('.nav-bar li .flyout').is(':visible').hide();
// } // }
// }); // });
   
/* DISABLED BUTTONS ------------- */ /* DISABLED BUTTONS ------------- */
/* Gives elements with a class of 'disabled' a return: false; */ /* Gives elements with a class of 'disabled' a return: false; */
   
}); });