mirror of https://github.com/freeCodeCamp/devdocs
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
565 B
25 lines
565 B
class app.views.Menu extends app.View
|
|
@el: '._menu'
|
|
@activeClass: 'active'
|
|
|
|
@events:
|
|
click: 'onClick'
|
|
|
|
init: ->
|
|
$.on document.body, 'click', @onGlobalClick
|
|
return
|
|
|
|
onClick: =>
|
|
prev = @el.previousElementSibling
|
|
$.remove @el
|
|
@delay (=> $.after prev, @el), 200
|
|
return
|
|
|
|
onGlobalClick: (event) =>
|
|
return if event.which isnt 1
|
|
if event.target.hasAttribute?('data-toggle-menu')
|
|
@toggleClass @constructor.activeClass
|
|
else if @hasClass @constructor.activeClass
|
|
@removeClass @constructor.activeClass
|
|
return
|