1function Asi_Web_iParts_Fundraising_DonationCreatorDisplay(containerId, otherRadioVal, decimalNumberSeparator, setSoftCreditContactKeyButton, softCreditContactKeyField) { 2 3 var container; 4 5 this.OnLoad = function() { 6 container = jQuery('#' + containerId); 7 8 jQuery(document).ready(function () { 9 var giftAmount2 = container.find('input[id$=GiftAmount2]'); 10 var giftAmount = container.find('input[id$=GiftAmount]'); 11 var premiumPagerKeyPressedTextBox = container.find('input[id$=PremiumPagerKeyPressed]'); 12 var giftAmountSelection = container.find('input[name$=GiftAmountSelection]'); 13 14 // This javascript ensures we remember which control we last selected when calling a postback 15 // upon exiting the GiftAmount2 text box 16 var lastSelectedControlIdTextBox = container.find('input[id$=LastSelectedElementIdAfterGiftAmountBlur]'); 17 if (lastSelectedControlIdTextBox && 18 lastSelectedControlIdTextBox.val() && 19 lastSelectedControlIdTextBox.val().length > 1) { 20 21 var lastControlId = lastSelectedControlIdTextBox.val(); 22 var lastControl = document.getElementById(lastControlId); 23 lastControl.focus(); 24 lastSelectedControlIdTextBox.val(' '); 25 26 // clear out lastClickedElementId to prevent us from reselecting the GiftAmount2 text box 27 var hiddenField = document.getElementById('lastClickedElementId'); 28 if (hiddenField != null) { 29 hiddenField.value = ''; 30 } 31 32 // this is a work around to remove any anchors in the URL, such as the anchor you go to when clicking on the "Skip to main content" link 33 location.hash = ''; 34 window.history.pushState('donationCreatorNoAnchorState', '', location.href); 35 } 36 37 if (premiumPagerKeyPressedTextBox && premiumPagerKeyPressedTextBox.val() && premiumPagerKeyPressedTextBox.val().length > 1) { 38 premiumPagerKeyPressedTextBox.val(' '); 39 jQuery('html, body').animate({ 40 scrollTop: container.offset().top 41 }, 100); 42 } 43 44 giftAmount.on('input', postBackGiftAmount); 45 giftAmount2.on('input', postBackGiftAmount2); 46 47 giftAmountSelection.on("change", function () { 48 //fireCustomValidator(); 49 var $this = jQuery(this); 50 $this.each(function() { 51 if ($this.prop('selected', true)) { 52 if ($this.val() !== otherRadioVal) { 53 // clicked on a radio button that isn't "Other" 54 giftAmount2.val(''); 55 56 //find required field validator and disable 57 // NOTE: ValidatorEnable causes the validator run, so when we enable we don't use ValidatorEnable, otherwise 58 // we end up with the validator behaving slightly differently to the others and displaying immediately. 59 ValidatorEnable(container.find('[id$=GiftAmountRequiredFieldValidator2]')[0], false); 60 ValidatorEnable(container.find('[id$=GiftAmount2RegExValidator]')[0], false); 61 } else { 62 // re-enable validator 63 container.find('[id$=GiftAmountRequiredFieldValidator2]')[0].enabled = true; 64 container.find('[id$=GiftAmount2RegExValidator]')[0].enabled = true; 65 } 66 } 67 }); 68 }); 69 var singlePaymentButton = container.find('input[id$=PaymentOptions_0]'); // Single payment option, use id instead of name due to RadioButtonList 70 if (singlePaymentButton.length > 0) { 71 72 singlePaymentButton.on('change', function () { 73 firePayPalVisibility(jQuery(this).is(':checked')); 74 }); 75 76 firePayPalVisibility(singlePaymentButton.is(':checked')); 77 } 78 79 // This event is fired if the javascript onready in PaymentCreator finishes before this onready 80 jQuery(document).on('OnloadLoopBack-PayPal', function (e) { 81 var singlePaymentRadio = container.find('input[id$=PaymentOptions_0]'); // Single payment option, use id instead of name due to RadioButtonList 82 if (singlePaymentRadio.length > 0) { 83 firePayPalVisibility(singlePaymentRadio.is(':checked')); 84 } 85 }); 86 }); 87 88 var postBackGiftAmount = debounce(function () { 89 var fieldIsValid = true;
90 var validators = [ 91 container.find('[id$=GiftAmountRegExValidator]')[0], 92 container.find('[id$=GiftAmountRequiredFieldValidator]')[0], 93 container.find('[id$=GiftAmountRangeValidator1]')[0] 94 ]; 95 96 jQuery.each(validators, function () { 97 ValidatorValidate(this); 98 if (!this.isvalid) 99 fieldIsValid = false; 100 }); 101 102 if (fieldIsValid) 103 __doPostBack(this.id, ''); 104 }, 1500); 105 106 var postBackGiftAmount2 = debounce(function () { 107 var fieldIsValid = true; 108 var validators = [ 109 container.find('[id$=GiftAmount2RegExValidator]')[0], 110 container.find('[id$=GiftAmountRequiredFieldValidator2]')[0], 111 container.find('[id$=GiftAmountRangeValidator2]')[0] 112 ]; 113 114 jQuery.each(validators, function() { 115 ValidatorValidate(this); 116 if (!this.isvalid) 117 fieldIsValid = false; 118 }); 119 120 if (fieldIsValid) 121 __doPostBack(this.id, ''); 122 }, 1500); 123 }; 124 125 // called on initial load and when radio buttons clicked 126 function firePayPalVisibility(showPayPal) { 127 jQuery(document).trigger( 128 { 129 type: "toggle-PayPal", 130 showPayPal: showPayPal 131 }); 132 } 133 134 // Public Functions 135 this.ValidateRadiosAndTextBox = function (source, args) { 136 var checked = container.find("input[name$='GiftAmountSelection']:checked"); 137 if (checked.length === 0 && container.find("input[id$='GiftAmount2']").val() === "") { 138 args.IsValid = false; 139 } else { 140 args.IsValid = true; 141 } 142 }; 143 144 this.EditCallBack = function (radWin) { 145 var refresh = false; 146 if (radWin !== null && typeof (radWin.IsDirty) === 'boolean') { 147 refresh = radWin.IsDirty; 148 } 149 else { 150 // if for some reason we dont get a rad window then assume we should refresh 151 refresh = true; 152 } 153 if (refresh) 154 window.location.reload(); 155 }; 156 157 this.OpenFinderAdder = function(e) { 158 ShowDialog('~/AsiCommon/Controls/Shared/FinderAdder/PartyFinderAdder.aspx?DocumentPath=$/ContactManagement/DefaultSystem/Queries/Contacts&PartyType=1&AllowAdd=true', null, null, null, "Find", null, "E", this.OpenFinderAdderCallBack, "ObjectBrowser", false, true); 159 }; 160 161 this.OpenFinderAdderCallBack = function (radwindow) { 162 var contactKey; 163 if (radwindow.newContactKey != null) 164 contactKey = radwindow.newContactKey; // We are creating a new contact via the "Add a contact" window 165 else { // We are using a preexisting contact 166 var result = radwindow.result; 167 if (result != null) 168 contactKey = result[0]; 169 } 170 if (contactKey) { 171 var contactSelectedKey = window.$get(softCreditContactKeyField); 172 contactSelectedKey.value = contactKey; 173 var elm = window.$get(setSoftCreditContactKeyButton); 174 if (elm != null) 175 elm.click(); 176 } 177 } 178}
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.