mirror of
https://github.com/grafana/grafana.git
synced 2024-11-30 12:44:10 -06:00
27f66a6df9
* moving coreModule to app/angular and isolating it more * fixed ts issue
30 lines
643 B
TypeScript
30 lines
643 B
TypeScript
import coreModule from './core_module';
|
|
|
|
coreModule.directive('giveFocus', () => {
|
|
return (scope: any, element: any, attrs: any) => {
|
|
element.click((e: any) => {
|
|
e.stopPropagation();
|
|
});
|
|
|
|
scope.$watch(
|
|
attrs.giveFocus,
|
|
(newValue: any) => {
|
|
if (!newValue) {
|
|
return;
|
|
}
|
|
setTimeout(() => {
|
|
element.focus();
|
|
const domEl: any = element[0];
|
|
if (domEl.setSelectionRange) {
|
|
const pos = element.val().length * 2;
|
|
domEl.setSelectionRange(pos, pos);
|
|
}
|
|
}, 200);
|
|
},
|
|
true
|
|
);
|
|
};
|
|
});
|
|
|
|
export default {};
|