header.js 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  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. this.language = _LangManager.language;
  10. }
  11. init() {
  12. var rootDoc = document.body
  13. if(_app.indexApp){
  14. rootDoc = _app.indexApp.entry == 'index' ? document.querySelector('#indexPage') : document.querySelector('#app');
  15. //let rootDoc = document.querySelector('#app');
  16. }
  17. let el = document.createElement("div");
  18. el.setAttribute("id", "header");
  19. rootDoc.prepend(el);
  20. document.querySelector("#header").$cell({
  21. id: 'header',
  22. $cell: true,
  23. $type: "div",
  24. $components: [
  25. {
  26. $type: "div",
  27. class: "mdc-layout-grid",
  28. $components: [
  29. {
  30. $type: "div",
  31. class: "mdc-layout-grid__inner",
  32. $components: [
  33. {
  34. $type: "div",
  35. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-12",
  36. $components: [
  37. {
  38. $type: "a",
  39. style: "cursor:pointer; margin-right: 10px",
  40. class: "mdc-typography link-in-text mdc-theme--text-hint-on-background",
  41. $text: "Home",
  42. //href: "/" + desc[2] + '/worlds/' + desc[0] + '/edit', ///:user/worlds/:name/edit
  43. onclick: function (e) {
  44. window.location.pathname = '/'
  45. //window.history.back();
  46. }
  47. },
  48. {
  49. $type: "a",
  50. style: "cursor:pointer; margin-right: 10px",
  51. class: "mdc-typography link-in-text mdc-theme--text-hint-on-background",
  52. $text: "Connection settings",
  53. //href: "/" + desc[2] + '/worlds/' + desc[0] + '/edit', ///:user/worlds/:name/edit
  54. onclick: function (e) {
  55. window.location.pathname = '/settings'
  56. //window.history.back();
  57. }
  58. },
  59. {
  60. $type: "a",
  61. style: "cursor:pointer; margin-right: 40px",
  62. class: "mdc-typography link-in-text mdc-theme--text-hint-on-background",
  63. $text: "Help",
  64. //href: "/" + desc[2] + '/worlds/' + desc[0] + '/edit', ///:user/worlds/:name/edit
  65. href: 'https://www.krestianstvo.org/docs/sdk3'
  66. },
  67. {
  68. $type: "a",
  69. id: 'ruLang',
  70. style: "cursor:pointer; margin-right: 10px",
  71. class: "mdc-typography link-in-text mdc-theme--text-hint-on-background",
  72. $text: "RU",
  73. //href: "/" + desc[2] + '/worlds/' + desc[0] + '/edit', ///:user/worlds/:name/edit
  74. onclick: function (e) {
  75. _LangManager.locale = 'ru';
  76. window.location.reload(true);
  77. }
  78. },
  79. {
  80. $type: "a",
  81. id: 'enLang',
  82. style: "cursor:pointer; margin-right: 10px",
  83. class: "mdc-typography link-in-text mdc-theme--text-hint-on-background",
  84. $text: "EN",
  85. //href: "/" + desc[2] + '/worlds/' + desc[0] + '/edit', ///:user/worlds/:name/edit
  86. onclick: function (e) {
  87. _LangManager.locale = 'en';
  88. window.location.reload(true);
  89. }
  90. }
  91. ]
  92. },
  93. {
  94. $type: "div",
  95. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-12",
  96. $components: [
  97. _app.widgets.divider
  98. ]
  99. }
  100. ]
  101. }
  102. ]
  103. }
  104. ]
  105. })
  106. }
  107. }
  108. export { Header }