Skip to content

Instantly share code, notes, and snippets.

@showell
Created November 20, 2011 01:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save showell/1379677 to your computer and use it in GitHub Desktop.
Save showell/1379677 to your computer and use it in GitHub Desktop.
refactoring help
jQuery ->
up = (icon) ->
icon.removeClass('downarrow').addClass('uparrow')
down = (icon) ->
icon.removeClass('uparrow').addClass('downarrow')
toggle = (elem) ->
icon = $(elem).find("span.icon")
if $($(elem).data("toggle")).is(":visible")
up icon
else
down icon
$("h2.toggle").each ->
toggle this
$("h2.toggle").click ->
$($(this).data("toggle")).slideToggle("fast", "linear", =>
toggle this
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment