idsk_frontend_toolkit 7.4.2
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 +7 -0
- data/.gitignore +3 -0
- data/.gitmodules +3 -0
- data/.ruby-version +1 -0
- data/.travis/govuk_frontend_toolkit_gem_push.enc +0 -0
- data/.travis/govuk_frontend_toolkit_gem_push.pub +1 -0
- data/.travis.yml +23 -0
- data/CONTRIBUTING.md +13 -0
- data/Gemfile +3 -0
- data/LICENCE +20 -0
- data/README.md +61 -0
- data/Rakefile +10 -0
- data/app/assets/.gitignore +5 -0
- data/app/assets/.ruby-version +1 -0
- data/app/assets/.travis/README.md +23 -0
- data/app/assets/.travis/govuk_frontend_toolkit_push.enc +0 -0
- data/app/assets/.travis/govuk_frontend_toolkit_push.pub +1 -0
- data/app/assets/.travis.yml +18 -0
- data/app/assets/CHANGELOG.md +381 -0
- data/app/assets/CONTRIBUTING.md +23 -0
- data/app/assets/Gemfile +4 -0
- data/app/assets/Gemfile.lock +48 -0
- data/app/assets/Gruntfile.js +68 -0
- data/app/assets/LICENCE +20 -0
- data/app/assets/README.md +170 -0
- data/app/assets/VERSION.txt +1 -0
- data/app/assets/create-release.sh +38 -0
- data/app/assets/docs/analytics.md +270 -0
- data/app/assets/docs/functions.md +62 -0
- data/app/assets/docs/javascript.md +337 -0
- data/app/assets/docs/mixins.md +617 -0
- data/app/assets/images/accordion-arrow-2x.png +0 -0
- data/app/assets/images/accordion-arrow.png +0 -0
- data/app/assets/images/arrow-sprite.png +0 -0
- data/app/assets/images/crests/bis_crest_13px.png +0 -0
- data/app/assets/images/crests/bis_crest_13px_x2.png +0 -0
- data/app/assets/images/crests/bis_crest_18px.png +0 -0
- data/app/assets/images/crests/bis_crest_18px_x2.png +0 -0
- data/app/assets/images/crests/bis_crest_27px.png +0 -0
- data/app/assets/images/crests/bis_crest_27px_x2.png +0 -0
- data/app/assets/images/crests/coastguard_13px.png +0 -0
- data/app/assets/images/crests/coastguard_13px_x2.png +0 -0
- data/app/assets/images/crests/coastguard_18px.png +0 -0
- data/app/assets/images/crests/coastguard_18px_x2.png +0 -0
- data/app/assets/images/crests/coastguard_27px.png +0 -0
- data/app/assets/images/crests/coastguard_27px_x2.png +0 -0
- data/app/assets/images/crests/dit_crest_13px.png +0 -0
- data/app/assets/images/crests/dit_crest_13px_x2.png +0 -0
- data/app/assets/images/crests/dit_crest_18px.png +0 -0
- data/app/assets/images/crests/dit_crest_18px_x2.png +0 -0
- data/app/assets/images/crests/dit_crest_27px.png +0 -0
- data/app/assets/images/crests/dit_crest_27px_x2.png +0 -0
- data/app/assets/images/crests/hmrc_crest_13px.png +0 -0
- data/app/assets/images/crests/hmrc_crest_13px_x2.png +0 -0
- data/app/assets/images/crests/hmrc_crest_18px.png +0 -0
- data/app/assets/images/crests/hmrc_crest_18px_x2.png +0 -0
- data/app/assets/images/crests/hmrc_crest_27px.png +0 -0
- data/app/assets/images/crests/hmrc_crest_27px_x2.png +0 -0
- data/app/assets/images/crests/ho_crest_13px.png +0 -0
- data/app/assets/images/crests/ho_crest_13px_x2.png +0 -0
- data/app/assets/images/crests/ho_crest_18px.png +0 -0
- data/app/assets/images/crests/ho_crest_18px_x2.png +0 -0
- data/app/assets/images/crests/ho_crest_27px.png +0 -0
- data/app/assets/images/crests/ho_crest_27px_x2.png +0 -0
- data/app/assets/images/crests/mod_crest_13px.png +0 -0
- data/app/assets/images/crests/mod_crest_13px_x2.png +0 -0
- data/app/assets/images/crests/mod_crest_18px.png +0 -0
- data/app/assets/images/crests/mod_crest_18px_x2.png +0 -0
- data/app/assets/images/crests/mod_crest_27px.png +0 -0
- data/app/assets/images/crests/mod_crest_27px_x2.png +0 -0
- data/app/assets/images/crests/org_crest_13px.png +0 -0
- data/app/assets/images/crests/org_crest_13px_x2.png +0 -0
- data/app/assets/images/crests/org_crest_18px.png +0 -0
- data/app/assets/images/crests/org_crest_18px_x2.png +0 -0
- data/app/assets/images/crests/org_crest_27px.png +0 -0
- data/app/assets/images/crests/org_crest_27px_x2.png +0 -0
- data/app/assets/images/crests/portcullis_13px.png +0 -0
- data/app/assets/images/crests/portcullis_13px_x2.png +0 -0
- data/app/assets/images/crests/portcullis_18px.png +0 -0
- data/app/assets/images/crests/portcullis_18px_x2.png +0 -0
- data/app/assets/images/crests/portcullis_27px.png +0 -0
- data/app/assets/images/crests/portcullis_27px_x2.png +0 -0
- data/app/assets/images/crests/so_crest_13px.png +0 -0
- data/app/assets/images/crests/so_crest_13px_x2.png +0 -0
- data/app/assets/images/crests/so_crest_18px.png +0 -0
- data/app/assets/images/crests/so_crest_18px_x2.png +0 -0
- data/app/assets/images/crests/so_crest_27px.png +0 -0
- data/app/assets/images/crests/so_crest_27px_x2.png +0 -0
- data/app/assets/images/crests/ukaea_crest_13px.png +0 -0
- data/app/assets/images/crests/ukaea_crest_13px_x2.png +0 -0
- data/app/assets/images/crests/ukaea_crest_18px.png +0 -0
- data/app/assets/images/crests/ukaea_crest_18px_x2.png +0 -0
- data/app/assets/images/crests/ukaea_crest_27px.png +0 -0
- data/app/assets/images/crests/ukaea_crest_27px_x2.png +0 -0
- data/app/assets/images/crests/ukho_13px.png +0 -0
- data/app/assets/images/crests/ukho_13px_x2.png +0 -0
- data/app/assets/images/crests/ukho_18px.png +0 -0
- data/app/assets/images/crests/ukho_18px_x2.png +0 -0
- data/app/assets/images/crests/ukho_27px.png +0 -0
- data/app/assets/images/crests/ukho_27px_x2.png +0 -0
- data/app/assets/images/crests/wales_crest_13px.png +0 -0
- data/app/assets/images/crests/wales_crest_13px_x2.png +0 -0
- data/app/assets/images/crests/wales_crest_18px.png +0 -0
- data/app/assets/images/crests/wales_crest_18px_x2.png +0 -0
- data/app/assets/images/crests/wales_crest_27px.png +0 -0
- data/app/assets/images/crests/wales_crest_27px_x2.png +0 -0
- data/app/assets/images/icon-arrow-left.png +0 -0
- data/app/assets/images/icon-calendar-2x.png +0 -0
- data/app/assets/images/icon-calendar.png +0 -0
- data/app/assets/images/icon-file-download-2x.png +0 -0
- data/app/assets/images/icon-file-download.png +0 -0
- data/app/assets/images/icon-important-2x.png +0 -0
- data/app/assets/images/icon-important.png +0 -0
- data/app/assets/images/icon-information-2x.png +0 -0
- data/app/assets/images/icon-information.png +0 -0
- data/app/assets/images/icon-locator-2x.png +0 -0
- data/app/assets/images/icon-locator.png +0 -0
- data/app/assets/images/icon-pointer-2x.png +0 -0
- data/app/assets/images/icon-pointer-black-2x.png +0 -0
- data/app/assets/images/icon-pointer-black.png +0 -0
- data/app/assets/images/icon-pointer-indexed.png +0 -0
- data/app/assets/images/icon-pointer.png +0 -0
- data/app/assets/images/icon-search-2x.png +0 -0
- data/app/assets/images/icon-search.png +0 -0
- data/app/assets/images/icon-steps/icon-step-1-2x.png +0 -0
- data/app/assets/images/icon-steps/icon-step-1.png +0 -0
- data/app/assets/images/icon-steps/icon-step-10-2x.png +0 -0
- data/app/assets/images/icon-steps/icon-step-10.png +0 -0
- data/app/assets/images/icon-steps/icon-step-11-2x.png +0 -0
- data/app/assets/images/icon-steps/icon-step-11.png +0 -0
- data/app/assets/images/icon-steps/icon-step-12-2x.png +0 -0
- data/app/assets/images/icon-steps/icon-step-12.png +0 -0
- data/app/assets/images/icon-steps/icon-step-13-2x.png +0 -0
- data/app/assets/images/icon-steps/icon-step-13.png +0 -0
- data/app/assets/images/icon-steps/icon-step-14-2x.png +0 -0
- data/app/assets/images/icon-steps/icon-step-14.png +0 -0
- data/app/assets/images/icon-steps/icon-step-2-2x.png +0 -0
- data/app/assets/images/icon-steps/icon-step-2.png +0 -0
- data/app/assets/images/icon-steps/icon-step-3-2x.png +0 -0
- data/app/assets/images/icon-steps/icon-step-3.png +0 -0
- data/app/assets/images/icon-steps/icon-step-4-2x.png +0 -0
- data/app/assets/images/icon-steps/icon-step-4.png +0 -0
- data/app/assets/images/icon-steps/icon-step-5-2x.png +0 -0
- data/app/assets/images/icon-steps/icon-step-5.png +0 -0
- data/app/assets/images/icon-steps/icon-step-6-2x.png +0 -0
- data/app/assets/images/icon-steps/icon-step-6.png +0 -0
- data/app/assets/images/icon-steps/icon-step-7-2x.png +0 -0
- data/app/assets/images/icon-steps/icon-step-7.png +0 -0
- data/app/assets/images/icon-steps/icon-step-8-2x.png +0 -0
- data/app/assets/images/icon-steps/icon-step-8.png +0 -0
- data/app/assets/images/icon-steps/icon-step-9-2x.png +0 -0
- data/app/assets/images/icon-steps/icon-step-9.png +0 -0
- data/app/assets/images/player-icon-forward.png +0 -0
- data/app/assets/images/player-icon-pause.png +0 -0
- data/app/assets/images/player-icon-play.png +0 -0
- data/app/assets/images/player-icon-rewind.png +0 -0
- data/app/assets/images/player-icon-volume.png +0 -0
- data/app/assets/images/separator-2x.png +0 -0
- data/app/assets/images/separator.png +0 -0
- data/app/assets/javascripts/govuk/analytics/analytics.js +143 -0
- data/app/assets/javascripts/govuk/analytics/download-link-tracker.js +41 -0
- data/app/assets/javascripts/govuk/analytics/error-tracking.js +51 -0
- data/app/assets/javascripts/govuk/analytics/external-link-tracker.js +56 -0
- data/app/assets/javascripts/govuk/analytics/google-analytics-universal-tracker.js +166 -0
- data/app/assets/javascripts/govuk/analytics/govuk-tracker.js +134 -0
- data/app/assets/javascripts/govuk/analytics/mailto-link-tracker.js +38 -0
- data/app/assets/javascripts/govuk/analytics/print-intent.js +39 -0
- data/app/assets/javascripts/govuk/details.polyfill.js +240 -0
- data/app/assets/javascripts/govuk/modules/auto-track-event.js +30 -0
- data/app/assets/javascripts/govuk/modules.js +61 -0
- data/app/assets/javascripts/govuk/primary-links.js +57 -0
- data/app/assets/javascripts/govuk/selection-buttons.js +116 -0
- data/app/assets/javascripts/govuk/shim-links-with-button-role.js +34 -0
- data/app/assets/javascripts/govuk/show-hide-content.js +172 -0
- data/app/assets/javascripts/govuk/stick-at-top-when-scrolling.js +128 -0
- data/app/assets/javascripts/govuk/stop-scrolling-at-footer.js +139 -0
- data/app/assets/javascripts/govuk_toolkit.js +1 -0
- data/app/assets/javascripts/stageprompt.js +69 -0
- data/app/assets/javascripts/vendor/jquery/jquery.player.min.js +25 -0
- data/app/assets/javascripts/vendor/polyfills/bind.js +40 -0
- data/app/assets/package.json +25 -0
- data/app/assets/spec/manifest.js +41 -0
- data/app/assets/spec/stylesheets/_colour_contrast_spec.scss +12 -0
- data/app/assets/spec/support/LocalTestRunner.html +21 -0
- data/app/assets/spec/support/console-runner.js +102 -0
- data/app/assets/spec/support/load.js +47 -0
- data/app/assets/spec/support/run_jasmine_test.js +62 -0
- data/app/assets/spec/unit/analytics/analytics.spec.js +315 -0
- data/app/assets/spec/unit/analytics/download-link-tracker.spec.js +72 -0
- data/app/assets/spec/unit/analytics/error-tracking.spec.js +65 -0
- data/app/assets/spec/unit/analytics/external-link-tracker.spec.js +109 -0
- data/app/assets/spec/unit/analytics/google-analytics-universal-tracker.spec.js +180 -0
- data/app/assets/spec/unit/analytics/govuk-tracker.spec.js +171 -0
- data/app/assets/spec/unit/analytics/mailto-link-tracker.spec.js +62 -0
- data/app/assets/spec/unit/details.polyfill.spec.js +91 -0
- data/app/assets/spec/unit/modules/auto-track-event.spec.js +54 -0
- data/app/assets/spec/unit/modules.spec.js +93 -0
- data/app/assets/spec/unit/primary-links.spec.js +55 -0
- data/app/assets/spec/unit/selection-button.spec.js +761 -0
- data/app/assets/spec/unit/shim-links-with-button-role.spec.js +41 -0
- data/app/assets/spec/unit/show-hide-content.spec.js +306 -0
- data/app/assets/spec/unit/stick-at-top-when-scrolling.spec.js +137 -0
- data/app/assets/stylesheets/.gitkeep +0 -0
- data/app/assets/stylesheets/_colours.scss +2 -0
- data/app/assets/stylesheets/_conditionals.scss +81 -0
- data/app/assets/stylesheets/_css3.scss +90 -0
- data/app/assets/stylesheets/_device-pixels.scss +10 -0
- data/app/assets/stylesheets/_font_stack.scss +25 -0
- data/app/assets/stylesheets/_grid_layout.scss +136 -0
- data/app/assets/stylesheets/_helpers.scss +16 -0
- data/app/assets/stylesheets/_measurements.scss +14 -0
- data/app/assets/stylesheets/_shims.scss +55 -0
- data/app/assets/stylesheets/_typography.scss +249 -0
- data/app/assets/stylesheets/_url-helpers.scss +16 -0
- data/app/assets/stylesheets/colours/_organisation.scss +104 -0
- data/app/assets/stylesheets/colours/_palette.scss +77 -0
- data/app/assets/stylesheets/design-patterns/_alpha-beta.scss +67 -0
- data/app/assets/stylesheets/design-patterns/_breadcrumbs.scss +53 -0
- data/app/assets/stylesheets/design-patterns/_buttons.scss +145 -0
- data/app/assets/stylesheets/design-patterns/_media-player.scss +264 -0
- data/app/assets/trigger.sh +24 -0
- data/idsk_frontend_toolkit.gemspec +49 -0
- data/lib/idsk_frontend_toolkit/engine.rb +4 -0
- data/lib/idsk_frontend_toolkit/version.rb +5 -0
- data/lib/idsk_frontend_toolkit.rb +4 -0
- data/publish.sh +30 -0
- metadata +314 -0
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
;(function (global) {
|
|
2
|
+
'use strict'
|
|
3
|
+
|
|
4
|
+
var GOVUK = global.GOVUK || {}
|
|
5
|
+
var EMAIL_PATTERN = /[^\s=/?&]+(?:@|%40)[^\s=/?&]+/g
|
|
6
|
+
var POSTCODE_PATTERN = /[A-PR-UWYZ][A-HJ-Z]?[0-9][0-9A-HJKMNPR-Y]?(?:[\s+]|%20)*[0-9][ABD-HJLNPQ-Z]{2}/gi
|
|
7
|
+
|
|
8
|
+
// For usage and initialisation see:
|
|
9
|
+
// https://github.com/alphagov/govuk_frontend_toolkit/blob/master/docs/analytics.md#create-an-analytics-tracker
|
|
10
|
+
|
|
11
|
+
var Analytics = function (config) {
|
|
12
|
+
this.stripPostcodePII = false
|
|
13
|
+
if (typeof config.stripPostcodePII !== 'undefined') {
|
|
14
|
+
this.stripPostcodePII = (config.stripPostcodePII === true)
|
|
15
|
+
// remove the option so we don't pass it to other trackers - it's not
|
|
16
|
+
// their concern
|
|
17
|
+
delete config.stripPostcodePII
|
|
18
|
+
}
|
|
19
|
+
this.trackers = []
|
|
20
|
+
if (typeof config.universalId !== 'undefined') {
|
|
21
|
+
var universalId = config.universalId
|
|
22
|
+
delete config.universalId
|
|
23
|
+
this.trackers.push(new GOVUK.GoogleAnalyticsUniversalTracker(universalId, config))
|
|
24
|
+
}
|
|
25
|
+
if (typeof config.govukTrackerUrl !== 'undefined') {
|
|
26
|
+
var govukTrackerUrl = config.govukTrackerUrl
|
|
27
|
+
delete config.govukTrackerUrl
|
|
28
|
+
this.trackers.push(new GOVUK.GOVUKTracker(govukTrackerUrl))
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
var PIISafe = function (value) {
|
|
33
|
+
this.value = value
|
|
34
|
+
}
|
|
35
|
+
Analytics.PIISafe = PIISafe
|
|
36
|
+
|
|
37
|
+
Analytics.prototype.stripPII = function (value) {
|
|
38
|
+
if (typeof value === 'string') {
|
|
39
|
+
return this.stripPIIFromString(value)
|
|
40
|
+
} else if (Object.prototype.toString.call(value) === '[object Array]' || Object.prototype.toString.call(value) === '[object Arguments]') {
|
|
41
|
+
return this.stripPIIFromArray(value)
|
|
42
|
+
} else if (typeof value === 'object') {
|
|
43
|
+
return this.stripPIIFromObject(value)
|
|
44
|
+
} else {
|
|
45
|
+
return value
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
Analytics.prototype.stripPIIFromString = function (string) {
|
|
50
|
+
var emailStripped = string.replace(EMAIL_PATTERN, '[email]')
|
|
51
|
+
if (this.stripPostcodePII === true) {
|
|
52
|
+
return emailStripped.replace(POSTCODE_PATTERN, '[postcode]')
|
|
53
|
+
} else {
|
|
54
|
+
return emailStripped
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
Analytics.prototype.stripPIIFromObject = function (object) {
|
|
59
|
+
if (object instanceof Analytics.PIISafe) {
|
|
60
|
+
return object.value
|
|
61
|
+
} else {
|
|
62
|
+
for (var property in object) {
|
|
63
|
+
var value = object[property]
|
|
64
|
+
|
|
65
|
+
object[property] = this.stripPII(value)
|
|
66
|
+
}
|
|
67
|
+
return object
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
Analytics.prototype.stripPIIFromArray = function (array) {
|
|
72
|
+
for (var i = 0, l = array.length; i < l; i++) {
|
|
73
|
+
var elem = array[i]
|
|
74
|
+
|
|
75
|
+
array[i] = this.stripPII(elem)
|
|
76
|
+
}
|
|
77
|
+
return array
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
Analytics.prototype.sendToTrackers = function (method, args) {
|
|
81
|
+
for (var i = 0, l = this.trackers.length; i < l; i++) {
|
|
82
|
+
var tracker = this.trackers[i]
|
|
83
|
+
var fn = tracker[method]
|
|
84
|
+
|
|
85
|
+
if (typeof fn === 'function') {
|
|
86
|
+
fn.apply(tracker, args)
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
Analytics.load = function () {
|
|
92
|
+
GOVUK.GoogleAnalyticsUniversalTracker.load()
|
|
93
|
+
GOVUK.GOVUKTracker.load()
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
Analytics.prototype.defaultPathForTrackPageview = function (location) {
|
|
97
|
+
// Get the page path including querystring, but ignoring the anchor
|
|
98
|
+
// as per default behaviour of GA (see: https://developers.google.com/analytics/devguides/collection/analyticsjs/pages#overview)
|
|
99
|
+
// we ignore the possibility of there being campaign variables in the
|
|
100
|
+
// anchor because we wouldn't know how to detect and parse them if they
|
|
101
|
+
// were present
|
|
102
|
+
return this.stripPIIFromString(location.href.substring(location.origin.length).split('#')[0])
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
Analytics.prototype.trackPageview = function (path, title, options) {
|
|
106
|
+
arguments[0] = arguments[0] || this.defaultPathForTrackPageview(window.location)
|
|
107
|
+
if (arguments.length === 0) { arguments.length = 1 }
|
|
108
|
+
this.sendToTrackers('trackPageview', this.stripPII(arguments))
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/*
|
|
112
|
+
https://developers.google.com/analytics/devguides/collection/analyticsjs/events
|
|
113
|
+
options.label – Useful for categorizing events (eg nav buttons)
|
|
114
|
+
options.value – Values must be non-negative. Useful to pass counts
|
|
115
|
+
options.nonInteraction – Prevent event from impacting bounce rate
|
|
116
|
+
*/
|
|
117
|
+
Analytics.prototype.trackEvent = function (category, action, options) {
|
|
118
|
+
this.sendToTrackers('trackEvent', this.stripPII(arguments))
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
Analytics.prototype.trackShare = function (network, options) {
|
|
122
|
+
this.sendToTrackers('trackSocial', this.stripPII([network, 'share', global.location.pathname, options]))
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/*
|
|
126
|
+
The custom dimension index must be configured within the
|
|
127
|
+
Universal Analytics profile
|
|
128
|
+
*/
|
|
129
|
+
Analytics.prototype.setDimension = function (index, value) {
|
|
130
|
+
this.sendToTrackers('setDimension', this.stripPII(arguments))
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/*
|
|
134
|
+
Add a beacon to track a page in another GA account on another domain.
|
|
135
|
+
*/
|
|
136
|
+
Analytics.prototype.addLinkedTrackerDomain = function (trackerId, name, domain) {
|
|
137
|
+
this.sendToTrackers('addLinkedTrackerDomain', arguments)
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
GOVUK.Analytics = Analytics
|
|
141
|
+
|
|
142
|
+
global.GOVUK = GOVUK
|
|
143
|
+
})(window)
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
;(function (global) {
|
|
2
|
+
'use strict'
|
|
3
|
+
|
|
4
|
+
var $ = global.jQuery
|
|
5
|
+
var GOVUK = global.GOVUK || {}
|
|
6
|
+
|
|
7
|
+
GOVUK.analyticsPlugins = GOVUK.analyticsPlugins || {}
|
|
8
|
+
GOVUK.analyticsPlugins.downloadLinkTracker = function (options) {
|
|
9
|
+
options = options || {}
|
|
10
|
+
var downloadLinkSelector = options.selector
|
|
11
|
+
|
|
12
|
+
if (downloadLinkSelector) {
|
|
13
|
+
$('body').on('click', downloadLinkSelector, trackDownload)
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function trackDownload (evt) {
|
|
17
|
+
var $link = getLinkFromEvent(evt)
|
|
18
|
+
var href = $link.attr('href')
|
|
19
|
+
var evtOptions = {transport: 'beacon'}
|
|
20
|
+
var linkText = $.trim($link.text())
|
|
21
|
+
|
|
22
|
+
if (linkText) {
|
|
23
|
+
evtOptions.label = linkText
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
GOVUK.analytics.trackEvent('Download Link Clicked', href, evtOptions)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function getLinkFromEvent (evt) {
|
|
30
|
+
var $target = $(evt.target)
|
|
31
|
+
|
|
32
|
+
if (!$target.is('a')) {
|
|
33
|
+
$target = $target.parents('a')
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return $target
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
global.GOVUK = GOVUK
|
|
41
|
+
})(window)
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
// Extension to track errors using google analytics as a data store.
|
|
2
|
+
;(function (global) {
|
|
3
|
+
'use strict'
|
|
4
|
+
|
|
5
|
+
var GOVUK = global.GOVUK || {}
|
|
6
|
+
|
|
7
|
+
GOVUK.analyticsPlugins = GOVUK.analyticsPlugins || {}
|
|
8
|
+
|
|
9
|
+
GOVUK.analyticsPlugins.error = function (options) {
|
|
10
|
+
options = options || {}
|
|
11
|
+
var filenameMustMatch = options.filenameMustMatch
|
|
12
|
+
|
|
13
|
+
var trackJavaScriptError = function (e) {
|
|
14
|
+
var errorFilename = e.filename
|
|
15
|
+
var errorSource = errorFilename + ': ' + e.lineno
|
|
16
|
+
|
|
17
|
+
if (shouldTrackThisError(errorFilename)) {
|
|
18
|
+
GOVUK.analytics.trackEvent('JavaScript Error', e.message, {
|
|
19
|
+
label: errorSource,
|
|
20
|
+
value: 1,
|
|
21
|
+
nonInteraction: true
|
|
22
|
+
})
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function shouldTrackThisError (errorFilename) {
|
|
27
|
+
// Errors in page should always be tracked
|
|
28
|
+
// If there's no filename filter, everything is tracked
|
|
29
|
+
if (!errorFilename || !filenameMustMatch) {
|
|
30
|
+
return true
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// If there's a filter and the error matches it, track it
|
|
34
|
+
if (filenameMustMatch.test(errorFilename)) {
|
|
35
|
+
return true
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return false
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (global.addEventListener) {
|
|
42
|
+
global.addEventListener('error', trackJavaScriptError, false)
|
|
43
|
+
} else if (global.attachEvent) {
|
|
44
|
+
global.attachEvent('onerror', trackJavaScriptError)
|
|
45
|
+
} else {
|
|
46
|
+
global.onerror = trackJavaScriptError
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
global.GOVUK = GOVUK
|
|
51
|
+
})(window)
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
;(function (global) {
|
|
2
|
+
'use strict'
|
|
3
|
+
|
|
4
|
+
var $ = global.jQuery
|
|
5
|
+
var GOVUK = global.GOVUK || {}
|
|
6
|
+
|
|
7
|
+
GOVUK.analyticsPlugins = GOVUK.analyticsPlugins || {}
|
|
8
|
+
GOVUK.analyticsPlugins.externalLinkTracker = function (options) {
|
|
9
|
+
options = options || {}
|
|
10
|
+
var externalLinkUploadCustomDimension = options.externalLinkUploadCustomDimension
|
|
11
|
+
var currentHost = GOVUK.analyticsPlugins.externalLinkTracker.getHostname()
|
|
12
|
+
var externalLinkSelector = 'a[href^="http"]:not(a[href*="' + currentHost + '"])'
|
|
13
|
+
|
|
14
|
+
$('body').on('click', externalLinkSelector, trackClickEvent)
|
|
15
|
+
|
|
16
|
+
function trackClickEvent (evt) {
|
|
17
|
+
var $link = getLinkFromEvent(evt)
|
|
18
|
+
var options = {transport: 'beacon'}
|
|
19
|
+
var href = $link.attr('href')
|
|
20
|
+
var linkText = $.trim($link.text())
|
|
21
|
+
|
|
22
|
+
if (linkText) {
|
|
23
|
+
options.label = linkText
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if (externalLinkUploadCustomDimension !== undefined) {
|
|
27
|
+
// This custom dimension will be used to duplicate the url information
|
|
28
|
+
// that we normally send in an "event action". This will be used to join
|
|
29
|
+
// up with a scheduled custom upload called "External Link Status".
|
|
30
|
+
// We can only join uploads on custom dimensions, not on `event actions`
|
|
31
|
+
// where we normally add the url info.
|
|
32
|
+
var externalLinkToJoinUploadOn = href
|
|
33
|
+
|
|
34
|
+
GOVUK.analytics.setDimension(externalLinkUploadCustomDimension, externalLinkToJoinUploadOn)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
GOVUK.analytics.trackEvent('External Link Clicked', href, options)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function getLinkFromEvent (evt) {
|
|
41
|
+
var $target = $(evt.target)
|
|
42
|
+
|
|
43
|
+
if (!$target.is('a')) {
|
|
44
|
+
$target = $target.parents('a')
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return $target
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
GOVUK.analyticsPlugins.externalLinkTracker.getHostname = function () {
|
|
52
|
+
return global.location.hostname
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
global.GOVUK = GOVUK
|
|
56
|
+
})(window)
|