1// JS RELACIONADO CON LAS FUNCIONALIDADES PRINCIPALES 2 3 4// Tabla 5$(function() { 6 7 init($(document)); 8 9 $(document).ajaxError(function(event, jqxhr, settings, thrownError) { 10 if (jqxhr.status == 403 || jqxhr.status == 401) { 11 notify('Error. Acción no permitida.', 'danger'); 12 } 13 }); 14 15 $('body').on('keyup click blur', '.js-numeric', function(e) { 16 17 var numericVal = $(this).val().replace(/[^0-9]/g, ''); 18 19 $(this).val(numericVal.slice(0,4)); 20 }); 21 22 $('body').on('click', '#next-step', function(e) { 23 24 e.preventDefault(); 25 26 if (!validateForm($(this).parents('.js-formStep1'))) { 27 return; 28 } 29 30 var retryTimes = $('.js-formStep1').data('retry-times'); 31 32 if (!$("#rut").prop('disabled') && retryTimes) { 33 34 loadStep2Retry(retryTimes); 35 } else { 36 37 loadStep2(); 38 } 39 40 }); 41 42 43 $('body').on('click', '#confirm_button', function(e) { 44 45 e.preventDefault(); 46 47 if (!validateForm($(this).parents('#form_step2'))) { 48 return; 49 } 50 51 var form = $('#form_step2'); 52 53 $.post(form.attr('action'), form.serialize(), function(response){ 54 55 if(response.html){ 56 $('.js-registrationModalBody').html(response.html); 57 }else{ 58 $("#loadingCircle").hide(); 59 var errors = JSON.parse(response.error); 60 $('p.text-warning').empty(); 61 for (var key in errors) { 62 if (errors.hasOwnProperty(key)) { 63 $('p.text-warning').append(errors[key]+'</br>'); 64 $('.js-activityRegistrationForm2 input[name='+key+']').css('border-color', 'red'); 65 } 66 } 67 } 68 }); 69 70 }); 71 72 73 function loadStep2Retry(retryTimes) { 74 75 var form = $('.js-formStep1'); 76 77 $.ajax({ 78 url : form.attr('action'), 79 type : 'POST', 80 data : form.serialize(), 81 tryCount : 0, 82 retryLimit : retryTimes, 83 success : function(response) { 84 85 if (response['type'] && response['type'] == 'no_info') { 86 $('.js-registrationModalBody').html(response.html); 87 return; 88 } 89 90 if (response['error'] !== undefined) { 91 92 this.tryCount++; 93 94 if (this.tryCount < this.retryLimit) { 95 96 $.ajax(this); 97 } 98 99 $('.js-registrationModalBody').html(response.html); 100 101 } else { 102 103 $('.js-registrationModalBody').html(response.html); 104 } 105 return; 106 } 107 }) 108 } 109 110 function loadStep2() { 111 var form = $('.js-formStep1'); 112 113 $.post(form.attr('action'), form.serialize(), function(response){ 114 if(response.html){ 115 $('.js-registrationModalBody').html(response.html); 116 } 117 }); 118 } 119 120 $(document).on('click', function(e) { 121 hideAllPopovers(e); 122 }); 123 124 $('body').on('click', '.js-toggleOption', function(e) { 125 126 if (!$(this).hasClass('toggleOption--active')) { 127 128 $('.js-toggleElement').toggle(); 129 130 $('.js-toggleOption').toggleClass('toggleOption--active'); 131 132 $('.js-toggleElement:visible :input').prop('disabled', false); 133 134 $('.js-toggleElement:hidden :input').prop('disabled', true); 135 $('.js-toggleElement:hidden :input').val(''); 136 } 137 138 }); 139 140 $('body').on('click', '[data-href]', function(e) { 141 142 window.location.href = $(this).data('href'); 143 }); 144 145 $('body').on('show.bs.modal', '.js-modalInit', function(e) { 146 // Cuando la carga es async, muestra un spinner 147 if ($('.modal-body', this).length == 0) { 148 $('.modal-content', this).html(loadingElement().wrap('<div class="modal-body"></div>')); 149 } 150 }); 151 152 $('body').on('loaded.bs.modal', '.js-modalInit', function(e) { 153 init($(this)); 154 }); 155 156 $('body').on('loaded.bs.modal', '.modal', function(e) {
157 $(this).find('input:text, textarea, select').first().focus(); 158 }); 159 160 $('body').on('hidden.bs.modal', '.js-modalInit', function(e) { 161 $(this).removeData('bs.modal'); 162 $('.modal-body', this).remove(); 163 }); 164 165 $('.js-toggleExpand').click(function() { 166 var $container = $(this).closest('.contentClipped'); 167 $container.toggleClass('is-collapsed'); 168 if ($container.hasClass('is-collapsed')) 169 $(this).text($(this).data('collapsed')); 170 else 171 $(this).text($(this).data('expanded')); 172 }); 173 174 $('body').on('click', '[data-modal-persist="true"]', function() { 175 176 if ($('.modal.in').length == 0 || $(this).closest('.modal').length == 0) 177 return; 178 var $modal = $(this).closest('.modal'); 179 $modal.addClass('js-persistedModal'); 180 $modal.hide(); 181 persistedModals.push($modal); 182 }); 183 184 $('body').on('click', '.js-formSubmitButton', function(e) { 185 186 var form = $(this).parents('.js-validateForm'); 187 188 if (!validateForm(form)) { 189 return; 190 } 191 192 var url = form.attr('action'); 193 var formData = form.serialize(); 194 195 $.post(url, formData, function(data) { 196 197 $('.js-formSubmitButton').parents('.js-validateForm').each(function(){ 198 this.reset(); 199 }); 200 const {message, status, title} = data; 201 swal({ 202 title: title, 203 text: message, 204 type: status, 205 confirmButtonText: 'OK', 206 confirmButtonColor: '#4ACD5F', 207 closeOnConfirm: false, 208 timer: 15000, 209 }); 210 }, 'json'); 211 212 }); 213 214 $('body').on('submit', '.js-validateFormBefore', function(e) { 215 if (!validateForm($(this))) { 216 return false; 217 } 218 219 return true; 220 221 }); 222 223 $('body').on("hidden.bs.modal", function(e) { 224 225 var $target = $(e.target); 226 227 if ($('textarea.htmleditor').length > 0) { 228 tinymce.execCommand('mceRemoveControl', true, $('textarea.htmleditor').attr('id')); 229 } 230 231 if ($target.hasClass('js-persistedModal')) { 232 for (var i = persistedModals.length - 1; i--;) { 233 if ($target.is(persistedModals[i])) { 234 persistedModals.splice(i, 1); 235 break; 236 } 237 } 238 } 239 240 if (persistedModals.length > 0) { 241 $modal = persistedModals.pop(); 242 $modal.removeClass('js-persistedModal'); 243 $modal.show(); 244 $('body').addClass('modal-open'); 245 } 246 247 $target.removeData("bs.modal").find(".modal-content").empty(); 248 249 }); 250 251 $('body').on('change', '.js-parentControl', function() { 252 if ($(this).data('disabled') == true) 253 return; 254 255 var $children = $($(this).data('children')); 256 var url = $(this).data('url'); 257 var json = {}; 258 259 $children.each(function() { 260 if ($(this).hasClass('select2-container')) 261 return; 262 var $child = $(this); 263 var url = $child.data('url'); 264 var $parents = $($child.data('parents')); 265 var params = {}; 266 267 $(this).find(':selected').each(function(i, sel) { 268 $(sel).removeAttr("selected"); 269 }); 270 $(this).trigger("change"); 271 272 $parents.each(function() { 273 if($(this).val() != '' && $(this).val() !== null){ 274 params[$(this).attr('data-tag')] = $(this).val(); 275 } 276 }); 277 $child.data('disabled', true); 278 279 $.post(url, params, function(data) { 280 if ($child.is('select')) { 281 if (!$child.attr('multiple')) { 282 var firstOption = $child.find('option:first'); 283 $child.html(''); 284 $child.append(firstOption); 285 } else { 286 $child.html(''); 287 } 288 if(data[$child.data('response')]) { 289 $.each(data[$child.data('response')], function(i, val) { 290 var option = new Option(val['name'], val['id']); 291 $child.append($(option)); 292 }); 293 } 294 $child.data('disabled', false); 295 } else if ($child.is('input')) { 296 $child.val(data[$child.data('response')]); 297 $child.data('disabled', false); 298 } 299 if ($child.hasClass('js-select2')){ 300 $child.select2('destroy'); 301 $child.select2(); 302 } 303 }, 'json'); 304 }); 305 306 }); 307 308 $('body').on('change', '.js-conditionalMetaOption', function() { 309 var parent = $(this).attr('data-parent-id'); 310 311 if (typeof parent == "undefined") { 312 $(this).find('option').each(function() { 313 if ($(this).val()!='') { 314 $('select[data-metaoption-id=' + $(this).val() + ']').removeAttr('required').parent().addClass('hidden'); 315 $('input[data-metaoption-id=' + $(this).val() + ']').removeAttr('required').parent().addClass('hidden'); 316 } 317 }); 318 if (typeof $(this).val() != "undefined" && $(this).val() != '') { 319 $('select[data-metaoption-id=' + $(this).val() + ']').attr('required', 'required').parent().removeClass('hidden'); 320 $('input[data-metaoption-id=' + $(this).val() + ']').attr('required', 'required').parent().removeClass('hidden'); 321 322 } 323 } 324 }); 325 326 $('body').on('change', '.js-conditionalUserOptionalData', function() { 327 var parent = $(this).attr('data-parent-id'); 328 329 //if (typeof parent == "undefined") { 330 $(this).find('option').each(function() { 331 if ($(this).val()!='') { 332 $('select[data-userOptionalData-id=' + $(this).val() + ']').removeAttr('required').parent().parent().addClass('hidden'); 333 $('input[data-userOptionalData-id=' + $(this).val() + ']').removeAttr('required').parent().parent().addClass('hidden'); 334 } 335 }); 336 if (typeof $(this).val() != "undefined" && $(this).val() != '') { 337 $('select[data-userOptionalData-id=' + $(this).val() + ']').attr('required', 'required').parent().parent().removeClass('hidden'); 338 $('input[data-userOptionalData-id=' + $(this).val() + ']').attr('required', 'required').parent().parent().removeClass('hidden'); 339 } 340 //} 341 }); 342 343 $('body').on('form.success', '.js-documentForm', function() { 344 var entityType = $(this).find('[name="entity_type"]').val(); 345 var entityId = $(this).find('[name="entity_id"]').val(); 346 347 var $table = $('#docTable' + entityType + entityId); 348 if ($table.length > 0) { 349 $table.tableter('reload'); 350 } 351 }); 352 353 if ($('.js-resizeLogo').length > 0) { 354 resizeLogo(); 355 $(window).scroll(resizeLogo); 356 } 357 358 $('body').on('tableter.loaded', '.js-tableterInit', function(event) { 359 init($(this)); 360 }); 361 362 $(document).on('click', '.menuFilter-container.dropdown-menu', function(e) { 363 e.stopPropagation(); 364 }); 365
366 /////////////////////////////////////////////////////////////////// 367 368 if($('.js-sportFilterUrl').length) { 369 370 getResultsFromFilter(); 371 } 372 373 $('body').on('change', '.js-placeSelect', function() { 374 375 var element = []; 376 377 element['type'] = $(this).data("sportfilter-type"); 378 element['value'] = $(this).closest('.js-select2').find('option:selected').val(); 379 380 getResultsFromFilter(element); 381 382 }); 383 384 function getResultsFromFilter(element) { 385 386 $(".js-loading-message").show(); 387 $(".js-filterResults").hide(); 388 389 var sportFilterUrl; 390 var values = []; 391 var types = []; 392 393 sportFilterUrl = $('.js-sportFilterUrl').data("url"); 394 395 $(".js-filterActive").each(function(index) { 396 397 if($(this).data("sportfilter-value")) { 398 values[index] = $(this).data("sportfilter-value"); 399 } else { 400 values[index] = $(this).closest('.js-select2').find('option:selected').val(); 401 } 402 403 types[index] = $(this).data("sportfilter-type"); 404 }); 405 406 $.ajax({ 407 type: 'GET', 408 url: sportFilterUrl, 409 data: { values: values, types: types }, 410 success: function(data) { 411 $(".js-filterResults").html(data); 412 }, 413 complete: function() { 414 $(".js-loading-message").hide(); 415 $(".js-filterResults").show(); 416 } 417 }); 418 } 419 420 if ($('.filterBoxItem').length) { 421 422 var paintActive = $('.filterBoxItem').data("paint-active"); 423 424 if (paintActive == null) { 425 paintActive = true; 426 } 427 428 paintFilterItemBox(true); 429 430 function paintFilterItemBox(firstLoad) { 431 432 $('.filterBoxItem').each(function(i, obj) { 433 434 if (paintActive) { 435 $(obj).removeClass("is-active"); 436 } 437 438 }); 439 440 if (firstLoad && paintActive) { 441 442 $('.filterBoxItem:last').addClass("is-active"); 443 444 } 445 } 446 447 $(".filterBoxItem").click(function() { 448 449 paintFilterItemBox(false); 450 451 if (paintActive) { 452 453 $(this).addClass("is-active"); 454 } 455 456 }); 457 } 458 459 $('body').on('form.success', '.js-formMemberUpdate', function(e, response) { 460 $('#staff-list').tableter('reload'); 461 $('#member-list').tableter('reload'); 462 }); 463 464 $('body').on('form.success', '.js-formRoleMember', function(e, response) { 465 466 //notify('El participante ha sido registrado correctamente.', 'success'); 467 $('#member-list').tableter('reload'); 468 }); 469 470 471 $('body').on('form.success', '.js-modalMember', function(e, response) { 472 473 //notify('El participante ha sido registrado correctamente.', 'success'); 474 $('#member-list').tableter('reload'); 475 }); 476 477 $('body').on('form.success', '.js-modalMember', function(e, response) { 478 479 //notify('El participante ha sido registrado correctamente.', 'success'); 480 $('#staff-list').tableter('reload'); 481 }); 482 483 $(document).on("click", '.js-layoverElement', function(event) { 484 485 $('.js-expandedMenu').toggle(); 486 487 if ($('.js-expandedMenu').is(":visible")) { 488 $('body').css('overflow','hidden'); 489 } else { 490 $('body').css('overflow','auto'); 491 } 492 493 }); 494 495 $(document).on("click", '.js-viewHideButton', function(event) { 496 497 $('.js-viewHideIcon').toggleClass("fa-chevron-down fa-chevron-up"); 498 $('.js-viewHideElement').toggle('u-invisibleElement'); 499 500 }); 501 502 if ($('.hidden-lg').is(":visible")) { 503 $('.js-viewHideElement').addClass('u-invisibleElement'); 504 } 505 506 $(document).on("click", '.js-viewHideHamburgerMenu', function(event) { 507 508 $('.js-viewHideHamburgerIcon').toggleClass('fa-bars fa-times'); 509 $('.js-viewHideHamburgerContent').slideToggle(50); 510 511 if ($('.js-viewHideHamburgerIcon').hasClass('fa-times')) { 512 $('.js-viewHideHamburgerContent').scrollTop(0); 513 $('.js-viewHideElement').css('display', 'none'); 514 $('.js-viewHideIcon').removeClass('fa-chevron-up').addClass('fa-chevron-down'); 515 $('body').css('overflow','hidden'); 516 } else { 517 $('body').css('overflow','scroll'); 518 } 519 520 }); 521 522 $(document).on("click", '.js-viewHideSectionButton', function(event) { 523 524 $(this).children('.js-viewHideIcon').toggleClass("fa-chevron-down fa-chevron-up"); 525 $(this).children('.js-viewHideElement').slideToggle(50); 526 527 }); 528 529 530 $('.mobile-results-select').change(function(){ 531 var input = $(this).val(); 532 var res = input.split("-"); 533 var last = res[res.length-1]; 534 535 if ( input.search("results-home-") == 1) {
536 $( "div[id^='results-home-']" ).removeClass('active'); 537 $( "#results-home-"+last ).addClass('active'); 538 } else { 539 $( "div[id^='results-foreign-']" ).removeClass('active'); 540 $( "#results-foreign-"+last ).addClass('active'); 541 } 542 }); 543 544 $('body').on('change','.js-rentDate', function(e){ 545 if ($(this).val() != '') { 546 var $timeContainer = $('.js-timeList'); 547 var $facilityContainer = $('.js-facilityList'); 548 $timeContainer.html('<div class="tableter-loading u-textCenter" style="width:100%!important;"><i class="fa fa-2x fa-spinner fa-spin"></i></div>'); 549 $facilityContainer.html('<div class="u-textCenter" style="width:100%!important;">Al seleccionar un horario se cargarán las canchas o espacios disponibles.</div>'); 550 var url = $timeContainer.attr('data-url') + '?date='+$(this).val(); 551 $.get(url, function(response){ 552 $timeContainer.html(''); 553 $timeContainer.html(response); 554 }); 555 556 } 557 }); 558 559 $('body').on('click', '.js-timeTag', function(e){ 560 $('.js-timeTag').each(function(e){ 561 $(this).removeClass('clickedTag'); 562 }); 563 $(this).addClass('clickedTag'); 564 var $facilityContainer = $('.js-facilityList'); 565 $facilityContainer.html('<div class="tableter-loading u-textCenter" style="width:100%!important;"><i class="fa fa-2x fa-spinner fa-spin"></i></div>'); 566 var url = $facilityContainer.attr('data-url') + '?date='+ $('.js-rentDate').val() +'&time='+$(this).attr('data-value'); 567 $.get(url, function(response){ 568 $facilityContainer.html(''); 569 $facilityContainer.html(response); 570 }); 571 }); 572 573 $('body').on('submit', '.js-inlineFilterForm', function(e) { 574 e.preventDefault(); 575 e.stopImmediatePropagation(); 576 var table = $($(this).data('table')); 577 var route = table.data('route'); 578 $('input, select', $(this)).each(function() { 579 if ($(this).val()) { 580 // Para poner ? o & según se requiera 581 route += route.indexOf('?') >= 0 ? '&' : '?'; 582 583 // Si define un campo en particular se formatea en 'parametros tableter' 584 // de lo contrario se manda como url parameter 585 if ($(this).data('field')) { 586 // Campo 587 route += 'filters[]=' + $(this).data('field'); 588 589 // Operator 590 if ($(this).data('operator')) { 591 route += ',' + $(this).data('operator') + ','; 592 } 593 594 // Valor 595 route += $(this).data('type') == 'date' ? ddmmyyyyToyyyymmdd($(this).val()) : $(this).val(); 596 } else { 597 route += $(this).attr('name') + '=' + $(this).val(); 598 } 599 600 } 601 }); 602 table.tableter('reload', route); 603 }); 604 605 $('body').on('change','.js-formSelectRegion', function(event){ 606 var url = $(this).attr('data-route'); 607 if (typeof($(this).val()) !== "undefined" && $(this).val() != '') { 608 clearSelectElement('.js-formSelectCommune'); 609 $.post(url, { 'region_id': $(this).val() }, function(response){ 610 fillSelectElement(response['communes'], '.js-formSelectCommune'); 611 }); 612 } 613 }); 614 615 function hasOptionOnSelectElement(classElement, val) { 616 return $(classElement + ' option').filter(function() { 617 return this.value == val; 618 }).length > 0; 619 } 620 621 function clearSelectElement(classElement) { 622 const $firstOption = $(classElement + ' option:first'); 623 $(classElement).select2('val', ''); 624 $(classElement).html('').append($firstOption); 625 $(classElement).select2('destroy'); 626 $(classElement).select2(); 627 } 628 629 function fillSelectElement(payload, classElement) { 630 if(payload) { 631 $.each(payload, function(key, val) { 632 if(!hasOptionOnSelectElement(classElement, key)){ 633 $(classElement).append('<option value="' + key + '">' + val + "</option>"); 634 } 635 }); 636 } 637 $(classElement).select2('destroy'); 638 $(classElement).select2(); 639 } 640 641 if ($('.fb-page').length) { 642 643 var TIMEOUT = null; 644 645 $(window).on('resize', function() { 646 if(TIMEOUT === null) { 647 TIMEOUT = window.setTimeout(function() { 648 TIMEOUT = null; 649 //fb_iframe_widget class is added after first FB.FXBML.parse() 650 //fb_iframe_widget_fluid is added in same situation, but only for mobile devices (tablets, p
650hones) 651 //By removing those classes FB.XFBML.parse() will reset the plugin widths. 652 $('.fb-page').removeClass('fb_iframe_widget fb_iframe_widget_fluid'); 653 654 FB.XFBML.parse(); 655 }, 300); 656 } 657 }); 658 } 659 660 $(document).ready(function() { 661 662 var observer = new IntersectionObserver( 663 664 function(entries) { 665 666 if (entries[0].isIntersecting === true ) { 667 668 $('.js-mainHeader').removeClass('shrink'); 669 670 } else { 671 672 $('.js-mainHeader').addClass('shrink'); 673 } 674 }, { threshold: [0] }); 675 676 677 if ($('.js-mainHeaderAfter').length) { 678 observer.observe(document.querySelector('.js-mainHeaderAfter')); 679 } 680 681 682 }); 683 684}); 685 686 687function resizeLogo() { 688 if ($(this).scrollTop() > 80) { 689 $('.js-resizeLogo').stop(1, 1).removeClass('metabar-logo--big'); 690 } else { 691 $('.js-resizeLogo').stop(1, 1).addClass('metabar-logo--big'); 692 } 693} 694 695function init($parent) { 696 $('[data-toggle="tooltip"]', $parent).tooltip(); 697 698 $parent.find('.js-tableter[data-route]').each(function() { 699 $.fn.tableter.call($(this), $(this).data()); 700 }); 701 702 $parent.find(':input.js-select2').select2(); 703 704 $parent.find('.js-datepicker').each(function() { 705 var $container = $(this).parents('.js-datepicker-container').length > 0 ? $(this).parents('.js-datepicker-container') : 'body'; 706 707 // Restringir a un rango de fechas 708 var startDate = $(this).data('start') && $(this).data('start').length > 0 ? $(this).data('start') : null; 709 var endDate = $(this).data('end') && $(this).data('end').length > 0 ? $(this).data('end') : null; 710 711 if ($(this).attr('startDate') !== typeof undefined && $(this).attr('startDate') !== false) { 712 $(this).datepicker({ 713 container: $container, 714 format: 'dd/mm/yyyy', 715 startDate: startDate, 716 endDate: endDate, 717 language: 'es', 718 autoclose: true, 719 todayHighlight: true, 720 todayBtn: 'linked', 721 startDate: $(this).attr('startDate') 722 }) 723 } else { 724 $(this).datepicker({ 725 container: $container, 726 format: 'dd/mm/yyyy', 727 startDate: startDate, 728 endDate: endDate, 729 language: 'es', 730 autoclose: true, 731 todayHighlight: true, 732 todayBtn: 'linked' 733 }) 734 } 735 736 }); 737 738 $parent.find('.js-modalForm').each(function() { 739 setModalFormSubmitListener($(this)); 740 }); 741 742 $parent.find('.js-tab').click(function() { 743 if ($(this).hasClass('is-active')) 744 return; 745 746 $(this).siblings('.js-tab.is-active').each(function() { 747 $(this).removeClass('is-active'); 748 $($(this).data('target')).hide(); 749 }); 750 751 $(this).addClass('is-active'); 752 $($(this).data('target')).show(); 753 }); 754 755 $parent.find('.js-selectTab').change(function() { 756 var $option = $(this).find('option:selected'); 757 selectTabItem($option); 758 }); 759 $parent.find('select.js-selectTab:first').change(); 760 761 $parent.find('.js-tabInscription').click(function(e) { 762 var stepTabs = $( ".wizard-navTab" ); 763 var position = $(this).hasClass('js-nextTab')?1:-1; 764 var active = false; 765 var errorOnForm = false; 766 767 for (var i = 0; i < stepTabs.length; i++) { 768 var item = stepTabs[i]; 769 770 if ( $(item).hasClass('is-active') && !active) { 771 var inputs = $($(item).data('target')+" :input"); 772 773 for (var j=0 ; j<inputs.length; j++){ 774 if($(inputs[j]).prop('required')){ 775 var hasError = false; 776 777 if (($(inputs[j]).prop('name') =='rut' && !validateRut($(inputs[j]).prop('value'))) || ($(inputs[j]).prop('name') =='phone_number' && !validatePhone($(inputs[j]).prop('value'))) || ($(inputs[j]).prop('name') =='email' && !validateEmail($(inputs[j]).prop('value'))) || $(inputs[j]).prop('value') =='' || $(inputs[j]).data('validated') == 0) { 778 hasError =true; 779 errorOnForm = true; 780 } 781 782 if (($(inputs[j]).prop('name') =='user[rut][]' && !validateRut($(inputs[j]).prop('value'))) || ($(inputs[j]).prop('name') =='user[phone][]' && !validatePhone($(inputs[j]).prop('value'))) || ($(inputs[j]).prop('name') =='user[email][]' && !validateEmail($(inputs[j]).prop('value'))) || $(inputs[j]).prop('value') == '' || $(inputs[j]).data('validated') == 0) { 783 hasError =true; 784 errorOnForm = true; 785 } 786 787 if ($(inputs[j]).hasClass('js-fileValue') && $(inputs[j]).prop('value') == '') { 788 hasError = true; 789 errorOnForm = true; 790 } 791 792 if ($(inputs[j]).hasClass('js-fileValue')) { 793 $(inputs[j]).parent().children('.js-uploadBtn').css('border', hasError ? '1px solid red' : ''); 794 } else if ($(inputs[j]).prop('name') != 'logo') { 795 $(inputs[j]).css('border', hasError ? '1px solid red' : ''); 796 } else { 797 $(inputs[j]).parent().css('border', hasError ? '1px solid red' : ''); 798 } 799 } 800 } 801 802 if (!errorOnForm || $(this).hasClass('prev-tab')) { 803 $(item).removeClass('is-active'); 804 $($(item).data('target')).hide(); 805 if (i+(position) < stepTabs.length ) { 806 active = true; 807 $(stepTabs[i+(position)]).addClass('is-active'); 808 $($(stepTabs[i+(position)]).data('target')).show(); 809 } else { 810 active = true; 811 $(stepTabs[i]).addClass('is-active'); 812 $($(stepTabs[i]).data('target')).show(); 813 } 814 } else { 815 e.preventDefault(e); 816 } 817 } 818 } 819 820 }); 821 822 823 $parent.find('.js-addMember').click(function() { 824 var stepTabs = $( $(this).data('target') ); 825 var maxMembers = $(this).data('member-counts'); 826 var noLimit = $(this).data('no-limit'); 827 var newRow = $('.new_member.prototype').clone(true); 828 829 newRow.find('input, select').each(function() { 830 $(this).val(''); 831 if ($(this).hasClass('js-datepicker')){ 832 $(this).removeClass('hasDatepicker') 833 .removeData('datepicker') 834 .unbind() 835 .datepicker({ 836 format: 'dd/mm/yyyy', 837 language: 'es', 838 autoclose: true, 839 todayHighlight: true, 840 todayBtn: 'linked' 841 }); 842 } 843 844 }); 845 newRow.find('.js-helpBlock').each(function() { 846 $(this).text(''); 847 }); 848 newRow.find('.has-error').each(function() { 849 $(this).removeClass('has-error'); 850 }); 851 852 newRow.find('.js-fileName, .js-fileSize, .js-filePercent, .js-fileItem
852Container').each(function() { 853 $(this).remove(); 854 }); 855 newRow.find('.js-uploadBtn').each(function() { 856 $(this).attr('id', $(this).attr('id') + '_' + $('.new_member').length); 857 }); 858 859 860 861 newRow.removeClass("prototype"); 862 stepTabs.append(newRow); 863 init(newRow); 864 if (!noLimit){ 865 if ($('.new_member').length == maxMembers ){ 866 $(".js-addMember").attr("disabled", true); 867 $('.alert.alert-warning').show(); 868 } 869 } 870 }); 871 872 873 /* 874 * plupload with S3 875 */ 876 $parent.find('.js-uploadBtn').each(function() { 877 createUploader($(this)); 878 }); 879 880 881 if ($(".js-readmore").length > 0) { 882 $('.js-readmore').readmore({ 883 moreLink: '<a class="readmore" href="#">Leer más</a>', 884 lessLink: '<a class="readmore" href="#">Leer menos</a>' 885 }); 886 } 887 888 $(window).bind('scroll', function() { 889 if ($(window).scrollTop() > 200) { 890 $(".js-socialNetworkTabs-container").removeClass("visible-lg-block"); 891 $('.js-socialNetworkTabs-container').fadeOut(); 892 } else { 893 $('.js-socialNetworkTabs-container').fadeIn(); 894 $(".js-socialNetworkTabs-container").addClass("visible-lg-block"); 895 } 896 }); 897 898 if ($(".js-royalSlider").length > 0) { 899 var opts = { 900 controlNavigation: 'none', 901 imageScaleMode: 'fill', 902 arrowsNav: true, 903 arrowsNavHideOnTouch: true, 904 fullscreen: false, 905 loop: true, 906 slidesSpacing: 0, 907 slidesOrientation: 'horizontal', 908 numImagesToPreload: 3, 909 thumbsFirstMargin: false, 910 autoScaleSlider: false, 911 autoScaleSliderHeight: 346, 912 keyboardNavEnabled: true, 913 navigateByClick: true, 914 fadeinLoadedSlide: true, 915 globalCaption: true, 916 autoPlay: { 917 // autoplay options go gere 918 enabled: true, 919 pauseOnHover: true, 920 delay: 5000 921 } 922 }; 923 924 var sliderJQ = $('.js-royalSlider').royalSlider(opts); 925 926 $('.rsGCaption').appendTo('.featuredBox-textCol'); 927 928 $('.js-royalSlider').each(function() { 929 var slider = $(this); 930 var sliderInstance = slider.data('royalSlider'); 931 var elements = $('.js-miniBox-container'); 932 933 if (elements.length) { 934 elements.css('visibility', 'visible'); 935 } 936 937 if (sliderInstance) { 938 var updCount = function() { 939 $('.js-miniBoxSlide').removeClass('miniBox-slideActive'); 940 $('.js-miniBoxText').removeClass('text-boldWhite'); 941 $('.js-miniBoxText').find("a").addClass('text-white'); 942 943 $('.js-miniBoxSlide').eq(sliderInstance.currSlideId).addClass('miniBox-slideActive'); 944 $('.js-miniBoxText').eq(sliderInstance.currSlideId).find("a").removeClass('text-white'); 945 $('.js-miniBoxText').eq(sliderInstance.currSlideId).addClass('text-boldWhite'); 946 } 947 sliderInstance.ev.on('rsAfterSlideChange', updCount); 948 updCount(); 949 } 950 }); 951 952 if ($('.js-miniBox-container').length > 0) { 953 $('.js-miniBox-container').click(function() { 954 var elementIndex = $('.js-miniBox-container').index(this); 955 var slider = $('.js-royalSlider').data('royalSlider'); 956 slider.goTo(elementIndex); 957 }); 958 } 959 } 960 961 if ($(".js-gallerySlider").length > 0) { 962 var opts = { 963 controlNavigation: 'none', 964 imageScaleMode: 'fill', 965 arrowsNav: true, 966 arrowsNavHideOnTouch: true, 967 fullscreen: false, 968 loop: false, 969 slidesSpacing: 0, 970 slidesOrientation: 'horizontal', 971 numImagesToPreload: 3, 972 thumbsFirstMargin: false, 973 autoScaleSlider: false, 974 autoScaleSliderHeight: 346, 975 keyboardNavEnabled: true, 976 navigateByClick: true, 977 fadeinLoadedSlide: true, 978 globalCaption: true, 979 }; 980 981 var sliderJQ = $('.js-gallerySlider').royalSlider(opts); 982 983 $('.js-gallerySlider').each(function() { 984 var slider = $(this); 985 var sliderInstance = slider.data('royalSlider'); 986 987 if (sliderInstance) { 988 var updCount2 = function() { 989 var currentSlide = sliderInstance.currSlideId + 1; 990 $(".js-galleryBullet").removeClass("fa-dot-circle-o"); 991 $(".js-galleryBullet").addClass("fa-circle-o"); 992 $(".js-galleryBullet").eq(sliderInstance.currSlideId).addClass("fa-dot-circle-o"); 993 } 994 sliderInstance.ev.on('rsAfterSlideChange', updCount2); 995 updCount2(); 996 } 997 }); 998 999 if ($(".js-galleryBullet").length > 0) { 1000 $(".js-galleryBullet").click(function() { 1001 var elementIndex = $(".js-galleryBullet").index(this); 1002 var slider = $(".js-gallerySlider").data('royalSlider'); 1003 slider.goTo(elementIndex); 1004 }); 1005 } 1006 } 1007 1008 $parent.find('.js-documentForm').each(function() { 1009 if (typeof($('.js-documentType').val()) !== "undefined") { 1010 $('.js-documentExtensionLabel').hide(); 1011 $('.js-documentExtension' + $('.js-documentType').val()).show(); 1012 if ($('.js-allowedExtensions' + $('.js-documentType').val()).text() == '') { 1013 $('#uploadBtn').attr('data-mime-types', "doc,docx,xls,xlsx,ppt,pptx,pdf,jpg,jpeg,png"); 1014 $('#uploadBtn').data('uploader').setOption('filters', { 1015 mime_types: [{ 1016 extensions: "doc,docx,xls,xlsx,ppt,pptx,pdf,jpg,jpeg,png" 1017 }] 1018 }); 1019 } else { 1020 $('#uploadBtn').attr('data-mime-types', $('.js-allowedExtensions' + $('.js-documentType').val()).text().replace(/[.]+/g, '')); 1021 var clean_string = $('.js-allowedExtensions' + $('.js-documentType').val()).text().replace(/[.]+/g, ''); 1022 $('#uploadBtn').data('uploader').setOption('filters', { 1023 mime_types: [{ 1024 extensions: String(clean_string).replace(/\"/g, "") 1025 }] 1026 }); 1027 } 1028 } 1029 }); 1030 $parent.find('.js-alert').each(function() { 1031 setAlertListener($(this)); 1032 }); 1033 1034 $parent.find(':input.js-select2-typeahead').each(function() { 1035 createTypeahead($(this)); 1036 }); 1037 1038 if ($parent.find('.js-timepicker').length > 0) 1039 $parent.find('.js-timepicker').timepicker({ 1040 showMeridian: false, 1041 minuteStep: 5, 1042 defaultTime: '12:00', 1043 showInputs: true, 1044 explicitMode: true 1045 }) 1046 .on('focus', function(event) { 1047 /* Parche para el comportamiento del timepicker, widgets no desaparecian con clicks en otros timepickers*/ 1048 $('.js-timepicker').not($(this)).timepicker('hideWidget'); 1049 }) 1050 .parents('body') /*otra parte del parche */ 1051 .on('click', function(e) { 1052 if ($(e.target).parents('.bootstrap-timepicker-widget').length == 0 && 1053 !$(e.target).hasClass('js-timepicker')) 1054 $('.js-timepicker').timepicker('hideWidget'); 1055 }); 1056} 1057 1058//Lista de modals abiertos cuando son anidados 1059var persistedModals = []; 1060 1061var loadingElement = (function() {
1062 return $('.js-helper-modalLoading').clone(); 1063}); 1064 1065var delay = (function() { 1066 var timer = 0; 1067 return function(callback, ms) { 1068 clearTimeout(timer); 1069 timer = setTimeout(callback, ms); 1070 }; 1071})(); 1072 1073function selectTabItem($item) { 1074 $item.siblings('.js-tab.is-active').each(function() { 1075 $(this).removeClass('is-active'); 1076 $($(this).data('target')).hide(); 1077 $(this).prop('selected', false); 1078 }); 1079 1080 $item.addClass('is-active'); 1081 $item.prop('selected', true); 1082 1083 var $target = $($item.data('target')); 1084 1085 1086 if ($target.data('route') && !$target.data('loading')) { 1087 $target.html(loadingElement()); 1088 $target.load($target.data('route'), function(){ 1089 //$(this).data('loaded', true); 1090 }); 1091 $target.data('loading', true); 1092 } 1093 1094 if ($target.find('.js-selectTab').length > 0) { 1095 $target.find('.js-selectTab').change(); 1096 } 1097 1098 $target.show(); 1099} 1100 1101 1102function setModalFormSubmitListener(form) { 1103 setFormSubmitListener(form); 1104 form.on('form.success', function(e, response) { 1105 if (typeof $('.js-modalForm').attr('data-table') !== "undefined") { 1106 $($('.js-modalForm').attr('data-table')).tableter('reload'); 1107 } 1108 form.parents('.modal').modal('hide'); 1109 }); 1110 1111 form.on('form.fail', function(e, response) { 1112 if (typeof $('.js-modalForm').attr('data-table') !== "undefined") { 1113 $($('.js-modalForm').attr('data-table')).tableter('reload'); 1114 } 1115 if (typeof response != 'undefined') { 1116 notify(response['data']['messages'], 'danger'); 1117 } else { 1118 notify('Ocurrió un error. Por favor intente de nuevo.', 'danger'); 1119 } 1120 }); 1121} 1122 1123 1124function setAlertListener($object) { 1125 $object.on('click', function(e) { 1126 e.preventDefault(); 1127 var $button = $(this); 1128 var title = $button.data('title'); 1129 var text = $button.data('text'); 1130 var type = $button.data('type') ? $button.data('type') : 'warning'; 1131 var button_label = $button.data('button-label') ? $button.data('button-label') : 'Aceptar'; 1132 if ($button.data('modal')) 1133 $('.modal.in').hide(); 1134 swal({ 1135 title: title, 1136 text: text, 1137 type: type, 1138 showCancelButton: true, 1139 confirmButtonText: button_label, 1140 confirmButtonColor: type == 'success' ? null : '#DD6B55', 1141 cancelButtonText: 'Cancelar', 1142 closeOnConfirm: false, 1143 showLoaderOnConfirm: $button.is('[type=submit]') 1144 }, 1145 function(isConfirm) { 1146 if (isConfirm) { 1147 $button.trigger('alert.accepted'); 1148 if ($button.is('[type=submit]')) { 1149 $form = $button.parents('form'); 1150 setFormSubmitListener($form); 1151 $form.submit(); 1152 1153 $form.on('form.success', function(e, response) { 1154 swal('El registro ha sido eliminado.', null, 'success'); 1155 }); 1156 1157 $form.on('form.fail', function(e, response) { 1158 swal('Ocurrió un error... Intente nuevamente', null, 'error'); 1159 }); 1160 } else if ($button.is('a') && !$button.hasClass('js-deleteTrigger')) { 1161 if ($button.data('delete') == 'delete') { 1162 $.ajax({ 1163 url: $button.attr('href'), 1164 type: 'DELETE', 1165 success: function(data) { 1166 swal('El registro ha sido eliminado.', null, 'success'); 1167 //data.url esta cargado cuando el usuario se ha salido de la sesión 1168 if (data.url) { window.location.href = data.url; } 1169 if ($button.data('table-id')) { $($button.data('table-id')).tableter('reload');} 1170 $button.trigger('alert.success'); 1171 } 1172 }); 1173 } else { 1174 window.location = $object.attr('href'); 1175 } 1176 } 1177 } 1178 if ($button.data('modal')) 1179 $('.modal.in').show(); 1180 } 1181 ); 1182 }); 1183} 1184 1185// Aca poner la lógica de cerrar popovers abiertos manualmente 1186function hideAllPopovers(e) { 1187 if (typeof $(e.target).data('original-title') == 'undefined' && !$(e.target).parents().is('.popover.in')) { 1188 //$('[data-original-title]').popover('hide'); 1189 //$(this).data('visible', false); 1190 } 1191}; 1192 1193function notify(message, type, element) { 1194 element = typeof element !== 'undefined' ? element : 'body'; 1195 1196 $.notify({ 1197 message: message 1198 }, {
1199 element: element, 1200 allow_dismiss: false, 1201 animate: { 1202 enter: 'animated fadeInDown', 1203 exit: 'animated fadeOutUp' 1204 }, 1205 position: 'fixed', 1206 type: type, 1207 placement: { 1208 from: 'top', 1209 align: 'center' 1210 }, 1211 mouseover: 'pause', 1212 offset: 100, 1213 z_index: 2000 1214 }); 1215} 1216 1217/* 1218 * Funciones auxiliares para la gestión de las fechas 1219 */ 1220function twoDatesToString(sd, ed) { 1221 var str_date = 'Del ' + sd.getDate(); 1222 1223 // Si tienen el mismo mes 1224 if (sd.getMonth() == ed.getMonth()) { 1225 var month_name = $.fn.datepicker.dates['es']['months'][ed.getMonth()]; 1226 str_date += ' al ' + ed.getDate() + ' de ' + month_name; 1227 } else { 1228 var sd_month_name = $.fn.datepicker.dates['es']['months'][sd.getMonth()]; 1229 var ed_month_name = $.fn.datepicker.dates['es']['months'][ed.getMonth()]; 1230 str_date += ' de ' + sd_month_name + ' #YEAR# al ' + ed.getDate() + ' de ' + ed_month_name; 1231 } 1232 1233 // Si tienen el mismo año 1234 if (sd.getFullYear() == ed.getFullYear()) { 1235 str_date = str_date.replace('#YEAR#', ''); 1236 str_date += ' ' + sd.getFullYear(); 1237 } else { 1238 str_date = str_date.replace('#YEAR#', 'de ' + sd.getFullYear()); 1239 str_date += ' de ' + ed.getFullYear(); 1240 } 1241 1242 return str_date; 1243} 1244 1245function ddmmyyyyToDate(str) { 1246 var parts = str.split('/'); 1247 var tmp = new Date(parts[2], (parts[1] - 1), parts[0]); 1248 return tmp; 1249} 1250 1251function dateToddmmyyyy(str) { 1252 var parts = str.split('-'); 1253 var tmp = parts[2] + '/' + parts[1] + '/' + parts[0]; 1254 return tmp; 1255} 1256 1257function ddmmyyyyToyyyymmdd(str) { 1258 var parts = str.split('/'); 1259 var tmp = parts[2] + '-' + parts[1] + '-' + parts[0]; 1260 return tmp; 1261} 1262 1263function aContainsB(a, b) { 1264 return a.indexOf(b) >= 0; 1265} 1266 1267function createTypeahead(objeto) { 1268 var options = { 1269 multiple: true, 1270 minimumInputLength: 2, 1271 formatInputTooShort: function() { 1272 return objeto.data('placeholder') ? objeto.data('placeholder') : "Introduce el nombre"; 1273 }, 1274 ajax: { 1275 url: objeto.data('source'), 1276 dataType: 'json', 1277 quietMillis: 250, 1278 data: function(term, page) { 1279 return { 1280 autocomplete: true, 1281 q: term, // search term 1282 page: page 1283 }; 1284 }, 1285 results: function(data, page) { 1286 return { results: data.data }; 1287 }, 1288 cache: true 1289 }, 1290 initSelection: function(element, callback) { 1291 var data = []; 1292 1293 if (objeto.data('init-selection-function')) { 1294 data = eval(objeto.data('init-selection-function'))(element); 1295 } else 1296 for (var i in element.data('init-selection')) { 1297 var item = element.data('init-selection')[i]; 1298 data.push({ id: item.id, text: item.name }); 1299 } 1300 1301 callback(data); 1302 }, 1303 dropdownCssClass: "bigdrop", 1304 escapeMarkup: function(m) { return m; } // we do not want to escape markup since we are displaying html in results 1305 } 1306 1307 if (objeto.data('values')) { 1308 delete options.ajax; 1309 options['data'] = objeto.data('values'); 1310 } 1311 1312 if (!objeto.data('multiple') || objeto.data('multiple') == false) 1313 options['maximumSelectionSize'] = 1; 1314 1315 // Binding callbacks 1316 if (objeto.data('no-matches')) 1317 options['formatNoMatches'] = eval(objeto.data('no-matches')); 1318 1319 if (objeto.data('create-choice')) { 1320 options['tags'] = true; 1321 options['createSearchChoice'] = eval(objeto.data('create-choice')); 1322 } 1323 1324 if (objeto.data('format-result')) { 1325 options['formatResult'] = eval(objeto.data('format-result')); 1326 } 1327 1328 objeto.select2(options); 1329} 1330 1331//Si no existe el usuario 1332function userNoMatches(term) { 1333 var html_str = ''; 1334 1335 if (term != null && term != "" && term != this.data('placeholder')) { 1336 html_str = 'No se encontraron personas que coincidan con la búsqueda.</li>' + 1337 '<li class="select2-quick-add"><a class="btn btn-md btn-block btn--success js-userCreate"' + 1338 ' data-url="" data-toggle="modal" href="' + this.data('modal-url') + '?rut=' + term+ '" data-target="#modalForm">Crear nuevo usuario</a>'; 1339 } 1340 1341 return html_str; 1342} 1343 1344function formatUserResults(user) { 1345 if (user.creating) return user.text; 1346 1347 var photo = "https://www.gravatar.com/avatar/00000000000000000000000000000000?d=mm&s=200"; 1348 1349 if (user.photo) 1350 photo = "/imagecache/avatar/" + user.photo; 1351 1352 var markup = "<div class='row-fluid clearfix'>" + 1353 "<div class='col-md-2'><div class='avatar avatar--medium'><img src='" + photo + "'/></div></div>" + 1354 "<div class='col-md-10'>" + 1355 "<div class='select2Result-title'>
1355" + user.text + "</div>"; 1356 1357 markup += "<div class='select2Result-description'>" + user.rut + "</div>" + 1358 "</div></div>"; 1359 1360 return markup; 1361} 1362 1363const imageTransition = (imageContainer) => { 1364 let image = imageContainer.querySelector('.active'); 1365 image.classList.remove('active'); 1366 if (Number(image.dataset['position']) + 1 < imageContainer.children.length ){ 1367 imageContainer.children[Number(image.dataset['position']) + 1].classList.add('active') 1368 } else { 1369 imageContainer.children[0].classList.add('active') 1370 } 1371 } 1372 1373(function($) { 1374 1375 // Tableter plugin 1376 var Tableter = function(element, options) { 1377 this.$element = $(element); 1378 this.options = $.extend({ 1379 // These are the defaults. 1380 route: "#", 1381 onTableLoad: function() {}, 1382 }, options); 1383 this.request = null; 1384 this.$element.on('tableter-reload', $.proxy(this.loadContent, this)); 1385 this.loadContent(); 1386 } 1387 1388 Tableter.DEFAULTS = { 1389 route: "#", 1390 onTableLoad: function() {}, 1391 } 1392 1393 Tableter.prototype.loadContent = function(e, route) { 1394 var type = this.$element.prop('tagName'); 1395 var colspan, tbody, pagination, page, count, loading; 1396 if (type == 'DIV') { 1397 colspan = "100%"; 1398 tbody = this.$element.find('.js-tableterContent'); 1399 pagination = $('.pagination[data-table="#' + this.$element.attr('id') + '"]'); 1400 page = $('.js-tableter-pagination[data-table="#' + this.$element.attr('id') + '"] li.active').text(); 1401 count = $('.js-tableter-count[data-table="#' + this.$element.attr('id') + '"]'); 1402 loading = '<div class="tableter-loading u-textCenter col-md-12"><i class="fa fa-2x fa-spinner fa-spin"></i></div>'; 1403 } else if (type == 'TABLE') { 1404 colspan = this.$element.find('thead th').length; 1405 tbody = this.$element.find('tbody'); 1406 pagination = $('.pagination[data-table="#' + this.$element.attr('id') + '"]'); 1407 page = $('.js-tableter-pagination[data-table="#' + this.$element.attr('id') + '"] li.active').text(); 1408 count = $('.js-tableter-count[data-table="#' + this.$element.attr('id') + '"]'); 1409 loading = '<tr><td class="tableter-loading u-textCenter" colspan="' + colspan + '"><i class="fa fa-2x fa-spinner fa-spin"></i></td></tr>'; 1410 } 1411 1412 1413 var tableter = this; 1414 var url = route; 1415 1416 if (typeof route === 'undefined' || route == null) { 1417 url = this.options.route; 1418 if (page && page === parseInt(page)) 1419 url += (url.indexOf('?') >= 0 ? '&' : '?') + 'page=' + page; 1420 } 1421 1422 if (tableter.options.append == true) 1423 tbody.append(loading); 1424 else 1425 tbody.html(loading); 1426 1427 pagination.empty(); 1428 1429 if (this.request != null) 1430 this.request.abort(); 1431 1432 var tableterObj = this; 1433 $('.js-tableterFilterForm').each(function() { 1434 if ($(this).length > 0 && tableterObj.$element.is($($(this).data('table')))) { 1435 var $form = $(this).closest('form'); 1436 /* removing soon */ 1437 $(this).find('.js-filterSelect, .js-filterText').each(function(i, obj) { 1438 var $input = $(obj).siblings('input.js-tableterFilter'); 1439 if ($(obj).val() != "" && $(obj).val()!=null ) { 1440 $input.val($(obj).data('prepend') + $(obj).val()); 1441 } else { 1442 $input.val(""); 1443 } 1444 }); 1445 /*****************/ 1446 $(this).find('.js-generalFilterSelect, .js-generalFilterText').each(function(i, obj) { 1447 var $input = $(obj).siblings('input.js-tableterFilter'); 1448 if ($(obj).val() != "" && $(obj).val()!=null ) { 1449 $input.val($(obj).val()); 1450 } else { 1451 $input.val(""); 1452 } 1453 }); 1454 1455 var formData = $form.serialize(); 1456 url += (url.indexOf('?') >= 0 ? '&' : '?') + formData; 1457 return false;
1458 } 1459 }); 1460 1461 1462 this.request = $.get(url, function(response) { 1463 if (tableter.options.append == true) { 1464 $('.tableter-loading', tbody).parent().remove(); 1465 tbody.append(response); 1466 } else { 1467 tbody.html(response); 1468 } 1469 1470 // La paginación 1471 pagination.html($('.pagination', $(response)).html()); 1472 1473 // Los resultados 1474 count.empty().html($('.js-tableter-count', $(response)).html()); 1475 1476 // Evento para poder manejar los distintos comportamientos una vez hecho submit 1477 tableter.$element.trigger('tableter.loaded'); 1478 1479 // Si fuera necesario ejecutar una rutina luego 1480 tableter.options.onTableLoad.call(tableter.$element); 1481 1482 tableter.request = null; 1483 }) 1484 .fail(function(data, textStatus) { 1485 if (textStatus != 'abort') 1486 notify('Ocurrió un error. Por favor intente de nuevo.', 'danger'); 1487 tableter.request = null; 1488 }) 1489 .success(function(data, textStatus) { 1490 const {show_filter_on_url} = tableter.options; 1491 if(show_filter_on_url) { 1492 let rawUrl = url.slice(url.lastIndexOf('_token')); 1493 const queryString = rawUrl.slice(rawUrl.indexOf('filter')); 1494 const params = new URLSearchParams(queryString); 1495 [...params.entries()].forEach(([key, value]) => { 1496 if (!value) { 1497 params.delete(key); 1498 } 1499 }); 1500 const {location, history} = window; 1501 const {origin, pathname} = location; 1502 const nextURL = origin + pathname + '?' + params; 1503 const nextTitle = ''; 1504 const nextState = { additionalInformation: '' }; 1505 history.replaceState(nextState, nextTitle, nextURL); 1506 } 1507 }); 1508 return this; 1509 } 1510 1511 Tableter.prototype.reload = function(route) { 1512 this.loadContent(null, route); 1513 } 1514 1515 $.fn.tableter = function(options, arg) { 1516 return this.each(function() { 1517 var $this = $(this); 1518 var data = $this.data('bs.tableter'); 1519 var allOptions = $.extend({}, Tableter.DEFAULTS, $this.data(), typeof options == 'object' && options); 1520 1521 if (!data) { 1522 $this.data('bs.tableter', (data = new Tableter(this, allOptions))); 1523 } 1524 if (typeof options == 'string') { 1525 data[options](arg); 1526 } 1527 }); 1528 1529 }; 1530 1531 $(window).on('load', function() { 1532 $('.js-maskrut').on('keyup click blur', function(e) { 1533 const identityDocument = $(this).val(); 1534 const newVal = rutFormat(identityDocument); 1535 $(this).val(newVal); 1536 }); 1537 1538 // Controlar el click para el sorting 1539 $('body').on('click', '.js-tableter th[class*=sorting]', function() { 1540 1541 var table = $($(this).parents('.js-tableter')); 1542
1543 if ($(this).data('sort') == '' || $(this).data('sort') == 'desc') 1544 $(this).data('sort', 'asc'); 1545 else 1546 $(this).data('sort', 'desc'); 1547 1548 // Cambiando la clase, por ahora el filtro es individual, pero se puede hacer multiple 1549 $('th[class*=sorting]', table).removeClass('sorting_asc sorting_desc').addClass('sorting'); 1550 $(this).removeClass('sorting').addClass('sorting_' + $(this).data('sort')); 1551 1552 var route = table.data('route') + (table.data('route').indexOf('?') >= 0 ? '&' : '?') + 'sort[]=' + $(this).data('field') + ',' + $(this).data('sort'); 1553 1554 // Sort con condiciones 1555 if ($(this).data('filters')) 1556 route += '&' + $(this).data('filters'); 1557 1558 table.tableter('reload', route); 1559 }); 1560 1561 // Controlar la caja de búsqueda de la tabla 1562 $('body').on('keyup', '.js-tableter-search[data-table]', function() { 1563 var table = $($(this).data('table')); 1564 var field = $(this).data('field'); 1565 var value = $(this).val(); 1566 1567 var route = table.data('route') + (table.data('route').indexOf('?') >= 0 ? '&' : '?') + 'filters[]=' + field + ',like,' + value; 1568 delay(function() { 1569 table.tableter('reload', route); 1570 }, 600); 1571 }); 1572 1573 // Controlar otros elementos relacionados 1574 $('body').on('click', '.js-tableter-modifier[data-table] a', function(e) { 1575 var table = $($(this).parents('.js-tableter-modifier').data('table')); 1576 var field = $(this).parents('.js-tableter-modifier').data('field'); 1577 1578 e.preventDefault(); 1579 1580 // Cambia status 1581 $(this).parents('.js-tableter-modifier').find('li').removeClass('is-active'); 1582 $(this).parents('li').addClass('is-active'); 1583 1584 var route = table.data('route') + (table.data('route').indexOf('?') >= 0 ? '&' : '?') + 'filters[]=' + field + ',' + $(this).data('value'); 1585 table.tableter('reload', route); 1586 }); 1587 1588 $('body').on('click', '.js-filterButton', function() { 1589 var $input = $(this).siblings('input.js-tableterFilter'); 1590 if ($(this).data('value') != "") 1591 $input.val($(this).data('prepend') + $(this).data('value')); 1592 else 1593 $input.val(""); 1594 1595 $input.change(); 1596 }); 1597 1598 /* removing soon */ 1599 $('body').on('keyup', '.js-filterText', function() { 1600 var $input = $(this).siblings('input.js-tableterFilter'); 1601 if ($(this).val() != "") 1602 $input.val($(this).data('prepend') + $(this).val()); 1603 else 1604 $input.val(""); 1605 1606 delay(function() { 1607 $input.change(); 1608 }, 600); 1609 }); 1610 1611 $('body').on('change', '.js-filterSelect,.js-filterDate,.js-filterTime', function() { 1612 var $input = $(this).siblings('input.js-tableterFilter'); 1613 1614 if ($(this).val() != "") 1615 $input.val($(this).data('prepend') + $(this).val()); 1616 else 1617 $input.val(""); 1618 1619 $input.change(); 1620 }); 1621 /***************/ 1622 1623 $('body').on('keyup', '.js-generalFilterText', function() { 1624 var $input = $(this).siblings('input.js-tableterFilter'); 1625 if ($(this).val() != "") 1626 $input.val($(this).val()); 1627 else 1628 $input.val(""); 1629 1630 delay(function() { 1631 $input.change(); 1632 }, 600); 1633 }); 1634 1635 $('body').on('change', '.js-generalFilterSelect,.js-generalFilterDate,.js-generalFilterTime', function() { 1636 var $input = $(this).siblings('input.js-tableterFilter'); 1637 1638 if ($(this).val() != "") 1639 $input.val($(this).val()); 1640 else 1641 $input.val(""); 1642 1643 $input.change(); 1644 }); 1645 1646 1647 $('body').on('change', '.js-tableterFilter', function() { 1648 var $form = $(this).closest('form'); 1649 var $table = $($form.data('table')); 1650 $table.tableter('reload'); 1651 }); 1652 1653 // Controlar el click en la paginación 1654 $('body').on('click', '.js-tableter-pagination[data-table] a', function(e) { 1655 e.preventDefault(); 1656 var table = $($(this).parents('.js-tableter-pagination').data('table')); 1657 table.tableter('reload', $(this).attr('href')); 1658 }); 1659 1660 $('body').on('submit', '.js-tableter-searchForm', function(e) { 1661 e.preventDefault(); 1662 e.stopImmediatePropagation(); 1663 var table = $($(this).data('table')); 1664 var route = table.data('route'); 1665 1666 $('input, select', $(this)).each(function() { 1667 if ($(this).val()) { 1668 // Para poner ? o & según se requiera 1669 route += route.indexOf('?') >= 0 ? '&' : '?'; 1670 1671 // Si define un campo en particular se formatea en 'parametros tableter' 1672 // de lo contrario se manda como url parameter 1673 if ($(this).data('field')) { 1674 // Campo 1675 route += 'filters[]=' + $(this).data('field'); 1676 1677 // Operator 1678 if ($(this).data('operator')) { 1679 route += ',' + $(this).data('operator') + ','; 1680 } 1681 1682 // Valor 1683 route += $(this).data('type') == 'date' ? ddmmyyyyToyyyymmdd($(this).val()) : $(this).val(); 1684 } else { 1685 route += $(this).attr('name') + '=' + $(this).val(); 1686 } 1687 1688 } 1689 }); 1690 table.tableter('reload', route); 1691 }); 1692 }) 1693 1694 // Autoloader Plugin 1695 var Autoloader = function(element) { 1696 this.$element = $(element); 1697 } 1698 1699 Autoloader.prototype.loadContent = function(e) { 1700 var autoloader = this; 1701 this.$element.html(loadingElement()); 1702 1703 this.$element.load(this.$element.data('route'), function() { 1704 autoloader.$element.trigger('autoloader.loaded'); 1705 }); 1706 }; 1707 1708 $.fn.autoloader = function(method) { 1709 return this.each(function() { 1710 var $this = $(this); 1711 var data = $this.data('bs.autoloader'); 1712 1713 if (!data) { 1714 $this.data('bs.autoloader', (data = new Autoloader(this))); 1715 $this.data('bs.autoloader').loadContent(); 1716 } 1717 1718 if (method == 'reload') { 1719 $this.data('bs.autoloader').loadContent(); 1720 } 1721 }); 1722 }; 1723 1724 /*$(window).ready(function() { 1725 var sourceImage = document.getElementById("js-colorThiefImage"); 1726 var color = colorThief(sourceImage); 1727 $('.section--fullWidth').css("background-color", "rgb(" + color + ")"); 1728 1729 });*/ 1730 1731 function colorThief(sourceImage) { 1732 1733 var colorThief = new ColorThief(); 1734 var color = colorThief.getColor(sourceImage); 1735 1736 color[0] = color[0] * (1 / 2); 1737 color[1] = color[1] * (1 / 2); 1738 color[2] = color[2] * (3 / 4); 1739 1740 return color; 1741 } 1742 1743 $(document).mousedown(function (event) { 1744
1745 if (!$(event.target).closest(".js-dropdownChild").length && !$(event.target).closest(".js-dropdownFather").length) { 1746 1747 $('.js-dropdownChild').hide(); 1748 } 1749 1750 if (!$(event.target).closest(".js-dropdownChildMobile").length && !$(event.target).closest(".js-dropdownFatherMobile").length) { 1751 1752 $('.js-dropdownChildMobile').hide(); 1753 } 1754 1755 }); 1756 1757 $(document).ready(function() { 1758 1759 $('.js-dropdownFather').click(function(event) { 1760 1761 event.stopPropagation(); 1762 1763 var dropdownFatherId = $(this).data('dropdown-father-id'); 1764 1765 $('.js-dropdownChild').each(function() { 1766 if ($(this).data('dropdown-father-id') != dropdownFatherId) { 1767 $(this).hide(); 1768 } 1769 }); 1770 1771 $('.js-dropdownChild[data-dropdown-father-id="' + dropdownFatherId + '"]' ).toggle(); 1772 }); 1773 1774 $('.js-dropdownFatherMobile').click(function(event) { 1775 1776 event.stopPropagation(); 1777 1778 var dropdownFatherId = $(this).data('dropdown-father-id'); 1779 1780 $('.js-dropdownChildMobile').each(function() { 1781 if ($(this).data('dropdown-father-id') != dropdownFatherId) { 1782 $(this).hide(); 1783 } 1784 }); 1785 1786 $('.js-dropdownChildMobile[data-dropdown-father-id="' + dropdownFatherId + '"]' ).toggle(); 1787 }); 1788 1789 1790 $('.js-infoBoxControl').click(function(e) { 1791 1792 if ($(this).data('status') == 'expanded') { 1793 1794 $(this).closest('.row').find("div[class^='infoBox-']").not('.infoBox-header').hide(100); 1795 $(this).data('status', 'collapsed'); 1796 $(this).closest('.row').find(".js-infoBoxControl").removeClass('fa-minus').addClass('fa-plus'); 1797 1798 } else { 1799 1800 $(this).closest('.row').find("div[class^='infoBox-']").not('.infoBox-header').show(100); 1801 $(this).data('status', 'expanded'); 1802 $(this).closest('.row').find(".js-infoBoxControl").removeClass('fa-plus').addClass('fa-minus'); 1803 } 1804 }); 1805 1806 let multiBackgroundContainers = document.getElementsByClassName('js-multi-background'); 1807 for (i = 0; i < multiBackgroundContainers.length; i++ ){ 1808 if (multiBackgroundContainers[i].children.length > 1) { 1809 setInterval(imageTransition, 4000, multiBackgroundContainers[i]); 1810 } 1811 } 1812 1813 if ($('.owl-carousel.fullScreenSlider').length) { 1814 1815 owlfullScreenSlider = $('.owl-carousel.fullScreenSlider').owlCarousel({ 1816 loop:true, 1817 nav:true, 1818 center: true, 1819 autoplay: false, 1820 dots: true, 1821 navText : ['<i class="fa fa-angle-left" aria-hidden="true" style="font-size:40px;"></i>','<i class="fa fa-angle-right" aria-hidden="true"></i>'], 1822 navClass: ['owl-prev','owl-next'], 1823 responsive:{ 1824 0:{ 1825 items:1 1826 } 1827 } 1828 }); 1829 1830 owlfullScreenSlider.on('changed.owl.carousel', function(e) { 1831 owlfullScreenSlider.trigger('stop.owl.autoplay'); 1832 owlfullScreenSlider.trigger('play.owl.autoplay'); 1833 }); 1834 1835 if ($('.fullWidthHeader.hidden-xs').height() < 90) { 1836 1837 $('.fullWidthSlider--small').height( $(window.top).height() - 200); 1838 $('.owl-stage-outer').height( $(window.top).height() - 200); 1839 $('.homeSlider--textContainer').css('top', $(window.top).height() - 350); 1840 1841 } else if ($(document).width() > 1200) { 1842 1843 $('.owl-stage-outer').height( $(window.top).height() - 190); 1844 $('.homeSlider--textContainer').css('top', $(window.top).height() - 350); 1845 } 1846 1847 } 1848 function getItems(currentLength, items) { 1849 if (currentLength < items) { 1850 return currentLength; 1851 } 1852 else { 1853 return items; 1854 } 1855 } 1856 1857 function getLoop(currentLength, items) { 1858 if (currentLength < items) { 1859 return false;
1860 } 1861 else { 1862 return true; 1863 } 1864 } 1865 1866 var fixOwl = function(owl_reference){ 1867 var $stage = $(`.${owl_reference.id} .owl-stage`); 1868 // if ($(`.${owl_reference.id} .owl-prev`).length > 0 && $stage[0].parentElement.parentElement.style.color){ 1869 // $(`.${owl_reference.id} .owl-prev`)[0].setAttribute('style', 1870 // `background: linear-gradient(to right, ${$stage[0].parentElement.parentElement.style.color}, 90%, ${$stage[0].parentElement.parentElement.style.color.replace(')', ', 0)').replace('gb', 'gba')}) !important;`) 1871 // $(`.${owl_reference.id} .owl-next`)[0].setAttribute('style', 1872 // `background: linear-gradient(to left, ${$stage[0].parentElement.parentElement.style.color}, 90%, ${$stage[0].parentElement.parentElement.style.color.replace(')', ', 0)').replace('gb', 'gba')}) !important;`) 1873 // } 1874 if ($stage.length > 0){ 1875 let counter = 0; 1876 var $imgs = $(`.${owl_reference.id} .banner-img-link`); 1877 1878 for (let i = 0; i < $imgs.length; i++){ 1879 if ($imgs[i].complete && $imgs[i].naturalWidth !== 0){ 1880 counter ++; 1881 } 1882 } 1883 1884 if ($imgs.length !== counter) { 1885 return false; 1886 } else { 1887 var stageW = $stage.width(), 1888 $el = $(`.${owl_reference.id} .owl-item`), 1889 elW = 0; 1890 $el.each(function() { 1891 elW += $(this).width()+ +($(this).css("margin-right").slice(0, -2)) 1892 }); 1893 if ( elW > stageW ) { 1894 $stage.width( elW ); 1895 } else { 1896 let imgsWidth = 0; 1897 if ($el.length > 0){ 1898 for (let i = 0; i < $imgs.length; i++){ 1899 imgsWidth += $imgs[i].width + 40; //20 px de margen * 2 1900 } 1901 } 1902 $stage[0].setAttribute('style', ''); 1903 $el.each(function(){ 1904 $(this).css('display', 'flex'); 1905 $(this).css('justify-content', 'center'); 1906 $(this).css('width', 'auto'); 1907 if(imgsWidth > 0){ 1908 $(this).css('padding-left', `${Math.floor((stageW - imgsWidth)/(($el.length)* 2))}px`); 1909 $(this).css('padding-right', `${Math.floor((stageW - imgsWidth)/(($el.length)* 2))}px`); 1910 } 1911 }) 1912 }; 1913 return true; 1914 } 1915 1916 } 1917 } 1918 1919 if ($('.owl-carousel.banner-cycler-circular').length){ 1920 1921 $(".owl-carousel.banner-cycler-circular").each(function(){ 1922 1923 $(this).owlCarousel({ 1924 smartSpeed: 450, 1925 autoplay: true, 1926 mouseDrag: true, 1927 touchDrag: true, 1928 autoplayHoverPause: true, 1929 nav:true, 1930 navText : ['<i class="fa fa-angle-left" aria-hidden="true" style="font-size:40px;"></i>','<i class="fa fa-angle-right" aria-hidden="true"></i>'], 1931 navClass: ['owl-prev','owl-next'], 1932 dots: false, 1933 responsive: { 1934 0: { 1935 dots: getLoop($(this).children().length, 3), 1936 dotsEach: 1, 1937 items: getItems($(this).children().length, 3), 1938 loop: getLoop($(this).children().length, 3), 1939 }, 1940 410: { 1941 dots: getLoop($(this).children().length, 4), 1942 dotsEach: 1, 1943 items: getItems($(this).children().length, 4), 1944 loop: getLoop($(this).children().length, 4), 1945 }, 1946 667: { 1947 dots: getLoop($(this).children().length, 5), 1948 dotsEach: 1, 1949 items: getItems($(this).children().length, 5), 1950 loop: getLoop($(this).children().length, 5), 1951 }, 1952 768: { 1953 dots: getLoop($(this).children().length, 3), 1954 dotsEach: 1, 1955 items: getItems($(this).children().length, 3), 1956 loop: getLoop($(this).children().length, 3), 1957 }, 1958 950: { 1959 dots: false, 1960 items: getItems($(this).children().length, 4), 1961 loop: getLoop($(this).children().length, 4), 1962 }, 1963 1100: { 1964 dots: false, 1965 items: getItems($(this).children().length, 5), 1966 loop: getLoop($(this).children().length, 5), 1967 }, 1968 1300: { 1969 dots: false, 1970 items: getItems($(this).children().length, 6), 1971 loop: getLoop($(this).children().length, 6), 1972 }, 1973 1400: { 1974 dots: false, 1975 items: getItems($(this).children().length, 7), 1976 loop: getLoop($(this).children().length, 7), 1977 }, 1978 1600: { 1979 dots: false, 1980 items: getItems($(this).children().length, 8), 1981 loop: getLoop($(this).children().length, 8), 1982 }, 1983 1980: { 1984 dots: false, 1985 items: getItems($(this).children().length, 9), 1986 loop: getLoop($(this).children().length, 9), 1987 } 1988 } 1989 }); 1990 1991 $(this).on('changed.owl.carousel', function(e) { 1992 $(this).trigger('stop.owl.autoplay'); 1993 $(this).trigger('play.owl.autoplay'); 1994 }); 1995 }) 1996 } 1997 1998 if ($('.owl-carousel.banner-cycler-rectangular').length){ 1999 2000 $(".owl-carousel.banner-cycler-rectangular").each(function(){ 2001 let elements_width = 0; 2002 for (let i = 0; i < $(this)[0].children.length; i++){ 2003 elements_width += parseFloat($(this)[0].children[i].getAttribute('data-width')) + 20; //20 px de margen 2004 } 2005 let fullWidth = !$(this)[0].parentElement.classList.contains('container'); 2006 if (fullWidth) { 2007 elements_width += 150 + 80 + 30; // px de paddings y margenes de los parents 2008 } 2009 2010 $(this).owlCarousel({ 2011 smartSpeed: 450, 2012 nav:true, 2013 navText : ['<i class="fa fa-angle-left" aria-hidden="true" style="font-size:40px;"></i>','<i class="fa fa-angle-right" aria-hidden="true"></i>'], 2014 navClass: ['owl-prev owl-nav-gradient','owl-next owl-nav-gradient'], 2015 autoplayHoverPause: true, 2016 center: true, 2017 onInitialized: () => { 2018 if (!fixOwl($(this)[0])) { 2019 setTimeout(() => { 2020 $(this).trigger('refresh.owl.carousel'); 2021 }, 2000); 2022 }}, 2023 onRefreshed: () => { 2024 if (!fixOwl($(this)[0])) { 2025 setTimeout(() => { 2026 $(this).trigger('refresh.owl.carousel'); 2027 }, 2000); 2028 } else{ 2029 if ($(this)[0].clientWidth < 460){ 2030 $(this).trigger('play.owl.autoplay'); 2031 } 2032 }}, 2033 responsive: { 2034 0: {
2035 autoPlay: getLoop($(this).children().length, 3), 2036 autoWidth: getLoop($(this).children().length, 3), 2037 dots: getLoop($(this).children().length, 3), 2038 items: 1, 2039 loop: getLoop($(this).children().length, 3), 2040 mouseDrag: getLoop($(this).children().length, 3), 2041 nav: getLoop($(this).children().length, 3), 2042 touchDrag: getLoop($(this).children().length, 3), 2043 }, 2044 460: { 2045 autoplay: elements_width >= 460, 2046 autoWidth: elements_width >= 460, 2047 dots: elements_width >= 460, 2048 loop: elements_width >= 460, 2049 mouseDrag: elements_width >= 460, 2050 touchDrag: elements_width >= 460, 2051 }, 2052 768: { 2053 autoplay: elements_width >= 768, 2054 autoWidth: elements_width >= 768, 2055 dots: elements_width >= 768, 2056 loop: elements_width >= 768, 2057 mouseDrag: elements_width >= 768, 2058 touchDrag: elements_width >= 768, 2059 }, 2060 1000: { 2061 autoplay: elements_width >= 1000, 2062 autoWidth: elements_width >= 1000, 2063 dots: false, 2064 items: elements_width <= 1000 ? $(this)[0].children.length : undefined, 2065 loop: elements_width >= 1000, 2066 mouseDrag: elements_width >= 1000, 2067 touchDrag: elements_width >= 1000, 2068 }, 2069 1200: { 2070 autoplay: elements_width >= (fullWidth ? 1200 : 1170), 2071 autoWidth: elements_width >= (fullWidth ? 1200 : 1170), 2072 dots: false, 2073 items: elements_width <= (fullWidth ? 1200 : 1170) ? $(this)[0].children.length : undefined, 2074 loop: elements_width >= (fullWidth ? 1200 : 1170), 2075 mouseDrag: elements_width >= (fullWidth ? 1200 : 1170), 2076 touchDrag: elements_width >= (fullWidth ? 1200 : 1170), 2077 }, 2078 1400: { 2079 autoplay: elements_width >= (fullWidth ? 1400 : 1170), 2080 autoWidth: elements_width >= (fullWidth ? 1400 : 1170), 2081 dots: false, 2082 items: elements_width <= (fullWidth ? 1400 : 1170) ? $(this)[0].children.length : undefined, 2083 loop: elements_width >= (fullWidth ? 1400 : 1170), 2084 mouseDrag: elements_width >= (fullWidth ? 1400 : 1170), 2085 touchDrag: elements_width >= (fullWidth ? 1400 : 1170), 2086 }, 2087 1980: { 2088 autoplay: elements_width >= (fullWidth ? 1980 : 1170), 2089 autoWidth: elements_width >= (fullWidth ? 1980 : 1170), 2090 dots: false, 2091 items: elements_width <= (fullWidth ? 1980 : 1170) ? $(this)[0].children.length : undefined, 2092 loop: elements_width >= (fullWidth ? 1980 : 1170), 2093 mouseDrag: elements_width >= (fullWidth ? 1980 : 1170), 2094 touchDrag: elements_width >= (fullWidth ? 1980 : 1170), 2095 }, 2096 2400: { 2097 autoplay: elements_width >= (fullWidth ? 2400 : 1170), 2098 autoWidth: elements_width >= (fullWidth ? 2400 : 1170), 2099 dots: false, 2100 items: elements_width <= (fullWidth ? 2400 : 1170) ? $(this)[0].children.length : undefined, 2101 loop: elements_width >= (fullWidth ? 2400 : 1170), 2102 mouseDrag: elements_width >= (fullWidth ? 2400 : 1170), 2103 touchDrag: elements_width >= (fullWidth ? 2400 : 1170), 2104 } 2105 } 2106 }); 2107 2108 }); 2109 } 2110 2111 2112 if ($('.owl-carousel.diagonal').length) { 2113 2114 owl = $('.owl-carousel.diagonal').owlCarousel({ 2115 loop:true, 2116 nav:true, 2117 center: true, 2118 autoplay: false, 2119 nav:true, 2120 navText : ['<i class="fa fa-angle-left" aria-hidden="true" style="font-size:40px;"></i>','<i class="fa fa-angle-right" aria-hidden="true"></i>'], 2121 navClass: ['owl-prev','owl-next'], 2122 responsive:{ 2123 0:{ 2124 items:1 2125 }, 2126 769:{ 2127 items:1.25 2128 }, 2129 992:{ 2130 items:1.25 2131 } 2132 } 2133 }); 2134 2135 owl.on('changed.owl.carousel', function(e) { 2136 owl.trigger('stop.owl.autoplay'); 2137 owl.trigger('play.owl.autoplay'); 2138 }); 2139 2140 if ($(document).width() > 1200) { 2141 $('.owl-stage-outer').height( $(window.top).height() - 190); 2142 $('.homeSlider--textContainer').css('top', $(window.top).height() - 350); 2143 } 2144 } 2145 2146 if ($('.owl-carousel.owl-video').length) { 2147 2148 owl = $('.owl-carousel.owl-video').owlCarousel({ 2149 items:1, 2150 merge:true, 2151 loop:true, 2152 margin:10, 2153 video:true, 2154 lazyLoad:true, 2155 nav : true, 2156 navText : ["<i class='fa fa-chevron-left'></i>","<i class='fa fa-chevron-right'></i>"] 2157 /*center:true,*/ 2158 }); 2159 2160 $('.videoSliderSidebar-item').click(function(){ 2161 $('html, body').animate({ scrollTop: 0 }, 'fast'); 2162 $('.owl-carousel.owl-video').trigger('to.owl.carousel', $(this).data('video-id')); 2163 }); 2164 2165 } 2166 2167 2168 if ($('.js-mapGraph').length) { 2169 $('.extendedPageContent').height( $(window.top).height() - 43); 2170 } 2171 2172 }); 2173 2174})(jQuery); 2175 2176function rutClean(value) { 2177 if (typeof value === "string") { 2178 return value 2179 .replace(/[^0-9kK]+/g, "") 2180 .replace(/^0+/, "") 2181 .toUpperCase() 2182 } 2183 return "" 2184} 2185 2186function rutValidate(value) { 2187 if (typeof value !== "string") { 2188 return false 2189 } 2190 2191 if (/[A-Za-z]/g.test(value.replace(/[kK]/g, ""))) { 2192 return false 2193 } 2194 2195 const rut = rutClean(value) 2196 let rutDigits = parseInt(rut.slice(0, -1), 10) 2197 let m = 0 2198 let s = 1 2199 2200 while (rutDigits > 0) { 2201 s = (s + (rutDigits % 10) * (9 - (m++ % 6))) % 11 2202 rutDigits = Math.floor(rutDigits / 10) 2203 } 2204 const checkDigit = s > 0 ? String(s - 1) : "K" 2205 2206 return checkDigit === rut.slice(-1) 2207} 2208 2209function rutFormat(value) { 2210 const rut = rutClean(value) 2211 2212 if (rut.length <= 1) { 2213 return rut 2214 } 2215 2216 let result = `${rut.slice(-4, -1)}-${rut.substr(rut.length - 1)}` 2217 for (let i = 4; i < rut.length; i += 3) { 2218 result = `${rut.slice(-3 - i, -i)}.${result}` 2219 } 2220 2221 return result 2222}
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.