let users know when changes have occurred while tabs lack focus

pull/1/head
ansuz 9 years ago
parent 6075849ed7
commit 1ae212af44

@ -11,10 +11,12 @@ define([
'/common/cryptpad-common.js',
'/code/modes.js',
'/code/themes.js',
'/common/visible.js',
'/common/notify.js',
'/bower_components/file-saver/FileSaver.min.js',
'/bower_components/jquery/dist/jquery.min.js',
'/customize/pad.js'
], function (Config, /*RTCode,*/ Messages, Crypto, Realtime, TextPatcher, Toolbar, JSONSortify, JsonOT, Cryptpad, Modes, Themes) {
], function (Config, /*RTCode,*/ Messages, Crypto, Realtime, TextPatcher, Toolbar, JSONSortify, JsonOT, Cryptpad, Modes, Themes, Visible, Notify) {
var $ = window.jQuery;
var saveAs = window.saveAs;
var module = window.APP = {};
@ -332,6 +334,12 @@ define([
editor.setValue(newDoc);
if (Visible.isSupported()) {
Visible.onChange(function (yes) {
if (yes) { unnotify(); }
});
}
setEditable(true);
initializing = false;
};
@ -363,6 +371,20 @@ define([
return cursor;
};
var unnotify = function () {
if (module.tabNotification &&
typeof(module.tabNotification.cancel) === 'function') {
module.tabNotification.cancel();
}
};
var notify = function () {
if (Visible.isSupported() && !Visible.currently()) {
unnotify();
module.tabNotification = Notify.tab(document.title, 1000, 10);
}
};
var onRemote = config.onRemote = function (info) {
if (initializing) { return; }
@ -404,6 +426,8 @@ define([
console.error("shjson2 !== shjson");
module.patchText(shjson2);
}
notify();
};
var onAbort = config.onAbort = function (info) {

Loading…
Cancel
Save