|
1 | | -import "phoenix_html" |
2 | | -import { Socket, LongPoll } from "phoenix" |
3 | | -import { LiveSocket } from "phoenix_live_view" |
4 | | -import topbar from "topbar" |
5 | | - |
6 | | -import { loadAll } from "./lib/settings" |
7 | | - |
8 | | -import Charter from "./hooks/charter" |
9 | | -import Completer from "./hooks/completer" |
10 | | -import Instantiator from "./hooks/instantiator" |
11 | | -import Refresher from "./hooks/refresher" |
12 | | -import Relativize from "./hooks/relativize" |
13 | | -import Shortcuts from "./hooks/shortcuts" |
14 | | -import Themer from "./hooks/themer" |
15 | | -import Tippy from "./hooks/tippy" |
16 | | - |
17 | | -const hooks = { Charter, Completer, Instantiator, Refresher, Relativize, Shortcuts, Themer, Tippy } |
| 1 | +// Phoenix assets are imported from dependencies |
| 2 | +import topbar from "topbar"; |
| 3 | + |
| 4 | +import { loadAll } from "./lib/settings"; |
| 5 | + |
| 6 | +import Charter from "./hooks/charter"; |
| 7 | +import Completer from "./hooks/completer"; |
| 8 | +import Instantiator from "./hooks/instantiator"; |
| 9 | +import Refresher from "./hooks/refresher"; |
| 10 | +import Relativize from "./hooks/relativize"; |
| 11 | +import Shortcuts from "./hooks/shortcuts"; |
| 12 | +import Themer from "./hooks/themer"; |
| 13 | +import Tippy from "./hooks/tippy"; |
| 14 | + |
| 15 | +const hooks = { |
| 16 | + Charter, |
| 17 | + Completer, |
| 18 | + Instantiator, |
| 19 | + Refresher, |
| 20 | + Relativize, |
| 21 | + Shortcuts, |
| 22 | + Themer, |
| 23 | + Tippy, |
| 24 | +}; |
18 | 25 |
|
19 | 26 | // Topbar --- |
20 | 27 |
|
21 | | -let topBarScheduled = undefined |
| 28 | +let topBarScheduled = undefined; |
22 | 29 |
|
23 | 30 | topbar.config({ |
24 | 31 | barColors: { 0: "#0284c7" }, |
25 | 32 | shadowColor: "rgba(0, 0, 0, .3)", |
26 | | -}) |
| 33 | +}); |
27 | 34 |
|
28 | 35 | window.addEventListener("phx:page-loading-start", (info) => { |
29 | 36 | if (!topBarScheduled) { |
30 | | - topBarScheduled = setTimeout(() => topbar.show(), 500) |
| 37 | + topBarScheduled = setTimeout(() => topbar.show(), 500); |
31 | 38 | } |
32 | | -}) |
| 39 | +}); |
33 | 40 |
|
34 | 41 | window.addEventListener("phx:page-loading-stop", (info) => { |
35 | | - clearTimeout(topBarScheduled) |
36 | | - topBarScheduled = undefined |
37 | | - topbar.hide() |
38 | | -}) |
| 42 | + clearTimeout(topBarScheduled); |
| 43 | + topBarScheduled = undefined; |
| 44 | + topbar.hide(); |
| 45 | +}); |
39 | 46 |
|
40 | 47 | // Mounting --- |
41 | 48 |
|
42 | | -const csrfToken = document.querySelector("meta[name='csrf-token']").getAttribute("content") |
43 | | -const liveTran = document.querySelector("meta[name='live-transport']").getAttribute("content") |
44 | | -const livePath = document.querySelector("meta[name='live-path']").getAttribute("content") |
| 49 | +const csrfToken = document.querySelector("meta[name='csrf-token']").getAttribute("content"); |
| 50 | +const liveTran = document.querySelector("meta[name='live-transport']").getAttribute("content"); |
| 51 | +const livePath = document.querySelector("meta[name='live-path']").getAttribute("content"); |
45 | 52 |
|
46 | | -const liveSocket = new LiveSocket(livePath, Socket, { |
47 | | - transport: liveTran === "longpoll" ? LongPoll : WebSocket, |
| 53 | +const liveSocket = new LiveView.LiveSocket(livePath, Phoenix.Socket, { |
| 54 | + transport: liveTran === "longpoll" ? Phoenix.LongPoll : WebSocket, |
48 | 55 | params: { _csrf_token: csrfToken, init_state: loadAll() }, |
49 | 56 | hooks: hooks, |
50 | | -}) |
| 57 | +}); |
51 | 58 |
|
52 | | -liveSocket.connect() |
| 59 | +liveSocket.connect(); |
0 commit comments