2021-11-09 01:37:16 -06:00
|
|
|
|
import coreModule from './core_module';
|
2019-01-16 08:09:48 -06:00
|
|
|
|
|
2019-04-28 02:58:12 -05:00
|
|
|
|
export function autofillEventFix($compile: any) {
|
2019-01-16 08:09:48 -06:00
|
|
|
|
return {
|
|
|
|
|
link: ($scope: any, elem: any) => {
|
|
|
|
|
const input = elem[0];
|
|
|
|
|
const dispatchChangeEvent = () => {
|
|
|
|
|
const event = new Event('change');
|
|
|
|
|
return input.dispatchEvent(event);
|
|
|
|
|
};
|
|
|
|
|
const onAnimationStart = ({ animationName }: AnimationEvent) => {
|
|
|
|
|
switch (animationName) {
|
|
|
|
|
case 'onAutoFillStart':
|
|
|
|
|
return dispatchChangeEvent();
|
|
|
|
|
case 'onAutoFillCancel':
|
|
|
|
|
return dispatchChangeEvent();
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// const onChange = (evt: Event) => console.log(evt);
|
|
|
|
|
|
|
|
|
|
input.addEventListener('animationstart', onAnimationStart);
|
|
|
|
|
// input.addEventListener('change', onChange);
|
|
|
|
|
|
|
|
|
|
$scope.$on('$destroy', () => {
|
|
|
|
|
input.removeEventListener('animationstart', onAnimationStart);
|
|
|
|
|
// input.removeEventListener('change', onChange);
|
|
|
|
|
});
|
2019-02-13 04:14:53 -06:00
|
|
|
|
},
|
2019-01-16 08:09:48 -06:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-23 05:15:05 -06:00
|
|
|
|
coreModule.directive('autofillEventFix', ['$compile', autofillEventFix]);
|