PageSourceSearch

https://www.papachina.com/web/js/extra.js

js papachina.com collected 2026-10-01 14:49:23 UTC 18,633 bytes, 412 lines download raw bytes

1jQuery.event.special.touchstart = {
2    setup: function( _, ns, handle ){
3        if ( ns.includes("noPreventDefault") ) {
4            this.addEventListener("touchstart", handle, { passive: false });
5        } else {
6            this.addEventListener("touchstart", handle, { passive: true });
7        }
8    }
9};
10jQuery.event.special.touchmove = {
11    setup: function( _, ns, handle ){
12        if ( ns.includes("noPreventDefault") ) {
13            this.addEventListener("touchmove", handle, { passive: false });
14        } else {
15            this.addEventListener("touchmove", handle, { passive: true });
16        }
17    }
18};
19
20
21jQuery(document).on('click','#allow-cookies', function(e){
22    jQuery.ajax({
23        headers: {'X-CSRF-TOKEN': jQuery('meta[name="csrf-token"]').attr('content')},
24        url: PAPC_setcookie,
25        type: "get",
26        success: function (res) {
27            jQuery('.alert-cookie').removeClass('show');
28            jQuery('.alert-cookie').addClass('hide');
29        },
30    });
31});
32
33
34function validd(){var e=parseInt(document.detailform.quantity.max),t=parseInt(document.detailform.quantity.value);if(t>e||t<1)return jQuery("#alert-exceed").show(),setTimeout(function(){jQuery("#alert-exceed").hide()},6e3),document.detailform.quantity.focus(),!1;var a=jQuery("#add-Product-form").serialize(),n=jQuery("#checkout_url").val();jQuery.ajax({url:'{{ URL::to("/addToCart")}}',headers:{"X-CSRF-TOKEN":jQuery('meta[name="csrf-token"]').attr("content")},type:"POST",data:a,success:function(e){"already added"==e.trim()?"Product is added!":(jQuery(".head-cart-content").html(e),"Product is added!",jQuery(parent).addClass("active")),"true"==n.trim()?window.location.href='{{ URL::to("/checkout")}}':"exceed"==e?swal("Something Happened To Stock","@lang('website.Ops! Product is available in stock But Not Active For Sale. Please contact to the admin')","error"):swal("Congrates!","Product Added Successfully Thanks.Continue Shopping","success")}})}function changeCurrency(e){ console.log(e); jQuery(function(t){jQuery.ajax({beforeSend:function(e){e.setRequestHeader("X-CSRF-Token",t('[name="_csrfToken"]').val())},url:PAPC_change_currency,type:"POST",data:{currency_id:e,_token:PAPC_token},success:function(e){window.location.reload()}})})}jQuery(document).on("change",".sortby",function(e){jQuery("#loader").show(),jQuery("#load_products_form").submit()}),jQuery(document).on("click",".add-to-Cart-from-detail",function(e){if(e.preventDefault(),!validd())return!1}),jQuery(document).on("click",".update-single-Cart",function(e){jQuery("#loader").show();var t=jQuery("#add-Product-form").serialize(),a=jQuery("#checkout_url").val();jQuery.ajax({headers:{"X-CSRF-TOKEN":jQuery('meta[name="csrf-token"]').attr("content")},url:'{{ URL::to("/updatesinglecart")}}',type:"POST",data:t,success:function(e){"already added"==e.trim()?"Product is added!":(jQuery(".head-cart-content").html(e),"Product is added!",jQuery(parent).addClass("active")),"true"==a.trim()?window.location.href='{{ URL::to("/checkout")}}':jQuery("#loader").css("display","none"),jQuery("#loader").hide()}})}),$(function(){$(document).on("mouseover",".main-menu",function(e){if(e.preventDefault(),$(this).find(".dropdown-content").is(":empty")){var t=$(this).attr("data-id"),a="";$.each(site_array,function(e,n){e==t&&(a+=' <ul class="dropdown-menu show">',5==e?$.each(menu_array[e],function(t,n){if(a+='<li><a class="dropdown-item" href="'+url+"/"+n.menu_link+'">'+n.menu_name+'        <i class="fa fa-angle-right " aria-hidden="true"></i>\n       </a>',n.category_list.length>0){var r=0;a+='<ul class="dropdown-menu dropdown-submenu" '+(4==e?'style="left: -98%;"':"")+">",a+='<div class="sub-container mega" style="left: 0px; top: -1px; z-index: 1;"><ul class="sub" style="display: block;"><div class="row" style="width: max-content;"><li class="mega-unit mega-hdr last">',a+="<ul>",$.each(n.category_list,function(e,t){a+='<li><a class="dropdown-item" href="'+t.categories_link+'">'+t.categories_name+"</a></li>";Math.round(t.subcate.length/18);18==r&&(a+='</ul><ul class="caunt_ul_1">',r=0),r++}),a+="</ul>",a+="</li></div></ul></div>",a+="</ul>"}}
34):$.each(menu_array[e],function(t,n){if(a+='<li><a class="dropdown-item" href="'+n.categories_link+'">'+n.categories_name+'        <i class="fa fa-angle-right " aria-hidden="true"></i>\n       </a>',n.subcate.length>0){a+='<ul class="dropdown-menu dropdown-submenu" '+(4==e?'style="left: -92%; width: inherit;"':"")+">";var r=0;Math.round(n.subcate.length/18);a+='<div class="sub-container mega" style="left: 0px; top: -1px; z-index: 1;"><ul class="sub" style="display: block;"><div class="row" style="width: max-content;"><li class="mega-unit mega-hdr last">',a+="<ul>",$.each(n.subcate,function(e,t){18==r&&(a+='</ul><ul class="caunt_ul_1">',r=0),a+='<li><a class="dropdown-item" href="'+t.categories_link+'">'+t.categories_name+"</a></li>",r++}),a+="</ul>",a+="</li></div></ul></div>",a+="</ul>"}}),a+="   </ul>")}),$(this).find(".dropdown-content").append(a)}})}),jQuery("#currency").on("click",function(){var e=$("#currency");$.each(["AED","AFN","ALL","AMD","ANG","AON","ARS","AUD","AWG","AZN","BAM","BBD","BDT","BGN","BHD","BIF","BMD","BND","BOB","BRL","BSD","BTN","BWP","BYR","BZD","CAD","CDF","CHF","CLP","CNY","COP","CRC","CUP","CVE","CYP","CZK","CZK","DJF","DKK","DOP","DZD","EEK","EGP","ERN","ETB","EUR","FJD","FKP","GBP","GEL","GHS","GIP","GMD","GNF","GTQ","GYD","HKD","HNL","HRK","HTG","HUF","IDR","ILS","INR","IQD","IRR","ISK","JMD","JOD","JPY","KES","KGS","KHR","KMF","KPW","KRW","KWD","KYD","KZT","LAK","LBP","LKR","LRD","LSL","LTL","LVL","LYD","MAD","MDL","MGA","MKD","MMK","MNT","MOP","MRO","MTL","MUR","MVR","MWK","MXN","MXN","MYR","MZN","NAD","NGN","NIO","NOK","NPR","NZD","OMR","PAB","PEN","PGK","PHP","PKR","PLN","PLZ","PYG","QAR","RON","RUB","RWF","SAR","SBD","SCR","SDG","SEK","SGD","SHP","SKK","SLL","SOS","SRD","STD","SVC","SYP","SZL","THB","TJS","TMT","TND","TOP","TRY","TTD","TWD","TZS","UAH","UGX","USD","UYU","UZS","VEB","VND","VUV","WST","XAF","XCD","XOF","XPF","YER","YUN","ZAR","ZMK","ZWD"],function(t,a){var n=$("<option />");n.html(a),n.val(a),e.append(n)})});
35
36
37function perpage(){
38    record = $('#recordlimit').val();
39    var base_url = PAPC_current_url;
40    base_url = base_url+"?limit="+record;
41    window.location = base_url;
42}
43
44function perpage1(){
45    record = $('#recordlimit1').val();
46    var base_url = PAPC_current_url;
47    base_url = base_url+"?limit="+record;
48    window.location = base_url;
49}
50
51$('#search_input_check').keyup(function(){
52
53    string_length = $(this).val();
54
55    if(string_length.length < 3){
56        $(this).css('border','2px solid red');
57        return false;
58    }else{
59        $(this).css('border','2px solid #0b7ad6');
60    }
61    if (event.keyCode == 13) {
62        window.location = PAPC_search + '/'+string_length;
63    }
64});
65
66function submitSearch(){
67
68    string_length = $('#search_input_check').val();
69    if (string_length !== undefined) {
70
71        if(string_length.length < 3){
72            return false;
73        }else{
74            window.location = PAPC_search +'/'+string_length;
75        }
76    }
77}
78
79
80
81//cart item price
82
83jQuery(".qtyminuscart").click(function(e) {
84
85    // Stop acting like a button
86    e.preventDefault();
87
88    // Get the field name
89    fieldName = jQuery(this).attr('field');
90
91    // Get its current value
92    var currentVal = parseInt(jQuery(this).parents('span').prev('.qty').val());
93    var minimumVal =  jQuery(this).parents('span').prev('.qty').attr('min');
94    // If it isn't undefined or its greater than 0
95    if (!isNaN(currentVal) && currentVal > minimumVal) {
96        // Decrement one
97        jQuery(this).parents('span').prev('.qty').val(currentVal - 1);
98    } else {
99        // Otherwise put a 0 there
100        jQuery(this).parents('span').prev('.qty').val(minimumVal);
101
102    }
103});
104
105jQuery('.qtypluscart').click(function(e){
106    e.preventDefault();
107    // Get the field name
108    //fieldName = jQuery(this).attr('field');
109    // Get its current value
110    var currentVal = parseInt(jQuery(this).parents('span').prev('.qty').val());
111    var maximumVal =  jQuery(this).parents('span').prev('.qty').attr('max');
112
113
114    //alert(maximum);
115    // If is not undefined
116    if (!isNaN(currentVal)) {
117        if(maximumVal!=0){
118            if(currentVal < maximumVal ){
119                // Increment
120                jQuery(this).parents('span').prev('.qty').val(currentVal + 1);
121            }
122        }
123
124    } else {
125        // Otherwise put a 0 there
126        jQuery(this).prev('.qty').val(0);
127    }
128});
129
130
131//update_cart
132jQuery(document).on('click', '#update_cart', function(e){
133    jQuery('#loader').css('display','block');
134    jQuery("#update_cart_form").submit();
135});
136
137
138jQuery.ajaxSetup({
139    headers: {
140        'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
141    }
142});
143jQuery(document).ready(function($) {
144    var isSubmitting = false;
145
146    $('#footer_enquiry_form').on('submit', function(event) {
147        event.preventDefault();
148
149        if (isSubmitting) {
150            return; // Prevent further submissions
151        }
152        isSubmitting = true;
153
154        var ajaxcall = true;
155        $('#loader').show();
156
157        $('#footer_enquiry_form input, #footer_enquiry_form textarea, #footer_enquiry_form select').each(function() {
158            var htmlid = $(this).attr('id');
159            if (htmlid !== undefined) {
160                Mid = '#' + htmlid;
161                $mValue = $(Mid).val();
162                if (htmlid == 'fenquiry_file') {
163                    ajaxcall = true;
164                    $(Mid).removeClass('error');
165                } else if ($mValue == '') {
166                    $(Mid).addClass('error');
167                    $(Mid).focus();
168                    $('#loader').hide();
169                    ajaxcall = false;
170                    isSubmitting = false;
171                    return false;
172                } else {
173                    ajaxcall = true;
174                    $(Mid).removeClass('error');
175                }
176            }
177        });
178
179        if (ajaxcall) {
180            var files = $('#fenquiry_file'); // FileList object
181            f = files[0].files;
182            if (f[0]) {
183                if (f[0].type == "application/pdf" || f[0].type == "image/jpeg" || f[0].type == "image/png") {
184                    // Valid file type
185                } else {
186                    swal("", "Accepting Only JPG, JPEG, PNG, Pdf only", "error");
187                    ajaxcall = false;
188                    $('#loader').hide();
189                    isSubmitting = false;
190                    return false;
191                }
192            }
193
194            $.ajax({
195                url: PAPC_submitQuote,
196                method: "POST",
197                data: new FormData(this),
198                dataType: 'JSON',
199                contentType: false,
200                cache: false,
201                processData: false,
202                success: function(data) {
203                    if (data.result == 'success') {
204                        swal(data.message_1, data.message_2, "success");
205                        $('#footer_enquiry_form')[0].reset();
206                    } else if (data.result == 'error') {
207                        gtag('event', 'conversion', {'send_to': 'AW-700467480/WxJqCMjG64wCEJiSgc4C'});
208                        swal(data.message_1, data.message_2, "success");
209                        // NOT GOOD TO SHOW ERROR, SO JUST SHOW FAKE SUCCESS MSG
210                        $('#footer_enquiry_form')[0].reset();
211                    } else {
212                        var error = data.result;
213                        var errormsg = '';
214                        $.each(error, function(index, value) {
215                            errormsg += value;
216                        });
217                        swal("Error:", errormsg, "error");
218                    }
219                    $('#loader').hide();
220                    isSubmitting = false; // Reset flag
221                },
222                error: function() {
223                    $('#loader').hide();
224                    isSubmitting = false; // Reset flag on error
225                }
226            });
227        } else {
228            isSubmitting = false; // Reset flag if validation fails
229        }
230    });
231});
232
233
234
235jQuery(document).on("click", ".p_quote", function(e) {
236    e.preventDefault();
237    var p_id = $(this).data("p_id");
238    var p_name = $(this).data("p_name");
239    var prod_source = $(this).data("p_source");
240
241    $('#gq_prod_id').val(p_id);
242    $('#gq_prod_source').val(prod_source);
243    $('#gq_title').text(p_name);
244    $('#gq_message').attr('placeholder', 'Enquiry Message');
245    $('#requestQuote').modal();
246});
247
248jQuery(document).on("click", "#g_enquiry_close", function(e) {
249    e.preventDefault();
250    $('#gq_prod_id').val('');
251    $('#gq_title').text('Get A FREE Presentation & Quote!');
252});
253
254jQuery(document).ready(function($) {
255    var isSubmitting = false;
256
257    $('#global_enquiry_form').on('submit', function(event) {
258        event.preventDefault();
259
260        if (isSubmitting) {
261            return; // Prevent further submissions
262        }
263        isSubmitting = true;
264
265        var ajaxcall = true;
266        $('#loader').show();
267
268        $('#global_enquiry_form input, #global_enquiry_form textarea, #global_enquiry_form select').each(function() {
269            var htmlid = $(this).attr('id');
270            if (htmlid !== undefined) {
271                Mid = '#' + htmlid;
272                $mValue = $(Mid).val();
273
274                if (htmlid == 'gq_title' || htmlid == 'gq_prod_source' || htmlid == 'gq_prod_id' || htmlid == 'gq_enquiry_file') {
275                    ajaxcall = true;
276                    $(Mid).removeClass('error');
277                } else if ($mValue == '') {
278                    $(Mid).addClass('error');
279                    $(Mid).focus();
280                    $('#loader').hide();
281                    ajaxcall = false;
282                    isSubmitting = false;
283                    return false;
284                } else {
285                    ajaxcall = true;
286                    $(Mid).removeClass('error');
287                }
288            }
289        });
290
291        if (ajaxcall) {
292            var files = $('#gq_enquiry_file'); // FileList object
293            f = files[0].files;
294            if (f[0]) {
295                if (f[0].type == "application/pdf" || f[0].type == "image/jpeg" || f[0].type == "image/png") {
296                    // Valid file type
297                } else {
298                    $('#loader').hide();
299                    swal("", "Accepting Only JPG, JPEG, PNG, Pdf only", "error");
300                    ajaxcall = false;
301                    isSubmitting = false;
302                    return false;
303                }
304            }
305
306            $.ajax({
307                url: PAPC_submitQuote,
308                method: "POST",
309                data: new FormData(this),
310                dataType: 'JSON',
311                contentType: false,
312                cache: false,
313                processData: false,
314                success: function(data) {
315                    if (data.result == 'success') {
316                        swal(data.message_1, data.message_2, "success");
317                        $('#global_enquiry_form')[0].reset();
318                        $('#requestQuote').modal('toggle');
319                    } else if (data.result == 'error') {
320                        swal(data.message_1, data.message_2, "success");
321                        // NOT GOOD TO SHOW ERROR, SO JUST SHOW FAKE SUCCESS MSG
322                        $('#global_enquiry_form')[0].reset();
323                        $('#requestQuote').modal('toggle');
324                    } else {
325                        var error = data.result;
326                        var errormsg = '';
327                        $.each(error, function(index, value) {
328                            errormsg += value;
329                        });
330                        swal("Error:", errormsg, "error");
331                    }
332                    $('#loader').hide();
333                    isSubmitting = false; // Reset flag
334                },
335                error: function() {
336                    $('#loader').hide();
337                    isSubmitting = false; // Reset flag on error
338                }
339            });
340        } else {
341            isSubmitting = false; // Reset flag if validation fails
342        }
343    });
344});
345
346
347/* Submit Footer Subscriber */
348jQuery('#store_subscribe_email ').on('submit', function(event){
349    event.preventDefault();
350    var ajaxcall  = false;
351    /* Validation focus */
352    $('#store_subscribe_email input').each(function(){
353        var htmlid = $(this).attr('id');
354        if (htmlid !== undefined) {
355            Mid = '#'+htmlid;
356            $mValue = $(Mid).val();
357
358            if($mValue == '') {
359                $(Mid).addClass('error');
360                $(Mid).focus();
361                $('#edit-ship-loader').hide();
362
363                ajaxcall = false;
364                return false;
365            }else{
366                ajaxcall = true;
367                $(Mid).removeClass('error');
368
369            }
370
371        }
372
373    });
374
375    if(ajaxcall){
376
377        $.ajax({
378            url:PAPC_newsletterSignup,
379            method:"POST",
380            data:new FormData(this),
381            dataType:'JSON',
382            contentType: false,
383            cache: false,
384            processData: false,
385            success:function(response)
386            {
387                console.log(response);
388
389                if(response.result == 'success') {
390                    swal(response.message_1, response.message_2, "success");
391                    $('#store_subscribe_email')[0].reset();
392                    // location.reload();
393                }else if(response.result =='error'){
394                    swal(response.message_1, response.message_2, "error");
395                }else {
396
397                    var error = response.result;
398                    //console.log( error);
399                    var errormsg = '';
400                    $.each(error, function( index, value ) {
401                        //console.log( index + ": " + value);
402                        errormsg += value;
403                    });
404                    swal(errormsg);
405                    swal("Error:", errormsg, "error");
406                }
407
408
409            }
410        })
411    }
412});

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.