import Dropdown from 'flarum/components/Dropdown'; import icon from 'flarum/helpers/icon'; import NotificationList from 'flarum/components/NotificationList'; export default class NotificationsDropdown extends Dropdown { static initProps(props) { props.className = props.className || 'NotificationsDropdown'; props.buttonClassName = props.buttonClassName || 'Button Button--flat'; props.menuClassName = props.menuClassName || 'Dropdown-menu--right'; props.label = props.label || app.trans('core.notifications_tooltip'); props.icon = props.icon || 'bell'; super.initProps(props); } constructor(...args) { super(...args); /** * Whether or not the notifications dropdown is visible. * * @type {Boolean} */ this.showing = false; this.list = new NotificationList(); } getButton() { const newNotifications = this.getNewCount(); const vdom = super.getButton(); vdom.attrs.title = this.props.label; vdom.attrs.className += (newNotifications ? ' new' : ''); vdom.attrs.onclick = this.onclick.bind(this); return vdom; } getButtonContent() { const unread = this.getUnreadCount(); return [ icon(this.props.icon, {className: 'Button-icon'}), unread ? {unread} : '', {this.props.label} ]; } getMenu() { return (