Merge branch 'staging' of github.com:xwiki-labs/cryptpad into staging

This commit is contained in:
yflory 2017-09-12 18:40:20 +02:00
commit 8c41e0bdd6
5 changed files with 62 additions and 4 deletions

View file

@ -76,7 +76,7 @@ define([
])
])
]),
h('div.cp-version-footer', "CryptPad v1.15.0 (Poukai)")
h('div.cp-version-footer', "CryptPad v1.16.0 (Qalupalik)")
]);
};

View file

@ -1,7 +1,7 @@
{
"name": "cryptpad",
"description": "realtime collaborative visual editor with zero knowlege server",
"version": "1.15.0",
"version": "1.16.0",
"dependencies": {
"chainpad-server": "^1.0.1",
"express": "~4.10.1",

View file

@ -2,7 +2,11 @@ define([
'jquery',
'/common/cryptpad-common.js',
'/common/media-tag.js',
], function ($, Cryptpad, MediaTag) {
'/common/tippy.min.js',
'/customize/application_config.js',
'css!/common/tippy.css',
], function ($, Cryptpad, MediaTag, Tippy, AppConfig) {
var UI = {};
var Messages = Cryptpad.Messages;
@ -498,5 +502,58 @@ define([
});
};
UI.addTooltips = function () {
var MutationObserver = window.MutationObserver;
var delay = typeof(AppConfig.tooltipDelay) === "number" ? AppConfig.tooltipDelay : 500;
var addTippy = function (i, el) {
if (el.nodeName === 'IFRAME') { return; }
Tippy(el, {
position: 'bottom',
distance: 0,
performance: true,
dynamicTitle: true,
delay: [delay, 0]
});
};
var clearTooltips = function () {
$('.tippy-popper').each(function (i, el) {
if ($('[aria-describedby=' + el.getAttribute('id') + ']').length === 0) {
el.remove();
}
});
};
// This is the robust solution to remove dangling tooltips
// The mutation observer does not always find removed nodes.
setInterval(clearTooltips, delay);
var checkRemoved = function (x) {
var out = false;
$(x).find('[aria-describedby]').each(function (i, el) {
var id = el.getAttribute('aria-describedby');
if (id.indexOf('tippy-tooltip-') !== 0) { return; }
out = true;
});
return out;
};
$('[title]').each(addTippy);
var observer = new MutationObserver(function(mutations) {
var removed = false;
mutations.forEach(function(mutation) {
for (var i = 0; i < mutation.addedNodes.length; i++) {
$(mutation.addedNodes[i]).find('[title]').each(addTippy);
}
for (var j = 0; j < mutation.removedNodes.length; j++) {
removed |= checkRemoved(mutation.removedNodes[j]);
}
});
if (removed) { clearTooltips(); }
});
observer.observe($('body')[0], {
attributes: false,
childList: true,
characterData: false,
subtree: true
});
};
return UI;
});

View file

@ -259,6 +259,8 @@ define([
}).nThen(function () {
ctx.metadataMgr = MetadataMgr.create(ctx.sframeChan);
UI.addTooltips();
ctx.sframeChan.on('EV_RT_CONNECT', function () { CommonRealtime.setConnectionState(true); });
ctx.sframeChan.on('EV_RT_DISCONNECT', function () { CommonRealtime.setConnectionState(false); });

View file

@ -183,7 +183,6 @@ define([
// Update the userlist
var $editUsers = $userlistContent.find('.' + USERLIST_CLS).html('');
Cryptpad.clearTooltips();
var $editUsersList = $('<div>', {'class': 'cp-toolbar-userlist-others'});