passman/js/app/directives/clickselect.js

22 lines
488 B
JavaScript
Raw Normal View History

2016-09-26 16:37:43 +08:00
'use strict';
/**
* @ngdoc directive
* @name passmanApp.directive:selectOnClick
* @description
* # selectOnClick
*/
angular.module('passmanApp')
.directive('selectOnClick', ['$window', function ($window) {
return {
restrict: 'A',
link: function (scope, element, attrs) {
element.on('click', function () {
if (!$window.getSelection().toString()) {
// Required for mobile Safari
this.setSelectionRange(0, this.value.length)
}
});
}
};
}]);