by kodablah · 14y ago · 0 comments
linkClickHandler = (e) ->
# can't have meta key
if not e.originalEvent?.ctrlKey and not e.originalEvent?.altKey and not e.originalEvent?.shiftKey
# defer the work so we can kill the link right away
deferred = () =>
href = $(e.target).attr 'href'
if href?
#do something here like history.pushState
setTimeout deferred, 0
# stop bubbling and return false
e.stopPropagation()
return false
else
return true
This gives the users that want to save links and open them in other ways, but still have a good feel when left click only. Clicking on directories in Github source trees demonstrate this well.