1(function ($, Drupal) { 2 "use strict"; 3 Drupal.behaviors.dropkickSelects = { 4 attach: function (context, settings) { 5 6 var getUrlParameter = function getUrlParameter(sParam) { 7 var sPageURL = window.location.search.substring(1), 8 sURLVariables = sPageURL.split('&'), 9 sParameterName, 10 i; 11 12 for (i = 0; i < sURLVariables.length; i++) { 13 sParameterName = sURLVariables[i].split('='); 14 15 if (sParameterName[0] === sParam) { 16 return sParameterName[1] === undefined ? true : decodeURIComponent(sParameterName[1]); 17 } 18 } 19 }; 20 21 function removeHashFromString(string) { 22 return string.split('#')[0]; 23 } 24 function addHashtoString(string, hash) { 25 return removeHashFromString(string) + hash; 26 } 27 28 if ($('.don-tabs')[0]) { 29 30 var otherText = $("#tabform-1 .amount-selector option[value='other']").text(); 31 32 var onceSelect = $("#tabform-1 .amount-selector").dropkick({ 33 mobile: true 34 }); 35 var regularSelect = $("#tabform-2 .second-amount-selector").dropkick({ 36 mobile: true 37 }); 38 39 $(".don-tab-content").hide(); 40 // Make regular donation the default 41 $('#radio-mensuel').click(); 42 $("#tabform-2").show(); 43 $("input[name$='formtabs']").click(function() { 44 var test = $(this).val(); 45 $(".don-tab-content").hide(); 46 $("#" + test).show(); 47 }); 48 49 var frequencyParam = getUrlParameter('frequency'); 50 if ((frequencyParam) && (frequencyParam == 'once')) { 51 $('#radio-ponctuel').click(); 52 $(".don-tab-content").hide(); 53 $("#tabform-1").show(); 54 } 55 if ((frequencyParam) && (frequencyParam == 'regular')) { 56 $('#radio-mensuel').click(); 57 $(".don-tab-content").hide(); 58 $("#tabform-2").show(); 59 } 60 61 var amountParam = getUrlParameter('amount'); 62 function changeAmount(amountParam) { 63 if ((amountParam) && (amountParam > 0)) { 64 var translatedAmount = amountParam / 100; 65 var amount = ''; 66 if ($("#tabform-1 select option[value='" + translatedAmount + "']").length > 0) { 67 var text = translatedAmount + ' â¬'; 68 amount = translatedAmount; 69 } else { 70 var text = otherText; 71 amount = 'other' 72 } 73 $("#tabform-1 select").val(amount); 74 $('#tabform-1 .dk-selected').text(text); 75 $("#tabform-1 .dk_options_inner li").each(function(){ 76 $(this).removeAttr('class'); 77 if ($(this).text() == text){ 78 $(this).attr('class', 'dk_option_current'); 79 } 80 }); 81 82 if ($("#tabform-2 select option[value='" + translatedAmount + "']").length > 0) { 83 var text = translatedAmount + ' â¬'; 84 amount = translatedAmount; 85 } else { 86 var text = otherText; 87 amount = 'other' 88 } 89 $("#tabform-2 select").val(amount); 90 $('#tabform-2 .dk-selected').text(text); 91 $("#tabform-2 .dk_options_inner li").each(function(){ 92 $(this).removeAttr('class'); 93 if ($(this).text() == text){ 94 $(this).attr('class', 'dk_option_current'); 95 } 96 }); 97 $('input.amount').val(amountParam); 98 99 } 100 } 101 var amountParam = getUrlParameter('amount'); 102 changeAmount(amountParam); 103 104 function selectWatcher() { 105 $('.don-tab-content form', context).submit(function( event ) { 106 event.preventDefault(); 107 var selectVal = $(this).find('select[name="amount_select"]').val(); 108 if (selectVal == 'other') { 109 if (amountParam) { 110 var finalAmount = amountParam / 100; 111 } else { 112 var finalAmount = ''; 113 } 114 var other = true; 115 } else { 116 var finalAmount = selectVal; 117 var other = false;
118 } 119 120 $(this).find('input.amount').val(Math.round(finalAmount * 100)); 121 let formType = $('input[name="formtabs"]:checked').val(); 122 let formName = ''; 123 switch (formType) { 124 case 'tabform-1': 125 formName = "Don ponctuel"; 126 if (other) { 127 var url = $("#tabform-1 form").attr('action'); 128 $("#tabform-1 form").attr('action', addHashtoString(url,'#once')); 129 } else { 130 var url = $("#tabform-1 form").attr('action'); 131 $("#tabform-1 form").attr('action', removeHashFromString(url)); 132 } 133 break; 134 case 'tabform-2': 135 formName = "Don mensuel"; 136 if (other) { 137 var url = $("#tabform-2 form").attr('action'); 138 $("#tabform-2 form").attr('action', addHashtoString(url,'#regular')); 139 } else { 140 var url = $("#tabform-2 form").attr('action'); 141 $("#tabform-2 form").attr('action', removeHashFromString(url)); 142 } 143 break; 144 } 145 // console.table([ 146 // ["event", "AgirDonHP"], 147 // ["donChoice", formName], 148 // ["donValue", finalAmount] 149 // ]); 150 window.dataLayer.push({ 151 'event': 'AgirDonHP', 152 'donChoice': formName, 153 'donValue': finalAmount 154 }); 155 $(this).off("submit").submit(); 156 selectWatcher(); 157 }); 158 } 159 selectWatcher(); 160 161 setTimeout(function() { 162 var formActionUrl = new URL($('#tabform-1 form').attr('action')); 163 //console.log(formActionUrl); 164 if (formActionUrl.searchParams.get("amount")) { 165 166 var amountParam = formActionUrl.searchParams.get("amount"); 167 // console.log(amountParam); 168 // console.log(frequencyParam); 169 if (formActionUrl.searchParams.get("frequency")) { 170 var frequencyParam = formActionUrl.searchParams.get("frequency"); 171 if ((frequencyParam) && (frequencyParam == 'regular')) { 172 $('#radio-mensuel').click(); 173 $(".don-tab-content").hide(); 174 $("#tabform-2").show(); 175 } 176 } 177 changeAmount(amountParam) 178 } 179 }, 2000); 180 181 } 182 183 // collection details donation form: 184 185 if ($('.paragraph--type--donation-form')[0]) { 186 187 var win = window, 188 doc = document, 189 docElem = doc.documentElement, 190 body = doc.getElementsByTagName('body')[0], 191 x = win.innerWidth || docElem.clientWidth || body.clientWidth; 192 // on scroll actions 193 194 $(window).scroll(function(){ 195 if (!$('body').hasClass('form-manually-closed') && !$('body').hasClass('page-node-type-hub-highlight')) { 196 if (($(window).scrollTop() > 100) && (x > 990)) { 197 $(".paragraph--type--donation-form.open:not(.filled)").removeClass('open'); 198 } 199 if (($(window).scrollTop() < 50) && (x > 990)) { 200 $(".paragraph--type--donation-form").addClass('open'); 201 } 202 } 203 }); 204 if (($(window).scrollTop() < 50) && (x > 990) && !$('body').hasClass('page-node-type-hub-highlight')) { 205 $(".paragraph--type--donation-form").addClass('open'); 206 } 207 // open/close on click 208 $('.paragraph--type--donation-form .header-button').on('click', function(e) { 209 e.preventDefault(); 210 $(this).parent().addClass('open'); 211 }); 212 $('.paragraph--type--donation-form .minimize-form').on('click', function(e) { 213 e.preventDefault(); 214 $(this).parents('.paragraph--type--donation-form').removeClass('open'); 215 $('.leg-doc').removeClass('open'); 216 $('body').addClass('form-manually-closed'); 217 }); 218 219 // MAIN TABS switching 220 $('.paragraph--type--donation-form .header-tab a').on('click', function(e) { 221 e.preventDefault(); 222 $('.paragraph--type--donation-form .header-tab, .donation-content .tab').removeClass('active'); 223 $(this).parent().addClass('active'); 224 $('.' + $(this).data('goto')).addClass('active'); 225 226 }) 227 228 //formatting of custom value field -> disabled now because custom velue field is disabled 229 230 // $('.other-input input').inputmask({ 231 // alias: 'numeric', 232 // numeric: true, 233 // prefix: '', 234 // suffix: ' â¬', 235 // radixPoint: ',', 236 // groupSeparator: '', 237 // autoGroup: false, 238 // }); //specifying options 239 240 // $('.donation-options ul li.other-input').on('click', function() { 241 // $(this).parents('.donation-options').find('.active').removeClass('active'); 242 // $(this).addClass('active'); 243 // }) 244 245 // $('.donation-options ul li.other-input input').on('focus', function() { 246 // $(this).parents('.donation-options').find('.active').removeClass('active'); 247 // $(this).parent().addClass('active'); 248 // }) 249 250 // switching the amount buttons 251 $('.donation-options ul li button').on('click', function() { 252 $(this).parents('.donation-options').find('.active').removeClass('active'); 253 $(this).parent().addClass('active'); 254 $(this).parents('.tab').find('.content-options .content-field').removeClass('active'); 255 $('.content-options .' + $(this).data('content')).addClass('active'); 256 257 }) 258 259 //getting the frequency parameter from url and setting the form on load 260 var frequencyParam = getUrlParameter('frequency'); 261 if ((!frequencyParam) || (typeof frequencyParam == 'undefined')) { 262 // $('.header-tab:first-child, .tab:first-child').addClass('active'); 263 // Make mensual the default 264 $('.header-tab-mensuel, .tab-mensuel').addClass('active'); 265 } 266 if ((frequencyParam) && (frequencyParam == 'regular')) { 267 $('.header-tab-mensuel, .tab-mensuel').addClass('active'); 268 } 269 if ((frequencyParam) && (frequencyParam == 'once')) { 270 $('.header-tab-ponctuel, .tab-ponctuel').addClass('active'); 271 } 272 // if ((frequencyParam) && (frequencyParam == 'ifi')) { 273 // $('.header-tab-ifi, .tab-ifi').addClass('active'); 274 // } 275 276 //getting the amount parameter 277 var amountParam = getUrlParameter('amount'); 278 if ((!amountParam) || (typeof amountParam == 'undefined')) { 279 $('.donation-options ul li:first-child button').trigger('click');; 280 } 281 if ((amountParam) && (amountParam > 0)) { 282 $('.donation-options').each(function( index ) { 283 if ($(this).find("[data-amount='" + amountParam + "']")[0]) { 284 $(this).find("[data-amount='" + amountParam + "']").trigger('click'); 285 } else { 286 $(this).find('li:first-child button').trigger('click'); 287 } 288 }) 289 } 290 291 // //getting url parameters for hidden fields 292 // var reservedFieldParam = getUrlParameter('reserved_field'); 293 // if ((reservedFieldParam) || (typeof reservedFieldParam != 'undefined')) { 294 // $('#donation-form input[name="reserved_field"]').val(reservedFieldParam); 295 // } 296 297 // var reservedTrackingIraiserParam = getUrlParameter('reserved_tracking_iraiser'); 298 // if ((reservedTrackingIraiserParam) || (typeof reservedTrackingIraiserParam != 'undefined')) { 299 // $('#donation-form input[name="reserved_tracking_iraiser"]').val(reservedTrackingIraiserParam); 300 // } 301 // populating values and submitting the form on clicking on donate-link 302 $('.paragraph--type--donation-form .donate-link').on('click', function(e) { 303 e.preventDefault(); 304 var amount = $(this).parents('.tab').find('.donation-options .active button').data('amount'); 305 $(this).parents('.tab').find('form input[name="amount"]').val(Math.round(amount * 100)); 306 $(this).parents('.tab').find('form').submit(); 307 }); 308 309 //preventing the form to minimize on scroll when a button/tab was clicked 310 setTimeout(function() { 311 312 if (!$('.donation-header .header-tab.active')[0]) { 313 $('.header-tab:first-child, .tab:first-child').addClass('active'); 314 } 315 316 $('.donation-options ul li button, .paragraph--type--donation-form .header-tab a').on('click', function() { 317 $(this).parents('.paragraph--type--donation-form').addClass('filled'); 318 }); 319 }, 1000) 320 321 322 } 323 324 } 325 }; 326 327})(jQuery, Drupal);
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.