forked from extern/egroupware
Add a method to egw.notification to check API availability
This commit is contained in:
parent
d054aa90f5
commit
77c1d67240
@ -28,7 +28,7 @@ egw.extend('notification', egw.MODULE_WND_LOCAL, function(_app, _wnd)
|
|||||||
|
|
||||||
// Notification permission, the default value is 'default' which is equivalent to 'denied'
|
// Notification permission, the default value is 'default' which is equivalent to 'denied'
|
||||||
var permission = 'default';
|
var permission = 'default';
|
||||||
|
|
||||||
if (typeof Notification != 'undefined')
|
if (typeof Notification != 'undefined')
|
||||||
{
|
{
|
||||||
permission = Notification.permission;
|
permission = Notification.permission;
|
||||||
@ -89,6 +89,15 @@ egw.extend('notification', egw.MODULE_WND_LOCAL, function(_app, _wnd)
|
|||||||
// Callback function dispatches on error
|
// Callback function dispatches on error
|
||||||
notification.onerror = options.onerror || function (e) {egw.debug('Notification failed because of ' + e);};
|
notification.onerror = options.onerror || function (e) {egw.debug('Notification failed because of ' + e);};
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check Notification availability by browser
|
||||||
|
*
|
||||||
|
* @returns {Boolean} true if notification is supported and permitted otherwise false
|
||||||
|
*/
|
||||||
|
checkNotification: function () {
|
||||||
|
return (Notification && Notification.requestPermission && permission == 'granted');
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user