提交 1b3da84d 编写于 作者: M Mr.doob

Simplified ui.js a bit more.

上级 885b4d90
......@@ -12,8 +12,6 @@ UI.Element.prototype = {
},
// styles
setStyle: function ( style, array ) {
for ( var i = 0; i < array.length; i ++ ) {
......@@ -24,44 +22,18 @@ UI.Element.prototype = {
},
// content
setTextContent: function ( value ) {
this.dom.textContent = value;
return this;
},
// events
onMouseOver: function ( callback ) {
this.dom.addEventListener( 'mouseover', callback, false );
return this;
},
onMouseOut: function ( callback ) {
this.dom.addEventListener( 'mouseout', callback, false );
return this;
},
onClick: function ( callback ) {
this.dom.addEventListener( 'click', callback, false );
return this;
}
}
// properties
var properties = [ 'left', 'top', 'right', 'bottom', 'width', 'height', 'border', 'borderLeft',
'borderTop', 'borderRight', 'borderBottom', 'margin', 'marginLeft', 'marginTop', 'marginRight',
'marginBottom', 'padding', 'paddingLeft', 'paddingTop', 'paddingRight', 'paddingBottom', 'color',
......@@ -80,6 +52,23 @@ properties.forEach( function ( property ) {
} );
// events
var events = [ 'MouseOver', 'MouseOut', 'Click' ];
events.forEach( function ( event ) {
var method = 'on' + event;
UI.Element.prototype[ method ] = function ( callback ) {
this.dom.addEventListener( event.toLowerCase(), callback, false );
return this;
};
} );
// Panel
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册