cryptpad/customize.dist/template.js

53 lines
1.8 KiB
JavaScript
Raw Normal View History

2017-06-22 00:02:38 +08:00
define([
'jquery',
'/common/hyperscript.js',
'/customize/pages.js',
2018-03-22 01:31:53 +08:00
'css!/bower_components/components-font-awesome/css/font-awesome.min.css',
2017-11-21 22:52:21 +08:00
], function ($, h, Pages) {
2017-06-22 00:02:38 +08:00
$(function () {
var $body = $('body');
2017-06-22 17:06:11 +08: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-22 00:02:38 +08:00
2017-06-22 17:06:11 +08:00
var pathname = location.pathname;
2018-03-20 17:44:26 +08: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 17:06:11 +08:00
2017-10-23 17:57:10 +08:00
window.Tether = function () {};
require([
2017-07-22 22:43:53 +08:00
'less!/customize/src/less2/main.less',
2018-03-22 17:49:20 +08:00
'css!/bower_components/bootstrap/dist/css/bootstrap.min.css'
], function () {
$body.append($main);
2017-07-13 00:34:16 +08: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 22:01:50 +08:00
} else if (/invite/.test(pathname)) {
require([ '/invite/main.js'], function () {});
2018-03-13 18:31:08 +08:00
} else if (/faq/.test(pathname)) {
window.location.hash = window.location.hash;
} else {
require([ '/customize/main.js', ], function () {});
}
});
});
});