PageSourceSearch

https://donate.esnorcal.org/_includes/legacyJqueryDependencies/jqueryDependencies.js?v=2026-09-22T11:37:44

js esnorcal.org collected 2026-09-29 04:56:56 UTC 17,174 bytes, 469 lines download raw bytes

1
2//WARNING: do not use for form customization.  these functions have been deprecated and will be dropped in a future version of this app.
3//WARNING: do not use for form customization.  these functions have been deprecated and will be dropped in a future version of this app.
4//WARNING: do not use for form customization.  these functions have been deprecated and will be dropped in a future version of this app.
5//WARNING: do not use for form customization.  these functions have been deprecated and will be dropped in a future version of this app.
6//WARNING: do not use for form customization.  these functions have been deprecated and will be dropped in a future version of this app.
7
8//TODO: Fix and remove all JQUERY dependencies and rmove this forced injection.  They only belong in themes.
9//if (!$) {
10//    document.appendChild('<script src="/_includes/_jquery/jquery-3.7.1.min.js"  type="text/javascript"></script>');
11//}
12
13document.addEventListener('DOMContentLoaded', function () {
14
15    //Default Implementation, override as necessary
16    if (window.jQuery) {
17         
18        jQuery(".promoCodeWidget").each(function(i, elem) {
19
20            if (jQuery(elem).val().length > 0) 
21                validatePromoCode(elem);
22            
23        });
24    }
25
26});
27
28//todo: eliminate jquery dependencies
29function convertCreditCardTypeDropDownToImage() {
30
31    if (jQuery(".cc-type-images").length > 0)
32    {
33
34        // change cc type
35        jQuery('select.tsDropDownLists_creditCardTypes.cc-type-images').wrap('<div id="cc-type-images-container"></div>');
36        jQuery('#cc-type-images-container').append('<ul id="cc-images"><li><img src="../_sysimages/visa-off.png" id="visa" alt="Visa" /></li><li><img src="../_sysimages/mc-off.png" id="mastercard" alt="Mastercard" /></li><li><img src="../_sysimages/amex-off.png" id="amex" alt="American Express" /></li><li><img src="../_sysimages/discover-off.jpg" id="discover"alt="Discover" /></li></ul>');
37
38        // click function for cc images
39        jQuery('ul#cc-images li img').click(function () {
40
41            if (jQuery(this).attr('id') == "visa")
42            {
43                setCreditCardImages("visa");
44                jQuery('#visa').attr('src', '../_sysimages/visa.png');
45            }
46            else if (jQuery(this).attr('id') == "mastercard")
47            {
48                setCreditCardImages("mastercard");
49                jQuery('#mastercard').attr('src', '../_sysimages/mc.png');
50            }
51            else if (jQuery(this).attr('id') == "amex")
52            {
53                setCreditCardImages("amex");
54                jQuery('#amex').attr('src', '../_sysimages/amex.png');
55            }
56            else if (jQuery(this).attr('id') == "discover")
57            {
58                setCreditCardImages("discover");
59                jQuery('#discover').attr('src', '../_sysimages/discover.jpg');
60            }
61            else
62                setCreditCardImages();
63
64        });
65
66        addCCNumKeyUpHandler();
67
68    }
69
70}
71
72//todo: eliminate jquery dependencies
73function addCCNumKeyUpHandler() {
74
75    //Default Implementation, override as necessary
76    jQuery('input.transCC').keyup(function () {
77
78        if (GetCardType(jQuery(this).val()) == "visa")
79        {
80            setCreditCardImages("visa");
81            jQuery('#visa').attr('src', '../_sysimages/visa.png');
82            jQuery('#visa').addClass('active-cc-type');
83        }
84        else if (GetCardType(jQuery(this).val()) == "mastercard")
85        {
86            setCreditCardImages("mastercard");
87            jQuery('#mastercard').attr('src', '../_sysimages/mc.png');
88            jQuery('#mastercard').addClass('active-cc-type');
89        }
90        else if (GetCardType(jQuery(this).val()) == "amex")
91        {
92            setCreditCardImages("amex");
93            jQuery('#amex').attr('src', '../_sysimages/amex.png');
94            jQuery('#amex').addClass('active-cc-type');
95        }
96        else if (GetCardType(jQuery(this).val()) == "discover")
97        {
98            setCreditCardImages("discover");
99            jQuery('#discover').attr('src', '../_sysimages/discover.jpg');
100            jQuery('#discover').addClass('active-cc-type');
101        }
102        else 
103            setCreditCardImages();
104         
105    });
106
107}
108
109//todo: eliminate jquery dependencies
110function setCreditCardImages(active) {
111
112    //Default Implementation, override as necessary
113    if (active == "visa")
114    {
115        jQuery('#mastercard').attr('src', '../_sysimages/mc-off.png');
116        jQuery('#amex').attr('src', '../_sysimages/amex-off.png');
117        jQuery('#discover').attr('src', '../_sysimages/discover-off.jpg');
118        jQuery('#mastercard').removeClass('active-cc-type');
119        jQuery('#amex').removeClass('active-cc-type');
120        jQuery('#discover').removeClass('active-cc-type');
121        // set mapped select to the visa
122        jQuery('select.tsDropDownLists_creditCardTypes.cc-type-images').val('1');
123    }
124    else if (active == "mastercard")
125    {
126        jQuery('#visa').attr('src', '../_sysimages/visa-off.png');
127        jQuery('#amex').attr('src', '../_sysimages/amex-off.png');
128        jQuery('#discover').attr('src', '../_sysimages/discover-off.jpg');
129        jQuery('#visa').removeClass('active-cc-type');
130        jQuery('#amex').removeClass('active-cc-type');
131        jQuery('#discover').removeClass('active-cc-type');
132        // set mapped select to the mastercard
133        jQuery('select.tsDropDownLists_creditCardTypes.cc-type-images').val('2');
134    }
135    else if (active == "amex")
136    {
137        jQuery('#visa').attr('src', '../_sysimages/visa-off.png');
138        jQuery('#mastercard').attr('src', '../_sysimages/mc-off.png');
139        jQuery('#discover').attr('src', '../_sysimages/discover-off.jpg');
140        jQuery('#visa').removeClass('active-cc-type');
141        jQuery('#mastercard').removeClass('active-cc-type');
142        jQuery('#discover').removeClass('active-cc-type');
143        // set mapped select to the amex
144        jQuery('select.tsDropDownLists_creditCardTypes.cc-type-images').val('3');
145    }
146    else if (active == "discover")
147    {
148        jQuery('#visa').attr('src', '../_sysimages/visa-off.png');
149        jQuery('#mastercard').attr('src', '../_sysimages/mc-off.png');
150        jQuery('#amex').attr('src', '../_sysimages/amex-off.png');
151        jQuery('#visa').removeClass('active-cc-type');
152        jQuery('#mastercard').removeClass('active-cc-type');
153        jQuery('#amex').removeClass('active-cc-type');
154        // set mapped select to the discover
155        jQuery('select.tsDropDownLists_creditCardTypes.cc-type-images').val('4');
156    }
157    else
158    {
159        jQuery('#visa').attr('src', '../_sysimages/visa-off.png');
160        jQuery('#mastercard').attr('src', '../_sysimages/mc-off.png');
161        jQuery('#amex').attr('src', '../_sysimages/amex-off.png');
162        jQuery('#discover').attr('src', '../_sysimages/discover-off.jpg');
163        jQuery('#visa').removeClass('active-cc-type');
164        jQuery('#mastercard').removeClass('active-cc-type');
165        jQuery('#amex').removeClass('active-cc-type');
166        jQuery('#discover').removeClass('active-cc-type');
167    }
168
169}
170
171// function that detects cc type based on cc number
172function GetCardType(number) {
173
174    // visa
175    var re = new RegExp("^4");
176    if (number.match(re) != null)
177        return "visa";
178
179    // Mastercard
180    re = new RegExp("^5[1-5]");
181    if (number.match(re) != null)
182        return "mastercard";
183
184    // AMEX
185    re = new RegExp("^3[47]");
186    if (number.match(re) != null)
187        return "amex";
188
189    // Discover
190    re = new RegExp("^(6011|622(12[6-9]|1[3-9][0-9]|[2-8][0-9]{2}|9[0-1][0-9]|92[0-5]|64[4-9])|65)");
191    if (number.match(re) != null)
192        return "discover";
193
194    return "";
195
196}
197 
198//fails forms fatally if Jquery not installed in template
199//TODO: FIX ASAP, Depdency creation
200 
201function validateP2PUrlSuffixField(elem, orgPortalId) {
202
203    //Default Implementation, override as necessary
204    elem = $(elem);
205    var val = elem.val();
206
207    //disable the submit button
208    elem.parents("form").find("input[type=submit]").attr('disabled', 'disabled');
209     
210    var ajaxParms = {
211        orgPortalId: orgPortalId,
212        suffix: val,        
213        pageType: 3 //Inv Portal
214    };
215     
216    App.BackgroundPostJsonAsync('/api/WebFormsAppAjaxEndpoint/IsP2PPageURLSuffixAvailable',
217        JSON.stringify(ajaxParms),
218        function (data) {
219
220            var validationIcon;
221
222            $(".urlValidationIcon").remove();
223
224            if (data) {
225
226                //elem.val(data.token); // not need to stomp with same info
227
228                var successClass = $(elem).data('success-class') || "fa fa-check";
229
230                validationIcon = $("<span class='urlValidationIcon " + successClass + "'/>");
231                elem.after(validationIcon);
232
233                //enable the submit button
234                elem.parents("form").find("input[type=submit]").removeAttr('disabled');
235
236            }
237            else
238            {
239
240                var failureClass = $(elem).data('failure-class') || "fa fa-exclamation-circle";
241                var alterMessage = $(elem).data('alert-message') || 'There is already a page registered with same name or same Custom URL.';
242
243                var displayAlert = true;
244                if ($(elem).data('display-alert')) 
245                    displayAlert = $(elem).data('display-alert') === "true";                
246
247                validationIcon = $("<span class='urlValidationIcon " + failureClass + "'/>");
248                elem.after(validationIcon);
249
250                if (displayAlert) 
251                    alert(alterMessage);
252                
253            }
254
255        },
256        function (error) {
257            console.log(error);
258        });
259
260}
261
262function validateEnteredPromoCode() {    
263
264    //lookup promo element using context    
265    var promoInputElem = null;
266
267    if (!isBlank(WebFormContext.Form.PromoCodeEntryFieldId))
268        promoInputElem = document.getElementById(WebFormContext.Form.PromoCodeEntryFieldId);
269
270    if(promoInputElem != null)
271        validatePromoCode(promoInputElem);
272
273}
274
275function validatePromoCode(elem) {
276
277    console.log('validate entered promo code called (' + elem.value + ')');
278
279    if (!isBlank(elem.value))
280    {
281         
282        $(elem).nextAll(".promoCodeValidationInfo").html(""); 
283        $(".ts_sys_ReadOnlyFields_promoMessages").html("");
284         
285        var formId = getCurrentFormId();
286        var promoCodeEntered = elem.value;
287        var totalAmount = getDonationAmountMinusTickets();
288        var ticketQuantityMap = getTicketQuantityMap();        
289 
290        beforePromoCodeValidation(promoCodeEntered, totalAmount, ticketQuantityMap);
291
292        var tixModified = [];
293
294        for (var key in ticketQuantityMap) 
295            if (ticketQuantityMap.hasOwnProperty(key)) {
296
297                var tikInfo = {};
298
299                tikInfo.Ticket_Id = key; 
300                tikInfo.Quantity = ticketQuantityMap[key]; 
301
302                console.log('Key: ' + tikInfo.Ticket_Id + ', Value: ' + tikInfo.Quantity);
303
304                tixModified.push(tikInfo);
305
306            }
307   
308        //moved to app.lib.js (2.27.26)
309        var realTotalAmt = getDonationAmount();
310
311        ValidatePromoCode(promoCodeEntered, realTotalAmt, tixModified, formId,
312            function (result) {
313
314                console.log('ValidatePromoCode successful');                
315                onPromoCodeResultSuccess(result, elem);
316
317            },
318            function (error) {
319
320                console.log('ValidatePromoCode failed - ' + error);
321                onPromoCodeError(error, elem, false);
322
323            });
324             
325    }
326    else
327    {
328
329        $(elem).nextAll(".promoCodeValidationIcon").removeClass("fa-check").removeClass("fa-exclamation-circle");        
330        $(elem).nextAll(".promoCodeValidationInfo").html("");        
331        $(".ts_sys_ReadOnlyFields_promoMessages").html("");
332
333    }
334
335}
336
337//Override
338function beforePromoCodeValidation(promoCodeEntered, totalAmount, ticketQuantityMap) {}
339
340function onPromoCodeResultSuccess(data, elem) {
341     
342    if (!data)
343    {
344        onPromoCodeError(null, elem, true);
345        return;
346    }
347
348    if (data.Success) //IsValid)
349        onPromoCodeValidated(data, elem);
350    else  
351        onPromoCodeInvalidated(data, elem); 
352
353}
354
355//Default Implementation, override as necessary
356function onPromoCodeValidated(data, elem) {
357     
358    //Default Implementation, override as necessary
359    var successClass = $(elem).data('success-class') || "fa fa-check";
360
361    var message = 'Promo Code Accepted.'; //data.Message || 
362
363    //Default Implementation, override as necessary
364    $(elem).nextAll(".promoCodeValidationIcon").removeClass("fa-check").removeClass("fa-exclamation-circle").addClass(successClass).attr("title", message);
365    
366    //var promoOutput = "Promo Code Accepted: " + (data.IsValid ? "Yes" : "No") + "<br/>";
367    //promoOutput += "Message: " + message + "<br/>";
368    //promoOutput += "Discount Amount: $" + data.DiscountAmount.toFixed(2) + "<br/>";
369    //promoOutput += "New Total: $" + data.DiscountedTotalAmount.toFixed(2) + "<br/>";
370
371    var discTotal = (getDonationAmount() - data.DiscountAmount);
372
373    var promoOutput = "Promo Code Accepted: Yes <br/>";
374    promoOutput += "Message: " + message + "<br/>";    
375    promoOutput += "Discount Amount: $" + data.DiscountAmount.toFixed(2) + "<br/>";
376    promoOutput += "New Total: $" + discTotal.toFixed(2) + "<br/>";    
377
378    //Default Implementation, override as necessary
379    $(elem).nextAll(".promoCodeValidationInfo").html(promoOutput);
380
381    //Default Implementation, override as necessary
382    $(".ts_sys_ReadOnlyFields_promoMessages").html(message);
383
384    //todo: move this hacky dependency to a function in form object that does the validation and stop calling old Jquery code
385    if (Form != null)
386    { 
387
388        //set promo code has hacky fire processed event
389        if (Form.SetPromoCodeDiscountAmount != null && typeof Form.SetPromoCodeDiscountAmount == 'function')
390            Form.SetPromoCodeDiscountAmount(data.DiscountAmount);
391
392        Form.FirePromoCodeValidatedEvent(data.DiscountAmount);        
393
394    }
395
396}
397
398function onPromoCodeInvalidated(data, elem) {
399
400    var failureClass = $(elem).data('failure-class') || "fa fa-exclamation-circle";
401
402    var message = data.ErrorMessage || "Promo Code Invalid."; //data.Message
403    
404    $(elem).nextAll(".promoCodeValidationIcon").removeClass("fa-check").removeClass("fa-exclamation-circle").addClass(failureClass).attr("title", message);    
405    $(elem).nextAll(".promoCodeValidationInfo").html("Message: " + message);    
406    $(".ts_sys_ReadOnlyFields_promoMessages").html(message);
407
408    //todo: move this hacky dependency to a function in form object that does the validation and stop calling old Jquery code
409    if (Form != null)
410    { 
411
412        Form.FirePromoCodeValidatedEvent();
413
414        //set promo code has hacky fire processed event
415        if (Form.SetPromoCodeDiscountAmount != null && typeof Form.SetPromoCodeDiscountAmount == 'function')
416            Form.SetPromoCodeDiscountAmount(0.00);
417
418    }
419
420}
421 
422function onPromoCodeError(error, elem, securityError) {
423
424    if (securityError)
425    {
426
427        //IMPORTANT: core app code has to be rewritten to remove Jquery Dependency
428        $(elem).nextAll(".promoCodeValidationInfo").html("");
429        $(elem).nextAll(".promoCodeValidationIcon").removeClass("fa-check").removeClass("fa-exclamation-circle");
430
431        //IMPORTANT: core app code has to be rewritten to remove Jquery Dependency
432        $(".ts_sys_ReadOnlyFields_promoMessages").html("");
433
434    }
435    else
436    {
437
438        if (error)  
439            console.log(error); 
440
441    }
442
443    //todo: move this hacky dependency to a function in form object that does the validation and stop calling old Jquery code
444    if (Form != null)
445    { 
446
447        Form.FirePromoCodeProcessingErrorEvent(error);
448
449        //set promo code has hacky fire processed event
450        if (Form.SetPromoCodeDiscountAmount != null && typeof Form.SetPromoCodeDiscountAmount == 'function')
451            Form.SetPromoCodeDiscountAmount(0.00);
452
453    }
454
455}
456
457function singleLineAddressJquerySlideUpHelper(nativeElem) {
458
459    //IMPORTANT: core app code has to be rewritten to remove Jquery Dependency
460    $(nativeElem).find('.isDonorAddress1,.isDonorAddress2,.isDonorZipCode,.isDonorCity,.isDonorState_id,.isDonorCountry_id').parents('div.tsFormRows').hide();
461
462}
463
464function singleLineAddressJquerySlideDownHelper(nativeElem) {
465
466    //IMPORTANT: core app code has to be rewritten to remove Jquery Dependency
467    $(nativeElem).find('.isDonorAddress1,.isDonorAddress2,.isDonorZipCode,.isDonorCity,.isDonorState_id,.isDonorCountry_id').parents('div.tsFormRows').show();
468
469}

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.