js_cookie_rails 1.0.1 → 2.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -0
- data/lib/js_cookie_rails/version.rb +1 -1
- data/vendor/assets/javascripts/js.cookie.js +26 -14
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2fb24d333a92c686193a4d1025a15ef229f2ad4c
|
4
|
+
data.tar.gz: 0f548149a897afbb5cb29ab48aef95391efb67dc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 427e275bd39b0042d837647ebb685844ac4691f49a7648d64ca0893c3480414e9bc38f0e273fb1702cb21910ca73e6ac43f4d2a676eded349c9cb0fa48969c5c
|
7
|
+
data.tar.gz: ddc81652a5441bba4f7c33ba98fe16d604a5224435821d6170760c19265ea9470269e0b984c7a0987e293270b8997a39e54b9a51e2fcf6d216857a191f84fa9d
|
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# js_cookie_rails
|
2
2
|
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/js_cookie_rails.svg)](http://badge.fury.io/rb/js_cookie_rails)
|
4
|
+
|
3
5
|
js_cookie_rails wraps the [js-cookie](https://github.com/js-cookie/js-cookie)
|
4
6
|
library in a rails engine for simple use with the asset pipeline provided by
|
5
7
|
Rails 3.1 and higher. The gem includes the development (non-minified) source
|
@@ -1,20 +1,20 @@
|
|
1
1
|
/*!
|
2
|
-
* JavaScript Cookie v2.
|
2
|
+
* JavaScript Cookie v2.1.2
|
3
3
|
* https://github.com/js-cookie/js-cookie
|
4
4
|
*
|
5
5
|
* Copyright 2006, 2015 Klaus Hartl & Fagner Brack
|
6
6
|
* Released under the MIT license
|
7
7
|
*/
|
8
|
-
(function (factory) {
|
8
|
+
;(function (factory) {
|
9
9
|
if (typeof define === 'function' && define.amd) {
|
10
10
|
define(factory);
|
11
11
|
} else if (typeof exports === 'object') {
|
12
12
|
module.exports = factory();
|
13
13
|
} else {
|
14
|
-
var
|
14
|
+
var OldCookies = window.Cookies;
|
15
15
|
var api = window.Cookies = factory();
|
16
16
|
api.noConflict = function () {
|
17
|
-
window.Cookies =
|
17
|
+
window.Cookies = OldCookies;
|
18
18
|
return api;
|
19
19
|
};
|
20
20
|
}
|
@@ -34,6 +34,9 @@
|
|
34
34
|
function init (converter) {
|
35
35
|
function api (key, value, attributes) {
|
36
36
|
var result;
|
37
|
+
if (typeof document === 'undefined') {
|
38
|
+
return;
|
39
|
+
}
|
37
40
|
|
38
41
|
// Write
|
39
42
|
|
@@ -55,8 +58,12 @@
|
|
55
58
|
}
|
56
59
|
} catch (e) {}
|
57
60
|
|
58
|
-
|
59
|
-
|
61
|
+
if (!converter.write) {
|
62
|
+
value = encodeURIComponent(String(value))
|
63
|
+
.replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g, decodeURIComponent);
|
64
|
+
} else {
|
65
|
+
value = converter.write(value, key);
|
66
|
+
}
|
60
67
|
|
61
68
|
key = encodeURIComponent(String(key));
|
62
69
|
key = key.replace(/%(23|24|26|2B|5E|60|7C)/g, decodeURIComponent);
|
@@ -64,10 +71,10 @@
|
|
64
71
|
|
65
72
|
return (document.cookie = [
|
66
73
|
key, '=', value,
|
67
|
-
attributes.expires
|
68
|
-
attributes.path
|
69
|
-
attributes.domain
|
70
|
-
attributes.secure
|
74
|
+
attributes.expires ? '; expires=' + attributes.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
|
75
|
+
attributes.path ? '; path=' + attributes.path : '',
|
76
|
+
attributes.domain ? '; domain=' + attributes.domain : '',
|
77
|
+
attributes.secure ? '; secure' : ''
|
71
78
|
].join(''));
|
72
79
|
}
|
73
80
|
|
@@ -86,7 +93,6 @@
|
|
86
93
|
|
87
94
|
for (; i < cookies.length; i++) {
|
88
95
|
var parts = cookies[i].split('=');
|
89
|
-
var name = parts[0].replace(rdecode, decodeURIComponent);
|
90
96
|
var cookie = parts.slice(1).join('=');
|
91
97
|
|
92
98
|
if (cookie.charAt(0) === '"') {
|
@@ -94,7 +100,10 @@
|
|
94
100
|
}
|
95
101
|
|
96
102
|
try {
|
97
|
-
|
103
|
+
var name = parts[0].replace(rdecode, decodeURIComponent);
|
104
|
+
cookie = converter.read ?
|
105
|
+
converter.read(cookie, name) : converter(cookie, name) ||
|
106
|
+
cookie.replace(rdecode, decodeURIComponent);
|
98
107
|
|
99
108
|
if (this.json) {
|
100
109
|
try {
|
@@ -116,7 +125,10 @@
|
|
116
125
|
return result;
|
117
126
|
}
|
118
127
|
|
119
|
-
api.
|
128
|
+
api.set = api;
|
129
|
+
api.get = function (key) {
|
130
|
+
return api(key);
|
131
|
+
};
|
120
132
|
api.getJSON = function () {
|
121
133
|
return api.apply({
|
122
134
|
json: true
|
@@ -135,5 +147,5 @@
|
|
135
147
|
return api;
|
136
148
|
}
|
137
149
|
|
138
|
-
return init();
|
150
|
+
return init(function () {});
|
139
151
|
}));
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: js_cookie_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 2.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alessandro Lepore
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-07-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|
@@ -94,7 +94,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
94
94
|
version: '0'
|
95
95
|
requirements: []
|
96
96
|
rubyforge_project:
|
97
|
-
rubygems_version: 2.4.
|
97
|
+
rubygems_version: 2.4.8
|
98
98
|
signing_key:
|
99
99
|
specification_version: 4
|
100
100
|
summary: Adds js-cookie to the Rails asset pipeline.
|