You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

67 lines
2.2 KiB

  1. define([
  2. 'jquery',
  3. '/common/hyperscript.js',
  4. '/customize/pages.js',
  5. '/bower_components/nthen/index.js',
  6. 'css!/bower_components/components-font-awesome/css/font-awesome.min.css',
  7. ], function ($, h, Pages, nThen) {
  8. $(function () {
  9. var $body = $('body');
  10. var pathname = location.pathname;
  11. // add class on info-pages
  12. var pageName = pathname.replace(/(index)?\.html$/gi, "") // .html
  13. .replace(/[^a-zA-Z]+/gi, '-') // any non-alpha character
  14. .replace(/^-|-$/g, ''); // starting/trailing dashes
  15. if (pageName === '') { pageName = 'index'; }
  16. $('body').addClass('cp-page-' + pageName);
  17. var infoPage = function () {
  18. return h('div#mainBlock.hidden', typeof(Pages[pathname]) === 'function'?
  19. Pages[pathname](): [h('div#container')]);
  20. };
  21. window.Tether = function () {};
  22. nThen(function (waitFor) {
  23. var w = waitFor();
  24. require([
  25. '/customize/pages/' + pageName + '.js',
  26. ], function (Page) {
  27. infoPage = Page;
  28. w();
  29. }, function () {
  30. w();
  31. });
  32. }).nThen(function () {
  33. require([
  34. 'less!/customize/src/less2/pages/page-' + pageName + '.less',
  35. 'css!/bower_components/bootstrap/dist/css/bootstrap.min.css',
  36. 'css!/customize/fonts/cptools/style.css'
  37. ], function () {
  38. var $main = $(infoPage());
  39. $body.append($main);
  40. if (/^\/register\//.test(pathname)) {
  41. require([ '/register/main.js' ], function () {});
  42. } else if (/^\/login\//.test(pathname)) {
  43. require([ '/login/main.js' ], function () {});
  44. } else if (/^\/($|^\/index\.html$)/.test(pathname)) {
  45. // TODO use different top bar
  46. require([ '/customize/main.js', ], function () {});
  47. } else if (/invite/.test(pathname)) {
  48. require([ '/invite/main.js'], function () {});
  49. } else if (/faq/.test(pathname)) {
  50. var hash = window.location.hash;
  51. window.location.hash = '';
  52. window.location.hash = hash;
  53. } else {
  54. require([ '/customize/main.js', ], function () {});
  55. }
  56. });
  57. });
  58. });
  59. });