uc_coupon.admin.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. (function($) {
  2. Drupal.behaviors.ucCouponAdmin = {
  3. attach: function(context) {
  4. function toggleUsageLimits() {
  5. if ($('#edit-store-credit').is(':checked')) {
  6. $('#edit-usage-limits').hide();
  7. }
  8. else {
  9. $('#edit-usage-limits').show();
  10. }
  11. }
  12. $('#edit-store-credit', context).click(toggleUsageLimits);
  13. $('#edit-discount', context).keyup(function() {
  14. if (this.value.indexOf('%') == -1) {
  15. $(this).siblings('span').show();
  16. }
  17. else {
  18. $(this).siblings('span').hide();
  19. }
  20. if (this.value.indexOf('%') != -1 || this.value.indexOf('=') != -1) {
  21. $('#store-credit-wrapper').hide();
  22. $('#edit-usage-limits').show();
  23. }
  24. else {
  25. $('#store-credit-wrapper').show();
  26. toggleUsageLimits();
  27. }
  28. }).keyup();
  29. $('#edit-store-credit', context).click(function() {
  30. if ($(this).is(':checked')) {
  31. $('#edit-usage-limits').hide();
  32. }
  33. else {
  34. $('#edit-usage-limits').show();
  35. }
  36. });
  37. $('input[name=apply_to]', context).click(function() {
  38. if (this.value == 'cheapest' || this.value == 'expensive') {
  39. $('.form-item-apply-count').show();
  40. }
  41. else {
  42. $('.form-item-apply-count').hide();
  43. }
  44. }).filter(':checked').click();
  45. if ($('input[name=use_validity]', context).change(function() {
  46. $('.form-item-valid-from, .form-item-valid-until').toggle();
  47. }).is(':not(:checked)')) {
  48. $('.form-item-valid-from, .form-item-valid-until').hide();
  49. }
  50. }
  51. };
  52. })(jQuery);