1window.onload = function() { 2 if (window.jQuery) { 3 // jQuery is loaded 4 } else { 5 // jQuery is not loaded 6 var message = "File failed to load likely caused by an intermittent internet connection. If this problem persists, please contact Crossbar support at [email protected].\n\nClick OK to refresh the page."; 7 if(confirm(message)) 8 { 9 window.location.reload(); 10 } 11 } 12} 13 14 15 16$(document).ready(function() 17{ 18 Forms.init(); 19 20 21 $('body').on('click', '.js_show', function() 22 { 23 $($(this).attr('data-show')).show(); 24 }); 25 26 $('body').on('click', '.js_uncheck', function() 27 { 28 $($(this).attr('data-uncheck')).prop('checked', false).trigger('change'); 29 }); 30 $('body').on('click', '.js_check', function() 31 { 32 $($(this).attr('data-check')).prop('checked', true).trigger('change'); 33 }); 34 35 36 /* CHECK ALL */ 37 $('body').on('click', '.check_all', function() 38 { 39 var checked = $(this).prop('checked'); 40 var target = $(this).attr('data-target'); 41 42 $(target).each( function() { 43 if($(this).prop('checked') != checked) 44 { 45 $(this).prop('checked', checked).trigger('change'); 46 } 47 }); 48 49 }); 50 51 52 $('body').on('click', '.js_hide', function() 53 { 54 if($(this).attr('data-hide') == "this") 55 { 56 $(this).hide(); 57 } 58 else 59 { 60 $($(this).attr('data-hide')).hide(); 61 } 62 }); 63 64 $('.js_toggle').click(function() 65 { 66 $($(this).attr('data-toggle')).toggle(); 67 }); 68 69 70 const ToggleSwitch = { 71 events: function() { 72 $('body').on('click', '.toggle-switch.on', this.turn_off.bind(this)); 73 $('body').on('click', '.toggle-switch.off', this.turn_on.bind(this)); 74 }, 75 submit_request: function(tswitch, url, method, success, fail) { 76 const jax = $.ajax({ 77 'url': url, 78 'type': method || 'GET', 79 }); 80 success && jax.done(success); 81 jax.fail((function(data) { 82 if (Forms.maybe_do_refresh_login(null, data, false, this.submit_request.bind(this, tswitch, url, method, success, fail))) return; 83 var errors = data.responseJSON; 84 if(errors && errors.flash) 85 { 86 location.reload(); 87 return; 88 } 89 if(errors && 'error' in errors) 90 { 91 alert(errors['error']) 92 } 93 else 94 { 95 alert('An error occurred. Please make sure you are still logged in.'); 96 } 97 fail && fail(data); 98 }).bind(this)); 99 }, 100 turn_off: function(event) { 101 const tswitch = $(event.target).closest('.toggle-switch'); 102 this.submit_request( 103 tswitch, 104 tswitch.attr('data-disable-url'), 105 tswitch.data('request-method'), 106 this.turned_off__success.bind(this, tswitch), 107 this.turned_off__fail.bind(this, tswitch), 108 ); 109 }, 110 turned_off__success: function(tswitch, data) { 111 tswitch.addClass('off').removeClass('on'); 112 tswitch.trigger('toggle-switch-off-success', [data]); 113 }, 114 turned_off__fail: function(tswitch, data) { 115 tswitch.trigger('toggle-switch-off-fail', [data]); 116 }, 117 turn_on: function(event) { 118 const tswitch = $(event.target).closest('.toggle-switch'); 119 this.submit_request( 120 tswitch, 121 tswitch.attr('data-enable-url'), 122 tswitch.data('request-method'), 123 this.turned_on__success.bind(this, tswitch), 124 this.turned_on__fail.bind(this, tswitch), 125 ); 126 }, 127 turned_on__success: function(tswitch, data) { 128 tswitch.addClass('on').removeClass('off'); 129 tswitch.trigger('toggle-switch-on-success', [data]); 130 }, 131 turned_on__fail: function(tswitch, data) { 132 tswitch.trigger('toggle-switch-on-fail', [data]); 133 }, 134 }; 135 ToggleSwitch.events(); 136 137 // toggle-switch without URL: 138 $('body').on('click', '.toggle-switch.checked', function(e) 139 { 140 const $tswitch = $(this); 141 $tswitch.toggleClass('unchecked checked'); 142 }); 143 $('body').on('click', '.toggle-switch.unchecked', function(e) 144 { 145 const $tswitch = $(this); 146 $tswitch.toggleClass('unchecked checked'); 147 }); 148 149 150 if(jQuery().tooltip) 151 { 152 $('[data-toggle="tooltip"], [data-bs-toggle="tooltip"]').tooltip() 153 } 154 155 /* 156 $("#owl-sponsors").owlCarousel({ 157 autoPlay: 5000, 158 stopOnHover: true, 159 navigation: false, 160 pagination: true, 161 rewindNav: true, 162 items: 7 163 }); 164 */ 165 166 /* disabled tabs - limited to site-tabs for now */ 167 $('body').on('click', '#site-tabs a.disabled', function(e) { 168 e.stopPropagation(); 169 e.preventDefault(); 170 }); 171 172 var options = 173 { 174 url: function(phrase) 175 { 176 return "/dashboard/user/search?query="+phrase; 177 } 178 ,template: 179 { 180 type: "custom", 181 method: function(value, element) 182 { 183 return element.first_name + " " + element.last_name + " (" + element.email + ")" 184 } 185 } 186 ,getValue: function(element) 187 { 188 return element.email 189 } 190 ,ajaxSettings: 191 { 192 dataType: "json", 193 method: "GET", 194 data: { 195 dataType: "json" 196 } 197 } 198 ,requestDelay: 400 199 }; 200 201 202 if(jQuery().easyAutocomplete) 203 { 204 $(".user_autocomplete").easyAutocomplete(options); 205 } 206 207 208 if(jQuery().datepicker) 209 { 210 $('.datepicker').datepicker({autoclose: true}); 211 } 212 213 214 if(jQuery().timepicker) 215 { 216 $('.timepicker').timepicker({ 217 scrollDefault: '8:05 AM', 218 showDuration: false, 219 timeFormat: 'g:ia', 220 step: 5, 221 }); 222 } 223 224 if(jQuery().glDatePicker) 225 { 226 227 $('#schedule_datepicker').glDatePicker({ 228 onClick: function(target, cell, date, data) 229 { 230 var base_url = $("#base_url").val(); 231 window.location = base_url+date.toISOString().slice(0, 10); 232 } 233 }); 234 } 235 236 if(jQuery().glDatePicker) 237 { 238 var selected_date = $("#date").val(); 239 240 $('#finance_datepicker').glDatePicker({ 241 onClick: function(target, cell, date, data) 242 { 243 window.location = "/dashboard/finances/day/"+date.toISOString().slice(0, 10); 244 }, 245 selectedDate: new Date(selected_date + "T00:00:00") 246 }); 247 } 248 249 if(jQuery().datepicker && $('.custom_datepicker').length > 0) 250 { 251 $('.custom_datepicker').each(function(index, element) { 252 const ATTR_NAME_MAP = { 253 "defaultviewdate": "defaultViewDate", 254 "startdate": "startDate", 255 "enddate": "endDate" 256 }; 257 var custom_datepicker_params = {}; 258 $.each(this.attributes, function() { 259 var name = this.name 260 if (ATTR_NAME_MAP[name]) { 261 name = ATTR_NAME_MAP[name]; 262 } 263 custom_datepicker_params[name] = this.value; 264 }); 265 if (custom_datepicker_params.beforeshowdayfuncname && typeof window[custom_datepicker_params.beforeshowdayfuncname] === 'function') { 266 custom_datepicker_params.beforeShowDay = window[custom_datepicker_params.beforeshowdayfuncname]; 267 } 268 $(this).datepicker(custom_datepicker_params); 269 if (custom_datepicker_params.changedatefuncname && typeof window[custom_datepicker_params.changedatefuncname] === 'function') { 270 $(this).datepicker().on('changeDate', window[custom_datepicker_params.changedatefuncname]); 271 } 272 }) 273 } 274 275 if (typeof ClipboardJS !== 'undefined') 276 { 277 clipboard = new ClipboardJS('.clipboard'); 278 clipboard.on('success', function(e) { 279 $(e.trigger).addClass('btn-success').removeClass('btn-default'); 280 281 setTimeout(function() 282 { 283 $(e.trigger).addClass('btn-default').removeClass('btn-success'); 284 285 }, 1000) 286 }); 287 } 288 289 $('body').on('change', '.redirect_to_value', function() 290 { 291 window.location = $(this).val(); 292 }); 293 294 295 $('body').on('mouseover', '.mailto', function() 296 { 297 $(this).attr("href", "mailto:"+$(this).attr('data-name') + "@" + $(this).attr("data-domain")); 298 }); 299 300 301 $('.alphanumeric').keypress(function (e) 302 { 303 var regex = new RegExp("^[a-zA-Z0-9]+$"); 304 var str = String.fromCharCode(!e.charCode ? e.which : e.charCode); 305 if (regex.test(str)) { 306 return true; 307 } 308 309 e.preventDefault(); 310 return false;
311 }); 312 313 $('body').on('click', '.doubleclick', function(e) 314 { 315 e.preventDefault(); 316 $(this).attr("href", $(this).attr("doubleclick_href")).addClass("text-error").addClass("doubleclick_clicked").removeClass("doubleclick"); 317 $(".confirm-delete-notification").show(); 318 }); 319 320 $(document).keyup(function(e) { 321 if (e.keyCode == 27) { // escape key maps to keycode `27` 322 $(".confirm-delete-notification").hide(); 323 $(".doubleclick_clicked").each(function() 324 { 325 $(this).attr("href", "javascript:void(0);").removeClass("text-error").removeClass("doubleclick_clicked").addClass("doubleclick"); 326 }); 327 } 328 }); 329 330 331 $('body').on('click', '.doubleclick_delete:not(.delete)', function(e) 332 { 333 e.preventDefault(); 334 var href = $(this).attr('confirm_href'); 335 $(this).attr('href', href); 336 $(this).addClass("delete"); 337 $(".doubleclick-delete-notification").show(); 338 }); 339 340 // expects to have .doubleclick_delete (ignores confirm_href) 341 $('body').on('click', '.doubleclick_delete_submit_form.delete', function(e) 342 { 343 e.preventDefault(); 344 var form_id = $(this).attr('data-form_id'); 345 $("#"+form_id).submit(); 346 }); 347 348 $(document).keyup(function(e) { 349 if (e.keyCode == 27) { // escape key maps to keycode `27` 350 $(".doubleclick_delete.delete").each(function() { 351 $(this).attr('href', "javascript:void(0);"); 352 $(this).removeClass("delete"); 353 $(".doubleclick-delete-notification").hide(); 354 355 }); 356 } 357 }); 358 359 360 $('body').on('click', '.copy_to_clipboard', function(e) 361 { 362 const el = document.createElement('textarea'); 363 el.value = $(this).attr("data-copy"); 364 el.setAttribute('readonly', ''); 365 el.style.position = 'absolute'; 366 el.style.left = '-9999px'; 367 document.body.appendChild(el); 368 el.select(); 369 document.execCommand('copy'); 370 document.body.removeChild(el); 371 $(this).addClass('copied'); 372 }); 373 374 /* Everytign inside .equal_height that matches data-target will be set to same size */ 375 var equal_height_check_interval = 250; 376 equal_height(); 377 function equal_height() 378 { 379 if($(".equal_height").length > 0) 380 { 381 $(".equal_height").each( function() 382 { 383 var target = $(this).attr('data-target'); 384 var height = 0; 385 $(this).find(target).css('height', 'auto'); 386 $(this).find(target).each( function() 387 { 388 if($(this).height() > height) 389 { 390 height = $(this).height(); 391 } 392 }); 393 $(this).find(target).height(height); 394 }); 395 396 // we keep trying because some shit, especially fonts, load slowly. 397 setTimeout(equal_height, equal_height_check_interval); 398 equal_height_check_interval = equal_height_check_interval * 2; 399 } 400 } 401 402 /* Everytign inside .equal_height that matches data-target will be set to same size */ 403 equal_column_width(); 404 function equal_column_width() 405 { 406 table_count = 0 407 if($(".equal_column_width").length > 0) 408 { 409 num_columns = 0 410 column_widths = {} 411 $(".equal_column_width").each( function() 412 { 413 table_count += 1 414 415 // loop through each table tbody tr and then calculate the average width of each column. 416 var tds = $(this).find('thead tr th'); 417 if(table_count == 1) 418 { 419 num_columns = tds.length 420 for(i = 1; i <= num_columns; i++) 421 { 422 column_widths[i] = [] 423 } 424 } 425 else if(num_columns != tds.length) 426 { 427 return; 428 } 429 column_count = 0 430 tds.each( function() 431 { 432 column_count += 1 433 column_widths[column_count].push($(this).width()); 434 }); 435 }); 436 437 min_widths = {} 438 for(i = 1; i <= num_columns; i++) 439 { 440 min_widths[i] = Math.min(...column_widths[i]); 441 } 442 // what is the sum of the min widths? 443 var sum_of_min_widths = Object.values(min_widths).reduce((a, b) => a + b, 0); 444 445 average_widths = {} 446 for(i = 1; i <= num_columns; i++) 447 { 448 average_widths[i] = parseInt(min_widths[i] / sum_of_min_widths * 100) 449 } 450 451 $(".equal_column_width").each(function() 452 { 453 i = 1 454 $(this).find('thead tr th').each(function() 455 { 456 if(i > 1) 457 { 458 $(this).css('width', String(average_widths[i]) + "%"); 459 } 460 i += 1 461 }); 462 }); 463 } 464 } 465 466 467 var square_check_interval = 250; 468 square(); 469 function square() 470 { 471 if($(".square").length > 0) 472 { 473 $(".square").each( function() 474 { 475 if($(this).is(":visible")) 476 { 477 $(this).height($(this).width()); 478 } 479 }); 480 // we keep trying because some shit, especially fonts, load slowly. 481 if($('.save-bar').length > 0) 482 { 483 square_check_interval = 100; 484 } 485 else 486 { 487 square_check_interval = square_check_interval * 2; 488 } 489 setTimeout(square, square_check_interval); 490 } 491 } 492 493 /* Hide intercom when any modal is opened */ 494 $('.modal').on('show.bs.modal', function () { 495 try { 496 window.capacityConcierge.hide_callbutton(); 497 //Intercom('update', {
498 // "hide_default_launcher": true 499 //}); 500 } catch (error) {} 501 }) 502 $('.modal').on('hide.bs.modal', function () { 503 try { 504 window.capacityConcierge.show_callbutton() 505 //Intercom('update', { 506 // "hide_default_launcher": false 507 //}); 508 } catch (error) {} 509 }) 510}); 511 512 513function resize_org_name_on_mobile() 514{ 515 var min_font_size = 20; 516 var width = $(window).width(); 517 if(width <= 1028) 518 { 519 // not sure why this is sometimes undefined, but going with 10 seems to be fine if undefined 520 var fontsize = $('.navbar-brand.mobile h2').css('font-size'); 521 if (typeof fontsize == 'undefined') { 522 fontsize = 10; 523 } 524 else { 525 fontsize = parseInt(fontsize.replace('px','')); 526 } 527 //var fontsize = parseInt($('.navbar-brand.mobile h2').css('font-size').replace('px', '')); 528 while($('.navbar-brand.mobile').width() < $('.navbar-brand.mobile')[0].scrollWidth) 529 { 530 fontsize = fontsize - 1; 531 $('.navbar-brand.mobile h2').css('font-size', fontsize+"px") 532 533 if(fontsize <= min_font_size) 534 { 535 $('.navbar-brand.mobile h2').css('white-space', 'nowrap') 536 $('.navbar-brand.mobile h2').css('overflow', 'hidden') 537 $('.navbar-brand.mobile h2').css('text-overflow', 'ellipsis') 538 break; 539 } 540 } 541 } 542} 543 544 545 546 547 548var Forms = 549{ 550 init: function() 551 { 552 Forms.events(); 553 Forms.richtext(); 554 Forms.location_autocomplete(); 555 }, 556 events: function() 557 { 558 $('body').on('submit', '.submit_and_redirect', function(e) { e.preventDefault(); Forms.submit(this, Forms.redirect_callback); }); 559 $('body').on('submit', '.submit_and_refresh', function(e) { e.preventDefault(); Forms.submit(this, Forms.refresh_callback); }); 560 561 $('body').on('click', '.submit_form', function(e) { 562 $(this).prop('disabled', true); 563 var form_id = $(this).attr('data-form_id'); 564 $("#"+form_id).submit(); 565 }); 566 567 $('body').on('change', 'SELECT.on_change_submit', function() 568 { 569 $(this).closest('form').submit(); 570 }); 571 }, 572 submit: function(form, success_callback, fail_callback, complete_callback, alt_path) 573 { 574 $(form).find('.loading').addClass('display-inline-block'); 575 $(form).find('BUTTON').prop('disabled', true); 576 577 const form_id = $(form).attr('id'); 578 579 fail_callback = fail_callback || Forms.default_fail_callback.bind(this, form); 580 complete_callback = complete_callback || function() {}; 581 582 if($(form).find(".form-group").hasClass("has-error")) 583 { 584 $(form).find(".form-group").removeClass("has-error") 585 $(form).find(".form-group .help-block").hide() 586 $(form).find(".error").hide() 587 } 588 589 $(form).find(".doubleclick_delete.delete").each(function() { 590 $(this).attr('href', "javascript:void(0);") 591 .removeAttr('disabled') 592 .removeClass("delete") 593 .removeClass("text-error") 594 $(".doubleclick-delete-notification").hide(); 595 $(".confirm-delete-notification").hide(); 596 }); 597 598 // Serialize tracked_player_stats before FormData capture (subseason form) 599 if (form_id === 'subseason_form' && typeof Subseason !== 'undefined' && Subseason.serialize_tracked_player_stats) { 600 Subseason.serialize_tracked_player_stats(); 601 } 602 603 let form_data = new FormData($(form)[0]); 604 $("#"+form_id+' input[type="file"]').each(function(index) 605 { 606 if($(this).val() == "") 607 { 608 try 609 { 610 form_data.delete($(this).attr('name')); 611 } 612 catch(e) 613 { 614 } 615 } 616 }); 617 618 let jax = $.ajax({ 619 url:alt_path || $(form).attr('action'), 620 type:'POST', 621 data:form_data, 622 processData:false, 623 contentType:false, 624 dataType: "json", 625 success: success_callback, 626 error: fail_callback, 627 complete: complete_callback, 628 }); 629 jax.always( function(response) 630 { 631 $('#'+form_id).find('.loading').removeClass('display-inline-block'); 632 $('#'+form_id + ' BUTTON').prop('disabled', false); 633 $('#'+form_id + ' .loading').hide(); 634 }); 635 } 636 ,maybe_do_refresh_login: function(form, response, check_only, success_callback) 637 { 638 const data = response.responseJSON; 639 if (response.status == 401 && data && data.refresh_login) { 640 if (data.inline_login) { 641 if (check_only) return {refresh: true, inline: true}; 642 const html = $(data.html); 643 const modal = html.closest('#inline_login_modal'); 644 $('body').append(html); 645 modal.modal('show'); 646 modal.find('form').on('submit', function(e) { 647 e.preventDefault(); 648 Forms.clear_errors('#inline_login_modal'); 649 Forms.submit( 650 this, 651 function() { 652 if (success_callback) { 653 modal.on('hidden.bs.modal', success_callback); 654 } 655 modal.modal('hide'); 656 }, 657 function(resp) { 658 Forms.display_errors('#inline_login_modal', resp); 659 } 660 ); 661 }); 662 } else { 663 if (check_only) return {refresh: true, inline: false}; 664 location.reload(); 665 } 666 return true; 667 }
668 if (check_only) return {refresh: false, inline: false}; 669 return false; 670 } 671 ,default_fail_callback: function(form, response) 672 { 673 if (this.maybe_do_refresh_login(form, response)) return; 674 Forms.display_errors("#" + form.id, response); 675 } 676 ,redirect_callback: function(response) 677 { 678 window.location.href = response['redirect'] 679 } 680 ,refresh_callback: function(response) 681 { 682 location.reload(); 683 } 684 ,set_field_error(field_sel, error, selector, obj) 685 { 686 let field = obj || $((selector || '') + " #input_"+field_sel); 687 if (!(field && field.length)) { 688 field = $((selector || '') + " [data-root-name=" + field_sel.replace(/^#input_/, '') + "]"); 689 } 690 let group = field.closest(".form-group"); 691 if (field.prop('type') === 'file' && field.parents('.input-group[data-provides=fileinput]').length) { 692 field = group.find('.form-control'); 693 } 694 field.addClass("is-invalid"); 695 group.addClass("has-error"); 696 const help = group.find('.help-block'); 697 const desc = group.find('.input-description'); 698 const text = group.find('.form-text'); 699 let target_el; 700 if (help.length) target_el = help; 701 else if (desc.length) target_el = desc; 702 else if (text.length) target_el = $(text[0]); 703 else { 704 target_el = $('<p class="form-text help-block"></p>'); 705 group.append(target_el); 706 } 707 target_el 708 .attr('data-is-error', 1) 709 .attr('data-original-text', target_el.html()) 710 .addClass('invalid-feedback') 711 .html(error) 712 .show(); 713 } 714 ,unset_field_error(field_name, selector, obj) 715 { 716 let group, field; 717 if (selector && !field_name) { 718 // clearing errors for every field in selector 719 group = $(selector + ' .form-group'); 720 field = group.find('.is-invalid'); 721 } else { 722 field = obj || $((selector || '') + " #input_"+field_name); 723 group = field.closest(".form-group"); 724 if (field.prop('type') === 'file' && field.parents('.input-group[data-provides=fileinput]')) { 725 field = group.find('.form-control'); 726 } 727 } 728 field.removeClass("is-invalid"); 729 group.removeClass("has-error"); 730 const target_el = group.find('[data-is-error=1]') 731 target_el 732 .attr('data-is-error', 0) 733 .html(target_el.attr('data-original-text')) 734 .attr('data-original-text', '') 735 .removeClass('invalid-feedback') 736 .filter(':empty') 737 .hide(); 738 } 739 ,display_errors: function(selector, data, errors, skip_scroll) 740 { 741 errors = errors || data.responseJSON; 742 try 743 { 744 745 if('field_errors' in errors) 746 { 747 for(var field in errors.field_errors) 748 { 749 error = errors.field_errors[field]; 750 if( typeof error !== 'string' ) 751 { 752 error = error.join(", "); 753 } 754 Forms.set_field_error(field, error, selector); 755 } 756 } 757 758 if('error' in errors) 759 { 760 if($(selector + " .error").length == 0) 761 { 762 alert(errors.error); 763 } 764 else 765 { 766 $(selector + " .error").html(errors.error).show(); 767 } 768 } 769 770 if('list' in errors) 771 { 772 if($(selector + " .error").length == 0) 773 { 774 alert(errors.list.join("<br>")); 775 } 776 else 777 { 778 $(selector + " .error").html(errors.list.join("<br>")).show(); 779 } 780 } 781 782 if (!skip_scroll) { 783 $("html, body").animate({ scrollTop: $(selector).offset().top-20 }, "slow"); 784 } 785 } 786 catch(e) 787 { 788 //Raven.captureException(e, {extra: { ajax_response: data }}); 789 alert('Please verify that all required fields are filled and the values entered are formatted correctly.'); 790 } 791 } 792 ,clear_errors(selector) 793 { 794 $(selector).find('.error').html('').hide(); 795 Forms.unset_field_error(null, selector) 796 } 797 ,richtext: function() 798 { 799 $(".richtext").each(function() 800 { 801 var height = $(this).attr('options-height'); 802 if(height == undefined){ 803 height = 100; 804 } 805 else { 806 height = parseInt(height); 807 } 808 809 summernote_options = { 810 minHeight: height, 811 toolbar: [ 812 ['style', [ 813 'style', 814 'bold', 815 'underline', 816 'italic', 817 'clear', 818 ]], 819 ['color', [ 820 'color', 821 ]], 822 ['elements', [ 823 'link', 824 'hr', 825 ]], 826 ['options', [ 827 'codeview', 828 'help' 829 ]], 830 ], 831 callbacks: 832 { 833 onChange: function(contents, $editable) 834 { 835 var input = $(this).attr('input'); 836 $("#"+input).val(contents); 837 } 838 } 839 } 840 841 842 $(this).summernote(summernote_options); 843 }); 844 845 846 } 847 ,location_autocomplete: function() 848 { 849 $(".location_autocomplete").each(function() 850 { 851 var input_id = $(this).attr('id'); 852 853 // Location Autocomplete ---- 854 var input = document.getElementById(input_id); 855 var autocomplete = new google.maps.places.Autocomplete(input); 856 autocomplete.setFields(['address_component', 'geometry']); 857 858 autocomplete.addListener('place_changed', function() { 859 var place = autocomplete.getPlace(); 860 var address = Forms.get_address_component(place, 'street_number') + " " + Forms.get_address_component(place, 'route'); 861 var city = Forms.get_address_component(place, 'locality'); 862 var state = Forms.get_address_component(place, 'administrative_area_level_1'); 863 var zip = Forms.get_address_component(place, 'postal_code'); 864 865 $('#input_address').val(address); 866 $('#input_city').val(city); 867 $('#input_state').val(state); 868 $('#input_zip').val(zip); 869 $('#'+input_id).val(place.name); 870 871 var lat = place.geometry.location.lat(); 872 var lng = place.geometry.location.lng(); 873 874 875 var a = "AIzaSyBDYRMIGMSJLpQ8hYC" 876 var b = "ZVyDl3zdfzne9g0" 877 var params = { 878 'location': lat + "," + lng, 879 'key':a+'-'+b, 880 'timestamp': Math.round(Date.now() / 1000), 881 } 882 883 var jax = $.ajax({
884 url:"https://maps.googleapis.com/maps/api/timezone/json", 885 data: params, 886 type:'GET', 887 dataType: "json", 888 success: function(response) 889 { 890 if($("#timezone").val() != response['timeZoneId']) 891 { 892 $("#time_zone_warning").show(); 893 } 894 else 895 { 896 $("#time_zone_warning").hide(); 897 } 898 899 }, 900 error: function() 901 { 902 } 903 }); 904 }); 905 906 $('#'+input_id).keydown(function (e) { 907 if (e.which == 13 && $('.pac-container:visible').length) return false; 908 }); 909 910 $('#'+input_id).focus(function (e) { 911 $(this).val(""); 912 }); 913 }); 914 915 }, 916 get_address_component: function(place, component_name) 917 { 918 for(i = 0; i < place['address_components'].length; i++) 919 { 920 component = place['address_components'][i]; 921 for(j = 0; j < component['types'].length; j++) 922 { 923 type = component['types'][j]; 924 if(type == component_name) 925 { 926 return component['short_name']; 927 } 928 } 929 } 930 return "" 931 }, 932 validate_required_fields: function(selector) 933 { 934 let missing_required_fields = 0; 935 $(selector).find(":input[required]").each(function () 936 { 937 const field = $(this); 938 let good = true; 939 if (field.attr("type") == "radio" || field.attr("type") == "checkbox") 940 { 941 if ($("input[name=" + field.attr("name") + "]:checked").length == 0) 942 { 943 Forms.set_field_error(null, "This field is required", null, field); 944 good = false; 945 } 946 } 947 else 948 { 949 if (field.val() == "") 950 { 951 Forms.set_field_error(null, "This field is required", null, field); 952 good = false; 953 } 954 } 955 956 if (good) 957 { 958 // just in case this is on there from a previous error 959 Forms.unset_field_error(null, null, field); 960 } 961 else 962 { 963 missing_required_fields += 1; 964 } 965 }); 966 967 if (missing_required_fields == 0) 968 { 969 return true; 970 } 971 else 972 { 973 return false; 974 } 975 }, 976}; 977 978$(document).ready(function () { 979 980 if(jQuery().dropdownHover) 981 { 982 $('.js-activated').dropdownHover({ 983 instantlyCloseOthers: false, 984 delay: 0 985 }) 986 } 987});
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.