Skip to content

Instantly share code, notes, and snippets.

@brandonc
Forked from zznq/Ugly Conditions
Created September 28, 2011 17:25
Show Gist options
  • Save brandonc/1248567 to your computer and use it in GitHub Desktop.
Save brandonc/1248567 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();
}
@zznq
Copy link

zznq commented Sep 28, 2011

$desc.has(':visible')(quick ? 'hide' : 'slideUp');
$desc.has(':hidden')(quick ? 'show' : 'slidedown');

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment