diff --git a/customize.dist/pages/index.js b/customize.dist/pages/index.js index 4f233e718..300637748 100644 --- a/customize.dist/pages/index.js +++ b/customize.dist/pages/index.js @@ -97,7 +97,7 @@ define([ ]);*/ var _link = h('a', { - href: "https://opencollective.com/cryptpad/contribute", + href: "https://opencollective.com/cryptpad/", target: '_blank', rel: 'noopener', }); diff --git a/customize.dist/src/less2/include/dropdown.less b/customize.dist/src/less2/include/dropdown.less index 7c316a33a..10044528e 100644 --- a/customize.dist/src/less2/include/dropdown.less +++ b/customize.dist/src/less2/include/dropdown.less @@ -121,6 +121,9 @@ margin: 5px 0px; height: 1px; background: #bbb; + & + hr { + display: none; + } } p { diff --git a/customize.dist/src/less2/include/limit-bar.less b/customize.dist/src/less2/include/limit-bar.less index 3ed7bd454..fe5049249 100644 --- a/customize.dist/src/less2/include/limit-bar.less +++ b/customize.dist/src/less2/include/limit-bar.less @@ -53,12 +53,22 @@ font-weight: bold; } } - .cp-limit-upgrade { - padding: 0; - line-height: 25px; - height: 25px; - margin: 0 3px; - border-radius: 0; + .cp-limit-buttons { + display: flex; + flex-wrap: wrap; + justify-content: space-around; + justify-content: space-evenly; + a { + height: 25px; + display: inline-flex; + align-items: center; + min-width: 200px; + width: 50%; + padding-top: 0; + padding-bottom: 0; + justify-content: center; + flex: 1; + } } } } diff --git a/www/common/application_config_internal.js b/www/common/application_config_internal.js index be0ba3f47..ce71d3927 100644 --- a/www/common/application_config_internal.js +++ b/www/common/application_config_internal.js @@ -156,5 +156,7 @@ define(function() { // by default by the CryptPad developers. config.disableSharedFolders = false; + config.surveyURL = "https://survey.cryptpad.fr/index.php/672782"; + return config; }); diff --git a/www/common/common-ui-elements.js b/www/common/common-ui-elements.js index 26b848ca9..b13353d0e 100644 --- a/www/common/common-ui-elements.js +++ b/www/common/common-ui-elements.js @@ -2205,15 +2205,16 @@ define([ var $limit = $('', {'class': 'cp-limit-bar'}).appendTo($container); var quota = usage/limit; var $usage = $('', {'class': 'cp-limit-usage'}).css('width', quota*100+'%'); + var $buttons = $(h('span.cp-limit-buttons')).appendTo($container); var urls = common.getMetadataMgr().getPrivateData().accounts; var makeDonateButton = function () { var $a = $('', { - 'class': 'cp-limit-upgrade btn btn-success', + 'class': 'cp-limit-upgrade btn btn-primary', href: urls.donateURL, rel: "noreferrer noopener", target: "_blank", - }).text(Messages.supportCryptpad).appendTo($container); + }).text(Messages.crowdfunding_button2).appendTo($buttons); $a.click(function () { Feedback.send('SUPPORT_CRYPTPAD'); }); @@ -2225,7 +2226,7 @@ define([ href: urls.upgradeURL, rel: "noreferrer noopener", target: "_blank", - }).text(Messages.upgradeAccount).appendTo($container); + }).text(Messages.upgradeAccount).appendTo($buttons); $a.click(function () { Feedback.send('UPGRADE_ACCOUNT'); }); @@ -2238,6 +2239,7 @@ define([ } else if (!plan) { // user is logged in and subscriptions are allowed // and they don't have one. show upgrades + makeDonateButton(); makeUpgradeButton(); } else { // they have a plan. show nothing @@ -2548,15 +2550,42 @@ define([ content: h('span', Messages.supportPage || 'Support') }); } - options.push({ - tag: 'a', - attributes: { - 'target': '_blank', - 'href': origin+'/features.html', - 'class': 'fa fa-star-o' - }, - content: h('span', priv.plan ? Messages.settings_cat_subscription : Messages.pricing) - }); + options.push({ tag: 'hr' }); + if (Config.allowSubscriptions) { + options.push({ + tag: 'a', + attributes: { + 'target': '_blank', + 'href': priv.plan ? priv.accounts.upgradeURL : origin+'/features.html', + 'class': 'fa fa-star-o' + }, + content: h('span', priv.plan ? Messages.settings_cat_subscription : Messages.pricing) + }); + } + if (!priv.plan && !Config.removeDonateButton) { + options.push({ + tag: 'a', + attributes: { + 'target': '_blank', + 'rel': 'noopener', + 'href': priv.accounts.donateURL, + 'class': 'fa fa-gift' + }, + content: h('span', Messages.crowdfunding_button2) + }); + } + if (AppConfig.surveyURL) { + options.push({ + tag: 'a', + attributes: { + 'target': '_blank', + 'rel': 'noopener', + 'href': AppConfig.surveyURL, + 'class': 'fa fa-graduation-cap' + }, + content: h('span', Messages.survey) + }); + } options.push({ tag: 'hr' }); // Add login or logout button depending on the current status if (accountName) { @@ -3440,37 +3469,40 @@ define([ setTimeout(function () { common.getAttribute(['general', 'crowdfunding'], function (err, val) { if (err || val === false) { return; } - // Display the popup - var text = Messages.crowdfunding_popup_text; - var yes = h('button.cp-corner-primary', Messages.crowdfunding_popup_yes); - var no = h('button.cp-corner-primary', Messages.crowdfunding_popup_no); - var never = h('button.cp-corner-cancel', Messages.crowdfunding_popup_never); - var actions = h('div', [yes, no, never]); - - var modal = UI.cornerPopup(text, actions, null, {big: true}); - - $(yes).click(function () { - modal.delete(); - common.openURL('https://opencollective.com/cryptpad/contribute'); - Feedback.send('CROWDFUNDING_YES'); - }); - $(modal.popup).find('a').click(function (e) { - e.stopPropagation(); - e.preventDefault(); - modal.delete(); - common.openURL('https://opencollective.com/cryptpad/'); - Feedback.send('CROWDFUNDING_LINK'); - }); - $(no).click(function () { - modal.delete(); - Feedback.send('CROWDFUNDING_NO'); - }); - $(never).click(function () { - modal.delete(); - common.setAttribute(['general', 'crowdfunding'], false); - Feedback.send('CROWDFUNDING_NEVER'); + common.getSframeChannel().query('Q_GET_PINNED_USAGE', null, function (err, obj) { + var quotaMb = obj.quota / (1024 * 1024); + if (quotaMb < 10) { return; } + // Display the popup + var text = Messages.crowdfunding_popup_text; + var yes = h('button.cp-corner-primary', Messages.crowdfunding_popup_yes); + var no = h('button.cp-corner-primary', Messages.crowdfunding_popup_no); + var never = h('button.cp-corner-cancel', Messages.crowdfunding_popup_never); + var actions = h('div', [yes, no, never]); + + var modal = UI.cornerPopup(text, actions, null, {big: true}); + + $(yes).click(function () { + modal.delete(); + common.openURL(priv.accounts.donateURL); + Feedback.send('CROWDFUNDING_YES'); + }); + $(modal.popup).find('a').click(function (e) { + e.stopPropagation(); + e.preventDefault(); + modal.delete(); + common.openURL(priv.accounts.donateURL); + Feedback.send('CROWDFUNDING_LINK'); + }); + $(no).click(function () { + modal.delete(); + Feedback.send('CROWDFUNDING_NO'); + }); + $(never).click(function () { + modal.delete(); + common.setAttribute(['general', 'crowdfunding'], false); + Feedback.send('CROWDFUNDING_NEVER'); + }); }); - }); }, 5000); }; diff --git a/www/common/cryptpad-common.js b/www/common/cryptpad-common.js index 2dbf772dc..7f16fa860 100644 --- a/www/common/cryptpad-common.js +++ b/www/common/cryptpad-common.js @@ -42,7 +42,8 @@ define([ var origin = encodeURIComponent(window.location.hostname); var common = window.Cryptpad = { Messages: Messages, - donateURL: 'https://accounts.cryptpad.fr/#/donate?on=' + origin, + //donateURL: 'https://accounts.cryptpad.fr/#/donate?on=' + origin, + donateURL: "https://opencollective.com/cryptpad/", upgradeURL: 'https://accounts.cryptpad.fr/#/?on=' + origin, account: {}, }; diff --git a/www/common/sframe-common-outer.js b/www/common/sframe-common-outer.js index a2c909c50..e919f1506 100644 --- a/www/common/sframe-common-outer.js +++ b/www/common/sframe-common-outer.js @@ -376,6 +376,14 @@ define([ }); }); + sframeChan.on('Q_GET_PINNED_USAGE', function (data, cb) { + Cryptpad.getPinnedUsage({}, function (e, used) { + cb({ + error: e, + quota: used + }); + }); + }); sframeChan.on('Q_GET_PIN_LIMIT_STATUS', function (data, cb) { Cryptpad.isOverPinLimit(null, function (e, overLimit, limits) { cb({ diff --git a/www/common/translations/messages.fr.json b/www/common/translations/messages.fr.json index d585d6e02..2042f11c1 100644 --- a/www/common/translations/messages.fr.json +++ b/www/common/translations/messages.fr.json @@ -1000,10 +1000,12 @@ "crowdfunding_home1": "CryptPad a besoin d'aide !", "crowdfunding_home2": "Cliquez sur le bouton pour découvrir notre campagne de financement participatif.", "crowdfunding_button": "Soutenir CryptPad", + "crowdfunding_button2": "Aider CryptPad", "crowdfunding_popup_text": "

Aider CryptPad

Pour vous assurer que CryptPad soit activement développé, nous vous invitons à supporter le projet via la
page OpenCollective, où vous pouvez trouver notre Roadmap et nos objectifs de financement.", "crowdfunding_popup_yes": "Voir la page", "crowdfunding_popup_no": "Pas maintenant", "crowdfunding_popup_never": "Ne plus demander", + "survey": "Enquête CryptPad", "markdown_toc": "Sommaire", "debug_getGraph": "Obtenir le code permettant de générer un graphe de ce document", "debug_getGraphWait": "Génération du graphe... Veuillez patienter.", diff --git a/www/common/translations/messages.json b/www/common/translations/messages.json index feab1a206..3c1cf5077 100644 --- a/www/common/translations/messages.json +++ b/www/common/translations/messages.json @@ -1020,10 +1020,12 @@ "crowdfunding_home1": "CryptPad needs your help!", "crowdfunding_home2": "Click on the button to learn about our crowdfunding campaign.", "crowdfunding_button": "Support CryptPad", + "crowdfunding_button2": "Help CryptPad", "crowdfunding_popup_text": "

We need your help!

To ensure that CryptPad is actively developed, consider supporting the project via the OpenCollective page, where you can see our Roadmap and Funding goals.", "crowdfunding_popup_yes": "Go to OpenCollective", "crowdfunding_popup_no": "Not now", "crowdfunding_popup_never": "Don't ask me again", + "survey": "CryptPad survey", "markdown_toc": "Contents", "fm_expirablePad": "This pad will expire on {0}", "admin_authError": "Only administrators can access this page", diff --git a/www/teams/app-team.less b/www/teams/app-team.less index d517b73d3..b99afa42f 100644 --- a/www/teams/app-team.less +++ b/www/teams/app-team.less @@ -47,7 +47,7 @@ height: 100%; } } - .cp-limit-upgrade { + .cp-limit-buttons { display: none; } }