notify users of changes if the visibility api is supported
This commit is contained in:
parent
d64e06c12e
commit
b229a18ccf
@ -6,10 +6,12 @@ define([
|
|||||||
'/bower_components/textpatcher/TextPatcher.amd.js',
|
'/bower_components/textpatcher/TextPatcher.amd.js',
|
||||||
'/common/cryptpad-common.js',
|
'/common/cryptpad-common.js',
|
||||||
'/slide/slide.js',
|
'/slide/slide.js',
|
||||||
|
'/common/notify.js',
|
||||||
|
'/common/visible.js',
|
||||||
'/bower_components/file-saver/FileSaver.min.js',
|
'/bower_components/file-saver/FileSaver.min.js',
|
||||||
'/bower_components/jquery/dist/jquery.min.js',
|
'/bower_components/jquery/dist/jquery.min.js',
|
||||||
'/customize/pad.js'
|
'/customize/pad.js'
|
||||||
], function (Config, Messages, Realtime, Crypto, TextPatcher, Cryptpad, Slide) {
|
], function (Config, Messages, Realtime, Crypto, TextPatcher, Cryptpad, Slide, Notify, Visible) {
|
||||||
var $ = window.jQuery;
|
var $ = window.jQuery;
|
||||||
var saveAs = window.saveAs;
|
var saveAs = window.saveAs;
|
||||||
|
|
||||||
@ -49,6 +51,18 @@ define([
|
|||||||
return title;
|
return title;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var unnotify = function () {
|
||||||
|
if (!(module.tabNofification &&
|
||||||
|
typeof(module.tabNofification.cancel) === 'function')) { return; }
|
||||||
|
module.tabNofification.cancel();
|
||||||
|
};
|
||||||
|
|
||||||
|
var notify = function () {
|
||||||
|
if (!(Visible.isSupported() && !Visible.currently())) { return; }
|
||||||
|
unnotify();
|
||||||
|
module.tabNofification = Notify.tab(document.title, 1000, 10);
|
||||||
|
};
|
||||||
|
|
||||||
var $modal = $('#modal');
|
var $modal = $('#modal');
|
||||||
var $content = $('#content');
|
var $content = $('#content');
|
||||||
Slide.setModal($modal, $content);
|
Slide.setModal($modal, $content);
|
||||||
@ -213,8 +227,9 @@ define([
|
|||||||
elem.selectionEnd = selects[1];
|
elem.selectionEnd = selects[1];
|
||||||
|
|
||||||
Slide.update(content);
|
Slide.update(content);
|
||||||
};
|
|
||||||
|
|
||||||
|
notify();
|
||||||
|
};
|
||||||
|
|
||||||
var onReady = config.onReady = function (info) {
|
var onReady = config.onReady = function (info) {
|
||||||
var realtime = module.realtime = info.realtime;
|
var realtime = module.realtime = info.realtime;
|
||||||
@ -228,6 +243,12 @@ define([
|
|||||||
|
|
||||||
Slide.update(content);
|
Slide.update(content);
|
||||||
|
|
||||||
|
if (Visible.isSupported()) {
|
||||||
|
Visible.onChange(function (yes) {
|
||||||
|
if (yes) { unnotify(); }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
setEditable(true);
|
setEditable(true);
|
||||||
initializing = false;
|
initializing = false;
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user