govuk_publishing_components 28.5.0 → 28.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (138) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -2
  3. data/app/assets/javascripts/govuk_publishing_components/analytics/page-content.js +3 -3
  4. data/app/assets/javascripts/govuk_publishing_components/analytics/track-select-change.js +4 -3
  5. data/app/assets/javascripts/govuk_publishing_components/components/accordion.js +21 -291
  6. data/app/assets/javascripts/govuk_publishing_components/components/button.js +1 -1
  7. data/app/assets/javascripts/govuk_publishing_components/components/character-count.js +1 -1
  8. data/app/assets/javascripts/govuk_publishing_components/components/checkboxes.js +1 -1
  9. data/app/assets/javascripts/govuk_publishing_components/components/details.js +1 -1
  10. data/app/assets/javascripts/govuk_publishing_components/components/error-summary.js +1 -1
  11. data/app/assets/javascripts/govuk_publishing_components/components/feedback.js +7 -6
  12. data/app/assets/javascripts/govuk_publishing_components/components/layout-header.js +1 -1
  13. data/app/assets/javascripts/govuk_publishing_components/components/radio.js +1 -1
  14. data/app/assets/javascripts/govuk_publishing_components/components/skip-link.js +5 -0
  15. data/app/assets/javascripts/govuk_publishing_components/components/step-by-step-nav.js +40 -37
  16. data/app/assets/javascripts/govuk_publishing_components/components/tabs.js +1 -1
  17. data/app/assets/javascripts/govuk_publishing_components/lib/govspeak/barchart-enhancement.js +2 -1
  18. data/app/assets/javascripts/govuk_publishing_components/lib/govspeak/magna-charta.js +8 -10
  19. data/app/assets/javascripts/govuk_publishing_components/lib/initial-focus.js +4 -3
  20. data/app/assets/javascripts/govuk_publishing_components/lib/toggle-input-class-on-focus.js +4 -3
  21. data/app/assets/javascripts/govuk_publishing_components/lib/toggle.js +4 -3
  22. data/app/assets/javascripts/govuk_publishing_components/vendor/lux/lux-reporter.js +1796 -911
  23. data/app/assets/stylesheets/govuk_publishing_components/components/_accordion.scss +1 -329
  24. data/app/assets/stylesheets/govuk_publishing_components/components/_share-links.scss +1 -1
  25. data/app/assets/stylesheets/govuk_publishing_components/components/_step-by-step-nav.scss +95 -56
  26. data/app/assets/stylesheets/govuk_publishing_components/components/print/_accordion.scss +6 -17
  27. data/app/assets/stylesheets/govuk_publishing_components/govuk_frontend_support.scss +0 -9
  28. data/app/models/govuk_publishing_components/component_docs.rb +1 -1
  29. data/app/views/govuk_publishing_components/components/_accordion.html.erb +31 -16
  30. data/app/views/govuk_publishing_components/components/_attachment.html.erb +3 -1
  31. data/app/views/govuk_publishing_components/components/_button.html.erb +4 -4
  32. data/app/views/govuk_publishing_components/components/_character_count.html.erb +2 -2
  33. data/app/views/govuk_publishing_components/components/_checkboxes.html.erb +2 -2
  34. data/app/views/govuk_publishing_components/components/_error_message.html.erb +1 -1
  35. data/app/views/govuk_publishing_components/components/_error_summary.html.erb +0 -1
  36. data/app/views/govuk_publishing_components/components/_input.html.erb +3 -3
  37. data/app/views/govuk_publishing_components/components/_inset_text.html.erb +12 -1
  38. data/app/views/govuk_publishing_components/components/_intervention.html.erb +2 -2
  39. data/app/views/govuk_publishing_components/components/_layout_footer.html.erb +1 -1
  40. data/app/views/govuk_publishing_components/components/_modal_dialogue.html.erb +1 -1
  41. data/app/views/govuk_publishing_components/components/_radio.html.erb +1 -1
  42. data/app/views/govuk_publishing_components/components/_search.html.erb +2 -4
  43. data/app/views/govuk_publishing_components/components/_select.html.erb +15 -43
  44. data/app/views/govuk_publishing_components/components/_skip_link.html.erb +1 -1
  45. data/app/views/govuk_publishing_components/components/_subscription_links.html.erb +7 -8
  46. data/app/views/govuk_publishing_components/components/docs/accordion.yml +2 -97
  47. data/app/views/govuk_publishing_components/components/docs/attachment.yml +11 -0
  48. data/app/views/govuk_publishing_components/components/docs/govspeak.yml +1 -1
  49. data/app/views/govuk_publishing_components/components/docs/inset_text.yml +6 -0
  50. data/app/views/govuk_publishing_components/components/docs/select.yml +1 -1
  51. data/app/views/govuk_publishing_components/components/docs/share_links.yml +1 -1
  52. data/app/views/govuk_publishing_components/components/docs/step_by_step_nav.yml +13 -13
  53. data/app/views/govuk_publishing_components/components/docs/tabs.yml +1 -1
  54. data/app/views/govuk_publishing_components/components/docs/textarea.yml +1 -1
  55. data/app/views/govuk_publishing_components/components/layout_header/_navigation_items.html.erb +11 -11
  56. data/config/initializers/assets.rb +1 -0
  57. data/lib/govuk_publishing_components/presenters/attachment.rb +23 -0
  58. data/lib/govuk_publishing_components/presenters/select_helper.rb +85 -0
  59. data/lib/govuk_publishing_components/version.rb +1 -1
  60. data/lib/govuk_publishing_components.rb +1 -1
  61. data/node_modules/govuk-frontend/govuk/all.js +294 -76
  62. data/node_modules/govuk-frontend/govuk/components/accordion/_index.scss +274 -99
  63. data/node_modules/govuk-frontend/govuk/components/accordion/accordion.js +169 -65
  64. data/node_modules/govuk-frontend/govuk/components/accordion/fixtures.json +37 -5
  65. data/node_modules/govuk-frontend/govuk/components/accordion/macro-options.json +4 -4
  66. data/node_modules/govuk-frontend/govuk/components/button/button.js +2 -2
  67. data/node_modules/govuk-frontend/govuk/components/character-count/character-count.js +3 -3
  68. data/node_modules/govuk-frontend/govuk/components/character-count/fixtures.json +15 -2
  69. data/node_modules/govuk-frontend/govuk/components/checkboxes/checkboxes.js +8 -10
  70. data/node_modules/govuk-frontend/govuk/components/checkboxes/fixtures.json +52 -15
  71. data/node_modules/govuk-frontend/govuk/components/cookie-banner/_index.scss +0 -2
  72. data/node_modules/govuk-frontend/govuk/components/cookie-banner/fixtures.json +31 -0
  73. data/node_modules/govuk-frontend/govuk/components/date-input/fixtures.json +25 -25
  74. data/node_modules/govuk-frontend/govuk/components/details/details.js +2 -2
  75. data/node_modules/govuk-frontend/govuk/components/error-message/_index.scss +1 -0
  76. data/node_modules/govuk-frontend/govuk/components/error-message/fixtures.json +8 -8
  77. data/node_modules/govuk-frontend/govuk/components/error-message/template.njk +2 -2
  78. data/node_modules/govuk-frontend/govuk/components/error-summary/error-summary.js +24 -3
  79. data/node_modules/govuk-frontend/govuk/components/error-summary/fixtures.json +25 -16
  80. data/node_modules/govuk-frontend/govuk/components/error-summary/macro-options.json +6 -0
  81. data/node_modules/govuk-frontend/govuk/components/error-summary/template.njk +2 -1
  82. data/node_modules/govuk-frontend/govuk/components/file-upload/fixtures.json +4 -4
  83. data/node_modules/govuk-frontend/govuk/components/footer/_index.scss +3 -37
  84. data/node_modules/govuk-frontend/govuk/components/footer/fixtures.json +119 -15
  85. data/node_modules/govuk-frontend/govuk/components/footer/macro-options.json +6 -0
  86. data/node_modules/govuk-frontend/govuk/components/footer/template.njk +1 -1
  87. data/node_modules/govuk-frontend/govuk/components/header/_index.scss +10 -4
  88. data/node_modules/govuk-frontend/govuk/components/header/fixtures.json +11 -11
  89. data/node_modules/govuk-frontend/govuk/components/header/header.js +4 -4
  90. data/node_modules/govuk-frontend/govuk/components/header/template.njk +4 -3
  91. data/node_modules/govuk-frontend/govuk/components/hint/_index.scss +1 -3
  92. data/node_modules/govuk-frontend/govuk/components/input/_index.scss +1 -1
  93. data/node_modules/govuk-frontend/govuk/components/input/fixtures.json +40 -40
  94. data/node_modules/govuk-frontend/govuk/components/input/template.njk +4 -3
  95. data/node_modules/govuk-frontend/govuk/components/notification-banner/notification-banner.js +499 -2
  96. data/node_modules/govuk-frontend/govuk/components/phase-banner/fixtures.json +2 -2
  97. data/node_modules/govuk-frontend/govuk/components/radios/_index.scss +0 -8
  98. data/node_modules/govuk-frontend/govuk/components/radios/fixtures.json +44 -45
  99. data/node_modules/govuk-frontend/govuk/components/radios/radios.js +4 -4
  100. data/node_modules/govuk-frontend/govuk/components/radios/template.njk +2 -9
  101. data/node_modules/govuk-frontend/govuk/components/select/_index.scss +6 -1
  102. data/node_modules/govuk-frontend/govuk/components/select/fixtures.json +3 -3
  103. data/node_modules/govuk-frontend/govuk/components/skip-link/_index.scss +13 -0
  104. data/node_modules/govuk-frontend/govuk/components/skip-link/fixtures.json +9 -9
  105. data/node_modules/govuk-frontend/govuk/components/skip-link/skip-link.js +1108 -0
  106. data/node_modules/govuk-frontend/govuk/components/skip-link/template.njk +1 -1
  107. data/node_modules/govuk-frontend/govuk/components/summary-list/_index.scss +20 -23
  108. data/node_modules/govuk-frontend/govuk/components/summary-list/fixtures.json +86 -1
  109. data/node_modules/govuk-frontend/govuk/components/summary-list/template.njk +1 -4
  110. data/node_modules/govuk-frontend/govuk/components/tabs/_index.scss +2 -2
  111. data/node_modules/govuk-frontend/govuk/components/tabs/tabs.js +2 -2
  112. data/node_modules/govuk-frontend/govuk/components/tag/_index.scss +0 -5
  113. data/node_modules/govuk-frontend/govuk/components/tag/fixtures.json +2 -2
  114. data/node_modules/govuk-frontend/govuk/components/textarea/_index.scss +1 -1
  115. data/node_modules/govuk-frontend/govuk/components/textarea/fixtures.json +4 -4
  116. data/node_modules/govuk-frontend/govuk/core/_all.scss +0 -1
  117. data/node_modules/govuk-frontend/govuk/core/_global-styles.scss +0 -6
  118. data/node_modules/govuk-frontend/govuk/core/_links.scss +0 -6
  119. data/node_modules/govuk-frontend/govuk/core/_lists.scss +0 -6
  120. data/node_modules/govuk-frontend/govuk/core/_section-break.scss +0 -6
  121. data/node_modules/govuk-frontend/govuk/core/_typography.scss +0 -6
  122. data/node_modules/govuk-frontend/govuk/objects/_all.scss +1 -0
  123. data/node_modules/govuk-frontend/govuk/objects/_main-wrapper.scss +15 -30
  124. data/node_modules/govuk-frontend/govuk/{core → objects}/_template.scss +1 -5
  125. data/node_modules/govuk-frontend/govuk/overrides/_display.scss +0 -6
  126. data/node_modules/govuk-frontend/govuk/overrides/_spacing.scss +0 -6
  127. data/node_modules/govuk-frontend/govuk/overrides/_text-align.scss +0 -6
  128. data/node_modules/govuk-frontend/govuk/overrides/_typography.scss +0 -6
  129. data/node_modules/govuk-frontend/govuk/overrides/_width.scss +0 -6
  130. data/node_modules/govuk-frontend/govuk/settings/_colours-organisations.scss +3 -0
  131. data/node_modules/govuk-frontend/govuk/settings/_measurements.scss +0 -10
  132. data/node_modules/govuk-frontend/govuk/tools/_all.scss +0 -1
  133. data/node_modules/govuk-frontend/package.json +1 -1
  134. metadata +22 -37
  135. data/app/assets/javascripts/govuk_publishing_components/lib/header-navigation.js +0 -100
  136. data/lib/govuk_publishing_components/presenters/select.rb +0 -43
  137. data/lib/tasks/govuk_publishing_components_tasks.rake +0 -49
  138. data/node_modules/govuk-frontend/govuk/tools/_iff.scss +0 -17
@@ -40,15 +40,6 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
40
40
  this.$module.sessionStoreLink = this.$module.sessionStoreLink + '_' + this.$module.uniqueId
41
41
  }
42
42
 
43
- this.$module.upChevronSvg = '<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">' +
44
- '<path class="gem-c-step-nav__chevron-stroke" d="M19.5 10C19.5 15.2467 15.2467 19.5 10 19.5C4.75329 19.5 0.499997 15.2467 0.499998 10C0.499999 4.7533 4.7533 0.500001 10 0.500002C15.2467 0.500003 19.5 4.7533 19.5 10Z" stroke="#1D70B8"/>' +
45
- '<path class="gem-c-step-nav__chevron-stroke" d="M6.32617 12.3262L10 8.65234L13.6738 12.3262" stroke="#1D70B8" stroke-width="2"/>' +
46
- '</svg>'
47
- this.$module.downChevronSvg = '<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">' +
48
- '<path class="gem-c-step-nav__chevron-stroke" d="M0.499997 10C0.499998 4.75329 4.75329 0.499999 10 0.499999C15.2467 0.5 19.5 4.75329 19.5 10C19.5 15.2467 15.2467 19.5 10 19.5C4.75329 19.5 0.499997 15.2467 0.499997 10Z" stroke="#1D70B8"/>' +
49
- '<path class="gem-c-step-nav__chevron-stroke" d="M13.6738 8.67383L10 12.3477L6.32617 8.67383" stroke="#1D70B8" stroke-width="2"/>' +
50
- '</svg>'
51
-
52
43
  var stepNavTracker = new this.StepNavTracker(this.$module.uniqueId, this.$module.totalSteps, this.$module.totalLinks)
53
44
 
54
45
  this.getTextForInsertedElements()
@@ -73,16 +64,19 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
73
64
  }
74
65
 
75
66
  Gemstepnav.prototype.addShowHideAllButton = function () {
76
- var showall = document.createElement('div')
77
- showall.className = 'gem-c-step-nav__controls govuk-!-display-none-print'
78
- showall.innerHTML = '<button aria-expanded="false" class="gem-c-step-nav__button gem-c-step-nav__button--controls js-step-controls-button">' +
79
- '<span class="gem-c-step-nav__button-text gem-c-step-nav__button-text--all js-step-controls-button-text">' + this.$module.actions.showAllText + '</span>' +
80
- '<span class="gem-c-step-nav__chevron js-step-controls-button-icon">' + this.$module.downChevronSvg + '</span>' +
81
- '</button>'
82
-
67
+ var showAll = document.createElement('div')
83
68
  var steps = this.$module.querySelectorAll('.gem-c-step-nav__steps')[0]
84
- this.$module.insertBefore(showall, steps)
85
69
 
70
+ showAll.className = 'gem-c-step-nav__controls govuk-!-display-none-print'
71
+ showAll.innerHTML =
72
+ '<button aria-expanded="false" class="gem-c-step-nav__button gem-c-step-nav__button--controls js-step-controls-button">' +
73
+ '<span class="gem-c-step-nav__chevron gem-c-step-nav__chevron--down js-step-controls-button-icon"></span>' +
74
+ '<span class="gem-c-step-nav__button-text gem-c-step-nav__button-text--all js-step-controls-button-text">' +
75
+ this.$module.actions.showAllText +
76
+ '</span>' +
77
+ '</button>'
78
+
79
+ this.$module.insertBefore(showAll, steps)
86
80
  this.$module.showOrHideAllButton = this.$module.querySelectorAll('.js-step-controls-button')[0]
87
81
  }
88
82
 
@@ -91,30 +85,26 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
91
85
  var thisel = this.$module.stepHeaders[i]
92
86
 
93
87
  if (!thisel.querySelectorAll('.js-toggle-link').length) {
94
- var span = document.createElement('span')
95
88
  var showHideSpan = document.createElement('span')
96
89
  var showHideSpanText = document.createElement('span')
97
90
  var showHideSpanIcon = document.createElement('span')
98
- var commaSpan = document.createElement('span')
91
+ var showHideSpanFocus = document.createElement('span')
99
92
  var thisSectionSpan = document.createElement('span')
100
93
 
101
94
  showHideSpan.className = 'gem-c-step-nav__toggle-link js-toggle-link govuk-!-display-none-print'
102
95
  showHideSpanText.className = 'gem-c-step-nav__button-text js-toggle-link-text'
103
96
  showHideSpanIcon.className = 'gem-c-step-nav__chevron js-toggle-link-icon'
104
- commaSpan.className = 'govuk-visually-hidden'
97
+ showHideSpanFocus.className = 'gem-c-step-nav__toggle-link-focus'
105
98
  thisSectionSpan.className = 'govuk-visually-hidden'
106
99
 
107
- showHideSpan.appendChild(showHideSpanText)
108
- showHideSpan.appendChild(showHideSpanIcon)
100
+ showHideSpan.appendChild(showHideSpanFocus)
101
+ showHideSpanFocus.appendChild(showHideSpanIcon)
102
+ showHideSpanFocus.appendChild(showHideSpanText)
109
103
 
110
- commaSpan.innerHTML = ', '
111
104
  thisSectionSpan.innerHTML = ' this section'
105
+ showHideSpan.appendChild(thisSectionSpan)
112
106
 
113
- span.appendChild(commaSpan)
114
- span.appendChild(showHideSpan)
115
- span.appendChild(thisSectionSpan)
116
-
117
- thisel.querySelectorAll('.js-step-title-button')[0].appendChild(span)
107
+ thisel.querySelectorAll('.js-step-title-button')[0].appendChild(showHideSpan)
118
108
  }
119
109
  }
120
110
  }
@@ -125,6 +115,7 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
125
115
 
126
116
  Gemstepnav.prototype.addAriaControlsAttrForShowHideAllButton = function () {
127
117
  var ariaControlsValue = this.$module.querySelectorAll('.js-panel')[0].getAttribute('id')
118
+
128
119
  this.$module.showOrHideAllButton.setAttribute('aria-controls', ariaControlsValue)
129
120
  }
130
121
 
@@ -184,7 +175,10 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
184
175
  '<button ' +
185
176
  'class="gem-c-step-nav__button gem-c-step-nav__button--title js-step-title-button" ' +
186
177
  'aria-expanded="false" aria-controls="' + contentId + '">' +
187
- '<span class="gem-c-step-nav__title-text js-step-title-text">' + titleText + '</span>' +
178
+ '<span class="gem-c-step-nav____title-text-focus">' +
179
+ '<span class="gem-c-step-nav__title-text js-step-title-text">' + titleText + '</span>' +
180
+ '<span class="govuk-visually-hidden gem-c-step-nav__section-heading-divider">, </span>' +
181
+ '</span>' +
188
182
  '</button>' +
189
183
  '</span>'
190
184
  }
@@ -358,12 +352,18 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
358
352
 
359
353
  Gemstepnav.prototype.setShowHideAllText = function () {
360
354
  var shownSteps = this.$module.querySelectorAll('.step-is-shown').length
361
-
355
+ var showAllChevon = this.$module.showOrHideAllButton.querySelector('.js-step-controls-button-icon')
356
+ var showAllButtonText = this.$module.showOrHideAllButton.querySelector('.js-step-controls-button-text')
362
357
  // Find out if the number of is-opens == total number of steps
363
358
  var shownStepsIsTotalSteps = shownSteps === this.$module.totalSteps
364
359
 
365
- this.$module.showOrHideAllButton.querySelector('.js-step-controls-button-text').innerHTML = shownStepsIsTotalSteps ? this.$module.actions.hideAllText : this.$module.actions.showAllText
366
- this.$module.showOrHideAllButton.querySelector('.js-step-controls-button-icon').innerHTML = shownStepsIsTotalSteps ? this.$module.upChevronSvg : this.$module.downChevronSvg
360
+ if (shownStepsIsTotalSteps) {
361
+ showAllButtonText.innerHTML = this.$module.actions.hideAllText
362
+ showAllChevon.classList.remove('gem-c-step-nav__chevron--down')
363
+ } else {
364
+ showAllButtonText.innerHTML = this.$module.actions.showAllText
365
+ showAllChevon.classList.add('gem-c-step-nav__chevron--down')
366
+ }
367
367
  }
368
368
 
369
369
  Gemstepnav.prototype.StepView = function (stepElement, $module) {
@@ -391,19 +391,22 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
391
391
  }
392
392
 
393
393
  this.setIsShown = function (isShown) {
394
+ var toggleLink = this.stepElement.querySelectorAll('.js-toggle-link')[0]
395
+ var toggleLinkText = toggleLink.querySelector('.js-toggle-link-text')
396
+ var stepChevron = toggleLink.querySelector('.js-toggle-link-icon')
397
+
394
398
  if (isShown) {
395
399
  this.stepElement.classList.add('step-is-shown')
396
400
  this.stepContent.classList.remove('js-hidden')
401
+ toggleLinkText.innerHTML = this.hideText
402
+ stepChevron.classList.remove('gem-c-step-nav__chevron--down')
397
403
  } else {
398
404
  this.stepElement.classList.remove('step-is-shown')
399
405
  this.stepContent.classList.add('js-hidden')
406
+ toggleLinkText.innerHTML = this.showText
407
+ stepChevron.classList.add('gem-c-step-nav__chevron--down')
400
408
  }
401
-
402
409
  this.titleButton.setAttribute('aria-expanded', isShown)
403
- var showHideText = this.stepElement.querySelectorAll('.js-toggle-link')[0]
404
-
405
- showHideText.querySelector('.js-toggle-link-text').innerHTML = isShown ? this.hideText : this.showText
406
- showHideText.querySelector('.js-toggle-link-icon').innerHTML = isShown ? this.upChevronSvg : this.downChevronSvg
407
410
  }
408
411
 
409
412
  this.isShown = function () {
@@ -2,4 +2,4 @@
2
2
  // = require govuk/components/tabs/tabs.js
3
3
  window.GOVUK = window.GOVUK || {}
4
4
  window.GOVUK.Modules = window.GOVUK.Modules || {}
5
- window.GOVUK.Modules.GovukTabs = window.GOVUKFrontend
5
+ window.GOVUK.Modules.GovukTabs = window.GOVUKFrontend.Tabs
@@ -24,7 +24,8 @@ window.GOVUK = window.GOVUK || {};
24
24
 
25
25
  for (var i = 0; i < $barcharts.length; i++) {
26
26
  var $table = $barcharts[i]
27
- new GOVUK.Modules.MagnaCharta().start($table, { toggleText: 'Change between chart and table' })
27
+ var magna = new GOVUK.Modules.MagnaCharta($table, { toggleText: 'Change between chart and table' })
28
+ magna.init()
28
29
  $table.className = $table.className + ' js-barchart-table-init'
29
30
  }
30
31
  }
@@ -4,10 +4,8 @@ window.GOVUK = window.GOVUK || {}
4
4
  window.GOVUK.Modules = window.GOVUK.Modules || {};
5
5
 
6
6
  (function (Modules) {
7
- function MagnaCharta () { }
8
-
9
- MagnaCharta.prototype.start = function ($module, options) {
10
- this.$module = $module[0]
7
+ function MagnaCharta ($module, options) {
8
+ this.$table = $module
11
9
  this.options = {
12
10
  outOf: 65,
13
11
  applyOnInit: true,
@@ -22,14 +20,14 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
22
20
  }
23
21
 
24
22
  for (var k in options) this.options[k] = options[k]
23
+ }
24
+
25
+ MagnaCharta.prototype.init = function () {
25
26
  this.detectIEVersion()
26
27
 
27
28
  // Magna Charta doesn't work in IE7 or less - so plain tables are shown to those browsers
28
29
  this.ENABLED = !(this.ie && this.ie < 8)
29
30
 
30
- // store a reference to the table in the object
31
- this.$table = $module
32
-
33
31
  // a container around the graph element so that it can be targeted by screen readers, allowing us to inform screen reader users that the graph isn't accessible
34
32
  this.$graphContainer = document.createElement('div')
35
33
  this.$graphContainer.className = 'mc-chart-container'
@@ -47,7 +45,7 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
47
45
  this.$graph.classList.add('mc-chart')
48
46
 
49
47
  // get the id of the current chart within the page so that it can be used during the generation of the toggleLink
50
- this.chartId = this.getChartId($module)
48
+ this.chartId = this.getChartId()
51
49
 
52
50
  // set the stacked option based on
53
51
  // giving the table a class of mc-stacked
@@ -458,12 +456,12 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
458
456
  }
459
457
  }
460
458
 
461
- MagnaCharta.prototype.getChartId = function (module) {
459
+ MagnaCharta.prototype.getChartId = function () {
462
460
  var allCharts = document.querySelectorAll('table.js-barchart-table')
463
461
  var id = null
464
462
 
465
463
  for (var i = 0; i < allCharts.length; i++) {
466
- if (allCharts[i] === module) {
464
+ if (allCharts[i] === this.$table) {
467
465
  id = i
468
466
  }
469
467
  }
@@ -2,10 +2,11 @@ window.GOVUK = window.GOVUK || {}
2
2
  window.GOVUK.Modules = window.GOVUK.Modules || {};
3
3
 
4
4
  (function (Modules) {
5
- function InitialFocus () { }
5
+ function InitialFocus ($module) {
6
+ this.$module = $module
7
+ }
6
8
 
7
- InitialFocus.prototype.start = function ($module) {
8
- this.$module = $module[0]
9
+ InitialFocus.prototype.init = function () {
9
10
  this.$module.focus()
10
11
  }
11
12
 
@@ -7,10 +7,11 @@ window.GOVUK = window.GOVUK || {}
7
7
  window.GOVUK.Modules = window.GOVUK.Modules || {};
8
8
 
9
9
  (function (Modules) {
10
- function GemToggleInputClassOnFocus () { }
10
+ function GemToggleInputClassOnFocus ($module) {
11
+ this.$module = $module
12
+ }
11
13
 
12
- GemToggleInputClassOnFocus.prototype.start = function ($module) {
13
- this.$module = $module[0]
14
+ GemToggleInputClassOnFocus.prototype.init = function () {
14
15
  this.toggleTarget = this.$module.querySelector('.js-class-toggle')
15
16
  this.$module.addFocusClass = this.addFocusClass.bind(this)
16
17
  this.$module.removeFocusClassFromEmptyInput = this.removeFocusClassFromEmptyInput.bind(this)
@@ -87,10 +87,11 @@ window.GOVUK = window.GOVUK || {}
87
87
  window.GOVUK.Modules = window.GOVUK.Modules || {};
88
88
 
89
89
  (function (Modules) {
90
- function GemToggle () { }
90
+ function GemToggle ($module) {
91
+ this.$module = $module
92
+ }
91
93
 
92
- GemToggle.prototype.start = function ($module) {
93
- this.$module = $module[0]
94
+ GemToggle.prototype.init = function () {
94
95
  this.$module.toggleTrigger = this.$module.querySelector('[data-controls][data-expanded]')
95
96
 
96
97
  if (this.$module.toggleTrigger) {