cryptpad/customize.dist/pages.js

163 lines
6.5 KiB
JavaScript
Raw Normal View History

2017-06-21 16:02:38 +00:00
define([
'/common/hyperscript.js',
'/common/common-language.js',
'/customize/application_config.js',
2017-09-07 14:39:20 +00:00
'/customize/messages.js',
'jquery',
], function (h, Language, AppConfig, Msg, $) {
2017-06-21 16:02:38 +00:00
var Pages = {};
Pages.setHTML = function (e, html) {
e.innerHTML = html;
return e;
};
2017-06-21 16:02:38 +00:00
var languageSelector = function () {
var options = [];
var languages = Msg._languages;
var selected = Msg._languageUsed;
var keys = Object.keys(languages).sort();
keys.forEach(function (l) {
var attr = { value: l };
if (selected === l) { attr.selected = 'selected'; }
options.push(h('option', attr, languages[l]));
});
var select = h('select', {}, options);
$(select).change(function () {
Language.setLanguage($(select).val() || '', null, function () {
window.location.reload();
});
});
return select;
};
var footerCol = function (title, L, literal) {
return h('div.col-6.col-sm-3', [
h('ul.list-unstyled', [
2017-08-04 15:44:02 +00:00
h('li.footer-title', {
'data-localization': title,
}, title? Msg[title]: literal )
].concat(L.map(function (l) {
return h('li', [ l ]);
}))
)
]);
};
var footLink = function (ref, loc, text) {
var attrs = {
href: ref,
};
if (!/^\//.test(ref)) {
attrs.target = '_blank';
attrs.rel = 'noopener noreferrer';
}
if (loc) {
attrs['data-localization'] = loc;
text = Msg[loc];
}
return h('a', attrs, text);
};
var imprintUrl = AppConfig.imprint && (typeof(AppConfig.imprint) === "boolean" ?
'/imprint.html' : AppConfig.imprint);
Pages.infopageFooter = function () {
return h('footer', [
h('div.container', [
h('div.row', [
footerCol(null, [
2017-08-16 08:51:08 +00:00
h('div.cp-bio-foot', [
h('p', Msg.main_footerText),
languageSelector()
2017-08-16 08:51:08 +00:00
])
], ''),
/*footerCol('footer_applications', [
footLink('/drive/', 'main_drive'),
footLink('/pad/', 'main_richText'),
footLink('/code/', 'main_code'),
footLink('/slide/', 'main_slide'),
footLink('/poll/', 'main_poll'),
2018-04-01 16:52:21 +00:00
footLink('/kanban/', 'main_kanban'),
footLink('/whiteboard/', null, Msg.type.whiteboard)
]),*/
footerCol('footer_product', [
2019-04-01 13:36:31 +00:00
footLink('https://cryptpad.fr/what-is-cryptpad.html', 'topbar_whatIsCryptpad'),
footLink('/faq.html', 'faq_link'),
footLink('https://github.com/xwiki-labs/cryptpad', null, 'GitHub'),
footLink('https://opencollective.com/cryptpad/contribute/', 'footer_donate'),
]),
footerCol('footer_aboutUs', [
/*footLink('https://blog.cryptpad.fr', 'blog'),
footLink('https://labs.xwiki.com', null, 'XWiki Labs'),*/
footLink('http://www.xwiki.com', null, 'XWiki SAS'),
footLink('https://www.open-paas.org', null, 'OpenPaaS'),
footLink('/about.html', 'footer_team'),
footLink('/contact.html', 'contact'),
]),
footerCol('footer_legal', [
footLink('/terms.html', 'footer_tos'),
footLink('/privacy.html', 'privacy'),
AppConfig.imprint ? footLink(imprintUrl, 'imprint') : undefined,
]),
/*footerCol('footer_contact', [
footLink('https://riot.im/app/#/room/#cryptpad:matrix.org', null, 'Chat'),
footLink('https://twitter.com/cryptpad', null, 'Twitter'),
footLink('https://github.com/xwiki-labs/cryptpad', null, 'GitHub'),
footLink('/contact.html', null, 'Email')
])*/
])
]),
2020-04-06 15:26:34 +00:00
h('div.cp-version-footer', "CryptPad v3.15.0 (PigFootedBandicoot)")
]);
};
Pages.infopageTopbar = function () {
2017-08-04 14:48:01 +00:00
var rightLinks;
var username = window.localStorage.getItem('User_name');
if (username === null) {
rightLinks = [
h('a.nav-item.nav-link.cp-login-btn', { href: '/login/'}, Msg.login_login),
h('a.nav-item.nav-link.cp-register-btn', { href: '/register/'}, Msg.login_register)
2017-08-04 14:48:01 +00:00
];
} else {
rightLinks = h('a.nav-item.nav-link.cp-user-btn', { href: '/drive/' }, [
2017-08-04 14:48:01 +00:00
h('i.fa.fa-user-circle'),
" ",
username
]);
}
2018-03-22 09:49:20 +00:00
var button = h('button.navbar-toggler', {
'type':'button',
/*'data-toggle':'collapse',
'data-target':'#menuCollapse',
'aria-controls': 'menuCollapse',
'aria-expanded':'false',
'aria-label':'Toggle navigation'*/
}, h('i.fa.fa-bars '));
$(button).click(function () {
if ($('#menuCollapse').is(':visible')) {
return void $('#menuCollapse').slideUp();
}
$('#menuCollapse').slideDown();
});
2018-03-20 10:05:43 +00:00
return h('nav.navbar.navbar-expand-lg',
h('a.navbar-brand', { href: '/index.html'}),
2018-03-22 09:49:20 +00:00
button,
2018-03-20 10:05:43 +00:00
h('div.collapse.navbar-collapse.justify-content-end#menuCollapse', [
//h('a.nav-item.nav-link', { href: '/what-is-cryptpad.html'}, Msg.topbar_whatIsCryptpad), // Moved the FAQ
//h('a.nav-item.nav-link', { href: '/faq.html'}, Msg.faq_link),
2018-03-20 10:05:43 +00:00
h('a.nav-item.nav-link', { href: 'https://blog.cryptpad.fr/'}, Msg.blog),
2019-08-23 14:19:45 +00:00
h('a.nav-item.nav-link', { href: '/features.html'}, Msg.pricing),
2018-03-20 10:05:43 +00:00
h('a.nav-item.nav-link', { href: '/privacy.html'}, Msg.privacy),
//h('a.nav-item.nav-link', { href: '/contact.html'}, Msg.contact),
//h('a.nav-item.nav-link', { href: '/about.html'}, Msg.about),
2018-03-20 10:05:43 +00:00
].concat(rightLinks))
);
};
2017-06-21 16:02:38 +00:00
return Pages;
});