From daf112a5b5a294f38c017aea730ab3c9e9b489fd Mon Sep 17 00:00:00 2001 From: ansuz Date: Tue, 30 May 2017 20:11:15 +0200 Subject: [PATCH] take api settings into account for upgrade button --- customize.dist/main.js | 18 +++++++++++------- www/settings/main.js | 17 +++++++++++------ 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/customize.dist/main.js b/customize.dist/main.js index 4e150682a..b6149b8ef 100644 --- a/customize.dist/main.js +++ b/customize.dist/main.js @@ -1,7 +1,8 @@ define([ 'jquery', '/customize/application_config.js', - '/common/cryptpad-common.js' + '/common/cryptpad-common.js', + '/api/config', ], function ($, Config, Cryptpad, ApiConfig) { window.APP = { @@ -21,6 +22,13 @@ define([ 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 = { @@ -58,17 +66,13 @@ define([ }); }); - if (!localStorage.plan) { - $upgrade.show().text(Messages.upgradeAccount); - } - + showUpgrade(Messages.upgradeAccount); $loggedInBlock.removeClass('hidden'); - //return; } else { $main.find('#userForm').removeClass('hidden'); $('#name').focus(); - $upgrade.show().text(Messages.supportCryptpad); + showUpgrade(Messages.supportCryptpad); } var displayCreateButtons = function () { diff --git a/www/settings/main.js b/www/settings/main.js index 0c16e9864..d02825fc1 100644 --- a/www/settings/main.js +++ b/www/settings/main.js @@ -3,8 +3,9 @@ define([ '/common/cryptpad-common.js', '/common/cryptget.js', '/common/mergeDrive.js', - '/bower_components/file-saver/FileSaver.min.js' -], function ($, Cryptpad, Crypt, Merge) { + '/api/config', + '/bower_components/file-saver/FileSaver.min.js', +], function ($, Cryptpad, Crypt, Merge, ApiConfig) { var saveAs = window.saveAs; var USERNAME_KEY = 'cryptpad.username'; @@ -15,6 +16,12 @@ define([ }; 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; @@ -329,11 +336,9 @@ define([ if (Cryptpad.isLoggedIn()) { - if (!Cryptpad.account.plan) { - $upgrade.text(Messages.upgradeAccount).show(); - } + showUpgrade(Messages.upgradeAccount); } else { - $upgrade.text(Messages.supportCryptpad).show(); + showUpgrade(Messages.supportCryptpad); } };