Permalink
Browse files

Merge pull request #63 from niallsmart/master

Fix issue #59 in window.name adapter, and misc fixes for IE userData adapter. This is awesome. Thank you!!!!
  • Loading branch information...
2 parents 04514fd + a556d71 commit f73aee061a24c4c2b1b378747e1fff17497f28c2 @brianleroux brianleroux committed Sep 23, 2011
Showing with 26 additions and 21 deletions.
  1. +25 −20 src/adapters/ie-userdata.js
  2. +1 −1 src/adapters/window-name.js
@@ -3,39 +3,42 @@
*
*/
Lawnchair.adapter('ie-userdata', {
- valid: function () {
- return typeof(document.body.addBehavior) != 'undefined';
- },
- init:function(){
+
+ valid: function () {
+ return typeof(document.body.addBehavior) != 'undefined';
+ },
+
+ init:function(options, callback){
var s = document.createElement('span');
s.style.behavior = 'url(\'#default#userData\')';
s.style.position = 'absolute';
s.style.left = 10000;
document.body.appendChild(s);
this.storage = s;
this.storage.load('lawnchair');
+ this.fn(this.name, callback).call(this, this)
},
get:function(key, callback){
var obj = JSON.parse(this.storage.getAttribute(key) || 'null');
- if (obj) {
- obj.key = key;
-
- }
- if (callback)
- callback(obj);
+ if (obj) {
+ obj.key = key;
+ }
+ if (callback) this.lambda(callback).call(this, obj)
+ return this;
},
save:function(obj, callback){
var id = obj.key || 'lc' + this.uuid();
delete obj.key;
this.storage.setAttribute(id, JSON.stringify(obj));
this.storage.save('lawnchair');
- if (callback){
- obj.key = id;
- callback(obj);
- }
+ obj.key = id;
+ if (callback) {
+ this.lambda(callback).call(this, obj)
+ }
+ return this;
},
all:function(callback){
@@ -51,25 +54,27 @@ Lawnchair.adapter('ie-userdata', {
yar.push(o);
}
}
- if (callback)
- callback(yar);
+ if (callback) this.fn(this.name, callback).call(this, yar)
+ return this;
},
+
remove:function(keyOrObj,callback) {
var key = (typeof keyOrObj == 'string') ? keyOrObj : keyOrObj.key;
this.storage.removeAttribute(key);
this.storage.save('lawnchair');
- if(callback)
- callback();
+ if (callback) this.lambda(callback).call(this)
+ return this;
},
+
nuke:function(callback) {
var that = this;
this.all(function(r){
for (var i = 0, l = r.length; i < l; i++) {
if (r[i].key)
that.remove(r[i].key);
}
- if(callback)
- callback();
+ if (callback) that.lambda(callback).call(that)
});
+ return this;
}
});
@@ -30,8 +30,8 @@ Lawnchair.adapter('window-name', (function(index, store) {
if (!exists) index.push(key)
store[key] = obj
window.top.name = JSON.stringify(data) // TODO wow, this is the only diff from the memory adapter
+ obj.key = key
if (cb) {
- obj.key = key
this.lambda(cb).call(this, obj)
}
})

0 comments on commit f73aee0

Please sign in to comment.