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