Commit 9db02e5b authored by Alfredo Sumaran's avatar Alfredo Sumaran

Move event handlers to methods

parent 5c10b297
......@@ -5,16 +5,8 @@ class @Sidebar
@addEventListeners()
addEventListeners: ->
_this = @
@sidebar.on 'click', '.sidebar-collapsed-icon', (e) ->
e.preventDefault()
$block = $(@).closest('.block')
_this.openDropdown($block);
$('.dropdown').on 'hidden.gl.dropdown', (e) ->
e.preventDefault()
$block = $(@).closest('.block')
_this.sidebarDropdownHidden($block)
@sidebar.on('click', '.sidebar-collapsed-icon', @, @sidebarCollapseClicked)
$('.dropdown').on('hidden.gl.dropdown', @, @onSidebarDropdownHidden)
$('.dropdown').on('loading.gl.dropdown', @sidebarDropdownLoading)
$('.dropdown').on('loaded.gl.dropdown', @sidebarDropdownLoaded)
......@@ -40,6 +32,12 @@ class @Sidebar
else
i.show()
sidebarCollapseClicked: (e) ->
sidebar = e.data
e.preventDefault()
$block = $(@).closest('.block')
sidebar.openDropdown($block);
openDropdown: (blockOrName) ->
$block = if _.isString(blockOrName) then @getBlock(blockOrName) else blockOrName
......@@ -53,6 +51,12 @@ class @Sidebar
$block.addClass('collapse-after-update')
$('.page-with-sidebar').addClass('with-overlay')
onSidebarDropdownHidden: (e) ->
sidebar = e.data
e.preventDefault()
$block = $(@).closest('.block')
sidebar.sidebarDropdownHidden($block)
sidebarDropdownHidden: ($block) ->
if $block.hasClass('collapse-after-update')
$block.removeClass('collapse-after-update')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment