PageSourceSearch

https://www.yarnsandfibers.com/wp-content/uploads/hummingbird-assets/acf12c0156e41acb82edac9b3f1c7a10.js

js yarnsandfibers.com collected 2026-09-24 23:12:03 UTC 4,106 bytes, 114 lines download raw bytes

1/**handles:wcmp-b2b-rfq**/
2"use strict";
3var b2bmp = jQuery.noConflict();
4b2bmp(function () {
5	b2bmp(document).ready( (e) => {
6		if(b2bmp("#b2b-quote-product-category").length > 0 ) {
7            b2bmp("#b2b-quote-product-category").select2();
8        }
9		b2bmp('.b2b-form-upload-button').on('click', function (e) {
10			e.preventDefault();
11			let currentElement = b2bmp(this);
12			var attachment_ids = '';
13			var file_frame;
14			if (file_frame) {
15				file_frame.open();
16				return;
17			}
18			var file_frame = wp.media({
19				title: 'Upload sample images',
20				button: {
21					text: 'Upload',
22				},
23				multiple: true
24			}).on('select', function () {
25				var selection = file_frame.state().get('selection');
26				var image_holder = currentElement.closest("td.forminp").find(".b2b-quote-product-image");
27				image_holder.empty();
28				attachment_ids = selection.map(function (attachment) {
29					attachment = attachment.toJSON();
30					if (attachment.sizes != undefined) {
31						image_holder.append("<img src='" + attachment.sizes.thumbnail.url + "' class='wpmp-rfq-form-pro-img'/>");
32					}
33					return attachment.id;
34				});
35				if ( currentElement.closest("td.forminp").children("input[name='b2b-quote-sample']").length ) {
36					currentElement.closest("td.forminp").children("input[name='b2b-quote-sample']").empty();
37					currentElement.closest("td.forminp").children("input[name='b2b-quote-sample']").val(attachment_ids.toString());
38				} else {
39					currentElement.closest("td.forminp").children("input[name='b2b-quote-product[sample]']").empty(); 
40					currentElement.closest("td.forminp").children("input[name='b2b-quote-product[sample]']").val(attachment_ids.toString());
41				}
42			}).open();
43		});
44
45		b2bmp('.wcmp-b2b-approve-quote-request-btn').on('click', function(e) {
46			let quote_id = b2bmp(this).data("quote-id");
47			let shop_id = b2bmp(this).data("shop-id");
48			let reply = confirm(b2bmpObj.translation.approve_quote);
49			let action = 'wcmp_b2b_shop_approve_quote';
50			process_quote_request(quote_id, shop_id, reply, action);
51		});
52
53		b2bmp('.wcmp-b2b-reject-quote-request-btn').on('click', function(e) {
54			let quote_id = b2bmp(this).data("quote-id");
55			let shop_id = b2bmp(this).data("shop-id");
56			let reply = confirm(b2bmpObj.translation.reject_quote);
57			let action = 'wcmp_b2b_shop_reject_quote';
58			process_quote_request(quote_id, shop_id, reply, action);
59		});
60
61		function process_quote_request(quote_id, shop_id, reply, action) {
62			if(reply && quote_id && shop_id) {
63				b2bmp.ajax({
64					type: 'POST',
65					url: b2bmpObj.ajax.ajaxUrl,
66					data: {
67						'action' 	: action,
68						'quote_id' 	: quote_id,
69						'shop_id' 	: shop_id,
70						'nonce'		: b2bmpObj.ajax.ajaxNonce
71					},
72					success: function (response) {
73						if(response) {
74							alert(response.message);
75							location.reload();
76						}
77					}
78				});
79			}
80		}
81
82		b2bmp('#wcmp-b2b-quote-product').submit( (e) => {
83			e.preventDefault();
84			var data = b2bmp(e.target).serializeArray();
85			if( b2bmp(".wc_quote-products tbody").find("tr.b2b-empty-cell").length > 0 ) {
86				b2bmp(".wc_quote-products tbody").empty();
87			}
88			console.log(data);
89			let _index = b2bmp(".wc_quote-products tbody tr").length;
90			let items = data.map((item)	=> {
91				let currentItem = item.name;
92				var index = currentItem.lastIndexOf("[");
93				var newName = '';
94				if(currentItem.includes("category")) {
95					newName = currentItem.substring(0,index)+"["+_index+"]"+currentItem.substring(index)+'[]';
96				} else {
97					newName = currentItem.substring(0,index)+"["+_index+"]"+currentItem.substring(index);
98				}			
99				item.name = newName;
100				return item;
101			});
102			
103			let productTemplate = wp.template('quote-product');
104			var __html = productTemplate(items);
105			b2bmp(e.target).closest("table.wc_status_table").find(".b2b-quote-product-image");
106			b2bmp(".b2b-quote-product-image").empty();
107			if( b2bmp(e.target).find("#b2b-quote-product-category").length > 0 ) {
108				b2bmp(e.target).find("#b2b-quote-product-category").val('').change();
109			}
110			b2bmp(".wc_quote-products tbody").append(__html);
111			b2bmp(e.target)[0].reset();
112		});
113	});
114});

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.