Showing the changes to assets/javascripts/views (3 of 4 files). Show all
Unified · Split
| @@ -39,13 +39,18 @@ class app.views.Document extends app.View · 38 unmodified lines | ||
| 39 | 39 | app.appCache?.updateInBackground() |
| 40 | 40 | return |
| 41 | 41 | |
| 42 | − toggleSidebar: -> | |
| 43 | − sidebarHidden = app.el.classList.contains(HIDE_SIDEBAR_CLASS) | |
| 44 | − app.el.classList[if sidebarHidden then 'remove' else 'add'](HIDE_SIDEBAR_CLASS) | |
| 45 | − app.settings.setLayout(HIDE_SIDEBAR_CLASS, !sidebarHidden) | |
| 42 | + toggleSidebar: (saveLayout = true) -> | |
| 43 | + hasHiddenClass = app.el.classList.contains(HIDE_SIDEBAR_CLASS) | |
| 44 | + forceShow = (!hasHiddenClass || !@hasSidebar()) && !saveLayout | |
| 45 | + app.el.classList[if hasHiddenClass or forceShow then 'remove' else 'add'](HIDE_SIDEBAR_CLASS) | |
| 46 | + return unless saveLayout | |
| 47 | + app.settings.setLayout(HIDE_SIDEBAR_CLASS, !hasHiddenClass) | |
| 46 | 48 | app.appCache?.updateInBackground() |
| 47 | 49 | return |
| 48 | 50 | |
| 51 | + hasSidebar: -> | |
| 52 | + return !app.el.classList.contains(HIDE_SIDEBAR_CLASS) && !app.settings.hasLayout(HIDE_SIDEBAR_CLASS) | |
| 53 | + | |
| 49 | 54 | setTitle: (title) -> |
| 50 | 55 | @el.title = if title then "DevDocs - #{title}" else 'DevDocs API Documentation' |
| 51 | 56 | |
| @@ -55,6 +55,11 @@ class app.views.Resizer extends app.View · 54 unmodified lines | ||
| 55 | 55 | onDragEnd: (event) => |
| 56 | 56 | $.off(window, 'dragover', @onDrag) |
| 57 | 57 | value = event.pageX or (event.screenX - window.screenX) |
| 58 | + if value <= 5 | |
| 59 | + app.document.toggleSidebar() | |
| 60 | + return | |
| 61 | + else if !app.document.hasSidebar() | |
| 62 | + app.document.toggleSidebar(true) | |
| 58 | 63 | if @lastDragValue and not (@lastDragValue - 5 < value < @lastDragValue + 5) # https://github.com/Thibaut/devdocs/issues/265 |
| 59 | 64 | value = @lastDragValue |
| 60 | 65 | @resize(value, true) |
| @@ -68,8 +68,10 @@ class app.views.Search extends app.View · 67 unmodified lines | ||
| 68 | 68 | @value = @input.value |
| 69 | 69 | |
| 70 | 70 | if @value.length |
| 71 | + app.document.toggleSidebar(false) | |
| 71 | 72 | @search() |
| 72 | 73 | else |
| 74 | + app.document.toggleSidebar() unless app.document.hasSidebar() | |
| 73 | 75 | @clear() |
| 74 | 76 | return |
| 75 | 77 | |