add new methods to Ox.$ (width, height, show, hide)
This commit is contained in:
parent
42f0700a00
commit
49a16328f5
1 changed files with 14 additions and 3 deletions
|
@ -75,7 +75,7 @@ Ox.$ = Ox.element = function(val) {
|
|||
// fixme: remove click and mousedown,
|
||||
// add native css selector
|
||||
// take all matches of getElementsBy...
|
||||
var element = Ox.isObject(val) ? val // window
|
||||
var element = Ox.isObject(val) ? val // window or document
|
||||
: val[0] == '<' ? document.createElement(Ox.sub(val, 1, -1))
|
||||
: val[0] == '#' ? document.getElementById(Ox.sub(val, 1))
|
||||
: val[0] == '.' ? document.getElementsByClassName(Ox.sub(val, 1))[0]
|
||||
|
@ -187,8 +187,7 @@ Ox.$ = Ox.element = function(val) {
|
|||
return ret;
|
||||
},
|
||||
empty: function() {
|
||||
this.html('');
|
||||
return this;
|
||||
return this.html('');
|
||||
},
|
||||
/*@
|
||||
hasClass <f> Returns true if the element has a given class
|
||||
|
@ -198,6 +197,12 @@ Ox.$ = Ox.element = function(val) {
|
|||
hasClass: function(str) {
|
||||
return this[0].className.split(' ').indexOf(str) > -1;
|
||||
},
|
||||
height: function() {
|
||||
return this[0].offsetHeight;
|
||||
},
|
||||
hide: function() {
|
||||
return this.css({display: 'none'});
|
||||
},
|
||||
/*@
|
||||
html <f> Gets or sets the inner HTML
|
||||
() -> <s> The inner HTML
|
||||
|
@ -250,9 +255,15 @@ Ox.$ = Ox.element = function(val) {
|
|||
).join(' ');
|
||||
return this;
|
||||
},
|
||||
show: function() {
|
||||
return this.css({display: 'block'});
|
||||
},
|
||||
unbind: function(event) {
|
||||
this[0]['on' + event] = null;
|
||||
return this;
|
||||
},
|
||||
width: function() {
|
||||
return this[0].offsetWidth;
|
||||
}
|
||||
} : null;
|
||||
};
|
Loading…
Reference in a new issue