-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathpush_notification.min.js
1 lines (1 loc) · 1.14 KB
/
push_notification.min.js
1
(function(){!function(t){var i;return i={create_notification:function(t){return new Notification(t.title,t)},close_notification:function(t,i){return setTimeout(t.close.bind(t),i.closeTime)},set_default_icon:function(t){return default_options.icon=t},isSupported:function(){return"Notification"in window&&"denied"!==Notification.permission?!0:!1},permission_request:function(){return"default"===Notification.permission?Notification.requestPermission():void 0}},t.extend({notify:function(n,e){var o,r;if(arguments.length<1)throw"Notification: few arguments";if("string"!=typeof n)throw"Notification: body must 'String'";var c={title:"Notification",body:"Body",closeTime:5e3,icon:""};return c.body=n,r=t.extend(c,e),i.isSupported()?(i.permission_request(),o=i.create_notification(r),i.close_notification(o,r),{click:function(t){return o.addEventListener("click",function(){return t()}),this},show:function(t){return o.addEventListener("show",function(){return t()}),this},close:function(t){return o.addEventListener("close",function(){return t()}),this},error:function(t){return o.addEventListener("error",function(){return t()}),this}}):void 0}})}(jQuery)}).call(this);