Socket
Socket
Sign inDemoInstall

notificationsjs

Package Overview
Dependencies
1
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.1.2 to 0.1.3

5

lib/notifications.js

@@ -345,2 +345,7 @@ (function (global, factory) {

}, {
key: 'getMessages',
value: function getMessages() {
return this.messages;
}
}, {
key: 'push',

@@ -347,0 +352,0 @@ value: function push(text) {

2

lib/notifications.min.js

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

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.Notifications=t()}(this,function(){"use strict";function e(e,t){return t={exports:{}},e(t,t.exports),t.exports}function t(e,t){n.apply(void 0,[e,t].concat(a))}function n(e,t){for(var n=arguments.length,i=Array(n>2?n-2:0),o=2;n>o;o++)i[o-2]=arguments[o];i.forEach(function(n){return e.addEventListener(n,t)})}var i={};i.classCallCheck=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},i.createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),i.toConsumableArray=function(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)};var o=e(function(e){function t(e){if(null===e||void 0===e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}function n(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},n=0;10>n;n++)t["_"+String.fromCharCode(n)]=n;var i=Object.getOwnPropertyNames(t).map(function(e){return t[e]});if("0123456789"!==i.join(""))return!1;var o={};return"abcdefghijklmnopqrst".split("").forEach(function(e){o[e]=e}),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},o)).join("")}catch(s){return!1}}var i=Object.prototype.hasOwnProperty,o=Object.prototype.propertyIsEnumerable;e.exports=n()?Object.assign:function(e,n){for(var s,a,r=t(e),c=1;c<arguments.length;c++){s=Object(arguments[c]);for(var l in s)i.call(s,l)&&(r[l]=s[l]);if(Object.getOwnPropertySymbols){a=Object.getOwnPropertySymbols(s);for(var f=0;f<a.length;f++)o.call(s,a[f])&&(r[a[f]]=s[a[f]])}}return r}}),s=o&&"object"==typeof o&&"default"in o?o["default"]:o,a=["webkitAnimationEnd","mozAnimationEnd","MSAnimationEnd","oanimationend","animationend"],r=0,c=function(){function e(t){var n=t.text,o=t.target,s=t.template,a=t.notificationClasses,c=t.animations,l=t.onClose,f=void 0===l?function(){}:l,u=t.closeAfter;i.classCallCheck(this,e),this.rendered=!1,this.removed=!1,this.target=o,this.onClose=f,this.closeAfter=u,this.animations=c,this.notificationClasses=a,this.text=n,this.index=r++,this.element=this.makeElement({template:s,notificationClasses:a,animations:c,text:n,index:this.index})}return i.createClass(e,[{key:"makeElement",value:function(e){var t,n=e.template,o=e.notificationClasses,s=e.animations,a=e.text,r=e.index,c=document.createElement("div");return c.setAttribute("data-notifications-index",r),(t=c.classList).add.apply(t,i.toConsumableArray(o)),this.animations.on&&c.classList.add("animated",s.animateInClasses),c.innerHTML=n({text:a}),c}},{key:"bindOnClose",value:function(){var e=this,t=document.querySelector('[data-notifications-index="'+this.index+'"] [data-notifications-close]');t.addEventListener("click",function(t){t.preventDefault(),e.remove(),e.onClose()})}},{key:"render",value:function(){var e=this;this.rendered===!1&&(this.target.insertBefore(this.element,this.target.firstChild),this.rendered=!0,this.bindOnClose(),0!==this.closeAfter&&setTimeout(function(){e.remove(),e.onClose()},this.closeAfter))}},{key:"remove",value:function(){var e=this;if(!this.removed){var n;t(this.element,function(){e.removed||e.target.removeChild(e.element),e.removed=!0}),(n=this.element.classList).add.apply(n,i.toConsumableArray(this.animations.animateOutClasses))}}}]),e}(),l=function(e){var t=e.text;return"\n <div>\n "+t+'\n\n <button class="notification__close" data-notifications-close>&times;</button>\n </div>\n '},f={targetDOMElement:"#notifications",closeAfter:5e3,notificationClasses:["notification"],animations:{on:!0,animateInClasses:["fadeIn"],animateOutClasses:["fadeOut"]},onClose:function(){},onShow:function(){},onNewMessage:function(){},pusher:{instance:null,channelName:"",eventName:"",transform:function(){return"Configure `pusher.transform`"}},template:l,shouldRender:!0},u=function(){function e(t){if(i.classCallCheck(this,e),this.config=s({},f,t),this.messages=[],this.targetElement=document.querySelector(this.config.targetDOMElement),!this.targetElement&&this.config.shouldRender)throw new Error("Element with selector "+this.config.targetDOMElement+" was not found");this.templateFn=this.config.template,this.config.pusher.instance&&this.bindPusher(this.config.pusher)}return i.createClass(e,[{key:"bindPusher",value:function(e){var t=this,n=e.instance,i=e.channelName,o=e.eventName,s=e.transform,a=n.subscribe(i);a.bind(o,function(e){t.createNewMessage(s(e))})}},{key:"createNewMessage",value:function(e){var t=arguments.length<=1||void 0===arguments[1]?[]:arguments[1],n=new c({text:e,target:this.targetElement,template:this.templateFn,notificationClasses:[].concat(i.toConsumableArray(this.config.notificationClasses),i.toConsumableArray(t)),onClose:this.config.onClose,closeAfter:this.config.closeAfter,animations:this.config.animations});this.messages.push(n),this.config.onNewMessage(n),this.config.shouldRender&&(n.render(),this.config.onShow(n))}},{key:"push",value:function(e){var t=arguments.length<=1||void 0===arguments[1]?{}:arguments[1],n=t.classes,i=void 0===n?[]:n;this.createNewMessage(e,i)}}]),e}();return u});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.Notifications=t()}(this,function(){"use strict";function e(e,t){return t={exports:{}},e(t,t.exports),t.exports}function t(e,t){n.apply(void 0,[e,t].concat(a))}function n(e,t){for(var n=arguments.length,i=Array(n>2?n-2:0),o=2;n>o;o++)i[o-2]=arguments[o];i.forEach(function(n){return e.addEventListener(n,t)})}var i={};i.classCallCheck=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},i.createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),i.toConsumableArray=function(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)};var o=e(function(e){function t(e){if(null===e||void 0===e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}function n(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},n=0;10>n;n++)t["_"+String.fromCharCode(n)]=n;var i=Object.getOwnPropertyNames(t).map(function(e){return t[e]});if("0123456789"!==i.join(""))return!1;var o={};return"abcdefghijklmnopqrst".split("").forEach(function(e){o[e]=e}),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},o)).join("")}catch(s){return!1}}var i=Object.prototype.hasOwnProperty,o=Object.prototype.propertyIsEnumerable;e.exports=n()?Object.assign:function(e,n){for(var s,a,r=t(e),c=1;c<arguments.length;c++){s=Object(arguments[c]);for(var l in s)i.call(s,l)&&(r[l]=s[l]);if(Object.getOwnPropertySymbols){a=Object.getOwnPropertySymbols(s);for(var f=0;f<a.length;f++)o.call(s,a[f])&&(r[a[f]]=s[a[f]])}}return r}}),s=o&&"object"==typeof o&&"default"in o?o["default"]:o,a=["webkitAnimationEnd","mozAnimationEnd","MSAnimationEnd","oanimationend","animationend"],r=0,c=function(){function e(t){var n=t.text,o=t.target,s=t.template,a=t.notificationClasses,c=t.animations,l=t.onClose,f=void 0===l?function(){}:l,u=t.closeAfter;i.classCallCheck(this,e),this.rendered=!1,this.removed=!1,this.target=o,this.onClose=f,this.closeAfter=u,this.animations=c,this.notificationClasses=a,this.text=n,this.index=r++,this.element=this.makeElement({template:s,notificationClasses:a,animations:c,text:n,index:this.index})}return i.createClass(e,[{key:"makeElement",value:function(e){var t,n=e.template,o=e.notificationClasses,s=e.animations,a=e.text,r=e.index,c=document.createElement("div");return c.setAttribute("data-notifications-index",r),(t=c.classList).add.apply(t,i.toConsumableArray(o)),this.animations.on&&c.classList.add("animated",s.animateInClasses),c.innerHTML=n({text:a}),c}},{key:"bindOnClose",value:function(){var e=this,t=document.querySelector('[data-notifications-index="'+this.index+'"] [data-notifications-close]');t.addEventListener("click",function(t){t.preventDefault(),e.remove(),e.onClose()})}},{key:"render",value:function(){var e=this;this.rendered===!1&&(this.target.insertBefore(this.element,this.target.firstChild),this.rendered=!0,this.bindOnClose(),0!==this.closeAfter&&setTimeout(function(){e.remove(),e.onClose()},this.closeAfter))}},{key:"remove",value:function(){var e=this;if(!this.removed){var n;t(this.element,function(){e.removed||e.target.removeChild(e.element),e.removed=!0}),(n=this.element.classList).add.apply(n,i.toConsumableArray(this.animations.animateOutClasses))}}}]),e}(),l=function(e){var t=e.text;return"\n <div>\n "+t+'\n\n <button class="notification__close" data-notifications-close>&times;</button>\n </div>\n '},f={targetDOMElement:"#notifications",closeAfter:5e3,notificationClasses:["notification"],animations:{on:!0,animateInClasses:["fadeIn"],animateOutClasses:["fadeOut"]},onClose:function(){},onShow:function(){},onNewMessage:function(){},pusher:{instance:null,channelName:"",eventName:"",transform:function(){return"Configure `pusher.transform`"}},template:l,shouldRender:!0},u=function(){function e(t){if(i.classCallCheck(this,e),this.config=s({},f,t),this.messages=[],this.targetElement=document.querySelector(this.config.targetDOMElement),!this.targetElement&&this.config.shouldRender)throw new Error("Element with selector "+this.config.targetDOMElement+" was not found");this.templateFn=this.config.template,this.config.pusher.instance&&this.bindPusher(this.config.pusher)}return i.createClass(e,[{key:"bindPusher",value:function(e){var t=this,n=e.instance,i=e.channelName,o=e.eventName,s=e.transform,a=n.subscribe(i);a.bind(o,function(e){t.createNewMessage(s(e))})}},{key:"createNewMessage",value:function(e){var t=arguments.length<=1||void 0===arguments[1]?[]:arguments[1],n=new c({text:e,target:this.targetElement,template:this.templateFn,notificationClasses:[].concat(i.toConsumableArray(this.config.notificationClasses),i.toConsumableArray(t)),onClose:this.config.onClose,closeAfter:this.config.closeAfter,animations:this.config.animations});this.messages.push(n),this.config.onNewMessage(n),this.config.shouldRender&&(n.render(),this.config.onShow(n))}},{key:"getMessages",value:function(){return this.messages}},{key:"push",value:function(e){var t=arguments.length<=1||void 0===arguments[1]?{}:arguments[1],n=t.classes,i=void 0===n?[]:n;this.createNewMessage(e,i)}}]),e}();return u});
{
"name": "notificationsjs",
"version": "0.1.2",
"version": "0.1.3",
"description": "Coming soon...",

@@ -10,3 +10,3 @@ "main": "lib/notifications.js",

"build-prod": "rollup --config rollup.config.js && rollup --config rollup.config.js --environment MINIFY",
"build": "npm run build-prod && cp src/style.css lib",
"build": "npm run build-prod",
"prepublish": "npm run build",

@@ -13,0 +13,0 @@ "test": "npm run lint && ava --tap | tap-dot",

@@ -11,2 +11,4 @@ # Notifications.js

![](http://i.imgur.com/wdwyPWf.png)
# Getting Started

@@ -59,3 +61,3 @@

You can also [see an example on JSBin](http://jsbin.com/dewiyekoku/edit?html,js,output).
You can also [see an example on JSBin](http://jsbin.com/luwetapelo/edit?html,js,output).

@@ -150,2 +152,5 @@ If you'd like an example of using the library through npm and browserify, [check out the getting started repon](https://github.com/pusher-community/notifications.js-getting-started).

### 0.1.3
- add `notifications.getMessages()`
### 0.1.2

@@ -152,0 +157,0 @@ - nicer default CSS styling

@@ -70,2 +70,6 @@ import objectAssign from 'object-assign';

getMessages() {
return this.messages;
}
push(text, { classes = [] } = {}) {

@@ -72,0 +76,0 @@ this.createNewMessage(text, classes);

@@ -9,1 +9,7 @@ import test from 'ava';

});
test('it lets you access the messages', t => {
const notifications = new Notifications({ shouldRender: false });
notifications.push('Hello World');
t.is(notifications.getMessages().length, 1);
});
SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc