1(function ($, Drupal, window, document, once) { 2 Drupal.laResourceMap = Drupal.laResourceMap || {}; 3 4 Drupal.behaviors.homeSlide = { 5 attach: context => { 6 const element = once('field-slide-items', '.field--name-field-slide-items', context); 7 8 element.forEach(() => { 9 $('.field--name-field-slide-items').slick({ 10 autoplay: true, 11 dots: true, 12 prevArrow: '.prev-slide', 13 nextArrow: '.next-slide' 14 }); 15 }); 16 } 17 }; 18 19 Drupal.behaviors.featuredResources = { 20 attach: context => { 21 const element = once('paragraph-resources-field-resources', '.paragraph--type--resources .field--name-field-resources', context); 22 23 element.forEach(() => { 24 $('.paragraph--type--resources .field--name-field-resources').slick({ 25 autoplay: false, 26 dots: true, 27 infinite: false, 28 slidesToShow: 3, 29 slidesToScroll: 1, 30 prevArrow: '<i class="fas fa-chevron-left"></i>', 31 nextArrow: '<i class="fas fa-chevron-right"></i>', 32 responsive: [ 33 { 34 breakpoint: 1024, 35 settings: { 36 slidesToShow: 2, 37 slidesToScroll: 1, 38 } 39 }, 40 { 41 breakpoint: 600, 42 settings: { 43 slidesToShow: 2, 44 slidesToScroll: 1 45 } 46 }, 47 { 48 breakpoint: 480, 49 settings: { 50 slidesToShow: 1, 51 slidesToScroll: 1 52 } 53 } 54 ] 55 }); 56 }); 57 } 58 }; 59 60 Drupal.behaviors.toggleSearch = { 61 attach: context => { 62 $(document).ready(function () { 63 $('.search-block-form h5', context).click(function () { 64 $(this).hide(); 65 $('#search-block-form').show(); 66 $('.close-form').show(); 67 $('#search-block-form .form-search').focus(); 68 }); 69 70 $('.close-form', context).click(function () { 71 $('.search-block-form h5').show(); 72 $(this).hide(); 73 $('#search-block-form').hide(); 74 }); 75 }); 76 } 77 }; 78 79 Drupal.behaviors.tabs = { 80 attach: context => { 81 $(document).ready(function () { 82 $('#tabs-nav li:first-child').addClass('active'); 83 $('.tab-content').hide(); 84 $('.tab-content:first').show(); 85 86 $('#tabs-nav li', context).click(function () { 87 88 $('#tabs-nav li').removeClass('active'); 89 $(this).addClass('active'); 90 $('.tab-content').hide(); 91 92 var link_name = $(this).text(); 93 $('.tabs-toggler').text(link_name); 94 95 var activeTab = $(this).find('a').attr('href'); 96 $(activeTab).fadeIn(); 97 98 }); 99 var link_name = $('#tabs-nav li.active').text(); 100 $('.tabs-toggler').text(link_name); 101 var hash = window.location.hash; 102 $('a[href="' + hash + '"]').trigger("click"); 103 }); 104 } 105 }; 106 107 Drupal.behaviors.toggleProfile = { 108 attach: context => { 109 $(document).ready(function () { 110 $('.profile-item', context).click(function () { 111 var itemId = $(this).attr('data-profile'); 112 var itemInfo = $(this).parents('.paragraph').find('.profile-info__wrapper[data-profile="' + itemId + '"]'); 113 114 $('.profile-item').not($(this)).removeClass('open'); 115 $('.profile-info__wrapper:not([data-profile="' + itemId + '"])').removeClass('expanded'); 116 $(this).toggleClass('open'); 117 $(itemInfo).toggleClass('expanded'); 118 }); 119 }); 120 } 121 }; 122 123 Drupal.behaviors.toggleHighlight = { 124 attach: context => { 125 once('toggleHighlightLeader', '.higlight-items__leader', context).forEach(function (element) { 126 $(element).click(function () { 127 $(this).parents().find('.higlight-items__desc').css('display', 'block'); 128 }); 129 }); 130 131 once('toggleHighlightClose', '.higlight-items__desc i', context).forEach(function (element) { 132 $(element).click(function () { 133 $(this).closest('.higlight-items__desc').css('display', 'none'); 134 }); 135 }); 136 137 $('.higlight-items__box', context).click(function () { 138 var itemId = $(this).attr('data-team'); 139 var itemInfo = $('.higlight-items__featured[data-team="' + itemId + '"]'); 140 $('.higlight-items__desc').css('display', 'none'); 141 142 if (!$(this).hasClass('open')) { 143 $('.higlight-items__box').not($(this)).removeClass('open'); 144 $('.higlight-items__featured:not([data-team="' + itemId + '"])').removeClass('expanded'); 145 $(this).toggleClass('open'); 146 $(itemInfo).toggleClass('expanded'); 147 } 148 }); 149 } 150 }; 151 152 Drupal.behaviors.toggleDisaster = { 153 attach: context => { 154 $(document).ready(function () { 155 $('.hide-info', context).click(function () { 156 $('.disaster-info-wrapper').hide(); 157 }); 158 }); 159 } 160 }; 161 162 Drupal.behaviors.articlesMenu = { 163 attach: context => { 164 $('.block-system-menu-blockarticles-category .menu-item--expanded', context).each(function () { 165 $(this).parents('.block-system-menu-blockarticles-category').addClass('expanded'); 166 }); 167 } 168 }; 169 170 Drupal.behaviors.matchHeigh = { 171 attach: context => { 172 // Select and loop the container element of the elements you want to equalise 173 $('.field--name-field-grid-items').each(function () { 174 175 // Cache the highest 176 var highestBox = 0; 177 178 // Select and loop the elements you want to equalise 179 $('.field--name-field-title', this).each(function () { 180 181 // If this box is higher than the cached highest then store it 182 if ($(this).height() > highestBox) {
183 highestBox = $(this).height(); 184 } 185 }); 186 187 // Set the height of all those children to whichever was highest 188 $('.field--name-field-title', this).height(highestBox); 189 190 }); 191 } 192 }; 193 194 Drupal.behaviors.accordionItems = { 195 attach: context => { 196 $(document).ready(function () { 197 $('.accordion-title', context).click(function () { 198 $(this).parent().siblings().find('.accordion-content').slideUp('fast'); 199 $(this).parent().siblings().find('.accordion-title').removeClass('open'); 200 $(this).toggleClass('open'); 201 $(this).next().slideToggle('fast'); 202 }); 203 }); 204 } 205 }; 206 207 Drupal.behaviors.listingCheckboxSorter = { 208 attach: context => { 209 $(document).ready(function () { 210 var formItem = $('.js-form-item-switch-button'); 211 $('.option', '.js-form-item-switch-button').append('<span class="slider round"></span>'); 212 if ($('.sorter-option').length == 0) { 213 formItem.prepend('<span class="sorter-option">Best Fit</span>'); 214 formItem.append('<span class="sorter-option">Closest</span>'); 215 } 216 }); 217 } 218 }; 219 220 Drupal.behaviors.listingTotalResults = { 221 attach: context => { 222 $(document).ready(function () { 223 $('.result-value', '.resources-header').text($('.resources-count').text() + ' results'); 224 }); 225 } 226 }; 227 228 Drupal.behaviors.returnButton = { 229 attach: context => { 230 $(document).ready(function () { 231 // On each load of page update storage if on listing page. 232 var body = $('body'); 233 if (body.hasClass('path-resources') || body.hasClass('path-events')) { 234 localStorage.setItem("queryserach", window.location.href); 235 } 236 $('.button-back').on('click', function () { 237 if (localStorage.getItem("queryserach")) { 238 window.location.href = localStorage.getItem("queryserach"); 239 } else { 240 window.location.href = '/resources/search'; 241 } 242 }) 243 }); 244 } 245 }; 246 247 Drupal.behaviors.warningDismiss = { 248 attach: context => { 249 $(document).ready(function () { 250 var warningState = localStorage.getItem('warning_dismiss'); 251 if (warningState === 'hide') { 252 $('.website-warning').hide(); 253 } 254 255 $('.dismiss-warning', context).on('click', function () { 256 localStorage.setItem('warning_dismiss', 'hide'); 257 258 $('.website-warning').hide(); 259 }) 260 }); 261 } 262 }; 263 264 Drupal.behaviors.whenFilter = { 265 attach: context => { 266 $(document).ready(function () { 267 $('.la-select-hours').prop('disabled', 'disabled'); 268 $('.form-wrapper-when .js-form-type-radio').on('change', function () { 269 if ($('#edit-when-check-open-now').is(':checked')) { 270 $('.la-select-hours').prop('disabled', 'disabled'); 271 } else { 272 $('.la-select-hours').prop('disabled', false); 273 } 274 }); 275 }); 276 } 277 }; 278 279 Drupal.behaviors.locationFilter = { 280 attach: context => { 281 $(document).ready(function () { 282 var locationInput = $('.la-location-text'); 283 var locationSelect = $('.la-region-select'); 284 285 locationInput.on('keyup', function () { 286 if ($(this).val()) { 287 locationSelect.prop('disabled', 'disabled'); 288 } else { 289 locationSelect.prop('disabled', false); 290 } 291 }); 292 293 locationSelect.on('change', function () { 294 if ($(this).val() === '') { 295 locationInput.prop('disabled', false); 296 $('#edit-miles-from .form-radio').prop('disabled', false); 297 $('#edit-miles-from label').css({ 298 "cursor": "pointer", 299 "background-color": "white" 300 }); 301 } else { 302 locationInput.prop('disabled', 'disabled'); 303 $('#edit-miles-from .form-radio').prop('disabled', 'disabled'); 304 $('#edit-miles-from label').css({
305 "cursor": "default", 306 "background-color": "#d4d4d4" 307 }); 308 } 309 }); 310 }); 311 } 312 }; 313 314 Drupal.behaviors.clearFilterForm = { 315 attach: context => { 316 $('.js-form-item-when-date-range-end').hide(); 317 $('#edit-when-date-range').on('change', function () { 318 $('.js-form-item-when-date-range-end').show(); 319 }); 320 // $('#edit-filter-reset').on('click', function () { 321 // 322 // $('#la-search-resources-form').find('input').each(function(){ 323 // if ((this.type === 'radio') || (this.type === 'checkbox')) 324 // { 325 // this.checked = false; 326 // } 327 // else if (this.type === 'text') 328 // { 329 // this.value = ''; 330 // } 331 // }); 332 // 333 // $('#la-search-resources-form').find('select').each(function() { 334 // this.selectedIndex = 0; 335 // }); 336 // }); 337 } 338 }; 339 340 Drupal.behaviors.keywordSubmitForm = { 341 attach: context => { 342 $('#edit-keyword').keydown(function (e) { 343 if (e.keyCode == 13) { 344 e.preventDefault(); 345 return false; 346 } 347 }); 348 $("#edit-agency-keyword").keyup(function (event) { 349 if (event.keyCode === 13) { 350 event.preventDefault(); 351 event.stopPropagation(); 352 $('#edit-keyword').autocomplete('close'); 353 if ($('#la-search-agency-form').length) { 354 var value = $("#edit-agency-keyword").val(); 355 window.location.href = "/agency/search?agency_keyword=" + value; 356 } 357 } 358 }); 359 360 $("#edit-keyword").keyup(function (event) { 361 if (event.keyCode === 13) { 362 event.preventDefault(); 363 event.stopPropagation(); 364 $('#edit-keyword').autocomplete('close'); 365 if ($('#la-search-resources-form').length) { 366 var value = $("#edit-keyword").val(); 367 if ($('#edit-keyword-checkboxes-events').is(':checked')) { 368 window.location.href = "/events/search?event_keyword=" + value; 369 } 370 } 371 372 if (value.indexOf(' (') === -1 && value.indexOf(')') === -1) { 373 $('.page-title').find('span').html(value); 374 $('.la-user-keyword-hidden').val(value) 375 } else { 376 377 } 378 379 $(".la-resources-submit-button").mousedown(); 380 $('.la-fieldset-filters').hide(); 381 } 382 }); 383 384 // Events 385 $("#edit-event-keyword").keyup(function (event) { 386 if (event.keyCode === 13) { 387 $('#edit-event-keyword').autocomplete('close'); 388 var event_value = $("#edit-event-keyword").val(); 389 if ($('#la-search-events-form').length) { 390 $('.page-title').find('span').html(event_value); 391 if ($('#edit-keyword-checkboxes-resources').is(':checked')) { 392 var encoded_value = encodeURI(event_value); 393 window.location.href = "/resources/search?keyword=" + encoded_value + "&keyword_hidden=" + encoded_value; 394 } 395 } 396 397 if (event_value.indexOf(' (') === -1 && event_value.indexOf(')') === -1) { 398 $('.page-title').find('span').html(event_value); 399 } else { 400 401 } 402 } 403 }); 404 405 // Global search block. 406 $(".la-search-global-resources-form").on('submit', function (e) { 407 e.preventDefault(); 408 var global_value = $("#edit-global-keyword").val(); 409 if ($('#edit-keyword-checkboxes-resources').is(':checked')) { 410 window.location.href = "/resources/search?keyword=" + global_value + "&keyword_hidden=" + global_value; 411 } 412 if ($('#edit-keyword-checkboxes-events').is(':checked')) { 413 window.location.href = "/events/search?event_keyword=" + global_value + "&keyword_hidden=" + global_value; 414 } 415 }); 416 $("#edit-global-keyword").keyup(function (event) { 417 if (event.keyCode === 13) { 418 $('#edit-global-keyword').autocomplete('close'); 419 } 420 }); 421 422 // Load map on submit of the form 423 $('.la-resources-submit-button').on('mousedown', function () { 424 setTimeout(function () { 425 Drupal.laResourceMap.loadMap('submit-form'); 426 }, 1000); 427 }); 428 429 // Load map on change of page limit selector.
430 $('.la-page-limit, #edit-switch-button').on('change', function () { 431 var new_url = removeURLParameter(location.href, 'page'); 432 window.history.pushState({}, document.title, new_url); 433 setTimeout(function () { 434 Drupal.laResourceMap.loadMap('switch-button'); 435 }, 3000); 436 }); 437 438 // write results on Agency page. 439 var number = $('.total-results-holder').text(); 440 $('.total-results').text(number + ' results'); 441 } 442 }; 443 444 // function submitAgencyFrom() { 445 // $(".la-agency-submit-button-pager").trigger('mousedown'); 446 // if ($("#agency-listing").length) { 447 // $(window).scrollTop($("#agency-listing").offset().top); 448 // } 449 // } 450 451 452 function submitResourcesFrom() { 453 $(".la-resources-submit-button-pager").trigger('mousedown'); 454 if ($('.resources-listing.map-shown').length) { 455 $('#resources-listing').animate({ 456 scrollTop: $("#resources-listing-wrapper").offset().top 457 }, 500); 458 } else { 459 if ($('#resources-listing-wrapper').length) { 460 $(window).scrollTop($('#resources-listing-wrapper').offset().top); 461 } 462 } 463 } 464 465 Drupal.behaviors.whenFilter = { 466 attach: context => { 467 $(document).ready(function () { 468 once('webCategoryTypeToggle', '.webcategory-type a', context).forEach(function (element) { 469 $(element).click(function () { 470 $(this).parent().find('.services-by-type').toggle(); 471 $(this).toggleClass('active'); 472 }); 473 }); 474 }); 475 } 476 }; 477 478 Drupal.behaviors.basicExpander = { 479 attach: function (context, settings) { 480 $(document).ready(function () { 481 once('basicExpander', '.field--name-field-expander-label', context).forEach(function (element) { 482 $(element).click(function () { 483 $(this).parent().find('.field--name-field-expander-summary').toggle(); 484 $(this).toggleClass('reverted'); 485 }); 486 }); 487 }); 488 } 489 }; 490 491 Drupal.behaviors.hamburger = { 492 attach: function (context, settings) { 493 $('#hamburger-menu').click(function () { 494 $(this).toggleClass('open'); 495 $('#block-la211-main-menu').toggleClass('expanded'); 496 }); 497 } 498 }; 499 500 Drupal.behaviors.hamburgerArticles = { 501 attach: function (context, settings) { 502 $('#hamburger-menu-articles').click(function () { 503 $(this).toggleClass('open'); 504 $('.block-system-menu-blockarticles-category .menu').not('.menu-lvl-2').toggleClass('expanded'); 505 }); 506 } 507 }; 508 509 // Drupal.behaviors.toggleGrid = { 510 // attach: function (context, settings) { 511 // $('.higlight-items__leader', context).once().click(function () { 512 // $(this).parents().find('.higlight-items__desc').css('display', 513 // 'block'); $(this).addClass('clicked') }); $('.higlight-items__desc i', 514 // context).once().click(function () { 515 // $(this).closest('.higlight-items__desc').css('display', 'none'); 516 // $(this).addClass('clicked') }); } }; 517 518 Drupal.behaviors.showMore = { 519 attach: context => { 520 once('showMoreExpand', '.paragraph--type--expandable-list .show-more', context).forEach(function (element) { 521 $(element).click(function () { 522 $(this).parent().toggleClass('expanded'); 523 }); 524 }); 525 } 526 }; 527 528 Drupal.behaviors.expandTags = { 529 attach: context => { 530 once('expandTags', '.view-video-tags .fieldset-legend', context).forEach(function (element) { 531 $(element).click(function () { 532 $('.view-video-tags .fieldset-wrapper', context).toggleClass('expanded'); 533 }); 534 }); 535 } 536 }; 537 538 Drupal.behaviors.expandSubmenu = { 539 attach: context => { 540 once('expandSubmenu', '.topic-submenu span', context).forEach(function (element) { 541 $(element).click(function () { 542 $('.topic-submenu', context).toggleClass('expanded'); 543 }); 544 }); 545 } 546 }; 547 548 // Drupal.behaviors.AjaxPager = { 549 // attach: function (context, settings) { 550 // $('.resources-listing-wrapper .pager__item a').once().click(function (e) { 551 // e.preventDefault(); 552 // var link = $(this).attr('href');
553 // var urlParams = new URLSearchParams(link); 554 // $(".la-user-current-page").val(urlParams.get('page')); 555 // submitResourcesFrom(); 556 // setTimeout(function () { 557 // Drupal.laResourceMap.loadMap('pager'); 558 // }, 1000); 559 // }); 560 // $('.agency-listing-wrapper .pager__item a').once().click(function (e) { 561 // e.preventDefault(); 562 // var link = $(this).attr('href'); 563 // var urlParams = new URLSearchParams(link); 564 // $(".la-user-current-page").val(urlParams.get('page')); 565 // submitAgencyFrom(); 566 // 567 // }); 568 // } 569 // }; 570 571 /** 572 * check if value is empty. 573 * 574 * @param mixedVar 575 * @returns {boolean} 576 */ 577 function empty(mixedVar) { 578 // discuss at: https://locutus.io/php/empty/ 579 // original by: Philippe Baumann 580 // input by: Onno Marsman (https://twitter.com/onnomarsman) 581 // input by: LH 582 // input by: Stoyan Kyosev (https://www.svest.org/) 583 // bugfixed by: Kevin van Zonneveld (https://kvz.io) 584 // improved by: Onno Marsman (https://twitter.com/onnomarsman) 585 // improved by: Francesco 586 // improved by: Marc Jansen 587 // improved by: RafaÅ Kukawski (https://blog.kukawski.pl) 588 // example 1: empty(null) 589 // returns 1: true 590 // example 2: empty(undefined) 591 // returns 2: true 592 // example 3: empty([]) 593 // returns 3: true 594 // example 4: empty({}) 595 // returns 4: true 596 // example 5: empty({'aFunc' : function () { alert('humpty'); } }) 597 // returns 5: false 598 599 var undef; 600 var key; 601 var i; 602 var len; 603 var emptyValues = [undef, null, false, 0, '', '0']; 604 605 for (i = 0, len = emptyValues.length; i < len; i++) { 606 if (mixedVar === emptyValues[i]) { 607 return true 608 } 609 } 610 if (typeof mixedVar === 'object') { 611 for (key in mixedVar) { 612 if (mixedVar.hasOwnProperty(key)) { 613 return false 614 } 615 } 616 return true 617 } 618 return false 619 } 620 621 622 function removeURLParameter(url, parameter) { 623 //prefer to use l.search if you have a location/link object 624 var urlparts = url.split('?'); 625 if (urlparts.length >= 2) { 626 627 var prefix = encodeURIComponent(parameter) + '='; 628 var pars = urlparts[1].split(/[&;]/g); 629 630 //reverse iteration as may be destructive 631 for (var i = pars.length; i-- > 0;) { 632 //idiom for string.startsWith 633 if (pars[i].lastIndexOf(prefix, 0) !== -1) { 634 pars.splice(i, 1); 635 } 636 } 637 638 return urlparts[0] + (pars.length > 0 ? '?' + pars.join('&') : ''); 639 } 640 return url; 641 } 642 643 644 Drupal.behaviors.catInfoDesc = { 645 attach: context => { 646 once('211CatInfo', '.category-item', context).forEach(function (element) { 647 var wrapper = $(element); 648 var data = $('.category-item__info-content', wrapper); 649 var trigger = $('.category-item__trigger', wrapper); 650 651 // Show/Hide description 652 trigger.on('click keydown', function (event) { 653 if ((event.type === 'click') || (event.type === 'keydown' && event.which === 32)) { 654 event.preventDefault(); 655 data.toggleClass('expanded'); 656 } 657 }); 658 }); 659 } 660 }; 661 662 Drupal.behaviors.smothScroll = { 663 attach: context => { 664 once('211SubMenu', '.paragraph--type--guided-topic-submenu', context).forEach(function () { 665 $(document).on('click', 'a[href^="#"]', function (event) { 666 event.preventDefault(); 667 668 $('html, body').animate({ 669 scrollTop: $($.attr(this, 'href')).offset().top 670 }, 500); 671 }); 672 }); 673 } 674 }; 675 676 Drupal.behaviors.rotateLanguage = { 677 attach: context => { 678 once('rotate', '.language-label', context).forEach(function (element) { 679 var lis = $(element).find('li'), 680 currentHighlight = 0; 681 N = 3; //interval in seconds 682 setInterval(function () { 683 currentHighlight = (currentHighlight + 1) % lis.length; 684 lis.removeClass('active').eq(currentHighlight).addClass('active'); 685 }, N * 1000); 686 }); 687 } 688 }; 689 690 Drupal.behaviors.antihateSpinner = { 691 attach: context => { 692 $(document).ready(function(){ 693 694 var loaderDiv = "<div id=\"pageloader\">\n" + 695 " <img src=\"/themes/custom/la211/dist/icons/blueloader.gif\" alt=\"processing...\" />\n" + 696 "</div>" 697
698 $('#webform-submission-anti-hate-add-form').append(loaderDiv); 699 700 $("#webform-submission-anti-hate-add-form").on("submit", function(){ 701 $("#pageloader").fadeIn(); 702 }); 703 704 }); 705 } 706 }; 707 708 }(jQuery, Drupal, this, this.document, once) 709);
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.