Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow enable all documentations feature #1591

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions assets/javascripts/app/router.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,13 @@ class app.Router
settings: (context) ->
return "/#/#{context.path}" if app.isSingleDoc()
@triggerRoute 'settings'

# Allows check all the checkboxes in /settings.
# This event needs to be added runtime since the button is
# added to the sidebar when the page is loaded, not like
# other elements that are hidden and are shown when the page
# loads
app.document.settings.setCheckboxesEvent()
return

offline: (context)->
Expand Down
5 changes: 4 additions & 1 deletion assets/javascripts/templates/sidebar_tmpl.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@ templates.sidebarDisabledList = (html) ->
templates.sidebarDisabledVersionedDoc = (doc, versions) ->
"""<a class="_list-item _list-dir _icon-#{doc.icon} _list-disabled" data-slug="#{doc.slug_without_version}" tabindex="-1">#{arrow}#{doc.name}</a><div class="_list _list-sub">#{versions}</div>"""

templates.docPickerHeader = """<div class="_list-picker-head"><span>Documentation</span> <span>Enable</span></div>"""
templates.docPickerHeader = """
<div class="_list-picker-head"><span>Documentation</span> <span>Enable</span></div>
<div class="_list-picker-head _centered-list-picker-head" id="enable-all"><div>Enable all</div></div>
"""

templates.docPickerNote = """
<div class="_list-note">Tip: for faster and better search results, select only the docs you need.</div>
Expand Down
16 changes: 16 additions & 0 deletions assets/javascripts/views/layout/settings.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,19 @@ class app.views.Settings extends app.View
$.stopEvent(event)
app.router.show '/'
return

setCheckboxesEvent: =>
button = document.getElementById('enable-all')
button.addEventListener 'click', @checkAllCheckboxes
return

checkAllCheckboxes: =>
checkboxes = document.getElementsByClassName('_list-checkbox')
i = 0

while (i < checkboxes.length)
checkboxes[i].checked = true
i++

@addClass('_dirty')
return
17 changes: 17 additions & 0 deletions assets/stylesheets/components/_sidebar.scss
Original file line number Diff line number Diff line change
Expand Up @@ -367,3 +367,20 @@
&:after { visibility: hidden; }
&:hover:after { visibility: visible; }
}

._centered-list-picker-head {
cursor: pointer;
text-aling: center;
color: var(--textColor);
@extend %border-box;

& div{
margin-left: auto;
margin-right: auto;
}

&:active {
box-shadow: inset 0 1px 1px rgba(black, .05), inset 0 1px 4px var(--boxBorder);
}

}