admin.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. var flexibleContentField = (function (w, d, $, undefined) {
  2. 'use strict';
  3. var s = {
  4. selectors: {
  5. theRepeater: '.form-statut',
  6. theSelect: '.field-selection__select'
  7. }
  8. },
  9. els = {},
  10. init = function () {
  11. // console.log("hello !");
  12. // $(this).on('change', checkTarget);
  13. // define elements
  14. els.theRepeater = $(s.selectors.theRepeater);
  15. els.theSelect = $(s.selectors.theSelect);
  16. // no elements
  17. if (!els.theRepeater.length) { return; }
  18. els.theSelect.each(function() {
  19. let c = $(this).attr("checked");
  20. if(c){
  21. // console.log(this);
  22. hideShow(this);
  23. }
  24. });
  25. els.theSelect.each(function() {
  26. $(this).on('mouseup', function(){
  27. hideShow(this);
  28. });
  29. });
  30. },
  31. checkTarget = function(event) {
  32. // console.log($(this).attr("value"));
  33. },
  34. hideShow = function (elem) {
  35. els.theRepeater.each(function() {
  36. // $(this).parents().eq(2).hide();
  37. });
  38. let v = $(elem).attr("value");
  39. // $("."+v).parents().eq(2).show();
  40. }
  41. return {
  42. init: init
  43. };
  44. }(window, window.document, window.jQuery));
  45. //
  46. // // theCall - on window loaded
  47. (function (w, d, undefined) {
  48. "use strict";
  49. // .parentElement.nodeName;
  50. var raf = requestAnimationFrame || mozRequestAnimationFrame || webkitRequestAnimationFrame || msRequestAnimationFrame,
  51. init = function () { w.flexibleContentField.init(); };
  52. // when all is loaded
  53. raf ? raf(function () { w.setTimeout(init, 500); }) : w.addEventListener('load', init);
  54. }(window, window.document));