mirror of
https://github.com/DeviceFarmer/stf.git
synced 2026-04-18 16:13:24 +02:00
21 lines
465 B
JavaScript
21 lines
465 B
JavaScript
module.exports = function blurElementDirective($parse, $timeout) {
|
|
return {
|
|
restrict: 'A',
|
|
link: function(scope, element, attrs) {
|
|
var model = $parse(attrs.blurElement)
|
|
|
|
scope.$watch(model, function(value) {
|
|
if (value === true) {
|
|
$timeout(function() {
|
|
element[0].blur()
|
|
})
|
|
}
|
|
})
|
|
|
|
element.bind('blur', function() {
|
|
scope.$apply(model.assign(scope, false))
|
|
})
|
|
}
|
|
}
|
|
}
|