1let $ = jQuery.noConflict(); 2let body = $('body'); 3let header = $('#header'); 4let header_offset = header.offset().top; 5let menu_burger = $('.menu-burger'); 6let menu_container = $('.menu-container'); 7let project_link_popup = '.link-project[data-action="popup"]'; 8let project_popup = $('.project-view.popup'); 9let project_popup_close = '.project-view.popup .close-popup'; 10let project_popup_loader = $('.project-view.popup .loader'); 11 12let search_header = $('#form-directory-search #search'); 13 14let user_item = $('.user-item'); 15 16let search_content = $('header .search-content'); 17 18let form_feste_socia = $('#modal-feste-socia .wpcf7'); 19 20const funcionAjax = function (data) { 21 let retorno; 22 loader(); 23 let request = $.ajax({ 24 url: config.ajaxurl, 25 method: "POST", 26 data: data, 27 aync: false 28 }); 29 request.done(function (msg) { 30 return msg; 31 }); 32 33 request.fail(function (jqXHR, textStatus) { 34 //alert("Request failed: " + textStatus); 35 }); 36 loader(true); 37 38 return retorno; 39} 40 41const stickyMenu = function () { 42 $(window).scroll(function () { 43 if (window.innerWidth > 991 && header.hasClass('home')) { 44 if (window.pageYOffset >= header_offset) { 45 header.addClass("fixed"); 46 } else { 47 header.removeClass("fixed"); 48 } 49 } 50 }); 51} 52const toggleMenu = function () { 53 menu_burger.on('click', function () { 54 // OPEN MENU_CONTAINER 55 header.toggleClass("active"); 56 menu_container.toggleClass("active"); 57 $(this).toggleClass("active"); 58 search_content.removeClass('active'); 59 search_content.html(''); 60 }); 61} 62 63const loader = function (hide = false) { 64 if (hide) { 65 project_popup_loader.removeClass("active"); 66 } else { 67 project_popup_loader.addClass("active"); 68 } 69 70} 71 72const openProjectPopup = function () { 73 body.on('click', project_link_popup, function (e) { 74 /* 75 }); 76 project_link_popup.on('click', function (e) { */ 77 e.preventDefault(); 78 let project_url = $(this).attr("href"); 79 80 if (window.innerWidth > 992) { 81 body.addClass('project-popup-active'); 82 project_popup.addClass('active'); 83 let project_id = $(this).attr("data-project-id"); 84 //LLAMADA AJAX 85 let data = { 86 action: "get_project_popup", 87 project_id: project_id 88 } 89 90 91 let a = $.ajax({ 92 url: config.ajaxurl, 93 type: 'post', 94 data: data 95 }); 96 a.done(function (msg) { 97 //window.location.reload(); 98 $('.popup-content').append(msg); 99 }); 100 101 window.history.pushState({ 102 urlPath: project_url 103 }, 104 "", 105 project_url 106 ); 107 } else { 108 window.location.href = project_url; 109 } 110 111 112 }); 113 114 body.on('click', project_popup_close, function (e) { 115 e.preventDefault(); 116 body.removeClass('project-popup-active'); 117 project_popup.removeClass('active'); 118 $('.popup-content').empty(); 119 window.history.back(); 120 }); 121} 122 123const windowResize = function () { 124 $(window).resize(function () { 125 126 stickyMenu(); 127 128 /* 129 * Si la pantalla es más pequeña que 992, no mostramos el popup y mandamos al usuario a la página de proyecto 130 */ 131 if (project_popup.innerWidth() < 992 && project_popup.hasClass('active')) { 132 window.location.reload(); 133 } 134 home_intro_height(); 135 // RESIZE USER BOXES 136 user_items_height(); 137 138 qui_som_column_height(); 139 }); 140} 141 142const slugify = function (text) { 143 return text.toString().toLowerCase() 144 .replace(/\s+/g, '-') // Replace spaces with - 145 .replace(/[^\w\-]+/g, '') // Remove all non-word chars 146 .replace(/\-\-+/g, '-') // Replace multiple - with single - 147 .replace(/^-+/, '') // Trim - from start of text 148 .replace(/-+$/, ''); // Trim - from end of text 149} 150 151const register_form = function () { 152 let name = $('#signup-form #field_1'); 153 let username = $('#signup-form #signup_username'); 154 name.on('focusout', function () { 155 let text = slugify($(this).val()); 156 username.val(text); 157 }); 158 159 $('.check-label').on('focusout', function () { 160 if ($(this).val() != "") { 161 $('label[for="' + $(this).attr("name") + '"]').hide(); 162 } else { 163 $('label[for="' + $(this).attr("name") + '"]').show(); 164 } 165 }); 166} 167 168const edit_form = function () { 169 170 let form = $('#editar-usuario'); 171 172 form.submit(function (event) { 173 tinyMCE.triggerSave(); 174 let data = JSON.parse(JSON.stringify($(this).serializeArray())); 175 176 let o = { 177 name: "action", 178 value: "save_user_data" 179 } 180 data.push(o); 181 182 let a = $.ajax({ 183 url: config.ajaxurl, 184 type: 'post', 185 data: data 186 }); 187 a.done(function (msg) { 188 //console.log(msg); 189 window.location.reload(); 190 }); 191 event.preventDefault(); 192 return false;
193 }); 194} 195 196const delete_project = function () { 197 $('.delete-project').on('click', function (e) { 198 e.preventDefault(); 199 let p_id = $(this).attr("data-project-id"); 200 201 if (confirm('Segur que desitges esborrar aquest projecte?')) { 202 let data = { 203 action: "delete_project", 204 project_id: p_id 205 } 206 207 let a = $.ajax({ 208 url: config.ajaxurl, 209 type: 'post', 210 data: data 211 }); 212 a.done(function (msg) { 213 if (msg == "ok") { 214 window.location.reload(); 215 } else { 216 alert("Ha ocorregut un error"); 217 } 218 }); 219 } 220 }); 221} 222 223function delete_participacio(p_id) { 224 225 if (!p_id || p_id <= 0) return false; 226 227 if (confirm('Segur que desitges esborrar aquesta participacio?')) { 228 let data = { 229 action: "delete_participacio", 230 participacio_id: p_id 231 } 232 233 let a = $.ajax({ 234 url: config.ajaxurl, 235 type: 'post', 236 data: data 237 }); 238 a.done(function (msg) { 239 if (msg == "ok") { 240 window.location.reload(); 241 } else { 242 alert("Ha ocorregut un error"); 243 } 244 }); 245 } 246} 247 248const destacar_projecte = function () { 249 $('.featured-project').click(function (e) { 250 e.preventDefault(); 251 let user_id = $(this).attr("data-user-id"); 252 let project_id = $(this).attr("data-project-id"); 253 254 let data = { 255 action: "destacar_projecte", 256 project_id: project_id, 257 user_id: user_id 258 } 259 let a = $.ajax({ 260 url: config.ajaxurl, 261 type: 'post', 262 data: data 263 }); 264 a.done(function (msg) { 265 //console.log(msg); 266 if (msg == "ok") { 267 window.location.reload(); 268 } else { 269 alert("Ha ocorregut un error"); 270 } 271 }); 272 273 }); 274} 275 276const disable_links = function () { 277 $('body').on('click', '.disable-js', function (e) { 278 e.preventDefault(); 279 }); 280} 281 282const maxHeight = function (elems) { 283 return Math.max.apply(null, elems.map(function () { 284 return $(this).height(); 285 }).get()); 286} 287 288const user_items_height = function () { 289 var highest = null; 290 var hi = 0; 291 user_item.each(function () { 292 var h = $(this).height(); 293 if (h > hi) { 294 hi = h; 295 highest = $(this); 296 } 297 }); 298 //highest now contains the div with the highest so lets highlight it 299 user_item.find('.user-content').css('minHeight', hi + "px"); 300} 301 302const home_intro_height = function () { 303 if ($(window).width() < 992 && $(window).width() > 500) { 304 let height = $('section#intro-home .container-form-registro').css("height"); 305 $('section#intro-home .col-iz').css("height", height); 306 } 307} 308 309const qui_som_column_height = function () { 310 if ($(window).width() > 992) { 311 let height = $('section#feste-socia-columns .col-de').css("height"); 312 $('section#feste-socia-columns .col-iz').css("height", height); 313 } 314} 315 316const boton_flotante = function () { 317 let first_section = $('section').first(); 318 $(window).scroll(function () { 319 if (window.pageYOffset >= first_section.innerHeight() && window.innerWidth > 767) { 320 $('.btn-flotante').addClass('active'); 321 322 if (!window.sessionStorage.getItem('colabora-oculto')) { 323 $('section#barra-colabora').addClass('active'); 324 } 325 } else { 326 $('.btn-flotante').removeClass('active'); 327 if (!window.sessionStorage.getItem('colabora-oculto')) { 328 $('section#barra-colabora').removeClass('active'); 329 } 330 } 331 }); 332} 333 334const buscador_predictivo = function () { 335 /* 336 search_content.on('mouseleave', function () { 337 $(this).html(''); 338 $(this).removeClass('active'); 339 search_header.val(''); 340 search_header.parent().find('label').show(); 341 342 }); 343 */ 344 let timer = null; 345 search_header.on('keyup', function (e) { 346 e.preventDefault(); 347 348 $(this).parent().submit(function () { 349 return false;
350 }); 351 352 let length = $(this).val().length; 353 let valor = $(this).val(); 354 355 $(this).parent().find('label').hide(); 356 let allow_projects = true; 357 358 search_content.addClass('active'); 359 search_content.html('<div id="lod" class="lds-dual-ring"></div>'); 360 361 if (window.innerWidth < 767) { 362 allow_projects = false; 363 } 364 if (length > 1) { 365 366 let p = $(this).parent(); 367 clearTimeout(timer); 368 timer = setTimeout(function () { 369 //console.log(valor); 370 search(valor, allow_projects, p); 371 }, 500); 372 // OPEN CONTAINER 373 } else { 374 $(this).parent().find('label').show(); 375 // REMOVE CONTENT 376 // CLOSE CONTAINER 377 search_content.html(''); 378 search_content.removeClass('active'); 379 } 380 }); 381} 382 383const search = function (valor, allow_projects, p) { 384 let data = { 385 action: "buscador_mejorado", 386 texto: valor, 387 allow_projects: allow_projects 388 } 389 390 let request = $.ajax({ 391 url: config.ajaxurl, 392 method: "post", 393 data: data, 394 async: false, 395 beforeSend: function () { 396 }, 397 complete: function () { 398 399 }, 400 }); 401 request.success(function (msg) { 402 if (msg != false) { 403 // LLAMADA AJAX 404 405 let html = ``; 406 let users = JSON.parse(msg); 407 console.log(msg); 408 409 users.forEach(function (user, index) { 410 if (user.name != '' && user.link != false) { 411 html += ` 412 <div class="row user"> 413 <div class="user-avatar"> 414 <a href = "`+ user.link + `" class="link-save-route"> 415 <img src="`+ user.avatar + `" alt=""> 416 <div class="name">`+ user.name + `</div> 417 </a> 418 </div>`; 419 if (allow_projects) { 420 html += `<div class="user-projects">`; 421 $max_projects = 3; 422 $current_size = user.projects.length; 423 user.projects.forEach(function (project, index) { 424 if (index < $max_projects) { 425 html += ` 426 <a href="`+ project.p_link + `" class="link-project col-xs-4" data-action="popup" data-project-id="` + project.p_id + `"> 427 <div class="img-destacada" style="background-image:url(`+ project.image + `);"></div> 428 </a> 429 `; 430 /* 431 432html += ` 433<a href="`+ project.p_link + `" class="link-project col-xs-4"> 434 <div class="img-destacada" style="background-image:url(`+ project.image + `);"></div> 435</a> 436`; 437*/ 438 } 439 }); 440 html += `</div>`; 441 } 442 html += ` 443 444 </div> 445 `; 446 447 } 448 }); 449 450 //setTimeout(function(){ 451 search_content.html(''); 452 search_content.append(html); 453 //}, 1000); 454 } else { 455 search_content.html(''); 456 search_content.removeClass('active'); 457 } 458 }); 459 460 request.fail(function (jqXHR, textStatus) { 461 //alert("Request failed: " + textStatus); 462 }); 463} 464 465const submit_form_feste_socia = function () { 466 form_feste_socia.on('wpcf7submit', function (event) { 467 $(this).find('.modal-body').addClass('hide'); 468 $(this).find('.modal-footer').addClass('hide'); 469 }); 470} 471 472const go_to_content = function () { 473 let hash = window.location.hash; 474 console.log(hash); 475 if (body.hasClass('search-results') || body.hasClass('tax-profession') || body.hasClass('search-no-results') || hash == '#tree') { 476 $('html, body').animate({ scrollTop: $('section.cabecera').offset().top - 50 }, 1000); 477 } 478} 479 480/******* 481 * CUSTOM SELECT 482 */ 483const closeAllSelect = function (elmnt) { 484 /*a function that will close all select boxes in the document, 485 except the current select box:*/ 486 var x, y, i, arrNo = []; 487 x = document.getElementsByClassName("select-items"); 488 y = document.getElementsByClassName("select-selected"); 489 for (i = 0; i < y.length; i++) { 490 if (elmnt == y[i]) { 491 arrNo.push(i) 492 } else { 493 y[i].classList.remove("select-arrow-active"); 494 } 495 } 496 for (i = 0; i < x.length; i++) { 497 if (arrNo.indexOf(i)) { 498 x[i].classList.add("select-hide"); 499 } 500 } 501} 502const custom_select = function (x = false) { 503 var i, j, selElmnt, a, b, c; 504 /*look for any elements with the class "custom-select":*/ 505 if (!x) { 506 x = document.getElementsByClassName("custom-select"); 507 } 508 509 for (i = 0; i < x.length; i++) { 510 selElmnt = x[i].getElementsByTagName("select")[0]; 511 /*for each element, create a new DIV that will act as the selected item:*/ 512 a = document.createElement("DIV"); 513 a.setAttribute("class", "select-selected"); 514 a.innerHTML = selElmnt.options[selElmnt.selectedIndex].innerHTML; 515 x[i].appendChild(a); 516 /*for each element, create a new DIV that will contain the option list:*/ 517 b = document.createElement("DIV"); 518 b.setAttribute("class", "select-items select-hide"); 519 for (j = 0; j < selElmnt.length; j++) { 520 /*for each option in the original select element, 521 create a new DIV that will act as an option item:*/ 522 c = document.createElement("DIV"); 523 c.innerHTML = selElmnt.options[j].innerHTML; 524 c.addEventListener("click", function (e) { 525 /*when an item is clicked, update the original select box, 526 and the selected item:*/ 527 var y, i, k, s, h; 528 s = this.parentNode.parentNode.getElementsByTagName("select")[0]; 529 h = this.parentNode.previousSibling; 530 for (i = 0; i < s.length; i++) { 531 if (s.options[i].innerHTML == this.innerHTML) { 532 s.selectedIndex = i; 533 h.innerHTML = this.innerHTML; 534 y = this.parentNode.getElementsByClassName("same-as-selected"); 535 for (k = 0; k < y.length; k++) { 536 y[k].removeAttribute("class"); 537 } 538 this.setAttribute("class", "same-as-selected"); 539 break; 540 } 541 } 542 h.click(); 543 }); 544 b.appendChild(c); 545 } 546 x[i].appendChild(b); 547 a.addEventListener("click", function (e) { 548 /*when the select box is clicked, close any other select boxes, 549 and open/close the current select box:*/ 550 e.stopPropagation(); 551 closeAllSelect(this); 552 if (!this.parentNode.classList.contains('disabled')) { 553 this.nextSibling.classList.toggle("select-hide"); 554 this.classList.toggle("select-arrow-active"); 555 } 556 557 }); 558 } 559 /*if the user clicks anywhere outside the select box, 560 then close all select boxes:*/ 561 document.addEventListener("click", closeAllSelect); 562} 563 564const init_slick = function () { 565 $('.slider').slick({ 566 slidesToShow: 4, 567 slidesToScroll: 4, 568 infinite: false, 569 arrows: true, 570 prevArrow: $('.prev'), 571 nextArrow: $('.next'), 572 573 responsive: [ 574 { 575 breakpoint: 991, 576 settings: { 577 slidesToShow: 2, 578 slidesToScroll: 2, 579 } 580 }, 581 { 582 breakpoint: 767, 583 settings: { 584 slidesToShow: 1, 585 slidesToScroll: 1, 586 } 587 } 588 // You can unslick at a given breakpoint now by adding: 589 // settings: "unslick" 590 // instead of a settings object 591 ] 592 }) 593} 594 595function goBack() { 596 window.history.back(); 597 return false;
598 history.go(-1); 599 console.log("go back"); 600} 601 602const menu_directori = function () { 603 let first_section = $('section').first(); 604 window.onscroll = function () { 605 if (window.pageYOffset >= first_section.innerHeight() && window.innerWidth > 767) { 606 //$('header.directori').removeClass('directori'); 607 $('header.directori').addClass('scrolled'); 608 } else { 609 //$('header.directori').addClass('directori'); 610 $('header.directori').removeClass('scrolled'); 611 } 612 } 613} 614 615const load_professions = function () { 616 let hola = "hola"; 617 let html = ` 618 <span class="wpcf7-list-item"><label><input type="checkbox" name="especialidad_professional[]" value="`+ hola + `"><span class="wpcf7-list-item-label">` + hola + `</span></label></span> 619 `; 620 621 // LLAMADA AJAX 622 let data = { 623 "action": "modal_feste_social_professions" 624 } 625 let request = $.ajax({ 626 url: config.ajaxurl, 627 method: "POST", 628 data: data, 629 aync: false 630 }); 631 request.done(function (msg) { 632 $('.especialidad-container .wpcf7-checkbox').html(msg); 633 }); 634 635 request.fail(function (jqXHR, textStatus) { 636 //alert("Request failed: " + textStatus); 637 }); 638} 639 640const check_email_register = function () { 641 let input = $('#signup_email'); 642 let parent = input.parent(); 643 input.on('keyup', function (e) { 644 e.preventDefault(); 645 646 let length = $(this).val().length; 647 let valor = $(this).val(); 648 649 if (length > 1) { 650 // LLAMADA AJAX 651 let data = { 652 "action": "check_email_register", 653 "email": valor 654 } 655 let request = $.ajax({ 656 url: config.ajaxurl, 657 method: "POST", 658 data: data, 659 aync: false 660 }); 661 request.done(function (msg) { 662 console.log(msg) 663 if (msg == 'false') { 664 parent.addClass('error-input'); 665 } else { 666 parent.removeClass('error-input'); 667 } 668 }); 669 670 request.fail(function (jqXHR, textStatus) { 671 //alert("Request failed: " + textStatus); 672 }); 673 } else { 674 parent.removeClass('error-input'); 675 } 676 677 }); 678 679} 680 681const link_new_window = function () { 682 let link = $('#description-user .link-page'); 683 684 link.each(function (index, element) { 685 $(this).find('a').attr("target", "_blank"); 686 }); 687} 688function formatBytes(bytes, decimals = 2) { 689 if (bytes === 0) return '0 Bytes'; 690 691 const k = 1024; 692 const dm = decimals < 0 ? 0 : decimals; 693 const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']; 694 695 const i = Math.floor(Math.log(bytes) / Math.log(k)); 696 697 return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)); 698} 699const check_image_size = function () { 700 body.on('change', '.acf-image-uploader input[type="file"]', function (evt) { 701 702 let size = this.files[0].size / 1024 / 1024; 703 704 if (size > 10) { 705 alert('El tamany mà xim permès de l\'imatge és de 10MB'); 706 $(this).val(''); 707 } 708 /* $('.acf-form-submit input[type="submit"]').attr("disabled", "disabled"); 709 }else{ 710 $('.acf-form-submit input[type="submit"]').removeAttr("disabled"); 711 } */ 712 }); 713 body.on('change', '.acf-file-uploader input[type="file"]', function (evt) { 714 let size = this.files[0].size / 1024 / 1024; 715 716 if (size > 10) { 717 alert('El tamany mà xim permès del PDF és de 10MB'); 718 $(this).val(''); 719 } 720 /* $('.acf-form-submit input[type="submit"]').attr("disabled", "disabled"); 721 }else{ 722 $('.acf-form-submit input[type="submit"]').removeAttr("disabled"); 723 } */ 724 }); 725} 726 727const sortable_projects = function () { 728 $(".sortable").sortable({ 729 update: function (event, ui) { 730 var $items = $(this).children('.project'); 731 var items = []; 732 $items.each(function () { 733 var newVal = $(this).index() + 1; 734 735 $(this).attr("data-orden", newVal); 736 737 var item = { 738 "id": $(this).attr('data-id'), 739 "orden": newVal 740 } 741 items.push(item); 742 }); 743 744 let data = { 745 "action": "order_projects", 746 "items": items 747 } 748 749 // LLAMADA AJAX CAMBIANDO EL ORDEN DE TODOS LOS ITEMS 750 let request = $.ajax({ 751 url: config.ajaxurl, 752 method: "POST", 753 data: data, 754 aync: false 755 }); 756 request.done(function (msg) { 757 console.log(msg); 758 }); 759 760 request.fail(function (jqXHR, textStatus) { 761 //alert("Request failed: " + textStatus); 762 }); 763 764 } 765 }); 766 $(".sortable").disableSelection(); 767} 768 769const change_subcat = function () { 770 $('#change-cat .select-items div').on('click', function () { 771 console.log($('#change-cat select').val()); 772 window.location.href = $('#change-cat select').val(); 773 }); 774} 775 776$(document).ready(function () { 777 stickyMenu(); 778 toggleMenu(); 779 boton_flotante(); 780 windowResize(); 781 openProjectPopup(); 782 register_form(); 783 edit_form(); 784 delete_project(); 785 delete_participacio(); 786 destacar_projecte(); 787 //disable_links(); 788 go_to_content(); 789 buscador_predictivo(); 790 791 user_items_height(); 792 custom_select(); 793 home_intro_height(); 794 795 qui_som_column_height(); 796 797 init_slick(); 798 menu_directori(); 799 800 load_professions(); 801 802 check_email_register(); 803 804 805 check_image_size(); 806 //link_new_window(); 807 808 sortable_projects(); 809 810 change_subcat(); 811 812 //submit_form_feste_socia(); 813 let select_sub = document.getElementsByClassName('select-subcategories'); 814 let select_sub_el = $('select#s'); 815 $('.select-categories .select-items div').on('click', function () { 816 let select = $(this).parent().parent().find('select'); 817 let $value_selected = $(this).html(); 818 select.find('option').each(function ($index, $element) { 819 if ($value_selected == $(this).html()) { 820 let $categoria_padre = $(this).val(); 821 822 // LLAMADA AJAX 823 let data = { 824 "action": "get_all_user_categories", 825 "cat_padre": $categoria_padre 826 } 827 828 829 let request = $.ajax({ 830 url: config.ajaxurl, 831 method: "POST", 832 data: data, 833 aync: false 834 }); 835 request.done(function (msg) { 836 let subcategories = JSON.parse(msg); 837 select_sub_el.find('option').remove(); 838 839 console.log(subcategories); 840 841 if (subcategories.length > 0) { 842 $('.select-subcategories').removeClass('disabled');
843 subcategories.forEach(function (element, index) { 844 console.log(element); 845 let $option = '<option value="' + element.term_id + '">' + element.term_name + '</option>'; 846 select_sub_el.append($option); 847 }); 848 } else { 849 $('.select-subcategories').addClass('disabled'); 850 select_sub_el.append('<option value="-">Sense subcategories</option>'); 851 } 852 853 854 // REMOVE SUBCATEGORES CUSTOM SELECT 855 $('.select-subcategories .select-selected').remove(); 856 $('.select-subcategories .select-items').remove(); 857 858 custom_select(document.getElementsByClassName('select-subcategories')); 859 }); 860 861 request.fail(function (jqXHR, textStatus) { 862 //alert("Request failed: " + textStatus); 863 }); 864 865 866 } 867 }); 868 }); 869 870 $('.profession .parent-list li').before().on('click', function () { 871 if (!$(this).find('.children-list').hasClass('active')) { 872 $(this).addClass('active'); 873 $(this).find('.children-list').addClass('active'); 874 } else { 875 $(this).removeClass('active'); 876 $(this).find('.children-list').removeClass('active'); 877 } 878 }); 879 880 let contador_professions = 0; 881 $('.profession .children-list input[type="checkbox"]').on('click', function () { 882 let parent = $(this).attr("data-parent"); 883 let string = '#term-' + parent; 884 let parent_element = $(string); 885 886 contador_professions = get_number_checked(); 887 888 if ($(this).is(':checked')) { 889 // SI LO ACBAN DE SELECCIONAR 890 if (contador_professions <= 3) { 891 // DEJAMOS QUE CHECKEE 892 contador_professions = get_number_checked(); 893 } else { 894 // MOSTRAMOS MENSAJE NUMERO MÃXIMO 895 alert("Ep! Has seleccionat més de tres categories. Segur que ets molt bona en molts camps, però necessitem que et decideixis per les tres més importants. Aixà les recerques poden ser més acurades. Deixa alguna cosa per la resta ;)"); 896 // DESELECCIONAMOS 897 $(this).prop("checked", false); 898 } 899 } else { 900 // SI LO HAN DESELECCIONADO 901 contador_professions = get_number_checked(); 902 } 903 }); 904 905 906 $("input.same_name:checkbox").click(function () { 907 var checkboxgroup = "input.same_name:checkbox[name='" + $(this).attr("name") + "']"; 908 $(checkboxgroup).attr("checked", false); 909 $(this).attr("checked", true); 910 }); 911 912 /* 913 $('.profession .children-list input[type="checkbox"]').each(function(index, value){ 914 if($(this).is(':checked') && contador_professions < 3){ 915 contador_professions++; 916 // ENABLE CHECKS 917 change_checkbox_status('enable'); 918 }else{ 919 alert("Ep! Has seleccionat més de tres categories. Segur que ets molt bona en molts camps, però necessitem que et decideixis per les tres més importants. Aixà les recerques poden ser més acurades. Deixa alguna cosa per la resta ;)"); 920 // DISABLE CHECKS 921 change_checkbox_status('disable'); 922 return false; 923 } 924 }); 925 */ 926 927 $('.wpcf7-form-control').on('focusout', function () { 928 if ($(this).val() != "") { 929 $('label[for="' + $(this).attr("name") + '"]').hide(); 930 } else { 931 $('label[for="' + $(this).attr("name") + '"]').show(); 932 } 933 }); 934 935 $('.wpcf7-form-control').on('click', function () { 936 $('label[for="' + $(this).attr("name") + '"]').hide(); 937 }); 938 939 $('.modal .close-popup img').on('click', function () { 940 $('.modal#modal-feste-socia').modal('hide'); 941 }); 942 943 $('.btn-cerrar-barra').on('click', function () { 944 window.sessionStorage.setItem('colabora-oculto', true); 945 $('section#barra-colabora').removeClass('active'); 946 }); 947 948 949 $('body').on('click', '.link-save-route', function () { 950 let route = window.location.href; 951 952 window.sessionStorage.setItem('route', route); 953 }); 954 955 if (window.sessionStorage.getItem('route')) { 956 $('.return-to-page').attr("href", window.sessionStorage.getItem('route')); 957 } 958 959}); 960 961const get_number_checked = function () {
962 let checked = 0; 963 $('.profession .children-list input[type="checkbox"]').each(function (index, value) { 964 if ($(this).is(':checked')) { 965 checked++; 966 } 967 }); 968 return checked; 969} 970 971const change_checkbox_status = function (status = 'enable') { 972 $('.profession .children-list input[type="checkbox"]').each(function (index, value) { 973 if (status == 'enable') { 974 $(this).attr("disabled", false); 975 } else { 976 if (!$(this).is(':checked')) { 977 $(this).attr("disabled", true); 978 } 979 } 980 }); 981}
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.