1(function ($) { 2 var insuranceDlgIsOpen = false; 3 var insuranceTIDecline = false; 4 var insuranceDPDecline = false; 5 6 Drupal.behaviors.rcjs = { 7 insuranceCheck: function(trigger) { 8 if(insuranceDlgIsOpen) { 9 return false; 10 } 11 if(typeof Drupal.settings.rcInsuranceStates != 'undefined' && !$.cookie('rcstate')) { 12 var stateselect = $('<select><option value=\"\">' + Drupal.settings.rcInsuranceText['sel'] + '</option></select>').change(function() { 13 if($(this).val() != '') { 14 $(this).siblings('button').show(); 15 } else { 16 $(this).siblings('button').hide(); 17 } 18 }); 19 for(state in Drupal.settings.rcInsuranceStates) { 20 $(stateselect).append($('<option></option>').attr('value', state).append(Drupal.settings.rcInsuranceStates[state])); 21 } 22 $(stateselect).append($('<option></option>').attr('value', 'none').append(Drupal.settings.rcInsuranceText['nl'])); 23 var dlg = $('<div class=\"rc-insurance-state-select\"><span class=\"copy\">' + Drupal.settings.rcInsuranceText['prompt'] + '</span></div>'); 24 $(dlg).append(stateselect) 25 $(dlg).append($('<button style=\"display:none;\">' + Drupal.settings.rcInsuranceText['button'] + '</button>').click(function() { 26 $.cookie('rcstate', $(stateselect).val(), {'path': "/"}); 27 $(dlg).dialog('close').dialog('destroy'); 28 $(trigger).trigger('click'); 29 })); 30 $(dlg).dialog({ 31 'modal': 1, 32 'title': Drupal.settings.rcInsuranceText['title'], 33 'minWidth': 280, 34 'close': function() { 35 insuranceDlgIsOpen = false; 36 } 37 }); 38 insuranceDlgIsOpen = true; 39 return false; 40 } 41 if($(trigger).is('button')) { 42 $(trigger).parents('form').attr('action', $(trigger).parents('form').attr('action') + "&province=" + $.cookie('rcstate')); 43 } else { 44 $(trigger).attr('href', $(trigger).attr('href') + "&province=" + $.cookie('rcstate')); 45 } 46 return true; 47 }, 48 attach: function (context, settings) { 49 // Line item description toggle vis 50 $('.line-item-desc-toggle', context).once('rcjsLineItemDesc', function() { 51 $(this).click(function() { 52 var desc = $(this).siblings('.line-item-desc'); 53 if($(desc).is(':visible')) { 54 $(desc).hide(150); 55 $(this).text($(this).attr('data-show-copy')); 56 } else { 57 $(desc).show(150); 58 $(this).text($(this).attr('data-hide-copy')); 59 } 60 }); 61 }); 62 // Pager behavior for HTML availability calendar pagers 63 $('.rcjs-pager', context).once('rcjs-pager-init', function() { 64 $(this).each(function() { 65 $(this).wrapInner('<div class="rcjs-pages"></div>'); 66 $('.rcjs-page:gt(0)', this).hide(); 67 $('.rcjs-page:eq(0)', this).addClass('active'); 68 69 var pager = this; 70 var updateControls = function() { 71 var title = $('.rcjs-page.active .rcjs-page-caption', pager).filter(':first').html(); 72 var title2 = $('.rcjs-page.active .rcjs-page-caption', pager).filter(':last').html(); 73 if(title != title2) title = title + " - " + title2; 74 $('.rcjs-controls span.title', pager).html(title); 75 if($('.rcjs-page.active', pager).prev().length) { 76 $('.rcjs-controls .prev', pager).removeClass('inactive').get(0).removeAttribute('disabled'); 77 } else { 78 $('.rcjs-controls .prev', pager).attr('disabled', 'disabled').addClass('inactive'); 79 } 80 if($('.rcjs-page.active', pager).next().length) { 81 $('.rcjs-controls .next', pager).removeClass('inactive').get(0).removeAttribute('disabled'); 82 } else { 83 $('.rcjs-controls .next', pager).attr('disabled', 'disabled').addClass('inactive'); 84 } 85 }; 86 var lockControls = function() { 87 $('.rcjs-controls button', pager).attr('disabled', 'disabled'); 88 } 89 var controls = $('<div class="rcjs-controls"><span class="title"></span></div>') 90 .append($('<button class="prev"><< Prev</button>') 91 .click(function() { 92 if($('.rcjs-page.active', pager).prev().length) { 93 $('.rcjs-controls span.title', pager).html(' '); 94 lockControls(); 95 $('.rcjs-page.active', pager).fadeOut(300, function() { $(this).prev().fadeIn(300, updateControls).addClass('active'); }).removeClass('active'); 96 } 97 }) 98 ) 99 .append($('<button class="next">Next >></button>') 100 .click(function() { 101 if($('.rcjs-page.active', pager).next().length) { 102 $('.rcjs-controls span.title', pager).html(' '); 103 lockControls(); 104 $('.rcjs-page.active', pager).fadeOut(300, function() { $(this).next().fadeIn(300, updateControls).addClass('active'); }).removeClass('active'); 105 } 106 }) 107 ); 108 $(pager).prepend(controls); 109 if($('.rcjs-center', this)) { 110 $('.rcjs-center', this).parents('.rcjs-page').each(function() { 111 $(this).siblings().hide().removeClass('active'); 112 $(this).show().addClass('active'); 113 }); 114 } 115 updateControls(); 116 }); 117 }) 118 // GA tracking for search alternates links 119 $('.rc-search-alternate', context).click(function() { 120 if (typeof ga4 !== "undefined") { 121 ga4.event({ 122 event: 'click', 123 location: 'rescms_search_alternate', 124 label: $(this).attr('data-alternate-label'), 125 count: Math.round($(this).attr('data-alternate-count')), 126 eventCategory: 'ResCMS Search Alternate', 127 eventAction: 'Click', 128 eventLabel: $(this).attr('data-alternate-label'), 129 eventValue: Math.round($(this).attr('data-alternate-count')) 130 }); 131 } 132 133 if(typeof(ga) !== undefined) { 134 var link = this; 135 var payload = { 136 'hitType': 'event', 137 'eventCategory': 'ResCMS Search Alternate', 138 'eventAction': 'Click', 139 'eventLabel': $(this).attr('data-alternate-label'), 140 'eventValue': Math.round($(this).attr('data-alternate-count')), 141 'hitCallback': function() { 142 window.location = $(link).attr('href'); 143 } 144 }; 145 146 ga('send', payload); 147 return false;
148 } 149 }); 150 $('.rc-core-search-alternates', context).each(function() { 151 if (typeof ga4 !== "undefined") { 152 ga4.event({ 153 event: 'offer', 154 location: 'rescms_search_alternate', 155 value: Math.round($(this).find('a').length), 156 eventCategory: 'ResCMS Search Alternate', 157 eventAction: 'Offer', 158 eventLabel: 'Offer', 159 eventValue: Math.round($(this).find('a').length), 160 }); 161 } 162 163 if(typeof(ga) !== undefined) { 164 var payload = { 165 'hitType': 'event', 166 'eventCategory': 'ResCMS Search Alternate', 167 'eventAction': 'Offer', 168 'eventLabel': 'Offer', 169 'eventValue': Math.round($(this).find('a').length), 170 'nonInteraction': 1 171 }; 172 ga('send', payload); 173 } 174 }); 175 // State select cookie functionality for state-by-state insurance 176 $('.rc-item-quote-link, .rc-item-price-buy button, .rc-trigger-state').click(function() { 177 var trigger = this; 178 return Drupal.behaviors.rcjs.insuranceCheck(trigger); 179 }); 180 181 182 var thumbact = function() { 183 $(this).parents('.rc-core-item-images').find('.first').attr('src', $(this).attr('rel')); 184 $(this).parents('.rc-core-item-images').find('.first-caption').html($(this).attr('title')); 185 }; 186 $('.rcjs-image-thumb', context).hover(thumbact); 187 $('.rc-country-select', context).change(function() { 188 var cc = $(this).val(); 189 if(cc != '') { 190 $('.rc-state-select[rel='+$(this).attr('rel')+']', $(this).parents('fieldset').first()).each(function() { 191 var field = this; 192 $('option', this).remove(); 193 $(this).append('<option value=\'0\'>Loading...</option>'); 194 $.getJSON('/rescms/order/provinces/'+cc, function(data) { 195 $('option', field).remove(); 196 $(field).append('<option value=\'0\'>Select...</option>'); 197 for(code in data) { 198 $(field).append('<option value=\''+code+'\'>'+data[code]+'</option>'); 199 } 200 }); 201 }); 202 } 203 }); 204 // Checkout insurance decline prompts 205 if(typeof Drupal.settings.rcInsuranceTIDecline != 'undefined') { 206 $('.insurance-ti', context).once('rcInsuranceTI', function () { 207 var row = this, $row = $(row); 208 209 $row.find('input').next('label').on('click', function (e) { 210 e.stopPropagation(); 211 e.preventDefault(); 212 $(this).prev('input').trigger('mousedown'); 213 }); 214 215 $row.find('input').on('mousedown', function (e) { 216 var $t = $(this); 217 if( $(row).is('.forced-choice') && $t.attr('value') == 1 ) { 218 return true; 219 } 220 if(!insuranceTIDecline && ( 221 ( !$t.is(':checked') && $row.is('.declinable') ) || 222 ( $t.is(':checked') && $row.is('.acceptable') ) || 223 ( $row.is('.forced-choice') && $t.attr('value') == -1 ) 224 )) { 225 var trigger = this; 226 $( '<div>' + Drupal.settings.rcInsuranceTIDecline + '</div>' ).dialog({ 227 resizable: false, 228 width:280, 229 modal: true, 230 buttons: [ 231 { 232 text: Drupal.settings.rcInsuranceTIText.declineBtn, 233 click: function() { 234 insuranceTIDecline = true; 235 $( this ).dialog( "destroy" ); 236 $(trigger).trigger("click"); 237 if (typeof ga4 !== "undefined") { 238 ga4.event({ 239 event: 'decline', 240 value: 'insurance', 241 eventCategory: 'Insurance', 242 eventAction: 'Decline' 243 }); 244 } 245 if(typeof(ga) !== undefined) { 246 ga('send', { 247 'hitType': 'event', 248 'eventCategory': 'Insurance', 249 'eventAction': 'Decline' 250 }); 251 } 252 } 253 }, 254 {
255 text: Drupal.settings.rcInsuranceTIText.acceptBtn, 256 click: function() { 257 insuranceTIDecline = true; 258 $( this ).dialog( "destroy" ); 259 if($(trigger).hasClass('form-radio')) { 260 $(trigger).parents('.form-radios').find('input[value=1]').trigger('click'); 261 } 262 if (typeof ga4 !== "undefined") { 263 ga4.event({ 264 event: 'purchased', 265 value: 'insurance', 266 eventCategory: 'Insurance', 267 eventAction: 'Purchased' 268 }); 269 } 270 if(typeof(ga) !== undefined) { 271 ga('send', { 272 'hitType': 'event', 273 'eventCategory': 'Insurance', 274 'eventAction': 'Purchased' 275 }); 276 } 277 } 278 } 279 ] 280 }); 281 } else { 282 return true; 283 } 284 if (!insuranceTIDecline) { 285 e.stopPropagation(); 286 e.preventDefault(); 287 } 288 return insuranceTIDecline; 289 }); 290 }); 291 } 292 if(typeof Drupal.settings.rcInsuranceDPDecline != 'undefined') { 293 $('.insurance-dp', context).once('rcInsuranceDP', function () { 294 var row = this, $row = $(row); 295 $row.find('input').next('label').on('click', function (e) { 296 e.stopPropagation(); 297 e.preventDefault(); 298 $(this).prev('input').trigger('mousedown'); 299 }); 300 301 $row.find('input').on('mousedown', function (e) { 302 var $t = $(this); 303 if( $(row).is('.forced-choice') && $t.attr('value') == 1 ) { 304 return true; 305 } 306 if(!insuranceDPDecline && ( 307 ( !$t.is(':checked') && $row.is('.declinable') ) || 308 ( $t.is(':checked') && $row.is('.acceptable') ) || 309 ( $row.is('.forced-choice') && $t.attr('value') == -1 ) 310 )) { 311 var trigger = this; 312 $( '<div>' + Drupal.settings.rcInsuranceDPDecline + '</div>' ).dialog({ 313 resizable: false, 314 width:280, 315 modal: true, 316 buttons: [ 317 { 318 text: Drupal.settings.rcInsuranceDPText.declineBtn, 319 click: function() { 320 insuranceDPDecline = true; 321 $( this ).dialog( "destroy" ); 322 $(trigger).trigger("click"); 323 } 324 }, 325 { 326 text: Drupal.settings.rcInsuranceDPText.acceptBtn, 327 click: function() { 328 insuranceDPDecline = true; 329 $( this ).dialog( "destroy" ); 330 if($(trigger).hasClass('form-radio')) { 331 $(trigger).parents('.form-radios').find('input[value=1]').trigger('click'); 332 } 333 } 334 } 335 ] 336 }); 337 } else { 338 return true; 339 } 340 if (!insuranceDPDecline) { 341 e.stopPropagation(); 342 e.preventDefault(); 343 } 344 return insuranceDPDecline; 345 }); 346 }); 347 } 348 349 var setCheckoutButtonTextForSPS = function() { 350 if($("input[name='payment[payment_option]']:checked").length) { 351 var payopt = $("input[name='payment[payment_option]']:checked").val(); 352 } else { 353 var payopt = $("input[name='payment[payment_option]']").val(); 354 } 355 $('button[data-later-text]').each(function() { 356 if(payopt == 'cc' || payopt == 'ach') { 357 $(this).text($(this).attr('data-sps-text')) 358 $('.sps-order-submit-copy').show() 359 } else { 360 $(this).text($(this).attr('data-later-text')) 361 $('.sps-order-submit-copy').hide() 362 } 363 }) 364 } 365 366 // SPS payment / pay later 367 $("input[name='payment[payment_option]']").once('rcjs', function () { 368 $(this).on('change', function() { 369 if($(this).is(':checked')) { 370 setCheckoutButtonTextForSPS() 371 } 372 }) 373 }) 374 375 setCheckoutButtonTextForSPS() 376 } 377 }; 378})(jQuery);
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.