use Ox.methods

This commit is contained in:
rolux 2012-05-21 22:07:40 +02:00
parent c5b148773f
commit bf9a19a71e

View file

@ -29,9 +29,8 @@ Ox.JQueryElement = function($element) {
};
// add all jQuery functions to the prototype of Ox.JQueryElement
Ox.forEach($('<div>'), function(val, key) {
if (Ox.isFunction(val)) {
Ox.JQueryElement.prototype[key] = function() {
Ox.methods($('<div>'), true).forEach(function(method) {
Ox.JQueryElement.prototype[method] = function() {
var args = arguments, id, ret, that = this;
Ox.forEach(args, function(arg, i) {
// FIXME: with the changes above, is this still needed?
@ -42,7 +41,7 @@ Ox.forEach($('<div>'), function(val, key) {
args[i] = arg.$element;
}
});
ret = that.$element[key].apply(that.$element, args);
ret = that.$element[method].apply(that.$element, args);
// if exactly one $element of an ox object was returned
// then return the ox object instead
// so that we can do oxObj.jqFn().oxFn()
@ -51,5 +50,4 @@ Ox.forEach($('<div>'), function(val, key) {
&& Ox.UI.elements[id = ret.data('oxid')]
? Ox.UI.elements[id] : ret;
};
}
}, true);
});