PageSourceSearch

https://www.rolls-roycemotorcarsoc.com/wp-content/plugins/pm-motor…/js/quick-quote-form.js?ver=1.0

js rolls-roycemotorcarsoc.com collected 2026-10-08 18:53:19 UTC 5,065 bytes, 136 lines download raw bytes

1var QuickQuoteForm = {};
2
3(function ($) {
4    QuickQuoteForm = {
5
6        successSubmitCallBack: null,//vin param
7
8        setSuccessSubmitCallBack: function(callback){
9            this.successSubmitCallBack = callback;
10        },
11
12        init: function () {
13            QuickQuoteForm.populateHiddenFields();
14            QuickQuoteForm.eventHandlers();
15        },
16
17        populateHiddenFields: function () {
18            $('#pmf_qq_source_url').val(window.location.href);
19            $('#pmf_qq_source_host').val(window.location.hostname);
20            $('#pmf_qq_source_path').val(window.location.pathname);
21            $('#pmf_qq_clicked_at_field').val(window.sessionStorage.getItem("gform-modal-clicked-at"));
22        },
23
24        addDashes: function (input, num1, num2) {
25            var val = $(input).val();
26            var regex = /(\d)/g;
27            var matches = val.match(regex);
28            if (val.length > num1 && val.length <= num2) {
29                matches.splice(num1, 0, '-');
30            }
31            if (val.length > num2) {
32                matches.splice(num1, 0, '-');
33                matches.splice(num2 + 1, 0, '-');
34            }
35            if(matches){
36                val = matches.join('');
37                $(input).val(val);
38            }
39        },
40
41        checkPhoneNumber: function (input) {
42            QuickQuoteForm.addDashes(input, 3, 6);
43        },
44
45        errorNotification: function (msg) {
46            msg = msg || 'Please complete all required fields';
47            let $formError = $("#pm_form_quick_quote .form-error");
48            $formError.html(msg);
49            clearTimeout(QuickQuoteForm.errorNotification.timer);
50            $formError.fadeIn('fast');
51            QuickQuoteForm.errorNotification.timer = setTimeout(function () {
52                $formError.fadeOut();
53            }, 7000);
54        },
55
56
57        eventHandlers: function () {
58            $('#pmf_qq_phone').on('keyup', function (e) {
59                if (e.keyCode == 8) return;
60                QuickQuoteForm.checkPhoneNumber(this);
61            });
62
63            $('#pm_form_quick_quote input').on('invalid', QuickQuoteForm.errorNotification);
64
65        
66
67            $('#pm_form_quick_quote input, #pm_form_quick_quote textarea').on('focus', function name(params) {
68                if (sessionStorage.getItem("gform-modal-clicked-at") == null &&
69                    'DataLayer' in window) {
70                    DataLayer.setClickedAtValue();
71                }
72            });
73
74            $('#pm_form_quick_quote input').on('click', function () {
75                $clickedAtField = $('#pmf_qq_clicked_at_field');
76                if ($clickedAtField.val() !== true && 'DataLayer' in window) {
77                    DataLayer.setClickedAtValue();
78                    $clickedAtField.val(window.sessionStorage.getItem("gform-modal-clicked-at"))
79                }
80            });
81
82            $(document.body).on("click", ".pmf-qq-btn", function() {
83                var vin = $(this).data("vin");
84                $("#pmf_qq_vin").val(vin);
85
86                // if("VLP" in window){                    
87                //     var vehicle = VLP.getVehicle(vin);
88                //     $("#source_url").val(window.location.origin + vehicle.vdp_href);
89                // }
90
91            });
92
93            $('form#pm_form_quick_quote').submit(function(e) {
94                e.preventDefault();
95                let $form = $(this);
96                let $btn = $form.find("button");
97                let $successMsg = $form.find(".success-msg");
98                let vinVal = $("#pmf_qq_vin").val();
99
100                $form.find('.captcha-error').hide();
101                $btn.button('loading');
102
103                PmGforms.preValidateRecaptchaV3($form,
104                    function() { // ✅ success captcha validation
105                        let leadId = PmGforms.generateLeadId();
106                        PmGforms.addHiddenField($form, 'leadId', leadId);
107
108                        $.ajax({
109                            url: $form.attr('action'),
110                            method: 'POST',
111                            dataType: 'json',
112                            data: $form.serialize() + '&ajax=true',
113                            success: function(response) {
114                                $btn.button('reset');
115                                $successMsg.fadeIn('fast');
116                                setTimeout(() => $successMsg.fadeOut(), 3000);
117
118                                if (typeof QuickQuoteForm.successSubmitCallBack === 'function') {
119                                    QuickQuoteForm.successSubmitCallBack(vinVal);
120                                }
121                            }
122                        });
123                    },
124                    function() { // ❌ captcha error
125                        $form.find('.captcha-error').show();
126                        $btn.button('reset');
127                    }
128                );
129            });
130
131        }
132    };
133    $(document).ready(function(){
134        QuickQuoteForm.init();
135    });
136})(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.