Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFatih Acet <acetfatih@gmail.com>2016-07-24 23:45:11 +0300
committerFatih Acet <acetfatih@gmail.com>2016-07-24 23:45:11 +0300
commitaaa9509d120524573085e94af9de5cdde83e3271 (patch)
tree3824cffd4cdd132ee9cf75a00a7624f5ccc0dabd /app/assets/javascripts/lib/utils/notify.js
parent56b79181adc0bd6e9abef97ea075c14be971a01a (diff)
ES6ify all the things!
Diffstat (limited to 'app/assets/javascripts/lib/utils/notify.js')
-rw-r--r--app/assets/javascripts/lib/utils/notify.js41
1 files changed, 41 insertions, 0 deletions
diff --git a/app/assets/javascripts/lib/utils/notify.js b/app/assets/javascripts/lib/utils/notify.js
new file mode 100644
index 00000000000..42b6ac0589e
--- /dev/null
+++ b/app/assets/javascripts/lib/utils/notify.js
@@ -0,0 +1,41 @@
+(function() {
+ (function(w) {
+ var notificationGranted, notifyMe, notifyPermissions;
+ notificationGranted = function(message, opts, onclick) {
+ var notification;
+ notification = new Notification(message, opts);
+ setTimeout(function() {
+ return notification.close();
+ }, 8000);
+ if (onclick) {
+ return notification.onclick = onclick;
+ }
+ };
+ notifyPermissions = function() {
+ if ('Notification' in window) {
+ return Notification.requestPermission();
+ }
+ };
+ notifyMe = function(message, body, icon, onclick) {
+ var opts;
+ opts = {
+ body: body,
+ icon: icon
+ };
+ if (!('Notification' in window)) {
+
+ } else if (Notification.permission === 'granted') {
+ return notificationGranted(message, opts, onclick);
+ } else if (Notification.permission !== 'denied') {
+ return Notification.requestPermission(function(permission) {
+ if (permission === 'granted') {
+ return notificationGranted(message, opts, onclick);
+ }
+ });
+ }
+ };
+ w.notify = notifyMe;
+ return w.notifyPermissions = notifyPermissions;
+ })(window);
+
+}).call(this);