@jsenv/plugin-toolbar 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (117) hide show
  1. package/dist/css/toolbar_main.css +784 -0
  2. package/dist/html/toolbar.html +305 -0
  3. package/dist/js/toolbar_injector.js +300 -0
  4. package/dist/js/toolbar_main.js +900 -0
  5. package/dist/jsenv_plugin_toolbar.js +51 -0
  6. package/dist/other/jsenv_logo.svg +140 -0
  7. package/package.json +30 -0
  8. package/scripts/build.mjs +20 -0
  9. package/src/client/animation/toolbar_animation_core.js +30 -0
  10. package/src/client/animation/toolbar_animation_ui.js +21 -0
  11. package/src/client/communication/parent_window_communication.js +33 -0
  12. package/src/client/eventsource/eventsource.css +83 -0
  13. package/src/client/eventsource/toolbar_eventsource.js +57 -0
  14. package/src/client/execution/execution.css +79 -0
  15. package/src/client/execution/toolbar_execution.js +88 -0
  16. package/src/client/focus/focus.css +61 -0
  17. package/src/client/focus/toolbar_focus.js +19 -0
  18. package/src/client/jsenv_logo.svg +140 -0
  19. package/src/client/notification/toolbar_notification.js +181 -0
  20. package/src/client/responsive/overflow_menu.css +61 -0
  21. package/src/client/responsive/toolbar_responsive.js +103 -0
  22. package/src/client/settings/settings.css +201 -0
  23. package/src/client/settings/toolbar_settings.js +47 -0
  24. package/src/client/theme/jsenv_theme.css +77 -0
  25. package/src/client/theme/light_theme.css +106 -0
  26. package/src/client/theme/toolbar_theme.js +34 -0
  27. package/src/client/toolbar.html +452 -0
  28. package/src/client/toolbar_injector.js +230 -0
  29. package/src/client/toolbar_main.css +173 -0
  30. package/src/client/toolbar_main.js +174 -0
  31. package/src/client/toolbar_state.js +16 -0
  32. package/src/client/tooltip/tooltip.css +61 -0
  33. package/src/client/tooltip/tooltip.js +39 -0
  34. package/src/client/util/animation.js +305 -0
  35. package/src/client/util/dom.js +108 -0
  36. package/src/client/util/fetch_using_xhr.js +400 -0
  37. package/src/client/util/fetching.js +14 -0
  38. package/src/client/util/iframe_to_parent_href.js +10 -0
  39. package/src/client/util/jsenv_logger.js +28 -0
  40. package/src/client/util/preferences.js +10 -0
  41. package/src/client/util/responsive.js +112 -0
  42. package/src/client/util/util.js +19 -0
  43. package/src/client/variant/variant.js +74 -0
  44. package/src/jsenv_plugin_toolbar.js +63 -0
  45. package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/packages/ast/src/html/html_src_set.js +18 -0
  46. package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/packages/jsenv-plugin-toolbar/src/client/animation/toolbar_animation.js +45 -0
  47. package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/packages/jsenv-plugin-toolbar/src/client/animation/toolbar_animation.js.map +12 -0
  48. package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/packages/jsenv-plugin-toolbar/src/client/animation/toolbar_animation_core.js +32 -0
  49. package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/packages/jsenv-plugin-toolbar/src/client/animation/toolbar_animation_core.js.map +12 -0
  50. package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/packages/jsenv-plugin-toolbar/src/client/animation/toolbar_animation_ui.js +23 -0
  51. package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/packages/jsenv-plugin-toolbar/src/client/animation/toolbar_animation_ui.js.map +12 -0
  52. package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/packages/jsenv-plugin-toolbar/src/client/communication/parent_window_communication.js +33 -0
  53. package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/packages/jsenv-plugin-toolbar/src/client/eventsource/eventsource.css +87 -0
  54. package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/packages/jsenv-plugin-toolbar/src/client/eventsource/toolbar_eventsource.js +59 -0
  55. package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/packages/jsenv-plugin-toolbar/src/client/eventsource/toolbar_eventsource.js.map +12 -0
  56. package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/packages/jsenv-plugin-toolbar/src/client/execution/execution.css +88 -0
  57. package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/packages/jsenv-plugin-toolbar/src/client/execution/toolbar_execution.js +90 -0
  58. package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/packages/jsenv-plugin-toolbar/src/client/execution/toolbar_execution.js.map +12 -0
  59. package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/packages/jsenv-plugin-toolbar/src/client/focus/focus.css +28 -0
  60. package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/packages/jsenv-plugin-toolbar/src/client/focus/toolbar_focus.js +19 -0
  61. package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/packages/jsenv-plugin-toolbar/src/client/jsenv_logo.svg +140 -0
  62. package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/packages/jsenv-plugin-toolbar/src/client/notification/toolbar_notification.js +183 -0
  63. package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/packages/jsenv-plugin-toolbar/src/client/notification/toolbar_notification.js.map +12 -0
  64. package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/packages/jsenv-plugin-toolbar/src/client/responsive/overflow_menu.css +60 -0
  65. package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/packages/jsenv-plugin-toolbar/src/client/responsive/toolbar_responsive.js +105 -0
  66. package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/packages/jsenv-plugin-toolbar/src/client/responsive/toolbar_responsive.js.map +12 -0
  67. package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/packages/jsenv-plugin-toolbar/src/client/settings/settings.css +200 -0
  68. package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/packages/jsenv-plugin-toolbar/src/client/settings/toolbar_settings.js +49 -0
  69. package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/packages/jsenv-plugin-toolbar/src/client/settings/toolbar_settings.js.map +12 -0
  70. package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/packages/jsenv-plugin-toolbar/src/client/theme/light_theme.css +110 -0
  71. package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/packages/jsenv-plugin-toolbar/src/client/theme/toolbar_theme.js +36 -0
  72. package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/packages/jsenv-plugin-toolbar/src/client/theme/toolbar_theme.js.map +12 -0
  73. package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/packages/jsenv-plugin-toolbar/src/client/toolbar.html +319 -0
  74. package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/packages/jsenv-plugin-toolbar/src/client/toolbar_injector.js +232 -0
  75. package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/packages/jsenv-plugin-toolbar/src/client/toolbar_injector.js.map +12 -0
  76. package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/packages/jsenv-plugin-toolbar/src/client/toolbar_main.css +161 -0
  77. package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/packages/jsenv-plugin-toolbar/src/client/toolbar_main.css.map +12 -0
  78. package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/packages/jsenv-plugin-toolbar/src/client/toolbar_main.js +176 -0
  79. package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/packages/jsenv-plugin-toolbar/src/client/toolbar_main.js.map +12 -0
  80. package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/packages/jsenv-plugin-toolbar/src/client/toolbar_state.js +18 -0
  81. package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/packages/jsenv-plugin-toolbar/src/client/toolbar_state.js.map +12 -0
  82. package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/packages/jsenv-plugin-toolbar/src/client/tooltip/tooltip.css +60 -0
  83. package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/packages/jsenv-plugin-toolbar/src/client/tooltip/tooltip.js +41 -0
  84. package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/packages/jsenv-plugin-toolbar/src/client/tooltip/tooltip.js.map +12 -0
  85. package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/packages/jsenv-plugin-toolbar/src/client/util/animation.js +307 -0
  86. package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/packages/jsenv-plugin-toolbar/src/client/util/animation.js.map +12 -0
  87. package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/packages/jsenv-plugin-toolbar/src/client/util/dom.js +108 -0
  88. package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/packages/jsenv-plugin-toolbar/src/client/util/iframe_to_parent_href.js +10 -0
  89. package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/packages/jsenv-plugin-toolbar/src/client/util/preferences.js +10 -0
  90. package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/packages/jsenv-plugin-toolbar/src/client/util/responsive.js +112 -0
  91. package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/packages/jsenv-plugin-toolbar/src/client/variant/variant.js +74 -0
  92. package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/src/plugins/autoreload/client/autoreload.js +201 -0
  93. package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/src/plugins/autoreload/client/autoreload.js.map +12 -0
  94. package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/src/plugins/autoreload/client/autoreload_preference.js +11 -0
  95. package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/src/plugins/autoreload/client/reload.js +138 -0
  96. package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/src/plugins/autoreload/client/reload.js.map +12 -0
  97. package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/src/plugins/autoreload/client/url_helpers.js +20 -0
  98. package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/src/plugins/explorer/client/explorer.html +590 -0
  99. package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/src/plugins/explorer/client/explorer.html@L15C5-L20C12.js +7 -0
  100. package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/src/plugins/explorer/client/explorer.html@L15C5-L20C12.js.map +12 -0
  101. package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/src/plugins/explorer/client/explorer.html@L368C5-L481C14.js +114 -0
  102. package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/src/plugins/explorer/client/explorer.html@L482C5-L605C14.js +124 -0
  103. package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/src/plugins/explorer/client/explorer.html@L69C5-L299C13.css +227 -0
  104. package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/src/plugins/explorer/client/explorer.html@L8C5-L68C13.css +28 -0
  105. package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/src/plugins/import_meta_hot/client/import_meta_hot.js +82 -0
  106. package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/src/plugins/ribbon/client/ribbon.js +51 -0
  107. package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/src/plugins/server_events/client/connection_manager.js +165 -0
  108. package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/src/plugins/server_events/client/events_manager.js +75 -0
  109. package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/src/plugins/server_events/client/server_events_client.js +20 -0
  110. package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/src/plugins/server_events/client/server_events_client.js.map +12 -0
  111. package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/src/plugins/server_events/client/web_socket_connection.js +83 -0
  112. package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/src/plugins/server_events/client/web_socket_connection.js.map +12 -0
  113. package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/src/plugins/supervisor/client/script_type_module_supervisor.js +98 -0
  114. package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/src/plugins/supervisor/client/supervisor.js +966 -0
  115. package/tests/toolbar_basic/main.html +18 -0
  116. package/tests/toolbar_basic/start_dev_server.mjs +7 -0
  117. package/todo.txt +0 -0
@@ -0,0 +1,173 @@
1
+ @import "./execution/execution.css";
2
+ @import "./focus/focus.css";
3
+ @import "./eventsource/eventsource.css";
4
+ @import "./responsive/overflow_menu.css";
5
+ @import "./settings/settings.css";
6
+ @import "./theme/light_theme.css";
7
+ @import "./tooltip/tooltip.css";
8
+
9
+ html[data-animation-disabled] * {
10
+ transition: none !important;
11
+ animation-duration: 0s !important;
12
+ animation-delay: 0s !important;
13
+ }
14
+
15
+ [data-when] {
16
+ display: none !important;
17
+ }
18
+
19
+ * {
20
+ box-sizing: border-box;
21
+ }
22
+
23
+ html,
24
+ body {
25
+ margin: 0;
26
+ padding: 0;
27
+ height: 100%;
28
+ }
29
+
30
+ html {
31
+ font-family: arial, sans;
32
+ }
33
+
34
+ /* global utils */
35
+ [data-force-hide] {
36
+ display: none !important;
37
+ }
38
+
39
+ #toolbar-overlay {
40
+ position: fixed;
41
+ left: 0;
42
+ top: 0;
43
+ width: 100%;
44
+ height: 100%;
45
+ filter: url(#better-blur);
46
+ background-color: rgba(0, 0, 0, 0.2);
47
+ }
48
+
49
+ #toolbar {
50
+ position: fixed;
51
+ bottom: 0;
52
+ height: 40px;
53
+ width: 100%;
54
+ background: #404040;
55
+ }
56
+
57
+ #toolbar-wrapper {
58
+ display: table;
59
+ width: 100%;
60
+ height: 100%;
61
+ }
62
+
63
+ #toolbar-wrapper > * {
64
+ display: table-cell;
65
+ vertical-align: middle;
66
+ }
67
+
68
+ #toolbar button {
69
+ background: none;
70
+ border: none;
71
+ height: 100%;
72
+ padding: 0;
73
+ }
74
+
75
+ #toolbar button:hover {
76
+ cursor: pointer;
77
+ }
78
+
79
+ #toolbar a:hover {
80
+ cursor: pointer;
81
+ }
82
+
83
+ /* file and settings icons */
84
+ #fileIconSvg,
85
+ .settings-icon {
86
+ width: 20px;
87
+ }
88
+
89
+ .iconToolbar {
90
+ height: 40px;
91
+ fill: #cecece;
92
+ color: #cecece;
93
+ }
94
+
95
+ .iconToolbar:hover {
96
+ fill: #909090 !important;
97
+ }
98
+
99
+ .toolbar-icon-wrapper {
100
+ height: 100%;
101
+ text-align: center;
102
+ width: 40px;
103
+ display: inline-block;
104
+ }
105
+
106
+ #file-list-link[data-active] a {
107
+ background: #1f262c;
108
+ }
109
+
110
+ #file[data-active] {
111
+ background: rgba(31, 38, 44, 0.72);
112
+ }
113
+
114
+ #settings[data-active] button {
115
+ background: #030713;
116
+ }
117
+
118
+ /* close icon */
119
+ #crossIconSvg {
120
+ width: 18px;
121
+ }
122
+
123
+ /* re-open toolbar-trigger */
124
+ #toolbar-trigger {
125
+ display: block;
126
+ overflow: hidden;
127
+ position: absolute;
128
+ bottom: -32px;
129
+ right: 20px;
130
+ height: 40px;
131
+ width: 40px;
132
+ padding: 0;
133
+ border-radius: 5px 5px 0 0;
134
+ border: 1px solid rgba(0, 0, 0, 0.33);
135
+ border-bottom: none;
136
+ box-shadow: 0px 0px 6px 2px rgba(0, 0, 0, 0.46);
137
+ background: transparent;
138
+ }
139
+
140
+ #toolbar-trigger[data-animate] {
141
+ transition: 600ms;
142
+ }
143
+
144
+ #toolbar-trigger #jsenvLogoSvg {
145
+ width: 35px;
146
+ height: 35px;
147
+ opacity: 0;
148
+ transition: 600ms;
149
+ }
150
+
151
+ html[data-toolbar-visible] #toolbar-trigger {
152
+ display: none;
153
+ }
154
+
155
+ #toolbar-trigger:hover {
156
+ cursor: pointer;
157
+ }
158
+
159
+ #toolbar-trigger[data-expanded] {
160
+ bottom: 0;
161
+ }
162
+
163
+ #toolbar-trigger[data-expanded] #jsenvLogoSvg {
164
+ opacity: 1;
165
+ }
166
+
167
+ /* #jsenvLogo {
168
+ transition: 600ms;
169
+ } */
170
+
171
+ #toolbar a {
172
+ color: inherit;
173
+ }
@@ -0,0 +1,174 @@
1
+ import { updateToolbarState } from "./toolbar_state.js"
2
+ import { addExternalCommandCallback } from "./communication/parent_window_communication.js"
3
+ import { startJavaScriptAnimation } from "./util/animation.js"
4
+ import "./focus/toolbar_focus.js"
5
+ import { setLinkHrefForParentWindow } from "./util/iframe_to_parent_href.js"
6
+ import {
7
+ getToolbarIframe,
8
+ deactivateToolbarSection,
9
+ setStyles,
10
+ } from "./util/dom.js"
11
+ import { createPreference } from "./util/preferences.js"
12
+ import { hideTooltip, hideAllTooltip } from "./tooltip/tooltip.js"
13
+ import {
14
+ renderToolbarSettings,
15
+ hideSettings,
16
+ } from "./settings/toolbar_settings.js"
17
+ import { animationsAreEnabled } from "./animation/toolbar_animation_core.js"
18
+ import { renderToolbarNotification } from "./notification/toolbar_notification.js"
19
+ import { renderToolbarTheme } from "./theme/toolbar_theme.js"
20
+ import { renderToolbarAnimation } from "./animation/toolbar_animation_ui.js"
21
+ import { renderExecutionInToolbar } from "./execution/toolbar_execution.js"
22
+ import { initToolbarEventSource } from "./eventsource/toolbar_eventsource.js"
23
+ import { makeToolbarResponsive } from "./responsive/toolbar_responsive.js"
24
+
25
+ const toolbarVisibilityPreference = createPreference("jsenv_toolbar_visible")
26
+
27
+ const renderToolbar = async () => {
28
+ const toolbarOverlay = document.querySelector("#toolbar-overlay")
29
+ toolbarOverlay.onclick = () => {
30
+ hideAllTooltip()
31
+ hideSettings()
32
+ }
33
+
34
+ const toolbarVisible = toolbarVisibilityPreference.has()
35
+ ? toolbarVisibilityPreference.get()
36
+ : true
37
+
38
+ if (toolbarVisible) {
39
+ showToolbar({ animate: false })
40
+ } else {
41
+ hideToolbar({ animate: false })
42
+ }
43
+
44
+ setLinkHrefForParentWindow(
45
+ document.querySelector(".toolbar-icon-wrapper"),
46
+ "/",
47
+ )
48
+ renderToolbarNotification()
49
+ makeToolbarResponsive()
50
+ renderToolbarSettings()
51
+ renderToolbarAnimation()
52
+ renderToolbarTheme()
53
+ renderExecutionInToolbar()
54
+ // this might become active but we need to detect this somehow
55
+ deactivateToolbarSection(document.querySelector("#file-list-link"))
56
+ initToolbarEventSource()
57
+
58
+ // if user click enter or space quickly while closing toolbar
59
+ // it will cancel the closing
60
+ // that's why I used toggleToolbar and not hideToolbar
61
+ document.querySelector("#button-close-toolbar").onclick = () =>
62
+ toogleToolbar()
63
+ }
64
+
65
+ const toogleToolbar = () => {
66
+ if (toolbarIsVisible()) {
67
+ hideToolbar()
68
+ } else {
69
+ showToolbar()
70
+ }
71
+ }
72
+
73
+ const toolbarIsVisible = () =>
74
+ document.documentElement.hasAttribute("data-toolbar-visible")
75
+
76
+ let hideToolbar = () => {
77
+ // toolbar hidden by default, nothing to do to hide it by default
78
+ updateToolbarState({
79
+ visible: false,
80
+ })
81
+ }
82
+
83
+ // (by the way it might be cool to have the toolbar auto show when)
84
+ // it has something to say (being disconnected from server)
85
+ const showToolbar = () => {
86
+ toolbarVisibilityPreference.set(true)
87
+ if (animationsAreEnabled()) {
88
+ document.documentElement.setAttribute("data-toolbar-animation", "")
89
+ } else {
90
+ document.documentElement.removeAttribute("data-toolbar-animation")
91
+ }
92
+ document.documentElement.setAttribute("data-toolbar-visible", "")
93
+
94
+ updateToolbarState({
95
+ visible: true,
96
+ })
97
+
98
+ const toolbarIframe = getToolbarIframe()
99
+ const toolbarIframeParent = toolbarIframe.parentNode
100
+ const parentWindow = window.parent
101
+ const parentDocumentElement =
102
+ parentWindow.document.compatMode === "CSS1Compat"
103
+ ? parentWindow.document.documentElement
104
+ : parentWindow.document.body
105
+
106
+ const scrollYMax =
107
+ parentDocumentElement.scrollHeight - parentWindow.innerHeight
108
+ const scrollY = parentDocumentElement.scrollTop
109
+ const scrollYRemaining = scrollYMax - scrollY
110
+
111
+ setStyles(toolbarIframeParent, {
112
+ "transition-property": "padding-bottom",
113
+ "transition-duration": animationsAreEnabled() ? "300ms" : "0s",
114
+ })
115
+ // maybe we should use js animation here because we would not conflict with css
116
+ const restoreToolbarIframeParentStyles = setStyles(toolbarIframeParent, {
117
+ "scroll-padding-bottom": "40px", // same here we should add 40px
118
+ "padding-bottom": "40px", // if there is already one we should add 40px
119
+ })
120
+ const restoreToolbarIframeStyles = setStyles(toolbarIframe, {
121
+ height: "40px",
122
+ visibility: "visible",
123
+ })
124
+
125
+ if (scrollYRemaining < 40 && scrollYMax > 0) {
126
+ const scrollEnd = scrollY + 40
127
+ startJavaScriptAnimation({
128
+ duration: 300,
129
+ onProgress: ({ progress }) => {
130
+ const value = scrollY + (scrollEnd - scrollY) * progress
131
+ parentDocumentElement.scrollTop = value
132
+ },
133
+ })
134
+ }
135
+
136
+ hideToolbar = () => {
137
+ restoreToolbarIframeParentStyles()
138
+ restoreToolbarIframeStyles()
139
+
140
+ hideTooltip(document.querySelector("#eventsource-indicator"))
141
+ hideTooltip(document.querySelector("#execution-indicator"))
142
+ toolbarVisibilityPreference.set(false)
143
+ if (animationsAreEnabled()) {
144
+ document.documentElement.setAttribute("data-toolbar-animation", "")
145
+ } else {
146
+ document.documentElement.removeAttribute("data-toolbar-animation")
147
+ }
148
+ document.documentElement.removeAttribute("data-toolbar-visible")
149
+ updateToolbarState({
150
+ visible: false,
151
+ })
152
+ }
153
+ }
154
+
155
+ window.toolbar = {
156
+ show: showToolbar,
157
+ hide: () => hideToolbar(),
158
+ }
159
+
160
+ // const { currentScript } = document
161
+ addExternalCommandCallback("renderToolbar", ({ logs }) => {
162
+ renderToolbar({
163
+ logs,
164
+ })
165
+ })
166
+ addExternalCommandCallback("showToolbar", () => {
167
+ showToolbar()
168
+ })
169
+ addExternalCommandCallback("hideToolbar", () => {
170
+ hideToolbar()
171
+ })
172
+ updateToolbarState({
173
+ ready: true,
174
+ })
@@ -0,0 +1,16 @@
1
+ import { sendEventToParent } from "./communication/parent_window_communication.js"
2
+
3
+ export const toolbarState = {
4
+ ready: false,
5
+ visible: false,
6
+ animationsEnabled:
7
+ window.localStorage.getItem("jsenv_toolbar_animation") === "true",
8
+ }
9
+
10
+ export const updateToolbarState = (properties) => {
11
+ Object.assign(toolbarState, properties)
12
+ if (!toolbarState.ready) {
13
+ return
14
+ }
15
+ sendEventToParent("toolbar_state_change", toolbarState)
16
+ }
@@ -0,0 +1,61 @@
1
+ .tooltip {
2
+ display: none;
3
+ background-color: rgb(94, 94, 94);
4
+ color: #fff;
5
+ text-align: center;
6
+ border-radius: 6px;
7
+ position: absolute;
8
+ bottom: 120%;
9
+ padding: 10px;
10
+ font-size: 14px;
11
+ margin-left: -40px;
12
+ max-width: 260px;
13
+ cursor: default;
14
+ }
15
+
16
+ .tooltip::after {
17
+ content: "";
18
+ position: absolute;
19
+ top: 100%;
20
+ left: 60px;
21
+ margin-left: -5px;
22
+ border-width: 5px;
23
+ border-style: solid;
24
+ border-color: rgb(94, 94, 94) transparent transparent transparent;
25
+ }
26
+
27
+ [data-tooltip-visible] .tooltip,
28
+ [data-tooltip-auto-visible] .tooltip {
29
+ display: block;
30
+ animation: fadeIn ease 0.4s;
31
+ }
32
+
33
+ @keyframes fadeIn {
34
+ 0% {
35
+ opacity: 0;
36
+ }
37
+ 100% {
38
+ opacity: 1;
39
+ }
40
+ }
41
+
42
+ .tooltipAction {
43
+ display: inline-block;
44
+ border: 1px solid #a0a0a0;
45
+ border-radius: 3px;
46
+ padding: 3px 7px;
47
+ margin-top: 6px;
48
+ }
49
+
50
+ .tooltipAction a {
51
+ vertical-align: middle;
52
+ color: white;
53
+ text-decoration: none;
54
+ }
55
+
56
+ .tooltipIcon {
57
+ fill: white;
58
+ width: 20px;
59
+ height: 20px;
60
+ vertical-align: middle;
61
+ }
@@ -0,0 +1,39 @@
1
+ import { updateIframeOverflowOnParentWindow } from "../util/dom.js"
2
+
3
+ export const toggleTooltip = (element) => {
4
+ if (element.hasAttribute("data-tooltip-visible")) {
5
+ hideTooltip(element)
6
+ } else {
7
+ showTooltip(element)
8
+ }
9
+ }
10
+
11
+ export const hideTooltip = (element) => {
12
+ element.removeAttribute("data-tooltip-visible")
13
+ element.removeAttribute("data-tooltip-auto-visible")
14
+ updateIframeOverflowOnParentWindow()
15
+ }
16
+
17
+ export const showTooltip = (element) => {
18
+ element.setAttribute("data-tooltip-visible", "")
19
+ updateIframeOverflowOnParentWindow()
20
+ }
21
+
22
+ export const autoShowTooltip = (element) => {
23
+ element.setAttribute("data-tooltip-auto-visible", "")
24
+ updateIframeOverflowOnParentWindow()
25
+ }
26
+
27
+ export const removeAutoShowTooltip = (element) => {
28
+ element.removeAttribute("data-tooltip-auto-visible")
29
+ updateIframeOverflowOnParentWindow()
30
+ }
31
+
32
+ export const hideAllTooltip = () => {
33
+ const elementsWithTooltip = Array.from(
34
+ document.querySelectorAll("[data-tooltip-visible]"),
35
+ )
36
+ elementsWithTooltip.forEach((elementWithTooltip) => {
37
+ hideTooltip(elementWithTooltip)
38
+ })
39
+ }