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() app.appCache?.updateInBackground()
return return
toggleSidebar: -> toggleSidebar: (saveLayout = true) ->
sidebarHidden = app.el.classList.contains(HIDE_SIDEBAR_CLASS) hasHiddenClass = app.el.classList.contains(HIDE_SIDEBAR_CLASS)
app.el.classList[if sidebarHidden then 'remove' else 'add'](HIDE_SIDEBAR_CLASS) forceShow = (!hasHiddenClass || !@hasSidebar()) && !saveLayout
app.settings.setLayout(HIDE_SIDEBAR_CLASS, !sidebarHidden) app.el.classList[if hasHiddenClass or forceShow then 'remove' else 'add'](HIDE_SIDEBAR_CLASS)
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)
return unless saveLayout return unless saveLayout
app.settings.setLayout(HIDE_SIDEBAR_CLASS, false) app.settings.setLayout(HIDE_SIDEBAR_CLASS, !hasHiddenClass)
app.appCache?.updateInBackground() app.appCache?.updateInBackground()
return return

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

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

Loading…
Cancel
Save