Add "enable" link to disabled doc entries in search results

pull/309/head
Thibaut 9 years ago
parent ddf87bb0b8
commit 96abd6756e

@ -18,7 +18,11 @@ templates.sidebarEntry = (entry) ->
"""<a href="#{entry.fullPath()}" class="_list-item _list-hover">#{$.escape entry.name}</a>""" """<a href="#{entry.fullPath()}" class="_list-item _list-hover">#{$.escape entry.name}</a>"""
templates.sidebarResult = (entry) -> templates.sidebarResult = (entry) ->
"""<a href="#{entry.fullPath()}" class="_list-item _list-hover _list-result _icon-#{entry.doc.slug}"><span class="_list-reveal" data-reset-list title="Reveal in list"></span>#{$.escape entry.name}</a>""" addon = if entry.isIndex() and app.disabledDocs.contains(entry.doc)
"""<span class="_list-enable" data-enable="#{entry.doc.slug}">Enable</span>"""
else
"""<span class="_list-reveal" data-reset-list title="Reveal in list"></span>"""
"""<a href="#{entry.fullPath()}" class="_list-item _list-hover _list-result _icon-#{entry.doc.slug}">#{addon}#{$.escape entry.name}</a>"""
templates.sidebarNoResults = -> templates.sidebarNoResults = ->
html = """ <div class="_list-note">No results.</div> """ html = """ <div class="_list-note">No results.</div> """

@ -142,10 +142,10 @@ class app.views.DocList extends app.View
else if slug = event.target.getAttribute('data-enable') else if slug = event.target.getAttribute('data-enable')
$.stopEvent(event) $.stopEvent(event)
doc = app.disabledDocs.findBy('slug', slug) doc = app.disabledDocs.findBy('slug', slug)
app.enableDoc(doc, @onEnable, @onEnable) app.enableDoc(doc, @onEnabled, @onEnabled)
return return
onEnable: => onEnabled: =>
@reset() @reset()
@render() @render()
return return

@ -1,10 +1,13 @@
class app.views.Results extends app.View class app.views.Results extends app.View
@className: '_list' @className: '_list'
@events:
click: 'onClick'
@routes: @routes:
after: 'afterRoute' after: 'afterRoute'
constructor: (@search) -> super constructor: (@sidebar, @search) -> super
deactivate: -> deactivate: ->
if super if super
@ -46,9 +49,20 @@ class app.views.Results extends app.View
@el.firstElementChild?.click() @el.firstElementChild?.click()
return return
onDocEnabled: (doc) ->
app.router.show(doc.fullPath())
@sidebar.onDocEnabled()
afterRoute: (route, context) => afterRoute: (route, context) =>
if route is 'entry' if route is 'entry'
@listSelect.selectByHref context.entry.fullPath() @listSelect.selectByHref context.entry.fullPath()
else else
@listSelect.deselect() @listSelect.deselect()
return return
onClick: (event) =>
return if event.which isnt 1
if slug = event.target.getAttribute('data-enable')
$.stopEvent(event)
doc = app.disabledDocs.findBy('slug', slug)
app.enableDoc(doc, @onDocEnabled.bind(@, doc), $.noop)

@ -17,7 +17,7 @@ class app.views.Sidebar extends app.View
.on 'searching', @showResults .on 'searching', @showResults
.on 'clear', @showDocList .on 'clear', @showDocList
@results = new app.views.Results @search @results = new app.views.Results @, @search
@docList = new app.views.DocList @docList = new app.views.DocList
@docPicker = new app.views.DocPicker unless app.isSingleDoc() @docPicker = new app.views.DocPicker unless app.isSingleDoc()
@ -105,3 +105,7 @@ class app.views.Sidebar extends app.View
@reset() @reset()
@scrollToTop() @scrollToTop()
return return
onDocEnabled: ->
@docList.onEnabled()
@reset()

@ -143,7 +143,7 @@
cursor: pointer; cursor: pointer;
&:hover { text-decoration: underline; } &:hover { text-decoration: underline; }
._list-disabled:hover > & { display: block; } ._list-disabled:hover > &, ._list-result > & { display: block; }
} }
// //

Loading…
Cancel
Save