forked from 0x2620/oxjs
modularize oxui
This commit is contained in:
parent
2e3292e9ce
commit
0024af978c
106 changed files with 16127 additions and 47034 deletions
32
source/js/Ox.JQueryElement.js
Normal file
32
source/js/Ox.JQueryElement.js
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
// Basic jQuery element
|
||||
Ox.JQueryElement = function($element) {
|
||||
var that = this;
|
||||
that.id = Ox.uid();
|
||||
that.ox = Ox.VERSION;
|
||||
that.$element = $element.data({
|
||||
oxid: that.id
|
||||
});
|
||||
Ox.UI.elements[that.id] = that;
|
||||
return that;
|
||||
};
|
||||
Ox.forEach($('<div>'), function(val, key) {
|
||||
if (Ox.isFunction(val)) {
|
||||
Ox.JQueryElement.prototype[key] = function() {
|
||||
var args = arguments, id, ret, that = this;
|
||||
Ox.forEach(args, function(arg, i) {
|
||||
// if an ox object was passed
|
||||
// then pass its $element instead
|
||||
// so that we can do oxObj.jqFn(oxObj)
|
||||
if (arg && arg.ox) {
|
||||
args[i] = arg.$element;
|
||||
}
|
||||
});
|
||||
ret = that.$element[key].apply(that.$element, args);
|
||||
// if the $element of an ox object was returned
|
||||
// then return the ox object instead
|
||||
// so that we can do oxObj.jqFn().oxFn()
|
||||
return ret.jquery && Ox.UI.elements[id = ret.data('oxid')] ?
|
||||
Ox.UI.elements[id] : ret;
|
||||
};
|
||||
}
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue