govuk_frontend_toolkit 5.1.0 → 5.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 22fafcc6055ff4474250ffa6304e94a4fbf03cab
4
- data.tar.gz: 176d0192da328ee83432ccbf0f13abc190e697f9
3
+ metadata.gz: 675e5847b8fe55142c8bfcdc1a44b89859ebb6b2
4
+ data.tar.gz: acd7680a1f6626db9a45ea97d89ee5c08f06a944
5
5
  SHA512:
6
- metadata.gz: bb15be95deff5e46b16035a0ec6fa09dc68930cd579c61b75fa8b922ad5e6ead4cab08decdb742d032b73fbc6faef3ca636baec439cccada1e77671cc573275a
7
- data.tar.gz: 976d6e1c3fa4d311e3dd7bf17c3cf483315a120d98c15f83205e98fc29afe5e634d725193415e55547a040bef13bfaa59062d70f441f0ecf634e525a1e0b6df1
6
+ metadata.gz: a57923a7ddf0097e51eae6eb258cd19512265c43fbfc04f85dc536569effb3e1a69ecb7f47aec3aaead323cf43903abc8c0a0fad6a3da21bbf3d4b5f5193f7bc
7
+ data.tar.gz: 9177483203d92473543c6f0e71e81d8075955c42b7e38b4d0f19e4268013c9345c66442fdafb2e5c9e790ebe440cf90044832d2b109c08c63eb0da5e3b65e763
@@ -1,5 +1,5 @@
1
1
  node_modules/
2
2
  .sass-cache
3
3
  npm-debug.log
4
- spec/stylesheets
4
+ spec/stylesheets/test*
5
5
  _SpecRunner.html
@@ -2,9 +2,6 @@ sudo: false
2
2
  language: node_js
3
3
  node_js:
4
4
  - "0.10"
5
- env:
6
- global:
7
- secure: "15QWA6igmMx1I2YlDrdkxsOi2YJIWNrXmgEtfEoCWR7eJQW2bkUDdzTXYFzxaEPIVMEgO+0pxfGwMWn/9MBhnXCLu9x0f0KqJ/0YfCGXHW21g8J+31zypdiCiw/Ir/dxazP9wpvWFhuqjo9X35zP3Md7TC8u+20uW2Q5KUVyqZM="
8
5
  before_install:
9
6
  - openssl aes-256-cbc -K $encrypted_909ac1036a94_key -iv $encrypted_909ac1036a94_iv -in .travis/govuk_frontend_toolkit_push.enc -out ~/.ssh/id_rsa -d
10
7
  - chmod 600 ~/.ssh/id_rsa
@@ -16,8 +16,9 @@ is the only way we can find that Travis can trigger another job.
16
16
  In this case, the downstream jobs publish the frontend toolkit to npm
17
17
  and RubyGems.
18
18
 
19
- The `env.global.secure` in `/.travis.yml` contains a Travis token that
20
- belongs to [@alexmuller](https://github.com/alexmuller) - as far as we
19
+ The [Travis settings](https://travis-ci.org/alphagov/govuk_frontend_toolkit/settings)
20
+ contains a Travis token that belongs to
21
+ [@alexmuller](https://github.com/alexmuller) - as far as we
21
22
  can tell there's no way to generate one of these that isn't related to
22
23
  a specific user. This token could be replaced with a generic bot account
23
24
  if we created one.
@@ -1,3 +1,10 @@
1
+ # 5.1.1
2
+
3
+ - Update the alpha, beta and discovery colours to $govuk-blue to match the updated phase banner ([PR #370](https://github.com/alphagov/govuk_frontend_toolkit/pull/370))
4
+ - Fix radio button show/hide behaviour when used outside a form ([PR #375](https://github.com/alphagov/govuk_frontend_toolkit/pull/375))
5
+ - Fix a "Stick at top when scrolling" component bug related to scroll anchoring in Chrome 56+ ([PR #376](https://github.com/alphagov/govuk_frontend_toolkit/pull/376))
6
+ - Minor travis fixes ([PR #373](https://github.com/alphagov/govuk_frontend_toolkit/pull/373))
7
+
1
8
  # 5.1.0
2
9
 
3
10
  - Allow custom options when tracking events ([PR #365](https://github.com/alphagov/govuk_frontend_toolkit/pull/365))
@@ -16,6 +16,8 @@ module.exports = function (grunt) {
16
16
  }
17
17
  )
18
18
 
19
+ allSassFiles.push("@import '_colour_contrast_spec.scss';")
20
+
19
21
  grunt.file.write(
20
22
  './spec/stylesheets/test.scss',
21
23
  allSassFiles.join('\n')
@@ -46,7 +48,9 @@ module.exports = function (grunt) {
46
48
  },
47
49
  options: {
48
50
  loadPath: [
49
- './stylesheets'
51
+ './node_modules',
52
+ './stylesheets',
53
+ './spec/stylesheets'
50
54
  ],
51
55
  style: 'nested'
52
56
  }
@@ -1 +1 @@
1
- 5.1.0
1
+ 5.1.1
@@ -80,7 +80,8 @@
80
80
  function handleRadioContent ($control, $content) {
81
81
  // All radios in this group which control content
82
82
  var selector = selectors.radio + '[name=' + escapeElementName($control.attr('name')) + '][aria-controls]'
83
- var $radios = $control.closest('form').find(selector)
83
+ var $form = $control.closest('form')
84
+ var $radios = $form.length ? $form.find(selector) : $(selector)
84
85
 
85
86
  // Hide content for radios in group
86
87
  $radios.each(function () {
@@ -110,8 +110,9 @@
110
110
  if (!$el.hasClass('content-fixed')) {
111
111
  $el.data('scrolled-from', sticky.getElementOffset($el).top)
112
112
  var height = Math.max($el.height(), 1)
113
- $el.before('<div class="shim" style="width: ' + $el.width() + 'px; height: ' + height + 'px">&nbsp;</div>')
114
- $el.css('width', $el.width() + 'px').addClass('content-fixed')
113
+ var width = $el.width()
114
+ $el.before('<div class="shim" style="width: ' + width + 'px; height: ' + height + 'px">&nbsp;</div>')
115
+ $el.css('width', width + 'px').addClass('content-fixed')
115
116
  }
116
117
  },
117
118
  release: function ($el) {
@@ -9,7 +9,8 @@
9
9
  "grunt-contrib-jasmine": "^1.0.0",
10
10
  "grunt-contrib-sass": "0.7.4",
11
11
  "jquery": "~1.12.4",
12
- "standard": "^8.2.0"
12
+ "standard": "^8.2.0",
13
+ "sass-color-helpers": "^2.0.3"
13
14
  },
14
15
  "scripts": {
15
16
  "test": "grunt test && npm run lint --silent",
@@ -0,0 +1,12 @@
1
+ @import "colours/organisation";
2
+ @import "sass-color-helpers/stylesheets/color-helpers/math";
3
+ @import "sass-color-helpers/stylesheets/color-helpers/contrast";
4
+
5
+ @each $organisation in $all-organisation-brand-colours {
6
+ $minimum-contrast: 4.5;
7
+ $contrast: ch-color-contrast($white, nth($organisation, 3));
8
+
9
+ @if ($contrast < $minimum-contrast) {
10
+ @error "Contrast ratio for #{nth($organisation, 1)} too low. #{nth($organisation, 3)} on #{$white} has a contrast of: #{$contrast}. Must be higher than #{$minimum-contrast} for WCAG AA support";
11
+ }
12
+ }
@@ -6,66 +6,6 @@ describe('show-hide-content', function () {
6
6
  'use strict'
7
7
  var GOVUK = window.GOVUK
8
8
 
9
- beforeEach(function () {
10
- // Sample markup
11
- this.$content = $(
12
-
13
- // Radio buttons (yes/no)
14
- '<form>' +
15
- '<label class="block-label" data-target="show-hide-radios">' +
16
- '<input type="radio" name="single" value="no">' +
17
- 'Yes' +
18
- '</label>' +
19
- '<label class="block-label">' +
20
- '<input type="radio" name="single" value="yes">' +
21
- 'No' +
22
- '</label>' +
23
- '<div id="show-hide-radios" class="panel js-hidden" />' +
24
- '</form>' +
25
-
26
- // Checkboxes (multiple values)
27
- '<form>' +
28
- '<label class="block-label" data-target="show-hide-checkboxes">' +
29
- '<input type="checkbox" name="multiple[option1]">' +
30
- 'Option 1' +
31
- '</label>' +
32
- '<label class="block-label">' +
33
- '<input type="checkbox" name="multiple[option2]">' +
34
- 'Option 2' +
35
- '</label>' +
36
- '<label class="block-label">' +
37
- '<input type="checkbox" name="multiple[option3]">' +
38
- 'Option 3' +
39
- '</label>' +
40
- '<div id="show-hide-checkboxes" class="panel js-hidden" />' +
41
- '</form>'
42
- )
43
-
44
- // Find radios/checkboxes
45
- var $radios = this.$content.find('input[type=radio]')
46
- var $checkboxes = this.$content.find('input[type=checkbox]')
47
-
48
- // Two radios
49
- this.$radio1 = $radios.eq(0)
50
- this.$radio2 = $radios.eq(1)
51
-
52
- // Three checkboxes
53
- this.$checkbox1 = $checkboxes.eq(0)
54
- this.$checkbox2 = $checkboxes.eq(1)
55
- this.$checkbox3 = $checkboxes.eq(2)
56
-
57
- // Add to page
58
- $(document.body).append(this.$content)
59
-
60
- // Show/Hide content
61
- this.$radioShowHide = $('#show-hide-radios')
62
- this.$checkboxShowHide = $('#show-hide-checkboxes')
63
-
64
- // Add show/hide content support
65
- this.showHideContent = new GOVUK.ShowHideContent()
66
- this.showHideContent.init()
67
- })
68
-
69
9
  afterEach(function () {
70
10
  if (this.showHideContent) {
71
11
  this.showHideContent.destroy()
@@ -74,176 +14,293 @@ describe('show-hide-content', function () {
74
14
  this.$content.remove()
75
15
  })
76
16
 
77
- describe('when this.showHideContent = new GOVUK.ShowHideContent() is called', function () {
78
- it('should add the aria attributes to inputs with show/hide content', function () {
79
- expect(this.$radio1.attr('aria-expanded')).toBe('false')
80
- expect(this.$radio1.attr('aria-controls')).toBe('show-hide-radios')
81
- })
82
-
83
- it('should add the aria attributes to show/hide content', function () {
84
- expect(this.$radioShowHide.attr('aria-hidden')).toBe('true')
85
- expect(this.$radioShowHide.hasClass('js-hidden')).toEqual(true)
86
- })
87
-
88
- it('should hide the show/hide content visually', function () {
89
- expect(this.$radioShowHide.hasClass('js-hidden')).toEqual(true)
90
- })
91
-
92
- it('should do nothing if no radios are checked', function () {
93
- expect(this.$radio1.attr('aria-expanded')).toBe('false')
94
- expect(this.$radio2.attr('aria-expanded')).toBe(undefined)
95
- })
96
-
97
- it('should do nothing if no checkboxes are checked', function () {
98
- expect(this.$radio1.attr('aria-expanded')).toBe('false')
99
- expect(this.$radio2.attr('aria-expanded')).toBe(undefined)
17
+ describe('when the radios are inside a form', function () {
18
+ beforeEach(function () {
19
+ // Sample markup
20
+ this.$content = $(
21
+
22
+ // Radio buttons (yes/no)
23
+ '<form>' +
24
+ '<label class="block-label" data-target="show-hide-radios">' +
25
+ '<input type="radio" name="single" value="yes">' +
26
+ 'Yes' +
27
+ '</label>' +
28
+ '<label class="block-label">' +
29
+ '<input type="radio" name="single" value="no">' +
30
+ 'No' +
31
+ '</label>' +
32
+ '<div id="show-hide-radios" class="panel js-hidden" />' +
33
+ '</form>' +
34
+
35
+ // Checkboxes (multiple values)
36
+ '<form>' +
37
+ '<label class="block-label" data-target="show-hide-checkboxes">' +
38
+ '<input type="checkbox" name="multiple[option1]">' +
39
+ 'Option 1' +
40
+ '</label>' +
41
+ '<label class="block-label">' +
42
+ '<input type="checkbox" name="multiple[option2]">' +
43
+ 'Option 2' +
44
+ '</label>' +
45
+ '<label class="block-label">' +
46
+ '<input type="checkbox" name="multiple[option3]">' +
47
+ 'Option 3' +
48
+ '</label>' +
49
+ '<div id="show-hide-checkboxes" class="panel js-hidden" />' +
50
+ '</form>'
51
+ )
52
+
53
+ // Find radios/checkboxes
54
+ var $radios = this.$content.find('input[type=radio]')
55
+ var $checkboxes = this.$content.find('input[type=checkbox]')
56
+
57
+ // Two radios
58
+ this.$radio1 = $radios.eq(0)
59
+ this.$radio2 = $radios.eq(1)
60
+
61
+ // Three checkboxes
62
+ this.$checkbox1 = $checkboxes.eq(0)
63
+ this.$checkbox2 = $checkboxes.eq(1)
64
+ this.$checkbox3 = $checkboxes.eq(2)
65
+
66
+ // Add to page
67
+ $(document.body).append(this.$content)
68
+
69
+ // Show/Hide content
70
+ this.$radioShowHide = $('#show-hide-radios')
71
+ this.$checkboxShowHide = $('#show-hide-checkboxes')
72
+
73
+ // Add show/hide content support
74
+ this.showHideContent = new GOVUK.ShowHideContent()
75
+ this.showHideContent.init()
100
76
  })
101
77
 
102
- describe('with non-default markup', function () {
103
- beforeEach(function () {
104
- this.showHideContent.destroy()
78
+ describe('and when this.showHideContent = new GOVUK.ShowHideContent() is called', function () {
79
+ it('should add the aria attributes to inputs with show/hide content', function () {
80
+ expect(this.$radio1.attr('aria-expanded')).toBe('false')
81
+ expect(this.$radio1.attr('aria-controls')).toBe('show-hide-radios')
105
82
  })
106
83
 
107
- it('should do nothing if a radio without show/hide content is checked', function () {
108
- this.$radio2.prop('checked', true)
109
-
110
- // Defaults changed, initialise again
111
- this.showHideContent = new GOVUK.ShowHideContent().init()
112
- expect(this.$radio1.attr('aria-expanded')).toBe('false')
84
+ it('should add the aria attributes to show/hide content', function () {
113
85
  expect(this.$radioShowHide.attr('aria-hidden')).toBe('true')
114
86
  expect(this.$radioShowHide.hasClass('js-hidden')).toEqual(true)
115
87
  })
116
88
 
117
- it('should do nothing if a checkbox without show/hide content is checked', function () {
118
- this.$checkbox2.prop('checked', true)
119
-
120
- // Defaults changed, initialise again
121
- this.showHideContent = new GOVUK.ShowHideContent().init()
122
- expect(this.$checkbox1.attr('aria-expanded')).toBe('false')
123
- expect(this.$checkboxShowHide.attr('aria-hidden')).toBe('true')
124
- expect(this.$checkboxShowHide.hasClass('js-hidden')).toEqual(true)
89
+ it('should hide the show/hide content visually', function () {
90
+ expect(this.$radioShowHide.hasClass('js-hidden')).toEqual(true)
125
91
  })
126
92
 
127
- it('should do nothing if checkboxes without show/hide content is checked', function () {
128
- this.$checkbox2.prop('checked', true)
129
- this.$checkbox3.prop('checked', true)
130
-
131
- // Defaults changed, initialise again
132
- this.showHideContent = new GOVUK.ShowHideContent().init()
133
- expect(this.$checkbox1.attr('aria-expanded')).toBe('false')
134
- expect(this.$checkboxShowHide.attr('aria-hidden')).toBe('true')
135
- expect(this.$checkboxShowHide.hasClass('js-hidden')).toEqual(true)
93
+ it('should do nothing if no radios are checked', function () {
94
+ expect(this.$radio1.attr('aria-expanded')).toBe('false')
95
+ expect(this.$radio2.attr('aria-expanded')).toBe(undefined)
136
96
  })
137
97
 
138
- it('should make the show/hide content visible if its radio is checked', function () {
139
- this.$radio1.prop('checked', true)
140
-
141
- // Defaults changed, initialise again
142
- this.showHideContent = new GOVUK.ShowHideContent().init()
143
- expect(this.$radio1.attr('aria-expanded')).toBe('true')
144
- expect(this.$radioShowHide.attr('aria-hidden')).toBe('false')
145
- expect(this.$radioShowHide.hasClass('js-hidden')).toEqual(false)
98
+ it('should do nothing if no checkboxes are checked', function () {
99
+ expect(this.$radio1.attr('aria-expanded')).toBe('false')
100
+ expect(this.$radio2.attr('aria-expanded')).toBe(undefined)
146
101
  })
147
102
 
148
- it('should make the show/hide content visible if its checkbox is checked', function () {
149
- this.$checkbox1.prop('checked', true)
150
-
151
- // Defaults changed, initialise again
152
- this.showHideContent = new GOVUK.ShowHideContent().init()
153
- expect(this.$checkbox1.attr('aria-expanded')).toBe('true')
154
- expect(this.$checkboxShowHide.attr('aria-hidden')).toBe('false')
155
- expect(this.$checkboxShowHide.hasClass('js-hidden')).toEqual(false)
103
+ describe('with non-default markup', function () {
104
+ beforeEach(function () {
105
+ this.showHideContent.destroy()
106
+ })
107
+
108
+ it('should do nothing if a radio without show/hide content is checked', function () {
109
+ this.$radio2.prop('checked', true)
110
+
111
+ // Defaults changed, initialise again
112
+ this.showHideContent = new GOVUK.ShowHideContent().init()
113
+ expect(this.$radio1.attr('aria-expanded')).toBe('false')
114
+ expect(this.$radioShowHide.attr('aria-hidden')).toBe('true')
115
+ expect(this.$radioShowHide.hasClass('js-hidden')).toEqual(true)
116
+ })
117
+
118
+ it('should do nothing if a checkbox without show/hide content is checked', function () {
119
+ this.$checkbox2.prop('checked', true)
120
+
121
+ // Defaults changed, initialise again
122
+ this.showHideContent = new GOVUK.ShowHideContent().init()
123
+ expect(this.$checkbox1.attr('aria-expanded')).toBe('false')
124
+ expect(this.$checkboxShowHide.attr('aria-hidden')).toBe('true')
125
+ expect(this.$checkboxShowHide.hasClass('js-hidden')).toEqual(true)
126
+ })
127
+
128
+ it('should do nothing if checkboxes without show/hide content is checked', function () {
129
+ this.$checkbox2.prop('checked', true)
130
+ this.$checkbox3.prop('checked', true)
131
+
132
+ // Defaults changed, initialise again
133
+ this.showHideContent = new GOVUK.ShowHideContent().init()
134
+ expect(this.$checkbox1.attr('aria-expanded')).toBe('false')
135
+ expect(this.$checkboxShowHide.attr('aria-hidden')).toBe('true')
136
+ expect(this.$checkboxShowHide.hasClass('js-hidden')).toEqual(true)
137
+ })
138
+
139
+ it('should make the show/hide content visible if its radio is checked', function () {
140
+ this.$radio1.prop('checked', true)
141
+
142
+ // Defaults changed, initialise again
143
+ this.showHideContent = new GOVUK.ShowHideContent().init()
144
+ expect(this.$radio1.attr('aria-expanded')).toBe('true')
145
+ expect(this.$radioShowHide.attr('aria-hidden')).toBe('false')
146
+ expect(this.$radioShowHide.hasClass('js-hidden')).toEqual(false)
147
+ })
148
+
149
+ it('should make the show/hide content visible if its checkbox is checked', function () {
150
+ this.$checkbox1.prop('checked', true)
151
+
152
+ // Defaults changed, initialise again
153
+ this.showHideContent = new GOVUK.ShowHideContent().init()
154
+ expect(this.$checkbox1.attr('aria-expanded')).toBe('true')
155
+ expect(this.$checkboxShowHide.attr('aria-hidden')).toBe('false')
156
+ expect(this.$checkboxShowHide.hasClass('js-hidden')).toEqual(false)
157
+ })
156
158
  })
157
- })
158
159
 
159
- describe('and a show/hide radio receives a click', function () {
160
- it('should make the show/hide content visible', function () {
161
- this.$radio1.click()
162
- expect(this.$radioShowHide.hasClass('js-hidden')).toEqual(false)
160
+ describe('and a show/hide radio receives a click', function () {
161
+ it('should make the show/hide content visible', function () {
162
+ this.$radio1.click()
163
+ expect(this.$radioShowHide.hasClass('js-hidden')).toEqual(false)
164
+ })
165
+
166
+ it('should add the aria attributes to show/hide content', function () {
167
+ this.$radio1.click()
168
+ expect(this.$radio1.attr('aria-expanded')).toBe('true')
169
+ expect(this.$radioShowHide.attr('aria-hidden')).toBe('false')
170
+ expect(this.$radioShowHide.hasClass('js-hidden')).toEqual(false)
171
+ })
163
172
  })
164
173
 
165
- it('should add the aria attributes to show/hide content', function () {
166
- this.$radio1.click()
167
- expect(this.$radio1.attr('aria-expanded')).toBe('true')
168
- expect(this.$radioShowHide.attr('aria-hidden')).toBe('false')
169
- expect(this.$radioShowHide.hasClass('js-hidden')).toEqual(false)
174
+ describe('and a show/hide checkbox receives a click', function () {
175
+ it('should make the show/hide content visible', function () {
176
+ this.$checkbox1.click()
177
+ expect(this.$checkboxShowHide.hasClass('js-hidden')).toEqual(false)
178
+ })
179
+
180
+ it('should add the aria attributes to show/hide content', function () {
181
+ this.$checkbox1.click()
182
+ expect(this.$checkbox1.attr('aria-expanded')).toBe('true')
183
+ expect(this.$checkboxShowHide.attr('aria-hidden')).toBe('false')
184
+ expect(this.$checkboxShowHide.hasClass('js-hidden')).toEqual(false)
185
+ })
170
186
  })
171
- })
172
187
 
173
- describe('and a show/hide checkbox receives a click', function () {
174
- it('should make the show/hide content visible', function () {
175
- this.$checkbox1.click()
176
- expect(this.$checkboxShowHide.hasClass('js-hidden')).toEqual(false)
188
+ describe('and a show/hide radio receives a click, but another group radio is clicked afterwards', function () {
189
+ it('should make the show/hide content hidden', function () {
190
+ this.$radio1.click()
191
+ this.$radio2.click()
192
+ expect(this.$radioShowHide.hasClass('js-hidden')).toEqual(true)
193
+ })
194
+
195
+ it('should add the aria attributes to show/hide content', function () {
196
+ this.$radio1.click()
197
+ this.$radio2.click()
198
+ expect(this.$radio1.attr('aria-expanded')).toBe('false')
199
+ expect(this.$radioShowHide.attr('aria-hidden')).toBe('true')
200
+ })
177
201
  })
178
202
 
179
- it('should add the aria attributes to show/hide content', function () {
180
- this.$checkbox1.click()
181
- expect(this.$checkbox1.attr('aria-expanded')).toBe('true')
182
- expect(this.$checkboxShowHide.attr('aria-hidden')).toBe('false')
183
- expect(this.$checkboxShowHide.hasClass('js-hidden')).toEqual(false)
203
+ describe('and a show/hide checkbox receives a click, but another checkbox is clicked afterwards', function () {
204
+ it('should keep the show/hide content visible', function () {
205
+ this.$checkbox1.click()
206
+ this.$checkbox2.click()
207
+ expect(this.$checkboxShowHide.hasClass('js-hidden')).toEqual(false)
208
+ })
209
+
210
+ it('should keep the aria attributes to show/hide content', function () {
211
+ this.$checkbox1.click()
212
+ this.$checkbox2.click()
213
+ expect(this.$checkbox1.attr('aria-expanded')).toBe('true')
214
+ expect(this.$checkboxShowHide.attr('aria-hidden')).toBe('false')
215
+ })
184
216
  })
185
217
  })
186
218
 
187
- describe('and a show/hide radio receives a click, but another group radio is clicked afterwards', function () {
188
- it('should make the show/hide content hidden', function () {
189
- this.$radio1.click()
190
- this.$radio2.click()
191
- expect(this.$radioShowHide.hasClass('js-hidden')).toEqual(true)
192
- })
193
-
194
- it('should add the aria attributes to show/hide content', function () {
195
- this.$radio1.click()
196
- this.$radio2.click()
197
- expect(this.$radio1.attr('aria-expanded')).toBe('false')
198
- expect(this.$radioShowHide.attr('aria-hidden')).toBe('true')
219
+ describe('before this.showHideContent.destroy() is called', function () {
220
+ it('document.body should have show/hide event handlers', function () {
221
+ var events = $._data(document.body, 'events')
222
+ expect(events && events.click).toContain(jasmine.objectContaining({
223
+ namespace: 'ShowHideContent',
224
+ selector: 'input[type="radio"][name="single"]'
225
+ }))
226
+ expect(events && events.click).toContain(jasmine.objectContaining({
227
+ namespace: 'ShowHideContent',
228
+ selector: '.block-label[data-target] input[type="checkbox"]'
229
+ }))
199
230
  })
200
231
  })
201
232
 
202
- describe('and a show/hide checkbox receives a click, but another checkbox is clicked afterwards', function () {
203
- it('should keep the show/hide content visible', function () {
204
- this.$checkbox1.click()
205
- this.$checkbox2.click()
206
- expect(this.$checkboxShowHide.hasClass('js-hidden')).toEqual(false)
233
+ describe('and when this.showHideContent.destroy() is called', function () {
234
+ beforeEach(function () {
235
+ this.showHideContent.destroy()
207
236
  })
208
237
 
209
- it('should keep the aria attributes to show/hide content', function () {
210
- this.$checkbox1.click()
211
- this.$checkbox2.click()
212
- expect(this.$checkbox1.attr('aria-expanded')).toBe('true')
213
- expect(this.$checkboxShowHide.attr('aria-hidden')).toBe('false')
238
+ it('should have no show/hide event handlers', function () {
239
+ var events = $._data(document.body, 'events')
240
+ expect(events && events.click).not.toContain(jasmine.objectContaining({
241
+ namespace: 'ShowHideContent',
242
+ selector: 'input[type="radio"][name="single"]'
243
+ }))
244
+ expect(events && events.click).not.toContain(jasmine.objectContaining({
245
+ namespace: 'ShowHideContent',
246
+ selector: '.block-label[data-target] input[type="checkbox"]'
247
+ }))
214
248
  })
215
249
  })
216
250
  })
217
251
 
218
- describe('before this.showHideContent.destroy() is called', function () {
219
- it('document.body should have show/hide event handlers', function () {
220
- var events = $._data(document.body, 'events')
221
- expect(events && events.click).toContain(jasmine.objectContaining({
222
- namespace: 'ShowHideContent',
223
- selector: 'input[type="radio"][name="single"]'
224
- }))
225
- expect(events && events.click).toContain(jasmine.objectContaining({
226
- namespace: 'ShowHideContent',
227
- selector: '.block-label[data-target] input[type="checkbox"]'
228
- }))
252
+ describe('when the radios are outside of a form', function () {
253
+ beforeEach(function () {
254
+ // Sample markup
255
+ this.$content = $(
256
+ // Radio buttons (yes/no)
257
+ '<label class="block-label" data-target="show-hide-radios">' +
258
+ '<input type="radio" name="single" value="yes">' +
259
+ 'Yes' +
260
+ '</label>' +
261
+ '<label class="block-label">' +
262
+ '<input type="radio" name="single" value="no">' +
263
+ 'No' +
264
+ '</label>' +
265
+ '<div id="show-hide-radios" class="panel js-hidden" />'
266
+ )
267
+
268
+ // Find radios/checkboxes
269
+ var $radios = this.$content.find('input[type=radio]')
270
+
271
+ // Two radios
272
+ this.$radio1 = $radios.eq(0)
273
+ this.$radio2 = $radios.eq(1)
274
+
275
+ // Add to page
276
+ $(document.body).append(this.$content)
277
+
278
+ // Show/Hide content
279
+ this.$radioShowHide = $('#show-hide-radios')
280
+
281
+ // Add show/hide content support
282
+ this.showHideContent = new GOVUK.ShowHideContent()
283
+ this.showHideContent.init()
229
284
  })
230
- })
231
285
 
232
- describe('when this.showHideContent.destroy() is called', function () {
233
- beforeEach(function () {
234
- this.showHideContent.destroy()
286
+ it('should make the show/hide content visible if its radio is checked', function () {
287
+ this.$radio1.click()
288
+
289
+ // Defaults changed, initialise again
290
+ this.showHideContent = new GOVUK.ShowHideContent().init()
291
+ expect(this.$radio1.attr('aria-expanded')).toBe('true')
292
+ expect(this.$radioShowHide.attr('aria-hidden')).toBe('false')
293
+ expect(this.$radioShowHide.hasClass('js-hidden')).toEqual(false)
235
294
  })
236
295
 
237
- it('should have no show/hide event handlers', function () {
238
- var events = $._data(document.body, 'events')
239
- expect(events && events.click).not.toContain(jasmine.objectContaining({
240
- namespace: 'ShowHideContent',
241
- selector: 'input[type="radio"][name="single"]'
242
- }))
243
- expect(events && events.click).not.toContain(jasmine.objectContaining({
244
- namespace: 'ShowHideContent',
245
- selector: '.block-label[data-target] input[type="checkbox"]'
246
- }))
296
+ it('should do nothing if a radio without show/hide content is checked', function () {
297
+ this.$radio2.click()
298
+
299
+ // Defaults changed, initialise again
300
+ this.showHideContent = new GOVUK.ShowHideContent().init()
301
+ expect(this.$radio1.attr('aria-expanded')).toBe('false')
302
+ expect(this.$radioShowHide.attr('aria-hidden')).toBe('true')
303
+ expect(this.$radioShowHide.hasClass('js-hidden')).toEqual(true)
247
304
  })
248
305
  })
249
306
  })
@@ -68,9 +68,9 @@ $panel-colour: $grey-3; // Related links panel, page footer etc.
68
68
  $canvas-colour: $grey-4; // Page background
69
69
  $highlight-colour: $grey-4; // Table stripes etc.
70
70
  $page-colour: $white; // The page
71
- $discovery-colour: $fuschia; // Discovery badges and banners
72
- $alpha-colour: $pink; // Alpha badges and banners
73
- $beta-colour: $orange; // Beta badges and banners
71
+ $discovery-colour: $govuk-blue; // Discovery badges and banners
72
+ $alpha-colour: $govuk-blue; // Alpha badges and banners
73
+ $beta-colour: $govuk-blue; // Beta badges and banners
74
74
  $live-colour: $grass-green; // Live badges and banners
75
75
  $banner-text-colour: #000; // Text colour for Alpha & Beta banners
76
76
  $error-colour: $red; // Error text and border colour
@@ -1,5 +1,7 @@
1
1
  #!/bin/bash
2
2
 
3
+ set -e
4
+
3
5
  PAYLOAD='{
4
6
  "request": {
5
7
  "branch": "master"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: govuk_frontend_toolkit
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.1.0
4
+ version: 5.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Government Digital Service
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-17 00:00:00.000000000 Z
11
+ date: 2017-02-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -239,6 +239,7 @@ files:
239
239
  - app/assets/package.json
240
240
  - app/assets/push.sh
241
241
  - app/assets/spec/manifest.js
242
+ - app/assets/spec/stylesheets/_colour_contrast_spec.scss
242
243
  - app/assets/spec/support/LocalTestRunner.html
243
244
  - app/assets/spec/support/console-runner.js
244
245
  - app/assets/spec/support/load.js