Update framework
This commit is contained in:
29
framework/ui/menu/items/menu-item.js
Normal file
29
framework/ui/menu/items/menu-item.js
Normal file
@@ -0,0 +1,29 @@
|
||||
import { BaseItem } from './base-item';
|
||||
export class MenuItem extends BaseItem {
|
||||
constructor(id, title) {
|
||||
super(id, title);
|
||||
}
|
||||
getDOMNode() {
|
||||
const container = document.createElement('div');
|
||||
const button = document.createElement('button');
|
||||
button.textContent = this.title;
|
||||
button.addEventListener('click', this.handleClick.bind(this));
|
||||
button.addEventListener('focus', this.onFocus.bind(this));
|
||||
container.appendChild(button);
|
||||
this.container = container;
|
||||
this.button = button;
|
||||
return container;
|
||||
}
|
||||
getContents() {
|
||||
return this.id;
|
||||
}
|
||||
handleClick(event) {
|
||||
this.emit('choose', this.id);
|
||||
}
|
||||
focus() {
|
||||
this.button && this.button.focus();
|
||||
}
|
||||
click() {
|
||||
this.button.click();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user