// takes this.events with format 'element:event': function(e) { } and attaches it
attachEvent: function(selector) {
var sel = selector.split(':');
var el = this.el[sel[0]];
var ev = sel[1];
if (!el) return;
if (!el.each) Event.observe(el, ev, this.events[selector]);
else el.each( function(item, index) {
Event.observe(item, ev, this.events[selector]);
}.bind(this));
},
attachEvents: function() {
for (property in this.events) this.attachEvent(property);
},
removeEvent: function(selector) {
var sel = selector.split(':');
var el = this.el[sel[0]];
var ev = sel[1];
if (!el) return;
if (!el.each) Event.stopObserving(el, ev, this.events[selector]);
else el.each(function(item, index) {
Event.stopObserving(item, ev, this.events[selector]);
}.bind(this));
},
removeEvents: function() {
for (x in this.events) this.removeEvent(x);
}