Files
standardnotes-app-web/app/assets/javascripts/directives/functional/selectOnClick.ts
2020-04-13 08:27:10 -05:00

16 lines
427 B
TypeScript

/* @ngInject */
export function selectOnClick($window: ng.IWindowService) {
return {
restrict: 'A',
link: function(scope: ng.IScope, element: JQLite) {
element.on('focus', function() {
if (!$window.getSelection()!.toString()) {
const input = element as any;
/** Required for mobile Safari */
input.setSelectionRange(0, input.value.length);
}
});
}
};
}