/
annotator.js
36 lines (32 loc) · 1.11 KB
/
annotator.js
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
34
35
(function () {
var elem = document.getElementById('text-to-annotate'),
annotator = new Annotator(elem);
var oldAuth = new Annotator.Plugin.AnnotateItPermissions().options.userAuthorize;
annotator.setupPlugins({
storeUrl: OpenText.Annotator.store,
tokenUrl: "/__authtoken__"
}, {
Store: {
loadFromSearch: { limit: 1000 }
},
Permissions: false,
AnnotateItPermissions: {
userString: function (user) {
if (typeof user === 'string') {
return user;
} else if (user.hasOwnProperty('name') && typeof user.name === 'string') {
return user.name;
} else if (user.hasOwnProperty('id') && typeof user.id === 'string') {
return user.id;
}
},
userAuthorize: function (action, annotation, user, consumer) {
if (typeof user === 'string') {
return oldAuth.call(this, action, annotation, user, consumer);
} else if (user.hasOwnProperty('id') && typeof user.id === 'string') {
return oldAuth.call(this, action, annotation, user.id, consumer);
}
}
}
});
}());