You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
cryptpad/customize.dist/template.js

68 lines
2.2 KiB
JavaScript

This file contains invisible Unicode characters!

This file contains invisible Unicode characters that may be processed differently from what appears below. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to reveal hidden characters.

define([
'jquery',
'/common/hyperscript.js',
'/customize/pages.js',
'/bower_components/nthen/index.js',
'css!/bower_components/components-font-awesome/css/font-awesome.min.css',
], function ($, h, Pages, nThen) {
$(function () {
var $body = $('body');
var pathname = location.pathname;
// add class on info-pages
var pageName = pathname.replace(/(index)?\.html$/gi, "") // .html
.replace(/[^a-zA-Z]+/gi, '-') // any non-alpha character
.replace(/^-|-$/g, ''); // starting/trailing dashes
if (pageName === '') { pageName = 'index'; }
$('body').addClass('cp-page-' + pageName);
var infoPage = function () {
return h('div#mainBlock.hidden', typeof(Pages[pathname]) === 'function'?
Pages[pathname](): [h('div#container')]);
};
window.Tether = function () {};
nThen(function (waitFor) {
var w = waitFor();
require([
'/customize/pages/' + pageName + '.js',
], function (Page) {
infoPage = Page;
w();
}, function () {
w();
});
}).nThen(function () {
require([
'less!/customize/src/less2/pages/page-' + pageName + '.less',
'css!/bower_components/bootstrap/dist/css/bootstrap.min.css',
'css!/customize/fonts/cptools/style.css'
], function () {
var $main = $(infoPage());
$body.append($main);
if (/^\/register\//.test(pathname)) {
require([ '/register/main.js' ], function () {});
} else if (/^\/login\//.test(pathname)) {
require([ '/login/main.js' ], function () {});
} else if (/^\/($|^\/index\.html$)/.test(pathname)) {
// TODO use different top bar
require([ '/customize/main.js', ], function () {});
} else if (/invite/.test(pathname)) {
require([ '/invite/main.js'], function () {});
} else if (/faq/.test(pathname)) {
var hash = window.location.hash;
window.location.hash = '';
window.location.hash = hash;
} else {
require([ '/customize/main.js', ], function () {});
}
});
});
});
});