Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
getDefaultFoundation() {
/* eslint brace-style: "off" */
return new MDCSnackbarFoundation({
addClass: (className: string) => this.root.addClass(className),
removeClass: (className: string) => this.root.removeClass(className),
announce: () => this.labelEl && this.announce(this.labelEl),
notifyOpening: () => this.emit('onOpen', {}),
notifyOpened: () => this.emit('onOpened', {}),
notifyClosing: (reason: string) =>
this.emit('onClose', reason ? { reason } : {}),
notifyClosed: (reason: string) =>
this.emit('onClosed', reason ? { reason } : {})
});
}
registerActionClickHandler: (handler: EventListener) => {
if (this.action)
this.registry.listen(this.renderer, 'click', handler, this.action._elm);
},
deregisterActionClickHandler: (handler: EventListener) => {
this.registry.unlisten('click', handler);
},
registerTransitionEndHandler: (handler: EventListener) => {
this.registry.listen(this.renderer, getCorrectEventName(window, 'transitionend'), handler, this.root);
},
deregisterTransitionEndHandler: (handler: EventListener) => {
this.registry.unlisten(getCorrectEventName(window, 'transitionend'), handler);
}
};
private foundation: { init: Function, destroy: Function, show: (message: SnackbarMessage) => void }
= new MDCSnackbarFoundation(this.mdcAdapter);
constructor(private renderer: Renderer2, private root: ElementRef, private registry: MdcEventRegistry) {
}
ngAfterContentInit() {
this.foundation.init();
}
ngOnDestroy() {
this.foundation.destroy();
}
show(message: SnackbarMessage) {
this.foundation.show(message);
}
}
mounted () {
let vm = this;
this.foundation = new MDCSnackbarFoundation({
addClass (className) {
vm.$set(vm.classes, className, true);
},
removeClass (className) {
vm.$delete(vm.classes, className);
},
setAriaHidden () {
vm.hidden = true;
},
unsetAriaHidden () {
vm.hidden = false;
},
setActionAriaHidden () {
vm.actionHidden = true;
},
unsetActionAriaHidden () {
getDefaultFoundation() {
const adapter: MDCSnackbarAdapter = {
addClass: (className: string) => this._getHostElement().classList.add(className),
removeClass: (className: string) => this._getHostElement().classList.remove(className),
announce: () => this.label.nativeElement ? this._liveAnnouncer.announce(this.config.data.message,
this.config.politeness, this.config.timeoutMs || MDCSnackbarFoundation.numbers.ARIA_LIVE_DELAY_MS) : {},
notifyClosing: () => {},
notifyOpened: () => {},
notifyOpening: () => {},
notifyClosed: (reason: MdcSnackbarDismissReason | string) => this.snackbarRef.dismiss(reason)
};
return new MDCSnackbarFoundation(adapter);
}