admin
2 months ago
builder
2 months ago
stripe
2 months ago
admin.js
2 months ago
checkout-fields-manager.js
2 months ago
checkout.js
1 week ago
clipboard.min.js
2 months ago
content-control.js
2 months ago
create-form.js
2 months ago
frontend.js
2 months ago
frontend.min.js
1 week ago
index.php
2 months ago
jcarousel.min.js
2 months ago
jquery.blockUI.js
2 months ago
mailoptin.js
2 months ago
member-directory.js
2 months ago
member-directory.min.js
2 months ago
pp-wp-editor.js
2 months ago
checkout-fields-manager.js
132 lines
| 1 | (function ($) { |
| 2 | |
| 3 | $(function () { |
| 4 | |
| 5 | var template = wp.template('ppress-checkout-field-item'); |
| 6 | |
| 7 | $(document).on('ppress_update_dropdown', function () { |
| 8 | var cache = $('.ppress-checkout-field-list option'); |
| 9 | cache.removeAttr("disabled"); |
| 10 | $('.ppress-checkout-fields .widget').each(function () { |
| 11 | $('.ppress-checkout-field-list option[value="' + $(this).data('field-id') + '"]').attr("disabled", true); |
| 12 | }); |
| 13 | |
| 14 | // move selected option to first/default option after a field is added. |
| 15 | cache.eq(0).prop('selected', true) |
| 16 | }); |
| 17 | |
| 18 | if (typeof ppress_account_info_fields !== 'undefined') { |
| 19 | $.each(ppress_account_info_fields, function (key, value) { |
| 20 | $('#ppress-account-info-fields .ppress-checkout-fields').append( |
| 21 | template({ |
| 22 | 'fieldGroup': 'accountInfo', |
| 23 | 'field_key': key, |
| 24 | 'label': value.label, |
| 25 | 'width': value.width, |
| 26 | 'required': value.required, |
| 27 | 'logged_in_hide': value.logged_in_hide, |
| 28 | 'deletable': value.deletable |
| 29 | }) |
| 30 | ); |
| 31 | }); |
| 32 | } |
| 33 | |
| 34 | if (typeof ppress_blling_address_fields !== 'undefined') { |
| 35 | $.each(ppress_blling_address_fields, function (key, value) { |
| 36 | $('#ppress-billing-address-fields .ppress-checkout-fields').append( |
| 37 | template({ |
| 38 | 'fieldGroup': 'billing', |
| 39 | 'field_key': key, |
| 40 | 'label': value.label, |
| 41 | 'width': value.width, |
| 42 | 'required': value.required, |
| 43 | 'logged_in_hide': value.logged_in_hide, |
| 44 | 'deletable': value.deletable |
| 45 | }) |
| 46 | ); |
| 47 | }); |
| 48 | } |
| 49 | |
| 50 | $('.ppress-checkout-fields').sortable({ |
| 51 | containment: "#ppress-checkout-field-manager-form", |
| 52 | items: ".widget", |
| 53 | placeholder: "sortable-placeholder" |
| 54 | }); |
| 55 | |
| 56 | $(document).trigger('ppress_update_dropdown'); |
| 57 | |
| 58 | $(document).on('click', '.ppress-checkout-fields .widget-title-action', function (e) { |
| 59 | e.preventDefault(); |
| 60 | $(this).parents('.ppress-checkout-fields .widget').toggleClass('open'); |
| 61 | }); |
| 62 | |
| 63 | $(document).on('click', '.ppress-checkout-fields .widget-control-remove', function (e) { |
| 64 | e.preventDefault(); |
| 65 | $(this).parents('.ppress-checkout-fields .widget').slideUp("normal", function () { |
| 66 | $(this).remove(); |
| 67 | $(document).trigger('ppress_update_dropdown'); |
| 68 | }); |
| 69 | }); |
| 70 | |
| 71 | $(document).on('change', '.ppress-checkout-fields .widget-content input[name$="[label]"]', function () { |
| 72 | $(this).parents('.ppress-checkout-fields .widget').find('.widget-title h3').text($(this).val()); |
| 73 | }); |
| 74 | |
| 75 | $(document).on('click', '#ppress-cfm-submit-btn', function (e) { |
| 76 | e.preventDefault(); |
| 77 | document.getElementById("ppress-checkout-field-manager-form").submit(); |
| 78 | }); |
| 79 | |
| 80 | $(document).on('click', '#ppress-account-info-fields .ppress-checkout-add-field button', function (e) { |
| 81 | e.preventDefault(); |
| 82 | var selectedField = $(this).prev().val(); |
| 83 | |
| 84 | if ("" !== selectedField) { |
| 85 | |
| 86 | var bucket = typeof ppress_standard_acc_info_fields[selectedField] != 'undefined' ? |
| 87 | ppress_standard_acc_info_fields[selectedField] : |
| 88 | ppress_custom_fields[selectedField]; |
| 89 | |
| 90 | $('#ppress-account-info-fields .ppress-checkout-fields').append( |
| 91 | template({ |
| 92 | 'fieldGroup': 'accountInfo', |
| 93 | 'field_key': selectedField, |
| 94 | 'label': bucket['label'], |
| 95 | 'width': bucket['width'], |
| 96 | 'required': bucket['required'], |
| 97 | 'logged_in_hide': bucket['logged_in_hide'], |
| 98 | 'deletable': bucket['deletable'] |
| 99 | }) |
| 100 | ); |
| 101 | |
| 102 | $(document).trigger('ppress_update_dropdown'); |
| 103 | } |
| 104 | }); |
| 105 | |
| 106 | $(document).on('click', '#ppress-billing-address-fields .ppress-checkout-add-field button', function (e) { |
| 107 | e.preventDefault(); |
| 108 | var selectedField = $(this).prev().val(); |
| 109 | |
| 110 | if ("" !== selectedField) { |
| 111 | |
| 112 | var bucket = typeof ppress_standard_billing_fields[selectedField] != 'undefined' ? |
| 113 | ppress_standard_billing_fields[selectedField] : |
| 114 | ppress_custom_fields[selectedField]; |
| 115 | |
| 116 | $('#ppress-billing-address-fields .ppress-checkout-fields').append( |
| 117 | template({ |
| 118 | 'fieldGroup': 'billing', |
| 119 | 'field_key': selectedField, |
| 120 | 'label': bucket['label'], |
| 121 | 'width': bucket['width'], |
| 122 | 'required': bucket['required'], |
| 123 | 'logged_in_hide': bucket['logged_in_hide'], |
| 124 | 'deletable': bucket['deletable'] |
| 125 | }) |
| 126 | ); |
| 127 | |
| 128 | $(document).trigger('ppress_update_dropdown'); |
| 129 | } |
| 130 | }); |
| 131 | }); |
| 132 | })(jQuery); |