add support for donate button

pull/1/head
ansuz 8 years ago
parent 909bc2ebf3
commit 9ca5bc507e

@ -25,7 +25,9 @@ define([
*/
var common = window.Cryptpad = {
Messages: Messages,
Clipboard: Clipboard
Clipboard: Clipboard,
donateURL: 'https://accounts.cryptpad.fr/#/donate?on=' + window.location.hostname,
account: {},
};
// constants
@ -1428,6 +1430,14 @@ define([
console.log('RPC handshake complete');
rpc = common.rpc = env.rpc = call;
common.getPinLimit(function (e, limit, plan, note) {
if (e) { return void console.error(e); }
common.account.limit = limit;
common.account.plan = plan;
common.account.note = note;
cb();
});
common.arePinsSynced(function (err, yes) {
if (!yes) {
common.resetPins(function (err) {
@ -1436,7 +1446,6 @@ define([
});
}
});
cb();
});
} else if (PINNING_ENABLED) {
console.log('not logged in. pads will not be pinned');

@ -33,6 +33,7 @@ define([
var LIMIT_CLS = Bar.constants.lag = 'cryptpad-limit';
var TITLE_CLS = Bar.constants.title = "cryptpad-title";
var NEWPAD_CLS = Bar.constants.newpad = "cryptpad-newpad";
var UPGRADE_CLS = Bar.constants.upgrade = "cryptpad-upgrade";
// User admin menu
var USERADMIN_CLS = Bar.constants.user = 'cryptpad-user-dropdown';
@ -70,6 +71,7 @@ define([
var $userContainer = $('<span>', {
'class': USER_CLS
}).appendTo($topContainer);
$('<button>', {'class': UPGRADE_CLS}).hide().appendTo($userContainer);
$('<span>', {'class': SPINNER_CLS}).hide().appendTo($userContainer);
$('<span>', {'class': STATE_CLS}).hide().appendTo($userContainer);
$('<span>', {'class': LAG_CLS}).hide().appendTo($userContainer);
@ -595,7 +597,6 @@ define([
'class': 'synced fa fa-check',
title: Messages.synced
}).appendTo($spin);
toolbar.$userAdmin.prepend($spin);
if (config.realtime) {
config.realtime.onPatch(ks(toolbar, config));
config.realtime.onMessage(ks(toolbar, config, true));
@ -696,6 +697,22 @@ define([
return $userAdmin;
};
var createUpgrade = function (toolbar) {
if (ApiConfig.removeDonateButton) { return; }
if (Cryptpad.account.plan) { return; }
var text;
if (ApiConfig.allowSubscriptions && Cryptpad.isLoggedIn()) {
text = Messages.upgradeAccount;
} else { text = Messages.supportCryptpad; }
var $upgrade = toolbar.$top.find('.' + UPGRADE_CLS).attr({
'title': Messages.supportCryptpad
}).text(text).show()
.click(function () { window.open(Cryptpad.donateURL,'_blank'); });
return $upgrade;
};
// Events
var initClickEvents = function (toolbar, config) {
var removeDropdowns = function () {
@ -853,10 +870,10 @@ define([
tb['spinner'] = createSpinner;
tb['state'] = createState;
tb['limit'] = createLimit;
tb['upgrade'] = createUpgrade;
tb['newpad'] = createNewPad;
tb['useradmin'] = createUserAdmin;
var addElement = toolbar.addElement = function (arr, additionnalCfg, init) {
if (typeof additionnalCfg === "object") { $.extend(true, config, additionnalCfg); }
arr.forEach(function (el) {

Loading…
Cancel
Save