1(function($) { 2 3 var clicked_button = ''; 4 5 /** 6 * Scripts relating to adding/removing the "loading" class which some themes use 7 */ 8 9 $('body').on('click', '.somdn-download-button:not(.somdn-checkbox-submit), .somdn-download-archive', function (e) { 10 // Assign the clicked link/button to the clicked_button variable for later 11 clicked_button = $(this); 12 var form = $(this).closest('form'); 13 if (!capture_email_active_page(form)) { 14 $(this).addClass('loading'); 15 } 16 }); 17 18 $('body').on('click', '.somdn-download-button, .somdn-download-archive', function (e) { 19 var element = $(this); 20 setTimeout( 21 function() { 22 if (element.hasClass('loading')) { 23 element.removeClass('loading'); 24 } 25 }, 26 2000); 27 }); 28 29 $('body').on('somdn_email_capture_submit_clicked_success', function(event, click_event, button, form) { 30 31 // If a button or archive page link was clicked add the "loading" class and remove it after 2 seconds. 32 if (clicked_button.length) { 33 clicked_button.addClass('loading'); 34 setTimeout( 35 function() { 36 if (clicked_button.hasClass('loading')) { 37 clicked_button.removeClass('loading'); 38 } 39 }, 40 2000); 41 } 42 43 }); 44 45 /**********************************************************************/ 46 47 /** 48 * Scripts relating to download buttons that are actually anchor elements 49 */ 50 51 $('body').on('click', 'a.somdn-download-archive', function (e) { 52 e.stopImmediatePropagation(); 53 var form = $(this).closest('form.somdn-archive-download-form'); 54 if (capture_email_active_page(form)) { 55 somdn_open_email_capture(form, e); 56 } else { 57 form.submit(); 58 } 59 return false; 60 }); 61 62 $('body').on('click', '.bundle-item-file-download .somdn-download-link', function(e) { 63 e.preventDefault(); 64 e.stopImmediatePropagation(); 65 $('.bundle-item-download-form').remove(); 66 var product_url = $(this).closest('.bundle-item-file-download').data('url'); 67 var action = $(this).closest('.bundle-item-file-download').data('action'); 68 var form = $('<form action="' + product_url + '" method="post" class="bundle-item-download-form" style="height:0;margin:0;overflow:hidden;"></form>'); 69 var params = $(this).closest('.bundle-item-file-download').find('input'); 70 71 if ( $(this).closest('.bundle-item-file-download').find('.somdn-capture-email-wrap').length > 0 ) { 72 $(this).closest('.bundle-item-file-download').find('.somdn-capture-email-wrap').eq(0).clone().appendTo( form ); 73 } 74 75 params.clone().appendTo( form ); 76 $('<input type="hidden" name="action" value="' + action + '" />').appendTo(form); 77 form.appendTo($('body')); 78 if (capture_email_active_page(form)) { 79 somdn_open_email_capture(form, e); 80 } else { 81 form.submit(); 82 form.remove(); 83 } 84 return false; 85 }); 86 87 $('body').on('click', '.somdn-download-link', function (e) { 88 e.stopImmediatePropagation(); 89 var form = $(this).closest('form'); 90 if (capture_email_active_page(form)) { 91 somdn_open_email_capture(form, e); 92 } else { 93 form.submit(); 94 } 95 return false; 96 }); 97 98 $('body').on('click', '.bundle-item-file-download .somdn-download-button', function(e) { 99 e.stopImmediatePropagation(); 100 $('.bundle-item-download-form').remove(); 101 if ($(this).closest('.bundle-item-file-download').hasClass('somdn-checkbox-form') ) { 102 if ($(this).closest('.bundle-item-file-download').find('input[type="checkbox"]:checked').length == 0) { 103 e.preventDefault(); 104 $('.somdn-form-validate').css('display', 'block'); 105 return false; 106 } 107 } 108 var product_url = $(this).closest('.bundle-item-file-download').data('url'); 109 var action = $(this).closest('.bundle-item-file-download').data('action'); 110 var form = $('<form action="' + product_url + '" method="post" class="bundle-item-download-form" style="height:0;margin:0;overflow:hidden;"></form>'); 111 var params = $(this).closest('.bundle-item-file-download').find('input'); 112 params.clone().appendTo( form ); 113 if ( $(this).closest('.bundle-item-file-download').find('.somdn-capture-email-wrap').length > 0 ) { 114 $(this).closest('.bundle-item-file-download').find('.somdn-capture-email-wrap').eq(0).clone().appendTo( form ); 115 } 116 $('<input type="hidden" name="action" value="' + action + '" />').appendTo(form); 117 form.appendTo($('body')); 118 if (capture_email_active_page(form)) { 119 somdn_open_email_capture(form, e); 120 } else { 121 form.submit(); 122 form.remove(); 123 } 124 return false;
125 }); 126 127 /**********************************************************************/ 128 129 /** 130 * Scripts relating to the multiple file checkbox form 131 */ 132 133 $('body').on('click', '.somdn-checkbox-form .somdn-checkbox-submit', function (e) { 134 var form = $(this).closest('form'); 135 if ($(form).find('input[type="checkbox"]:checked').length == 0) { 136 e.preventDefault(); 137 $('.somdn-form-validate').css('display', 'block'); 138 } else { 139 $('.somdn-form-validate').css('display', 'none'); 140 $(this).addClass('loading'); 141 var form = $(this).closest('form'); 142 if (capture_email_active_page(form)) { 143 e.preventDefault(); 144 capture_email_checkbox_form(e, this); 145 } 146 } 147 }); 148 149 $('body').on('click', '.somdn-select-all-wrap input[type="checkbox"]', function (e) { 150 var c = this.checked; 151 var form = $(this).closest('form'); 152 $(form).find('.somdn-checkboxes-wrap input[type="checkbox"]').prop('checked', c); 153 }); 154 155 $('body').on('click', '.somdn-checkbox-form .somdn-checkbox-form-checkbox', function (e) { 156 var form = $(this).closest('form'); 157 var checkboxes = $(form).find('.somdn-checkbox-form-checkbox'); 158 var checked_count = $(form).find('.somdn-checkbox-form-checkbox:checked').length;// How many checkboxes currently checked 159 var count = checkboxes.length;// How many checkboxes in total 160 if (checked_count < count) { 161 $(form).find('.somdn-checkbox-all').prop('checked', false); 162 } else { 163 $(form).find('.somdn-checkbox-all').prop('checked', true); 164 } 165 }); 166 167 /**********************************************************************/ 168 169 /** 170 * Quick View scripts 171 */ 172 173 $('body').on('click', '.somdn-qview-link', function (e) { 174 var prod_wrap = $(this).closest('li.product'); 175 if (qview_active()) { 176 e.preventDefault(); 177 somdn_open_qview(prod_wrap, event); 178 } 179 }); 180 181 /** 182 * Check if Quick View is active globally 183 */ 184 function qview_active() { 185 var qview_enabled = somdn_script_params.somdn_qview_active; 186 if (qview_enabled) { 187 return true; 188 } else { 189 return false; 190 } 191 } 192 193 /** 194 * Check if Quick View is active on the current page 195 */ 196 function qview_active_page(form) { 197 var qview_enabled = somdn_script_params.somdn_qview_active; 198 if (qview_enabled) { 199 return true; 200 } else { 201 return false; 202 } 203 } 204 205 /** 206 * Open the Quick View modal 207 */ 208 function somdn_open_qview(prod_wrap, event) { 209 var the_qview_wrap = $(prod_wrap).find('.somdn-qview-wrap'); 210 211 $('body').addClass('somdn-qview-open'); 212 $(the_qview_wrap).addClass('open'); 213 214 $('body').trigger('somdn_open_qview', [ prod_wrap, event ]); 215 // if the quick view product has variations, trigger the change event 216 if ($(the_qview_wrap).find('.variations_form').length) { 217 $(the_qview_wrap).find('.variations_form').trigger('check_variations'); 218 219 // select the first option with a value if it is a select 220 $(the_qview_wrap).find('.variations_form .variations select').each(function() { 221 $(this).val($(this).find('option[value!=""]').first().val()).change(); 222 }); 223 // find the first input radio inside the variation form and check it 224 jQuery('.somdn-qview-wrap.open').find('.variations_form input[type="radio"]').first().prop('checked', true).change(); 225 226 } 227 } 228 229 /** 230 * Close the Quick View modal 231 */ 232 function somdn_close_qview(prod_wrap, event) { 233 $(prod_wrap).find('.somdn-checkbox-form-checkbox, .somdn-checkbox-all').prop('checked', false); 234 $(prod_wrap).find('input:radio').removeAttr("checked"); 235 $(prod_wrap).find('.somdn-qview-wrap').removeClass('open'); 236 $('body').removeClass('somdn-qview-open'); 237 238 $('body').trigger('somdn_close_qview', [ prod_wrap, event ]); 239 } 240 241 /** 242 * Two events that close the Quick View modal 243 * 1. Clicking the X in the top right corner of the modal 244 * 2. Clicking anywhere outside the modal when it is open 245 */ 246 $('body').on('click', '.somdn-qview-wrap .somdn-qview-close', function (event) { 247 var prod_wrap = $(this).closest('li.product'); 248 somdn_close_qview(prod_wrap, event); 249 }); 250 251 $(document).on('click', '.somdn-qview-wrap', function(event) { 252 var prod_wrap = $(this).closest('li.product'); 253 somdn_close_qview(prod_wrap, event); 254 }).on('click', '.somdn-qview-window', function(e) { 255 e.stopPropagation(); 256 }); 257 258 /**********************************************************************/ 259 260 /** 261 * Scripts relating to the download forms where email capture is being used 262 */ 263 264 function capture_email_checkbox_form(e, this_var) { 265 e.stopImmediatePropagation(); 266 var form = $(this_var).closest('form'); 267 if (capture_email_active_page(form)) { 268 somdn_open_email_capture(form, e); 269 } else { 270 form.submit(); 271 } 272 return false;
273 } 274 275 $('body').on('click', '.somdn-download-button:not(.somdn-checkbox-submit)', function (e) { 276 e.stopImmediatePropagation(); 277 var form = $(this).closest('form'); 278 if (capture_email_active_page(form)) { 279 somdn_open_email_capture(form, e); 280 } else { 281 form.submit(); 282 } 283 return false; 284 }); 285 286 /** 287 * Email Capture scripts 288 */ 289 290 /** 291 * Check if capture email is active globally 292 */ 293 function capture_email_active() { 294 var capture_enabled = somdn_script_params.somdn_capture_emails_active; 295 if (capture_enabled) { 296 return true; 297 } else { 298 return false; 299 } 300 } 301 302 /** 303 * Check if capture email is active on the current page 304 */ 305 function capture_email_active_page(form) { 306 var the_email_wrap = $(form).find('.somdn-capture-email-wrap'); 307 var the_email = $(the_email_wrap).find('.somdn-download-user-email'); 308 var capture_enabled = somdn_script_params.somdn_capture_emails_active; 309 if (the_email.length && capture_enabled) { 310 return true; 311 } else { 312 return false; 313 } 314 } 315 316 /** 317 * Open the email capture modal 318 */ 319 function somdn_open_email_capture(the_form, event) { 320 $(the_form).addClass('somdn-form-email-capture'); 321 322 var the_email_wrap = $(the_form).find('.somdn-capture-email-wrap'); 323 var the_email = $(the_email_wrap).find('.somdn-download-user-email'); 324 325 $(the_form).find('.somdn-capture-required').prop('required', true); 326 $(the_form).find('.somdn-capture-checkbox-wrap input[type="checkbox"].somdn-checkbox-auto-blank').prop('checked', false); 327 somdn_clear_capture_validity(the_form); 328 329 $('body').addClass('somdn-capture-email-open'); 330 $(the_email_wrap).addClass('open'); 331 332 $('body').trigger('somdn_open_email_capture', [ the_form, event ]); 333 } 334 335 /** 336 * Close the email capture modal 337 */ 338 function somdn_close_email_capture(the_form, event) { 339 340 $(the_form).removeClass('somdn-form-email-capture'); 341 $(the_form).find('.somdn-capture-email-wrap').removeClass('open'); 342 $('body').removeClass('somdn-capture-email-open'); 343 $(the_form).find('.somdn-capture-required').prop('required', false); 344 somdn_clear_capture_validity(the_form); 345 346 $('body').trigger('somdn_close_email_capture', [ the_form, event ]); 347 348 } 349 350 /** 351 * Without this, the browser shows its own built-in messages 352 * ("Please fill out this field" / "Please enter an email address") instead 353 * of the messages configured under Tracking settings, because HTML5 354 * constraint validation runs before the form's submit handler. We override 355 * the message via setCustomValidity so the browser's native validity 356 * tooltip shows the configured (or default-translated) text instead. 357 */ 358 var SOMDN_CAPTURE_EMPTY_MESSAGES = { 359 'somdn_download_user_name': 'somdn_capture_fname_empty', 360 'somdn_download_user_lname': 'somdn_capture_lname_empty', 361 'somdn_download_user_tel': 'somdn_capture_tel_empty', 362 'somdn_download_user_company': 'somdn_capture_company_empty', 363 'somdn_download_user_website': 'somdn_capture_website_empty', 364 'somdn_download_user_email': 'somdn_capture_email_empty', 365 'somdn_capture_email_subscribe': 'somdn_capture_checkbox_error' 366 }; 367 368 function somdn_capture_message_for(field_name, validity) { 369 if (!validity) { 370 return ''; 371 } 372 if (validity.typeMismatch && field_name === 'somdn_download_user_email') { 373 return (somdn_script_params && somdn_script_params.somdn_capture_email_invalid) || ''; 374 } 375 var key = SOMDN_CAPTURE_EMPTY_MESSAGES[field_name]; 376 if (key && somdn_script_params && somdn_script_params[key]) { 377 return somdn_script_params[key]; 378 } 379 return ''; 380 } 381 382 function somdn_clear_capture_validity(the_form) { 383 $(the_form).find('.somdn-capture-required').each(function() { 384 if (typeof this.setCustomValidity === 'function') { 385 this.setCustomValidity(''); 386 } 387 }); 388 } 389 390 // The HTML5 'invalid' event does NOT bubble, so jQuery's delegated 391 // binding ($('body').on('invalid', selector, ...)) does not work for it. 392 // We must use a native addEventListener with the capture phase (third 393 // argument `true`), which fires before the event reaches the target 394 // regardless of bubbling. This is the standard browser API workaround 395 // for the non-bubbling 'invalid' event. 396 if (typeof document !== 'undefined' && document.addEventListener) { 397 document.addEventListener('invalid', function(e) { 398 var input = e.target; 399 if (!input || !input.classList || !input.classList.contains('somdn-capture-required')) { 400 return; 401 } 402 if (typeof input.closest !== 'function' || !input.closest('.somdn-capture-email-wrap')) { 403 return; 404 } 405 if (typeof input.setCustomValidity !== 'function') { 406 return; 407 } 408 var v = input.validity; 409 if (!v) { 410 return; 411 } 412 // Preserve a previously-set customError when no native HTML5 violation 413 // is also active (e.g. our stricter email regex failed but type="email" 414 // accepts the value). 415 if (v.customError && !v.valueMissing && !v.typeMismatch && !v.patternMismatch 416 && !v.badInput && !v.tooLong && !v.tooShort 417 && !v.rangeOverflow && !v.rangeUnderflow && !v.stepMismatch) { 418 return; 419 } 420 var msg = somdn_capture_message_for(input.getAttribute('name'), v); 421 if (msg) { 422 input.setCustomValidity(msg); 423 } 424 }, true); 425 } 426 427 // 'input' and 'change' DO bubble, so jQuery delegation is fine here. 428 // Clear the custom message as soon as the user edits the field, otherwise
429 // the browser keeps the field flagged as invalid. 430 $('body').on('input change', '.somdn-capture-email-wrap .somdn-capture-required', function() { 431 if (typeof this.setCustomValidity === 'function') { 432 this.setCustomValidity(''); 433 } 434 }); 435 436 /** 437 * Two events that close the email capture modal 438 * 1. Clicking the X in the top right corner of the modal 439 * 2. Clicking anywhere outside the modal when it is open 440 */ 441 $('body').on('click', '.somdn-capture-email-header .dashicons-no', function (event) { 442 var form = $(this).closest('form'); 443 somdn_close_email_capture(form, event); 444 }); 445 446 $(document).on('click', '.somdn-capture-email-wrap', function(event) { 447 var form = $(this).closest('form'); 448 somdn_close_email_capture(form, event); 449 }).on('click', '.somdn-capture-email-wrap-form', function(e) { 450 e.stopPropagation(); 451 }); 452 453 /** 454 * Event when the user clicks the email capture submit button (submit event instead of click) 455 */ 456 $('body').on('submit', 'form.somdn-form-email-capture', function (e) { 457 458 var form = this; 459 var button = $(this).find('button.somdn-capture-email-button'); 460 461 $('body').trigger('somdn_email_capture_submit_clicked', [ e, button, form ]); 462 463 var email_name = $(form).find('input[name="somdn_download_user_name"]'); 464 if (email_name.length) { 465 if (!email_name.val() && $(email_name).hasClass('somdn-capture-required')) { 466 alert(somdn_script_params.somdn_capture_fname_empty); 467 e.preventDefault(); 468 return; 469 } 470 $('body input[name="somdn_download_user_name"]').each(function() { 471 $(this).val(email_name.val()); 472 }); 473 } 474 475 var email_lname = $(form).find('input[name="somdn_download_user_lname"]'); 476 if (email_lname.length) { 477 if (!email_lname.val() && $(email_lname).hasClass('somdn-capture-required')) { 478 alert(somdn_script_params.somdn_capture_lname_empty); 479 e.preventDefault(); 480 return; 481 } 482 $('body input[name="somdn_download_user_lname"]').each(function() { 483 $(this).val(email_lname.val()); 484 }); 485 } 486 487 var email_tel = $(form).find('input[name="somdn_download_user_tel"]'); 488 if (email_tel.length) { 489 if (!email_tel.val() && $(email_tel).hasClass('somdn-capture-required')) { 490 alert(somdn_script_params.somdn_capture_tel_empty); 491 e.preventDefault(); 492 return; 493 } 494 $('body input[name="somdn_download_user_tel"]').each(function() { 495 $(this).val(email_tel.val()); 496 }); 497 } 498 499 var email_company = $(form).find('input[name="somdn_download_user_company"]'); 500 if (email_company.length) { 501 if (!email_company.val() && $(email_company).hasClass('somdn-capture-required')) { 502 alert(somdn_script_params.somdn_capture_company_empty); 503 e.preventDefault(); 504 return; 505 } 506 $('body input[name="somdn_download_user_company"]').each(function() { 507 $(this).val(email_company.val()); 508 }); 509 } 510 511 var email_website = $(form).find('input[name="somdn_download_user_website"]'); 512 if (email_website.length) { 513 if (!email_website.val() && $(email_website).hasClass('somdn-capture-required')) { 514 alert(somdn_script_params.somdn_capture_website_empty); 515 e.preventDefault(); 516 return; 517 } 518 $('body input[name="somdn_download_user_website"]').each(function() { 519 $(this).val(email_website.val()); 520 }); 521 } 522 523 var user_email = $(form).find('input[name="somdn_download_user_email"]'); 524 if (user_email.length) { 525 526 // Note: empty / type="email" format failures are handled by the 527 // browser's native validity check + our 'invalid' event handler above, 528 // so this submit handler usually only runs when the value is non-empty 529 // and HTML5-valid. The remaining check enforces our stricter regex. 530 531 if (!isValidEmailAddress(user_email.val())) { 532 var invalid_msg = somdn_script_params.somdn_capture_email_invalid || ''; 533 if (typeof user_email[0].setCustomValidity === 'function') { 534 user_email[0].setCustomValidity(invalid_msg); 535 if (typeof user_email[0].reportValidity === 'function') { 536 user_email[0].reportValidity(); 537 } else if (invalid_msg) { 538 alert(invalid_msg); 539 } 540 } else if (invalid_msg) { 541 alert(invalid_msg); 542 } 543 e.preventDefault(); 544 return; 545 } 546 547 $('body .somdn-download-user-email').each(function() { 548 $(this).val(user_email.val()); 549 }); 550 551 } 552 553 var sub_checkbox = $(form).find('input[name="somdn_capture_email_subscribe"]'); 554 if (sub_checkbox.length) { 555 if (!$(sub_checkbox).is(':checked') && $(sub_checkbox).hasClass('somdn-capture-required')) { 556 alert(somdn_script_params.somdn_capture_checkbox_error); 557 e.preventDefault(); 558 return; 559 } 560 } 561 562 somdn_close_email_capture(form, e); 563 564 $('body').trigger('somdn_email_capture_submit_clicked_success', [ e, button, form ]); 565 566 }); 567 568 $('body').on('somdn_email_capture_submit_clicked_success', function(event, click_event, button, form) { 569 // Example event hook for user submitting the email capture form successfully 570 571 572 // // alert somdn_script_params 573 // alert("somdn_script_params: ", somdn_script_params); 574 575 var remember_guest_email = somdn_script_params.somdn_capture_remember_guest_email; 576 var remember_time = somdn_script_params.somdn_capture_remember_time; 577 578 // add JS cookie to remember the user "somdn_remember_guest_email" - set to true for 60 days 579 if (typeof Cookies !== 'undefined' && remember_guest_email == '1') { 580 Cookies.set('somdn_remember_guest_email', 'true', { expires: parseInt(remember_time) }); 581 } 582 }); 583 584 function isValidEmailAddress(emailAddress) { 585 var pattern = new RegExp(/^(("[\w-+\s]+")|([\w-+]+(?:\.[\w-+]+)*)|("[\w-+\s]+")([\w-+]+(?:\.[\w-+]+)*))(@((?:[\w-+]+\.)*\w[\w-+]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][\d]\.|1[\d]{2}\.|[\d]{1,2}\.))((25[0-5]|2[0-4][\d]|1[\d]{2}|[\d]{1,2})\.){2}(25[0-5]|2[0-4][\d]|1[\d]{2}|[\d]{1,2})\]?$)/i); 586 return pattern.test(emailAddress); 587 }; 588 589 /**********************************************************************/ 590 591 /** 592 * Scripts for manipulating variation product page 593 */ 594 $(document).on('hide_variation', function(event, variation) { 595 596 $('.somdn-download-wrap-variable').each(function() { 597 $(this).css('display', 'none'); 598 var this_wrap_variation = $(this).attr('data-somdn-var-id'); 599 $(this).insertAfter('.somdn-variable-anchor[data-somdn-anchor-var-id="'+this_wrap_variation+'"]'); 600 }); 601 602 var variation_wrap = $('.variations_form').find('.woocommerce-variation-add-to-cart'); 603 $(variation_wrap).css('display', ''); 604 605 $('.variations_form').find('.woocommerce-variation-add-to-cart-disabled').hide(); 606 607 }); 608 609 $(document).on('show_variation', function(event, variation) { 610 611 var is_quickview = "no"; 612 // if .somdn-qview-wrap exists, then we are in quickview 613 if ($('.somdn-qview-wrap').length) { 614 is_quickview = "yes"; 615 } 616 617 // if we are in quickview we need to look for each .somdn-download-wrap-variable inside the div .somdn-qview-wrap.open 618 619 if (is_quickview == "yes") { 620 var download_wrap_variable = $('.somdn-qview-wrap.open .somdn-download-wrap-variable'); 621 } else { 622 var download_wrap_variable = $('.somdn-download-wrap-variable'); 623 } 624 625 626 // for each . inside the div 627 628 629 $(download_wrap_variable).each(function() { 630 $(this).css('display', 'none'); 631 var this_wrap_variation = $(this).attr('data-somdn-var-id'); 632 $(this).insertAfter('.somdn-variable-anchor[data-somdn-anchor-var-id="'+this_wrap_variation+'"]'); 633 }); 634 635 var variation_wrap = $('.variations_form').find('.woocommerce-variation-add-to-cart'); 636 var variation_id = variation['variation_id']; 637 var variation_download = $('*[data-somdn-var-id="'+variation_id+'"]'); 638 if (variation_download.length) { 639 // remove duplicate .somdn-download-wrap-variable 640 $(variation_download).find('.somdn-download-wrap-variable').remove(); 641 $(variation_download).find('.single_add_to_cart_button').removeClass('disabled
641wc-variation-selection-needed wc-variation-is-unavailable'); 642 $(variation_wrap).css('display', 'none'); 643 $(variation_download).css('display', 'block'); 644 $(variation_download).insertAfter(variation_wrap); 645 } else { 646 $(variation_wrap).css('display', ''); 647 } 648 649 $('.variations_form').find('.woocommerce-variation-add-to-cart-disabled').hide(); 650 651 }); 652 653 /**********************************************************************/ 654 655 /** 656 * Scripts for the download redirecting 657 */ 658 659 $('body').on('click', 'a.somdn-redirect-form-link', function (e) { 660 e.preventDefault(); 661 e.stopImmediatePropagation(); 662 var somdn_redirect_form = $('body').find('form#somdn_download_redirect_form'); 663 if (somdn_redirect_form.length) { 664 $(somdn_redirect_form).addClass('somdn-redirect-download-submitted'); 665 somdn_redirect_form.submit(); 666 } 667 }); 668 669 $(document).ready(function() { 670 var somdn_redirect_form = $('body').find('form#somdn_download_redirect_form'); 671 if (somdn_redirect_form.length) { 672 var redirect_time = somdn_script_params.somdn_redirect_time; 673 if (!redirect_time) { 674 redirect_time = 5000; 675 } 676 setTimeout(function() { 677 if (!$(somdn_redirect_form).hasClass('somdn-redirect-download-submitted')) { 678 somdn_redirect_form.submit(); 679 } 680 }, redirect_time); 681 } 682 }); 683 684 /* 685 * Functionality to add the product review form to valid downloaded products 686 */ 687 $(document).ready(function() { 688 var product_reviews = $('body').find('div#reviews'); 689 if (product_reviews.length) { 690 var review_form = $('body').find('div#reviews div#review_form_wrapper'); 691 // Bail if the review form is already rendered. It won't be a valid product. 692 if (review_form.length) { 693 return; 694 } 695 696 var somdn_review_form = $('body').find('div#somdn-review_form_wrapper'); 697 var somdn_review_login = $('body').find('#somdn-download-review-required'); 698 // Bail if the download review form is not present. 699 if (!somdn_review_form.length && !somdn_review_login.length) { 700 return; 701 } 702 703 if (somdn_review_form.length) { 704 $('div#reviews .woocommerce-verification-required').remove(); 705 $('#somdn-review_form_wrapper').insertAfter($('div#reviews div#comments')); 706 $('#somdn-review_form_wrapper').attr('id', 'review_form_wrapper'); 707 $('#somdn-review_form').attr('id', 'review_form'); 708 return; 709 } 710 711 if (somdn_review_login.length) { 712 $('div#reviews .woocommerce-verification-required').remove(); 713 $('#somdn-download-review-required').insertAfter($('div#reviews div#comments')); 714 $('#somdn-download-review-required').attr('id', ''); 715 return; 716 } 717 718 } 719 }); 720 721})(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.