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
576 B
25 lines
576 B
8 years ago
|
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
|
||
|
$.requestAnimationFrame => $.after(prev, @el)
|
||
|
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
|