# Settings
# token
Type: String
Required The project secret token. Without it, it won't work.
Nop.init({
token: 'ce0bb036-6708-4b77-9413-1fc96e1dd0c4',
});
# enabled
Type: Boolean
Default: true
Optional Enable or disable Nop in the current page. Useful if you want to include the SDK in all the pages and decide per-page if enable it.
Nop.init({
enabled: false,
});
# user
Type: String
Default: null
Optional The current user name. It can be really anything: an email adress, a name, whatever. If given, it will be shown on access requests and other messages.
Nop.init({
user: 'John Doe',
});
# locale
Type: String | Object
Default: en-US
Optional The locale used to translate the messages. You can provide a custom translation providing an object as argument. On GitHub (opens new window) you can find the keys and their translation values.
Locales
These are the locales currently supported out-of-the-box: en-US, it-IT.
If you'd like to contribute to add new locales, please submit a PR in the GitHub repository (opens new window).
Example 1
Nop.init({
locale: 'it-IT',
});
Example 2
Nop.init({
locale: {
PAGE_LOCKED: {
TITLE: "Page locked",
DESCRIPTION: "Wait wait, someone else is currently editing this page!",
DESCRIPTION_USER: "Wait wait, <strong>{user}</strong> is currently editing this page!",
BUTTONS: {
REQUEST_ACCESS: "Request access",
CANCEL: "Cancel"
}
},
},
});
# redirectOnCancel
Type: String
Default: /
Optional The URL in which the guest will be redirected when canceling an access request.
If you're looking for more control, take a look to onCancel.
Nop.init({
redirectOnCancel: '/list',
});
# redirectOnReject
Type: String
Default: /
Optional The URL in which the guest will be redirected when his access request has been rejected.
If you're looking for more control, take a look to onReject.
Nop.init({
redirectOnReject: '/sad',
});
# redirectOnApprove
Type: String
Default: /
Optional The URL in which the owner will be redirected when accepting an access request and, therefore, his session has been closed.
If you're looking for more control, take a look to onApprove.
Nop.init({
redirectOnApprove: '/yay',
});
# redirectOnForced
Type: String
Default: /
Optional The URL in which the owner will be redirected when an access request has been forced from a guest and, therefore, his session has been closed.
If you're looking for more control, take a look to onForced.
Nop.init({
redirectOnForced: '/kick',
});
# onCancel
Type: Function
Default: redirect to redirectOnCancel
Optional Callback invoked when the guest cancels an access request.
Nop.init({
onCancel: () => {
console.log('Canceled');
},
});
# onReject
Type: Function
Default: redirect to redirectOnReject
Optional Callback invoked when the guest access request has been rejected.
Nop.init({
onReject: () => {
console.log('Rejected');
},
});
# onApprove
Type: Function
Default: redirect to redirectOnApprove
Optional Callback invoked when the owner approves an access request.
Nop.init({
onApprove: () => {
console.log('Approved');
},
});
# onForced
Type: Function
Default: redirect to redirectOnForced
Optional Callback invoked for the owner when an access request has been forced.
Nop.init({
onForced: () => {
console.log('Forced');
},
});