mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-23 08:23:12 +01:00
Ask for notification permission only when it gets called
This commit is contained in:
parent
d9f99b9fe4
commit
9d03e085ed
@ -27,9 +27,6 @@ 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 = Notification.permission || 'default';
|
var permission = Notification.permission || 'default';
|
||||||
|
|
||||||
if (Notification && Notification.requestPermission) Notification.requestPermission (function(_permission){
|
|
||||||
permission = _permission;
|
|
||||||
});
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
||||||
@ -48,9 +45,18 @@ egw.extend('notification', egw.MODULE_WND_LOCAL, function(_app, _wnd)
|
|||||||
* onclose: // Callback function dispateches on notification close
|
* onclose: // Callback function dispateches on notification close
|
||||||
* onerror: // Callback function dispatches on error, default is a egw.debug log
|
* onerror: // Callback function dispatches on error, default is a egw.debug log
|
||||||
* }
|
* }
|
||||||
|
* @return {boolean} true if the permission is granted otherwise false
|
||||||
*/
|
*/
|
||||||
notification: function (_title, _options)
|
notification: function (_title, _options)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
var self = this;
|
||||||
|
// Check and ask for permission
|
||||||
|
if (Notification && Notification.requestPermission && permission === 'default') Notification.requestPermission (function(_permission){
|
||||||
|
permission = _permission;
|
||||||
|
if (permission === 'granted') self.notification(_title,_options);
|
||||||
|
});
|
||||||
|
|
||||||
// All options including callbacks
|
// All options including callbacks
|
||||||
var options = _options || {};
|
var options = _options || {};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user