PageSourceSearch

https://www.susquehannavalleyhd.com/DesktopModules/Dominion/Common/Scripts/FormDialog.js?cdv=1390

js susquehannavalleyhd.com collected 2026-10-07 19:16:01 UTC 7,751 bytes, 190 lines download raw bytes

1/*globals initViewForm */
2
3(function ($) {
4    var existForm;
5
6    if (window.FormDialog === undefined) {
7        window.FormDialog = {};
8    }
9
10    function mergePageValidators(pageValidators) {
11        if (!pageValidators || pageValidators.length === 0) {
12            return;
13        }
14        pageValidators.forEach(function (item) {
15            window.Page_Validators.push(item);
16        });
17    }
18
19    function getLoadingDialog() {
20        return $('<div class="modal fade in" id="loadingDialog" role="dialog" aria-hidden="true" aria-labelledby="loadingDialogLabel"><div class="modal-dialog modal-sm"> <div class="modal-content"> <div class="modal-header"> <h5 class="modal-title" id="myModalLabel">Loading..</h5> </div><div class="modal-body"><div class="progress"> <div class="progress-bar progress-bar-striped active" role="progressbar" aria-valuenow="100" aria-valuemin="0" aria-valuemax="100" style="width:100%"></div></div></div></div></div></div>');
21    }
22
23    function displayDialog(option) {
24        if (existForm) {
25            existForm.clearReCaptcha();
26        }
27        var deferred = $.Deferred();
28        var $requestMoreInfomationPanel = $(option.panelSelector);
29        if (option.isPhoto && $requestMoreInfomationPanel.data("loaded")) {
30            addCustomCss();
31            $requestMoreInfomationPanel.modal("show");
32            $requestMoreInfomationPanel.find(".error-message").hide();
33            return deferred.resolve().promise();
34        }
35
36        var requestData = {
37            portalId: option.portalId,
38            moduleId: option.moduleId,
39            productId: option.productId,
40            formId: option.formId,
41            isFromFeatured: option.isFromFeatured,
42            prevSubmissionId: option.prevSubmissionId,
43            tabModuleId: option.tabModuleId,
44            useShowroomDetailsConfig: option.useShowroomDetailsConfig ? true : false,
45        };
46
47        if (option.forceSendLeadToThirdParty) {
48            requestData.forceSendLeadToThirdParty = option.forceSendLeadToThirdParty;
49        }
50        if (option.openFromTabId) {
51            requestData.openFromTabId = option.openFromTabId;
52        }
53
54        var ajaxOption = {
55            url: "//" + window.location.hostname + option.url,
56            data: requestData,
57            cache: false
58        };
59
60        var enforceModalFocusFn = $.fn.modal.Constructor.prototype.enforceFocus;
61        $requestMoreInfomationPanel.on("hidden.bs.modal", function () {
62            $('html, body').removeClass('modal-open'); //add class to body
63            $('#modalStyle').remove();
64            $.fn.modal.Constructor.prototype.enforceFocus = enforceModalFocusFn;
65        });
66
67        var currentPageValidators = window.Page_Validators;
68        var $loadingDialog = getLoadingDialog();
69        $loadingDialog.modal({ show: true, backdrop: "static" });
70
71        $.ajax(ajaxOption).then(function (responseData) {
72            if (responseData) {
73                $requestMoreInfomationPanel.find(".modal-body").html(responseData);
74                $requestMoreInfomationPanel.find(".recaptcha-section .error-message").hide();
75                $requestMoreInfomationPanel.data("loaded", true);
76                mergePageValidators(currentPageValidators);
77                $loadingDialog.on("hidden.bs.modal", function () {
78                    $.fn.modal.Constructor.prototype.enforceFocus = function () { };
79                    $requestMoreInfomationPanel.modal({ show: true, backdrop: "static" });
80                    var handlers = $(window).data('viewFormHandlers');
81                    if (handlers) {
82                        for (var i = 0; i < handlers.length; i++) {
83                            var handler = handlers[i];
84                            if ($requestMoreInfomationPanel.find('#' + handler.clientId).length > 0) {
85                                existForm = handler.init($requestMoreInfomationPanel);
86                                break;
87                            }
88                        }
89                    }
90
91                    if (option.isFormBrpPromotion) {
92                        $requestMoreInfomationPanel.find(".modal
92-body .CommentsField").text(option.brpPromotionText);
93                    }
94
95                    deferred.resolve();
96                }).modal("hide");
97            }
98        });
99        return deferred.promise();
100    }
101
102    function addCustomCss() {
103        if ($('#modalStyle').length === 0) {
104            $("body").prepend($("<style id=\"modalStyle\">").html("html.modal-open{overflow: initial;}"));
105        }
106    }
107
108    function getBrpActionByFormName(formName) {
109        switch (formName) {
110            case 'Get Price':
111                return 'click to get_a_quote|regular';
112            case 'Schedule a Test Drive':
113                return 'click to dealer_demo_std';
114            case 'Secure Finance Application':
115                return 'click to financing';
116            default:
117                return false;
118        }
119    }
120
121    FormDialog.init = function (option) {
122        $(option.buttonSelector).off('click')
123            .on("click",
124                function () {
125                    displayDialog(option);
126                    if (window.sendByCTAEventToBrpAnalytics) {
127                        const action = getBrpActionByFormName(option.formName);
128                        sendByCTAEventToBrpAnalytics(action, option.brpBrand);
129                    }
130                });
131    }
132
133    FormDialog.displayDialog = function (option) {
134        return displayDialog(option);
135    };
136
137    FormDialog.addDialogContent = function (option) {
138        var modalId = option.modalId;
139        var modalSelector = '#' + modalId;
140        var modalLabelId = option.modalId + '_label';
141        var modalTitle = option.modalTitle;
142        var modalHtml = '\
143        <div class="modal fade" id="'+ modalId + '" tabindex="-1" role="dialog" aria-labelledby="' + modalLabelId + '" aria-hidden="true">\
144          <div class="modal-dialog">\
145            <div class="modal-content">\
146              <div class="modal-header">\
147                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>\
148                <h4 class="modal-title" id="' + modalLabelId + '">' + modalTitle + '</h4>\
149              </div>\
150              <div class="modal-body"></div>\
151              <div class="modal-footer">\
152              </div>\
153            </div>\
154          </div>\
155        </div>'
156        if ($(modalSelector).length == 0) {
157            $("body").append(modalHtml);
158        }
159    };
160
161    FormDialog.initV2 = function (option) {
162        $(option.buttonSelector).off('click')
163            .on("click",
164                function () {
165                    FormDialog.addDialogContent(option);
166                    displayDialog(option);
167                    if (window.sendByCTAEventToBrpAnalytics) {
168                        const action = getBrpActionByFormName(option.formName);
169                        sendByCTAEventToBrpAnalytics(action, option.brpBrand);
170                    }
171                });
172    };
173
174    FormDialog.updateModalTitle = function (modalId, modalTitle) {
175        $("#" + modalId).find(".modal-title").html(modalTitle);
176    }
177
178    FormDialog.handleBrpAnalyticsEvent = function (formName, brpBrand) {
179        if (!formName || !brpBrand) {
180            return;
181        }
182
183        if (window.sendByCTAEventToBrpAnalytics) {
184            const action = getBrpActionByFormName(formName);
185            sendByCTAEventToBrpAnalytics(action, brpBrand);
186        }
187    }
188
189    return self;
190}(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.