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

This commit is contained in:
ansuz
2017-06-27 09:57:32 +02:00
10 changed files with 49 additions and 28 deletions

View File

@@ -19,11 +19,11 @@ define([
Alertify._$$alertify.delay = AppConfig.notificationTimeout || 5000;
var findCancelButton = UI.findCancelButton = function () {
return $('button.cancel');
return $('button.cancel').last();
};
var findOKButton = UI.findOKButton = function () {
return $('button.ok');
return $('button.ok').last();
};
var listenForKeys = UI.listenForKeys = function (yes, no) {
@@ -74,14 +74,22 @@ define([
findCancelButton().click();
});
// Make sure we don't call both the "yes" and "no" handlers if we use "findOKButton().click()"
// in the callback
var isClicked = false;
Alertify
.defaultValue(def || '')
.okBtn(opt.ok || Messages.okButton || 'OK')
.cancelBtn(opt.cancel || Messages.cancelButton || 'Cancel')
.prompt(msg, function (val, ev) {
if (isClicked) { return; }
isClicked = true;
cb(val, ev);
stopListening(keyHandler);
}, function (ev) {
if (isClicked) { return; }
isClicked = true;
cb(null, ev);
stopListening(keyHandler);
});
@@ -98,13 +106,21 @@ define([
findCancelButton().click();
});
// Make sure we don't call both the "yes" and "no" handlers if we use "findOKButton().click()"
// in the callback
var isClicked = false;
Alertify
.okBtn(opt.ok || Messages.okButton || 'OK')
.cancelBtn(opt.cancel || Messages.cancelButton || 'Cancel')
.confirm(msg, function () {
if (isClicked) { return; }
isClicked = true;
cb(true);
stopListening(keyHandler);
}, function () {
if (isClicked) { return; }
isClicked = true;
cb(false);
stopListening(keyHandler);
});

View File

@@ -519,9 +519,9 @@ define([
if (_onDisplayNameChanged.indexOf(h) !== -1) { return; }
_onDisplayNameChanged.push(h);
};
common.changeDisplayName = function (newName) {
common.changeDisplayName = function (newName, isLocal) {
_onDisplayNameChanged.forEach(function (h) {
h(newName);
h(newName, isLocal);
});
};

View File

@@ -736,7 +736,7 @@ define([
Cryptpad.prompt(Messages.changeNamePrompt, lastName || '', function (newName) {
if (newName === null && typeof(lastName) === "string") { return; }
if (newName === null) { newName = ''; }
Cryptpad.changeDisplayName(newName);
Cryptpad.changeDisplayName(newName, true);
});
});
});

View File

@@ -2714,6 +2714,7 @@ define([
var toolbar = APP.toolbar = Toolbar.create(config);
var $rightside = toolbar.$rightside;
$rightside.html(''); // Remove the drawer if we don't use it to hide the toolbar
var $leftside = toolbar.$leftside;
var $userBlock = toolbar.$userAdmin;
APP.$displayName = APP.$bar.find('.' + Toolbar.constants.username);
@@ -2749,8 +2750,7 @@ define([
href: window.location.origin + window.location.pathname + '#' + APP.hash
};
var $hist = Cryptpad.createButton('history', true, {histConfig: histConfig});
$rightside.append($hist);
if (!APP.loggedIn) { $hist.hide(); }
if (APP.loggedIn) { $rightside.append($hist); }
if (!readOnly && !APP.loggedIn) {
var $backupButton = Cryptpad.createButton('', true).removeClass('fa').removeClass('fa-question').addClass('cryptpad-backup');

View File

@@ -51,16 +51,9 @@ define([
uploadMode = true;
}
var getTitle = function () {
var pad = Cryptpad.getRelativeHref(window.location.href);
var fo = Cryptpad.getStore().getProxy().fo;
var data = fo.getFileData(pad);
return data ? data.title : undefined;
};
Title = Cryptpad.createTitle({}, function(){}, Cryptpad);
var displayed = ['title', 'useradmin', 'newpad', 'limit', 'upgrade'];
var displayed = ['useradmin', 'newpad', 'limit', 'upgrade'];
if (secret && hexFileName) {
displayed.push('fileshare');
}
@@ -69,30 +62,24 @@ define([
displayed: displayed,
ifrw: ifrw,
common: Cryptpad,
title: Title.getTitleConfig(),
hideDisplayName: true,
$container: $bar
};
var toolbar = APP.toolbar = Toolbar.create(configTb);
toolbar.$rightside.html(''); // Remove the drawer if we don't use it to hide the toolbar
Title.setToolbar(toolbar);
if (uploadMode) { toolbar.title.hide(); }
Title.updateTitle(Cryptpad.initialName || getTitle() || Title.defaultTitle);
if (!uploadMode) {
var src = Cryptpad.getBlobPathFromHex(hexFileName);
var cryptKey = secret.keys && secret.keys.fileKeyStr;
var key = Nacl.util.decodeBase64(cryptKey);
FileCrypto.fetchDecryptedMetadata(src, key, function (e, metadata) {
if (e) { return void console.error(e); }
var title = document.title = metadata.name;
Title.updateTitle(title || Title.defaultTitle);
var displayFile = function (ev) {
var displayFile = function (ev, sizeMb) {
var $mt = $dlview.find('media-tag');
var cryptKey = secret.keys && secret.keys.fileKeyStr;
var hexFileName = Cryptpad.base64ToHex(secret.channel);
@@ -112,6 +99,10 @@ define([
$appContainer.css('background', 'white');
}
$dlButton.addClass('btn btn-success');
var text = Messages.download_mt_button + '<br>';
text += '<b>' + Cryptpad.fixHTML(title) + '</b><br>';
text += '<em>' + Messages._getKey('formattedMB', [sizeMb]) + '</em>';
$dlButton.html(text);
toolbar.$rightside.append(Cryptpad.createButton('export', true, {}, function () {
saveAs(decrypted.blob, decrypted.metadata.name);
@@ -169,14 +160,14 @@ define([
$dlform.show();
Cryptpad.removeLoadingScreen();
$dllabel.append($('<br>'));
$dllabel.append(metadata.name);
$dllabel.append(Cryptpad.fixHTML(metadata.name));
$dllabel.append($('<br>'));
$dllabel.append(Messages._getKey('formattedMB', [sizeMb]));
var decrypting = false;
var onClick = function (ev) {
if (decrypting) { return; }
decrypting = true;
displayFile(ev);
displayFile(ev, sizeMb);
};
if (sizeMb < 5) { return void onClick(); }
$dlform.find('#dl, #progress').click(onClick);