govuk_frontend_toolkit 4.18.3 → 4.18.4

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.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/.gitignore +1 -0
  3. data/app/assets/CHANGELOG.md +5 -0
  4. data/app/assets/Gruntfile.js +21 -22
  5. data/app/assets/README.md +4 -0
  6. data/app/assets/VERSION.txt +1 -1
  7. data/app/assets/docs/javascript.md +29 -28
  8. data/app/assets/javascripts/govuk/analytics/analytics.js +37 -37
  9. data/app/assets/javascripts/govuk/analytics/download-link-tracker.js +21 -21
  10. data/app/assets/javascripts/govuk/analytics/error-tracking.js +19 -19
  11. data/app/assets/javascripts/govuk/analytics/external-link-tracker.js +23 -24
  12. data/app/assets/javascripts/govuk/analytics/google-analytics-universal-tracker.js +71 -70
  13. data/app/assets/javascripts/govuk/analytics/mailto-link-tracker.js +20 -21
  14. data/app/assets/javascripts/govuk/analytics/print-intent.js +19 -20
  15. data/app/assets/javascripts/govuk/modules.js +33 -32
  16. data/app/assets/javascripts/govuk/modules/auto-track-event.js +18 -18
  17. data/app/assets/javascripts/govuk/multivariate-test.js +83 -85
  18. data/app/assets/javascripts/govuk/primary-links.js +39 -38
  19. data/app/assets/javascripts/govuk/selection-buttons.js +57 -58
  20. data/app/assets/javascripts/govuk/shim-links-with-button-role.js +14 -15
  21. data/app/assets/javascripts/govuk/stick-at-top-when-scrolling.js +70 -70
  22. data/app/assets/javascripts/govuk/stop-scrolling-at-footer.js +74 -75
  23. data/app/assets/javascripts/govuk_toolkit.js +1 -1
  24. data/app/assets/javascripts/stageprompt.js +24 -25
  25. data/app/assets/javascripts/vendor/jquery/jquery.player.min.js +1 -1
  26. data/app/assets/package.json +10 -3
  27. data/app/assets/spec/manifest.js +2 -0
  28. data/app/assets/spec/support/console-runner.js +0 -1
  29. data/app/assets/spec/unit/analytics/analytics.spec.js +51 -47
  30. data/app/assets/spec/unit/analytics/download-link-tracker.spec.js +59 -51
  31. data/app/assets/spec/unit/analytics/error-tracking.spec.js +35 -30
  32. data/app/assets/spec/unit/analytics/external-link-tracker.spec.js +69 -61
  33. data/app/assets/spec/unit/analytics/google-analytics-universal-tracker.spec.js +129 -122
  34. data/app/assets/spec/unit/analytics/mailto-link-tracker.spec.js +55 -47
  35. data/app/assets/spec/unit/modules.spec.js +82 -78
  36. data/app/assets/spec/unit/modules/auto-track-event.spec.js +45 -40
  37. data/app/assets/spec/unit/multivariate-test.spec.js +150 -145
  38. data/app/assets/spec/unit/primary-links.spec.js +53 -47
  39. data/app/assets/spec/unit/selection-button.spec.js +701 -693
  40. data/app/assets/spec/unit/shim-links-with-button-role.spec.js +33 -28
  41. data/app/assets/spec/unit/show-hide-content.spec.js +5 -1
  42. data/app/assets/spec/unit/stick-at-top-when-scrolling.spec.js +104 -107
  43. metadata +2 -2
@@ -1,36 +1,41 @@
1
- describe("shim-links-with-button-role", function () {
2
- var $body;
3
- var $buttonLink;
4
- var keyupEvent;
1
+ /* global describe it expect beforeEach afterEach */
2
+
3
+ var $ = window.jQuery
4
+
5
+ describe('shim-links-with-button-role', function () {
6
+ 'use strict'
7
+ var GOVUK = window.GOVUK
8
+
9
+ var $buttonLink
10
+ var keyupEvent
5
11
 
6
12
  beforeEach(function () {
7
- $buttonLink = $('<a role="button">Button</a>');
8
- $buttonLink.on('click',function(){
9
- $buttonLink.addClass('clicked');
10
- });
11
- $(document.body).append($buttonLink);
12
- keyupEvent = $.Event('keyup');
13
- keyupEvent.target = $buttonLink.get(0);
14
- GOVUK.shimLinksWithButtonRole.init();
15
- });
13
+ $buttonLink = $('<a role="button">Button</a>')
14
+ $buttonLink.on('click', function () {
15
+ $buttonLink.addClass('clicked')
16
+ })
17
+ $(document.body).append($buttonLink)
18
+ keyupEvent = $.Event('keyup')
19
+ keyupEvent.target = $buttonLink.get(0)
20
+ GOVUK.shimLinksWithButtonRole.init()
21
+ })
16
22
 
17
23
  afterEach(function () {
18
- $buttonLink.remove();
19
- $(document).off('keyup');
20
- });
24
+ $buttonLink.remove()
25
+ $(document).off('keyup')
26
+ })
21
27
 
22
- it('should trigger event on space', function(){
28
+ it('should trigger event on space', function () {
23
29
  // Ideally we’d test the page loading functionality but that seems hard to
24
30
  // do within a Jasmine context. Settle for checking a bound event trigger.
25
- keyupEvent.which = 32; // Space character
26
- $(document).trigger(keyupEvent);
27
- expect($buttonLink.hasClass('clicked')).toBe(true);
28
- });
29
-
30
- it('should not trigger event on tab', function(){
31
- keyupEvent.which = 9; // Tab character
32
- $(document).trigger(keyupEvent);
33
- expect($buttonLink.hasClass('clicked')).toBe(false);
34
- });
31
+ keyupEvent.which = 32 // Space character
32
+ $(document).trigger(keyupEvent)
33
+ expect($buttonLink.hasClass('clicked')).toBe(true)
34
+ })
35
35
 
36
- });
36
+ it('should not trigger event on tab', function () {
37
+ keyupEvent.which = 9 // Tab character
38
+ $(document).trigger(keyupEvent)
39
+ expect($buttonLink.hasClass('clicked')).toBe(false)
40
+ })
41
+ })
@@ -1,8 +1,12 @@
1
+ /* global describe it expect beforeEach afterEach jasmine */
2
+
3
+ var $ = window.jQuery
4
+
1
5
  describe('show-hide-content', function () {
2
6
  'use strict'
7
+ var GOVUK = window.GOVUK
3
8
 
4
9
  beforeEach(function () {
5
-
6
10
  // Sample markup
7
11
  this.$content = $(
8
12
 
@@ -1,121 +1,118 @@
1
- describe("stick-at-top-when-scrolling", function(){
2
- var $stickyElement,
3
- $stickyWrapper;
4
-
5
- beforeEach(function(){
6
- $stickyElement = $('<div class="stick-at-top-when-scrolling"></div>');
7
- $stickyWrapper = $('<div>').append($stickyElement);
8
-
9
- $('body').append($stickyWrapper);
10
- });
11
-
12
- afterEach(function(){
13
- $stickyWrapper.remove();
14
- });
15
-
16
- describe('when stick is called', function(){
17
-
18
- it('should add fixed class on stick', function(){
19
- expect(!$stickyElement.hasClass('content-fixed')).toBe(true);
20
- GOVUK.stickAtTopWhenScrolling.stick($stickyElement);
21
- expect($stickyElement.hasClass('content-fixed')).toBe(true);
22
- });
23
-
24
- it('should insert shim when sticking the element', function(){
25
- expect($('.shim').length).toBe(0);
26
- GOVUK.stickAtTopWhenScrolling.stick($stickyElement);
27
- expect($('.shim').length).toBe(1);
28
- });
29
-
30
- it('should insert shim with minimum height', function(){
31
- GOVUK.stickAtTopWhenScrolling.stick($stickyElement);
32
- expect($('.shim').height()).toBe(1);
33
- });
34
-
35
- });
36
-
37
- describe('when release is called', function(){
38
-
39
- it('should remove fixed class', function(){
40
- $stickyElement.addClass('content-fixed');
41
- GOVUK.stickAtTopWhenScrolling.release($stickyElement);
42
- expect($stickyElement.hasClass('content-fixed')).toBe(false);
43
- });
44
-
45
- it('should remove the shim', function(){
46
- $stickyElement = $('<div class="stick-at-top-when-scrolling content-fixed"></div>');
47
- GOVUK.stickAtTopWhenScrolling.release($stickyElement);
48
- expect($('.shim').length).toBe(0);
49
- });
50
-
51
- });
52
-
53
- describe('for larger screens (>768px)', function(){
54
-
55
- beforeEach(function() {
56
- GOVUK.stickAtTopWhenScrolling.getWindowPositions = function(){
1
+ /* global describe it expect beforeEach afterEach */
2
+
3
+ var $ = window.jQuery
4
+
5
+ describe('stick-at-top-when-scrolling', function () {
6
+ 'use strict'
7
+ var GOVUK = window.GOVUK
8
+
9
+ var $stickyElement
10
+ var $stickyWrapper
11
+
12
+ beforeEach(function () {
13
+ $stickyElement = $('<div class="stick-at-top-when-scrolling"></div>')
14
+ $stickyWrapper = $('<div>').append($stickyElement)
15
+
16
+ $('body').append($stickyWrapper)
17
+ })
18
+
19
+ afterEach(function () {
20
+ $stickyWrapper.remove()
21
+ })
22
+
23
+ describe('when stick is called', function () {
24
+ it('should add fixed class on stick', function () {
25
+ expect(!$stickyElement.hasClass('content-fixed')).toBe(true)
26
+ GOVUK.stickAtTopWhenScrolling.stick($stickyElement)
27
+ expect($stickyElement.hasClass('content-fixed')).toBe(true)
28
+ })
29
+
30
+ it('should insert shim when sticking the element', function () {
31
+ expect($('.shim').length).toBe(0)
32
+ GOVUK.stickAtTopWhenScrolling.stick($stickyElement)
33
+ expect($('.shim').length).toBe(1)
34
+ })
35
+
36
+ it('should insert shim with minimum height', function () {
37
+ GOVUK.stickAtTopWhenScrolling.stick($stickyElement)
38
+ expect($('.shim').height()).toBe(1)
39
+ })
40
+ })
41
+
42
+ describe('when release is called', function () {
43
+ it('should remove fixed class', function () {
44
+ $stickyElement.addClass('content-fixed')
45
+ GOVUK.stickAtTopWhenScrolling.release($stickyElement)
46
+ expect($stickyElement.hasClass('content-fixed')).toBe(false)
47
+ })
48
+
49
+ it('should remove the shim', function () {
50
+ $stickyElement = $('<div class="stick-at-top-when-scrolling content-fixed"></div>')
51
+ GOVUK.stickAtTopWhenScrolling.release($stickyElement)
52
+ expect($('.shim').length).toBe(0)
53
+ })
54
+ })
55
+
56
+ describe('for larger screens (>768px)', function () {
57
+ beforeEach(function () {
58
+ GOVUK.stickAtTopWhenScrolling.getWindowPositions = function () {
57
59
  return {
58
60
  scrollTop: 300
59
- };
60
- };
61
- GOVUK.stickAtTopWhenScrolling.getElementOffset = function(){
61
+ }
62
+ }
63
+ GOVUK.stickAtTopWhenScrolling.getElementOffset = function () {
62
64
  return {
63
65
  top: 300
64
- };
65
- };
66
- GOVUK.stickAtTopWhenScrolling.getWindowDimensions = function(){
66
+ }
67
+ }
68
+ GOVUK.stickAtTopWhenScrolling.getWindowDimensions = function () {
67
69
  return {
68
70
  height: 768,
69
71
  width: 769
70
- };
71
- };
72
- GOVUK.stickAtTopWhenScrolling.$els = $stickyElement;
73
- GOVUK.stickAtTopWhenScrolling._hasScrolled = true;
74
- GOVUK.stickAtTopWhenScrolling.checkScroll();
75
- });
76
-
77
- it('should stick, if the scroll position is past the element position', function(){
78
- expect($stickyElement.hasClass('content-fixed')).toBe(true);
79
- });
80
-
81
- it('should unstick, if the scroll position is less than the point at which scrolling started', function(){
82
- GOVUK.stickAtTopWhenScrolling.getWindowPositions = function() {
72
+ }
73
+ }
74
+ GOVUK.stickAtTopWhenScrolling.$els = $stickyElement
75
+ GOVUK.stickAtTopWhenScrolling._hasScrolled = true
76
+ GOVUK.stickAtTopWhenScrolling.checkScroll()
77
+ })
78
+
79
+ it('should stick, if the scroll position is past the element position', function () {
80
+ expect($stickyElement.hasClass('content-fixed')).toBe(true)
81
+ })
82
+
83
+ it('should unstick, if the scroll position is less than the point at which scrolling started', function () {
84
+ GOVUK.stickAtTopWhenScrolling.getWindowPositions = function () {
83
85
  return {
84
86
  scrollTop: 0
85
- };
86
- };
87
- GOVUK.stickAtTopWhenScrolling.$els = $stickyElement;
88
- GOVUK.stickAtTopWhenScrolling._hasScrolled = true;
89
- GOVUK.stickAtTopWhenScrolling.checkScroll();
90
- expect($stickyElement.hasClass('content-fixed')).toBe(false);
91
- });
92
-
93
- });
94
-
95
- describe('for smaller screens (<=768px)', function(){
96
-
97
- beforeEach(function() {
98
- GOVUK.stickAtTopWhenScrolling.getWindowDimensions = function() {
87
+ }
88
+ }
89
+ GOVUK.stickAtTopWhenScrolling.$els = $stickyElement
90
+ GOVUK.stickAtTopWhenScrolling._hasScrolled = true
91
+ GOVUK.stickAtTopWhenScrolling.checkScroll()
92
+ expect($stickyElement.hasClass('content-fixed')).toBe(false)
93
+ })
94
+ })
95
+
96
+ describe('for smaller screens (<=768px)', function () {
97
+ beforeEach(function () {
98
+ GOVUK.stickAtTopWhenScrolling.getWindowDimensions = function () {
99
99
  return {
100
100
  height: 768,
101
101
  width: 767
102
- };
103
- };
104
- GOVUK.stickAtTopWhenScrolling.getElementOffset = function() {
102
+ }
103
+ }
104
+ GOVUK.stickAtTopWhenScrolling.getElementOffset = function () {
105
105
  return {
106
106
  top: 300
107
- };
108
- };
109
- GOVUK.stickAtTopWhenScrolling.$els = $stickyElement;
110
- GOVUK.stickAtTopWhenScrolling._hasScrolled = true;
111
- GOVUK.stickAtTopWhenScrolling.checkScroll();
112
- });
113
-
114
- it('should unstick the element', function(){
115
- expect($stickyElement.hasClass('content-fixed')).toBe(false);
116
- });
117
-
118
- });
119
-
120
- });
121
-
107
+ }
108
+ }
109
+ GOVUK.stickAtTopWhenScrolling.$els = $stickyElement
110
+ GOVUK.stickAtTopWhenScrolling._hasScrolled = true
111
+ GOVUK.stickAtTopWhenScrolling.checkScroll()
112
+ })
113
+
114
+ it('should unstick the element', function () {
115
+ expect($stickyElement.hasClass('content-fixed')).toBe(false)
116
+ })
117
+ })
118
+ })
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: 4.18.3
4
+ version: 4.18.4
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: 2016-10-07 00:00:00.000000000 Z
11
+ date: 2016-10-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails