PageSourceSearch

https://abainternational.org/scripts/shopping/frmAskAboutProgramBookDiscount.js?v=20241112.1

js abainternational.org collected 2026-09-24 08:53:02 UTC 5,725 bytes, 153 lines download raw bytes

1// Create the modal elements
2var mQuestion = '';
3
4// Reusable jQuery elements
5const $okButton = $('<button type="button" class="button">OK</button>');
6const $changeButton = $('<button type="button" class="button">Change your mind</button>');
7const $modalQuestionParent = $('<div class="modal-question-parent"></div>');
8const $shoppingModalButtonsParent = $('<div class="shopping-modal-buttons"></div>');
9const $shoppingModalOverlay = $('<div class="shopping-modal-foundation"></div>');
10const $modalContent = $('<div class="shopping-modal-content"></div>');
11const $yesButton = $('<button type="button" class="button">Yes</button>');
12const $noButton = $('<button type="button" class="button">No</button>');
13const C_PROGRAM_BOOK_DEFAULT = "0";
14
15// Function to create and display the modal
16function showModal(question, oCallback, oNextFunction) {
17
18    mQuestion = question;
19
20    // empty stuff, just in case we get back here without reloading
21    $modalQuestionParent.empty();
22    $shoppingModalButtonsParent.empty();
23
24    // Append elements to modal
25    $shoppingModalButtonsParent.append($yesButton).append($noButton);
26    $modalQuestionParent.append('<p>' + question + '</p>');
27    $modalContent.append($modalQuestionParent).append($shoppingModalButtonsParent);
28    $shoppingModalOverlay.append($modalContent);
29    $('body').append($shoppingModalOverlay);
30
31    // Show the modal
32    $shoppingModalOverlay.css('display', 'flex');
33
34    // Handle button clicks
35    $yesButton.off('click').on('click', function () {
36        oCallback("1"); // Return 1 for "Yes"
37    });
38
39    $noButton.off('click').on('click', function () {
40        oCallback("0"); // Return 0 for "No"
41    });
42
43    $okButton.off('click').on('click', function () {
44        $shoppingModalOverlay.remove();
45        oNextFunction();
46    });
47
48    $changeButton.off('click').on('click', function () {
49        // Go back to [YES]/[NO]
50        fnChangedMyMind(oNextFunction);
51    })
52}
53
54
55function fnChangedMyMind(nextFunction) {
56    // relaunch the dialog
57    showModal(mQuestion, function (result) {
58        $("#programBookHiddenField").val(result);
59        fnShowOKButton($shoppingModalButtonsParent);
60    }, nextFunction);
61}
62
63function fnShowOKButton($shoppingModalButtonsParent) {
64    // Show the OK button and acknowledge the member's decision.
65
66    // Remove the current buttons and text.
67    $shoppingModalButtonsParent.empty();
68    $modalQuestionParent.empty();
69
70    console.log($("#programBookHiddenField").val());
71
72    // Acknowledge the member's decision.
73    let sResponse = $("#programBookHiddenField").val() === "1"
74        ? 'Thank you! You saved $10 on your registration (and some trees)!'
75        : 'Thank you! We\'ll have a program book waiting for you in the conference registration area!';
76
77    $modalQuestionParent.append('<p>' + sResponse + '</p><p><i>Use the ABAI Events app or website to get the latest program updates.</i></p>');
78
79    // Show the OK button.
80    $shoppingModalButtonsParent.append($changeButton).append($okButton);
81}
82
83function fnStretchUmbMasterBodyTable() {
84    // Cosmetic only. This function stretches the umbMasterBodyTable element to push the footer to the bottom of the screen.
85
86    try {
87
88        if ($(window).width() > 1000) {
89
90            // only process this with the non-mobile stylesheet
91
92            // get the height of the display port
93            var iWindowHeight = $(window).height();
94
95            // get the height of the header: #banner_wrapper + #naviWrap
96            var iHeaderHeight = $('#banner_wrapper').height() + $('#naviWrap').height();
97
98            // get the height of the footer: #footer
99            var iFooterHeight = $('#footer').height();
100
101            // calculate the value needed to fill the space on the screen
102            var iNeededHeight = iWindowHeight - iHeaderHeight - iFooterHeight;
103
104            var $masterBodyTable = $('#umbMasterBodyTable');
105
106            // get the height of #umbMasterBodyTable
107            // if it is less than the value needed to fill the page then set the height.
108            if ($masterBodyTable.height() < iNeededHeight) {
109                $masterBodyTable.height(iNeededHeight);
110            }
111
112        }
113    } catch (err) {
114        // bury the error; this function is cosmetic only
115    }
116}
117
118$(document).ready(function () {
119
120    try {
121
122        // this replaces mSkipProgramBook - this script is called from multiple web controls, sometimes more than once on the same page, which causes "issues"
123        if ($("#programBookHiddenField").length === 0) {
124            $('<input>').attr({
125                type: 'hidden',
126                id: 'programBookHiddenField',
127                name: 'programBookHiddenField'
128            }).appendTo('body');
129        }
130
131        $("#programBookHiddenField").val(C_PROGRAM_BOOK_DEFAULT);    // default to false - do NOT skip the Program Book
132
133        // Set up the showModal function
134        $('#openModalButton').off('click').on('click', function () {
135            showModal('Want to save ten dollars by skipping the program book on site?', function (result) {
136                $("#programBookHiddenField").val(result);
137                fnShowOKButton($shoppingModalButtonsParent);
138            });
139        });
140
141        //  cosmetic only
142        fnStretchUmbMasterBodyTable();
143    } catch (ex) { handleProgramBookDiscountException(ex); }
144
145});
146
147function handleProgramBookDiscountException(ex) {
148    console.error(`Exception caught:`);
149    console.error(`Message: ${ex.message}`);
150    console.error(`Stack trace: ${ex.stack}`);
151
152    alert(`An error occurred: ${ex.message}`);
153}

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.