splitcolumn.ui.js 1.2 KB

1234567891011121314151617181920212223242526272829303132
  1. window.clickAddRows = function()
  2. {
  3. const rowIndex = $(this).closest('.form-row').data('row');
  4. let formRow = $(this).closest('.form-row').prop('outerHTML');
  5. formRow = formRow.replaceAll('name[' + rowIndex + ']', 'name[' + index + ']').replaceAll('limit[' + rowIndex + ']', 'limit[' + index + ']').replaceAll('noLimit[' + rowIndex + ']', 'noLimit[' + index + ']').replaceAll('color[' + rowIndex + ']', 'color[' + index + ']');
  6. $(this).closest('.form-row').after(formRow);
  7. index++;
  8. if($('.form-row').length > 3) $('.removeRows').removeClass('opacity-0').removeAttr('disabled');
  9. }
  10. window.clickRemoveRows = function(event)
  11. {
  12. $(this).closest('.form-row').remove();
  13. if($('.form-row').length <= 3) $('.removeRows').addClass('opacity-0').attr('disabled', true);
  14. }
  15. window.changeColumnLimit = function()
  16. {
  17. const noLimit = $(this).prop('checked');
  18. if(noLimit)
  19. {
  20. $(this).closest('.form-row').find('[name^=limit]').val('').attr('disabled', true);
  21. }
  22. else
  23. {
  24. $(this).closest('.form-row').find('[name^=limit]').removeAttr('disabled');
  25. }
  26. }
  27. $(function()
  28. {
  29. $('.removeRows').addClass('opacity-0').attr('disabled', true);
  30. })