PageSourceSearch

https://espacedonateur.plan-international.fr/Client/Scripts/ConsentDisplay.js

js plan-international.fr collected 2026-10-02 07:42:25 UTC 6,087 bytes, 158 lines download raw bytes

1/*jslint undef: false */
2/*globals BLACKBAUD hdnOptOut, SubmitConsentPopUpOverlay, EnableDisableConsentResponse, EnableDisableConsents, hdnCRMSolicitCode, hdnCRMConsentSolicitCode, hdnValidationGroup */
3
4/**
5 * @file  ConsentDisplay
6 * Holds Javascript for managing Global Opt out 
7 * funcationlity for consent part
8 * Not being used in User Email Preference form part
9 */
10
11if (!BLACKBAUD) {
12    var BLACKBAUD = {};
13}
14BLACKBAUD.netcommunity = BLACKBAUD.netcommunity || {};
15
16BLACKBAUD.netcommunity.ConsentDisplay = function () {
17
18    // this function is used to open consent overlay option.
19    var consentOptionHeight, consentOptionWidth;
20    function OpenConsentDisplayOverlay() {
21        $(window).on('load resize', function () {
22            consentOptionHeight = ($(window).height() * 0.95);
23            consentOptionWidth = ($(window).width() * 0.95);
24            $(".consentModal-content").css({ 'max-height': consentOptionHeight, 'max-width': consentOptionWidth });
25        });
26        if (typeof (hdnValidationGroup) !== "undefined" && !Page_ClientValidate(hdnValidationGroup)) {
27            return false;
28        }
29        if ($("#" + hdnConsentAlreadyGiven).val() !== "1") {
30            $('body').css({ 'overflow': 'hidden' });
31            consentOptionHeight = ($(window).height() * 0.95);
32            consentOptionWidth = ($(window).width() * 0.95);
33            $(".consentModal-content").css({ 'max-height': consentOptionHeight, 'max-width': consentOptionWidth });
34            $(".pnlConsentPopup").removeClass("displayNone");
35            $find("mpeConsentPopup").show();
36            setEnableDisableSubmitButton(true);
37            return false;
38        } else {
39            setEnableDisableSubmitButton(true);
40            return true;
41        }
42    }
43
44    function setEnableDisableSubmitButton(isEnable) {
45        var submitButton = $('[id*=btnConsentPopupSubmit]');
46        if (submitButton && submitButton.length > 0 && $(submitButton[0]).is(':visible')) {
47            if (isEnable && isEnable === true) {
48                $(submitButton[0]).removeAttr("disabled");
49            } else {
50                $(submitButton[0]).attr("disabled", "disabled");
51            }
52        }
53    }
54
55    function CloseConsentDisplayOverlay() {
56        $find("mpeConsentPopup").hide();
57        setEnableDisableSubmitButton(false);
58        return false;
59    }
60
61
62    this.OpenConsentDisplayOverlay = OpenConsentDisplayOverlay;
63};
64BLACKBAUD.netcommunity.ConsentDisplay = new BLACKBAUD.netcommunity.ConsentDisplay();
65
66function submitConsentPopUpOverlay(event) {
67    var allRequiredResponseProvided, summaryContent, consentOptions, bt
67nSubmit;
68
69    btnSubmit = $('[id*="btnConsentPopupSubmit"]');
70
71    if (!document.getElementById("" + $(btnSubmit)[0].id + "").hasAttribute("doNotClick")) {
72        document.getElementById("" + $(btnSubmit)[0].id + "").setAttribute("doNotClick", "true");
73    } else {
74        event.preventDefault();
75        event.stopPropagation();
76        return false;
77    }
78
79    allRequiredResponseProvided = true;
80    summaryContent = "The following error(s) must be corrected before continuing:<ul>";
81
82    // find all the consent options rows
83    consentOptions = $("div[id$=divConsentOptions]").find(".consentOptions");
84
85    // Iterate on consent option to find which all are required.
86    $.each(consentOptions, function () {
87        var consentOptionType, caption, isRequired, optIn, optOut, chkBox;
88        consentOptionType = $(this).find(".consentOptionType");
89        caption = consentOptionType.find(".consentCaption");
90        isRequired = consentOptionType.find(".isRequired");
91
92        if (isRequired.length > 0) {
93
94            optIn = $(this).find('.clsOptIn input[type="radio"]');
95            optOut = $(this).find('.clsOptOut input[type="radio"]');
96            chkBox = $(this).find('.clschkOptIn input[type="checkbox"]');
97
98            // if no response has been provided, add error message. 
99            if (chkBox.length === 0 && optIn[0].checked === false && optOut[0].checked === false) {
100                summaryContent = summaryContent + "<li>" + caption[0].innerText.replace(":", "") + ": Required" + "</li>";
101                allRequiredResponseProvided = false;
102            } else {
103                if (chkBox.length > 0 && !$(chkBox).is(':checked')) {
104                    summaryContent = summaryContent + "<li>" + caption[0].innerText.replace(":", "") + ": Required" + "</li>";
105                    allRequiredResponseProvided = false;
106                }
107            }
108        }
109    });
110
111    // If all the required response are not provided, show error message and let overlay remain open. 
112    if (!allRequiredResponseProvided) {
113        $(".consentOptionOverlayErrorMessages").html(summaryContent);
114        $(".consentOptionOverlayErrorMessages").show();
115        if (document.getElementById("" + $(btnSubmit)[0].id + "").hasAttribute("doNotClick")) {
116            document.getElementById("" + $(btnSubmit)[0].id + "").removeAttribute("doNotClick");
117        }
118        event.preventDefault();
119    }
120    else {
121        $("#" + hdnConsentAlreadyGiven).val("1");
122    }
123
124    return true;
125}
126
127function RegisterConsentEvents() {
128
129    $('.btnSubmit').click(function (event) {
130        submitConsentPopUpOverlay(event);
131    });
132}
133function setConsentOptionsWidthDynamicallyForDonationInline() {
134    var newWidth = $(".DonationCaptureFieldCaption ").innerWidth();
135    $(".div-table-cell-width50").width(newWidth);
136}
137
138
139function addScrollStyles() {
140    var bodyStyles = '', css = "overflow-x: auto !important;overflow-y: auto !important";
141    if ($("#BodyId").attr("style") == "undefined") {
142        bodyStyles = css;
143    }
144    else {
145        bodyStyles = $("#BodyId").attr("style");
146        if (bodyStyles.endsWith(";")) {
147            bodyStyles = bodyStyles + css;
148        }
149        else {
150            bodyStyles = bodyStyles + ";" + css;
151        }
152    }
153    $("#BodyId").attr("style", bodyStyles);
154}
155
156
157
158

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.