govuk_publishing_components 9.6.0 → 9.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/assets/javascripts/govuk_publishing_components/components/radio.js +32 -0
- data/app/assets/stylesheets/govuk_publishing_components/_all_components.scss +1 -1
- data/app/assets/stylesheets/govuk_publishing_components/components/_back-link.scss +4 -31
- data/app/assets/stylesheets/govuk_publishing_components/components/_button.scss +13 -42
- data/app/assets/stylesheets/govuk_publishing_components/components/_input.scss +4 -32
- data/app/assets/stylesheets/govuk_publishing_components/components/_label.scss +4 -23
- data/app/assets/stylesheets/govuk_publishing_components/components/_layout-header.scss +0 -8
- data/app/assets/stylesheets/govuk_publishing_components/components/_radio.scss +5 -129
- data/app/assets/stylesheets/govuk_publishing_components/components/govspeak/_button.scss +5 -3
- data/app/views/govuk_publishing_components/components/_back_link.html.erb +7 -6
- data/app/views/govuk_publishing_components/components/_button.html.erb +2 -2
- data/app/views/govuk_publishing_components/components/_input.html.erb +32 -25
- data/app/views/govuk_publishing_components/components/_label.html.erb +13 -31
- data/app/views/govuk_publishing_components/components/_radio.html.erb +54 -38
- data/app/views/govuk_publishing_components/components/docs/radio.yml +14 -2
- data/lib/govuk_publishing_components/version.rb +1 -1
- data/node_modules/govuk-frontend/all.js +172 -172
- data/node_modules/govuk-frontend/components/checkboxes/README.md +92 -4
- data/node_modules/govuk-frontend/components/checkboxes/_checkboxes.scss +7 -1
- data/node_modules/govuk-frontend/components/checkboxes/checkboxes.js +356 -1
- data/node_modules/govuk-frontend/components/checkboxes/template.njk +15 -3
- data/node_modules/govuk-frontend/components/date-input/README.md +3 -3
- data/node_modules/govuk-frontend/components/file-upload/README.md +3 -3
- data/node_modules/govuk-frontend/components/header/_header.scss +5 -3
- data/node_modules/govuk-frontend/components/input/README.md +3 -3
- data/node_modules/govuk-frontend/components/phase-banner/README.md +1 -1
- data/node_modules/govuk-frontend/components/radios/README.md +176 -3
- data/node_modules/govuk-frontend/components/radios/_radios.scss +15 -1
- data/node_modules/govuk-frontend/components/radios/radios.js +356 -1
- data/node_modules/govuk-frontend/components/radios/template.njk +19 -3
- data/node_modules/govuk-frontend/components/select/README.md +3 -3
- data/node_modules/govuk-frontend/components/tabs/_tabs.scss +4 -4
- data/node_modules/govuk-frontend/components/tabs/tabs.js +1 -1
- data/node_modules/govuk-frontend/components/textarea/README.md +3 -3
- data/node_modules/govuk-frontend/package.json +18 -18
- data/node_modules/govuk-frontend/template.njk +4 -2
- data/node_modules/govuk-frontend/tools/_font-url.scss +1 -1
- data/node_modules/govuk-frontend/tools/_image-url.scss +1 -1
- metadata +3 -2
@@ -155,6 +155,82 @@ Find out when to use the checkboxes component in your service in the [GOV.UK Des
|
|
155
155
|
]
|
156
156
|
}) }}
|
157
157
|
|
158
|
+
### Checkboxes with hints on items
|
159
|
+
|
160
|
+
[Preview this example in the Frontend review app](http://govuk-frontend-review.herokuapp.com/components/checkboxes/with-hints-on-items/preview)
|
161
|
+
|
162
|
+
#### Markup
|
163
|
+
|
164
|
+
<div class="govuk-form-group">
|
165
|
+
|
166
|
+
<fieldset class="govuk-fieldset">
|
167
|
+
|
168
|
+
<legend class="govuk-fieldset__legend">
|
169
|
+
<h1 class="govuk-fieldset__heading">
|
170
|
+
How do you want to sign in?
|
171
|
+
</h1>
|
172
|
+
</legend>
|
173
|
+
|
174
|
+
<div class="govuk-checkboxes">
|
175
|
+
|
176
|
+
<div class="govuk-checkboxes__item">
|
177
|
+
<input class="govuk-checkboxes__input" id="government-gateway" name="gateway" type="checkbox" value="gov-gateway" aria-describedby="government-gateway-item-hint">
|
178
|
+
<label class="govuk-label govuk-checkboxes__label" for="government-gateway">
|
179
|
+
Sign in with Government Gateway
|
180
|
+
</label>
|
181
|
+
<span id="government-gateway-item-hint" class="govuk-hint govuk-checkboxes__hint">
|
182
|
+
You’ll have a user ID if you’ve registered for Self Assessment or filed a tax return online before.
|
183
|
+
</span>
|
184
|
+
</div>
|
185
|
+
|
186
|
+
<div class="govuk-checkboxes__item">
|
187
|
+
<input class="govuk-checkboxes__input" id="govuk-verify" name="verify" type="checkbox" value="gov-verify" aria-describedby="govuk-verify-item-hint">
|
188
|
+
<label class="govuk-label govuk-checkboxes__label" for="govuk-verify">
|
189
|
+
Sign in with GOV.UK Verify
|
190
|
+
</label>
|
191
|
+
<span id="govuk-verify-item-hint" class="govuk-hint govuk-checkboxes__hint">
|
192
|
+
You’ll have an account if you’ve already proved your identity with either Barclays, CitizenSafe, Digidentity, Experian, Post Office, Royal Mail or SecureIdentity.
|
193
|
+
</span>
|
194
|
+
</div>
|
195
|
+
|
196
|
+
</div>
|
197
|
+
</fieldset>
|
198
|
+
|
199
|
+
</div>
|
200
|
+
|
201
|
+
#### Macro
|
202
|
+
|
203
|
+
{% from "checkboxes/macro.njk" import govukCheckboxes %}
|
204
|
+
|
205
|
+
{{ govukCheckboxes({
|
206
|
+
"fieldset": {
|
207
|
+
"legend": {
|
208
|
+
"text": "How do you want to sign in?",
|
209
|
+
"isPageHeading": true
|
210
|
+
}
|
211
|
+
},
|
212
|
+
"items": [
|
213
|
+
{
|
214
|
+
"name": "gateway",
|
215
|
+
"id": "government-gateway",
|
216
|
+
"value": "gov-gateway",
|
217
|
+
"text": "Sign in with Government Gateway",
|
218
|
+
"hint": {
|
219
|
+
"text": "You’ll have a user ID if you’ve registered for Self Assessment or filed a tax return online before."
|
220
|
+
}
|
221
|
+
},
|
222
|
+
{
|
223
|
+
"name": "verify",
|
224
|
+
"id": "govuk-verify",
|
225
|
+
"value": "gov-verify",
|
226
|
+
"text": "Sign in with GOV.UK Verify",
|
227
|
+
"hint": {
|
228
|
+
"text": "You’ll have an account if you’ve already proved your identity with either Barclays, CitizenSafe, Digidentity, Experian, Post Office, Royal Mail or SecureIdentity."
|
229
|
+
}
|
230
|
+
}
|
231
|
+
]
|
232
|
+
}) }}
|
233
|
+
|
158
234
|
### Checkboxes with disabled item
|
159
235
|
|
160
236
|
[Preview this example in the Frontend review app](http://govuk-frontend-review.herokuapp.com/components/checkboxes/with-disabled-item/preview)
|
@@ -649,7 +725,7 @@ If you are using Nunjucks,then macros take the following arguments
|
|
649
725
|
|
650
726
|
<td class="govuk-table__cell ">No</td>
|
651
727
|
|
652
|
-
<td class="govuk-table__cell ">Arguments for the fieldset component (e.g. legend). See fieldset component.</td>
|
728
|
+
<td class="govuk-table__cell ">Arguments for the fieldset component (e.g. legend). See <a href="../fieldset/README.md#component-arguments">fieldset</a> component.</td>
|
653
729
|
|
654
730
|
</tr>
|
655
731
|
|
@@ -661,7 +737,7 @@ If you are using Nunjucks,then macros take the following arguments
|
|
661
737
|
|
662
738
|
<td class="govuk-table__cell ">No</td>
|
663
739
|
|
664
|
-
<td class="govuk-table__cell ">Arguments for the hint component (e.g. text). See hint component.</td>
|
740
|
+
<td class="govuk-table__cell ">Arguments for the hint component (e.g. text). See <a href="../hint/README.md#component-arguments">hint</a> component.</td>
|
665
741
|
|
666
742
|
</tr>
|
667
743
|
|
@@ -673,7 +749,7 @@ If you are using Nunjucks,then macros take the following arguments
|
|
673
749
|
|
674
750
|
<td class="govuk-table__cell ">No</td>
|
675
751
|
|
676
|
-
<td class="govuk-table__cell ">Arguments for the errorMessage component (e.g. text). See errorMessage component.</td>
|
752
|
+
<td class="govuk-table__cell ">Arguments for the errorMessage component (e.g. text). See <a href="../error-message/README.md#component-arguments">errorMessage</a> component.</td>
|
677
753
|
|
678
754
|
</tr>
|
679
755
|
|
@@ -769,7 +845,19 @@ If you are using Nunjucks,then macros take the following arguments
|
|
769
845
|
|
770
846
|
<td class="govuk-table__cell ">No</td>
|
771
847
|
|
772
|
-
<td class="govuk-table__cell ">Provide additional attributes to each checkbox item label. See
|
848
|
+
<td class="govuk-table__cell ">Provide additional attributes and classes to each checkbox item label. See [label](../label/README.md#component-arguments) component for more details.</td>
|
849
|
+
|
850
|
+
</tr>
|
851
|
+
|
852
|
+
<tr class="govuk-table__row">
|
853
|
+
|
854
|
+
<th class="govuk-table__header" scope="row">items.{}.hint</th>
|
855
|
+
|
856
|
+
<td class="govuk-table__cell ">object</td>
|
857
|
+
|
858
|
+
<td class="govuk-table__cell ">No</td>
|
859
|
+
|
860
|
+
<td class="govuk-table__cell ">Provide optional hint to each checkbox item. See `hint` component for more details.</td>
|
773
861
|
|
774
862
|
</tr>
|
775
863
|
|
@@ -66,6 +66,12 @@
|
|
66
66
|
touch-action: manipulation;
|
67
67
|
}
|
68
68
|
|
69
|
+
.govuk-checkboxes__hint {
|
70
|
+
display: block;
|
71
|
+
padding-right: $govuk-checkboxes-label-padding-left-right;
|
72
|
+
padding-left: $govuk-checkboxes-label-padding-left-right;
|
73
|
+
}
|
74
|
+
|
69
75
|
.govuk-checkboxes__input + .govuk-checkboxes__label::before {
|
70
76
|
content: "";
|
71
77
|
-webkit-box-sizing: border-box;
|
@@ -146,7 +152,7 @@
|
|
146
152
|
padding-left: $conditional-padding-left;
|
147
153
|
border-left: $conditional-border-width solid $govuk-border-colour;
|
148
154
|
|
149
|
-
|
155
|
+
.js-enabled &--hidden {
|
150
156
|
display: none;
|
151
157
|
}
|
152
158
|
|
@@ -659,6 +659,361 @@ if (detect) return
|
|
659
659
|
})
|
660
660
|
.call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
|
661
661
|
|
662
|
+
(function(undefined) {
|
663
|
+
|
664
|
+
// Detection from https://raw.githubusercontent.com/Financial-Times/polyfill-service/master/packages/polyfill-library/polyfills/DOMTokenList/detect.js
|
665
|
+
var detect = (
|
666
|
+
'DOMTokenList' in this && (function (x) {
|
667
|
+
return 'classList' in x ? !x.classList.toggle('x', false) && !x.className : true;
|
668
|
+
})(document.createElement('x'))
|
669
|
+
);
|
670
|
+
|
671
|
+
if (detect) return
|
672
|
+
|
673
|
+
// Polyfill from https://raw.githubusercontent.com/Financial-Times/polyfill-service/master/packages/polyfill-library/polyfills/DOMTokenList/polyfill.js
|
674
|
+
(function (global) {
|
675
|
+
var nativeImpl = "DOMTokenList" in global && global.DOMTokenList;
|
676
|
+
|
677
|
+
if (
|
678
|
+
!nativeImpl ||
|
679
|
+
(
|
680
|
+
!!document.createElementNS &&
|
681
|
+
!!document.createElementNS('http://www.w3.org/2000/svg', 'svg') &&
|
682
|
+
!(document.createElementNS("http://www.w3.org/2000/svg", "svg").classList instanceof DOMTokenList)
|
683
|
+
)
|
684
|
+
) {
|
685
|
+
global.DOMTokenList = (function() { // eslint-disable-line no-unused-vars
|
686
|
+
var dpSupport = true;
|
687
|
+
var defineGetter = function (object, name, fn, configurable) {
|
688
|
+
if (Object.defineProperty)
|
689
|
+
Object.defineProperty(object, name, {
|
690
|
+
configurable: false === dpSupport ? true : !!configurable,
|
691
|
+
get: fn
|
692
|
+
});
|
693
|
+
|
694
|
+
else object.__defineGetter__(name, fn);
|
695
|
+
};
|
696
|
+
|
697
|
+
/** Ensure the browser allows Object.defineProperty to be used on native JavaScript objects. */
|
698
|
+
try {
|
699
|
+
defineGetter({}, "support");
|
700
|
+
}
|
701
|
+
catch (e) {
|
702
|
+
dpSupport = false;
|
703
|
+
}
|
704
|
+
|
705
|
+
|
706
|
+
var _DOMTokenList = function (el, prop) {
|
707
|
+
var that = this;
|
708
|
+
var tokens = [];
|
709
|
+
var tokenMap = {};
|
710
|
+
var length = 0;
|
711
|
+
var maxLength = 0;
|
712
|
+
var addIndexGetter = function (i) {
|
713
|
+
defineGetter(that, i, function () {
|
714
|
+
preop();
|
715
|
+
return tokens[i];
|
716
|
+
}, false);
|
717
|
+
|
718
|
+
};
|
719
|
+
var reindex = function () {
|
720
|
+
|
721
|
+
/** Define getter functions for array-like access to the tokenList's contents. */
|
722
|
+
if (length >= maxLength)
|
723
|
+
for (; maxLength < length; ++maxLength) {
|
724
|
+
addIndexGetter(maxLength);
|
725
|
+
}
|
726
|
+
};
|
727
|
+
|
728
|
+
/** Helper function called at the start of each class method. Internal use only. */
|
729
|
+
var preop = function () {
|
730
|
+
var error;
|
731
|
+
var i;
|
732
|
+
var args = arguments;
|
733
|
+
var rSpace = /\s+/;
|
734
|
+
|
735
|
+
/** Validate the token/s passed to an instance method, if any. */
|
736
|
+
if (args.length)
|
737
|
+
for (i = 0; i < args.length; ++i)
|
738
|
+
if (rSpace.test(args[i])) {
|
739
|
+
error = new SyntaxError('String "' + args[i] + '" ' + "contains" + ' an invalid character');
|
740
|
+
error.code = 5;
|
741
|
+
error.name = "InvalidCharacterError";
|
742
|
+
throw error;
|
743
|
+
}
|
744
|
+
|
745
|
+
|
746
|
+
/** Split the new value apart by whitespace*/
|
747
|
+
if (typeof el[prop] === "object") {
|
748
|
+
tokens = ("" + el[prop].baseVal).replace(/^\s+|\s+$/g, "").split(rSpace);
|
749
|
+
} else {
|
750
|
+
tokens = ("" + el[prop]).replace(/^\s+|\s+$/g, "").split(rSpace);
|
751
|
+
}
|
752
|
+
|
753
|
+
/** Avoid treating blank strings as single-item token lists */
|
754
|
+
if ("" === tokens[0]) tokens = [];
|
755
|
+
|
756
|
+
/** Repopulate the internal token lists */
|
757
|
+
tokenMap = {};
|
758
|
+
for (i = 0; i < tokens.length; ++i)
|
759
|
+
tokenMap[tokens[i]] = true;
|
760
|
+
length = tokens.length;
|
761
|
+
reindex();
|
762
|
+
};
|
763
|
+
|
764
|
+
/** Populate our internal token list if the targeted attribute of the subject element isn't empty. */
|
765
|
+
preop();
|
766
|
+
|
767
|
+
/** Return the number of tokens in the underlying string. Read-only. */
|
768
|
+
defineGetter(that, "length", function () {
|
769
|
+
preop();
|
770
|
+
return length;
|
771
|
+
});
|
772
|
+
|
773
|
+
/** Override the default toString/toLocaleString methods to return a space-delimited list of tokens when typecast. */
|
774
|
+
that.toLocaleString =
|
775
|
+
that.toString = function () {
|
776
|
+
preop();
|
777
|
+
return tokens.join(" ");
|
778
|
+
};
|
779
|
+
|
780
|
+
that.item = function (idx) {
|
781
|
+
preop();
|
782
|
+
return tokens[idx];
|
783
|
+
};
|
784
|
+
|
785
|
+
that.contains = function (token) {
|
786
|
+
preop();
|
787
|
+
return !!tokenMap[token];
|
788
|
+
};
|
789
|
+
|
790
|
+
that.add = function () {
|
791
|
+
preop.apply(that, args = arguments);
|
792
|
+
|
793
|
+
for (var args, token, i = 0, l = args.length; i < l; ++i) {
|
794
|
+
token = args[i];
|
795
|
+
if (!tokenMap[token]) {
|
796
|
+
tokens.push(token);
|
797
|
+
tokenMap[token] = true;
|
798
|
+
}
|
799
|
+
}
|
800
|
+
|
801
|
+
/** Update the targeted attribute of the attached element if the token list's changed. */
|
802
|
+
if (length !== tokens.length) {
|
803
|
+
length = tokens.length >>> 0;
|
804
|
+
if (typeof el[prop] === "object") {
|
805
|
+
el[prop].baseVal = tokens.join(" ");
|
806
|
+
} else {
|
807
|
+
el[prop] = tokens.join(" ");
|
808
|
+
}
|
809
|
+
reindex();
|
810
|
+
}
|
811
|
+
};
|
812
|
+
|
813
|
+
that.remove = function () {
|
814
|
+
preop.apply(that, args = arguments);
|
815
|
+
|
816
|
+
/** Build a hash of token names to compare against when recollecting our token list. */
|
817
|
+
for (var args, ignore = {}, i = 0, t = []; i < args.length; ++i) {
|
818
|
+
ignore[args[i]] = true;
|
819
|
+
delete tokenMap[args[i]];
|
820
|
+
}
|
821
|
+
|
822
|
+
/** Run through our tokens list and reassign only those that aren't defined in the hash declared above. */
|
823
|
+
for (i = 0; i < tokens.length; ++i)
|
824
|
+
if (!ignore[tokens[i]]) t.push(tokens[i]);
|
825
|
+
|
826
|
+
tokens = t;
|
827
|
+
length = t.length >>> 0;
|
828
|
+
|
829
|
+
/** Update the targeted attribute of the attached element. */
|
830
|
+
if (typeof el[prop] === "object") {
|
831
|
+
el[prop].baseVal = tokens.join(" ");
|
832
|
+
} else {
|
833
|
+
el[prop] = tokens.join(" ");
|
834
|
+
}
|
835
|
+
reindex();
|
836
|
+
};
|
837
|
+
|
838
|
+
that.toggle = function (token, force) {
|
839
|
+
preop.apply(that, [token]);
|
840
|
+
|
841
|
+
/** Token state's being forced. */
|
842
|
+
if (undefined !== force) {
|
843
|
+
if (force) {
|
844
|
+
that.add(token);
|
845
|
+
return true;
|
846
|
+
} else {
|
847
|
+
that.remove(token);
|
848
|
+
return false;
|
849
|
+
}
|
850
|
+
}
|
851
|
+
|
852
|
+
/** Token already exists in tokenList. Remove it, and return FALSE. */
|
853
|
+
if (tokenMap[token]) {
|
854
|
+
that.remove(token);
|
855
|
+
return false;
|
856
|
+
}
|
857
|
+
|
858
|
+
/** Otherwise, add the token and return TRUE. */
|
859
|
+
that.add(token);
|
860
|
+
return true;
|
861
|
+
};
|
862
|
+
|
863
|
+
return that;
|
864
|
+
};
|
865
|
+
|
866
|
+
return _DOMTokenList;
|
867
|
+
}());
|
868
|
+
}
|
869
|
+
|
870
|
+
// Add second argument to native DOMTokenList.toggle() if necessary
|
871
|
+
(function () {
|
872
|
+
var e = document.createElement('span');
|
873
|
+
if (!('classList' in e)) return;
|
874
|
+
e.classList.toggle('x', false);
|
875
|
+
if (!e.classList.contains('x')) return;
|
876
|
+
e.classList.constructor.prototype.toggle = function toggle(token /*, force*/) {
|
877
|
+
var force = arguments[1];
|
878
|
+
if (force === undefined) {
|
879
|
+
var add = !this.contains(token);
|
880
|
+
this[add ? 'add' : 'remove'](token);
|
881
|
+
return add;
|
882
|
+
}
|
883
|
+
force = !!force;
|
884
|
+
this[force ? 'add' : 'remove'](token);
|
885
|
+
return force;
|
886
|
+
};
|
887
|
+
}());
|
888
|
+
|
889
|
+
// Add multiple arguments to native DOMTokenList.add() if necessary
|
890
|
+
(function () {
|
891
|
+
var e = document.createElement('span');
|
892
|
+
if (!('classList' in e)) return;
|
893
|
+
e.classList.add('a', 'b');
|
894
|
+
if (e.classList.contains('b')) return;
|
895
|
+
var native = e.classList.constructor.prototype.add;
|
896
|
+
e.classList.constructor.prototype.add = function () {
|
897
|
+
var args = arguments;
|
898
|
+
var l = arguments.length;
|
899
|
+
for (var i = 0; i < l; i++) {
|
900
|
+
native.call(this, args[i]);
|
901
|
+
}
|
902
|
+
};
|
903
|
+
}());
|
904
|
+
|
905
|
+
// Add multiple arguments to native DOMTokenList.remove() if necessary
|
906
|
+
(function () {
|
907
|
+
var e = document.createElement('span');
|
908
|
+
if (!('classList' in e)) return;
|
909
|
+
e.classList.add('a');
|
910
|
+
e.classList.add('b');
|
911
|
+
e.classList.remove('a', 'b');
|
912
|
+
if (!e.classList.contains('b')) return;
|
913
|
+
var native = e.classList.constructor.prototype.remove;
|
914
|
+
e.classList.constructor.prototype.remove = function () {
|
915
|
+
var args = arguments;
|
916
|
+
var l = arguments.length;
|
917
|
+
for (var i = 0; i < l; i++) {
|
918
|
+
native.call(this, args[i]);
|
919
|
+
}
|
920
|
+
};
|
921
|
+
}());
|
922
|
+
|
923
|
+
}(this));
|
924
|
+
|
925
|
+
}).call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
|
926
|
+
|
927
|
+
(function(undefined) {
|
928
|
+
|
929
|
+
// Detection from https://raw.githubusercontent.com/Financial-Times/polyfill-service/8717a9e04ac7aff99b4980fbedead98036b0929a/packages/polyfill-library/polyfills/Element/prototype/classList/detect.js
|
930
|
+
var detect = (
|
931
|
+
'document' in this && "classList" in document.documentElement && 'Element' in this && 'classList' in Element.prototype && (function () {
|
932
|
+
var e = document.createElement('span');
|
933
|
+
e.classList.add('a', 'b');
|
934
|
+
return e.classList.contains('b');
|
935
|
+
}())
|
936
|
+
);
|
937
|
+
|
938
|
+
if (detect) return
|
939
|
+
|
940
|
+
// Polyfill from https://raw.githubusercontent.com/Financial-Times/polyfill-service/8717a9e04ac7aff99b4980fbedead98036b0929a/packages/polyfill-library/polyfills/Element/prototype/classList/polyfill.js
|
941
|
+
(function (global) {
|
942
|
+
var dpSupport = true;
|
943
|
+
var defineGetter = function (object, name, fn, configurable) {
|
944
|
+
if (Object.defineProperty)
|
945
|
+
Object.defineProperty(object, name, {
|
946
|
+
configurable: false === dpSupport ? true : !!configurable,
|
947
|
+
get: fn
|
948
|
+
});
|
949
|
+
|
950
|
+
else object.__defineGetter__(name, fn);
|
951
|
+
};
|
952
|
+
/** Ensure the browser allows Object.defineProperty to be used on native JavaScript objects. */
|
953
|
+
try {
|
954
|
+
defineGetter({}, "support");
|
955
|
+
}
|
956
|
+
catch (e) {
|
957
|
+
dpSupport = false;
|
958
|
+
}
|
959
|
+
/** Polyfills a property with a DOMTokenList */
|
960
|
+
var addProp = function (o, name, attr) {
|
961
|
+
|
962
|
+
defineGetter(o.prototype, name, function () {
|
963
|
+
var tokenList;
|
964
|
+
|
965
|
+
var THIS = this,
|
966
|
+
|
967
|
+
/** Prevent this from firing twice for some reason. What the hell, IE. */
|
968
|
+
gibberishProperty = "__defineGetter__" + "DEFINE_PROPERTY" + name;
|
969
|
+
if(THIS[gibberishProperty]) return tokenList;
|
970
|
+
THIS[gibberishProperty] = true;
|
971
|
+
|
972
|
+
/**
|
973
|
+
* IE8 can't define properties on native JavaScript objects, so we'll use a dumb hack instead.
|
974
|
+
*
|
975
|
+
* What this is doing is creating a dummy element ("reflection") inside a detached phantom node ("mirror")
|
976
|
+
* that serves as the target of Object.defineProperty instead. While we could simply use the subject HTML
|
977
|
+
* element instead, this would conflict with element types which use indexed properties (such as forms and
|
978
|
+
* select lists).
|
979
|
+
*/
|
980
|
+
if (false === dpSupport) {
|
981
|
+
|
982
|
+
var visage;
|
983
|
+
var mirror = addProp.mirror || document.createElement("div");
|
984
|
+
var reflections = mirror.childNodes;
|
985
|
+
var l = reflections.length;
|
986
|
+
|
987
|
+
for (var i = 0; i < l; ++i)
|
988
|
+
if (reflections[i]._R === THIS) {
|
989
|
+
visage = reflections[i];
|
990
|
+
break;
|
991
|
+
}
|
992
|
+
|
993
|
+
/** Couldn't find an element's reflection inside the mirror. Materialise one. */
|
994
|
+
visage || (visage = mirror.appendChild(document.createElement("div")));
|
995
|
+
|
996
|
+
tokenList = DOMTokenList.call(visage, THIS, attr);
|
997
|
+
} else tokenList = new DOMTokenList(THIS, attr);
|
998
|
+
|
999
|
+
defineGetter(THIS, name, function () {
|
1000
|
+
return tokenList;
|
1001
|
+
});
|
1002
|
+
delete THIS[gibberishProperty];
|
1003
|
+
|
1004
|
+
return tokenList;
|
1005
|
+
}, true);
|
1006
|
+
};
|
1007
|
+
|
1008
|
+
addProp(global.Element, "classList", "className");
|
1009
|
+
addProp(global.HTMLElement, "classList", "className");
|
1010
|
+
addProp(global.HTMLLinkElement, "relList", "rel");
|
1011
|
+
addProp(global.HTMLAnchorElement, "relList", "rel");
|
1012
|
+
addProp(global.HTMLAreaElement, "relList", "rel");
|
1013
|
+
}(this));
|
1014
|
+
|
1015
|
+
}).call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
|
1016
|
+
|
662
1017
|
/**
|
663
1018
|
* TODO: Ideally this would be a NodeList.prototype.forEach polyfill
|
664
1019
|
* This seems to fail in IE8, requires more investigation.
|
@@ -711,7 +1066,7 @@ Checkboxes.prototype.setAttributes = function ($input) {
|
|
711
1066
|
$input.setAttribute('aria-expanded', inputIsChecked);
|
712
1067
|
|
713
1068
|
var $content = document.querySelector('#' + $input.getAttribute('aria-controls'));
|
714
|
-
$content.
|
1069
|
+
$content.classList.toggle('govuk-checkboxes__conditional--hidden', !inputIsChecked);
|
715
1070
|
};
|
716
1071
|
|
717
1072
|
Checkboxes.prototype.handleClick = function (event) {
|