Advertisement
YarikHrom

Untitled

May 12th, 2022
948
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // This file is automatically compiled by Webpack, along with any other files
  2. // present in this directory. You're encouraged to place your actual application logic in
  3. // a relevant structure within app/javascript and only use these pack files to reference
  4. // that code so it'll be compiled.
  5.  
  6. require("@rails/ujs").start();
  7. require("@rails/activestorage").start();
  8. require("channels");
  9. require("scripts/toggle_elements");
  10. require("scripts/add_tag");
  11.  
  12. // Uncomment to copy all static images under ../images to the output folder and reference
  13. // them with the image_pack_tag helper in views (e.g <%= image_pack_tag 'rails.png' %>)
  14. // or the `imagePath` JavaScript helper below.
  15. //
  16. // const images = require.context('../images', true)
  17. // const imagePath = (name) => images(name, true)
  18. import jquery from "jquery";
  19.  
  20. window.$ = window.jquery = jquery; //force-load jquery before bootstrap
  21.  
  22. import "bootstrap";
  23. import "cocoon-js";
  24. import "../stylesheets/application";
  25. import "@fortawesome/fontawesome-free/js/all";
  26. import "@fortawesome/fontawesome-free/css/all.css";
  27. import "../scripts/employees";
  28.  
  29. document.addEventListener("ajax:success", () => {
  30.   let checkbox = document.querySelector(".checkbox-toggler");
  31.  
  32.   if (checkbox) {
  33.     fieldsToggler();
  34.  
  35.     checkbox.addEventListener("click", () => {
  36.       fieldsToggler();
  37.     });
  38.   }
  39.  
  40.   function fieldsToggler() {
  41.     let element = document.querySelector(".toggle-field");
  42.  
  43.     if (checkbox && checkbox.checked) {
  44.       element.style["display"] = "none";
  45.     } else {
  46.       element.style["display"] = "block";
  47.     }
  48.   }
  49. });
  50. // Support component names relative to this directory:
  51. var componentRequireContext = require.context("components", true);
  52. var ReactRailsUJS = require("react_ujs");
  53. ReactRailsUJS.useContext(componentRequireContext);
  54.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement