cryptpad/customize.dist/template.js

53 lines
1.8 KiB
JavaScript
Raw Normal View History

2017-06-21 16:02:38 +00:00
define([
'jquery',
'/common/hyperscript.js',
'/customize/pages.js',
2018-03-21 17:31:53 +00:00
'css!/bower_components/components-font-awesome/css/font-awesome.min.css',
2017-11-21 14:52:21 +00:00
], function ($, h, Pages) {
2017-06-21 16:02:38 +00:00
$(function () {
var $body = $('body');
2017-06-22 09:06:11 +00:00
var infoPage = function () {
return h('div#mainBlock.hidden', typeof(Pages[location.pathname]) === 'function'?
Pages[location.pathname](): [h('div#container')]);
};
var $main = $(infoPage());
2017-06-21 16:02:38 +00:00
2017-06-22 09:06:11 +00:00
var pathname = location.pathname;
2018-03-20 09:44:26 +00:00
// add class on info-pages
var css = location.pathname.replace(/(index)?\.html$/gi, "") // .html
.replace(/[^a-zA-Z]+/gi, '-') // any non-alpha character
.replace(/^-|-$/g, ''); // starting/trailing dashes
if (css === '') { css = 'index'; }
$('body').addClass('cp-page-' + css);
2017-06-22 09:06:11 +00:00
2017-10-23 09:57:10 +00:00
window.Tether = function () {};
require([
2018-07-14 13:15:23 +00:00
'less!/customize/src/less2/pages/page-' + css + '.less',
2018-03-22 09:49:20 +00:00
'css!/bower_components/bootstrap/dist/css/bootstrap.min.css'
], function () {
$body.append($main);
2017-07-12 16:34:16 +00:00
if (/^\/user\//.test(pathname)) {
require([ '/user/main.js'], function () {});
} else 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 () {});
2017-07-05 14:01:50 +00:00
} else if (/invite/.test(pathname)) {
require([ '/invite/main.js'], function () {});
2018-03-13 10:31:08 +00:00
} else if (/faq/.test(pathname)) {
window.location.hash = window.location.hash;
} else {
require([ '/customize/main.js', ], function () {});
}
});
});
});