peteshow 0.8.0 → 0.8.1
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.
- data/dist/peteshow.js +10 -2
- data/dist/peteshow.min.js +2 -2
- data/lib/assets/javascripts/peteshow.js +10 -2
- data/lib/assets/javascripts/peteshow.min.js +2 -2
- data/package.json +1 -1
- data/src/peteshow-core.js +10 -2
- data/tests/suite/localstorage.js +0 -2
- metadata +1 -1
data/package.json
CHANGED
data/src/peteshow-core.js
CHANGED
@@ -215,11 +215,11 @@
|
|
215
215
|
|
216
216
|
savedFieldsExist = function() {
|
217
217
|
var saved = _options.cookies ? $.cookie('peteshow') : localStorage.getItem('peteshow')
|
218
|
-
return
|
218
|
+
return saved != undefined || saved != null
|
219
219
|
}
|
220
220
|
|
221
221
|
Peteshow.setSavedFields = function(data) {
|
222
|
-
_options.cookies ? $.cookie('peteshow', data) : localStorage.setItem('peteshow', data)
|
222
|
+
_options.cookies ? $.cookie('peteshow', data, {domain: getDomain()}) : localStorage.setItem('peteshow', data)
|
223
223
|
}
|
224
224
|
|
225
225
|
Peteshow.getSavedFields = function() {
|
@@ -227,6 +227,14 @@
|
|
227
227
|
return (saved != undefined || saved != null) ? JSON.parse(saved) : {}
|
228
228
|
}
|
229
229
|
|
230
|
+
getDomain = function() {
|
231
|
+
var i = 0, d = document.domain, p = d.split('.')
|
232
|
+
while(i < (p.length - 1)){
|
233
|
+
d = p.slice(-1-(++i)).join('.');
|
234
|
+
}
|
235
|
+
return d == 'localhost' ? '' : d;
|
236
|
+
}
|
237
|
+
|
230
238
|
Peteshow.clearSaved = function() {
|
231
239
|
Peteshow.clearLocalStorage()
|
232
240
|
Peteshow.clearCookies()
|
data/tests/suite/localstorage.js
CHANGED
@@ -21,8 +21,6 @@ test('fields are saved into localstorage', function() {
|
|
21
21
|
// field was saved
|
22
22
|
ok(localStorage.getItem('peteshow') != null, 'localstorge isnt null')
|
23
23
|
|
24
|
-
var saved = Peteshow.getSavedFields();
|
25
|
-
|
26
24
|
// saved values equal the initial values
|
27
25
|
equal(saved[field], input, 'saved value equals initial input');
|
28
26
|
|