Skip to content

Instantly share code, notes, and snippets.

@kakuno
Created September 23, 2009 17:12
Show Gist options
  • Save kakuno/192120 to your computer and use it in GitHub Desktop.
Save kakuno/192120 to your computer and use it in GitHub Desktop.
/*
var ta = new ToggleAction({
on: function(obj) {
setClass(obj, "on");
}
off: function(obj) {
removeClass(obj);
}
});
*/
var ToggleAction = function() {
this.initialize.apply(this, arguments);
}
ToggleAction.prototype = {
initialize: function(args) {
this.__on = args.on;
this.__off = args.off;
},
on: function(obj) {
if (this._active) {
this.off(this._active);
}
this.__on(obj);
this._active = obj;
},
off: function(obj) {
this.__off(obj);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment