govuk_publishing_components 21.11.0 → 21.12.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2bbeb70eb7086f9fabacb9857824a4a7ba8f11903ff484b2e7556792b593a612
4
- data.tar.gz: 0cf68605b66f55385c67d90dee67e1cf193ceff4def3c4caa260273f73f93a0a
3
+ metadata.gz: 60ff27fe702ec5247205b706912d3df2b971f15c3ccda7ec96222b2929a028e5
4
+ data.tar.gz: 68485d1017605434db50a0c0488ff8eaa80d867a9509e4ce3b234c24d894a1bf
5
5
  SHA512:
6
- metadata.gz: 12de494131da57503893d764422bc097f0cd5a082bccd35e1e48f8fb234feb48a242dae5ffce964422f5c3577dcbcf89d1567b58b8fd2d2ad21d41afa08973ac
7
- data.tar.gz: 7fdf11ebf8e5c7bb9e1aae2b4a7f93f8453dfbd0c26053de2673b3b72e11677ae708ef937b7981f66668e6df05f87bb5d3e5b1077dddca675e857abbc68b9b4e
6
+ metadata.gz: 83b69b499d668533e01f55ffcf0c524f0de904bea20c3c1fe669aa484a8ad028548c27b874e44655c636fc43c1e5c807ee8a819ab01697644fbdeae3aeca2679
7
+ data.tar.gz: f75e729bf18d87c846e13d2bb9048cd1822dab68838228a9b500d5a57185d99acd71106612c5655a4deaf6c2c384d7fd400c5e121f761a8ad2eba394ae5b6dd1
@@ -0,0 +1,58 @@
1
+ // migrated from govuk_frontend_toolkit
2
+ ;(function (global) {
3
+ 'use strict'
4
+
5
+ var $ = global.jQuery
6
+ var GOVUK = global.GOVUK || {}
7
+
8
+ // Only show the first {n} items in a list, documentation is in the README.md
9
+ var PrimaryList = function (el, selector) {
10
+ this.$el = $(el)
11
+ this.$extraLinks = this.$el.find('li:not(' + selector + ')')
12
+ // only hide more than one extra link
13
+ if (this.$extraLinks.length > 1) {
14
+ this.addToggleLink()
15
+ this.hideExtraLinks()
16
+ }
17
+ }
18
+
19
+ PrimaryList.prototype = {
20
+ toggleText: function () {
21
+ if (this.$extraLinks.length > 1) {
22
+ return '+' + this.$extraLinks.length + ' others'
23
+ } else {
24
+ return '+' + this.$extraLinks.length + ' other'
25
+ }
26
+ },
27
+ addToggleLink: function () {
28
+ this.$toggleLink = $('<a href="#">' + this.toggleText() + '</a>')
29
+ this.$toggleLink.click($.proxy(this.toggleLinks, this))
30
+ this.$toggleLink.insertAfter(this.$el)
31
+ },
32
+ toggleLinks: function (e) {
33
+ e.preventDefault()
34
+ this.$toggleLink.remove()
35
+ this.showExtraLinks()
36
+ },
37
+ hideExtraLinks: function () {
38
+ this.$extraLinks.addClass('visuallyhidden')
39
+ $(window).trigger('govuk.pageSizeChanged')
40
+ },
41
+ showExtraLinks: function () {
42
+ this.$extraLinks.removeClass('visuallyhidden')
43
+ $(window).trigger('govuk.pageSizeChanged')
44
+ }
45
+ }
46
+
47
+ GOVUK.PrimaryList = PrimaryList
48
+
49
+ GOVUK.primaryLinks = {
50
+ init: function (selector) {
51
+ $(selector).parent().each(function (i, el) {
52
+ new GOVUK.PrimaryList(el, selector) // eslint-disable-line no-new
53
+ })
54
+ }
55
+ }
56
+
57
+ global.GOVUK = GOVUK
58
+ })(window)
@@ -1,3 +1,3 @@
1
1
  module GovukPublishingComponents
2
- VERSION = '21.11.0'.freeze
2
+ VERSION = '21.12.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: govuk_publishing_components
3
3
  version: !ruby/object:Gem::Version
4
- version: 21.11.0
4
+ version: 21.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - GOV.UK Dev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-11-15 00:00:00.000000000 Z
11
+ date: 2019-11-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gds-api-adapters
@@ -419,6 +419,7 @@ files:
419
419
  - app/assets/javascripts/govuk_publishing_components/lib/govspeak/barchart-enhancement.js
420
420
  - app/assets/javascripts/govuk_publishing_components/lib/govspeak/youtube-link-enhancement.js
421
421
  - app/assets/javascripts/govuk_publishing_components/lib/header-navigation.js
422
+ - app/assets/javascripts/govuk_publishing_components/lib/primary-links.js
422
423
  - app/assets/javascripts/govuk_publishing_components/lib/select.js
423
424
  - app/assets/javascripts/govuk_publishing_components/lib/toggle-input-class-on-focus.js
424
425
  - app/assets/javascripts/govuk_publishing_components/lib/toggle.js