govuk_tech_docs 2.4.3 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of govuk_tech_docs might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/.travis.yml +1 -1
- data/CHANGELOG.md +14 -0
- data/lib/assets/javascripts/_modules/search.js +59 -66
- data/lib/assets/javascripts/_modules/table-of-contents.js +0 -1
- data/lib/assets/stylesheets/modules/_search.scss +51 -73
- data/lib/assets/stylesheets/modules/_technical-documentation.scss +0 -4
- data/lib/assets/stylesheets/modules/_toc.scss +0 -3
- data/lib/govuk_tech_docs/version.rb +1 -1
- data/lib/govuk_tech_docs.rb +2 -0
- data/lib/source/layouts/_search.erb +0 -7
- data/lib/source/search/index.html.erb +31 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dbe80b6133cdaf41e2ab339250489d0a8c72f86cc88dc89f7e51c2340306a4c9
|
4
|
+
data.tar.gz: f79167cb25923c99056e776a289dfa7124643c251b19633e2f01b7995d04df2a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a32ec9f65bf6a326b7300575fd101a36663a982160b81462b0b57854ecd13b8a3fa9116cc93a4702f4bd0fcfb04480a1d787f61522b23a974cd7878250a86086
|
7
|
+
data.tar.gz: a978877e74111d7055b07682d32dc8e09c5e5aa972e6e143c144a3261a734b57b8257273e7afd3f850d657fd87d9b35744bfa87283a88450c3ca2eb7b1b0c33a
|
data/.travis.yml
CHANGED
@@ -13,7 +13,7 @@ deploy:
|
|
13
13
|
provider: rubygems
|
14
14
|
gem: govuk_tech_docs
|
15
15
|
api_key:
|
16
|
-
secure:
|
16
|
+
secure: "pFaDlf2VfJAv/EwTFQTdHQFlFRLxtNnipcJyFG0Dvn7itvETKzs5+91gnXQAJuUzGBgXSidHgMkmPTsmWM4k2wbOcHopir9ThSKf0OUtI6o/5GqCU92BpLNJ/Ykhf+wyz9ai6HWX+HN5KRDqpeiuwhraiQjy/tg6lwsauBU8sB80wvUgYYM6oXijHfVwPUkXdhqYTIj20S0M868yYGtf4IInHds8M85TSNor79TFvRd0SFLO7cS+bftqxnNo1mYuBzVXls3POjq59WX+yG8+vS9Sr/tHHuKxw1nho95Fnjf8RYzdxD45osCrXAu3JIbWyJjF6AmQd87zILhdl8n0KNf4tbpFVM+SXVUjMZ2ERvcS1v+nBybVzU3uPwskGZNfWMtCOS401yRF3A21xzNoS916gZrTUSvHjsMcNhzJAZCsEx6MGFVTMzfe5slfWQCPk8k9wBHjyUyC7dl0h5g9qo3jTDnafcpQdnWGOSGgwCxgTaYT1NFfV3M5YpdGevorkOnE6EmWtU67mdtjzRyVvMWc8obqBWdyYnxqrBYKnHDeu/LhtJq3Gvqt/IExwAI8Q1Q7j296hzfmYMcgnETctLNZWoIa4sESDDVMlspcZKqCsrxytDeBFm/yMqVp12S7cjoQbt+fItTl3Bh3BP56j+3fqJlFvTPX4FIKUaaRLy0="
|
17
17
|
on:
|
18
18
|
repo: alphagov/tech-docs-gem
|
19
19
|
branch: master
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,20 @@
|
|
2
2
|
|
3
3
|
## Unreleased
|
4
4
|
|
5
|
+
## 3.0.0
|
6
|
+
|
7
|
+
### Breaking changes
|
8
|
+
|
9
|
+
The search user experience is now more accessible for screenreader users. Search results are now on a separate page instead of a modal window.
|
10
|
+
|
11
|
+
Users can no longer see search results as they type. They must press the Return key or select the search button to see the search results page.
|
12
|
+
|
13
|
+
This was added in [pull request #263: Change search to only show results after submit](https://github.com/alphagov/tech-docs-gem/pull/263).
|
14
|
+
|
15
|
+
### Fixes
|
16
|
+
|
17
|
+
- [#265: Fix mark styles in Windows High Contrast Mode](https://github.com/alphagov/tech-docs-gem/pull/265)
|
18
|
+
|
5
19
|
## 2.4.3
|
6
20
|
|
7
21
|
- [#236: Fix search 'autocomplete' behaviour](https://github.com/alphagov/tech-docs-gem/pull/236)
|
@@ -6,35 +6,48 @@
|
|
6
6
|
Modules.Search = function Search () {
|
7
7
|
var s = this
|
8
8
|
var $html = $('html')
|
9
|
-
var $tocNav
|
10
9
|
var $searchForm
|
11
10
|
var $searchLabel
|
12
11
|
var $searchInput
|
13
12
|
var $searchResults
|
14
13
|
var $searchResultsTitle
|
15
14
|
var $searchResultsWrapper
|
16
|
-
var $
|
15
|
+
var $searchHelp
|
17
16
|
var results
|
18
17
|
var query
|
19
|
-
var queryTimer
|
20
18
|
var maxSearchEntries = 20
|
21
19
|
|
22
20
|
this.start = function start ($element) {
|
23
21
|
$searchForm = $element.find('form')
|
24
22
|
$searchInput = $element.find('#search')
|
25
23
|
$searchLabel = $element.find('.search__label')
|
26
|
-
$searchResultsWrapper = $
|
24
|
+
$searchResultsWrapper = $('#search-results')
|
27
25
|
$searchResults = $searchResultsWrapper.find('.search-results__content')
|
28
26
|
$searchResultsTitle = $searchResultsWrapper.find('.search-results__title')
|
29
|
-
$
|
30
|
-
|
31
|
-
|
32
|
-
attach()
|
27
|
+
$searchHelp = $('#search-help')
|
28
|
+
|
29
|
+
changeSearchAction()
|
33
30
|
changeSearchLabel()
|
31
|
+
|
32
|
+
// Only do searches on the search page
|
33
|
+
if (s.isOnSearchPage()) {
|
34
|
+
s.downloadSearchIndex()
|
35
|
+
$html.addClass('has-search-results-open')
|
36
|
+
|
37
|
+
if (window.location.search) {
|
38
|
+
query = s.getQuery()
|
39
|
+
if (query) {
|
40
|
+
$searchInput.val(query)
|
41
|
+
doSearch(query)
|
42
|
+
doAnalytics()
|
43
|
+
document.title = query + ' - ' + document.title
|
44
|
+
}
|
45
|
+
}
|
46
|
+
}
|
34
47
|
}
|
35
48
|
|
36
49
|
this.downloadSearchIndex = function downloadSearchIndex () {
|
37
|
-
updateTitle('Loading search
|
50
|
+
updateTitle('Loading search results')
|
38
51
|
$.ajax({
|
39
52
|
url: '/search.json',
|
40
53
|
cache: true,
|
@@ -48,46 +61,45 @@
|
|
48
61
|
})
|
49
62
|
}
|
50
63
|
|
51
|
-
function
|
52
|
-
//
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
renderResults(query)
|
59
|
-
updateTitle()
|
60
|
-
})
|
61
|
-
if (window.ga) {
|
62
|
-
window.clearTimeout(queryTimer)
|
63
|
-
queryTimer = window.setTimeout(sendQueryToAnalytics, 1000)
|
64
|
-
}
|
65
|
-
})
|
64
|
+
function changeSearchAction () {
|
65
|
+
// We need JavaScript to do search, so if JS is not available the search
|
66
|
+
// input sends the query string to Google. This JS function changes the
|
67
|
+
// input to instead send it to the search page.
|
68
|
+
$searchForm.prop('action', '/search')
|
69
|
+
$searchForm.find('input[name="as_sitesearch"]').remove()
|
70
|
+
}
|
66
71
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
e.preventDefault()
|
71
|
-
showResults()
|
72
|
-
var $firstResult = $searchResults.find('.search-result__title a').first()
|
73
|
-
if ($firstResult.length) {
|
74
|
-
$firstResult.focus()
|
75
|
-
} else {
|
76
|
-
// if there are no results, show the "0 results" state
|
77
|
-
results = []
|
78
|
-
updateTitle()
|
79
|
-
}
|
80
|
-
})
|
72
|
+
function changeSearchLabel () {
|
73
|
+
$searchLabel.text('Search this documentation')
|
74
|
+
}
|
81
75
|
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
76
|
+
this.isOnSearchPage = function isOnSearchPage () {
|
77
|
+
return Boolean(window.location.pathname.match(/\/search(\/|\/index.html)?$/))
|
78
|
+
}
|
79
|
+
|
80
|
+
this.getQuery = function getQuery () {
|
81
|
+
var query = decodeURIComponent(
|
82
|
+
window.location.search
|
83
|
+
.match(/q=([^&]*)/)[1]
|
84
|
+
.replace(/\+/g, ' ')
|
85
|
+
)
|
86
|
+
return query
|
87
|
+
}
|
88
|
+
|
89
|
+
function doSearch (query) {
|
90
|
+
s.search(query, function (r) {
|
91
|
+
results = r
|
92
|
+
renderResults(query)
|
93
|
+
updateTitle()
|
87
94
|
})
|
95
|
+
}
|
88
96
|
|
89
|
-
|
97
|
+
// TODO: remove this and sendQueryToAnalytics in a future breaking release
|
98
|
+
function doAnalytics () {
|
90
99
|
if (window.ga) {
|
100
|
+
sendQueryToAnalytics()
|
101
|
+
|
102
|
+
// Attach analytics events to search result clicks
|
91
103
|
$searchResults.on('click', '.search-result__title a', function () {
|
92
104
|
var href = $(this).attr('href')
|
93
105
|
ga('send', {
|
@@ -99,15 +111,6 @@
|
|
99
111
|
})
|
100
112
|
})
|
101
113
|
}
|
102
|
-
|
103
|
-
// When selecting navigation link, close the search results.
|
104
|
-
$('#toc').on('click', 'a', function (e) {
|
105
|
-
hideResults()
|
106
|
-
})
|
107
|
-
}
|
108
|
-
|
109
|
-
function changeSearchLabel () {
|
110
|
-
$searchLabel.text('Search this documentation')
|
111
114
|
}
|
112
115
|
|
113
116
|
function getResults (query) {
|
@@ -122,7 +125,6 @@
|
|
122
125
|
|
123
126
|
this.search = function search (query, callback) {
|
124
127
|
if (query === '') {
|
125
|
-
hideResults()
|
126
128
|
return
|
127
129
|
}
|
128
130
|
showResults()
|
@@ -192,23 +194,14 @@
|
|
192
194
|
function updateTitle (text) {
|
193
195
|
if (typeof text === 'undefined') {
|
194
196
|
var count = results.length
|
195
|
-
var resultsText = count + ' results'
|
197
|
+
var resultsText = 'Search - ' + query + ' - ' + count + ' results'
|
196
198
|
}
|
197
199
|
$searchResultsTitle.text(text || resultsText)
|
198
200
|
}
|
199
201
|
|
200
202
|
function showResults () {
|
201
|
-
$searchResultsWrapper.
|
202
|
-
|
203
|
-
$html.addClass('has-search-results-open')
|
204
|
-
$tocNav.addClass('search-results-open')
|
205
|
-
}
|
206
|
-
|
207
|
-
function hideResults () {
|
208
|
-
$searchResultsWrapper.removeClass('is-open')
|
209
|
-
.attr('aria-hidden', 'true')
|
210
|
-
$html.removeClass('has-search-results-open')
|
211
|
-
$tocNav.removeClass('search-results-open')
|
203
|
+
$searchResultsWrapper.removeAttr('hidden')
|
204
|
+
$searchHelp.attr('hidden', 'true')
|
212
205
|
}
|
213
206
|
|
214
207
|
function sendQueryToAnalytics () {
|
@@ -52,48 +52,44 @@ $input-size: 40px;
|
|
52
52
|
}
|
53
53
|
}
|
54
54
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
55
|
+
@include govuk-media-query($until: tablet) {
|
56
|
+
html.js.has-search-results-open:not(.toc-open) {
|
57
|
+
.toc {
|
58
|
+
display: block;
|
59
|
+
padding-bottom: 0;
|
60
|
+
}
|
61
|
+
|
62
|
+
.toc__close {
|
63
|
+
display: none;
|
64
|
+
}
|
65
|
+
|
66
|
+
.toc__list {
|
67
|
+
display: none;
|
68
|
+
}
|
63
69
|
}
|
64
70
|
}
|
71
|
+
|
65
72
|
.search-results {
|
66
|
-
|
67
|
-
|
68
|
-
|
73
|
+
@include govuk-media-query(tablet) {
|
74
|
+
// Create basis for the search results caret (below)
|
75
|
+
position: relative;
|
76
|
+
|
77
|
+
@include govuk-font($size: 16);
|
78
|
+
padding-top: govuk-spacing(6);
|
69
79
|
}
|
70
|
-
}
|
71
80
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
right: 0;
|
77
|
-
bottom: 0;
|
78
|
-
z-index: 600;
|
79
|
-
overflow-x: scroll;
|
80
|
-
-webkit-overflow-scrolling: touch;
|
81
|
-
-ms-overflow-style: none;
|
82
|
-
@include govuk-media-query(tablet) {
|
83
|
-
padding: govuk-spacing(6);
|
84
|
-
top: 0;
|
85
|
-
// The width of the sidebar
|
86
|
-
left: 330px;
|
87
|
-
min-height: auto;
|
88
|
-
}
|
81
|
+
a {
|
82
|
+
@include govuk-link-common;
|
83
|
+
@include govuk-link-style-no-visited-state;
|
84
|
+
}
|
89
85
|
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
86
|
+
ul {
|
87
|
+
list-style: none;
|
88
|
+
padding: 0;
|
89
|
+
margin: 0;
|
94
90
|
}
|
91
|
+
}
|
95
92
|
.search-results__inner {
|
96
|
-
position: relative;
|
97
93
|
background: govuk-colour("white");
|
98
94
|
border-top: 1px solid govuk-colour("mid-grey");
|
99
95
|
max-width: 40rem;
|
@@ -104,7 +100,7 @@ html.has-search-results-open {
|
|
104
100
|
&::after {
|
105
101
|
content: '';
|
106
102
|
position: absolute;
|
107
|
-
top:
|
103
|
+
top: 35px;
|
108
104
|
left: -9px;
|
109
105
|
width: 10px;
|
110
106
|
height: 20px;
|
@@ -117,44 +113,6 @@ html.has-search-results-open {
|
|
117
113
|
@include govuk-font($size: 27, $weight: bold);
|
118
114
|
margin-bottom: govuk-spacing(6);
|
119
115
|
}
|
120
|
-
.search-results__close {
|
121
|
-
@include govuk-font($size: 16);
|
122
|
-
position: absolute;
|
123
|
-
top: 18px;
|
124
|
-
right: 20px;
|
125
|
-
appearance: none;
|
126
|
-
-webkit-appearance: none;
|
127
|
-
background: none;
|
128
|
-
border: 0;
|
129
|
-
padding: 0;
|
130
|
-
cursor: pointer;
|
131
|
-
|
132
|
-
&:focus {
|
133
|
-
@include govuk-focused-text;
|
134
|
-
}
|
135
|
-
|
136
|
-
&::after {
|
137
|
-
content: '';
|
138
|
-
display: inline-block;
|
139
|
-
vertical-align: middle;
|
140
|
-
padding-left: 8px;
|
141
|
-
height: 18px;
|
142
|
-
width: 18px;
|
143
|
-
background: no-repeat url('/images/govuk-icn-close.png') center right;
|
144
|
-
@include govuk-device-pixel-ratio {
|
145
|
-
background-image: url('/images/govuk-icn-close@2x.png');
|
146
|
-
}
|
147
|
-
background-size: contain;
|
148
|
-
}
|
149
|
-
}
|
150
|
-
.search-results__close-label {
|
151
|
-
position: absolute;
|
152
|
-
left: -9999em;
|
153
|
-
top: auto;
|
154
|
-
width: 1px;
|
155
|
-
height: 1px;
|
156
|
-
overflow: hidden;
|
157
|
-
}
|
158
116
|
.search-result {
|
159
117
|
margin-bottom: govuk-spacing(6);
|
160
118
|
}
|
@@ -162,4 +120,24 @@ html.has-search-results-open {
|
|
162
120
|
background-color: transparent;
|
163
121
|
color: inherit;
|
164
122
|
font-weight: bold;
|
123
|
+
|
124
|
+
// In forced color mode some browsers will keep the background transparent
|
125
|
+
// but set the text colour black, making the highlighted text unreadable.
|
126
|
+
// The following blocks fix this by setting the text colour to be the same as
|
127
|
+
// other text in a way that forced color mode will respect.
|
128
|
+
|
129
|
+
@media screen and (-ms-high-contrast: active) {
|
130
|
+
// IE does not support `CanvasText`,
|
131
|
+
// and `currentColor` does not work with Blink
|
132
|
+
color: currentColor;
|
133
|
+
}
|
134
|
+
|
135
|
+
@media screen and (forced-colors: active) {
|
136
|
+
background-color: Canvas; // needed for Firefox
|
137
|
+
color: CanvasText;
|
138
|
+
}
|
139
|
+
}
|
140
|
+
|
141
|
+
.js .search-help__no-js {
|
142
|
+
display: none;
|
165
143
|
}
|
data/lib/govuk_tech_docs.rb
CHANGED
@@ -13,12 +13,5 @@
|
|
13
13
|
placeholder="Search">
|
14
14
|
<button type="submit" class="search__button">Search</button>
|
15
15
|
</form>
|
16
|
-
<div id="search-results" class="search-results" aria-hidden="true" role="dialog" aria-labelledby="search-results-title">
|
17
|
-
<div class="search-results__inner">
|
18
|
-
<button class="search-results__close">Close<span class="search-results__close-label"> search results</span></button>
|
19
|
-
<h2 id="search-results-title" class="search-results__title" aria-live="assertive" role="alert">Results</h2>
|
20
|
-
<div class="search-results__content"></div>
|
21
|
-
</div>
|
22
|
-
</div>
|
23
16
|
</div>
|
24
17
|
<% end %>
|
@@ -0,0 +1,31 @@
|
|
1
|
+
---
|
2
|
+
title: Search
|
3
|
+
index: false
|
4
|
+
prevent_indexing: true
|
5
|
+
hide_in_navigation: true
|
6
|
+
---
|
7
|
+
|
8
|
+
<div id="search-help" class="search-help">
|
9
|
+
<%# strange id is to avoid clash with search input id #%>
|
10
|
+
<h1 id="how-to-search">Search</h1>
|
11
|
+
|
12
|
+
<p class="govuk-body search-help__no-js">
|
13
|
+
You need to turn on JavaScript in your browser to search this site. You can either:
|
14
|
+
|
15
|
+
<ul>
|
16
|
+
<li>turn on JavaScript in your browser</li>
|
17
|
+
<li>search this site using Google</li>
|
18
|
+
</ul>
|
19
|
+
</p>
|
20
|
+
|
21
|
+
<p class="govuk-body">
|
22
|
+
Enter a search term in the search box, then select the search button.
|
23
|
+
</p>
|
24
|
+
</div>
|
25
|
+
|
26
|
+
<div id="search-results" class="search-results" hidden aria-labelledby="search-results-title">
|
27
|
+
<div class="search-results__inner">
|
28
|
+
<h1 id="search-results-title" class="search-results__title" aria-live="assertive">Results</h1>
|
29
|
+
<div class="search-results__content"></div>
|
30
|
+
</div>
|
31
|
+
</div>
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: govuk_tech_docs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Government Digital Service
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-10-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: autoprefixer-rails
|
@@ -387,6 +387,7 @@ files:
|
|
387
387
|
- lib/source/layouts/_search.erb
|
388
388
|
- lib/source/layouts/core.erb
|
389
389
|
- lib/source/layouts/layout.erb
|
390
|
+
- lib/source/search/index.html.erb
|
390
391
|
- lib/source/stylesheets/manifest.css
|
391
392
|
- node_modules/govuk-frontend/govuk/_base.scss
|
392
393
|
- node_modules/govuk-frontend/govuk/all-ie8.scss
|