open-nomad/ui/app/helpers/lazy-click.js
2020-06-18 22:08:26 -07:00

18 lines
397 B
JavaScript

import Helper from '@ember/component/helper';
/**
* Lazy Click Event
*
* Usage: {{lazy-click action}}
*
* Calls the provided action only if the target isn't an anchor
* that should be handled instead.
*/
export function lazyClick([onClick, event]) {
if (!['a', 'button'].includes(event.target.tagName.toLowerCase())) {
onClick(event);
}
}
export default Helper.helper(lazyClick);