PageSourceSearch

https://pwerle.com.au/wp-content/plugins/gift-registry-custom/assets/js/registry-form.js?ver=1790975040

js pwerle.com.au collected 2026-10-02 21:05:41 UTC 6,043 bytes, 153 lines download raw bytes

1(function ($) {
2  $(document).ready(function () {
3    const form = $("#nmgr-profile-form");
4
5    $(form)
6      .find("#nmgr-registry-cover-img")
7      .on("change", async function () {
8        const formData = new FormData($("#nmgr-profile-form")[0]);
9        formData.append("action", "nmgr_upload_cover_image");
10        const imageFile = $(this).prop("files")[0];
11        if (imageFile.size > 1024 * 1024) {
12          alert("File size must be less than 1Mb");
13          return;
14        }
15        $(".registry-cover-img-wrapper").addClass("loading");
16        $.ajax({
17          url: nmgrCustom.ajax_url,
18          type: "POST",
19          data: formData,
20          processData: false, // Prevent jQuery from processing the data
21          contentType: false,
22          success: function (response) {
23            if (response.success && response.data.attachment_id) {
24              const url = URL.createObjectURL(imageFile);
25              $(form).find(".registry-cover-img img").attr("src", url);
26              $("#background_image_id").val(response.data.attachment_id);
27            }
28          },
29          error: function (error) {
30            console.log(error);
31          },
32          complete: function () {
33            $(".registry-cover-img-wrapper").removeClass("loading");
34          },
35        });
36      });
37  });
38
39  $(document).ready(function () {
40    let timeout;
41    $("#nmgr-products-search").on("keyup", function () {
42      clearTimeout(timeout);
43      const searchValue = $(this).val();
44      timeout = setTimeout(function () {
45        $.ajax({
46          url: nmgrCustom.ajax_url,
47          type: "POST",
48          data: {
49            action: "nmgr_search_products",
50            security: $("#security").val(),
51            term: searchValue,
52            display_stock: true,
53          },
54          success: function (response) {
55            const list = $(".nmgr-items-select-products-panel-list");
56            if (response.success && response.data) {
57              const products = response.data;
58              list.html("");
59              const wishlistId = $("#wishlist_id").val();
60              products.forEach(function (product) {
61                list.append(
62                  `<div class="nmgr-item-select-product-item">
63                      <a href="${product.permalink}" target="_blank">
64                        <img src="${product.image_url}" alt="${product.name}" />
65                        <div class="nmgr-item-select-product-item-content">
66                          <div class="nmgr-item-select-product-item-name">${product.name}</div>
67                          <div class="nmgr-item-select-product-item-sku"><strong>SKU:</strong> ${product.sku}</div>
68                        </div>
69                      </a>
70                      <form id="nmgr-atw-content" data-post_action="atw_submit_dialog">
71                        <fieldset id="atw-selwish-wrapper" class="atw-row">
72                          <input type="hidden" name="data[btn_id]" value="${product.id}">
73                          <input type="hidden" name="data[type]" value="gift-registry">
74                          <input type="hidden" name="data[product_ids]" value="[${product.id}]">
75                          <input type="hidden" name="data[wishlist_id]" value="${wishlistId}" />
76                          <input type="number" id="quantity_${product.id}" class="input-text qty text" name="data[products][${product.id}][quantity]" value="1" aria-label="Product quantity" size="4" min="0" max="" step="1" placeholder="" inputmode="numeric" autocomplete="off">
77                          <div id="seladd" class="atw-row">
78                            <div id="matw-atw-btn">
79                              <input type="submit" name="atw_submit" class="atw_dialog_submit_btn button button-atom button-atom--primary breakdance-form-button breakdance-form-button__submit" value="Add to registry" />
80                            </div>
81                          </div>
82                        </fieldset>
83                      </form>
84                  </div>`
85                );
86              });
87            } else {
88              list.html("");
89            }
90          },
91          error: function (error) {
92            console.log(error);
93          },
94        });
95      }, 300);
96    });
97
98    $(document).on("click", "#nmgr-items #nmgr-atw-dialog", function (e) {
99      console.log(e.target);
100      if (
101        $(
102          "#nmgr-items #nmgr-atw-dialog #nmgr-atw-content .atw-fieldset"
103        )[0].contains(e.target)
104      ) {
105        return;
106      }
107      $("#nmgr-items #nmgr-atw-dialog #nmgr-atw-content .atw-fieldset").empty();
108    });
109  });
110
111  $(document.body).on("nmgr_post_action_response", function (e, response) {
112    if (!nmgr_global_params?.global?.is_wishlist_page) {
113      return;
114    }
115
116    if (!response.response?.added_to_wishlist) {
117      return;
118    }
119
120    const addedIds = Object.keys(response.response.added_to_wishlist);
121    addedIds.forEach(function (id) {
122      const quantity = response.response.added_to_wishlist[id];
123      const item = $(
124        `[name="nmgr-add-to-cart-product-id"][value="${id}"]`
125      ).closest("#nmgr_table_items tr.item");
126      if (item.length > 0) {
127        const currentQuantity = item
128          .find(".nmgr_quantity input.quantity")
129          .val();
130        const finalQuantity = parseInt(currentQuantity) + parseInt(quantity);
131        item.find(".nmgr_quantity input.quantity").val(finalQuantity);
132      } else {
133        $.ajax({
134          url: nmgrCustom.ajax_url,
135          type: "POST",
136          data: {
137            action: "nmgr_load_items_after_adding",
138            _wpnonce: nmgr_global_params.nonce,
139            wishlist_id: $("#wishlist_id").val(),
140          },
141          success: function (response) {
142            if (response.success && response.data.html) {
143              $("#nmgr-items-table-content").html(response.data.html);
144            }
145          },
146          error: function (error) {
147            console.log(error);
148          },
149        });
150      }
151    });
152  });
153})(jQuery);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.