-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
33 lines (31 loc) · 781 Bytes
/
index.js
File metadata and controls
33 lines (31 loc) · 781 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
var template = require('./template');
var keys = require('keys');
module.exports = {
init: function (scope, element, attrs) {
element.find('input').bind('blur', function () {
var res = keys.normalize(this.value);
if (res.value) {
this.value = res.value;
}
});
},
validator: function (scope, ctrl) {
return function (value) {
var res = keys.normalize(value);
if (res.error) {
ctrl.$setValidity('shortcut', false);
scope.error = res.error;
} else {
ctrl.$setValidity('shortcut', true);
}
if (res.value) {
return value;
}
if (res.value) return value;
}
},
normalize: function (value) {
return keys.normalize(value).value;
},
template: template,
};