Fix the upgrade and donate buttons in the home page

pull/1/head
yflory 8 years ago
parent ee57458158
commit ac91d2f413

@ -3,6 +3,7 @@ define([
'/customize/application_config.js', '/customize/application_config.js',
'/common/cryptpad-common.js', '/common/cryptpad-common.js',
'/api/config', '/api/config',
'/customize/header.js',
], function ($, Config, Cryptpad, ApiConfig) { ], function ($, Config, Cryptpad, ApiConfig) {
window.APP = { window.APP = {
@ -14,29 +15,6 @@ define([
$(function () { $(function () {
var $main = $('#mainBlock'); var $main = $('#mainBlock');
// 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) {
if (ApiConfig.removeDonateButton) { return; }
if (localStorage.plan) { return; }
if (!text) { return; }
$upgrade.text(text).show();
};
// User admin menu
var $userMenu = $('#user-menu');
var userMenuCfg = {
$initBlock: $userMenu
};
var $userAdmin = Cryptpad.createUserAdminMenu(userMenuCfg);
$userAdmin.find('button').addClass('btn').addClass('btn-secondary');
$(window).click(function () { $(window).click(function () {
$('.cryptpad-dropdown').hide(); $('.cryptpad-dropdown').hide();
}); });
@ -66,13 +44,11 @@ define([
}); });
}); });
showUpgrade(Messages.upgradeAccount);
$loggedInBlock.removeClass('hidden'); $loggedInBlock.removeClass('hidden');
} else { }
else {
$main.find('#userForm').removeClass('hidden'); $main.find('#userForm').removeClass('hidden');
$('#name').focus(); $('#name').focus();
showUpgrade(Messages.supportCryptpad);
} }
var displayCreateButtons = function () { var displayCreateButtons = function () {
@ -99,7 +75,6 @@ define([
var $block = Cryptpad.createDropdown(dropdownConfig); var $block = Cryptpad.createDropdown(dropdownConfig);
$block.find('button').addClass('btn').addClass('btn-primary'); $block.find('button').addClass('btn').addClass('btn-primary');
$block.appendTo($parent); $block.appendTo($parent);
}; };
/* Log in UI */ /* Log in UI */

@ -308,7 +308,7 @@ define(function () {
out.login_invalPass = 'Mot de passe requis'; out.login_invalPass = 'Mot de passe requis';
out.login_unhandledError = "Une erreur inattendue s'est produite :("; out.login_unhandledError = "Une erreur inattendue s'est produite :(";
out.login_notRegistered = 'Pas enregistré ?'; out.login_notRegistered = 'Pas encore inscrit ?';
out.register_importRecent = "Importer l'historique (Recommendé)"; out.register_importRecent = "Importer l'historique (Recommendé)";
out.register_acceptTerms = "J'accepte <a href='/terms.html'>les conditions d'utilisation</a>"; out.register_acceptTerms = "J'accepte <a href='/terms.html'>les conditions d'utilisation</a>";

@ -27,6 +27,7 @@ define([
Messages: Messages, Messages: Messages,
Clipboard: Clipboard, Clipboard: Clipboard,
donateURL: 'https://accounts.cryptpad.fr/#/donate?on=' + window.location.hostname, donateURL: 'https://accounts.cryptpad.fr/#/donate?on=' + window.location.hostname,
upgradeURL: 'https://accounts.cryptpad.fr/#/?on=' + window.location.hostname,
account: {}, account: {},
}; };

@ -703,12 +703,15 @@ define([
var text; var text;
var feedback; var feedback;
var url;
if (ApiConfig.allowSubscriptions && Cryptpad.isLoggedIn()) { if (ApiConfig.allowSubscriptions && Cryptpad.isLoggedIn()) {
text = Messages.upgradeAccount; text = Messages.upgradeAccount;
feedback = "UPGRADE_ACCOUNT"; feedback = "UPGRADE_ACCOUNT";
url = Cryptpad.upgradeURL;
} else { } else {
text = Messages.supportCryptpad; text = Messages.supportCryptpad;
feedback = "SUPPORT_CRYPTPAD"; feedback = "SUPPORT_CRYPTPAD";
url = Cryptpad.donateURL;
} }
var $upgrade = toolbar.$top.find('.' + UPGRADE_CLS).attr({ var $upgrade = toolbar.$top.find('.' + UPGRADE_CLS).attr({
@ -716,7 +719,7 @@ define([
}).text(text).show() }).text(text).show()
.click(function () { .click(function () {
Cryptpad.feedback(feedback); Cryptpad.feedback(feedback);
window.open(Cryptpad.donateURL,'_blank'); window.open(url,'_blank');
}); });
return $upgrade; return $upgrade;
}; };

@ -5,6 +5,7 @@ define([
'/common/mergeDrive.js', '/common/mergeDrive.js',
'/api/config', '/api/config',
'/bower_components/file-saver/FileSaver.min.js', '/bower_components/file-saver/FileSaver.min.js',
'/customize/header.js',
], function ($, Cryptpad, Crypt, Merge, ApiConfig) { ], function ($, Cryptpad, Crypt, Merge, ApiConfig) {
var saveAs = window.saveAs; var saveAs = window.saveAs;
@ -15,14 +16,6 @@ define([
_onRefresh: [] _onRefresh: []
}; };
var $upgrade = $('#upgrade');
var showUpgrade = function (text) {
if (ApiConfig.removeDonateButton) { return; }
if (localStorage.plan) { return; }
if (!text) { return; }
$upgrade.text(text).show();
};
var Messages = Cryptpad.Messages; var Messages = Cryptpad.Messages;
// Manage changes in the realtime object made from another page // Manage changes in the realtime object made from another page
@ -333,30 +326,10 @@ define([
APP.$container.append(createUserFeedbackToggle(obj)); APP.$container.append(createUserFeedbackToggle(obj));
obj.proxy.on('change', [], refresh); obj.proxy.on('change', [], refresh);
obj.proxy.on('remove', [], refresh); obj.proxy.on('remove', [], refresh);
if (Cryptpad.isLoggedIn()) {
showUpgrade(Messages.upgradeAccount);
} else {
showUpgrade(Messages.supportCryptpad);
}
}; };
$(function () { $(function () {
var $main = $('#mainBlock'); var $main = $('#mainBlock');
// Language selector
var $sel = $('#language-selector');
Cryptpad.createLanguageSelector(undefined, $sel);
$sel.find('button').addClass('btn').addClass('btn-secondary');
$sel.show();
// User admin menu
var $userMenu = $('#user-menu');
var userMenuCfg = {
$initBlock: $userMenu
};
var $userAdmin = Cryptpad.createUserAdminMenu(userMenuCfg);
$userAdmin.find('button').addClass('btn').addClass('btn-secondary');
$(window).click(function () { $(window).click(function () {
$('.cryptpad-dropdown').hide(); $('.cryptpad-dropdown').hide();

Loading…
Cancel
Save