Skip to content

Instantly share code, notes, and snippets.

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