Move event handlers to methods
This commit is contained in:
parent
5c10b29700
commit
9db02e5ba9
|
@ -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
|
||||||
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
|
||||||
$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')
|
||||||
|
|
Loading…
Reference in New Issue