Advertisement
YarikHrom

Untitled

May 12th, 2022
764
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.  
  13. // Uncomment to copy all static images under ../images to the output folder and reference
  14. // them with the image_pack_tag helper in views (e.g <%= image_pack_tag 'rails.png' %>)
  15. // or the `imagePath` JavaScript helper below.
  16. //
  17. // const images = require.context('../images', true)
  18. // const imagePath = (name) => images(name, true)
  19. import jquery from 'jquery';
  20.  
  21. window.$ = window.jquery = jquery; //force-load jquery before bootstrap
  22.  
  23. import 'bootstrap'
  24. import 'cocoon-js'
  25. import '../stylesheets/application'
  26. import "@fortawesome/fontawesome-free/js/all";
  27. import "@fortawesome/fontawesome-free/css/all.css";
  28. import '../scripts/employees'
  29.  
  30. document.addEventListener('ajax:success', () => {
  31.  
  32.     let checkbox = document.querySelector('.checkbox-toggler')
  33.  
  34.     if (checkbox) {
  35.         fieldsToggler();
  36.  
  37.         checkbox.addEventListener('click', () => {
  38.             fieldsToggler();
  39.         });
  40.     }
  41.  
  42.     function fieldsToggler() {
  43.         let element = document.querySelector('.toggle-field')
  44.  
  45.         if (checkbox && checkbox.checked) {
  46.             element.style['display'] = 'none';
  47.         } else {
  48.             element.style['display'] = 'block';
  49.         }
  50.     }
  51. });
  52. // Support component names relative to this directory:
  53. var componentRequireContext = require.context("components", true);
  54. var ReactRailsUJS = require("react_ujs");
  55. ReactRailsUJS.useContext(componentRequireContext);
  56.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement