2
0
mirror of https://github.com/tenrok/vue-native-notification.git synced 2026-05-17 05:09:38 +03:00

Merge branch 'master' into master

This commit is contained in:
Dennis Bruner
2018-08-03 18:45:24 +02:00
committed by GitHub
2 changed files with 17 additions and 8 deletions
+16 -7
View File
@@ -64,8 +64,6 @@ const VueNativeNotification = {
return new Error('No permission to show notification')
}
// Create Notification object
const notification = new Notification(title, opts)
const bindOnError = function (event) {
'use strict'
@@ -91,12 +89,23 @@ const VueNativeNotification = {
onshow()
}
notification.onerror = bindOnError
notification.onclick = bindOnClick
notification.onclose = bindOnClose
notification.onshow = bindOnShow
// Create Notification object
try {
const notification = new Notification(title, opts)
return notification
notification.onerror = bindOnError
notification.onclick = bindOnClick
notification.onclose = bindOnClose
notification.onshow = bindOnShow
return notification
} catch (e) {
if (e.name !== 'TypeError')
return e
return navigator.serviceWorker.ready.then(reg => reg.showNotification(title, opts))
.then(bindOnShow, bindOnError)
}
})
}
Vue.notification.show = show
+1 -1
View File
@@ -1 +1 @@
(function(){function a(e,u,c){function f(r,n){if(!u[r]){if(!e[r]){var o="function"==typeof require&&require;if(!n&&o)return o(r,!0);if(s)return s(r,!0);var t=new Error("Cannot find module '"+r+"'");throw t.code="MODULE_NOT_FOUND",t}var i=u[r]={exports:{}};e[r][0].call(i.exports,function(n){var o=e[r][1][n];return f(o||n)},i,i.exports,a,e,u,c)}return u[r].exports}for(var s="function"==typeof require&&require,n=0;n<c.length;n++)f(c[n]);return f}return a})()({1:[function(n,o,r){"use strict";Object.defineProperty(r,"__esModule",{value:true});var f=window.Notification||window.webkitNotification;var s=function n(o){};var a=function n(o){o.preventDefault();window.focus();o.target.close()};var w=function n(o){};var v=function n(o){};var l={onerror:s,onclick:a,onclose:w,onshow:v};var t={install:function n(o,r){r=r||{};r.requestOnNotify=r.requestOnNotify||true;o.notification={};o.prototype.$notification={};var t=function n(){return f.requestPermission()};o.notification.requestPermission=t;o.prototype.$notification.requestPermission=t;var i=function n(u,c,o){o.onerror=function(){};o.onclick=function(){};o.onclose=function(){};o.onshow=function(){};return Promise.resolve().then(function(){if(r.requestOnNotify&&f.permission!=="granted"){return t()}return f.permission}).then(function(n){if(n==="denied"){return new Error("No permission to show notification")}var o=new f(u,c);var r=function n(o){"use strict";l.onerror(o);s()};var t=function n(o){"use strict";l.onclick(o);a()};var i=function n(o){"use strict";l.onclose(o);w()};var e=function n(o){"use strict";l.onshow(o);v()};o.onerror=r;o.onclick=t;o.onclose=i;o.onshow=e;return o})};o.notification.show=i;o.prototype.$notification.show=i}};if(typeof window!=="undefined"&&window.Vue){window.Vue.use(t)}r.default=t},{}]},{},[1]);
(function(){function a(i,u,c){function f(r,n){if(!u[r]){if(!i[r]){var o="function"==typeof require&&require;if(!n&&o)return o(r,!0);if(s)return s(r,!0);var t=new Error("Cannot find module '"+r+"'");throw t.code="MODULE_NOT_FOUND",t}var e=u[r]={exports:{}};i[r][0].call(e.exports,function(n){var o=i[r][1][n];return f(o||n)},e,e.exports,a,i,u,c)}return u[r].exports}for(var s="function"==typeof require&&require,n=0;n<c.length;n++)f(c[n]);return f}return a})()({1:[function(n,o,r){"use strict";Object.defineProperty(r,"__esModule",{value:true});var l=window.Notification||window.webkitNotification;var t=function n(o){};var e=function n(o){o.preventDefault();window.focus();o.target.close()};var i=function n(o){};var u=function n(o){};var p={onerror:t,onclick:e,onclose:i,onshow:u};var c={install:function n(o,w){w=w||{};w.requestOnNotify=w.requestOnNotify||true;o.notification={};o.prototype.$notification={};var v=function n(){return l.requestPermission()};o.notification.requestPermission=v;o.prototype.$notification.requestPermission=v;var r=function n(u,c,o){var r=o.onerror,f=r===undefined?function(){}:r,t=o.onclick,s=t===undefined?function(){}:t,e=o.onclose,a=e===undefined?function(){}:e,i=o.onshow,d=i===undefined?function(){}:i;return Promise.resolve().then(function(){if(w.requestOnNotify&&l.permission!=="granted"){return v()}return l.permission}).then(function(n){if(n==="denied"){return new Error("No permission to show notification")}try{var o=new l(u,c);var r=function n(o){"use strict";p.onerror(o);f()};var t=function n(o){"use strict";p.onclick(o);s()};var e=function n(o){"use strict";p.onclose(o);a()};var i=function n(o){"use strict";p.onshow(o);d()};o.onerror=r;o.onclick=t;o.onclose=e;o.onshow=i;return o}catch(n){if(n.name!=="TypeError")throw n;return navigator.serviceWorker.ready.then(function(n){return n.showNotification(u,c)})}})};o.notification.show=r;o.prototype.$notification.show=r}};if(typeof window!=="undefined"&&window.Vue){window.Vue.use(c)}r.default=c},{}]},{},[1]);