PageSourceSearch

https://icma.org/themes/custom/icma/js/custom.js?v=1.0.107

js icma.org collected 2026-10-02 02:18:49 UTC 7,212 bytes, 210 lines download raw bytes

1/**
2 * @file
3 * Global utilities.
4 *
5 */
6
7(function($, Drupal, once) {
8
9  'use strict';
10
11  Drupal.behaviors.icma = {
12    attach: function(context, settings) {
13
14      // Search popup
15      $( '.popup-link' ).click( function(e) {
16        e.stopPropagation();
17        $( '#navbar-top' ).fadeIn().addClass('open');
18        $('body').addClass('search-open');
19        return false;
20      } );
21
22      $( '#navbar-top .close' ).click( function() {
23        $( this ).parents( '#navbar-top' ).hide();
24        $('body').removeClass('search-open');
25        $('#navbar-top').removeClass('open');
26      });
27
28      $(window).click(function() { //Close form if click outside
29        $( '#navbar-top' ).fadeOut().removeClass('open');
30        $('body').removeClass('search-open');
31      });
32
33      $( '#navbar-top' ).click( function( e ) {
34        e.stopPropagation();
35      });
36
37      // Responsive main menu burger
38      $(once('toggler-right', ".navbar-toggler-right")).click( function(e) {
39        e.stopPropagation();
40        $('#CollapsingNavbar').toggleClass("show");
41        $('body').toggleClass("offcanvas-active");
42      });
43
44      // Sidebar toggler
45      $(once('toggle-1', ".level-1-toggle")).click( function(e) {
46        e.stopPropagation();
47        var open = $( this ).parent().hasClass("show");
48        $('.item-level-1').removeClass('show');
49        $('.level-1').hide();
50        if (!open) {
51          $( this ).parent().addClass("show");
52          $( this ).parent().find('.level-1').show();
53        }
54      });
55
56      $(once('toggle-0', ".level-0-toggle")).click( function(e) {
57        e.stopPropagation();
58        var open = $( this ).parent().hasClass("show");
59        $('.item-level-0').removeClass('show');
60        $('.level-0').hide();
61        if (!open) {
62          $( this ).parent().addClass("show");
63          $( this ).parent().find('.level-0').show();
64        }
65      });
66
67      $(once('toggle-2', ".level-2-toggle")).click( function(e) {
68        e.stopPropagation();
69        var open = $( this ).parent().hasClass("show");
70        $('.item-level-2').removeClass('show');
71        $('.level-2').hide();
72        if (!open) {
73          $( this ).parent().addClass("show");
74          $( this ).parent().find('.level-2').show();
75        }
76      });
77
78      // Search filters show/hide (for the topic-search/* page)
79      $("[id^='block-exposed-form-search'].views-exposed-form .fieldset-wrapper").hide();
80      $(once('exposed-1', "[id^='block-exposed-form-search'].views-exposed-form legend")).click( function(e) {
81        e.stopPropagation();
82        $( this ).parent().toggleClass("show");
83        $( this ).parent().find(".fieldset-wrapper").toggle("slow");
84      });
85
86      // Search filters show/hide (for the keyword-search/* page)
87      $("[id^='block-exposedformsearchkeywords-block'].views-exposed-form .fieldset-wrapper").hide();
88      $(once('exposed-2', "[id^='block-exposedformsearchkeywords-block'].views-exposed-form legend")).click( function(e) {
89          e.stopPropagation();
90          $( this ).parent().toggleClass("show");
91          $( this ).parent().find(".fieldset-wrapper").toggle("slow");
92      });
93
94      // Job Search detail show/hide
95      $(".job-post-search-detail").hide();
96      $(once('post-search',".job-post-search-toggle")).click( function(e) {
97        e.stopPropagation();
98        $( this ).toggleClass("active");
99        $( this ).parents(".node__content").find(".job-post-search-detail").toggle("slow");
100      });
101
102      // Sidebar menu
103      $(once('sidebar', ".sidebar-menu li.have-children > .menu-item-toggle")).on("click", function(i){
104        i.preventDefault();
105        if( $(this).parent().hasClass("active") ){
106          $(this).parent().removeClass("active");
107        }
108        else{
109          $(".sidebar-menu > li").removeClass("active");
110          $(this).parents("li.have-children").addClass("active");
111        }
112      });
113
114      // $('.menu-item-toggle').each(function () {
115      //   var menuItemHeight = $(this).siblings('a').outerHeight();
116      //   $(this).height(menuItemHeight);
117      // });
118
119
120      // Parent clickable
121      $(".paragraph--type--article-slider .card").click( function(){
122        window.location = $(this).find("h4 a").first().attr("href");;
123        return false;
124      });
125
126      // Avoid dropdown menu close/open on click inside (only desktop).
127      if (!window.matchMedia("(max-width: 79.75rem)").matches) {
128        $(once('main-menu__nav-link', '.menu--main .dropdown.item-level-0 > .nav-link'))
129          .on('click', function(event) {
130            event.stopPropagation();
131          });
132      }
133
134    }
135  };
136
137  Drupal.behaviors.clickableImage = {
138    attach: function(context, settings) {
139      // Search results cards image link fix
140      $(once('clickableImage', '.view-mode--grid .card', context)).each(function () {
141        // Get the card href
142        var $link = $(this).find('.field--name-node-title a').attr('href');
143        // Set the image href
144        var $wrapper = $('<a/>').attr('href', $link);
145        $(this).find('.field-name-field-media-image img').wrap($wrapper);
146      });
147    }
148  };
149
150})(jQuery, Drupal, once);
151
152// SHow and Hide Card 
153
154  jQuery(document).ready(function ($) {
155    $("#toggle-cards-wrapper").on("click", function () {
156      const $cards = $(".more-card");
157      const $btn = $("#toggle-cards-btn");
158      const isHidden = $cards.first().hasClass("card-hidden");
159
160      if (isHidden) {
161        $cards.removeClass("card-hidden");
162        $btn.text("Show Less");
163      } else {
164        $cards.addClass("card-hidden");
165        $btn.text("More Topics");
166      }
167    });
168  });
169
170  // Show and Hide more button Card 
171
172jQuery(function ($) {
173  const chevronDown =
174    '<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" fill="currentColor" stroke="currentColor" stroke-width="1" class="bi bi-chevron-down" viewBox="0 0 16 16"><path fill-rule="evenodd" d="M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708"/></svg>';
175  const chevronUp =
176    '<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" fill="currentColor" stroke="currentColor" stroke-width="1" class="bi bi-chevron-up" viewBox="0 0 16 16"><path fill-rule="evenodd" d="M7.646 4.646a.5.5 0 0 1 .708 0l6 6a.5.5 0 0 1-.708.708L8 5.707l-5.646 5.647a.5.5 0 0 1-.708-.708z"/></svg>';
177
178  $(document).on("click", '[data-toggle="profile-more"]', function () {
179    const $btn = $(this);
180    const selector = $btn.attr("data-target");
181    const $more = $(selector);
182    const $row = $btn.closest(".profile-cards-row");
183
184    if (!$more.length) return;
185
186    const isHidden = $more.hasClass("d-none");
187
188    // Toggle the content
189    $more
190      .toggleClass("d-none", !isHidden)
191      .attr("aria-hidden", isHidden ? "false" : "true");
192    $btn
193      .attr("aria-expanded", isHidden ? "true" : "false")
194      .html(
195        (isHidden ? "Read Less " : "Read More ") +
196          (isHidden ? chevronUp : chevronDown)
197      );
198
199    // Toggle equal-height 
200    if (isHidden) {
201      $row.removeClass("align-items-stretch").addClass("align-items-start");
202    } else {
203      $row.removeClass("align-items-start").addClass("align-items-stretch");
204    }
205  });
206});
207
208
209
210

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.