header.js 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. /*
  2. The MIT License (MIT)
  3. Copyright (c) 2014-2018 Nikolai Suslov and the Krestianstvo.org project contributors. (https://github.com/NikolaySuslov/livecodingspace/blob/master/LICENSE.md)
  4. */
  5. //import page from '/lib/page.mjs';
  6. class Header {
  7. constructor() {
  8. console.log("header constructor");
  9. }
  10. init() {
  11. var rootDoc = document.body
  12. if(_app.indexApp){
  13. rootDoc = _app.indexApp.entry == 'index' ? document.querySelector('#indexPage') : document.querySelector('#app');
  14. //let rootDoc = document.querySelector('#app');
  15. }
  16. let el = document.createElement("div");
  17. el.setAttribute("id", "header");
  18. rootDoc.prepend(el);
  19. document.querySelector("#header").$cell({
  20. id: 'header',
  21. $cell: true,
  22. $type: "div",
  23. $components: [
  24. {
  25. $type: "div",
  26. class: "mdc-layout-grid",
  27. $components: [
  28. {
  29. $type: "div",
  30. class: "mdc-layout-grid__inner",
  31. $components: [
  32. {
  33. $type: "div",
  34. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-12",
  35. $components: [
  36. {
  37. $type: "a",
  38. style: "cursor:pointer; margin-right: 10px",
  39. class: "mdc-typography link-in-text mdc-theme--text-hint-on-background",
  40. $text: _l.t("header_home"),//"Home",
  41. //href: "/" + desc[2] + '/worlds/' + desc[0] + '/edit', ///:user/worlds/:name/edit
  42. onclick: function (e) {
  43. window.location.pathname = '/'
  44. //window.history.back();
  45. }
  46. },
  47. {
  48. $type: "a",
  49. style: "cursor:pointer; margin-right: 10px",
  50. class: "mdc-typography link-in-text mdc-theme--text-hint-on-background",
  51. $text: _l.t("conn_settings"),
  52. //href: "/" + desc[2] + '/worlds/' + desc[0] + '/edit', ///:user/worlds/:name/edit
  53. onclick: function (e) {
  54. window.location.pathname = '/settings'
  55. //window.history.back();
  56. }
  57. },
  58. {
  59. $type: "a",
  60. style: "cursor:pointer; margin-right: 40px",
  61. class: "mdc-typography link-in-text mdc-theme--text-hint-on-background",
  62. $text: _l.t("help"),
  63. //href: "/" + desc[2] + '/worlds/' + desc[0] + '/edit', ///:user/worlds/:name/edit
  64. href: 'https://www.krestianstvo.org/docs/sdk3'
  65. },
  66. {
  67. $type: "a",
  68. id: 'ruLang',
  69. style: "cursor:pointer; margin-right: 10px",
  70. class: "mdc-typography link-in-text mdc-theme--text-hint-on-background",
  71. $text: _l.t("ru"),
  72. //href: "/" + desc[2] + '/worlds/' + desc[0] + '/edit', ///:user/worlds/:name/edit
  73. onclick: function (e) {
  74. _LangManager.locale = 'ru';
  75. window.location.reload(true);
  76. }
  77. },
  78. {
  79. $type: "a",
  80. id: 'enLang',
  81. style: "cursor:pointer; margin-right: 10px",
  82. class: "mdc-typography link-in-text mdc-theme--text-hint-on-background",
  83. $text: _l.t("en"),
  84. //href: "/" + desc[2] + '/worlds/' + desc[0] + '/edit', ///:user/worlds/:name/edit
  85. onclick: function (e) {
  86. _LangManager.locale = 'en';
  87. window.location.reload(true);
  88. }
  89. }
  90. ]
  91. },
  92. {
  93. $type: "div",
  94. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-12",
  95. $components: [
  96. _app.widgets.divider
  97. ]
  98. }
  99. ]
  100. }
  101. ]
  102. }
  103. ]
  104. })
  105. }
  106. }
  107. export { Header }