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

Move event handlers to methods

parent 5c10b297
...@@ -5,16 +5,8 @@ class @Sidebar ...@@ -5,16 +5,8 @@ class @Sidebar
@addEventListeners() @addEventListeners()
addEventListeners: -> addEventListeners: ->
_this = @ @sidebar.on('click', '.sidebar-collapsed-icon', @, @sidebarCollapseClicked)
@sidebar.on 'click', '.sidebar-collapsed-icon', (e) -> $('.dropdown').on('hidden.gl.dropdown', @, @onSidebarDropdownHidden)
e.preventDefault()
$block = $(@).closest('.block')
_this.openDropdown($block);
$('.dropdown').on 'hidden.gl.dropdown', (e) ->
e.preventDefault()
$block = $(@).closest('.block')
_this.sidebarDropdownHidden($block)
$('.dropdown').on('loading.gl.dropdown', @sidebarDropdownLoading) $('.dropdown').on('loading.gl.dropdown', @sidebarDropdownLoading)
$('.dropdown').on('loaded.gl.dropdown', @sidebarDropdownLoaded) $('.dropdown').on('loaded.gl.dropdown', @sidebarDropdownLoaded)
...@@ -40,6 +32,12 @@ class @Sidebar ...@@ -40,6 +32,12 @@ class @Sidebar
else else
i.show() i.show()
sidebarCollapseClicked: (e) ->
sidebar = e.data
e.preventDefault()
$block = $(@).closest('.block')
sidebar.openDropdown($block);
openDropdown: (blockOrName) -> openDropdown: (blockOrName) ->
$block = if _.isString(blockOrName) then @getBlock(blockOrName) else blockOrName $block = if _.isString(blockOrName) then @getBlock(blockOrName) else blockOrName
...@@ -53,6 +51,12 @@ class @Sidebar ...@@ -53,6 +51,12 @@ class @Sidebar
$block.addClass('collapse-after-update') $block.addClass('collapse-after-update')
$('.page-with-sidebar').addClass('with-overlay') $('.page-with-sidebar').addClass('with-overlay')
onSidebarDropdownHidden: (e) ->
sidebar = e.data
e.preventDefault()
$block = $(@).closest('.block')
sidebar.sidebarDropdownHidden($block)
sidebarDropdownHidden: ($block) -> sidebarDropdownHidden: ($block) ->
if $block.hasClass('collapse-after-update') if $block.hasClass('collapse-after-update')
$block.removeClass('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