use Ox.methods
This commit is contained in:
parent
c5b148773f
commit
bf9a19a71e
1 changed files with 22 additions and 24 deletions
|
@ -29,27 +29,25 @@ Ox.JQueryElement = function($element) {
|
||||||
};
|
};
|
||||||
|
|
||||||
// add all jQuery functions to the prototype of Ox.JQueryElement
|
// add all jQuery functions to the prototype of Ox.JQueryElement
|
||||||
Ox.forEach($('<div>'), function(val, key) {
|
Ox.methods($('<div>'), true).forEach(function(method) {
|
||||||
if (Ox.isFunction(val)) {
|
Ox.JQueryElement.prototype[method] = function() {
|
||||||
Ox.JQueryElement.prototype[key] = function() {
|
var args = arguments, id, ret, that = this;
|
||||||
var args = arguments, id, ret, that = this;
|
Ox.forEach(args, function(arg, i) {
|
||||||
Ox.forEach(args, function(arg, i) {
|
// FIXME: with the changes above, is this still needed?
|
||||||
// FIXME: with the changes above, is this still needed?
|
// if an ox object was passed
|
||||||
// if an ox object was passed
|
// then pass its $element instead
|
||||||
// then pass its $element instead
|
// so that we can do oxObj.jqFn(oxObj)
|
||||||
// so that we can do oxObj.jqFn(oxObj)
|
if (arg && arg.ox) {
|
||||||
if (arg && arg.ox) {
|
args[i] = arg.$element;
|
||||||
args[i] = arg.$element;
|
}
|
||||||
}
|
});
|
||||||
});
|
ret = that.$element[method].apply(that.$element, args);
|
||||||
ret = that.$element[key].apply(that.$element, args);
|
// if exactly one $element of an ox object was returned
|
||||||
// if exactly one $element of an ox object was returned
|
// then return the ox object instead
|
||||||
// then return the ox object instead
|
// so that we can do oxObj.jqFn().oxFn()
|
||||||
// so that we can do oxObj.jqFn().oxFn()
|
return ret && ret.jquery
|
||||||
return ret && ret.jquery
|
&& ret.length == 1
|
||||||
&& ret.length == 1
|
&& Ox.UI.elements[id = ret.data('oxid')]
|
||||||
&& Ox.UI.elements[id = ret.data('oxid')]
|
? Ox.UI.elements[id] : ret;
|
||||||
? Ox.UI.elements[id] : ret;
|
};
|
||||||
};
|
});
|
||||||
}
|
|
||||||
}, true);
|
|
Loading…
Reference in a new issue