govuk_tech_docs 1.8.3 → 1.9.0.pre.gfe

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
- SHA256:
3
- metadata.gz: ca98142d9889b9d327ef922e841aadb51dee44d44ba1e649219e7db4e1c8494d
4
- data.tar.gz: 9ddc5532e23363a4916e5c0b90adf32e11aceb02ebdcacde6e2175476bc83116
2
+ SHA1:
3
+ metadata.gz: b15917404d723a9e26821b9631a06b181a051265
4
+ data.tar.gz: ff5c490cfde2dbde881f4a6d8dc678de7e81e536
5
5
  SHA512:
6
- metadata.gz: ab412d6c77c2e49f5d7d21474fb5e16fccaf20f338d64cf1eb29d32ad58af238f9889d44b39bc799ab7639b3b319233b880508beb2e394c58b8db701d58ee245
7
- data.tar.gz: 305c7029a492835b53775ae79d4b6e43f66319b669adc1fb7375fd0aacdaa6d1643bc1a97f7260ef89a2e172f549cb6e101b9c0a0589f626b72412101f25518a
6
+ metadata.gz: 7a7e6cdda4975aa034ac877c90a0ab8efdd52efcf68d4126d2fd7310d24952095cd58ed70b0b9d5cb45c10510a0baea28e01dfaa272d78dc16b36eb9f849cb52
7
+ data.tar.gz: f551baaafad28fda969b023d430e6694d8a068513a7ebfe7a4f043baa776865945df144feef0c03873c95c2861eea9f8872d3e6544a7e9e4cc113c2fa9ea0a3c
data/.gitignore CHANGED
@@ -32,3 +32,4 @@
32
32
  /example/.sass-cache
33
33
 
34
34
  Gemfile.lock
35
+ node_modules
data/.nvmrc ADDED
@@ -0,0 +1 @@
1
+ 10.16.0
@@ -1,4 +1,6 @@
1
1
  language: ruby
2
+ before_script:
3
+ - npm install
2
4
  deploy:
3
5
  provider: rubygems
4
6
  gem: govuk_tech_docs
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## Unreleased
4
+
5
+ This release adds [GOV.UK Frontend](https://github.com/alphagov/govuk-frontend) (part of the [GOV.UK Design System](https://design-system.service.gov.uk)). Converts the "phase tag" (the alpha/beta thing next to the logo) to use a GOV.UK Frontend component. Also adds [Standard JS](https://standardjs.com) to the code base to lint all Javascript.
6
+
3
7
  ## 1.8.3
4
8
 
5
9
  Fixes bug where search results disappear when opening results in a new tab, making it difficult to open several results in a batch (PR #86).
data/README.md CHANGED
@@ -15,6 +15,12 @@ Everybody who uses this project is encouraged to contribute.
15
15
 
16
16
  👉 [See CONTRIBUTING.md](CONTRIBUTING.md) for guidance on making changes.
17
17
 
18
+ ## GOV.UK frontend
19
+
20
+ This gem uses [GOV.UK Frontend](https://github.com/alphagov/govuk-frontend), part of the [GOV.UK Design System](https://design-system.service.gov.uk/).
21
+
22
+ We use `npm` to download the govuk-frontend package. To update to a new version, change the version in [package.json](blob/master/package.json) and run `npm update`.
23
+
18
24
  ## Developing locally
19
25
 
20
26
  There are 2 ways to develop with this gem. You can see your changes on either:
data/Rakefile CHANGED
@@ -8,6 +8,7 @@ load 'jasmine/tasks/jasmine.rake'
8
8
 
9
9
  task :lint do
10
10
  sh "govuk-lint-ruby example lib spec Rakefile"
11
+ sh "npm run lint --silent"
11
12
  end
12
13
 
13
14
  task default: ['lint', 'spec', 'jasmine:ci']
@@ -17,3 +17,5 @@ To change the title of the page or include additional files you'll need to edit
17
17
  If you want slightly more control, you can always use <strong>HTML</strong>.
18
18
 
19
19
  For more detail and troubleshooting, take a look at the `README.md` file in the root of this project.
20
+
21
+ <%= warning_text "Look out! A warning!" %>
@@ -14,9 +14,9 @@ Gem::Specification.new do |spec|
14
14
  spec.homepage = "https://github.com/alphagov/tech-docs-gem"
15
15
  spec.license = "MIT"
16
16
 
17
- spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
- f.match(%r{^(test|spec|features)/})
19
- end
17
+ files_in_git = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.files = files_in_git + ["node_modules/govuk-frontend"]
19
+
20
20
  spec.bindir = "exe"
21
21
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
22
  spec.require_paths = ["lib"]
@@ -1,8 +1,8 @@
1
- (function($) {
2
- function trackLinkClick(action, $element) {
3
- var linkText = $.trim($element.text());
4
- var linkURL = $element.attr('href');
5
- var label = linkText + '|' + linkURL;
1
+ (function ($) {
2
+ function trackLinkClick (action, $element) {
3
+ var linkText = $.trim($element.text())
4
+ var linkURL = $element.attr('href')
5
+ var label = linkText + '|' + linkURL
6
6
 
7
7
  ga(
8
8
  'send',
@@ -10,38 +10,38 @@
10
10
  'SM Technical Documentation', // Event Category
11
11
  action, // Event Action
12
12
  label // Event Label
13
- );
13
+ )
14
14
  }
15
15
 
16
- function linkTrackingEventHandler(action) {
17
- return function() {
18
- trackLinkClick(action, $(this));
19
- };
20
- };
16
+ function linkTrackingEventHandler (action) {
17
+ return function () {
18
+ trackLinkClick(action, $(this))
19
+ }
20
+ }
21
21
 
22
- function catchBrokenFragmentLinks() {
23
- var fragment = window.location.hash;
24
- var $target = $(fragment);
25
- if(!$target.get(0)) {
22
+ function catchBrokenFragmentLinks () {
23
+ var fragment = window.location.hash
24
+ var $target = $(fragment)
25
+ if (!$target.get(0)) {
26
26
  ga(
27
27
  'send',
28
28
  'event',
29
29
  'Broken fragment ID', // Event Category
30
30
  'pageview', // Event Action
31
31
  window.location.pathname + fragment // Event Label
32
- );
32
+ )
33
33
  }
34
34
  }
35
35
 
36
- $(document).on('ready', function() {
36
+ $(document).on('ready', function () {
37
37
  if (typeof ga === 'undefined') {
38
- return;
38
+ return
39
39
  }
40
40
 
41
- $('.technical-documentation a').on('click', linkTrackingEventHandler('inTextClick'));
42
- $('.header a').on('click', linkTrackingEventHandler('topNavigationClick'));
43
- $('.toc a').on('click', linkTrackingEventHandler('tableOfContentsNavigationClick'));
44
- catchBrokenFragmentLinks();
41
+ $('.technical-documentation a').on('click', linkTrackingEventHandler('inTextClick'))
42
+ $('.header a').on('click', linkTrackingEventHandler('topNavigationClick'))
43
+ $('.toc a').on('click', linkTrackingEventHandler('tableOfContentsNavigationClick'))
44
+ catchBrokenFragmentLinks()
45
45
 
46
46
  // Borrowed from:
47
47
  // https://github.com/alphagov/govuk_frontend_toolkit/blob/master/javascripts/govuk/analytics/analytics.js
@@ -50,9 +50,9 @@
50
50
  var POSTCODE_PATTERN = /[A-PR-UWYZ][A-HJ-Z]?[0-9][0-9A-HJKMNPR-Y]?(?:[\s+]|%20)*[0-9][ABD-HJLNPQ-Z]{2}/gi
51
51
  var DATE_PATTERN = /\d{4}(-?)\d{2}(-?)\d{2}/g
52
52
  var stripped = string.replace(EMAIL_PATTERN, '[email]')
53
- .replace(DATE_PATTERN, '[date]')
54
- .replace(POSTCODE_PATTERN, '[postcode]');
53
+ .replace(DATE_PATTERN, '[date]')
54
+ .replace(POSTCODE_PATTERN, '[postcode]')
55
55
  return stripped
56
56
  }
57
- });
58
- })(jQuery);
57
+ })
58
+ })(jQuery)
@@ -1,57 +1,56 @@
1
- (function($, root) {
2
- "use strict";
3
- root.GOVUK = root.GOVUK || {};
4
- GOVUK.Modules = GOVUK.Modules || {};
1
+ (function ($, root) {
2
+ 'use strict'
3
+ root.GOVUK = root.GOVUK || {}
4
+ GOVUK.Modules = GOVUK.Modules || {}
5
5
 
6
6
  GOVUK.modules = {
7
- find: function(container) {
8
- var modules,
9
- moduleSelector = '[data-module]',
10
- container = container || $('body');
7
+ find: function (container) {
8
+ var modules
9
+ var moduleSelector = '[data-module]'
10
+ var component = container || $('body')
11
11
 
12
- modules = container.find(moduleSelector);
12
+ modules = component.find(moduleSelector)
13
13
 
14
14
  // Container could be a module too
15
- if (container.is(moduleSelector)) {
16
- modules = modules.add(container);
15
+ if (component.is(moduleSelector)) {
16
+ modules = modules.add(component)
17
17
  }
18
18
 
19
- return modules;
19
+ return modules
20
20
  },
21
21
 
22
- start: function(container) {
23
- var modules = this.find(container);
22
+ start: function (container) {
23
+ var modules = this.find(container)
24
24
 
25
25
  for (var i = 0, l = modules.length; i < l; i++) {
26
- var module,
27
- element = $(modules[i]),
28
- type = camelCaseAndCapitalise(element.data('module')),
29
- started = element.data('module-started');
30
-
31
-
32
- if (typeof GOVUK.Modules[type] === "function" && !started) {
33
- module = new GOVUK.Modules[type]();
34
- module.start(element);
35
- element.data('module-started', true);
26
+ var module
27
+ var element = $(modules[i])
28
+ var type = camelCaseAndCapitalise(element.data('module'))
29
+ var started = element.data('module-started')
30
+
31
+ if (typeof GOVUK.Modules[type] === 'function' && !started) {
32
+ module = new GOVUK.Modules[type]()
33
+ module.start(element)
34
+ element.data('module-started', true)
36
35
  }
37
36
  }
38
37
 
39
38
  // eg selectable-table to SelectableTable
40
- function camelCaseAndCapitalise(string) {
41
- return capitaliseFirstLetter(camelCase(string));
39
+ function camelCaseAndCapitalise (string) {
40
+ return capitaliseFirstLetter(camelCase(string))
42
41
  }
43
42
 
44
43
  // http://stackoverflow.com/questions/6660977/convert-hyphens-to-camel-case-camelcase
45
- function camelCase(string) {
44
+ function camelCase (string) {
46
45
  return string.replace(/-([a-z])/g, function (g) {
47
- return g[1].toUpperCase();
48
- });
46
+ return g[1].toUpperCase()
47
+ })
49
48
  }
50
49
 
51
50
  // http://stackoverflow.com/questions/1026069/capitalize-the-first-letter-of-string-in-javascript
52
- function capitaliseFirstLetter(string) {
53
- return string.charAt(0).toUpperCase() + string.slice(1);
51
+ function capitaliseFirstLetter (string) {
52
+ return string.charAt(0).toUpperCase() + string.slice(1)
54
53
  }
55
54
  }
56
55
  }
57
- })(jQuery, window);
56
+ })(jQuery, window)
@@ -1,18 +1,18 @@
1
- (function($, Modules) {
2
- 'use strict';
1
+ (function ($, Modules) {
2
+ 'use strict'
3
3
 
4
- Modules.AnchoredHeadings = function() {
5
- this.start = function($element) {
6
- var headings = $element.find('h1, h2, h3, h4, h5, h6');
7
- headings.each(injectAnchor);
8
- };
4
+ Modules.AnchoredHeadings = function () {
5
+ this.start = function ($element) {
6
+ var headings = $element.find('h1, h2, h3, h4, h5, h6')
7
+ headings.each(injectAnchor)
8
+ }
9
9
 
10
- function injectAnchor() {
11
- var $this = $(this);
12
- $this.addClass('anchored-heading');
10
+ function injectAnchor () {
11
+ var $this = $(this)
12
+ $this.addClass('anchored-heading')
13
13
  $this.prepend(
14
14
  '<a href="#' + $this.attr('id') + '" class="anchored-heading__icon" aria-hidden="true"></a>'
15
- );
16
- };
17
- };
18
- })(jQuery, window.GOVUK.Modules);
15
+ )
16
+ }
17
+ }
18
+ })(jQuery, window.GOVUK.Modules)
@@ -1,95 +1,84 @@
1
- (function($, Modules) {
2
- 'use strict';
1
+ (function ($, Modules) {
2
+ 'use strict'
3
3
 
4
4
  Modules.CollapsibleNavigation = function () {
5
-
6
- var $contentPane;
7
- var $nav;
8
- var $topLevelItems;
9
- var $headings;
10
- var $listings;
11
-
12
- var $openLink;
13
- var $closeLink;
5
+ var $contentPane
6
+ var $nav
7
+ var $topLevelItems
14
8
 
15
9
  this.start = function ($element) {
16
- $contentPane = $('.app-pane__content');
17
- $nav = $element;
18
- $topLevelItems = $nav.find('> ul > li');
19
- $headings = $topLevelItems.find('> a');
20
- $listings = $topLevelItems.find('> ul');
10
+ $contentPane = $('.app-pane__content')
11
+ $nav = $element
12
+ $topLevelItems = $nav.find('> ul > li')
21
13
 
22
14
  // Attach collapsible heading functionality,on mobile and desktop
23
- collapsibleHeadings();
24
- openActiveHeading();
25
- $contentPane.on('scroll', _.debounce(openActiveHeading, 100, { maxWait: 100 }));
26
-
27
- };
15
+ collapsibleHeadings()
16
+ openActiveHeading()
17
+ $contentPane.on('scroll', _.debounce(openActiveHeading, 100, { maxWait: 100 }))
18
+ }
28
19
 
29
- function collapsibleHeadings() {
20
+ function collapsibleHeadings () {
30
21
  for (var i = $topLevelItems.length - 1; i >= 0; i--) {
31
- var $topLevelItem = $($topLevelItems[i]);
32
- var $heading = $topLevelItem.find('> a');
33
- var $listing = $topLevelItem.find('> ul');
34
- var id = 'toc-' + $heading.text().toLowerCase().replace(' ', '-');
22
+ var $topLevelItem = $($topLevelItems[i])
23
+ var $heading = $topLevelItem.find('> a')
24
+ var $listing = $topLevelItem.find('> ul')
25
+ var id = 'toc-' + $heading.text().toLowerCase().replace(' ', '-')
35
26
  // Only add collapsible functionality if there are children.
36
- if ($listing.length == 0) {
37
- continue;
27
+ if ($listing.length === 0) {
28
+ continue
38
29
  }
39
- $topLevelItem.addClass('collapsible');
30
+ $topLevelItem.addClass('collapsible')
40
31
  $listing.addClass('collapsible__body')
41
- .attr('id', id)
42
- .attr('aria-expanded', 'false');
32
+ .attr('id', id)
33
+ .attr('aria-expanded', 'false')
43
34
  $heading.addClass('collapsible__heading')
44
- .after('<button class="collapsible__toggle" aria-controls="' + id +'"><span class="collapsible__toggle-label">Expand ' + $heading.text() + '</span><span class="collapsible__toggle-icon" aria-hidden="true"></button>')
45
- $topLevelItem.on('click', '.collapsible__toggle', function(e) {
46
- e.preventDefault();
47
- var $parent = $(this).parent();
48
- toggleHeading($parent);
49
- });
35
+ .after('<button class="collapsible__toggle" aria-controls="' + id + '"><span class="collapsible__toggle-label">Expand ' + $heading.text() + '</span><span class="collapsible__toggle-icon" aria-hidden="true"></button>')
36
+ $topLevelItem.on('click', '.collapsible__toggle', function (e) {
37
+ e.preventDefault()
38
+ var $parent = $(this).parent()
39
+ toggleHeading($parent)
40
+ })
50
41
  }
51
42
  }
52
43
 
53
- function toggleHeading($topLevelItem) {
54
- var isOpen = $topLevelItem.hasClass('is-open');
55
- var $heading = $topLevelItem.find('> a');
56
- var $body = $topLevelItem.find('.collapsible__body');
57
- var $toggleLabel = $topLevelItem.find('.collapsible__toggle-label');
44
+ function toggleHeading ($topLevelItem) {
45
+ var isOpen = $topLevelItem.hasClass('is-open')
46
+ var $heading = $topLevelItem.find('> a')
47
+ var $body = $topLevelItem.find('.collapsible__body')
48
+ var $toggleLabel = $topLevelItem.find('.collapsible__toggle-label')
58
49
 
59
- $topLevelItem.toggleClass('is-open', !isOpen);
60
- $body.attr('aria-expanded', isOpen ? 'false' : 'true');
61
- $toggleLabel.text(isOpen ? 'Expand ' + $heading.text() : 'Collapse ' + $heading.text());
50
+ $topLevelItem.toggleClass('is-open', !isOpen)
51
+ $body.attr('aria-expanded', isOpen ? 'false' : 'true')
52
+ $toggleLabel.text(isOpen ? 'Expand ' + $heading.text() : 'Collapse ' + $heading.text())
62
53
  }
63
54
 
64
- function openActiveHeading() {
65
- var $activeElement;
66
- var currentPath = window.location.pathname;
67
- var isActiveTrail = '[href*="' + currentPath + '"]';
55
+ function openActiveHeading () {
56
+ var $activeElement
57
+ var currentPath = window.location.pathname
58
+ var isActiveTrail = '[href*="' + currentPath + '"]'
68
59
  // Add an exception for the root page, as every href includes /
69
- if(currentPath == '/') {
60
+ if (currentPath === '/') {
70
61
  isActiveTrail = '[href="' + currentPath + window.location.hash + '"]'
71
62
  }
72
63
  for (var i = $topLevelItems.length - 1; i >= 0; i--) {
73
- var $element = $($topLevelItems[i]);
74
- var $heading = $element.find('> a');
64
+ var $element = $($topLevelItems[i])
65
+ var $heading = $element.find('> a')
75
66
  // Check if this item href matches
76
- if($heading.is(isActiveTrail)) {
77
- $activeElement = $element;
78
- break;
67
+ if ($heading.is(isActiveTrail)) {
68
+ $activeElement = $element
69
+ break
79
70
  }
80
71
  // Otherwise check the children
81
- var $children = $element.find('li > a');
82
- var $matchingChildren = $children.filter(isActiveTrail);
72
+ var $children = $element.find('li > a')
73
+ var $matchingChildren = $children.filter(isActiveTrail)
83
74
  if ($matchingChildren.length) {
84
- $activeElement = $element;
85
- break;
75
+ $activeElement = $element
76
+ break
86
77
  }
87
78
  }
88
- if($activeElement && !$activeElement.hasClass('is-open')) {
89
- toggleHeading($activeElement);
79
+ if ($activeElement && !$activeElement.hasClass('is-open')) {
80
+ toggleHeading($activeElement)
90
81
  }
91
82
  }
92
-
93
-
94
- };
95
- })(jQuery, window.GOVUK.Modules);
83
+ }
84
+ })(jQuery, window.GOVUK.Modules)
@@ -1,132 +1,132 @@
1
- (function($, Modules) {
2
- 'use strict';
1
+ (function ($, Modules) {
2
+ 'use strict'
3
3
 
4
- Modules.InPageNavigation = function InPageNavigation() {
5
- var $tocPane;
6
- var $contentPane;
7
- var $tocItems;
8
- var $targets;
4
+ Modules.InPageNavigation = function InPageNavigation () {
5
+ var $tocPane
6
+ var $contentPane
7
+ var $tocItems
8
+ var $targets
9
9
 
10
- this.start = function start($element) {
11
- $tocPane = $element.find('.app-pane__toc');
12
- $contentPane = $element.find('.app-pane__content');
13
- $tocItems = $('.js-toc-list').find('a');
14
- $targets = $contentPane.find('[id]');
10
+ this.start = function start ($element) {
11
+ $tocPane = $element.find('.app-pane__toc')
12
+ $contentPane = $element.find('.app-pane__content')
13
+ $tocItems = $('.js-toc-list').find('a')
14
+ $targets = $contentPane.find('[id]')
15
15
 
16
- $contentPane.on('scroll', _.debounce(handleScrollEvent, 100, { maxWait: 100 }));
16
+ $contentPane.on('scroll', _.debounce(handleScrollEvent, 100, { maxWait: 100 }))
17
17
 
18
18
  if (Modernizr.history) {
19
19
  // Popstate is triggered when using the back button to navigate 'within'
20
20
  // the page, i.e. changing the anchor part of the URL.
21
21
  $(window).on('popstate', function (event) {
22
- restoreScrollPosition(event.originalEvent.state);
23
- });
22
+ restoreScrollPosition(event.originalEvent.state)
23
+ })
24
24
 
25
25
  if (history.state && history.state.scrollTop) {
26
26
  // Restore existing state when e.g. using the back button to return to
27
27
  // this page
28
- restoreScrollPosition(history.state);
28
+ restoreScrollPosition(history.state)
29
29
  } else {
30
30
  // Store the initial position so that we can restore it even if we
31
31
  // never scroll.
32
- handleInitialLoadEvent();
32
+ handleInitialLoadEvent()
33
33
  }
34
34
  }
35
- };
35
+ }
36
36
 
37
- function restoreScrollPosition(state) {
37
+ function restoreScrollPosition (state) {
38
38
  if (state && typeof state.scrollTop !== 'undefined') {
39
- $contentPane.scrollTop(state.scrollTop);
39
+ $contentPane.scrollTop(state.scrollTop)
40
40
  }
41
41
  }
42
42
 
43
- function handleInitialLoadEvent() {
44
- var fragment = fragmentForTargetElement();
43
+ function handleInitialLoadEvent () {
44
+ var fragment = fragmentForTargetElement()
45
45
 
46
46
  if (!fragment) {
47
- fragment = fragmentForFirstElementInView();
47
+ fragment = fragmentForFirstElementInView()
48
48
  }
49
49
 
50
- handleChangeInActiveItem(fragment);
50
+ handleChangeInActiveItem(fragment)
51
51
  }
52
52
 
53
- function handleScrollEvent() {
54
- handleChangeInActiveItem(fragmentForFirstElementInView());
53
+ function handleScrollEvent () {
54
+ handleChangeInActiveItem(fragmentForFirstElementInView())
55
55
  }
56
56
 
57
- function handleChangeInActiveItem(fragment) {
58
- storeCurrentPositionInHistoryApi(fragment);
59
- highlightActiveItemInToc(fragment);
57
+ function handleChangeInActiveItem (fragment) {
58
+ storeCurrentPositionInHistoryApi(fragment)
59
+ highlightActiveItemInToc(fragment)
60
60
  }
61
61
 
62
- function storeCurrentPositionInHistoryApi(fragment) {
62
+ function storeCurrentPositionInHistoryApi (fragment) {
63
63
  if (Modernizr.history && fragment) {
64
64
  history.replaceState(
65
65
  { scrollTop: $contentPane.scrollTop() },
66
- "",
66
+ '',
67
67
  fragment
68
- );
68
+ )
69
69
  }
70
70
  }
71
71
 
72
- function highlightActiveItemInToc(fragment) {
72
+ function highlightActiveItemInToc (fragment) {
73
73
  // Navigation items for single page navigation don't necessarily include the path name, but
74
74
  // navigation items for multipage navigation items do include it. This checks for either case.
75
75
  var $activeTocItem = $tocItems.filter(
76
76
  '[href="' + window.location.pathname + fragment + '"],[href="' + fragment + '"]'
77
- );
77
+ )
78
78
  // Navigation items with children don't contain fragments in their url
79
79
  // Check to see if any nav items contain just the path name.
80
- if(!$activeTocItem.get(0)) {
81
- $activeTocItem = $tocItems.filter('[href="' + window.location.pathname + '"]');
80
+ if (!$activeTocItem.get(0)) {
81
+ $activeTocItem = $tocItems.filter('[href="' + window.location.pathname + '"]')
82
82
  }
83
83
  if ($activeTocItem.get(0)) {
84
- $tocItems.removeClass('toc-link--in-view');
85
- $activeTocItem.addClass('toc-link--in-view');
86
- scrollTocToActiveItem($activeTocItem);
84
+ $tocItems.removeClass('toc-link--in-view')
85
+ $activeTocItem.addClass('toc-link--in-view')
86
+ scrollTocToActiveItem($activeTocItem)
87
87
  }
88
88
  }
89
89
 
90
- function scrollTocToActiveItem($activeTocItem) {
91
- var paneHeight = $tocPane.height();
92
- var linkTop = $activeTocItem.position().top;
93
- var linkBottom = linkTop + $activeTocItem.outerHeight();
90
+ function scrollTocToActiveItem ($activeTocItem) {
91
+ var paneHeight = $tocPane.height()
92
+ var linkTop = $activeTocItem.position().top
93
+ var linkBottom = linkTop + $activeTocItem.outerHeight()
94
94
 
95
- var offset = null;
95
+ var offset = null
96
96
 
97
97
  if (linkTop < 0) {
98
- offset = linkTop;
98
+ offset = linkTop
99
99
  } else if (linkBottom >= paneHeight) {
100
- offset = -(paneHeight - linkBottom);
100
+ offset = -(paneHeight - linkBottom)
101
101
  } else {
102
- return;
102
+ return
103
103
  }
104
104
 
105
- var newScrollTop = $tocPane.scrollTop() + offset;
105
+ var newScrollTop = $tocPane.scrollTop() + offset
106
106
 
107
- $tocPane.scrollTop(newScrollTop);
107
+ $tocPane.scrollTop(newScrollTop)
108
108
  }
109
109
 
110
- function fragmentForTargetElement() {
111
- return window.location.hash;
110
+ function fragmentForTargetElement () {
111
+ return window.location.hash
112
112
  }
113
113
 
114
- function fragmentForFirstElementInView() {
115
- var result = null;
114
+ function fragmentForFirstElementInView () {
115
+ var result = null
116
116
 
117
- $($targets.get().reverse()).each(function checkIfInView(index) {
117
+ $($targets.get().reverse()).each(function checkIfInView (index) {
118
118
  if (result) {
119
- return;
119
+ return
120
120
  }
121
121
 
122
- var $this = $(this);
122
+ var $this = $(this)
123
123
 
124
124
  if (Math.floor($this.position().top) <= 0) {
125
- result = $this;
125
+ result = $this
126
126
  }
127
- });
127
+ })
128
128
 
129
- return result ? '#' + result.attr('id') : false;
129
+ return result ? '#' + result.attr('id') : false
130
130
  }
131
- };
132
- })(jQuery, window.GOVUK.Modules);
131
+ }
132
+ })(jQuery, window.GOVUK.Modules)