Showing the changes to assets/javascripts (4 of 12 files). Show all
Unified · Split
| @@ -179,14 +179,6 @@ · 178 unmodified lines | |||
| 179 | # enabled because it doesn't support caching URLs that use CORS. | 179 | # enabled because it doesn't support caching URLs that use CORS. |
| 180 | @config[if @appCache and @settings.hasDocs() then 'index_path' else 'docs_host'] | 180 | @config[if @appCache and @settings.hasDocs() then 'index_path' else 'docs_host'] |
| 181 | 181 | ||
| 182 | toggleSidebar: -> | ||
| 183 | state = @el.getAttribute('data-sidebar') | ||
| 184 | newState = if state == 'visible' then 'hidden' else 'visible' | ||
| 185 | @el.setAttribute('data-sidebar', newState) | ||
| 186 | @settings.setSidebar(newState) | ||
| 187 | @appCache?.updateInBackground() | ||
| 188 | return | ||
| 189 | |||
| 190 | onBootError: (args...) -> | 182 | onBootError: (args...) -> |
| 191 | @trigger 'bootError' | 183 | @trigger 'bootError' |
| 192 | @hideLoading() | 184 | @hideLoading() |
| @@ -4,7 +4,6 @@ class app.Settings · 3 unmodified lines | |||
| 4 | DARK_KEY = 'dark' | 4 | DARK_KEY = 'dark' |
| 5 | LAYOUT_KEY = 'layout' | 5 | LAYOUT_KEY = 'layout' |
| 6 | SIZE_KEY = 'size' | 6 | SIZE_KEY = 'size' |
| 7 | SIDEBAR_KEY = 'sidebar' | ||
| 8 | 7 | ||
| 9 | @defaults: | 8 | @defaults: |
| 10 | count: 0 | 9 | count: 0 |
| @@ -63,10 +62,18 @@ class app.Settings · 52 unmodified lines | |||
| 63 | catch | 62 | catch |
| 64 | return | 63 | return |
| 65 | 64 | ||
| 66 | setLayout: (value) -> | 65 | setLayout: (name, enable) -> |
| 67 | try | 66 | try |
| 68 | if value | 67 | layout = (Cookies.get(LAYOUT_KEY) || '').split(' ') |
| 69 | Cookies.set LAYOUT_KEY, value, path: '/', expires: 1e8 | 68 | $.arrayDelete(layout, '') |
| 69 | |||
| 70 | if enable | ||
| 71 | layout.push(name) if layout.indexOf(name) is -1 | ||
| 72 | else | ||
| 73 | $.arrayDelete(layout, name) | ||
| 74 | |||
| 75 | if layout.length > 0 | ||
| 76 | Cookies.set LAYOUT_KEY, layout.join(' '), path: '/', expires: 1e8 | ||
| 70 | else | 77 | else |
| 71 | Cookies.expire LAYOUT_KEY | 78 | Cookies.expire LAYOUT_KEY |
| 72 | catch | 79 | catch |
| @@ -78,17 +85,10 @@ class app.Settings · 5 unmodified lines | |||
| 78 | catch | 85 | catch |
| 79 | return | 86 | return |
| 80 | 87 | ||
| 81 | setSidebar: (value) -> | ||
| 82 | try | ||
| 83 | Cookies.set SIDEBAR_KEY, value, path: '/', expires: 1e8 | ||
| 84 | catch | ||
| 85 | return | ||
| 86 | |||
| 87 | reset: -> | 88 | reset: -> |
| 88 | try Cookies.expire DOCS_KEY | 89 | try Cookies.expire DOCS_KEY |
| 89 | try Cookies.expire DARK_KEY | 90 | try Cookies.expire DARK_KEY |
| 90 | try Cookies.expire LAYOUT_KEY | 91 | try Cookies.expire LAYOUT_KEY |
| 91 | try Cookies.expire SIZE_KEY | 92 | try Cookies.expire SIZE_KEY |
| 92 | try Cookies.expire SIDEBAR_KEY | ||
| 93 | try @store.del(SETTINGS_KEY) | 93 | try @store.del(SETTINGS_KEY) |
| 94 | return | 94 | return |
| @@ -1,5 +1,6 @@ | |||
| 1 | class app.views.Document extends app.View | 1 | class app.views.Document extends app.View |
| 2 | MAX_WIDTH_CLASS = '_max-width' | 2 | MAX_WIDTH_CLASS = '_max-width' |
| 3 | HIDE_SIDEBAR_CLASS = '_sidebar-hidden' | ||
| 3 | 4 | ||
| 4 | @el: document | 5 | @el: document |
| 5 | 6 | ||
| @@ -34,7 +35,14 @@ class app.views.Document extends app.View · 28 unmodified lines | |||
| 34 | toggleLayout: -> | 35 | toggleLayout: -> |
| 35 | wantsMaxWidth = !app.el.classList.contains(MAX_WIDTH_CLASS) | 36 | wantsMaxWidth = !app.el.classList.contains(MAX_WIDTH_CLASS) |
| 36 | app.el.classList[if wantsMaxWidth then 'add' else 'remove'](MAX_WIDTH_CLASS) | 37 | app.el.classList[if wantsMaxWidth then 'add' else 'remove'](MAX_WIDTH_CLASS) |
| 37 | app.settings.setLayout(if wantsMaxWidth then MAX_WIDTH_CLASS else false) | 38 | app.settings.setLayout(MAX_WIDTH_CLASS, wantsMaxWidth) |
| 39 | app.appCache?.updateInBackground() | ||
| 40 | return | ||
| 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) | ||
| 38 | app.appCache?.updateInBackground() | 46 | app.appCache?.updateInBackground() |
| 39 | return | 47 | return |
| 40 | 48 | ||
| @@ -4,7 +4,7 @@ class app.views.Resizer extends app.View · 3 unmodified lines | |||
| 4 | @events: | 4 | @events: |
| 5 | dragstart: 'onDragStart' | 5 | dragstart: 'onDragStart' |
| 6 | dragend: 'onDragEnd' | 6 | dragend: 'onDragEnd' |
| 7 | dblclick: 'onDbLClick' | 7 | dblclick: 'onDblClick' |
| 8 | 8 | ||
| 9 | @isSupported: -> | 9 | @isSupported: -> |
| 10 | 'ondragstart' of document.createElement('div') and !app.isMobile() | 10 | 'ondragstart' of document.createElement('div') and !app.isMobile() |
| @@ -32,8 +32,8 @@ class app.views.Resizer extends app.View · 21 unmodified lines | |||
| 32 | app.appCache?.updateInBackground() | 32 | app.appCache?.updateInBackground() |
| 33 | return | 33 | return |
| 34 | 34 | ||
| 35 | onDbLClick: (event) => | 35 | onDblClick: (event) -> |
| 36 | app.toggleSidebar() | 36 | app.document.toggleSidebar() |
| 37 | return | 37 | return |
| 38 | 38 | ||
| 39 | onDragStart: (event) => | 39 | onDragStart: (event) => |