govuk_admin_template 2.5.1 → 2.6.0

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
2
  SHA1:
3
- metadata.gz: 275a44d03ba07ab2ca4b6b8f6a8c4efc1682f94a
4
- data.tar.gz: 408e1ca5743e7942602ca2d877a5e7ded68391b2
3
+ metadata.gz: 2f488325511d4be67781f3c9c29f0a807d1c6c2a
4
+ data.tar.gz: cbbd2e17b10112888182b1eab06a3157526cb4dd
5
5
  SHA512:
6
- metadata.gz: 8d4d4afb40085f9ac1815583eabb120a5ce81fc61d3e852ebd2f97e2f025ada736cc0fd4a50b2ac489779c5ef8c6d04c17b16a61caf3a0c34fb999554c8f82d7
7
- data.tar.gz: 7113c9c186d541a0ddf9ed2cb739d1f890fd20049f51a27c5b91567a16504cf72d3022414161bd4de5ce5601b23155ee6057219878f6979f9b3adae924b39aa8
6
+ metadata.gz: a33d76c990e7202c27dfac3bf1c4ffcd8bc3ced4983da7af956b41048c5876c37eff16d176687714968fca1e853ea0d6b2f9647030cece905ba131663ea7450b
7
+ data.tar.gz: 87c85a793fcc0bc1e32fb117c29bda17d1103d71bf3f6fb74778eebc63f355f132d2ad5f1956a0687d732fdcd78f67edb080328887d24bb25e31edf97b1360ff
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ # 2.6.0
2
+
3
+ * Add functions for setting, reading and deleting cookies
4
+
1
5
  # 2.5.1
2
6
 
3
7
  * Fix inline form rendering in IE7
@@ -111,12 +111,69 @@
111
111
  }
112
112
  }
113
113
 
114
- // Useful for debugging:
115
- // console.log(eventAnalytics);
116
-
117
114
  if (typeof root.ga === "function") {
118
115
  root.ga('send', eventAnalytics);
119
116
  }
120
117
  }
121
118
 
119
+ /*
120
+ Cookie methods
121
+ ==============
122
+ Usage:
123
+
124
+ Setting a cookie:
125
+ GOVUKAdmin.cookie('hobnob', 'tasty', { days: 30 });
126
+
127
+ Reading a cookie:
128
+ GOVUKAdmin.cookie('hobnob');
129
+
130
+ Deleting a cookie:
131
+ GOVUKAdmin.cookie('hobnob', null);
132
+ */
133
+ GOVUKAdmin.cookie = function(name, value, options) {
134
+ if(typeof value !== 'undefined'){
135
+ if(value === false || value === null) {
136
+ return GOVUKAdmin.setCookie(name, '', { days: -1 });
137
+ } else {
138
+ return GOVUKAdmin.setCookie(name, value, options);
139
+ }
140
+ } else {
141
+ return GOVUKAdmin.getCookie(name);
142
+ }
143
+ };
144
+
145
+ GOVUKAdmin.setCookie = function(name, value, options) {
146
+ if (typeof options === 'undefined') {
147
+ options = {};
148
+ }
149
+ var cookieString = name + "=" + value + "; path=/";
150
+ if (options.days) {
151
+ var date = new Date();
152
+ date.setTime(date.getTime() + (options.days * 24 * 60 * 60 * 1000));
153
+ cookieString = cookieString + "; expires=" + date.toGMTString();
154
+ }
155
+ if (options.domain) {
156
+ cookieString = cookieString + "; domain=" + options.domain;
157
+ }
158
+ if (document.location.protocol == 'https:'){
159
+ cookieString = cookieString + "; Secure";
160
+ }
161
+ document.cookie = cookieString;
162
+ };
163
+
164
+ GOVUKAdmin.getCookie = function(name) {
165
+ var nameEQ = name + "=";
166
+ var cookies = document.cookie.split(';');
167
+ for(var i = 0, len = cookies.length; i < len; i++) {
168
+ var cookie = cookies[i];
169
+ while (cookie.charAt(0) == ' ') {
170
+ cookie = cookie.substring(1, cookie.length);
171
+ }
172
+ if (cookie.indexOf(nameEQ) === 0) {
173
+ return decodeURIComponent(cookie.substring(nameEQ.length));
174
+ }
175
+ }
176
+ return null;
177
+ };
178
+
122
179
  })(jQuery, window);
@@ -1,3 +1,3 @@
1
1
  module GovukAdminTemplate
2
- VERSION = "2.5.1"
2
+ VERSION = "2.6.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: govuk_admin_template
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.1
4
+ version: 2.6.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: 2015-07-29 00:00:00.000000000 Z
11
+ date: 2015-08-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -192,7 +192,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
192
192
  version: '0'
193
193
  requirements: []
194
194
  rubyforge_project:
195
- rubygems_version: 2.2.3
195
+ rubygems_version: 2.2.5
196
196
  signing_key:
197
197
  specification_version: 4
198
198
  summary: Styles, scripts and templates for GOV.UK admin applications