Skip to content

Instantly share code, notes, and snippets.

@JGallardo
Created July 23, 2013 22:37
Show Gist options
  • Save JGallardo/6066784 to your computer and use it in GitHub Desktop.
Save JGallardo/6066784 to your computer and use it in GitHub Desktop.
I have these nested statements and this works but I am looking to make a cleaner version so that I can scale this properly and it does not get too "spaghetti" like.
/* -----------------------------------------
Global
----------------------------------------- */
$(window).load(checkWindowSize);
$(window).resize(checkWindowSize);
/* -----------------------------------------
Home Page - shipping.aspx
----------------------------------------- */
$('div#homelinks div').addClass('panel');
function checkWindowSize() {
if ( $(window).width() < 1200 ) {
$('div.responsiveContainer').addClass('row');
$('#homelinks div.panel:not(:last-child)').addClass('large-4 small-11 columns');
$('#homelinks div.panel:last-child').addClass('small-11 columns');
if ( $(window).width() < 380 ) {
$('span.shippingPhone').addClass('block');
$('div#footer ul li').addClass('button medium secondary expanded block');
}
else {
$('span.shippingPhone').removeClass('block');
$('div#footer ul li').removeClass('button medium secondary expanded block');
}
}
else {
$('div.responsiveContainer').removeClass('row');
$('#homelinks div.panel:not(:last-child)').removeClass('large-4 small-11 columns');
$('#homelinks div.panel:last-child').removeClass('small-11 columns');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment