Merge branch 'refactor2' into staging
This commit is contained in:
@@ -1,54 +0,0 @@
|
||||
define([
|
||||
'jquery',
|
||||
'/customize/application_config.js',
|
||||
'/common/cryptpad-common.js',
|
||||
'/api/config',
|
||||
], function ($, Config, Cryptpad, ApiConfig) {
|
||||
|
||||
window.APP = {
|
||||
Cryptpad: Cryptpad,
|
||||
};
|
||||
|
||||
var Messages = Cryptpad.Messages;
|
||||
|
||||
$(function () {
|
||||
// Language selector
|
||||
var $sel = $('#language-selector');
|
||||
Cryptpad.createLanguageSelector(undefined, $sel);
|
||||
$sel.find('button').addClass('btn').addClass('btn-secondary');
|
||||
$sel.show();
|
||||
|
||||
var $upgrade = $('#upgrade');
|
||||
|
||||
var showUpgrade = function (text, feedback, url) {
|
||||
if (ApiConfig.removeDonateButton) { return; }
|
||||
if (localStorage.plan) { return; }
|
||||
if (!text) { return; }
|
||||
$upgrade.text(text).show();
|
||||
$upgrade.click(function () {
|
||||
Cryptpad.feedback(feedback);
|
||||
window.open(url,'_blank');
|
||||
});
|
||||
};
|
||||
|
||||
// User admin menu
|
||||
var $userMenu = $('#user-menu');
|
||||
var userMenuCfg = {
|
||||
$initBlock: $userMenu,
|
||||
'static': true
|
||||
};
|
||||
var $userAdmin = Cryptpad.createUserAdminMenu(userMenuCfg);
|
||||
$userAdmin.find('button').addClass('btn').addClass('btn-secondary');
|
||||
|
||||
$(window).click(function () {
|
||||
$('.cp-dropdown-content').hide();
|
||||
});
|
||||
|
||||
if (Cryptpad.isLoggedIn() && ApiConfig.allowSubscriptions) {
|
||||
showUpgrade(Messages.upgradeAccount, "HOME_UPGRADE_ACCOUNT", Cryptpad.upgradeURL);
|
||||
} else {
|
||||
showUpgrade(Messages.supportCryptpad, "HOME_SUPPORT_CRYPTPAD", Cryptpad.donateURL);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -2,15 +2,15 @@ define([
|
||||
'jquery',
|
||||
'/customize/application_config.js',
|
||||
'/common/cryptpad-common.js',
|
||||
'/customize/header.js',
|
||||
], function ($, Config, Cryptpad) {
|
||||
'/common/common-interface.js',
|
||||
'/common/common-realtime.js',
|
||||
'/customize/messages.js',
|
||||
], function ($, Config, Cryptpad, UI, Realtime, Messages) {
|
||||
|
||||
window.APP = {
|
||||
Cryptpad: Cryptpad,
|
||||
};
|
||||
|
||||
var Messages = Cryptpad.Messages;
|
||||
|
||||
$(function () {
|
||||
var $main = $('#mainBlock');
|
||||
|
||||
@@ -58,34 +58,6 @@ define([
|
||||
$('#name').focus();
|
||||
}
|
||||
|
||||
var displayCreateButtons = function () {
|
||||
var $parent = $('#buttons');
|
||||
var options = [];
|
||||
var $container = $('<div>', {'class': 'cp-dropdown-container'}).appendTo($parent);
|
||||
Config.availablePadTypes.forEach(function (el) {
|
||||
if (el === 'drive') { return; }
|
||||
if (!Cryptpad.isLoggedIn() && Config.registeredOnlyTypes &&
|
||||
Config.registeredOnlyTypes.indexOf(el) !== -1) { return; }
|
||||
options.push({
|
||||
tag: 'a',
|
||||
attributes: {
|
||||
'class': 'newdoc',
|
||||
'href': '/' + el + '/',
|
||||
'target': '_blank'
|
||||
},
|
||||
content: Messages['button_new' + el] // Pretty name of the language value
|
||||
});
|
||||
});
|
||||
var dropdownConfig = {
|
||||
text: Messages.login_makeAPad, // Button initial text
|
||||
options: options, // Entries displayed in the menu
|
||||
container: $container
|
||||
};
|
||||
var $block = Cryptpad.createDropdown(dropdownConfig);
|
||||
$block.find('button').addClass('btn').addClass('btn-primary');
|
||||
$block.appendTo($parent);
|
||||
};
|
||||
|
||||
/* Log in UI */
|
||||
var Login;
|
||||
// deferred execution to avoid unnecessary asset loading
|
||||
@@ -116,7 +88,7 @@ define([
|
||||
$('button.login').click(function () {
|
||||
// setTimeout 100ms to remove the keyboard on mobile devices before the loading screen pops up
|
||||
window.setTimeout(function () {
|
||||
Cryptpad.addLoadingScreen({loadingText: Messages.login_hashing});
|
||||
UI.addLoadingScreen({loadingText: Messages.login_hashing});
|
||||
// We need a setTimeout(cb, 0) otherwise the loading screen is only displayed after hashing the password
|
||||
window.setTimeout(function () {
|
||||
loginReady(function () {
|
||||
@@ -135,7 +107,7 @@ define([
|
||||
proxy.edPrivate = result.edPrivate;
|
||||
proxy.edPublic = result.edPublic;
|
||||
|
||||
Cryptpad.whenRealtimeSyncs(result.realtime, function () {
|
||||
Realtime.whenRealtimeSyncs(result.realtime, function () {
|
||||
Cryptpad.login(result.userHash, result.userName, function () {
|
||||
document.location.href = '/drive/';
|
||||
});
|
||||
@@ -144,22 +116,22 @@ define([
|
||||
}
|
||||
switch (err) {
|
||||
case 'NO_SUCH_USER':
|
||||
Cryptpad.removeLoadingScreen(function () {
|
||||
Cryptpad.alert(Messages.login_noSuchUser);
|
||||
UI.removeLoadingScreen(function () {
|
||||
UI.alert(Messages.login_noSuchUser);
|
||||
});
|
||||
break;
|
||||
case 'INVAL_USER':
|
||||
Cryptpad.removeLoadingScreen(function () {
|
||||
Cryptpad.alert(Messages.login_invalUser);
|
||||
UI.removeLoadingScreen(function () {
|
||||
UI.alert(Messages.login_invalUser);
|
||||
});
|
||||
break;
|
||||
case 'INVAL_PASS':
|
||||
Cryptpad.removeLoadingScreen(function () {
|
||||
Cryptpad.alert(Messages.login_invalPass);
|
||||
UI.removeLoadingScreen(function () {
|
||||
UI.alert(Messages.login_invalPass);
|
||||
});
|
||||
break;
|
||||
default: // UNHANDLED ERROR
|
||||
Cryptpad.errorLoadingScreen(Messages.login_unhandledError);
|
||||
UI.errorLoadingScreen(Messages.login_unhandledError);
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -167,27 +139,6 @@ define([
|
||||
}, 100);
|
||||
});
|
||||
/* End Log in UI */
|
||||
|
||||
var addButtonHandlers = function () {
|
||||
$('button.register').click(function () {
|
||||
var username = $('#name').val();
|
||||
var passwd = $('#password').val();
|
||||
sessionStorage.login_user = username;
|
||||
sessionStorage.login_pass = passwd;
|
||||
document.location.href = '/register/';
|
||||
});
|
||||
$('button.gotodrive').click(function () {
|
||||
document.location.href = '/drive/';
|
||||
});
|
||||
|
||||
$('button#loggedInLogout').click(function () {
|
||||
$('#user-menu .logout').click();
|
||||
});
|
||||
};
|
||||
|
||||
displayCreateButtons();
|
||||
|
||||
addButtonHandlers();
|
||||
console.log("ready");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -30,7 +30,6 @@ if (language && map[language]) { req.push('/customize/translations/messages.' +
|
||||
define(req, function($, Default, Language) {
|
||||
map.en = 'English';
|
||||
var defaultLanguage = 'en';
|
||||
console.log(messages);
|
||||
|
||||
if (!Language || language === defaultLanguage || !map[language]) {
|
||||
messages = $.extend(true, messages, Default);
|
||||
@@ -39,7 +38,6 @@ console.log(messages);
|
||||
// Add the translated keys to the returned object
|
||||
messages = $.extend(true, messages, Default, Language);
|
||||
}
|
||||
console.log(messages);
|
||||
|
||||
messages._languages = map;
|
||||
messages._languageUsed = language;
|
||||
|
||||
@@ -488,12 +488,12 @@ define(function () {
|
||||
out.settings_resetTipsButton = "Réinitialiser les astuces visibles dans CryptDrive";
|
||||
out.settings_resetTipsDone = "Toutes les astuces sont de nouveau visibles.";
|
||||
|
||||
out.settings_thumbnails = "Vignettes";
|
||||
out.settings_disableThumbnailsAction = "Désactiver la création de vignettes dans CryptDrive";
|
||||
out.settings_disableThumbnailsDescription = "Des vignettes de vos pads sont automatiquement créées et stockées dans votre navigateur. Vous pouvez désactiver cette fonctionnalité.";
|
||||
out.settings_thumbnails = "Miniatures";
|
||||
out.settings_disableThumbnailsAction = "Désactiver la création de miniatures dans CryptDrive";
|
||||
out.settings_disableThumbnailsDescription = "Des miniatures de vos pads sont automatiquement créées et stockées dans votre navigateur. Vous pouvez désactiver cette fonctionnalité.";
|
||||
out.settings_resetThumbnailsAction = "Nettoyer";
|
||||
out.settings_resetThumbnailsDescription = "Nettoyer toutes les vignettes stockées dans votre navigateur.";
|
||||
out.settings_resetThumbnailsDone = "Toutes les vignettes ont été effacées.";
|
||||
out.settings_resetThumbnailsDescription = "Nettoyer toutes les miniatures stockées dans votre navigateur.";
|
||||
out.settings_resetThumbnailsDone = "Toutes les miniatures ont été effacées.";
|
||||
|
||||
out.settings_importTitle = "Importer les pads récents de ce navigateur dans votre CryptDrive";
|
||||
out.settings_import = "Importer";
|
||||
|
||||
Reference in New Issue
Block a user