From 811aa91cb3ef44870716e6e6b8a77228427b12a3 Mon Sep 17 00:00:00 2001 From: Enoc Date: Mon, 26 Jul 2021 23:37:03 -0600 Subject: [PATCH] Allow enable all documentations --- assets/javascripts/app/router.coffee | 7 +++++++ .../javascripts/templates/sidebar_tmpl.coffee | 5 ++++- assets/javascripts/views/layout/settings.coffee | 16 ++++++++++++++++ assets/stylesheets/components/_sidebar.scss | 17 +++++++++++++++++ 4 files changed, 44 insertions(+), 1 deletion(-) diff --git a/assets/javascripts/app/router.coffee b/assets/javascripts/app/router.coffee index ba25148acd..040a010fb6 100644 --- a/assets/javascripts/app/router.coffee +++ b/assets/javascripts/app/router.coffee @@ -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)-> diff --git a/assets/javascripts/templates/sidebar_tmpl.coffee b/assets/javascripts/templates/sidebar_tmpl.coffee index 46797e5658..1bd4b300f3 100644 --- a/assets/javascripts/templates/sidebar_tmpl.coffee +++ b/assets/javascripts/templates/sidebar_tmpl.coffee @@ -60,7 +60,10 @@ templates.sidebarDisabledList = (html) -> templates.sidebarDisabledVersionedDoc = (doc, versions) -> """#{arrow}#{doc.name}
#{versions}
""" -templates.docPickerHeader = """
Documentation Enable
""" +templates.docPickerHeader = """ +
Documentation Enable
+
Enable all
+""" templates.docPickerNote = """
Tip: for faster and better search results, select only the docs you need.
diff --git a/assets/javascripts/views/layout/settings.coffee b/assets/javascripts/views/layout/settings.coffee index 6941b9cd25..27aa81ab21 100644 --- a/assets/javascripts/views/layout/settings.coffee +++ b/assets/javascripts/views/layout/settings.coffee @@ -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 diff --git a/assets/stylesheets/components/_sidebar.scss b/assets/stylesheets/components/_sidebar.scss index 8813f92dac..831b4137d6 100644 --- a/assets/stylesheets/components/_sidebar.scss +++ b/assets/stylesheets/components/_sidebar.scss @@ -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); + } + +}