feeds_ui.js 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. Drupal.behaviors.feeds = function() {
  2. // Hide text in specific input fields.
  3. $('.hide-text-on-focus').focus(function() {
  4. $(this).val('');
  5. });
  6. // Hide submit buttons of .feeds-ui-hidden-submit class.
  7. $('input.form-submit.feeds-ui-hidden-submit').hide();
  8. /**
  9. * Tune checkboxes on mapping forms.
  10. * @see feeds_ui_mapping_form() in feeds_ui.admin.inc
  11. */
  12. // Attach submit behavior to elements with feeds-ui-trigger-submit class.
  13. $('.feeds-ui-trigger-submit').click(function() {
  14. // Use click, not form.submit() - submit() would use the wrong submission
  15. // handler.
  16. $('input.form-submit.feeds-ui-hidden-submit').click();
  17. });
  18. // Replace checkbox with .feeds-ui-checkbox-link class with a link.
  19. $('.feeds-ui-checkbox-link:not(.processed)').each(function(i) {
  20. $(this).addClass('processed').after(
  21. '<a href="#" onclick="return false;" class="feeds-ui-trigger-remove">' + $('label', this).text() + '</a>'
  22. ).hide();
  23. });
  24. // Check the box and then submit.
  25. $('.feeds-ui-trigger-remove').click(function() {
  26. // Use click, not form.submit() - submit() would use the wrong submission
  27. // handler.
  28. $(this).prev().children().children().children().attr('checked', 1);
  29. $('input.form-submit.feeds-ui-hidden-submit').click();
  30. });
  31. // Replace radio with .feeds-ui-radio-link class with a link.
  32. $('.feeds-ui-radio-link:not(.processed)').parent().each(function(i) {
  33. checked = '';
  34. if ($(this).children('input').attr('checked')) {
  35. checked = ' checked';
  36. }
  37. $(this).addClass('processed').after(
  38. '<a href="#" onclick="return false;" class="feeds-ui-check-submit' + checked + '" id="' + $(this).children('input').attr('id') + '">' + $(this).parent().text() + '</a>'
  39. );
  40. $(this).hide();
  41. });
  42. // Hide the the radio that is selected.
  43. $('.feeds-ui-check-submit.checked').parent().hide();
  44. // Check the radio and then submit.
  45. $('.feeds-ui-check-submit').click(function() {
  46. // Use click, not form.submit() - submit() would use the wrong submission
  47. // handler.
  48. $('#' + $(this).attr('id')).attr('checked', 1);
  49. $('input.form-submit.feeds-ui-hidden-submit').click();
  50. });
  51. };