govuk_frontend_toolkit 0.41.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +3 -0
- data/.gitmodules +3 -0
- data/CONTRIBUTING.md +13 -0
- data/Gemfile +4 -0
- data/LICENCE +20 -0
- data/README.md +46 -0
- data/Rakefile +16 -0
- data/app/assets/.gitignore +1 -0
- data/app/assets/.travis.yml +3 -0
- data/app/assets/CONTRIBUTING.md +18 -0
- data/app/assets/Gruntfile.js +19 -0
- data/app/assets/LICENCE +20 -0
- data/app/assets/README.md +675 -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/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/external-links/external-link-24x24.png +0 -0
- data/app/assets/images/external-links/external-link-black-12x12.png +0 -0
- data/app/assets/images/external-links/external-link-black-24x24.png +0 -0
- data/app/assets/images/external-links/external-link.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/javascripts/govuk/multivariate-test.js +101 -0
- data/app/assets/javascripts/govuk/stop-scrolling-at-footer.js +138 -0
- data/app/assets/javascripts/govuk_toolkit.js +1 -0
- data/app/assets/javascripts/stageprompt.js +63 -0
- data/app/assets/javascripts/vendor/jquery/jquery.player.min.js +25 -0
- data/app/assets/jenkins.sh +5 -0
- data/app/assets/package.json +14 -0
- data/app/assets/spec/MultivariateTestSpec.js +166 -0
- data/app/assets/stylesheets/.gitkeep +0 -0
- data/app/assets/stylesheets/_colours.scss +104 -0
- data/app/assets/stylesheets/_conditionals.scss +85 -0
- data/app/assets/stylesheets/_css3.scss +61 -0
- data/app/assets/stylesheets/_device-pixels.scss +11 -0
- data/app/assets/stylesheets/_font_stack.scss +40 -0
- data/app/assets/stylesheets/_measurements.scss +7 -0
- data/app/assets/stylesheets/_shims.scss +57 -0
- data/app/assets/stylesheets/_typography.scss +400 -0
- data/app/assets/stylesheets/design-patterns/_alpha-beta.scss +49 -0
- data/app/assets/stylesheets/design-patterns/_buttons.scss +142 -0
- data/app/assets/stylesheets/design-patterns/_media-player.scss +232 -0
- data/govuk_frontend_toolkit.gemspec +50 -0
- data/jenkins.sh +8 -0
- data/lib/govuk_frontend_toolkit.rb +4 -0
- data/lib/govuk_frontend_toolkit/engine.rb +4 -0
- data/lib/govuk_frontend_toolkit/version.rb +3 -0
- metadata +273 -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
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,101 @@
|
|
1
|
+
(function() {
|
2
|
+
"use strict";
|
3
|
+
window.GOVUK = window.GOVUK || {};
|
4
|
+
var $ = window.$;
|
5
|
+
|
6
|
+
// A multivariate test framework
|
7
|
+
//
|
8
|
+
// Based loosely on https://github.com/jamesyu/cohorts
|
9
|
+
//
|
10
|
+
// Full documentation is in README.md.
|
11
|
+
//
|
12
|
+
function MultivariateTest(options) {
|
13
|
+
this.$el = $(options.el);
|
14
|
+
this._loadOption(options, 'name');
|
15
|
+
this._loadOption(options, 'customVarIndex');
|
16
|
+
this._loadOption(options, 'cohorts');
|
17
|
+
this._loadOption(options, 'runImmediately', true);
|
18
|
+
|
19
|
+
if (this.runImmediately) {
|
20
|
+
this.run();
|
21
|
+
}
|
22
|
+
}
|
23
|
+
|
24
|
+
MultivariateTest.prototype._loadOption = function(options, key, defaultValue) {
|
25
|
+
if (options[key] !== undefined) {
|
26
|
+
this[key] = options[key];
|
27
|
+
}
|
28
|
+
if (this[key] === undefined) {
|
29
|
+
if (defaultValue === undefined) {
|
30
|
+
throw new Error(key+" option is required for a multivariate test");
|
31
|
+
}
|
32
|
+
else {
|
33
|
+
this[key] = defaultValue;
|
34
|
+
}
|
35
|
+
}
|
36
|
+
};
|
37
|
+
|
38
|
+
MultivariateTest.prototype.run = function() {
|
39
|
+
var cohort = this.getCohort();
|
40
|
+
if (cohort) {
|
41
|
+
this.setCustomVar(cohort);
|
42
|
+
this.executeCohort(cohort);
|
43
|
+
}
|
44
|
+
};
|
45
|
+
|
46
|
+
MultivariateTest.prototype.executeCohort = function(cohort) {
|
47
|
+
var cohortObj = this.cohorts[cohort];
|
48
|
+
if (cohortObj.callback) {
|
49
|
+
if (typeof cohortObj.callback === "string") {
|
50
|
+
this[cohortObj.callback]();
|
51
|
+
}
|
52
|
+
else {
|
53
|
+
cohortObj.callback();
|
54
|
+
}
|
55
|
+
}
|
56
|
+
if (cohortObj.html) {
|
57
|
+
this.$el.html(cohortObj.html);
|
58
|
+
this.$el.show();
|
59
|
+
}
|
60
|
+
};
|
61
|
+
|
62
|
+
// Get the current cohort or assign one if it has not been already
|
63
|
+
MultivariateTest.prototype.getCohort = function() {
|
64
|
+
var cohort = GOVUK.cookie(this.cookieName());
|
65
|
+
if (!cohort || !this.cohorts[cohort]) {
|
66
|
+
cohort = this.chooseRandomCohort();
|
67
|
+
GOVUK.cookie(this.cookieName(), cohort, {days: 30});
|
68
|
+
}
|
69
|
+
return cohort;
|
70
|
+
};
|
71
|
+
|
72
|
+
MultivariateTest.prototype.setCustomVar = function(cohort) {
|
73
|
+
window._gaq = window._gaq || [];
|
74
|
+
window._gaq.push([
|
75
|
+
'_setCustomVar',
|
76
|
+
this.customVarIndex,
|
77
|
+
this.cookieName(),
|
78
|
+
cohort,
|
79
|
+
2 // session level
|
80
|
+
]);
|
81
|
+
// Fire off a dummy event to set the custom var on the page.
|
82
|
+
// Ideally we'd be able to call setCustomVar before trackPageview,
|
83
|
+
// but would need reordering the existing GA code.
|
84
|
+
window._gaq.push(['_trackEvent', this.cookieName(), 'run', '-', 0, true]);
|
85
|
+
};
|
86
|
+
|
87
|
+
MultivariateTest.prototype.cohortNames = function() {
|
88
|
+
return $.map(this.cohorts, function(v, i) { return i; });
|
89
|
+
};
|
90
|
+
|
91
|
+
MultivariateTest.prototype.chooseRandomCohort = function() {
|
92
|
+
var names = this.cohortNames();
|
93
|
+
return names[Math.floor(Math.random() * names.length)];
|
94
|
+
};
|
95
|
+
|
96
|
+
MultivariateTest.prototype.cookieName = function() {
|
97
|
+
return "multivariatetest_cohort_" + this.name;
|
98
|
+
};
|
99
|
+
|
100
|
+
window.GOVUK.MultivariateTest = MultivariateTest;
|
101
|
+
}());
|
@@ -0,0 +1,138 @@
|
|
1
|
+
// Stop scrolling at footer.
|
2
|
+
//
|
3
|
+
// This can be added to elements with `position: fixed` to stop them from
|
4
|
+
// overflowing on the footer.
|
5
|
+
//
|
6
|
+
// Usage:
|
7
|
+
//
|
8
|
+
// GOVUK.stopScrollingAtFooter.addEl($(node), $(node).height());
|
9
|
+
//
|
10
|
+
// Height is passed in separatly incase the scrolling element has no height
|
11
|
+
// itself.
|
12
|
+
|
13
|
+
|
14
|
+
(function () {
|
15
|
+
"use strict"
|
16
|
+
var root = this,
|
17
|
+
$ = root.jQuery;
|
18
|
+
if(typeof root.GOVUK === 'undefined') { root.GOVUK = {}; }
|
19
|
+
|
20
|
+
var stopScrollingAtFooter = {
|
21
|
+
_pollingId: null,
|
22
|
+
_isPolling: false,
|
23
|
+
_hasScrollEvt: false,
|
24
|
+
_els: [],
|
25
|
+
|
26
|
+
addEl: function($fixedEl, height){
|
27
|
+
var fixedOffset;
|
28
|
+
|
29
|
+
if(!$fixedEl.length) { return; }
|
30
|
+
|
31
|
+
fixedOffset = parseInt($fixedEl.css('top'), 10);
|
32
|
+
fixedOffset = isNaN(fixedOffset) ? 0 : fixedOffset;
|
33
|
+
|
34
|
+
stopScrollingAtFooter.updateFooterTop();
|
35
|
+
$(root).on('govuk.pageSizeChanged', stopScrollingAtFooter.updateFooterTop);
|
36
|
+
|
37
|
+
var $siblingEl = $('<div></div>');
|
38
|
+
$siblingEl.insertBefore($fixedEl);
|
39
|
+
var fixedTop = $siblingEl.offset().top - $siblingEl.position().top;
|
40
|
+
$siblingEl.remove();
|
41
|
+
|
42
|
+
var el = {
|
43
|
+
$fixedEl: $fixedEl,
|
44
|
+
height: height + fixedOffset,
|
45
|
+
fixedTop: height + fixedTop,
|
46
|
+
state: 'fixed'
|
47
|
+
};
|
48
|
+
stopScrollingAtFooter._els.push(el);
|
49
|
+
|
50
|
+
stopScrollingAtFooter.initTimeout();
|
51
|
+
},
|
52
|
+
updateFooterTop: function(){
|
53
|
+
var footer = $('.js-footer:eq(0)');
|
54
|
+
if (footer.length === 0) {
|
55
|
+
return 0;
|
56
|
+
}
|
57
|
+
stopScrollingAtFooter.footerTop = footer.offset().top - 10;
|
58
|
+
},
|
59
|
+
initTimeout: function(){
|
60
|
+
if(stopScrollingAtFooter._hasScrollEvt === false) {
|
61
|
+
$(window).scroll(stopScrollingAtFooter.onScroll);
|
62
|
+
stopScrollingAtFooter._hasScrollEvt = true;
|
63
|
+
}
|
64
|
+
},
|
65
|
+
onScroll: function(){
|
66
|
+
if (stopScrollingAtFooter._isPolling === false) {
|
67
|
+
stopScrollingAtFooter.startPolling();
|
68
|
+
}
|
69
|
+
},
|
70
|
+
startPolling: (function(){
|
71
|
+
if (window.requestAnimationFrame) {
|
72
|
+
return (function(){
|
73
|
+
var callback = function(){
|
74
|
+
stopScrollingAtFooter.checkScroll();
|
75
|
+
if (stopScrollingAtFooter._isPolling === true) {
|
76
|
+
stopScrollingAtFooter.startPolling();
|
77
|
+
}
|
78
|
+
};
|
79
|
+
stopScrollingAtFooter._pollingId = window.requestAnimationFrame(callback);
|
80
|
+
stopScrollingAtFooter._isPolling = true;
|
81
|
+
});
|
82
|
+
} else {
|
83
|
+
return (function(){
|
84
|
+
stopScrollingAtFooter._pollingId = window.setInterval(stopScrollingAtFooter.checkScroll, 16);
|
85
|
+
stopScrollingAtFooter._isPolling = true;
|
86
|
+
});
|
87
|
+
}
|
88
|
+
}()),
|
89
|
+
stopPolling: (function(){
|
90
|
+
if (window.requestAnimationFrame) {
|
91
|
+
return (function(){
|
92
|
+
window.cancelAnimationFrame(stopScrollingAtFooter._pollingId);
|
93
|
+
stopScrollingAtFooter._isPolling = false;
|
94
|
+
});
|
95
|
+
} else {
|
96
|
+
return (function(){
|
97
|
+
window.clearInterval(stopScrollingAtFooter._pollingId);
|
98
|
+
stopScrollingAtFooter._isPolling = false;
|
99
|
+
});
|
100
|
+
}
|
101
|
+
}()),
|
102
|
+
checkScroll: function(){
|
103
|
+
var cachedScrollTop = $(window).scrollTop();
|
104
|
+
if ((cachedScrollTop < (stopScrollingAtFooter.cachedScrollTop + 2)) && (cachedScrollTop > (stopScrollingAtFooter.cachedScrollTop - 2))) {
|
105
|
+
stopScrollingAtFooter.stopPolling();
|
106
|
+
return;
|
107
|
+
} else {
|
108
|
+
stopScrollingAtFooter.cachedScrollTop = cachedScrollTop;
|
109
|
+
}
|
110
|
+
|
111
|
+
$.each(stopScrollingAtFooter._els, function(i, el){
|
112
|
+
var bottomOfEl = cachedScrollTop + el.height;
|
113
|
+
|
114
|
+
if (bottomOfEl > stopScrollingAtFooter.footerTop){
|
115
|
+
stopScrollingAtFooter.stick(el);
|
116
|
+
} else {
|
117
|
+
stopScrollingAtFooter.unstick(el);
|
118
|
+
}
|
119
|
+
});
|
120
|
+
},
|
121
|
+
stick: function(el){
|
122
|
+
if(el.state === 'fixed' && el.$fixedEl.css('position') === 'fixed'){
|
123
|
+
el.$fixedEl.css({ 'position': 'absolute', 'top': stopScrollingAtFooter.footerTop - el.fixedTop });
|
124
|
+
el.state = 'absolute';
|
125
|
+
}
|
126
|
+
},
|
127
|
+
unstick: function(el){
|
128
|
+
if(el.state === 'absolute'){
|
129
|
+
el.$fixedEl.css({ 'position': '', 'top': '' });
|
130
|
+
el.state = 'fixed';
|
131
|
+
}
|
132
|
+
}
|
133
|
+
};
|
134
|
+
|
135
|
+
root.GOVUK.stopScrollingAtFooter = stopScrollingAtFooter;
|
136
|
+
|
137
|
+
$(root).load(function(){ $(root).trigger('govuk.pageSizeChanged'); });
|
138
|
+
}).call(this);
|