You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

custom.js 1.3KB

4 years ago
4 years ago
12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. jQuery(document).ready(function () {
  2. custom_switch_merchants();
  3. initLcSortableList();
  4. initLcCkEditor();
  5. initLcTaxPriceWidget()
  6. });
  7. function custom_switch_merchants() {
  8. $('#switch-merchant select').change(function () {
  9. $('#switch-merchant form').submit();
  10. });
  11. }
  12. function initLcSortableList() {
  13. $('.lc-sortable tbody').sortable({
  14. placeholder: "ui-state-highlight"
  15. });
  16. $('.lc-sortable tbody').on("sortupdate", function (event, ui) {
  17. prototype = $('#form_entities').data('prototype');
  18. $('.lc-sortable tr.lc-draggable').each(function (index, li) {
  19. // instead be a number based on how many items we have
  20. var newForm = prototype.replace(/__name__/g, index);
  21. // Replace '__name__' in the prototype's HTML to
  22. $(li).find('div:last-child').remove();
  23. $(li).append(newForm);
  24. $(li).find('#form_entities_' + index + '_id').val($(li).data('id'));
  25. if ($('.lc-sortable').data('parent-position') !=='') val = $('.lc-sortable').data('parent-position') + '_' + index
  26. else val = index;
  27. log($(li).find('#form_entities_' + index + '_position'));
  28. $(li).find('#form_entities_' + index + '_position').val(val);
  29. });
  30. });
  31. }