2022-08-13 07:32:36 -04:00
|
|
|
// We import the main SCSS file, which performs all other SCSS imports,
|
|
|
|
// and which vite.js will preprocess with sass.
|
|
|
|
import '../css/app.scss'
|
2020-09-12 18:43:17 -04:00
|
|
|
|
2022-08-13 07:32:36 -04:00
|
|
|
// Include phoenix_html to handle method=PUT/DELETE in forms and buttons.
|
|
|
|
import 'phoenix_html'
|
2021-02-25 16:03:03 -05:00
|
|
|
|
2022-08-13 07:32:36 -04:00
|
|
|
// import Socket for Phoenix Channels
|
2021-02-24 11:46:13 -05:00
|
|
|
import { Socket } from "phoenix";
|
2022-08-13 07:32:36 -04:00
|
|
|
// import topbar for load progress in live reloading / liveview
|
2021-02-24 11:46:13 -05:00
|
|
|
import topbar from "topbar";
|
2022-08-13 07:32:36 -04:00
|
|
|
// import LiveSocket for LiveView
|
2021-02-24 11:46:13 -05:00
|
|
|
import { LiveSocket } from "phoenix_live_view";
|
2020-09-12 18:43:17 -04:00
|
|
|
|
2022-08-13 07:32:36 -04:00
|
|
|
|
2021-02-25 15:27:31 -05:00
|
|
|
// Bootstrap v5 js imports
|
2022-08-13 07:32:36 -04:00
|
|
|
import 'bootstrap/js/dist/alert';
|
|
|
|
import 'bootstrap/js/dist/collapse';
|
|
|
|
import 'bootstrap/js/dist/dropdown';
|
2021-03-03 16:07:59 -05:00
|
|
|
// Bootstrap helpers
|
2022-08-13 07:32:36 -04:00
|
|
|
import './_hamburger-helper';
|
2021-03-01 16:29:19 -05:00
|
|
|
import "./_form-validity";
|
2021-03-03 16:07:59 -05:00
|
|
|
// Bootstrap-liveview helpers
|
2021-02-26 12:07:33 -05:00
|
|
|
import { AlertRemover } from "./_alert-remover";
|
2021-03-03 16:07:59 -05:00
|
|
|
import { BsModal } from "./_bs_modal";
|
2021-03-15 15:46:59 -04:00
|
|
|
import { BsCollapse } from "./_bs_collapse";
|
2021-02-25 15:27:31 -05:00
|
|
|
|
|
|
|
// LiveSocket setup
|
2021-02-26 12:07:33 -05:00
|
|
|
let Hooks = {};
|
|
|
|
Hooks.AlertRemover = AlertRemover;
|
2021-03-03 16:07:59 -05:00
|
|
|
Hooks.BsModal = BsModal;
|
2021-03-15 15:46:59 -04:00
|
|
|
Hooks.BsCollapse = BsCollapse;
|
2021-02-24 11:46:13 -05:00
|
|
|
let csrfToken = document
|
|
|
|
.querySelector("meta[name='csrf-token']")
|
|
|
|
.getAttribute("content");
|
|
|
|
let liveSocket = new LiveSocket("/live", Socket, {
|
|
|
|
params: { _csrf_token: csrfToken },
|
2021-02-26 12:07:33 -05:00
|
|
|
hooks: Hooks,
|
2021-02-24 11:46:13 -05:00
|
|
|
});
|
2020-09-12 18:43:17 -04:00
|
|
|
|
|
|
|
// Show progress bar on live navigation and form submits
|
2021-02-24 11:46:13 -05:00
|
|
|
topbar.config({ barColors: { 0: "#29d" }, shadowColor: "rgba(0, 0, 0, .3)" });
|
|
|
|
window.addEventListener("phx:page-loading-start", (info) => topbar.show());
|
|
|
|
window.addEventListener("phx:page-loading-stop", (info) => topbar.hide());
|
2020-09-12 18:43:17 -04:00
|
|
|
|
|
|
|
// connect if there are any LiveViews on the page
|
2021-02-24 11:46:13 -05:00
|
|
|
liveSocket.connect();
|
2020-09-12 18:43:17 -04:00
|
|
|
|
|
|
|
// expose liveSocket on window for web console debug logs and latency simulation:
|
|
|
|
// >> liveSocket.enableDebug()
|
|
|
|
// >> liveSocket.enableLatencySim(1000) // enabled for duration of browser session
|
|
|
|
// >> liveSocket.disableLatencySim()
|
2021-02-24 11:46:13 -05:00
|
|
|
window.liveSocket = liveSocket;
|