Removed hide/show sidebar methods and use toggle instead

pull/398/head
cristian.corcoveanu 9 years ago
parent 96b05b3b17
commit 90cbb0aafe

@ -39,28 +39,12 @@ class app.views.Document extends app.View
app.appCache?.updateInBackground()
return
toggleSidebar: ->
sidebarHidden = app.el.classList.contains(HIDE_SIDEBAR_CLASS)
app.el.classList[if sidebarHidden then 'remove' else 'add'](HIDE_SIDEBAR_CLASS)
app.settings.setLayout(HIDE_SIDEBAR_CLASS, !sidebarHidden)
app.appCache?.updateInBackground()
return
hideSidebar: (saveLayout = true) ->
sidebarHidden = app.el.classList.contains(HIDE_SIDEBAR_CLASS)
return if sidebarHidden
app.el.classList.add(HIDE_SIDEBAR_CLASS)
return unless saveLayout
app.settings.setLayout(HIDE_SIDEBAR_CLASS, true)
app.appCache?.updateInBackground()
return
showSidebar: (saveLayout = true) ->
sidebarHidden = app.el.classList.contains(HIDE_SIDEBAR_CLASS)
return unless sidebarHidden
app.el.classList.remove(HIDE_SIDEBAR_CLASS)
toggleSidebar: (saveLayout = true) ->
hasHiddenClass = app.el.classList.contains(HIDE_SIDEBAR_CLASS)
forceShow = (!hasHiddenClass || !@hasSidebar()) && !saveLayout
app.el.classList[if hasHiddenClass or forceShow then 'remove' else 'add'](HIDE_SIDEBAR_CLASS)
return unless saveLayout
app.settings.setLayout(HIDE_SIDEBAR_CLASS, false)
app.settings.setLayout(HIDE_SIDEBAR_CLASS, !hasHiddenClass)
app.appCache?.updateInBackground()
return

@ -56,10 +56,10 @@ class app.views.Resizer extends app.View
$.off(window, 'dragover', @onDrag)
value = event.pageX or (event.screenX - window.screenX)
if value <= 5
app.document.hideSidebar()
app.document.toggleSidebar()
return
else if !app.document.hasSidebar()
app.document.showSidebar()
app.document.toggleSidebar(true)
if @lastDragValue and not (@lastDragValue - 5 < value < @lastDragValue + 5) # https://github.com/Thibaut/devdocs/issues/265
value = @lastDragValue
@resize(value, true)

@ -68,10 +68,10 @@ class app.views.Search extends app.View
@value = @input.value
if @value.length
app.document.showSidebar(false)
app.document.toggleSidebar(false)
@search()
else
app.document.hideSidebar(false) unless app.document.hasSidebar()
app.document.toggleSidebar() unless app.document.hasSidebar()
@clear()
return

Loading…
Cancel
Save