jquery_total_storage_rails 1.1.2.0
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/MIT-LICENSE +22 -0
- data/README.md +32 -0
- data/lib/jquery_total_storage_rails/version.rb +5 -0
- data/lib/jquery_total_storage_rails/version.rb~ +5 -0
- data/lib/jquery_total_storage_rails.rb +8 -0
- data/lib/jquery_total_storage_rails.rb~ +9 -0
- data/vendor/assets/javascripts/jquery.total-storage.js +182 -0
- metadata +94 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b4385bc824578e0fe1f6cd927cbca9538559e3cb
|
4
|
+
data.tar.gz: 4437dbf421247170a03411b8d60e469f1dd308f6
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c1dbe43798bc00d788103b7b0584013527e795e4602fe2e43301879b10b7fd9aafe428a68e8eac1b60a28179c24ddc0ee9920b21c68b22527bbe01d79844ec79
|
7
|
+
data.tar.gz: 104be922235dd7e5982da1311d48e890a1f3ba85165332ab39e72a9ae3115c6fac0d315dda352fc4f6415b4c9f18ee340ad752571723df6977f0c82c6fd9f2c8
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 robb-broome
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# JqueryTotalStorageRails
|
2
|
+
|
3
|
+
Rails pipeline implementation for [jquery-total-storage](https://github.com/Upstatement/jquery-total-storage)
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'jquery_total_storage_rails'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install jquery_total_storage_rails
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
Add
|
22
|
+
# = require jquery_total_storage_rails
|
23
|
+
|
24
|
+
to application.js.coffee
|
25
|
+
|
26
|
+
## Contributing
|
27
|
+
|
28
|
+
1. Fork it ( http://github.com/<my-github-username>/jquery_total_storage_rails/fork )
|
29
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
30
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
31
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
32
|
+
5. Create new Pull Request
|
@@ -0,0 +1,182 @@
|
|
1
|
+
/**
|
2
|
+
* TotalStorage
|
3
|
+
*
|
4
|
+
* Copyright (c) 2012 Jared Novack & Upstatement (upstatement.com)
|
5
|
+
* Dual licensed under the MIT and GPL licenses:
|
6
|
+
* http://www.opensource.org/licenses/mit-license.php
|
7
|
+
* http://www.gnu.org/licenses/gpl.html
|
8
|
+
*
|
9
|
+
* Total Storage is the conceptual the love child of jStorage by Andris Reinman,
|
10
|
+
* and Cookie by Klaus Hartl -- though this is not connected to either project.
|
11
|
+
*/
|
12
|
+
|
13
|
+
/**
|
14
|
+
* Create a local storage parameter
|
15
|
+
*
|
16
|
+
== What makes it TOTAL Storage? ==
|
17
|
+
|
18
|
+
* The browser doesn't support local storage it will fall-back to cookies! (Using the
|
19
|
+
wonderful $.cookie plugin).
|
20
|
+
* Send it strings, numbers even complex object arrays! TotalStorage does not care.
|
21
|
+
Your efforts to defeat it will prove futile.
|
22
|
+
* Simple as shit. jStorage and some other very well-written plugins provide a bevy of
|
23
|
+
options for expiration, security and so forth. Frequently this is more power than you
|
24
|
+
need and vulnerable to confusion if you're just want it to work (JWITW)
|
25
|
+
|
26
|
+
* @desc Set the value of a key to a string
|
27
|
+
* @example $.totalStorage('the_key', 'the_value');
|
28
|
+
* @desc Set the value of a key to a number
|
29
|
+
* @example $.totalStorage('the_key', 800.2);
|
30
|
+
* @desc Set the value of a key to a complex Array
|
31
|
+
* @example var myArray = new Array();
|
32
|
+
* myArray.push({name:'Jared', company:'Upstatement', zip:63124});
|
33
|
+
myArray.push({name:'McGruff', company:'Police', zip:60652};
|
34
|
+
$.totalStorage('people', myArray);
|
35
|
+
//to return:
|
36
|
+
$.totalStorage('people');
|
37
|
+
*
|
38
|
+
* @name $.totalStorage
|
39
|
+
* @cat Plugins/Cookie
|
40
|
+
* @author Jared Novack/jared@upstatement.com
|
41
|
+
* @version 1.1.2
|
42
|
+
* @url http://upstatement.com/blog/2012/01/jquery-local-storage-done-right-and-easy/
|
43
|
+
*/
|
44
|
+
|
45
|
+
;(function($, undefined){
|
46
|
+
|
47
|
+
/* Variables I'll need throghout */
|
48
|
+
|
49
|
+
var supported, ls, mod = 'test';
|
50
|
+
if ('localStorage' in window){
|
51
|
+
try {
|
52
|
+
ls = (typeof window.localStorage === 'undefined') ? undefined : window.localStorage;
|
53
|
+
if (typeof ls == 'undefined' || typeof window.JSON == 'undefined'){
|
54
|
+
supported = false;
|
55
|
+
} else {
|
56
|
+
supported = true;
|
57
|
+
}
|
58
|
+
|
59
|
+
window.localStorage.setItem(mod, '1');
|
60
|
+
window.localStorage.removeItem(mod);
|
61
|
+
}
|
62
|
+
catch (err){
|
63
|
+
supported = false;
|
64
|
+
}
|
65
|
+
}
|
66
|
+
|
67
|
+
|
68
|
+
/* Make the methods public */
|
69
|
+
|
70
|
+
$.totalStorage = function(key, value, options){
|
71
|
+
return $.totalStorage.impl.init(key, value);
|
72
|
+
};
|
73
|
+
|
74
|
+
$.totalStorage.setItem = function(key, value){
|
75
|
+
return $.totalStorage.impl.setItem(key, value);
|
76
|
+
};
|
77
|
+
|
78
|
+
$.totalStorage.getItem = function(key){
|
79
|
+
return $.totalStorage.impl.getItem(key);
|
80
|
+
};
|
81
|
+
|
82
|
+
$.totalStorage.getAll = function(){
|
83
|
+
return $.totalStorage.impl.getAll();
|
84
|
+
};
|
85
|
+
|
86
|
+
$.totalStorage.deleteItem = function(key){
|
87
|
+
return $.totalStorage.impl.deleteItem(key);
|
88
|
+
};
|
89
|
+
|
90
|
+
/* Object to hold all methods: public and private */
|
91
|
+
|
92
|
+
$.totalStorage.impl = {
|
93
|
+
|
94
|
+
init: function(key, value){
|
95
|
+
if (typeof value != 'undefined') {
|
96
|
+
return this.setItem(key, value);
|
97
|
+
} else {
|
98
|
+
return this.getItem(key);
|
99
|
+
}
|
100
|
+
},
|
101
|
+
|
102
|
+
setItem: function(key, value){
|
103
|
+
if (!supported){
|
104
|
+
try {
|
105
|
+
$.cookie(key, value);
|
106
|
+
return value;
|
107
|
+
} catch(e){
|
108
|
+
console.log('Local Storage not supported by this browser. Install the cookie plugin on your site to take advantage of the same functionality. You can get it at https://github.com/carhartl/jquery-cookie');
|
109
|
+
}
|
110
|
+
}
|
111
|
+
var saver = JSON.stringify(value);
|
112
|
+
ls.setItem(key, saver);
|
113
|
+
return this.parseResult(saver);
|
114
|
+
},
|
115
|
+
getItem: function(key){
|
116
|
+
if (!supported){
|
117
|
+
try {
|
118
|
+
return this.parseResult($.cookie(key));
|
119
|
+
} catch(e){
|
120
|
+
return null;
|
121
|
+
}
|
122
|
+
}
|
123
|
+
var item = ls.getItem(key);
|
124
|
+
return this.parseResult(item);
|
125
|
+
},
|
126
|
+
deleteItem: function(key){
|
127
|
+
if (!supported){
|
128
|
+
try {
|
129
|
+
$.cookie(key, null);
|
130
|
+
return true;
|
131
|
+
} catch(e){
|
132
|
+
return false;
|
133
|
+
}
|
134
|
+
}
|
135
|
+
ls.removeItem(key);
|
136
|
+
return true;
|
137
|
+
},
|
138
|
+
getAll: function(){
|
139
|
+
var items = [];
|
140
|
+
if (!supported){
|
141
|
+
try {
|
142
|
+
var pairs = document.cookie.split(";");
|
143
|
+
for (var i = 0; i<pairs.length; i++){
|
144
|
+
var pair = pairs[i].split('=');
|
145
|
+
var key = pair[0];
|
146
|
+
items.push({key:key, value:this.parseResult($.cookie(key))});
|
147
|
+
}
|
148
|
+
} catch(e){
|
149
|
+
return null;
|
150
|
+
}
|
151
|
+
} else {
|
152
|
+
for (var j in ls){
|
153
|
+
if (j.length){
|
154
|
+
items.push({key:j, value:this.parseResult(ls.getItem(j))});
|
155
|
+
}
|
156
|
+
}
|
157
|
+
}
|
158
|
+
return items;
|
159
|
+
},
|
160
|
+
parseResult: function(res){
|
161
|
+
var ret;
|
162
|
+
try {
|
163
|
+
ret = JSON.parse(res);
|
164
|
+
if (typeof ret == 'undefined'){
|
165
|
+
ret = res;
|
166
|
+
}
|
167
|
+
if (ret == 'true'){
|
168
|
+
ret = true;
|
169
|
+
}
|
170
|
+
if (ret == 'false'){
|
171
|
+
ret = false;
|
172
|
+
}
|
173
|
+
if (parseFloat(ret) == ret && typeof ret != "object"){
|
174
|
+
ret = parseFloat(ret);
|
175
|
+
}
|
176
|
+
} catch(e){
|
177
|
+
ret = res;
|
178
|
+
}
|
179
|
+
return ret;
|
180
|
+
}
|
181
|
+
};
|
182
|
+
})(jQuery);
|
metadata
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jquery_total_storage_rails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.1.2.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- robb-broome
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-07-12 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: railties
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '4.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '4.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.5'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.5'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: jquery-total-storage allows storing state at the clent using local storage
|
56
|
+
or cookies
|
57
|
+
email:
|
58
|
+
- robb@teamvoice.com
|
59
|
+
executables: []
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- MIT-LICENSE
|
64
|
+
- README.md
|
65
|
+
- lib/jquery_total_storage_rails.rb
|
66
|
+
- lib/jquery_total_storage_rails.rb~
|
67
|
+
- lib/jquery_total_storage_rails/version.rb
|
68
|
+
- lib/jquery_total_storage_rails/version.rb~
|
69
|
+
- vendor/assets/javascripts/jquery.total-storage.js
|
70
|
+
homepage: ''
|
71
|
+
licenses:
|
72
|
+
- MIT
|
73
|
+
metadata: {}
|
74
|
+
post_install_message:
|
75
|
+
rdoc_options: []
|
76
|
+
require_paths:
|
77
|
+
- lib
|
78
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
84
|
+
requirements:
|
85
|
+
- - '>='
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
88
|
+
requirements: []
|
89
|
+
rubyforge_project:
|
90
|
+
rubygems_version: 2.2.2
|
91
|
+
signing_key:
|
92
|
+
specification_version: 4
|
93
|
+
summary: Integrate jquery-total-storage with the rails asset pipeline.
|
94
|
+
test_files: []
|