Closes #73.
Showing the changes to assets/javascripts (5 of 41 files). Show all
Unified · Split
| @@ -1,6 +1,7 @@ | |||
| 1 | class app.Settings | 1 | class app.Settings |
| 2 | SETTINGS_KEY = 'settings' | 2 | SETTINGS_KEY = 'settings' |
| 3 | DOCS_KEY = 'docs' | 3 | DOCS_KEY = 'docs' |
| 4 | DARK_KEY = 'dark' | ||
| 4 | 5 | ||
| 5 | @defaults: -> | 6 | @defaults: -> |
| 6 | count: 0 | 7 | count: 0 |
| @@ -45,13 +46,21 @@ class app.Settings · 38 unmodified lines | |||
| 45 | 46 | ||
| 46 | setDocs: (docs) -> | 47 | setDocs: (docs) -> |
| 47 | try | 48 | try |
| 48 | Cookies.set DOCS_KEY, docs.join('/'), | 49 | Cookies.set DOCS_KEY, docs.join('/'), path: '/', expires: 1e8 |
| 49 | path: '/' | 50 | catch |
| 50 | expires: 1e8 | 51 | return |
| 52 | |||
| 53 | setDark: (value) -> | ||
| 54 | try | ||
| 55 | if value | ||
| 56 | Cookies.set DARK_KEY, '1', path: '/', expires: 1e8 | ||
| 57 | else | ||
| 58 | Cookies.expire DARK_KEY | ||
| 51 | catch | 59 | catch |
| 52 | return | 60 | return |
| 53 | 61 | ||
| 54 | reset: -> | 62 | reset: -> |
| 55 | try Cookies.expire DOCS_KEY | 63 | try Cookies.expire DOCS_KEY |
| 64 | try Cookies.expire DARK_KEY | ||
| 56 | try @store.del(SETTINGS_KEY) | 65 | try @store.del(SETTINGS_KEY) |
| 57 | return | 66 | return |
| @@ -1,5 +1,8 @@ | |||
| 1 | [ | 1 | [ |
| 2 | [ "2015-01-13", | 2 | [ "2015-02-08", |
| 3 | "New dark theme\nClick the icon in the bottom left corner to activate.\n<a href=\"https://github.com/Thibaut/devdocs/issues\" target=\"_blank\">Feedback</a> welcome :)" | ||
| 4 | ], [ | ||
| 5 | "2015-01-13", | ||
| 3 | "<a href=\"/offline\">Offline mode</a> has landed!\nIf you notice any bugs, please report them on <a href=\"https://github.com/Thibaut/devdocs/issues\" target=\"_blank\">GitHub</a>." | 6 | "<a href=\"/offline\">Offline mode</a> has landed!\nIf you notice any bugs, please report them on <a href=\"https://github.com/Thibaut/devdocs/issues\" target=\"_blank\">GitHub</a>." |
| 4 | ], [ | 7 | ], [ |
| 5 | "2014-12-21", | 8 | "2014-12-21", |
| @@ -51,7 +51,10 @@ templates.sidebarPickerNote = """ · 50 unmodified lines | |||
| 51 | sidebarFooter = (html) -> """<div class="_sidebar-footer">#{html}</div>""" | 51 | sidebarFooter = (html) -> """<div class="_sidebar-footer">#{html}</div>""" |
| 52 | 52 | ||
| 53 | templates.sidebarSettings = -> | 53 | templates.sidebarSettings = -> |
| 54 | sidebarFooter """<a class="_sidebar-footer-link _sidebar-footer-edit" data-pick-docs>Select documentation</a>""" | 54 | sidebarFooter """ |
| 55 | <a class="_sidebar-footer-link _sidebar-footer-light" title="Toggle light" data-light></a> | ||
| 56 | <a class="_sidebar-footer-link _sidebar-footer-edit" data-pick-docs>Select documentation</a> | ||
| 57 | """ | ||
| 55 | 58 | ||
| 56 | templates.sidebarSave = -> | 59 | templates.sidebarSave = -> |
| 57 | sidebarFooter """<a class="_sidebar-footer-link _sidebar-footer-save">Save</a>""" | 60 | sidebarFooter """<a class="_sidebar-footer-link _sidebar-footer-save">Save</a>""" |
| @@ -17,6 +17,14 @@ class app.views.Document extends app.View · 16 unmodified lines | |||
| 17 | @activate() | 17 | @activate() |
| 18 | return | 18 | return |
| 19 | 19 | ||
| 20 | toggleLight: -> | ||
| 21 | css = $('link[rel="stylesheet"][data-alt]') | ||
| 22 | alt = css.getAttribute('data-alt') | ||
| 23 | css.setAttribute('data-alt', css.getAttribute('href')) | ||
| 24 | css.setAttribute('href', alt) | ||
| 25 | app.settings.setDark(alt.indexOf('dark') > 0) | ||
| 26 | return | ||
| 27 | |||
| 20 | setTitle: (title) -> | 28 | setTitle: (title) -> |
| 21 | @el.title = if title then "DevDocs/#{title}" else 'DevDocs' | 29 | @el.title = if title then "DevDocs/#{title}" else 'DevDocs' |
| 22 | 30 | ||
| @@ -79,6 +79,9 @@ class app.views.Sidebar extends app.View · 78 unmodified lines | |||
| 79 | if event.target.hasAttribute? 'data-reset-list' | 79 | if event.target.hasAttribute? 'data-reset-list' |
| 80 | $.stopEvent(event) | 80 | $.stopEvent(event) |
| 81 | @reset() | 81 | @reset() |
| 82 | else if event.target.hasAttribute? 'data-light' | ||
| 83 | $.stopEvent(event) | ||
| 84 | app.document.toggleLight() | ||
| 82 | return | 85 | return |
| 83 | 86 | ||
| 84 | onGlobalClick: (event) => | 87 | onGlobalClick: (event) => |