History

Show doc version in search results

Ref #25.

Thibaut Courouble committed 10 years ago

Commit 472d40d1 parent 50154053 files · +31 −17Browse files

Unified · Split

3 files
  1. assets/javascripts/templates/sidebar_tmpl.coffee +7 −6
  2. assets/javascripts/views/sidebar/sidebar_hover.coffee +2 −3
  3. assets/stylesheets/components/_sidebar.scss +22 −8
assets/javascripts/templates/sidebar_tmpl.coffee+7−6
@@ -9,22 +9,23 @@ templates.sidebarDoc = (doc, options = {}) -> · 8 unmodified lines
99 else
1010 link += """<span class="_list-arrow"></span>"""
1111 link += """<span class="_list-count">#{doc.release}</span>""" if doc.release
12− link += "#{doc.name}"
12+ link += """<span class="_list-text">#{doc.name}"""
1313 link += " #{doc.version}" if options.disabled and doc.version
14− link + "</a>"
14+ link + "</span></a>"
1515
1616 templates.sidebarType = (type) ->
17− """<a href="#{type.fullPath()}" class="_list-item _list-dir" data-slug="#{type.slug}"><span class="_list-arrow"></span><span class="_list-count">#{type.count}</span>#{type.name}</a>"""
17+ """<a href="#{type.fullPath()}" class="_list-item _list-dir" data-slug="#{type.slug}"><span class="_list-arrow"></span><span class="_list-count">#{type.count}</span><span class="_list-text">#{type.name}</span></a>"""
1818
1919 templates.sidebarEntry = (entry) ->
2020 """<a href="#{entry.fullPath()}" class="_list-item _list-hover">#{$.escape entry.name}</a>"""
2121
2222 templates.sidebarResult = (entry) ->
23− addon = if entry.isIndex() and app.disabledDocs.contains(entry.doc)
23+ addons = if entry.isIndex() and app.disabledDocs.contains(entry.doc)
2424 """<span class="_list-enable" data-enable="#{entry.doc.slug}">Enable</span>"""
2525 else
2626 """<span class="_list-reveal" data-reset-list title="Reveal in list"></span>"""
27− """<a href="#{entry.fullPath()}" class="_list-item _list-hover _list-result _icon-#{entry.doc.icon}">#{addon}#{$.escape entry.name}</a>"""
27+ addons += """<span class="_list-count">#{entry.doc.version}</span>""" if entry.doc.version
28+ """<a href="#{entry.fullPath()}" class="_list-item _list-hover _list-result _icon-#{entry.doc.icon}">#{addons}<span class="_list-text">#{$.escape entry.name}</span></a>"""
2829
2930 templates.sidebarNoResults = ->
3031 html = """ <div class="_list-note">No results.</div> """
@@ -41,7 +42,7 @@ templates.sidebarLabel = (doc, options = {}) -> · 10 unmodified lines
4142 label += " _icon-#{doc.icon}" unless doc.version
4243 label += """"><input type="checkbox" name="#{doc.slug}" class="_list-checkbox" """
4344 label += "checked" if options.checked
44− label + ">#{doc.fullName}</label>"
45+ label + """><span class="_list-text">#{doc.fullName}</span></label>"""
4546
4647 templates.sidebarVersionedDoc = (doc, versions, options = {}) ->
4748 html = """<div class="_list-item _list-dir _list-rdir _icon-#{doc.icon}"""
assets/javascripts/views/sidebar/sidebar_hover.coffee+2−3
@@ -24,7 +24,7 @@ class app.views.SidebarHover extends app.View · 23 unmodified lines
2424 show: (el) ->
2525 unless el is @cursor
2626 @hide()
27− if @isTarget(el) and @isTruncated(el)
27+ if @isTarget(el) and @isTruncated(el.lastElementChild or el)
2828 @cursor = el
2929 @clone = @makeClone @cursor
3030 $.append document.body, @clone
@@ -48,8 +48,7 @@ class app.views.SidebarHover extends app.View · 17 unmodified lines
4848 return
4949
5050 makeClone: (el) ->
51− clone = el.cloneNode()
52− clone.textContent = el.textContent
51+ clone = el.cloneNode(true)
5352 clone.classList.add 'clone'
5453 clone
5554
assets/stylesheets/components/_sidebar.scss+22−8
@@ -80,14 +80,9 @@ · 79 unmodified lines
8080 ._list-item {
8181 display: block;
8282 position: relative;
83− overflow: hidden;
8483 padding: .25rem .75rem;
8584 line-height: 1.5rem;
8685 font-size: .875rem;
87− white-space: nowrap;
88− word-wrap: normal;
89− overflow-wrap: normal;
90− text-overflow: ellipsis;
9186 cursor: default;
9287 background: $sidebarBackground;
9388 box-shadow: inset -1px 0 $sidebarBorder;
@@ -120,9 +115,23 @@ · 26 unmodified lines
120115 }
121116 }
122117
118+._list-item, ._list-text {
119+ overflow: hidden;
120+ white-space: nowrap;
121+ word-wrap: normal;
122+ overflow-wrap: normal;
123+ text-overflow: ellipsis;
124+}
125+
126+._list-text {
127+ display: block;
128+ pointer-events: none;
129+}
130+
123131 ._list-count, ._list-enable {
124132 float: right;
125133 font-size: .75rem;
134+ margin-left: .375rem;
126135
127136 .focus > &,
128137 .active > & {
@@ -229,6 +238,7 @@ · 100 unmodified lines
229238 padding-right: 1.75rem;
230239
231240 > ._list-reveal { display: block; }
241+ > ._list-count { display: none; }
232242 }
233243
234244 ._list-reveal {
@@ -237,14 +247,14 @@ · 2 unmodified lines
237247 top: 0;
238248 bottom: 0;
239249 right: 0;
240− width: 1.75rem;
250+ width: 2rem;
241251 cursor: pointer;
242252
243253 &:before {
244254 content: '';
245255 position: absolute;
246256 bottom: 50%;
247− left: .5rem;
257+ left: .75rem;
248258 width: .75rem;
249259 height: 1px;
250260 background: rgba($selectionText, .9);
@@ -274,9 +284,9 @@ · 23 unmodified lines
274284
275285 ._list-hover.clone {
276286 position: fixed;
287+ overflow: visible;
277288 z-index: $hoverZ;
278289 left: 0;
279− overflow: visible;
280290 min-width: $sidebarWidth;
281291 padding: .25rem .75rem;
282292 pointer-events: none;
@@ -287,11 +297,15 @@ · 4 unmodified lines
287297
288298 @media #{$mediumScreen} { min-width: $sidebarMediumWidth; }
289299
300+ > ._list-text { display: inline; }
301+
290302 &:not(._list-result) {
291303 padding-left: 2.75rem;
292304
293305 &:before { content: none; }
294306 }
307+
308+ ._list-reveal, ._list-enable { display: none; }
295309 }
296310
297311 //