mirror of
https://github.com/gnh1201/welsonjs.git
synced 2025-05-17 15:11:04 +00:00
45 lines
1.3 KiB
JavaScript
45 lines
1.3 KiB
JavaScript
/*!
|
|
{
|
|
"name": "Notification",
|
|
"property": "notification",
|
|
"caniuse": "notifications",
|
|
"authors": ["Theodoor van Donge", "Hendrik Beskow"],
|
|
"notes": [{
|
|
"name": "HTML5 Rocks Tutorial",
|
|
"href": "https://www.html5rocks.com/en/tutorials/notifications/quick/"
|
|
}, {
|
|
"name": "W3C Spec",
|
|
"href": "https://www.w3.org/TR/notifications/"
|
|
}, {
|
|
"name": "Changes in Chrome to Notifications API due to Service Worker Push Notifications",
|
|
"href": "https://developers.google.com/web/updates/2015/05/Notifying-you-of-notificiation-changes"
|
|
}],
|
|
"knownBugs": ["Possibility of false-positive on Chrome for Android if permissions we're granted for a website prior to Chrome 44."],
|
|
"polyfills": ["desktop-notify", "html5-notifications"]
|
|
}
|
|
!*/
|
|
/* DOC
|
|
Detects support for the Notifications API
|
|
*/
|
|
define(['Modernizr'], function(Modernizr) {
|
|
Modernizr.addTest('notification', function() {
|
|
if (!window.Notification || !window.Notification.requestPermission) {
|
|
return false;
|
|
}
|
|
// if permission is already granted, assume support
|
|
if (window.Notification.permission === 'granted') {
|
|
return true;
|
|
}
|
|
|
|
try {
|
|
new window.Notification('');
|
|
} catch (e) {
|
|
if (e.name === 'TypeError') {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
return true;
|
|
});
|
|
});
|