add .data method to Ox.$, use in Ox.UI.getOxElement, don't use .attr in Ox.JQueryElement
This commit is contained in:
parent
94b5c5307d
commit
6acd99d74f
3 changed files with 18 additions and 5 deletions
|
@ -373,7 +373,7 @@ Ox.load.UI = function(options, callback) {
|
||||||
});
|
});
|
||||||
// ...
|
// ...
|
||||||
Ox.UI.getOxElement = function(element) {
|
Ox.UI.getOxElement = function(element) {
|
||||||
return Ox.$elements[Ox.$(element).attr('data-oxid')];
|
return Ox.$elements[Ox.$(element).data('oxid')];
|
||||||
};
|
};
|
||||||
/*@
|
/*@
|
||||||
Ox.UI.hideLoadingScreen <f> hide loading screen
|
Ox.UI.hideLoadingScreen <f> hide loading screen
|
||||||
|
|
|
@ -9,9 +9,7 @@ Ox.JQueryElement = function($element) {
|
||||||
//@ id <n> Unique id
|
//@ id <n> Unique id
|
||||||
this.oxid = Ox.uid();
|
this.oxid = Ox.uid();
|
||||||
//@ $element <o> The jQuery-wrapped DOM element
|
//@ $element <o> The jQuery-wrapped DOM element
|
||||||
this.$element = $element
|
this.$element = $element.data({oxid: this.oxid});
|
||||||
.attr({'data-oxid': this.oxid})
|
|
||||||
.data({oxid: this.oxid});
|
|
||||||
//@ 0 <h> The DOM element (for compatibility with jQuery)
|
//@ 0 <h> The DOM element (for compatibility with jQuery)
|
||||||
this[0] = this.$element[0];
|
this[0] = this.$element[0];
|
||||||
//@ length <n> 1 (for compatibility with jQuery)
|
//@ length <n> 1 (for compatibility with jQuery)
|
||||||
|
|
|
@ -29,7 +29,8 @@ Ox.$ <f> Generic HTML element, mimics jQuery
|
||||||
@*/
|
@*/
|
||||||
Ox.$ = Ox.element = function(value) {
|
Ox.$ = Ox.element = function(value) {
|
||||||
|
|
||||||
var element = !Ox.isString(value) ? value // window, document or element
|
var data = {},
|
||||||
|
element = !Ox.isString(value) ? value // window, document or element
|
||||||
: value[0] == '<' ? document.createElement(value.slice(1, -1))
|
: value[0] == '<' ? document.createElement(value.slice(1, -1))
|
||||||
: value[0] == '#' ? document.getElementById(value.slice(1))
|
: value[0] == '#' ? document.getElementById(value.slice(1))
|
||||||
: value[0] == '.' ? document.getElementsByClassName(value.slice(1))[0]
|
: value[0] == '.' ? document.getElementsByClassName(value.slice(1))[0]
|
||||||
|
@ -140,6 +141,20 @@ Ox.$ = Ox.element = function(value) {
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
},
|
},
|
||||||
|
data: function() {
|
||||||
|
var ret;
|
||||||
|
if (arguments.length == 0) {
|
||||||
|
ret = data;
|
||||||
|
} else if (arguments.length == 1 && Ox.isString(arguments[0])) {
|
||||||
|
ret = data[arguments[0]]
|
||||||
|
} else {
|
||||||
|
Ox.forEach(Ox.makeObject(arguments), funciton(value, key) {
|
||||||
|
data[key] = value;
|
||||||
|
});
|
||||||
|
ret = this;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
},
|
||||||
/*@
|
/*@
|
||||||
empty <f> Empties the inner HTML
|
empty <f> Empties the inner HTML
|
||||||
() -> <o> This element
|
() -> <o> This element
|
||||||
|
|
Loading…
Reference in a new issue