Skip to content

Instantly share code, notes, and snippets.

@mwawrusch
Forked from showell/gist:1379677
Created November 20, 2011 05:33
Show Gist options
  • 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