Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vue-native-notification

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vue-native-notification - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

20

index.js

@@ -5,5 +5,7 @@ // Notification object

const onerror = function onerror (event) {
// console.log('On error event was called')
}
const onclick = function onclick (event) {
// console.log('On click event was called')
event.preventDefault()

@@ -15,5 +17,7 @@ window.focus()

const onclose = function onclose (event) {
// console.log('On close event was called')
}
const onshow = function onshow (event) {
// console.log('On show event was called')
}

@@ -46,6 +50,6 @@

var show = function (title, opts, {
onerror = defaultEvents.onerror,
onclick = defaultEvents.onclick,
onclose = defaultEvents.onclose,
onshow = defaultEvents.onshow
onerror = function () { },
onclick = function () { },
onclose = function () { },
onshow = function () { }
}) {

@@ -73,3 +77,3 @@ return Promise.resolve()

defaultEvents.onerror(event)
onerror(event)
onerror()
}

@@ -80,3 +84,3 @@

defaultEvents.onclick(event)
onclick(event)
onclick()
}

@@ -87,3 +91,3 @@

defaultEvents.onclose(event)
onclose(event)
onclose()
}

@@ -94,3 +98,3 @@

defaultEvents.onshow(event)
onshow(event)
onshow()
}

@@ -97,0 +101,0 @@

2

package.json
{
"name": "vue-native-notification",
"version": "1.0.1",
"version": "1.0.2",
"description": "Vue.js plugin for native notifications",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -40,3 +40,3 @@ # vue-native-notification

body: 'This is an example!'
})
}, {})
}

@@ -65,4 +65,60 @@ }

### Events
https://developer.mozilla.org/en-US/docs/Web/API/Notification
We now supports all notifications events
#### onerror
https://developer.mozilla.org/en-US/docs/Web/API/Notification/onerror
Is an empty function. Nothing will be executed
#### onclick
https://developer.mozilla.org/en-US/docs/Web/API/Notification/onclick
When notification is clicked, we set the focus on the context browser and close the notification
#### onclose
https://developer.mozilla.org/en-US/docs/Web/API/Notification/onclose
Is an empty function. Nothing will be executed
#### onshow
https://developer.mozilla.org/en-US/docs/Web/API/Notification/onshow
Is an empty function. Nothing will be executed
#### Usage
```javascript
const notification = {
title: 'Your title',
options: {
body: 'This is an example!'
},
events: {
onerror: function () {
console.log('Custom error event was called');
},
onclick: function () {
console.log('Custom click event was called');
},
onclose: function () {
console.log('Custom close event was called');
},
onshow: function () {
console.log('Custom show event was called');
}
}
}
this.$notification.show(notification.title, notification.options, notification.events)
```
## License
[MIT](LICENSE.md)

@@ -1,1 +0,1 @@

(function n(o,r,e){function i(u,c){if(!r[u]){if(!o[u]){var f=typeof require=="function"&&require;if(!c&&f)return f(u,!0);if(t)return t(u,!0);var s=new Error("Cannot find module '"+u+"'");throw s.code="MODULE_NOT_FOUND",s}var a=r[u]={exports:{}};o[u][0].call(a.exports,function(n){var r=o[u][1][n];return i(r?r:n)},a,a.exports,n,o,r,e)}return r[u].exports}var t=typeof require=="function"&&require;for(var u=0;u<e.length;u++)i(e[u]);return i})({1:[function(n,o,r){"use strict";Object.defineProperty(r,"__esModule",{value:true});var e=window.Notification||window.webkitNotification;var i=function n(o){};var t=function n(o){o.preventDefault();window.focus();o.target.close()};var u=function n(o){};var c=function n(o){};var f={onerror:i,onclick:t,onclose:u,onshow:c};var s={install:function n(o,r){r=r||{};r.requestOnNotify=r.requestOnNotify||true;o.notification={};o.prototype.$notification={};var i=function n(){return e.requestPermission()};o.notification.requestPermission=i;o.prototype.$notification.requestPermission=i;var t=function n(o,t,u){var c=u.onerror,s=c===undefined?f.onerror:c,a=u.onclick,d=a===undefined?f.onclick:a,w=u.onclose,v=w===undefined?f.onclose:w,l=u.onshow,p=l===undefined?f.onshow:l;return Promise.resolve().then(function(){if(r.requestOnNotify&&e.permission!=="granted"){return i()}return e.permission}).then(function(n){if(n==="denied"){return new Error("No permission to show notification")}var r=new e(o,t);var i=function n(o){"use strict";f.onerror(o);s(o)};var u=function n(o){"use strict";f.onclick(o);d(o)};var c=function n(o){"use strict";f.onclose(o);v(o)};var a=function n(o){"use strict";f.onshow(o);p(o)};r.onerror=i;r.onclick=u;r.onclose=c;r.onshow=a;return r})};o.notification.show=t;o.prototype.$notification.show=t}};if(typeof window!=="undefined"&&window.Vue){window.Vue.use(s)}r.default=s},{}]},{},[1]);
(function n(o,r,e){function i(u,f){if(!r[u]){if(!o[u]){var c=typeof require=="function"&&require;if(!f&&c)return c(u,!0);if(t)return t(u,!0);var s=new Error("Cannot find module '"+u+"'");throw s.code="MODULE_NOT_FOUND",s}var a=r[u]={exports:{}};o[u][0].call(a.exports,function(n){var r=o[u][1][n];return i(r?r:n)},a,a.exports,n,o,r,e)}return r[u].exports}var t=typeof require=="function"&&require;for(var u=0;u<e.length;u++)i(e[u]);return i})({1:[function(n,o,r){"use strict";Object.defineProperty(r,"__esModule",{value:true});var e=window.Notification||window.webkitNotification;var i=function n(o){};var t=function n(o){o.preventDefault();window.focus();o.target.close()};var u=function n(o){};var f=function n(o){};var c={onerror:i,onclick:t,onclose:u,onshow:f};var s={install:function n(o,r){r=r||{};r.requestOnNotify=r.requestOnNotify||true;o.notification={};o.prototype.$notification={};var i=function n(){return e.requestPermission()};o.notification.requestPermission=i;o.prototype.$notification.requestPermission=i;var t=function n(o,t,u){var f=u.onerror,s=f===undefined?function(){}:f,a=u.onclick,d=a===undefined?function(){}:a,v=u.onclose,w=v===undefined?function(){}:v,l=u.onshow,p=l===undefined?function(){}:l;return Promise.resolve().then(function(){if(r.requestOnNotify&&e.permission!=="granted"){return i()}return e.permission}).then(function(n){if(n==="denied"){return new Error("No permission to show notification")}var r=new e(o,t);var i=function n(o){"use strict";c.onerror(o);s()};var u=function n(o){"use strict";c.onclick(o);d()};var f=function n(o){"use strict";c.onclose(o);w()};var a=function n(o){"use strict";c.onshow(o);p()};r.onerror=i;r.onclick=u;r.onclose=f;r.onshow=a;return r})};o.notification.show=t;o.prototype.$notification.show=t}};if(typeof window!=="undefined"&&window.Vue){window.Vue.use(s)}r.default=s},{}]},{},[1]);
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc