Skip to content

Commit

Permalink
added support for jquery 1.4.2 delegates
Browse files Browse the repository at this point in the history
  • Loading branch information
Greg Allen committed Mar 16, 2010
1 parent 41dde20 commit 254e5e8
Show file tree
Hide file tree
Showing 3 changed files with 217 additions and 14 deletions.
28 changes: 14 additions & 14 deletions src/lowpro.jquery.js
Expand Up @@ -77,17 +77,6 @@

return klass;
},
delegate: function(rules) {
return function(e) {
var target = $(e.target), parent = null;
for (var selector in rules) {
if (target.is(selector) || ((parent = target.parents(selector)) && parent.length > 0)) {
return rules[selector].apply(this, [parent || target].concat($.makeArray(arguments)));
}
parent = null;
}
}
},
ux: {
behavior: function() {
var args = $.makeArray(arguments), name = args.shift(), parent = null;
Expand All @@ -114,8 +103,19 @@

var bindEvents = function(instance) {
for (var member in instance) {
if (member.match(/^on(.+)/) && typeof instance[member] == 'function') {
instance.element.bind(RegExp.$1, $.bind(instance[member], instance));
if (member.match(/^on(.+)/)) {
if (typeof instance[member] == 'function') {
instance.element.bind(RegExp.$1, $.bind(instance[member], instance));
} else {
var rules = instance[member];
var eventName = RegExp.$1;
for (var rule in rules) {
var f = function(r, func) {
instance.element.delegate(r, eventName, function(e) { func(instance, e) });
}
f(rule, rules[rule]);
}
}
}
}
}
Expand Down Expand Up @@ -180,7 +180,7 @@
return attachBehavior(el, behavior, args);
});
},
delegate: function(type, rules) {
delegate2: function(type, rules) {
return this.bind(type, $.delegate(rules));
},
attached: function(behavior) {
Expand Down

0 comments on commit 254e5e8

Please sign in to comment.