1(function ($, Drupal, once) { 2 function isValidEmailAddress(emailAddress) { 3 // var pattern = new RegExp(/^(("[\w-+\s]+")|([\w-+]+(?:\.[\w-+]+)*)|("[\w-+\s]+")([\w-+]+(?:\.[\w-+]+)*))(@((?:[\w-+]+\.)*\w[\w-+]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][\d]\.|1[\d]{2}\.|[\d]{1,2}\.))((25[0-5]|2[0-4][\d]|1[\d]{2}|[\d]{1,2})\.){2}(25[0-5]|2[0-4][\d]|1[\d]{2}|[\d]{1,2})\]?$)/i); 4 var pattern = new RegExp("^[_A-Za-z0-9-]+(\\.[_A-Za-z0-9-]+)*@[_A-Za-z0-9-]+(\\.[_A-Za-z0-9-]+)*(\\.[A-Za-z]{2,})$"); 5 return pattern.test(emailAddress); 6 }; 7 8 /* 9 * Skip to main content â explicitly move focus to #main-content on activation. 10 * tabindex="-1" on <main> makes it programmatically focusable but some browsers 11 * don't reliably move focus via hash links alone. 12 */ 13 Drupal.behaviors.skipLink = { 14 attach: function (context, settings) { 15 once('skip-link', '.skip-link', context).forEach(function (link) { 16 link.addEventListener('click', function (e) { 17 var target = document.getElementById('main-content'); 18 if (target) { 19 e.preventDefault(); 20 target.focus(); 21 } 22 }); 23 }); 24 } 25 }; 26 27 /* 28 * Check all <a> link to login EB 29 */ 30 Drupal.behaviors.checkForEventBankRedirect = { 31 attach: function (context, settings) { 32 if($('a').length) { 33 $(once('glueup-links', 'a[href*="glueup."]:not([href*="-website.glueup."])', context)).click(function (e) { 34 var link_href = encodeURIComponent($(this).attr("href")); 35 var url = '/redirect-eventbank'; 36 window.open(url + '?redirect=' + link_href, '_blank'); 37 return false; 38 }); 39 } 40 } 41 }; 42 43 /* 44 * News page 45 */ 46 Drupal.behaviors.membershipDirectory = { 47 attach: function (context, settings) { 48 if($('.page-node-type-news').length) { 49 $('.field--name-field-source a').attr("target", "_blank"); 50 } 51 } 52 }; 53 54 /* 55 * Hide Ads when empty 56 */ 57 Drupal.behaviors.adsManage = { 58 attach: function (context, settings) { 59 if($('[class*="block-views-blockblock-ads"]').length) { 60 $('[class*="block-views-blockblock-ads"]').each(function(i,ele) { 61 var block_html = $(this).find('.view-block-ads-horizontal').html(); 62 if(typeof block_html != 'undefined'){ 63 if(block_html.indexOf('img') == -1){ 64 $(this).css('display', 'none'); 65 } else { 66 var field_html = $(this).find('.views-field-nothing').find('.field-content').html(); 67 if(field_html.indexOf('img') == -1){ 68 $(this).css('display', 'none'); 69 } 70 } 71 } 72 }); 73 } 74 } 75 }; 76 77 /* 78 * Document Listing 79 */ 80 Drupal.behaviors.documentListing = { 81 attach: function (context, settings) { 82 if($('.view-document').length) { 83 var curHeight, curPadTop, curPadBot, totalHeight, animatedHeight; 84 $('.view-document .views-row').on({ 85 mouseenter: function () { 86 $(this).find('.document-overlay').css('height', '100%'); 87 $(this).find('.views-field-field-document-file').show(); 88 $(this).find('.views-field-field-document-file-1').show(); 89 90 /* old system not working because of the calculation of the auto height when moving the mouse too fast */ 91 // curHeight = $(this).find('.document-overlay').height(); 92 // curPadTop = parseInt($(this).find('.document-overlay').css('padding-top')); 93 // curPadBot = parseInt($(this).find('.document-overlay').css('padding-bottom')); 94 // totalHeight = curHeight + curPadTop + curPadBot; 95 // 96 // $(this).find('.document-overlay').animate( 97 // { 'height': '100%' }, 98 // ) 99 // .promise() 100 // .done(function() { 101 // $(this).find('.views-field-field-document-file').fadeIn('fast'); 102 // $(this).find('.views-field-field-document-file-1').fadeIn('fast'); 103 // } ); 104 }, 105 mouseleave: function() { 106 $(this).find('.document-overlay').css('height', 'auto'); 107 $(this).find('.views-field-field-document-file').hide(); 108 $(this).find('.views-field-field-document-file-1').hide(); 109 110 /* old system not working because of the calculation of the auto height when moving the mouse too fast */ 111 // $(this).find('.views-field-field-document-file').fadeOut('fast'); 112 // $(this).find('.views-field-field-document-file-1').fadeOut('fast'); 113 // $(this).find('.document-overlay').animate( 114 // { 'height': totalHeight }, 115 // ) 116 // .promise() 117 // .done(function() { 118 // $(this).find('.views-field-field-document-file').hide(); 119 // $(this).find('.views-field-field-document-file-1').hide(); 120 // } ); 121 } 122 }); 123 } 124 } 125 }; 126 127 /* 128 * Modal Popup 129 */ 130 Drupal.behaviors.popupModal = { 131 attach: function (context, settings) { 132 if($('.popup-modal').length){ 133 134 //get modal function 135 function popupModal(url, email){ 136 var get_modal = '.modal-ajax'; 137 138 //check for custom modal from url 139 var custom_class_position = url.indexOf('#'); 140 if (custom_class_position >= 0) { 141 get_modal = '.' + url.substr(custom_class_position + 1) 142 } 143 144 $.ajax({ 145 type: 'POST', 146 url: url, 147 data: { email: email } 148 }).done(function(data, textStatus, jqXHR) { 149 var content_html = $(data).find(get_modal).html(); 150 151 //get region class to keep style when possible 152 var region_classes = $(data).find('.region-content').attr('class'); 153 var region_class_array = region_classes.split(' '); 154 var region_class = ''; 155 156 157 if (!String.prototype.startsWith) { 158 String.prototype.startsWith = function(searchString, position){ 159 return this.substr(position || 0, searchString.length) === searchString; 160 }; 161 } 162 163 $.each( region_class_array, function( i, l ){ 164 if(l.startsWith("class-region-")){ 165 region_class = l; 166 } 167 }); 168 169 $('.path-membership-directory').css('height', '100%'); 170 $('.path-membership-directory').css('overflow', 'hidden'); 171 172 $('.ajax-overlay').before('<div class="ajax-overlay-end"><div class="ajax-content '+region_class+'"><span class="ajax-close f-icon close-icon" role="button" tabindex="0" aria-label="Close"></span>'+content_html+'</div><div class="overlay-all-white"></div></div>'); 173 174 // Re-run Drupal behaviors (including spamspan) on the newly injected modal content. 175 Drupal.attachBehaviors($('.ajax-content')[0]); 176 177 // Move keyboard focus into the modal after it is painted. 178 setTimeout(function() { 179 var focusableSelectors = 'a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not
179([tabindex="-1"])'; 180 var $first = $('.ajax-content').find(focusableSelectors).first(); 181 if ($first.length) { 182 $first.focus(); 183 } else { 184 $('.ajax-content').attr('tabindex', '-1').focus(); 185 } 186 }, 50); 187 }).fail(function(jqXHR, textStatus, errorThrown) { 188 alert(jqXHR.responseText); 189 }); 190 } 191 192 //popup modal click button 193 $(once('body-class', '.popup-modal', context)).click(function (e) { 194 e.preventDefault(); 195 //get button url 196 var url = $(this).attr('href'); 197 198 var input_error = 0; 199 var email = ''; 200 201 //check if custom form & get custom data 202 if($(this).hasClass('newsletters-signup')){ 203 //get form container 204 var form_container = $(this).parents('.form-container'); 205 206 // get email 207 email = form_container.find('.email-input').val(); 208 209 //check email value if needed 210 if(email !== '' && isValidEmailAddress(email)){ 211 form_container.find('.email-value').removeClass('error'); 212 form_container.find('.email-not-valid').hide(); 213 214 input_error = 0; 215 } else { 216 //show error message 217 form_container.find('.newsletters-email').focus(); 218 form_container.find('.newsletters-email').addClass('error'); 219 form_container.find('.email-not-valid').show(); 220 221 input_error = 1; 222 } 223 } 224 225 //if no error call popup function 226 if(input_error == 0){ 227 $('body').data('last-popup-trigger', this); // Store trigger for focus return on close. 228 $('.ajax-content').remove(); 229 popupModal(url, email); 230 } 231 }); 232 233 // Allow pressing Enter in the email field to trigger the signup button. 234 $(once('newsletter-enter', '.newsletters-email', context)).on('keydown', function(e) { 235 if (e.key === 'Enter') { 236 e.preventDefault(); 237 $(this).closest('.form-container').find('.newsletters-signup').trigger('click'); 238 } 239 }); 240 241 //open newsletter modal on homepage load 242 if($('.open-on-load').length){ 243 var cookie_value = $.cookie('open_on_load') 244 var pathname = window.location.pathname; 245 if(cookie_value != 'true' && pathname == '/'){ 246 $.cookie('open_on_load', 'true'); 247 $('a.open-on-load').click(); 248 } 249 } 250 251 $(once('newsletter-link-submit', 'body')).on('click', '.newsletters-subscription-form .newsletter-link-submit', function(e){ 252 e.preventDefault(); 253 254 var renderValue = null; 255 256 $('script[src*="recaptcha/api.js"]').each(function () { 257 var src = $(this).attr('src'); 258 var urlParams = new URLSearchParams(src.split('?')[1]); 259 renderValue = urlParams.get('render'); 260 }); 261 262 grecaptcha.ready(function() { 263 grecaptcha.execute(renderValue, {action: 'submit'}).then(function(token) { 264 // Send the token to the server using AJAX 265 266 var url_verify = window.location.origin + '/verify-recaptcha'; 267 268 $.ajax({ 269 url: url_verify, 270 type: 'POST', 271 data: { 272 token: token 273 }, 274 // success: function(response) { 275 }).done(function(data, textStatus, jqXHR) { 276 if (data.results.success && data.results.score >= 0.5) { 277 var url = window.location.origin + '/newsletter-thank-you'; 278 279 var form_container = $('.newsletters-subscription-form .eventbank-newsletter-form'); 280 281 var email_error = 0; 282 var lastname_error = 0; 283 var firstname_error = 0; 284 285 // get values 286 var form_email = form_container.find("input[name='email']"); 287 var email = form_email.val(); 288 //check email value 289 if(email !== '' && isValidEmailAddress(email)){ 290 form_email.removeClass('error'); 291 form_container.find('.email-not-valid').css('display', 'none'); 292 293 email_error = 0; 294 } else { 295 //show error message 296 form_email.addClass('error'); 297 form_container.find('.email-not-valid').css('display', 'block'); 298 299 email_error = 1; 300 } 301 302 var form_lastname = form_container.find('#edit-lastname'); 303 var last_name = form_lastname.val(); 304 //check last name value 305 if(last_name !== ''){ 306 form_lastname.removeClass('error'); 307 form_container.find('.lastname-not-valid').css('display', 'none'); 308 309 lastname_error = 0; 310 } else { 311 //show error message 312 form_lastname.addClass('error'); 313 form_container.find('.lastname-not-valid').css('display', 'block'); 314 315 lastname_error = 1; 316 } 317 318 var form_firstname = form_container.find('#edit-firstname'); 319 var first_name = form_firstname.val(); 320 //check first name value 321 if(first_name !== ''){ 322 form_firstname.removeClass('error'); 323 form_container.find('.firstname-not-valid').css('display', 'none'); 324 325 firstname_error = 0; 326 } else { 327 //show error message 328 form_firstname.addClass('error'); 329 form_container.find('.firstname-not-valid').css('display', 'block'); 330 331 firstname_error = 1; 332 } 333 334 var subscriptions = {}; 335 $('.newsletters-subscription-form .form-checkbox').each(function(){ 336 if($(this).is(':checked')){ 337 subscriptions[$(this).val()] = $(this).val(); 338 } else { 339 subscriptions[$(this).val()] = 0; 340 } 341 }); 342 343 if(email_error == 0 && lastname_error == 0 && firstname_error == 0){ 344 $.ajax({ 345 type: 'POST', 346 url: url, 347 data: { last_name: last_name, first_name:first_name, email: email, subscriptions: subscriptions } 348 }).done(function(data, textStatus, jqXHR) { 349 $('.ajax-content').remove(); 350 var content_html = $(data).find('.modal
350-ajax').html(); 351 352 $('.ajax-overlay').before('<div class="ajax-overlay-end"><div class="ajax-content"><span class="ajax-close f-icon close-icon"></span>'+content_html+'</div><div class="overlay-all-white"></div></div>'); 353 }).fail(function(jqXHR, textStatus, errorThrown) { 354 alert(jqXHR.responseText); 355 }); 356 } 357 } else { 358 $('.ajax-overlay').before('<div class="ajax-overlay-end"><div class="ajax-content"><span class="ajax-close f-icon close-icon"></span><p>Recaptcha detect you as a bot - try again or contact us.</p></div><div class="overlay-all-white"></div></div>'); 359 } 360 }).fail(function(jqXHR, textStatus, errorThrown) { 361 $('.ajax-overlay').before('<div class="ajax-overlay-end"><div class="ajax-content"><span class="ajax-close f-icon close-icon"></span><p><p>Recaptcha detect you as a bot. - try again or contact us.</p></div><div class="overlay-all-white"></div></div>'); 362 }); 363 }); 364 }); 365 }); 366 } 367 } 368 }; 369 370 /* 371 * Rework select on view 372 */ 373 Drupal.behaviors.listingCommon = { 374 attach: function (context, settings) { 375 if($('.view').length){ 376 377 //for each form select, user select2MultiCheckboxes 378 $('.view .view-filters .form-select').each(function(index, value){ 379 var $placehoder = ($(this).attr('data-placeholder') != null) ? $(this).attr('data-placeholder') : 'Select'; 380 $(this).select2({ 381 placeholder: "Select a topic", 382 templateSelection: function (data) { 383 return $placehoder; 384 } 385 }); 386 }); 387 } 388 } 389 }; 390 391 /* 392 * Event Listing filter 393 */ 394 Drupal.behaviors.eventListingUpdate = { 395 attach: function (context, settings) { 396 if($('.context-events, .block-event-block').length){ 397 var url = window.location.href; 398 399 $('#edit-date-range').datetimepicker({ 400 viewMode: 'years', 401 format: 'MMM YYYY', 402 showClear: true, 403 icons: { 404 previous: 'glyphicon glyphicon-arrow date-arrow-left', 405 next: 'glyphicon glyphicon-arrow date-arrow-right', 406 clear: 'glyphicon glyphicon-close date-clear', 407 } 408 }); 409 410 function formatCustom (state) { 411 if (!state.id) { return state.text; } 412 var $state = $( 413 '<span><span class="select2-icon-span f-icon ' + state.element.value.toLowerCase() + '-icon"></span> ' + state.text + '</span>' 414 ); 415 return $state; 416 }; 417 418 function formatNonCustom (state) { 419 if (!state.id) { return state.text; } 420 var $state = $( 421 '<span><span class="select2-icon-span f-icon checkbox-checked-icon"></span>' + state.text + '</span>' 422 ); 423 return $state; 424 }; 425 426 //add select2 to filter 427 $('.non-custom-filter-form .form-select').select2({ 428 minimumResultsForSearch: Infinity, 429 templateResult: formatNonCustom, 430 }); 431 $('.custom-filter-form .form-select').select2({ 432 minimumResultsForSearch: Infinity, 433 templateSelection: formatCustom, 434 templateResult: formatCustom, 435 }); 436 437 var option_type = 0; 438 439 // Use once() to prevent duplicate event handlers on re-attach. 440 $(once('event-listing-handlers', '.events-listing', context)).each(function() { 441 var $listing = $(this); 442 443 $listing.on('click', '#resetDatePicker', function(e) { 444 $('#edit-date-range').data('DateTimePicker').clear(); 445 }); 446 447 $listing.on('dp.update', '#edit-date-range', function (e) { 448 //only when month M is selected 449 if(e.change == 'M'){ 450 option_type = 1; 451 $('.event-filter-form .events-search-ajax').trigger( 'click' ); 452 } 453 }); 454 455 $listing.on('change', '.events-filter-ajax:not
455(.events-filter-ajax-date)', function(e){ 456 $('#edit-search-name').val('').trigger('change'); 457 option_type = 2; 458 $('.event-filter-form .events-search-ajax').trigger( 'click' ); 459 }); 460 461 //force stop propagation 462 $listing.on('input', '#edit-search-name', function(e){ 463 option_type = 3; 464 }); 465 466 //search only work if value is not empty 467 $listing.on('click', '.form-item-search-name', function(){ 468 if($('#edit-search-name').val() != ''){ 469 $('.event-filter-form .events-search-ajax').trigger( 'click' ); 470 } 471 }); 472 473 //trigger on search or when change the other filters above 474 $listing.on('click', '.events-search-ajax', function(event){ 475 event.preventDefault(); 476 eventAjax(url, 'filter'); 477 return false; 478 }); 479 480 //trigger on reset 481 $listing.on('click keydown', '.form-reset', function(event){ 482 if (event.type === 'keydown' && event.key !== 'Enter' && event.key !== ' ') { return; } 483 event.preventDefault(); 484 eventAjax(url, 'filter', 'reset'); 485 return false; 486 }); 487 488 //trigger on show more 489 $listing.on('click', '.show-more-button', function(event){ 490 eventAjax(url, 'show-more'); 491 return false; 492 }); 493 }); 494 495 496 function eventAjax(url, type, reset){ 497 if(reset == 'reset'){ 498 var timeline = 3; 499 var range_date = 0; 500 var search_keyword = ''; 501 var registration = ''; 502 var tags = ''; 503 var location = ''; 504 var location_val = ''; 505 } else { 506 //default value to not fire filter on timeline or date range 507 var timeline = 3; 508 var range_date = 0; 509 var search_keyword = ''; 510 511 timeline = $('.event-filter-form #edit-timeline').val(); 512 513 if(option_type == 2){ 514 timeline = $('.event-filter-form #edit-timeline').val(); 515 } else if(option_type == 1){ 516 var timeline = 1; 517 range_date = $('#edit-date-range').val(); 518 } else if(option_type == 3) { 519 search_keyword = $('#edit-search-name').val(); 520 } 521 522 var registration = $('.event-filter-form #edit-registration').val(); 523 var tags = $('.event-filter-form #edit-tags').val(); 524 var location = $('.event-filter-form #edit-location option:selected').text(); 525 var location_val = $('.event-filter-form #edit-location option:selected').val(); 526 527 } 528 529 if(type == 'show-more'){ 530 var more_value = $('.show-more-button').attr('value'); 531 var ajax_type = 2; 532 } else { 533 var ajax_type = 1; 534 var more_value = ''; 535 } 536 537 $.ajax({ 538 type: 'POST', 539 url: url, 540 data: { more_value: more_value, timeline: timeline, registration: registration, tags: tags, location: location, location_val: location_val, range_date: range_date, search_keyword: search_keyword, ajax_call: ajax_type } 541 }).done(function(data, textStatus, jqXHR) { 542 var content_html = $(data).find('.events-listing').html(); 543 if(type == 'filter'){ 544 $('.events-listing-ajax').replaceWith(content_html); 545 546 //add select2 to filter
547 $('.non-custom-filter-form .form-select').select2({ 548 minimumResultsForSearch: Infinity, 549 templateResult: formatNonCustom, 550 }); 551 $('.custom-filter-form .form-select').select2({ 552 minimumResultsForSearch: Infinity, 553 templateSelection: formatCustom, 554 templateResult: formatCustom, 555 }); 556 557 $('#edit-date-range').datetimepicker({ 558 viewMode: 'years', 559 format: 'MMM YYYY', 560 showClear: true, 561 icons: { 562 previous: 'glyphicon glyphicon-arrow date-arrow-left', 563 next: 'glyphicon glyphicon-arrow date-arrow-right', 564 clear: 'glyphicon glyphicon-close date-clear', 565 } 566 }); 567 568 // Re-render AddToAny share buttons on the newly injected event 569 // cards â this flow intentionally skips Drupal.attachBehaviors(), 570 // so Drupal.behaviors.addToAny (which would normally call this) 571 // never runs. 572 if (window.a2a) { 573 a2a.init_all(); 574 } 575 } else { 576 $('.events-more-ajax').replaceWith(content_html); 577 // Drupal.attachBehaviors(); //do not add this to filter 578 579 // Re-render AddToAny share buttons on the newly injected event 580 // cards (see comment in the filter branch above). 581 if (window.a2a) { 582 a2a.init_all(); 583 } 584 } 585 }).fail(function(jqXHR, textStatus, errorThrown) { 586 alert(jqXHR.responseText); 587 }); 588 } 589 } 590 } 591 }; 592 593 /* 594 * Membership Listing Page 595 */ 596 Drupal.behaviors.membershipListingUpdate = { 597 attach: function (context, settings) { 598 // if($('.membership-listing-content').length){ 599 if($('.membership-listing').length){ 600 var url = window.location.href; 601 602 function formatCustom (state) { 603 if (!state.id) { return state.text; } 604 var $state = $( 605 '<span><span class="select2-icon-span f-icon ' + state.element.value.toLowerCase() + '-icon"></span> ' + state.text + '</span>' 606 ); 607 return $state; 608 }; 609 610 function formatNonCustom (state) { 611 if (!state.id) { return state.text; } 612 var $state = $( 613 '<span><span class="select2-icon-span f-icon checkbox-checked-icon"></span> ' + state.text + '</span>' 614 ); 615 return $state; 616 }; 617 618 //add select2 to filter 619 $('.non-custom-filter-form .form-select').select2MultiCheckboxes({ 620 minimumResultsForSearch: Infinity, 621 templateResult: formatNonCustom, 622 templateSelection: function(selected, total) { 623 return "Selected " + selected.length + " of " + total; 624 }, 625 }); 626 $('.custom-filter-form .form-select').select2MultiCheckboxes({ 627 minimumResultsForSearch: Infinity, 628 templateSelection: formatCustom, 629 templateResult: formatCustom, 630 }); 631 632 var option_type = 0; 633 634 $('.region-eventbank-api-membership-listing, .region-eventbank-api-membership-listing-default, .path-membership-directory', context).on('click', '.membership-clear-ajax',function(event){ 635 event.stopImmediatePropagation();
636 $('.non-custom-filter-form .form-select').val(null).trigger('change'); 637 $('.custom-filter-form .form-select').val(null).trigger('change'); 638 $('.form-container-search input[type="text"]').val(''); 639 // location.reload(); 640 641 return false; 642 }); 643 644 $('.region-eventbank-api-membership-listing, .region-eventbank-api-membership-listing-default, .path-membership-directory', context).on('click', '.membership-search-ajax',function(event){ 645 event.stopImmediatePropagation(); 646 var order = $('.membership-filter-form #edit-order').val(); 647 var industry = []; 648 649 $('.membership-filter-form .membership-filter-ajax').each(function(){ 650 if ($(this).val() != '' && $(this).val() != 0) { 651 industry.push($(this).val()); 652 // return false; 653 } 654 }); 655 var filter_tag = $("input[name=filter_tag]").val(); 656 var type = $('.membership-filter-form #edit-type').val(); 657 var search_keyword_value = ''; 658 var search_keyword = ''; 659 660 $('.membership-filter-form .membership-search-ajax-input', context).each(function(){ 661 if ($(this).val() != '' && $(this).val() != 0) { 662 var search_keyword_name = $(this).attr('name'); 663 search_keyword_name = search_keyword_name.substr(7); //Cut from 'search-' 664 search_keyword_value = $(this).val(); 665 search_keyword = search_keyword_value + '##FilterKey##' + search_keyword_name; 666 return false; 667 } 668 }); 669 670 $('.membership-filter-form .membership-search-ajax-input', context).onclick = function () { 671 if (search_keyword_value === '') { 672 return false; 673 } 674 } 675 676 $.ajax({ 677 type: 'POST', 678 url: url, 679 data: { order: order, industry: industry, filter_tag: filter_tag, type: type, search_keyword: search_keyword, ajax_call: 1 } 680 }).done(function(data, textStatus, jqXHR) { 681 var content_html = $(data).find('.membership-listing').html(); 682 $('.membership-listing-ajax').replaceWith(content_html); 683 684 //add select2 to filter 685 $('.non-custom-filter-form .form-select').select2({ 686 minimumResultsForSearch: Infinity, 687 templateResult: formatNonCustom, 688 }); 689 $('.custom-filter-form .form-select').select2({ 690 minimumResultsForSearch: Infinity, 691 templateSelection: formatCustom, 692 templateResult: formatCustom, 693 }); 694 $('.letter-filter.active').removeClass('underline'); 695 Drupal.attachBehaviors(); 696 }).fail(function(jqXHR, textStatus, errorThrown) { 697 alert(jqXHR.responseText); 698 }); 699 return false; 700 }); 701 702 $('.membership-listing', context).on('click keydown', '.form-reset', function(event){ 703 if (event.type === 'keydown' && event.key !== 'Enter' && event.key !== ' ') { return; } 704 event.stopImmediatePropagation(); 705 var order = ''; 706 var industry = ''; 707 var filter_tag = ''; 708 var type = ''; 709 var search_keyword = ''; 710 711 $.ajax({ 712 type: 'POST', 713 url: url, 714 data: { order: order, industry: industry, filter_tag: filter_tag, type: type, search_keyword: search_keyword, ajax_call: 0 } 715 }).done(function(data, textStatus, jqXHR) { 716 var content_html = $(data).find('.membership-listing').html(); 717 $('.membership-listing-ajax').replaceWith(content_html); 718 719 //add select2 to filter
720 $('.non-custom-filter-form .form-select').select2({ 721 minimumResultsForSearch: Infinity, 722 templateResult: formatNonCustom, 723 }); 724 $('.custom-filter-form .form-select').select2({ 725 minimumResultsForSearch: Infinity, 726 templateSelection: formatCustom, 727 templateResult: formatCustom, 728 }); 729 Drupal.attachBehaviors(); 730 }).fail(function(jqXHR, textStatus, errorThrown) { 731 alert(jqXHR.responseText); 732 }); 733 return false; 734 }); 735 736 $('.membership-listing', context).on('click', '.show-more-button', function(event){ 737 event.stopImmediatePropagation(); 738 var more_value = $('.show-more-button').attr('value'); 739 var order = $('.membership-filter-form #edit-order').val(); 740 var industry = ''; 741 $('.membership-filter-form .membership-filter-ajax').each(function(){ 742 if ($(this).val() != '' && $(this).val() != 0) { 743 industry = $(this).val(); 744 } 745 }); 746 747 var filter_tag = $("input[name=filter_tag]").val(); 748 var type = $('.membership-filter-form #edit-type').val(); 749 var search_keyword = ''; 750 $('.membership-filter-form .membership-search-ajax-input').each(function(){ 751 if ($(this).val() != '' && $(this).val() != 0) { 752 var search_keyword_name = $(this).attr('name'); 753 search_keyword_name = search_keyword_name.substr(7); //Cut from 'search-' 754 search_keyword = $(this).val(); 755 search_keyword = search_keyword + '##FilterKey##' + search_keyword_name; 756 } 757 }); 758 759 $.ajax({ 760 type: 'POST', 761 url: url, 762 data: { more_value: more_value, order: order, industry: industry, filter_tag: filter_tag, type: type, search_keyword: search_keyword, ajax_call: 2 } 763 }).done(function(data, textStatus, jqXHR) { 764 var content_html = $(data).find('.membership-listing').html(); 765 $('.membership-more-ajax').replaceWith(content_html); 766 Drupal.attachBehaviors(); 767 }).fail(function(jqXHR, textStatus, errorThrown) { 768 alert(jqXHR.responseText); 769 }); 770 return false; 771 }); 772 } 773 } 774 }; 775 776 777 /* 778 * Cascading filter: when a level-1 cascading dropdown changes, restrict 779 * the level-2 dropdown to only show the children of the selected parent(s). 780 * Works with the data-cascade-child / data-cascade-parent / data-cascade-map / 781 * data-all-options attributes set by membershipFilter::buildForm(). 782 */ 783 Drupal.behaviors.membershipCascadingFilter = { 784 attach: function (context, settings) { 785 once('cascading-filter', '[data-cascade-child]', context).forEach(function (parentEl) { 786 var cascadeMap = {}; 787 try { 788 cascadeMap = JSON.parse(parentEl.getAttribute('data-cascade-map') || '{}'); 789 } catch (e) {} 790 791 // preserveChildValue: true on initial attach (keep existing child selection if 792 // still valid), false on user-driven change (clear child selection). 793 function updateChild(preserveChildValue) { 794 var parentName = parentEl.name.replace('[]', ''); 795 var $child = $('[data-cascade-parent]').filter(function () { 796 return $(this).attr('data-cascade-parent') === parentName; 797 }); 798 if (!$child.length) { return; } 799
800 var $childWrapper = $child.closest('.non-custom-filter-form'); 801 var allOptions = []; 802 try { 803 allOptions = JSON.parse($child.attr('data-all-options') || '[]'); 804 } catch (e) {} 805 806 var previousVals = $child.val() || []; 807 var selected = $(parentEl).val() || []; 808 var parentCodes = selected.map(function (v) { 809 return v.split('##FilterKey##')[0]; 810 }); 811 812 // Collect allowed child codes (union of all selected parents' children). 813 var allowedCodes = []; 814 parentCodes.forEach(function (pCode) { 815 if (cascadeMap[pCode]) { 816 allowedCodes = allowedCodes.concat(cascadeMap[pCode]); 817 } 818 }); 819 820 // Rebuild child options: only matching children when parent selected. 821 $child.empty(); 822 var matchCount = 0; 823 allOptions.forEach(function (opt) { 824 var optCode = opt.v.split('##FilterKey##')[0]; 825 if (allowedCodes.length === 0 || allowedCodes.indexOf(optCode) !== -1) { 826 $child.append(new Option(opt.t, opt.v)); 827 if (allowedCodes.length > 0) { matchCount++; } 828 } 829 }); 830 831 // Show child only when parent has a selection AND children exist for it. 832 if (allowedCodes.length > 0 && matchCount > 0) { 833 $childWrapper.show(); 834 // Re-initialize select2 on the child now that it is visible. 835 if ($child.data('select2')) { $child.select2('destroy'); } 836 $child.select2MultiCheckboxes({ 837 minimumResultsForSearch: Infinity, 838 templateResult: function (state) { 839 if (!state.id) { return state.text; } 840 return $('<span><span class="select2-icon-span f-icon checkbox-checked-icon"></span> ' + state.text + '</span>'); 841 }, 842 templateSelection: function (selected, total) { 843 return 'Selected ' + selected.length + ' of ' + total; 844 }, 845 }); 846 if (preserveChildValue) { 847 // Restore previously selected values that are still in the filtered list. 848 var stillValid = previousVals.filter(function (v) { 849 return $child.find('option[value="' + v + '"]').length > 0; 850 }); 851 $child.val(stillValid.length > 0 ? stillValid : null).trigger('change'); 852 } else { 853 $child.val(null).trigger('change'); 854 } 855 } else { 856 $child.val(null).trigger('change'); 857 $childWrapper.hide(); 858 } 859 } 860 861 // User changes parent: clear child selection and update visibility. 862 $(parentEl).on('change.cascade', function () { updateChild(false); }); 863 864 // Initial attach: if parent already has a value (e.g. after AJAX re-render), 865 // filter child options and preserve any still-valid child selection. 866 if ($(parentEl).val() && $(parentEl).val().length > 0) { 867 updateChild(true); 868 } 869 }); 870 } 871 }; 872 873 /* 874 * Common Page View 875 */ 876 Drupal.behaviors.commonPageView = { 877 attach: function (context, settings) { 878 if($('.common-page-view').length){ 879 $('.views-exposed-form .form-item-title').on('click', '.control-label', function(){ 880 $('.views-exposed-form .form-actions .form-submit').trigger( 'click' ); 881 }); 882 } 883 } 884 }; 885 886 887 /* 888 * Weixin QR code 889 */ 890 Drupal.behaviors.weixinQrCode = { 891 attach: function (context, settings) { 892 if($('.weixin-qr-code').length){ 893 $('.weixin-icon').on('click', function(){ 894 $(this).next('.weixin-qr-code').toggle(); 895 $(this).parent('.button-social-media').toggleClass('active'); 896 }); 897 $('.line-icon').on('click', function(){ 898 $(this).next('.weixin-qr-code').toggle(); 899 $(this).parent('.button-social-media').toggleClass('active'); 900 }); 901 } 902 } 903 }; 904 905 906 /* 907 * Mobile menu 908 */ 909 Drupal.behaviors.mobileMenu = { 910 attach: function (context, settings) { 911 if($('.mobile-header-menu').length){ 912 $(once('mobile-header-menu', '.mobile-header-menu-link', context)).click(function () { 913 if($('.mobile-header-menu .mobile-block-menu').hasClass('mobile-block-menu-open')){ 914 $('.mobile-header-menu .mobile-block-menu').hide(); 915 $('.mobile-header-menu .mobile-block-menu #block-mainnavigation-2').hide(); 916 $('.mobile-header-menu .mobile-block-menu').removeClass('mobile-block-menu-open'); 917 } else { 918 $('.mobile-header-menu .mobile-block-menu').show(); 919 $('.mobile-header-menu .mobile-block-menu').addClass('mobile-block-menu-open'); 920 $('.mobile-header-menu .mobile-block-menu').addClass('testing'); 921 $('.mobile-header-menu .mobile-block-menu #block-mainnavigation-2').show(); 922 $('#block-mainnavigation-2 #superfish-main--2-accordion').removeClass('sf-hidden'); 923 $('#block-mainnavigation-2 #superfish-main--2-accordion').addClass('sf-expanded'); 924 $('#block-mainnavigation-2 #superfish-main--2-accordion').css('display', 'block'); 925 $('#block-mainnavigation-2 #superfish-main-accordion').removeClass('sf-hidden'); 926 $('#block-mainnavigation-2 #superfish-main-accordion').addClass('sf-expanded'); 927 $('#block-mainnavigation-2 #superfish-main-accordion').css('display', 'block'); 928 929 } 930 }); 931 $('.mobile-header-menu').on('click', '.close-icon', function(){ 932 $('.mobile-header-menu .mobile-block-menu').hide(); 933 $('.mobile-header-menu .mobile-block-menu').removeClass('mobile-block-menu-open'); 934 }); 935 // $('.mobile-block-menu').on('click', 'li.menuparent', function(){ 936 937 // $('.mobile-block-menu li.menuparent ul').css('position', 'absolute'); 938 939 // if($(this).hasClass('li-open')){ 940 // $('.mobile-block-menu li.menuparent').removeClass('li-open'); 941 // var sub_menu = $(this).find('ul'); 942 // sub_menu.css('display', 'none'); 943 // } else { 944 // $('.mobile-block-menu li.menuparent').removeClass('li-open'); 945 // $(this).addClass('li-open'); 946 // var sub_menu = $(this).find('ul'); 947 // sub_menu.css('position', 'relative'); 948 // sub_menu.css('top', '10px'); 949 // } 950 // }); 951 } 952 } 953 }; 954 955 956 /* 957 * Global 958 */ 959 /* 960 * Keyboard accessibility: make non-link nav parent items Tab-focusable. 961 * 962 * Superfish renders menu items with no URL as <span class="nolink"> which are 963 * not natively focusable. Adding tabindex="0" puts them in the Tab order so 964 * the CSS :focus-within rule on the parent <li> can show their submenu.
965 * Enter/Space toggle the submenu for keyboard users who expect that behaviour. 966 */ 967 Drupal.behaviors.navKeyboard = { 968 attach: function (context, settings) { 969 once('nav-nolink-focusable', '.sf-menu span.nolink.menuparent', context).forEach(function (span) { 970 span.setAttribute('tabindex', '0'); 971 $(span).on('keydown', function (e) { 972 if (e.key === 'Enter' || e.key === ' ') { 973 e.preventDefault(); 974 var $li = $(span).closest('li'); 975 var isOpen = $li.hasClass('sfHover'); 976 // Close all other open items first. 977 $('.sf-menu li.sfHover').not($li).removeClass('sfHover'); 978 $li.toggleClass('sfHover', !isOpen); 979 } 980 // Arrow-Down moves focus to the first submenu item. 981 if (e.key === 'ArrowDown') { 982 e.preventDefault(); 983 var $first = $(span).closest('li').find('ul a').first(); 984 if ($first.length) { $first.focus(); } 985 } 986 }); 987 }); 988 } 989 }; 990 991 Drupal.behaviors.global = { 992 attach: function (context, settings) { 993 // Shared helper so click, keyboard, and Escape all use the same close logic. 994 function closeAjaxModal() { 995 var $trigger = $('body').data('last-popup-trigger'); 996 $('.ajax-overlay').hide(); 997 $('.ajax-overlay-end').remove(); 998 $('.overlay-all-white').remove(); 999 $('.ajax-content').remove(); 1000 $('body').css('height', 'auto'); 1001 $('body').css('overflow', 'visible'); 1002 // Return focus to the element that opened the modal. 1003 if ($trigger) { $($trigger).focus(); } 1004 } 1005 1006 $('html').on('click', '.ajax-overlay-end .ajax-content .ajax-close, .overlay-all-white', function(){ 1007 closeAjaxModal(); 1008 }); 1009 1010 // Allow keyboard users to close the modal with Enter/Space on the close button. 1011 $('html').on('keydown', '.ajax-overlay-end .ajax-content .ajax-close', function(e){ 1012 if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); closeAjaxModal(); } 1013 }); 1014 1015 // Close on Escape key â required by WCAG 2.1 SC 2.1.2.
1016 // Focus trap: keep Tab/Shift+Tab cycling inside the modal while it is open. 1017 $(document).off('keydown.ajax-modal').on('keydown.ajax-modal', function(e) { 1018 if (e.key === 'Escape' && $('.ajax-overlay-end').length) { closeAjaxModal(); return; } 1019 1020 if (e.key === 'Tab' && $('.ajax-overlay-end').length) { 1021 e.preventDefault(); 1022 var focusableSelectors = 'a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])'; 1023 var $modal = $('.ajax-content'); 1024 var $focusable = $modal.find(focusableSelectors).filter(':visible'); 1025 if (!$focusable.length) { $modal.attr('tabindex', '-1').focus(); return; } 1026 var $first = $focusable.first(); 1027 var $last = $focusable.last(); 1028 // If focus is outside the modal, bring it in. 1029 if (!$.contains($modal[0], document.activeElement)) { 1030 (e.shiftKey ? $last : $first).focus(); 1031 return; 1032 } 1033 // Wrap at boundaries. 1034 if (e.shiftKey && $(document.activeElement).is($first)) { 1035 $last.focus(); 1036 } else if (!e.shiftKey && $(document.activeElement).is($last)) { 1037 $first.focus(); 1038 } else { 1039 // Move naturally to the next/previous focusable element within the modal. 1040 var index = $focusable.index(document.activeElement); 1041 $focusable.eq(e.shiftKey ? index - 1 : index + 1).focus(); 1042 } 1043 } 1044 }); 1045 1046 // Use once() to prevent duplicate ajaxStart/ajaxStop handlers on re-attach. 1047 once('global-ajax-handlers', 'html').forEach(function () {
1048 var $overlay = $('.ajax-overlay').hide(); 1049 var $overlay_end = $('.ajax-overlay-end').hide(); 1050 var $overlay_all_white = $('.overlay-all-white').hide(); 1051 var $loading = $('#loading').hide(); 1052 $(document) 1053 .ajaxStart(function () { 1054 $overlay.show(); 1055 $loading.show(); 1056 $overlay_end.remove(); 1057 $overlay_all_white.remove(); 1058 }) 1059 .ajaxStop(function () { 1060 $overlay.hide(); 1061 $loading.hide(); 1062 }); 1063 }); 1064 1065 1066 /* 1067 * Replace Anchor scroll to a smooth scroll 1068 */ 1069 $("a[href*='#']:not([href='#'])").click(function() { 1070 if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) { 1071 var target = $(this.hash); 1072 target = target.length ? target : $('[name=' + this.hash.slice(1) +']'); 1073 if (target.length) { 1074 var scroll = target.offset().top; 1075 if($('.mobile')){ 1076 scroll = scroll - 130; 1077 } else { 1078 scroll = scroll - 110; 1079 } 1080 1081 $('html,body', context).animate({ 1082 scrollTop: scroll 1083 }, 1000); 1084 return false; 1085 } 1086 } 1087 }); 1088 } 1089 }; 1090 1091 /* 1092 * Node Modal 1093 */ 1094 Drupal.behaviors.nodeModal = { 1095 attach: function (context, settings) { 1096 if($('.node-modal').length){ 1097 //get modal function 1098 function nodeModal(url){ 1099 var get_modal = '.node--view-mode-full'; 1100 var node_class = 'body'; 1101 1102 //check for custom modal from url 1103 var custom_class_position = url.indexOf('#'); 1104 if (custom_class_position >= 0) { 1105 get_modal = '.' + url.substr(custom_class_position + 1) 1106 } 1107 1108 $.ajax({ 1109 type: 'POST', 1110 url: url, 1111 }).done(function(data, textStatus, jqXHR) { 1112 var content_html = $(data).find(get_modal).html(); 1113 1114 //get region class to keep style when possible 1115 var parser = new DOMParser(); 1116 doc = parser.parseFromString(data, "text/html"); 1117 var docClass = doc.body.getAttribute('class'); 1118 parser = doc = null; 1119 1120 if (!String.prototype.startsWith) { 1121 String.prototype.startsWith = function(searchString, position){ 1122 return this.substr(position || 0, searchString.length) === searchString; 1123 }; 1124 } 1125 1126 $('.ajax-overlay').before('<div class="ajax-overlay-end"><div class="ajax-content '+docClass+'"><span class="ajax-close f-icon close-icon"></span>'+content_html+'</div><div class="overlay-all-white"></div></div>'); 1127 }).fail(function(jqXHR, textStatus, errorThrown) { 1128 alert(jqXHR.responseText); 1129 }); 1130 } 1131 1132 //node modal click button 1133 $(once('body-class', '.node-modal', context)).click(function (e) { 1134 // $('.node-modal').once().each(function(){ 1135 // $(this).one('click', function(e){ 1136 e.preventDefault(); 1137 var url = $(this).attr('href'); 1138 1139 $('.ajax-content').remove(); 1140 nodeModal(url); 1141 // }); 1142 }); 1143 } 1144 } 1145 }; 1146 1147 /* 1148 * Full List: having the letter filter fixed on top of the page after scrolling down 1149 */ 1150 Drupal.behaviors.alphabetNavPositionFixed = { 1151 attach: function (context, settings) { 1152 if ($('.letters-filter-fixednav').length) { 1153 var alphabetNav = $(".letters-filter-fixednav"); 1154 var win = $(window); 1155 var top_offset = $('.letters-filter-fixednav').offset().top; 1156 1157 var sc = $(document); 1158 win.scroll(function () { 1159 if (sc.scrollTop() >= top_offset) { 1160 alphabetNav.addClass("fixednav"); 1161 } else { 1162 alphabetNav.removeClass("fixednav"); 1163 } 1164 }) 1165 } 1166 } 1167 }; 1168 1169 /* 1170 * Get the height of membership info description so as to append shandow 1171 */ 1172 Drupal.behaviors.appendShandowForMembershipDescription = { 1173 attach: function (context, settings) { 1174 if ($('#block-membershippaymentdetails .membership-details-content').length) { 1175 $( "#block-membershippaymentdetails .membership-details-content .views-row .field-content-description" ).each(function() { 1176 if (($(this).height() > 190) && (!$(this).parent().contents('.membership-info-contents-hide').length)) { 1177 $(this).after('<span class="membership-info-contents-hide"></span>'); 1178 $(this).addClass("field-content-description-scroll"); 1179 } 1180 }); 1181 } 1182 } 1183 }; 1184 1185 Drupal.behaviors.appendShandowForMembershipV2Description = { 1186 attach: function (context, settings) { 1187 if ($('.block-membership-payment-corporate-individual .membership-details-content').length) { 1188 $( ".block-membership-payment-corporate-individual .membership-details-content .views-row .field-content-description" ).each(function() { 1189 if (($(this).height() > 190) && (!$(this).parent().contents('.membership-info-contents-hide').length)) { 1190 $(this).after('<span class="membership-info-contents-hide"></span>'); 1191 $(this).addClass("field-content-description-scroll"); 1192 } 1193 }); 1194 } 1195 } 1196 }; 1197 1198 1199 /*
1200 * Display none the button when the CTA link is empty 1201 */ 1202 Drupal.behaviors.displayNoneForCTALink = { 1203 attach: function (context, settings) { 1204 // Home banner buttons 1205 if ($('.block-views-blockhomepage-block-1 .banner-buttons').length) { 1206 var banner_left_link_html = $('.block-views-blockhomepage-block-1 .banner-buttons .views-field-field-left-link .field-content').html(); 1207 var banner_right_link_html = $('.block-views-blockhomepage-block-1 .banner-buttons .views-field-field-right-link .field-content').html(); 1208 if (banner_left_link_html.length == 0) { 1209 $('.block-views-blockhomepage-block-1 .banner-buttons .views-field-field-left-link').css('display', 'none'); 1210 $('.block-views-blockhomepage-block-1 .banner-buttons .views-field-field-left-link').css('margin-right', 'auto'); 1211 } 1212 if (banner_right_link_html.length == 0) { 1213 $('.block-views-blockhomepage-block-1 .banner-buttons .views-field-field-right-link').css('display', 'none'); 1214 } 1215 } 1216 } 1217 }; 1218 1219 /* 1220 * Hide job contact when page load 1221 */ 1222 // Drupal.behaviors.toggleContactFormForWebformContactPage = { 1223 // attach: function (context, settings) { 1224 // if ($('#webform-submission-jobs-add-form').length) { 1225 // if ($("webform-submission-volunteer-opportunity-add-form input[name='job_contact']:checked").val() == 'email') { 1226 // $('.form-item-contact-email').css('display', 'block'); 1227 // $('.form-item-contact-url').css('display', 'none'); 1228 // } else if ($("webform-submission-volunteer-opportunity-add-form input[name='job_contact']:checked").val() == 'link_url') { 1229 // $('.form-item-contact-url').css('display', 'block'); 1230 // $('.form-item-contact-email').css('display', 'none'); 1231 // } else { 1232 // $('.form-item-contact-url').css('display', 'none'); 1233 // $('.form-item-contact-email').css('display', 'none'); 1234 // } 1235 1236 // $('html').on('click', '#edit-job-contact-email', function(){ 1237 // $('.form-item-contact-email').css('display', 'block'); 1238 // $('.form-item-contact-url').css('display', 'none'); 1239 // $('#edit-job-contact-link-url').val(""); 1240 // }); 1241 1242 // $('html').on('click', '#edit-job-contact-link-url', function(){ 1243 // $('.form-item-contact-url').css('display', 'block'); 1244 // $('.form-item-contact-email').css('display', 'none'); 1245 // $('#edit-job-contact-email').val(""); 1246 // }); 1247 // } 1248 // } 1249 // }; 1250 1251 /* 1252 * FAQ 1253 */ 1254 Drupal.behaviors.faq = { 1255 attach: function (context, settings) { 1256 // Show all the body 1257 if($('.view-block-faq-body-visible').length){ 1258 $('.view-block-faq-body-visible .views-field-title').unbind().on('click', function(){ 1259 if ($(this).next('.views-field-body').hasClass('active')) {
1260 $(this).next('.views-field-body').slideUp("fast"); 1261 $(this).next('.views-field-body').removeClass('active'); 1262 1263 $($('this').find('.arrow-icon')).css({ 1264 'transform': 'translate(0, -50%) rotate(0deg)', 1265 }); 1266 } else { 1267 $(this).next('.views-field-body').slideUp("fast"); 1268 $(this).next('.views-field-body').removeClass('active'); 1269 $(this).next('.views-field-body').slideToggle("fast"); 1270 $(this).next('.views-field-body').addClass('active'); 1271 1272 $($(this).find('.arrow-icon')).css({ 1273 'transform': 'translate(0, -50%) rotate(-180deg)', 1274 }); 1275 } 1276 }); 1277 // Show only one body 1278 } else if ($('.view-faq').length) { 1279 $('.view-faq .views-field-title').unbind().on('click', function () { 1280 if($(this).next('.views-field-body').hasClass('active')) {
1281 $(this).next('.views-field-body').slideUp("fast"); 1282 $(this).next('.views-field-body').removeClass('active'); 1283 1284 $($(this).find('.arrow-icon')).css({ 1285 'transform': 'translate(0, -50%) rotate(0deg)', 1286 }); 1287 } else { 1288 $('.view-faq .views-field-body').slideUp("fast"); 1289 $('.view-faq .views-field-body').removeClass('active'); 1290 $(this).next('.views-field-body').slideToggle("fast"); 1291 $(this).next('.views-field-body').addClass('active'); 1292 1293 $('.view-faq .arrow-icon').css({ 1294 'transform': 'translate(0, -50%) rotate(0deg)', 1295 }); 1296 $($(this).find('.arrow-icon')).css({ 1297 'transform': 'translate(0, -50%) rotate(-180deg)', 1298 }); 1299 } 1300 }); 1301 } 1302 } 1303 }; 1304 1305 1306 /* 1307 * Home page banner slick 1308 */ 1309 Drupal.behaviors.homeBannerSlick = { 1310 attach: function (context, settings) { 1311 once('homeBannerSlick', '#block-views-block-homepage-block-1', document).forEach(function (el) { 1312 $(el).find('.views-field-field-image .field-content').slick({ 1313 arrows: false, 1314 slidesToShow: 1, 1315 slidesToScroll: 1, 1316 autoplay: true, 1317 autoplaySpeed: 5000, 1318 speed: 300, 1319 infinite: true, 1320 fade: true, 1321 cssEase: 'ease', 1322 pauseOnHover: false, 1323 pauseOnFocus: false 1324 }); 1325 }); 1326 } 1327 }; 1328 1329 /* 1330 * Facebook feed responsive 1331 */ 1332 Drupal.behaviors.FacebookFeedResponsive = { 1333 attach: function (context, settings) { 1334 if ($('.feeds-contents-social').length || $('.feeds-contents-social-front').length) { 1335 $(window).on('resize', function() { 1336 setTimeout(function(){facebookFeedResponsive()}, 500); 1337 }); 1338 1339 $(window).on('load', function() { 1340 setTimeout(function(){facebookFeedResponsive()}, 1500); 1341 }); 1342 1343 var facebookFeedResponsive = function () { 1344 //getting parent box width 1345 var container_width = Number($('.block-feeds-block').width()).toFixed(0) - 40; 1346 var container_height = Number($('.block-feeds-block').height()).toFixed(0) - 40; 1347 if (!isNaN(container_width)) { 1348 $(".fb-page").attr("data-width", container_width).attr("data-height", container_height); 1349 } 1350 if (typeof FB !== 'undefined' ) { 1351 FB.XFBML.parse(); 1352 } 1353 } 1354 } 1355 } 1356 }; 1357 1358 /* 1359 * Glueup profile menu 1360 */ 1361 Drupal.behaviors.GlueupProfileMenu = { 1362 attach: function (context, settings) { 1363 if($('.header-profile').length){ 1364 once('GlueupProfileMenu', 'html').forEach(function (element) { 1365 $('.header-profile').on('click', function(e){ 1366 $(this).find('.profile-menu').toggle(); 1367 $(this).find('.glueup-profile').toggleClass('active'); 1368 }); 1369 1370 $(document).on('click', function(event) { 1371 if (!$(event.target).closest('.header-profile').length) { 1372 //This code will run when the click is outside '.header-profile' 1373 $('.profile-menu').hide(); 1374 $('.glueup-profile').removeClass('active'); 1375 } 1376 }); 1377 1378 $('#profile-menu-main li a').click(function() { 1379 $('.profile-menu').toggle(); 1380 $('.glueup-profile').toggleClass('active'); 1381 }); 1382 }); 1383 } 1384 } 1385 }; 1386 1387 /* 1388 * Calendar Link 1389 */ 1390 Drupal.behaviors.CalendarLink = { 1391 attach: function (context, settings) { 1392 function openCalendar($widget) { 1393 $('.event-add-calendar .calendar-text-icon').hide(); 1394 $('.event-add-calendar .calendar-image a').attr('aria-expanded', 'false'); 1395 var $panel = $widget.find('.calendar-text-icon'); 1396 var isOpen = $panel.is(':visible');
1397 $panel.toggle(); 1398 $widget.find('.calendar-image a').attr('aria-expanded', isOpen ? 'false' : 'true'); 1399 if (!isOpen) { 1400 // Move focus into the panel for keyboard users. 1401 $panel.find('a').first().focus(); 1402 } 1403 } 1404 function closeCalendar($widget) { 1405 $widget.find('.calendar-text-icon').hide(); 1406 var $trigger = $widget.find('.calendar-image a'); 1407 $trigger.attr('aria-expanded', 'false').focus(); 1408 } 1409 1410 $(once('calendar-link-handlers', 'body')).each(function () { 1411 $(document).on('click keydown', '.event-add-calendar .calendar-image a', function(e){ 1412 if (e.type === 'keydown' && e.key !== 'Enter' && e.key !== ' ') { return; } 1413 e.preventDefault(); 1414 openCalendar($(this).closest('.event-add-calendar')); 1415 }); 1416 1417 $(document).on('click', function(event) { 1418 if (!$(event.target).closest('.event-add-calendar').length) { 1419 $('.event-add-calendar .calendar-text-icon').hide(); 1420 $('.event-add-calendar .calendar-image a').attr('aria-expanded', 'false'); 1421 } 1422 }); 1423 1424 $(document).on('click keydown', '.event-add-calendar .close-icon', function(e){ 1425 if (e.type === 'keydown' && e.key !== 'Enter' && e.key !== ' ') { return; } 1426 e.preventDefault(); 1427 closeCalendar($(this).closest('.event-add-calendar')); 1428 }); 1429 1430 $(document).on('keydown.calendar-panel', function(e) { 1431 if (e.key === 'Escape' && $('.event-add-calendar .calendar-text-icon:visible').length) { 1432 e.stopPropagation(); 1433 closeCalendar($('.event-add-calendar .calendar-text-icon:visible').closest('.event-add-calendar')); 1434 } 1435 }); 1436 }); 1437 } 1438 }; 1439 1440 /* 1441 * Event share 1442 */ 1443 Drupal.behaviors.EventShare = { 1444 attach: function (context, settings) { 1445 function openShare($widget) { 1446 $('.event-share .share-text-icon').hide(); 1447 $('.event-share .share-image a').attr('aria-expanded', 'false'); 1448 var $panel = $widget.find('.share-text-icon'); 1449 var isOpen = $panel.is(':visible'); 1450 $panel.toggle(); 1451 $widget.find('.share-image a').attr('aria-expanded', isOpen ? 'false' : 'true'); 1452 if (!isOpen) { 1453 $panel.find('a').first().focus(); 1454 } 1455 } 1456 function closeShare($widget) { 1457 $widget.find('.share-text-icon').hide(); 1458 var $trigger = $widget.find('.share-image a'); 1459 $trigger.attr('aria-expanded', 'false').focus(); 1460 } 1461 1462 $(once('event-share-handlers', 'body')).each(function () { 1463 $(document).on('click keydown', '.event-share .share-image a', function(e){ 1464 if (e.type === 'keydown' && e.key !== 'Enter' && e.key !== ' ') { return; } 1465 e.preventDefault(); 1466 openShare($(this).closest('.event-share')); 1467 }); 1468 1469 $(document).on('click', function(event) { 1470 if (!$(event.target).closest('.event-share').length) { 1471 $('.event-share .share-text-icon').hide(); 1472 $('.event-share .share-image a').attr('aria-expanded', 'false'); 1473 } 1474 }); 1475 1476 $(document).on('click keydown', '.event-share .close-icon', function(e){ 1477 if (e.type === 'keydown' && e.key !== 'Enter' && e.key !== ' ') { return; } 1478 e.preventDefault(); 1479 closeShare($(this).closest('.event-share')); 1480 }); 1481 1482 $(document).on('keydown.share-panel', function(e) { 1483 if (e.key === 'Escape' && $('.event-share .share-text-icon:visible').length) { 1484 e.stopPropagation(); 1485 closeShare($('.event-share .share-text-icon:visible').closest('.event-share')); 1486 } 1487 }); 1488 }); 1489 } 1490 }; 1491 1492})(jQuery, Drupal, once);
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.