govuk_frontend_toolkit 1.2.0 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
data/app/assets/README.md
CHANGED
@@ -703,7 +703,7 @@ var test = new GOVUK.MultivariateTest({
|
|
703
703
|
customVarIndex: 555,
|
704
704
|
cohorts: {
|
705
705
|
pay_your_car_tax: {html: "Pay Your Car Tax"},
|
706
|
-
give_us_money: {html: "Give Us Money Or We Will Crush Your Car"}
|
706
|
+
give_us_money: {html: "Give Us Money Or We Will Crush Your Car"}
|
707
707
|
}
|
708
708
|
});
|
709
709
|
```
|
@@ -717,7 +717,21 @@ var test = new GOVUK.MultivariateTest({
|
|
717
717
|
customVarIndex: 555,
|
718
718
|
cohorts: {
|
719
719
|
pay_your_car_tax: {callback: function() { ... }},
|
720
|
-
give_us_money: {callback: function() { ... }}
|
720
|
+
give_us_money: {callback: function() { ... }}
|
721
|
+
}
|
722
|
+
});
|
723
|
+
```
|
724
|
+
|
725
|
+
If you want one cohort to appear 25% of the time then you can optionally weight
|
726
|
+
that cohort:
|
727
|
+
|
728
|
+
```javascript
|
729
|
+
var test = new GOVUK.MultivariateTest({
|
730
|
+
name: 'car_tax_button_text',
|
731
|
+
customVarIndex: 555,
|
732
|
+
cohorts: {
|
733
|
+
pay_your_car_tax: {weight: 25, callback: function() { ... }}, // 25%
|
734
|
+
give_us_money: {weight: 75, callback: function() { ... }} // 75%
|
721
735
|
}
|
722
736
|
});
|
723
737
|
```
|
@@ -730,9 +744,11 @@ Takes these options:
|
|
730
744
|
- `el`: Element to run this test on (optional)
|
731
745
|
- `name`: The name of the text (alphanumeric and underscores)
|
732
746
|
- `customVarIndex`: The index of the custom variable in Google Analytics. GA only gives 50 integer slots to each account, and it is important that a unique integer is assigned to each test. Current contact for assigning a custom var slot for GOV.UK is: Ashraf Chohan <ashraf.chohan@digital.cabinet-office.gov.uk>
|
733
|
-
- `
|
747
|
+
- `defaultWeight`: Number of times each cohorts should appear in an array the random cohort is picked from, to be used in conjunction with weights on individual cohorts.
|
748
|
+
- `cohorts`: An object that maps cohort name to an object that defines the cohort. Name must be same format as test name. Object contains keys (all optional):
|
734
749
|
- `html`: HTML to fill element with when this cohort is picked.
|
735
750
|
- `callback`: Function to call when this cohort is chosen. If it is a string, that method on the test object is called.
|
751
|
+
- `weight`: Number of times this cohort should appear in an array the random cohort is picked from, defaults to the `defaultWeight` of the test.
|
736
752
|
|
737
753
|
Full documentation on how to design multivariate tests, use the data in GA and construct hypothesis tests is on its way soon.
|
738
754
|
|
@@ -15,6 +15,7 @@
|
|
15
15
|
this._loadOption(options, 'customVarIndex');
|
16
16
|
this._loadOption(options, 'cohorts');
|
17
17
|
this._loadOption(options, 'runImmediately', true);
|
18
|
+
this._loadOption(options, 'defaultWeight', 1);
|
18
19
|
|
19
20
|
if (this.runImmediately) {
|
20
21
|
this.run();
|
@@ -84,12 +85,29 @@
|
|
84
85
|
window._gaq.push(['_trackEvent', this.cookieName(), 'run', '-', 0, true]);
|
85
86
|
};
|
86
87
|
|
87
|
-
MultivariateTest.prototype.
|
88
|
-
|
88
|
+
MultivariateTest.prototype.weightedCohortNames = function() {
|
89
|
+
var names = [],
|
90
|
+
defaultWeight = this.defaultWeight;
|
91
|
+
|
92
|
+
$.each(this.cohorts, function(key, cohortSettings) {
|
93
|
+
var numberForCohort, i;
|
94
|
+
|
95
|
+
if (typeof cohortSettings.weight === 'undefined'){
|
96
|
+
numberForCohort = defaultWeight;
|
97
|
+
} else {
|
98
|
+
numberForCohort = cohortSettings.weight;
|
99
|
+
}
|
100
|
+
|
101
|
+
for(i=0; i<numberForCohort; i++){
|
102
|
+
names.push(key);
|
103
|
+
}
|
104
|
+
});
|
105
|
+
|
106
|
+
return names;
|
89
107
|
};
|
90
108
|
|
91
109
|
MultivariateTest.prototype.chooseRandomCohort = function() {
|
92
|
-
var names = this.
|
110
|
+
var names = this.weightedCohortNames();
|
93
111
|
return names[Math.floor(Math.random() * names.length)];
|
94
112
|
};
|
95
113
|
|
@@ -142,14 +142,43 @@ describe("MultivariateTest", function() {
|
|
142
142
|
});
|
143
143
|
});
|
144
144
|
|
145
|
-
describe("#
|
146
|
-
it("should return the names of the cohorts", function() {
|
145
|
+
describe("#weightedCohortNames", function() {
|
146
|
+
it("should return the weighted names of the cohorts when no weights are defined", function() {
|
147
147
|
var test = new GOVUK.MultivariateTest({
|
148
148
|
name: 'stuff',
|
149
149
|
customVarIndex: 1,
|
150
|
-
cohorts: {foo: {}, bar: {}}
|
150
|
+
cohorts: {foo: {}, bar: {}, baz: {}}
|
151
|
+
});
|
152
|
+
expect(test.weightedCohortNames()).toEqual(['foo', 'bar', 'baz']);
|
153
|
+
});
|
154
|
+
|
155
|
+
it("should return the weighted names of the cohorts when weights are defined", function() {
|
156
|
+
var test = new GOVUK.MultivariateTest({
|
157
|
+
name: 'stuff',
|
158
|
+
customVarIndex: 1,
|
159
|
+
cohorts: {foo: { weight: 2 }, bar: { weight: 1 }, baz: { weight: 3 }}
|
160
|
+
});
|
161
|
+
expect(test.weightedCohortNames()).toEqual(['foo', 'foo', 'bar', 'baz', 'baz', 'baz']);
|
162
|
+
});
|
163
|
+
|
164
|
+
it("should return the weighted names of the cohorts using default weighting", function() {
|
165
|
+
var test = new GOVUK.MultivariateTest({
|
166
|
+
name: 'stuff',
|
167
|
+
customVarIndex: 1,
|
168
|
+
defaultWeight: 2,
|
169
|
+
cohorts: {foo: {}, bar: {}, baz: {}}
|
170
|
+
});
|
171
|
+
expect(test.weightedCohortNames()).toEqual(['foo', 'foo', 'bar', 'bar', 'baz', 'baz']);
|
172
|
+
});
|
173
|
+
|
174
|
+
it("should return the weighted names of the cohorts using default weighting or defined weighting", function() {
|
175
|
+
var test = new GOVUK.MultivariateTest({
|
176
|
+
name: 'stuff',
|
177
|
+
customVarIndex: 1,
|
178
|
+
defaultWeight: 2,
|
179
|
+
cohorts: {foo: {}, bar: { weight: 1 }, baz: {}}
|
151
180
|
});
|
152
|
-
expect(test.
|
181
|
+
expect(test.weightedCohortNames()).toEqual(['foo', 'foo', 'bar', 'baz', 'baz']);
|
153
182
|
});
|
154
183
|
});
|
155
184
|
|
@@ -1,3 +1,6 @@
|
|
1
|
+
@import '../_colours';
|
2
|
+
@import '../_url-helpers';
|
3
|
+
|
1
4
|
// Player overrides
|
2
5
|
|
3
6
|
@mixin media-player {
|
@@ -62,11 +65,11 @@
|
|
62
65
|
}
|
63
66
|
|
64
67
|
.play {
|
65
|
-
background-image:
|
68
|
+
background-image: file-url('player-icon-play.png');
|
66
69
|
}
|
67
70
|
|
68
71
|
.pause {
|
69
|
-
background-image:
|
72
|
+
background-image: file-url('player-icon-pause.png');
|
70
73
|
}
|
71
74
|
|
72
75
|
.rewind, .forward {
|
@@ -83,13 +86,13 @@
|
|
83
86
|
|
84
87
|
.rewind {
|
85
88
|
left: 0;
|
86
|
-
background-image:
|
89
|
+
background-image: file-url('player-icon-rewind.png');
|
87
90
|
}
|
88
91
|
|
89
92
|
.forward {
|
90
93
|
left: 100%;
|
91
94
|
margin-left: -40px;
|
92
|
-
background-image:
|
95
|
+
background-image: file-url('player-icon-forward.png');
|
93
96
|
}
|
94
97
|
}
|
95
98
|
|
@@ -166,7 +169,7 @@
|
|
166
169
|
line-height: 40px;
|
167
170
|
background-repeat: no-repeat;
|
168
171
|
background-position: center left;
|
169
|
-
background-image:
|
172
|
+
background-image: file-url('player-icon-volume.png');
|
170
173
|
}
|
171
174
|
|
172
175
|
.muted ~ .vol-display {
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: govuk_frontend_toolkit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-05
|
12
|
+
date: 2014-06-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -264,7 +264,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
264
264
|
version: '0'
|
265
265
|
segments:
|
266
266
|
- 0
|
267
|
-
hash:
|
267
|
+
hash: -1772834152994469322
|
268
268
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
269
269
|
none: false
|
270
270
|
requirements:
|
@@ -273,7 +273,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
273
273
|
version: '0'
|
274
274
|
segments:
|
275
275
|
- 0
|
276
|
-
hash:
|
276
|
+
hash: -1772834152994469322
|
277
277
|
requirements: []
|
278
278
|
rubyforge_project:
|
279
279
|
rubygems_version: 1.8.23
|