Skip to content

Instantly share code, notes, and snippets.

@egervari
Created May 15, 2011 23:13
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 egervari/973664 to your computer and use it in GitHub Desktop.
Save egervari/973664 to your computer and use it in GitHub Desktop.
Dynamic Menu - is supposed to be used by the main coffee value.
class DynamicMenu
constructor: (@settings) ->
$("#{@settings.navigationId} a").click (event) ->
changeContent(event, $(this))
$(@settings.sectionClass).hide()
selectContent(@settings.currentId, false)
selectContent: (id, fade) ->
@settings.currentId = id
if fade is true
$(id).show(@settings.effect)
else
$(id).show()
$("#{@settings.navigationId} a[href=#{@settings.currentId}]").addClass("selected")
deselectContent: (id) ->
$(id).hide(@settings.effect)
$("#{@settings.navigationId} a[href=#{@settings.currentId}]").removeClass("selected")
changeContent: (event, anchor) ->
event.stopImmediatePropagation()
event.preventDefault()
newId = anchor.attr("href")
if newId isnt @settings.currentId
deselectContent(@settings.currentId)
selectContent(newId, true)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment