batchcreate.js 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. $(function()
  2. {
  3. $name = $('#batchCreateForm table thead tr th.col-name');
  4. if($name.width() < 200) $name.width(200);
  5. $('#customField').click(function()
  6. {
  7. hiddenRequireFields();
  8. });
  9. /* Implement a custom form without feeling refresh. */
  10. $('#formSettingForm .btn-primary').click(function()
  11. {
  12. saveCustomFields('batchCreateFields', 8, $name, 200);
  13. return false;
  14. });
  15. });
  16. $(document).on('click', '.chosen-with-drop', function()
  17. {
  18. var select = $(this).prev('select');
  19. if($(select).val() == 'ditto')
  20. {
  21. var index = $(select).closest('td').index();
  22. var row = $(select).closest('tr').index();
  23. var table = $(select).closest('tr').parent();
  24. var value = '';
  25. for(i = row - 1; i >= 0; i--)
  26. {
  27. value = $(table).find('tr').eq(i).find('td').eq(index).find('select').val();
  28. if(value != 'ditto') break;
  29. }
  30. $(select).val(value);
  31. $(select).trigger("chosen:updated");
  32. }
  33. });
  34. $(document).on('mousedown', 'select', function()
  35. {
  36. if($(this).val() == 'ditto')
  37. {
  38. var index = $(this).closest('td').index();
  39. var row = $(this).closest('tr').index();
  40. var table = $(this).closest('tr').parent();
  41. var value = '';
  42. for(i = row - 1; i >= 0; i--)
  43. {
  44. value = $(table).find('tr').eq(i).find('td').eq(index).find('select').val();
  45. if(value != 'ditto') break;
  46. }
  47. $(this).val(value);
  48. }
  49. });
  50. $(document).on('change', 'input[name^="undetermined"]', function()
  51. {
  52. if($(this).is(':checked'))
  53. {
  54. $(this).closest('td').find('select[name^="products"]').attr('disabled', 'disabled');
  55. $(this).closest('td').find('div[id^="products"]').addClass('hidden');
  56. $(this).closest('td').find('input[name^="undeterminedProduct"]').removeClass('hidden');
  57. $(this).closest('td').find('select[name^="products"]').trigger('chosen:updated');
  58. }
  59. else
  60. {
  61. $(this).closest('td').find('select[name^="products"]').removeAttr('disabled');
  62. $(this).closest('td').find('div[id^="products"]').removeClass('hidden');
  63. $(this).closest('td').find('input[name^="undeterminedProduct"]').addClass('hidden');
  64. $(this).closest('td').find('select[name^="products"]').trigger('chosen:updated');
  65. }
  66. })