diff --git a/HELP.md b/HELP.md
index de6c6e7b..2b3885e1 100644
--- a/HELP.md
+++ b/HELP.md
@@ -149,6 +149,7 @@ All main configuration could be done via [config.json](json/config.json "Config"
"appCache" : false, /* cache files for offline use */
"analytics" : true, /* google analytics suport */
"diff" : false, /* when save - send patch, not whole file */
+ "notifications" : false, /* show notifications when tab is not active*/
"localStorage" : true, /* cache directory data */
"minify" : true /* minification of js,css,html and img */
"online" : true, /* load js files from cdn or local path */
diff --git a/html/config.html b/html/config.html
index ebf91524..d98df612 100644
--- a/html/config.html
+++ b/html/config.html
@@ -3,6 +3,7 @@
App cache
Analytics
Diff
+ Notifications
Local Storage
Minify
Online
diff --git a/json/config.json b/json/config.json
index 26dd04be..2527a0b8 100644
--- a/json/config.json
+++ b/json/config.json
@@ -3,6 +3,7 @@
"appДache": false,
"analytics": true,
"diff": false,
+ "notifications": false,
"localStorage": true,
"minify": true,
"online": true,
diff --git a/lib/client/config.js b/lib/client/config.js
index 13bc2c32..52cbe890 100644
--- a/lib/client/config.js
+++ b/lib/client/config.js
@@ -11,6 +11,7 @@ var CloudCmd, Util, DOM;
INPUT = 'INPUT',
CONFIG,
TEMPLATE,
+ Notify = DOM.Notify,
Config = this;
function init(pCallBack) {
@@ -130,6 +131,11 @@ var CloudCmd, Util, DOM;
obj[name] = data;
+ if (name === 'notifications') {
+ if (data && !Notify.check())
+ Notify.request();
+ }
+
CloudCmd.setConfig(CONFIG, function() {
CONFIG[name] = data;
});
diff --git a/lib/client/console.js b/lib/client/console.js
index c7879021..e68e49e5 100644
--- a/lib/client/console.js
+++ b/lib/client/console.js
@@ -17,6 +17,7 @@ var CloudCmd, Util, DOM, $;
MouseBinded,
Key = CloudCmd.Key,
Images = DOM.Images,
+ Notify = DOM.Notify,
Console = this;
function init() {
@@ -126,6 +127,7 @@ var CloudCmd, Util, DOM, $;
if (jqconsole && ret) {
jqconsole.Write(Buffer[status], status + '-msg');
+ Notify.send(Buffer[status]);
Buffer[status] = '';
}
}
diff --git a/lib/client/dom.js b/lib/client/dom.js
index 80ffeabc..68a3272f 100644
--- a/lib/client/dom.js
+++ b/lib/client/dom.js
@@ -642,6 +642,44 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog;
return lRet;
};
},
+ NotifyProto = function() {
+ var Notify = this,
+ Show = false;
+
+ Events.add({
+ 'blur' :function() {
+ Show = true;
+ },
+ 'focus': function() {
+ Show = false;
+ }
+ }, window);
+
+ this.send = function(msg) {
+ var notify, granted = Notify.check();
+
+ if (granted && Show)
+ notify = new Notification(msg);
+ };
+
+ this.check = function () {
+ var ret,
+ Not = Notification,
+ perm = Not.permission;
+
+ if (perm === 'granted')
+ ret = true;
+
+ return ret;
+ };
+
+ this.request = function () {
+ var Not = Notification;
+
+ if (Not)
+ Not.requestPermission();
+ };
+ },
LoaderProto = function() {
var Loader = this;
@@ -1953,6 +1991,7 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog;
DOMTree = Util.extendProto(DOMTreeProto),
Events = Util.extendProto(EventsProto),
+ Notify = Util.extendProto(NotifyProto),
Loader = Util.extendProto(LoaderProto),
Images = Util.extendProto(ImagesProto),
RESTful = Util.extendProto(RESTfulProto),
@@ -1968,7 +2007,8 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog;
Events : Events,
RESTful: RESTful,
Images : Images,
- Cache : Cache
+ Cache : Cache,
+ Notify : Notify
}
]);