Skip to content

Instantly share code, notes, and snippets.

@zznq
Forked from brandonc/SImpler
Created September 28, 2011 17:45
Show Gist options
  • Save zznq/1248627 to your computer and use it in GitHub Desktop.
Save zznq/1248627 to your computer and use it in GitHub Desktop.
Ugly Nested Conditions
methodShow = (quick ? 'show' : 'slidedown');
methodHide = (quick ? 'hide' : 'slideUp');
if (!$desc.is(':visible')) {
$desc[methodShow]();
} else {
$desc[methodHide[();
}
$desc.has(':visible')[(quick ? 'hide' : 'slideUp')]();
$desc.has(':hidden')[(quick ? 'show' : 'slidedown')]();
if (!$desc.is(':visible')) {
if(quick)
$desc.show();
else
$desc.slideDown();
} else {
if(quick)
$desc.hide();
else
$desc.slideUp();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment