diff --git a/customize.dist/fsStore.js b/customize.dist/fsStore.js
index 83fcb8066..bbf3d34e6 100644
--- a/customize.dist/fsStore.js
+++ b/customize.dist/fsStore.js
@@ -176,7 +176,18 @@ define([
window.location.reload();
} else if (o && !n) {
//window.location.reload();
- window.location.href = '/';
+ //window.location.href = '/';
+ $(window).on('keyup', function (e) {
+ if (e.keyCode === 27) {
+ Cryptpad.removeLoadingScreen();
+ }
+ });
+ Cryptpad.logout();
+ Cryptpad.addLoadingScreen();
+ Cryptpad.errorLoadingScreen(Messages.onLogout, true);
+ if (exp.info) {
+ exp.info.network.disconnect();
+ }
}
});
diff --git a/customize.dist/translations/messages.fr.js b/customize.dist/translations/messages.fr.js
index 9e738720b..1bc60132e 100644
--- a/customize.dist/translations/messages.fr.js
+++ b/customize.dist/translations/messages.fr.js
@@ -25,6 +25,7 @@ define(function () {
out.websocketError = 'Impossible de se connecter au serveur WebSocket...';
out.typeError = "Ce document temps-réel n'est pas compatible avec l'application sélectionnée";
+ out.onLogout = 'Vous êtes déconnecté de votre compte utilisateur, cliquez ici pour vous authentifier
ou appuyez sur Échap pour accéder au document en mode lecture seule.';
out.loading = "Chargement...";
out.error = "Erreur";
diff --git a/customize.dist/translations/messages.js b/customize.dist/translations/messages.js
index 6d2faab1f..ee09575e7 100644
--- a/customize.dist/translations/messages.js
+++ b/customize.dist/translations/messages.js
@@ -29,6 +29,7 @@ define(function () {
out.websocketError = 'Unable to connect to the websocket server...';
out.typeError = "That realtime document is not compatible with the selected application";
+ out.onLogout = 'You are logged out, click here to log in
or press Escape to access your pad in read-only mode.';
out.loading = "Loading...";
out.error = "Error";
diff --git a/www/code/main.js b/www/code/main.js
index 2e9d2f97b..ba1208a2d 100644
--- a/www/code/main.js
+++ b/www/code/main.js
@@ -719,6 +719,8 @@ define([
var realtime = module.realtime = Realtime.start(config);
editor.on('change', onLocal);
+
+ Cryptpad.onLogout(function () { setEditable(false); });
};
var interval = 100;
diff --git a/www/common/cryptpad-common.js b/www/common/cryptpad-common.js
index 845eafe3e..ff2943c16 100644
--- a/www/common/cryptpad-common.js
+++ b/www/common/cryptpad-common.js
@@ -107,8 +107,18 @@ define([
}
eraseTempSessionValues();
+ logoutHandlers.forEach(function (h) {
+ if (typeof (h) === "function") { h(); }
+ });
+
if (cb) { cb(); }
};
+ var logoutHandlers= [];
+ var onLogout = common.onLogout = function (h) {
+ if (typeof (h) !== "function") { return; }
+ if (logoutHandlers.indexOf(h) !== -1) { return; }
+ logoutHandlers.push(h);
+ };
var getUserHash = common.getUserHash = function () {
var hash;
@@ -760,6 +770,10 @@ define([
var LOADING = 'loading';
common.addLoadingScreen = function () {
+ if ($('#' + LOADING).length) {
+ $('#' + LOADING).show();
+ return;
+ }
var $loading = $('
');
@@ -773,9 +787,10 @@ define([
common.removeLoadingScreen = function (cb) {
$('#' + LOADING).fadeOut(750, cb);
};
- common.errorLoadingScreen = function (error) {
+ common.errorLoadingScreen = function (error, transparent) {
$('.spinnerContainer').hide();
- $('#' + LOADING).find('p').text(error || Messages.error);
+ if (transparent) { $('#' + LOADING).css('opacity', 0.8); }
+ $('#' + LOADING).find('p').html(error || Messages.error);
};
/*
diff --git a/www/common/toolbar.js b/www/common/toolbar.js
index d369e8293..97aa7c535 100644
--- a/www/common/toolbar.js
+++ b/www/common/toolbar.js
@@ -49,6 +49,7 @@ define([
var $style;
+ var connected = false;
var firstConnection = true;
var lagErrors = 0;
@@ -414,14 +415,17 @@ define([
content: Messages.user_rename
});
}
- options.push({
- tag: 'a',
- attributes: {
- 'target': '_blank',
- 'href': '/drive/'
- },
- content: Messages.login_accessDrive
- });
+ var parsed = Cryptpad.parsePadUrl(window.location.href);
+ if (parsed && parsed.type && parsed.type !== 'drive') {
+ options.push({
+ tag: 'a',
+ attributes: {
+ 'target': '_blank',
+ 'href': '/drive/'
+ },
+ content: Messages.login_accessDrive
+ });
+ }
// Add login or logout button depending on the current status
if (account) {
options.push({
@@ -453,6 +457,7 @@ define([
left: true, // Open to the left of the button
};
var $userAdmin = Cryptpad.createDropdown(dropdownConfigUser);
+ $userAdmin.attr('id', 'userDropdown');
$userContainer.append($userAdmin);
$userAdmin.find('a.logout').click(function (e) {
@@ -522,7 +527,7 @@ define([
return true;
});
$input.on('keyup', function (e) {
- if (e.which === 13) {
+ if (e.which === 13 && connected === true) {
var name = $input.val().trim();
if (name === "") {
name = $input.attr('placeholder');
@@ -544,6 +549,7 @@ define([
});
var displayInput = function () {
+ if (connected === false) { return; }
$text.hide();
//$pencilIcon.css('display', 'none');
var inputVal = suggestName() || "";
@@ -575,8 +581,6 @@ define([
var loadElement;
var $stateElement = toolbar.find('.' + STATE_CLS);
- var connected = false;
-
if (config.ifrw) {
var removeDropdowns = function (e) {
$container.find('.cryptpad-dropdown').hide();
@@ -701,12 +705,21 @@ define([
checkLag(getLag, lagElement);
}, 3000);
+ var failed = function () {
+ connected = false;
+ $stateElement.text(Messages.disconnected);
+ checkLag(undefined, lagElement);
+ };
+
+ // On log out, remove permanently the realtime elements of the toolbar
+ Cryptpad.onLogout(function () {
+ failed();
+ $userAdminElement.find('#userDropdown').hide();
+ $(userListElement).hide();
+ });
+
return {
- failed: function () {
- connected = false;
- $stateElement.text(Messages.disconnected);
- checkLag(undefined, lagElement);
- },
+ failed: failed,
reconnecting: function (userId) {
myUserName = userId;
connected = false;
diff --git a/www/drive/main.js b/www/drive/main.js
index 5e5cb7451..6cbad00ec 100644
--- a/www/drive/main.js
+++ b/www/drive/main.js
@@ -30,7 +30,7 @@ define([
editable: false,
Cryptpad: Cryptpad,
loggedIn: Cryptpad.isLoggedIn(),
- mobile: $('body').width() <= 600 // Menu and content area are not inline-block anymore for mobiles
+ mobile: function () { return $('body').width() <= 600; } // Menu and content area are not inline-block anymore for mobiles
};
var stringify = APP.stringify = function (obj) {
@@ -801,7 +801,7 @@ define([
if (!path || path.length === 0) { return; }
var isTrash = filesOp.isPathInTrash(path);
var $title = $('', {'class': 'path unselectable'});
- if (APP.mobile) {
+ if (APP.mobile()) {
return $title;
}
path.forEach(function (p, idx) {
@@ -1170,7 +1170,7 @@ define([
var $toolbar = $driveToolbar;
$toolbar.html('');
var $leftside = $('