History

UI improvements

Thibaut Courouble committed 9 years ago

Commit 0f238601 parent fd03ac139 files · +295 −334Browse files

Showing the changes to assets/javascripts (18 of 39 files). Show all

Unified · Split

18 files
  1. assets/javascripts/templates/pages/about_tmpl.coffee +6 −6
  2. assets/javascripts/templates/pages/help_tmpl.coffee +5 −3
  3. assets/javascripts/templates/pages/news_tmpl.coffee.erb +1 −1
  4. assets/javascripts/templates/pages/offline_tmpl.coffee +1 −1
  5. assets/javascripts/templates/pages/root_tmpl.coffee.erb +0 −9
  6. assets/javascripts/views/content/root_page.coffee +0 −1
  7. assets/javascripts/views/layout/document.coffee +11 −37
  8. assets/javascripts/views/layout/menu.coffee +24 −0
  9. assets/javascripts/views/layout/mobile.coffee +17 −18
  10. assets/javascripts/views/layout/nav.coffee +0 −26
  11. assets/javascripts/views/layout/resizer.coffee +1 −1
  12. assets/javascripts/views/list/list_focus.coffee +6 −6
  13. assets/javascripts/views/misc/notice.coffee +0 −1
  14. assets/javascripts/views/search/search.coffee +1 −1
  15. assets/javascripts/views/sidebar/doc_list.coffee +1 −1
  16. assets/javascripts/views/sidebar/results.coffee +2 −2
  17. assets/javascripts/views/sidebar/sidebar.coffee +41 −14
  18. assets/javascripts/views/view.coffee +7 −0
assets/javascripts/templates/pages/about_tmpl.coffee+6−6
@@ -10,7 +10,7 @@ app.templates.aboutPage = -> """ · 9 unmodified lines
10 </ul>10 </ul>
11 </nav>11 </nav>
12 12
13 <h1 class="_lined-heading">API Documentation Browser</h1>13 <h1 class="_lined-heading">DevDocs: API Documentation Browser</h1>
14 <p>DevDocs combines multiple API documentations in a fast, organized, and searchable interface.14 <p>DevDocs combines multiple API documentations in a fast, organized, and searchable interface.
15 <ul>15 <ul>
16 <li>Created and maintained by <a href="http://thibaut.me">Thibaut Courouble</a>16 <li>Created and maintained by <a href="http://thibaut.me">Thibaut Courouble</a>
@@ -26,7 +26,7 @@ app.templates.aboutPage = -> """ · 9 unmodified lines
26 <p class="_note _note-green">If you like DevDocs, please consider supporting my work on26 <p class="_note _note-green">If you like DevDocs, please consider supporting my work on
27 <a href="https://gratipay.com/devdocs/">Gratipay</a>. Thanks!<br>27 <a href="https://gratipay.com/devdocs/">Gratipay</a>. Thanks!<br>
28 28
29 <h2 class="_lined-heading" id="credits">Credits</h2>29 <h2 class="_block-heading" id="credits">Credits</h2>
30 30
31 <p><strong>Special thanks to:</strong>31 <p><strong>Special thanks to:</strong>
32 <ul>32 <ul>
@@ -45,7 +45,7 @@ app.templates.aboutPage = -> """ · 12 unmodified lines
45 #{("<tr><td>#{c[0]}<td>&copy; #{c[1]}<td><a href=\"#{c[3]}\">#{c[2]}</a>" for c in credits).join('')}45 #{("<tr><td>#{c[0]}<td>&copy; #{c[1]}<td><a href=\"#{c[3]}\">#{c[2]}</a>" for c in credits).join('')}
46 </table>46 </table>
47 47
48 <h2 class="_lined-heading" id="faq">Questions & Answers</h2>48 <h2 class="_block-heading" id="faq">Questions & Answers</h2>
49 <dl>49 <dl>
50 <dt>Where can I suggest new docs and features?50 <dt>Where can I suggest new docs and features?
51 <dd>You can suggest and vote for new docs on the <a href="https://trello.com/b/6BmTulfx/devdocs-documentation">Trello board</a>.<br>51 <dd>You can suggest and vote for new docs on the <a href="https://trello.com/b/6BmTulfx/devdocs-documentation">Trello board</a>.<br>
@@ -56,7 +56,7 @@ app.templates.aboutPage = -> """ · 4 unmodified lines
56 </dl>56 </dl>
57 <p>For anything else, feel free to email me at <a href="mailto:thibaut@devdocs.io">thibaut@devdocs.io</a>.57 <p>For anything else, feel free to email me at <a href="mailto:thibaut@devdocs.io">thibaut@devdocs.io</a>.
58 58
59 <h2 class="_lined-heading" id="copyright">Copyright and License</h2>59 <h2 class="_block-heading" id="copyright">Copyright and License</h2>
60 <p class="_note">60 <p class="_note">
61 <strong>Copyright 2013&ndash;2017 Thibaut Courouble and <a href="https://github.com/Thibaut/devdocs/graphs/contributors">other contributors</a></strong><br>61 <strong>Copyright 2013&ndash;2017 Thibaut Courouble and <a href="https://github.com/Thibaut/devdocs/graphs/contributors">other contributors</a></strong><br>
62 This software is licensed under the terms of the Mozilla Public License v2.0.<br>62 This software is licensed under the terms of the Mozilla Public License v2.0.<br>
@@ -64,7 +64,7 @@ app.templates.aboutPage = -> """ · 1 unmodified line
64 For more information, see the <a href="https://github.com/Thibaut/devdocs/blob/master/COPYRIGHT">COPYRIGHT</a>64 For more information, see the <a href="https://github.com/Thibaut/devdocs/blob/master/COPYRIGHT">COPYRIGHT</a>
65 and <a href="https://github.com/Thibaut/devdocs/blob/master/LICENSE">LICENSE</a> files.65 and <a href="https://github.com/Thibaut/devdocs/blob/master/LICENSE">LICENSE</a> files.
66 66
67 <h2 class="_lined-heading" id="plugins">Plugins and Extensions</h2>67 <h2 class="_block-heading" id="plugins">Plugins and Extensions</h2>
68 <ul>68 <ul>
69 <li><a href="https://chrome.google.com/webstore/detail/devdocs/mnfehgbmkapmjnhcnbodoamcioleeooe">Chrome web app</a>69 <li><a href="https://chrome.google.com/webstore/detail/devdocs/mnfehgbmkapmjnhcnbodoamcioleeooe">Chrome web app</a>
70 <li><a href="https://sublime.wbond.net/packages/DevDocs">Sublime Text plugin</a>70 <li><a href="https://sublime.wbond.net/packages/DevDocs">Sublime Text plugin</a>
@@ -73,7 +73,7 @@ app.templates.aboutPage = -> """ · 2 unmodified lines
73 <li><a href="https://github.com/xuchunyang/DevDocs.el">Emacs Package</a>73 <li><a href="https://github.com/xuchunyang/DevDocs.el">Emacs Package</a>
74 </ul>74 </ul>
75 75
76 <h2 class="_lined-heading" id="privacy">Privacy Policy</h2>76 <h2 class="_block-heading" id="privacy">Privacy Policy</h2>
77 <ul>77 <ul>
78 <li><a href="http://devdocs.io">devdocs.io</a> ("App") is operated by Thibaut Courouble ("We").78 <li><a href="http://devdocs.io">devdocs.io</a> ("App") is operated by Thibaut Courouble ("We").
79 <li>We do not collect personal information.79 <li>We do not collect personal information.
assets/javascripts/templates/pages/help_tmpl.coffee+5−3
@@ -11,7 +11,9 @@ app.templates.helpPage = """ · 10 unmodified lines
11 </ul>11 </ul>
12 </nav>12 </nav>
13 13
14 <h2 class="_lined-heading" id="search">Search</h2>14 <h1 class="_lined-heading" id="search">Help</h2>
15
16 <h2 class="_block-heading" id="search">Search</h2>
15 <p>17 <p>
16 The search is case-insensitive and supports fuzzy matching (for queries longer than two characters).18 The search is case-insensitive and supports fuzzy matching (for queries longer than two characters).
17 For example, searching <code class="_label">bgcp</code> brings up <code class="_label">background-clip</code>.<br>19 For example, searching <code class="_label">bgcp</code> brings up <code class="_label">background-clip</code>.<br>
@@ -42,7 +44,7 @@ app.templates.helpPage = """ · 24 unmodified lines
42 <a href="https://support.mozilla.org/en-US/kb/how-search-from-address-bar">these instructions</a>.44 <a href="https://support.mozilla.org/en-US/kb/how-search-from-address-bar">these instructions</a>.
43 </dl>45 </dl>
44 46
45 <h2 class="_lined-heading" id="shortcuts">Keyboard Shortcuts</h2>47 <h2 class="_block-heading" id="shortcuts">Keyboard Shortcuts</h2>
46 <h3 class="_shortcuts-title">Selection</h3>48 <h3 class="_shortcuts-title">Selection</h3>
47 <dl class="_shortcuts-dl">49 <dl class="_shortcuts-dl">
48 <dt class="_shortcuts-dt">50 <dt class="_shortcuts-dt">
@@ -110,7 +112,7 @@ app.templates.helpPage = """ · 61 unmodified lines
110 <strong>Tip:</strong> If the cursor is no longer in the search field, press <code class="_label">/</code> or112 <strong>Tip:</strong> If the cursor is no longer in the search field, press <code class="_label">/</code> or
111 continue to type and it will refocus the search field and start showing new results.113 continue to type and it will refocus the search field and start showing new results.
112 114
113 <h2 class="_lined-heading" id="abbreviations">Abbreviations</h2>115 <h2 class="_block-heading" id="abbreviations">Abbreviations</h2>
114 <p>Feel free to suggest new abbreviations on <a href="https://github.com/Thibaut/devdocs/issues/new">GitHub</a>.116 <p>Feel free to suggest new abbreviations on <a href="https://github.com/Thibaut/devdocs/issues/new">GitHub</a>.
115 <table class="_abbreviations">117 <table class="_abbreviations">
116 <tr>118 <tr>
assets/javascripts/templates/pages/news_tmpl.coffee.erb+1−1
@@ -15,7 +15,7 @@ app.templates.newsList = (news, options = {}) -> · 14 unmodified lines
15 date = new Date(value[0])15 date = new Date(value[0])
16 if options.years isnt false and year isnt date.getUTCFullYear()16 if options.years isnt false and year isnt date.getUTCFullYear()
17 year = date.getUTCFullYear()17 year = date.getUTCFullYear()
18 result += "<h4>#{year}</h4>"18 result += """<h2 class="_block-heading">#{year}</h2>"""
19 result += newsItem(date, value[1..])19 result += newsItem(date, value[1..])
20 20
21 result21 result
assets/javascripts/templates/pages/offline_tmpl.coffee+1−1
@@ -21,7 +21,7 @@ app.templates.offlinePage = (docs) -> """ · 20 unmodified lines
21 #{docs}21 #{docs}
22 </table>22 </table>
23 <p class="_note"><strong>Note:</strong> your browser may delete DevDocs's offline data if your computer is running low on disk space and you haven't used the app in a while. Load this page before going offline to make sure the data is still there.23 <p class="_note"><strong>Note:</strong> your browser may delete DevDocs's offline data if your computer is running low on disk space and you haven't used the app in a while. Load this page before going offline to make sure the data is still there.
24 <h1 class="_lined-heading">Questions & Answers</h1>24 <h2 class="_block-heading">Questions & Answers</h2>
25 <dl>25 <dl>
26 <dt>How does this work?26 <dt>How does this work?
27 <dd>Each page is cached as a key-value pair in <a href="https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API">IndexedDB</a> (downloaded from a single file).<br>27 <dd>Each page is cached as a key-value pair in <a href="https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API">IndexedDB</a> (downloaded from a single file).<br>
assets/javascripts/templates/pages/root_tmpl.coffee.erb+0−9
@@ -48,15 +48,6 @@ app.templates.intro = """ · 47 unmodified lines
48"""48"""
49<% end %>49<% end %>
50 50
51app.templates.mobileNav = """
52 <nav class="_mobile-nav">
53 <a href="/offline" class="_mobile-nav-link">Offline</a>
54 <a href="/about" class="_mobile-nav-link">About</a>
55 <a href="/news" class="_mobile-nav-link">News</a>
56 <a href="/help" class="_mobile-nav-link">Help</a>
57 </nav>
58"""
59
60app.templates.mobileIntro = """51app.templates.mobileIntro = """
61 <div class="_mobile-intro">52 <div class="_mobile-intro">
62 <h2 class="_intro-title">Welcome!</h2>53 <h2 class="_intro-title">Welcome!</h2>
assets/javascripts/views/content/root_page.coffee+0−1
@@ -9,7 +9,6 @@ class app.views.RootPage extends app.View · 8 unmodified lines
9 9
10 render: ->10 render: ->
11 @empty()11 @empty()
12 @append @tmpl('mobileNav') if app.isMobile()
13 if app.isAndroidWebview()12 if app.isAndroidWebview()
14 @append @tmpl('androidWarning')13 @append @tmpl('androidWarning')
15 else14 else
assets/javascripts/views/layout/document.coffee+11−37
@@ -1,6 +1,6 @@
1class app.views.Document extends app.View1class app.views.Document extends app.View
2 MAX_WIDTH_CLASS = '_max-width'2 MAX_WIDTH_LAYOUT = '_max-width'
3 HIDE_SIDEBAR_CLASS = '_sidebar-hidden'3 SIDEBAR_HIDDEN_LAYOUT = '_sidebar-hidden'
4 4
5 @el: document5 @el: document
6 6
@@ -14,16 +14,12 @@ class app.views.Document extends app.View · 7 unmodified lines
14 superRight: 'onForward'14 superRight: 'onForward'
15 15
16 init: ->16 init: ->
17 @addSubview @nav = new app.views.Nav,17 @addSubview @menu = new app.views.Menu,
18 @addSubview @sidebar = new app.views.Sidebar18 @addSubview @sidebar = new app.views.Sidebar
19 @addSubview @resizer = new app.views.Resizer if app.views.Resizer.isSupported()19 @addSubview @resizer = new app.views.Resizer if app.views.Resizer.isSupported()
20 @addSubview @content = new app.views.Content20 @addSubview @content = new app.views.Content
21 @addSubview @path = new app.views.Path unless app.isSingleDoc() or app.isMobile()21 @addSubview @path = new app.views.Path unless app.isSingleDoc() or app.isMobile()
22 22
23 @sidebar.search
24 .on 'searching', @onSearching
25 .on 'clear', @onSearchClear
26
27 $.on document.body, 'click', @onClick23 $.on document.body, 'click', @onClick
28 24
29 @activate()25 @activate()
@@ -39,39 +35,17 @@ class app.views.Document extends app.View · 9 unmodified lines
39 return35 return
40 36
41 toggleLayout: ->37 toggleLayout: ->
42 wantsMaxWidth = !app.el.classList.contains(MAX_WIDTH_CLASS)38 wantsMaxWidth = !app.el.classList.contains(MAX_WIDTH_LAYOUT)
43 app.el.classList[if wantsMaxWidth then 'add' else 'remove'](MAX_WIDTH_CLASS)39 app.el.classList[if wantsMaxWidth then 'add' else 'remove'](MAX_WIDTH_LAYOUT)
44 app.settings.setLayout(MAX_WIDTH_CLASS, wantsMaxWidth)40 app.settings.setLayout(MAX_WIDTH_LAYOUT, wantsMaxWidth)
45 app.appCache?.updateInBackground()41 app.appCache?.updateInBackground()
46 return42 return
47 43
48 showSidebar: (options = {}) ->44 toggleSidebarLayout: ->
49 @toggleSidebar(options, true)45 shouldHide = !app.settings.hasLayout(SIDEBAR_HIDDEN_LAYOUT)
50 return46 app.el.classList[if shouldHide then 'add' else 'remove'](SIDEBAR_HIDDEN_LAYOUT)
51 47 app.settings.setLayout(SIDEBAR_HIDDEN_LAYOUT, shouldHide)
52 hideSidebar: (options = {}) ->48 app.appCache?.updateInBackground()
53 @toggleSidebar(options, false)
54 return
55
56 toggleSidebar: (options = {}, shouldShow) ->
57 shouldShow ?= if options.save then !@hasSidebar() else app.el.classList.contains(HIDE_SIDEBAR_CLASS)
58 app.el.classList[if shouldShow then 'remove' else 'add'](HIDE_SIDEBAR_CLASS)
59 if options.save
60 app.settings.setLayout(HIDE_SIDEBAR_CLASS, !shouldShow)
61 app.appCache?.updateInBackground()
62 return
63
64 hasSidebar: ->
65 !app.settings.hasLayout(HIDE_SIDEBAR_CLASS)
66
67 onSearching: =>
68 unless @hasSidebar()
69 @showSidebar()
70 return
71
72 onSearchClear: =>
73 unless @hasSidebar()
74 @hideSidebar()
75 return49 return
76 50
77 setTitle: (title) ->51 setTitle: (title) ->
assets/javascripts/views/layout/menu.coffee+24−0
@@ -0,0 +1,24 @@
1class app.views.Menu extends app.View
2 @el: '._menu'
3 @activeClass: 'active'
4
5 @events:
6 click: 'onClick'
7
8 init: ->
9 $.on document.body, 'click', @onGlobalClick
10 return
11
12 onClick: =>
13 prev = @el.previousElementSibling
14 $.remove @el
15 $.requestAnimationFrame => $.after(prev, @el)
16 return
17
18 onGlobalClick: (event) =>
19 return if event.which isnt 1
20 if event.target.hasAttribute?('data-toggle-menu')
21 @toggleClass @constructor.activeClass
22 else if @hasClass @constructor.activeClass
23 @removeClass @constructor.activeClass
24 return
assets/javascripts/views/layout/mobile.coffee+17−18
@@ -35,44 +35,48 @@ class app.views.Mobile extends app.View · 34 unmodified lines
35 FastClick.attach @body35 FastClick.attach @body
36 36
37 $.on @body, 'click', @onClick37 $.on @body, 'click', @onClick
38 $.on $('._home-btn'), 'click', @onClickHome
39 $.on $('._menu-btn'), 'click', @onClickMenu
40 $.on $('._search'), 'touchend', @onTapSearch38 $.on $('._search'), 'touchend', @onTapSearch
41 39
42 @back = $('._back-btn')40 @toggleSidebar = $('button[data-toggle-sidebar]')
41 @toggleSidebar.removeAttribute('hidden')
42 $.on @toggleSidebar, 'click', @onClickToggleSidebar
43
44 @back = $('button[data-back]')
45 @back.removeAttribute('hidden')
43 $.on @back, 'click', @onClickBack46 $.on @back, 'click', @onClickBack
44 47
45 @forward = $('._forward-btn')48 @forward = $('button[data-forward]')
49 @forward.removeAttribute('hidden')
46 $.on @forward, 'click', @onClickForward50 $.on @forward, 'click', @onClickForward
47 51
48 app.document.sidebar.search52 app.document.sidebar.search
49 .on 'searching', @showSidebar53 .on 'searching', @showSidebar
50 .on 'clear', @hideSidebar
51 54
52 @activate()55 @activate()
53 return56 return
54 57
55 showSidebar: =>58 showSidebar: =>
56 if @isSidebarShown()59 if @isSidebarShown()
57 @body.scrollTop = 060 window.scrollTo 0, 0
58 return61 return
59 62
60 @contentTop = @body.scrollTop63 @contentTop = window.scrollY
61 @content.style.display = 'none'64 @content.style.display = 'none'
62 @sidebar.style.display = 'block'65 @sidebar.style.display = 'block'
63 66
64 if selection = @findByClass app.views.ListSelect.activeClass67 if selection = @findByClass app.views.ListSelect.activeClass
65 $.scrollTo selection, @body, 'center'68 scrollContainer = if window.scrollY is @body.scrollTop then @body else document.documentElement
69 $.scrollTo selection, scrollContainer, 'center'
66 else70 else
67 @body.scrollTop = @findByClass(app.views.ListFold.activeClass) and @sidebarTop or 071 window.scrollTo 0, @findByClass(app.views.ListFold.activeClass) and @sidebarTop or 0
68 return72 return
69 73
70 hideSidebar: =>74 hideSidebar: =>
71 return unless @isSidebarShown()75 return unless @isSidebarShown()
72 @sidebarTop = @body.scrollTop76 @sidebarTop = window.scrollY
73 @sidebar.style.display = 'none'77 @sidebar.style.display = 'none'
74 @content.style.display = 'block'78 @content.style.display = 'block'
75 @body.scrollTop = @contentTop or 079 window.scrollTo 0, @contentTop or 0
76 return80 return
77 81
78 isSidebarShown: ->82 isSidebarShown: ->
@@ -89,17 +93,12 @@ class app.views.Mobile extends app.View · 10 unmodified lines
89 onClickForward: =>93 onClickForward: =>
90 history.forward()94 history.forward()
91 95
92 onClickHome: =>96 onClickToggleSidebar: =>
93 app.shortcuts.trigger 'escape'
94 @hideSidebar()
95 return
96
97 onClickMenu: =>
98 if @isSidebarShown() then @hideSidebar() else @showSidebar()97 if @isSidebarShown() then @hideSidebar() else @showSidebar()
99 return98 return
100 99
101 onTapSearch: =>100 onTapSearch: =>
102 @body.scrollTop = 0101 window.scrollTo 0, 0
103 102
104 afterRoute: =>103 afterRoute: =>
105 @hideSidebar()104 @hideSidebar()
assets/javascripts/views/layout/nav.coffee+0−26
@@ -1,26 +0,0 @@
1class app.views.Nav extends app.View
2 @el: '._nav'
3 @activeClass: '_nav-current'
4
5 @routes:
6 after: 'afterRoute'
7
8 select: (href) ->
9 @deselect()
10 if @current = @find "a[href='#{href}']"
11 @current.classList.add @constructor.activeClass
12 @current.setAttribute 'tabindex', '-1'
13 return
14
15 deselect: ->
16 if @current
17 @current.classList.remove @constructor.activeClass
18 @current.removeAttribute 'tabindex'
19 @current = null
20 return
21
22 afterRoute: (route, context) =>
23 if route in ['page', 'offline']
24 @select context.pathname
25 else
26 @deselect()
assets/javascripts/views/layout/resizer.coffee+1−1
@@ -35,7 +35,7 @@ class app.views.Resizer extends app.View · 34 unmodified lines
35 return35 return
36 36
37 onClick: ->37 onClick: ->
38 app.document.toggleSidebar(save: true)38 app.document.toggleSidebarLayout()
39 return39 return
40 40
41 onDragStart: (event) =>41 onDragStart: (event) =>
assets/javascripts/views/list/list_focus.coffee+6−6
@@ -14,7 +14,7 @@ class app.views.ListFocus extends app.View · 13 unmodified lines
14 14
15 constructor: (@el) ->15 constructor: (@el) ->
16 super16 super
17 @focus = $.framify(@focus, @)17 @focusOnNextFrame = $.framify(@focus, @)
18 18
19 focus: (el) ->19 focus: (el) ->
20 if el and not el.classList.contains @constructor.activeClass20 if el and not el.classList.contains @constructor.activeClass
@@ -87,22 +87,22 @@ class app.views.ListFocus extends app.View · 66 unmodified lines
87 87
88 onDown: =>88 onDown: =>
89 if cursor = @getCursor()89 if cursor = @getCursor()
90 @focus @findNext(cursor)90 @focusOnNextFrame @findNext(cursor)
91 else91 else
92 @focus @findByTag('a')92 @focusOnNextFrame @findByTag('a')
93 return93 return
94 94
95 onUp: =>95 onUp: =>
96 if cursor = @getCursor()96 if cursor = @getCursor()
97 @focus @findPrev(cursor)97 @focusOnNextFrame @findPrev(cursor)
98 else98 else
99 @focus @findLastByTag('a')99 @focusOnNextFrame @findLastByTag('a')
100 return100 return
101 101
102 onLeft: =>102 onLeft: =>
103 cursor = @getCursor()103 cursor = @getCursor()
104 if cursor and not cursor.classList.contains(app.views.ListFold.activeClass) and cursor.parentElement isnt @el104 if cursor and not cursor.classList.contains(app.views.ListFold.activeClass) and cursor.parentElement isnt @el
105 @focus cursor.parentElement.previousSibling105 @focusOnNextFrame cursor.parentElement.previousSibling
106 return106 return
107 107
108 onEnter: =>108 onEnter: =>
assets/javascripts/views/misc/notice.coffee+0−1
@@ -18,7 +18,6 @@ class app.views.Notice extends app.View · 17 unmodified lines
18 return18 return
19 19
20 show: ->20 show: ->
21 @addClass '_top' if @type is 'disabledDoc'
22 @html @tmpl("#{@type}Notice", @args...)21 @html @tmpl("#{@type}Notice", @args...)
23 @prependTo $('._app')22 @prependTo $('._app')
24 return23 return
assets/javascripts/views/search/search.coffee+1−1
@@ -130,7 +130,7 @@ class app.views.Search extends app.View · 129 unmodified lines
130 if event.target is @resetLink130 if event.target is @resetLink
131 $.stopEvent(event)131 $.stopEvent(event)
132 @reset()132 @reset()
133 @focus()133 app.document.onEscape()
134 return134 return
135 135
136 onSubmit: (event) ->136 onSubmit: (event) ->
assets/javascripts/views/sidebar/doc_list.coffee+1−1
@@ -148,7 +148,7 @@ class app.views.DocList extends app.View · 147 unmodified lines
148 return148 return
149 149
150 scrollTo: (model) ->150 scrollTo: (model) ->
151 $.scrollTo @find("a[href='#{model.fullPath()}']"), null, 'top', margin: 0151 $.scrollTo @find("a[href='#{model.fullPath()}']"), null, 'top', margin: if app.isMobile() then 48 else 0
152 return152 return
153 153
154 toggleDisabled: ->154 toggleDisabled: ->
assets/javascripts/views/sidebar/results.coffee+2−2
@@ -15,8 +15,8 @@ class app.views.Results extends app.View · 14 unmodified lines
15 return15 return
16 16
17 init: ->17 init: ->
18 @addSubview @listSelect = new app.views.ListSelect @el
19 @addSubview @listFocus = new app.views.ListFocus @el unless app.isMobile()18 @addSubview @listFocus = new app.views.ListFocus @el unless app.isMobile()
19 @addSubview @listSelect = new app.views.ListSelect @el
20 20
21 @search21 @search
22 .on 'results', @onResults22 .on 'results', @onResults
@@ -42,7 +42,7 @@ class app.views.Results extends app.View · 19 unmodified lines
42 return42 return
43 43
44 focusFirst: ->44 focusFirst: ->
45 @listFocus?.focus @el.firstElementChild45 @listFocus?.focusOnNextFrame @el.firstElementChild
46 return46 return
47 47
48 openFirst: ->48 openFirst: ->
assets/javascripts/views/sidebar/sidebar.coffee+41−14
@@ -3,6 +3,7 @@ class app.views.Sidebar extends app.View · 2 unmodified lines
3 3
4 @events:4 @events:
5 focus: 'onFocus'5 focus: 'onFocus'
6 select: 'onSelect'
6 click: 'onClick'7 click: 'onClick'
7 8
8 @shortcuts:9 @shortcuts:
@@ -14,8 +15,8 @@ class app.views.Sidebar extends app.View · 5 unmodified lines
14 @addSubview @search = new app.views.Search15 @addSubview @search = new app.views.Search
15 16
16 @search17 @search
17 .on 'searching', @showResults18 .on 'searching', @onSearching
18 .on 'clear', @showDocList19 .on 'clear', @onSearchClear
19 .scope20 .scope
20 .on 'change', @onScopeChange21 .on 'change', @onScopeChange
21 22
@@ -27,7 +28,15 @@ class app.views.Sidebar extends app.View · 5 unmodified lines
27 $.on document, 'click', @onGlobalClick if @docPicker28 $.on document, 'click', @onGlobalClick if @docPicker
28 return29 return
29 30
30 show: (view) ->31 display: ->
32 @el.style.display = 'block'
33 return
34
35 resetDisplay: ->
36 @el.style.display = '' unless @el.style.display is 'none'
37 return
38
39 showView: (view) ->
31 unless @view is view40 unless @view is view
32 @hover?.hide()41 @hover?.hide()
33 @saveScrollPosition()42 @saveScrollPosition()
@@ -44,28 +53,29 @@ class app.views.Sidebar extends app.View · 10 unmodified lines
44 @append @tmpl('sidebarSettings') if @view is @docList and @docPicker53 @append @tmpl('sidebarSettings') if @view is @docList and @docPicker
45 return54 return
46 55
47 showDocList: (reset) =>56 showDocList: ->
48 @show @docList57 @showView @docList
49 if reset is true
50 @docList.reset(revealCurrent: true)
51 @search.reset()
52 return58 return
53 59
54 showDocPicker: =>60 showDocPicker: =>
55 @show @docPicker61 @showView @docPicker
56 return62 return
57 63
58 showResults: =>64 showResults: =>
59 @show @results65 @showView @results
66 return
67
68 reset: ->
69 @display()
70 @showDocList()
71 @docList.reset()
72 @search.reset()
60 return73 return
61 74
62 onReady: =>75 onReady: =>
63 @view = @docList76 @view = @docList
64 @render()77 @render()
65 @view.activate()78 @view.activate()
66
67 reset: ->
68 @showDocList true
69 return79 return
70 80
71 onScopeChange: (newDoc, previousDoc) =>81 onScopeChange: (newDoc, previousDoc) =>
@@ -90,15 +100,30 @@ class app.views.Sidebar extends app.View · 18 unmodified lines
90 @el.scrollTop = 0100 @el.scrollTop = 0
91 return101 return
92 102
103 onSearching: =>
104 @display()
105 @showResults()
106 return
107
108 onSearchClear: =>
109 @resetDisplay()
110 @showDocList()
111 return
112
93 onFocus: (event) =>113 onFocus: (event) =>
114 @display()
94 $.scrollTo event.target, @el, 'continuous', bottomGap: 2 unless event.target is @el115 $.scrollTo event.target, @el, 'continuous', bottomGap: 2 unless event.target is @el
95 return116 return
96 117
118 onSelect: =>
119 @resetDisplay()
120 return
121
97 onClick: (event) =>122 onClick: (event) =>
98 return if event.which isnt 1123 return if event.which isnt 1
99 if event.target.hasAttribute? 'data-reset-list'124 if event.target.hasAttribute? 'data-reset-list'
100 $.stopEvent(event)125 $.stopEvent(event)
101 @reset()126 @onAltR()
102 else if event.target.hasAttribute? 'data-light'127 else if event.target.hasAttribute? 'data-light'
103 $.stopEvent(event)128 $.stopEvent(event)
104 document.activeElement?.blur()129 document.activeElement?.blur()
@@ -120,6 +145,8 @@ class app.views.Sidebar extends app.View · 15 unmodified lines
120 145
121 onAltR: =>146 onAltR: =>
122 @reset()147 @reset()
148 @docList.reset(revealCurrent: true)
149 @display()
123 return150 return
124 151
125 onEscape: =>152 onEscape: =>
assets/javascripts/views/view.coffee+7−0
@@ -35,6 +35,13 @@ class app.View · 34 unmodified lines
35 @el.classList.remove(name)35 @el.classList.remove(name)
36 return36 return
37 37
38 toggleClass: (name) ->
39 @el.classList.toggle(name)
40 return
41
42 hasClass: (name) ->
43 @el.classList.contains(name)
44
38 resetClass: ->45 resetClass: ->
39 @el.className = @originalClassName or ''46 @el.className = @originalClassName or ''
40 if @constructor.className47 if @constructor.className