multilang.js 673 B

12345678910111213141516171819202122
  1. import $ from 'jquery';
  2. $('[name="task"][value="saveas"], [name="task"][value="switchlanguage"]').on('mousedown touchstart', (event) => {
  3. let fields = ['lang', 'redirect'];
  4. let element = $(event.currentTarget);
  5. let form = $(`#${element.attr('form')}`);
  6. if (!form.length) { return; }
  7. fields.forEach((field) => {
  8. let value = element.attr(field);
  9. if (!value) { return; }
  10. let input = form.find(`[name="data[${field}]"]`);
  11. if (!input.length) {
  12. input = $(`<input type="hidden" name="data[${field}]" value="" />`);
  13. form.append(input);
  14. }
  15. input.val(value);
  16. });
  17. return true;
  18. });