PageSourceSearch

https://www.ecpi.edu/themes/custom/ecpi_university/js/custom.js?v=12

js ecpi.edu collected 2026-09-24 17:35:46 UTC 6,409 bytes, 176 lines download raw bytes

1/**
2 * @file
3 * Global utilities.
4 *
5 */
6(function($, Drupal) {
7
8  'use strict';
9
10  Drupal.behaviors.ecpi_university = {
11    attach: function(context, settings) {
12
13      // Mega nav setup (programs)
14      var panels = document.querySelectorAll(".mega-dropdown-menu .view-degrees-mega-menu .view-grouping.top");
15
16      panels.forEach(function (panel, index) {
17        panel.querySelector('.meganav-trigger a').addEventListener('click', event => {
18          event.preventDefault();
19
20          panels.forEach(elem => {
21            elem.classList.remove('show');
22            elem.classList.add('hide');
23          });
24
25          event.target.closest('.top').classList.remove('hide');
26          event.target.closest('.top').classList.add('show');
27        });
28      });
29
30      // Video modal helpers
31      var videoModals = Array.from(document.getElementsByClassName('video modal'));
32      for (let i = 0; i < videoModals.length; i++) {
33        document.body.appendChild(videoModals[i]);
34      }
35
36      // Clobber video on modal close
37      $("body").on('hidden.bs.modal', function (e) {
38        var $iframes = $(e.target).find("iframe");
39        $iframes.each(function(index, iframe) {
40          $(iframe).attr("src", $(iframe).attr("src"));
41        });
42      });
43
44      // Search block
45      $('.block-search-form-block .search-close', context).click(function (e) {
46        e.preventDefault();
47        $('#search-block-form-wrapper').collapse('hide');
48      });
49
50      // Mailchimp subscription helpers
51      $('.mailchimp-signup-subscribe-form .form-email', context).attr('placeholder', Drupal.t('Your e-mail address'));
52
53      $('.mailchimp-signup-subscribe-form', context).submit(function (e) {
54        if($('.mailchimp-signup-subscribe-form .form-email').val() === '') {
55          window.open(settings.mailchimp_form, '_blank')
56          return false;
57        }
58      });
59
60      // Menu helpers
61      $('.menu-item--expanded .nav-link', context).click(function () {
62        $(this).parent().find('.menu').toggle();
63      });
64
65      window.onload = function() {
66        if($('#block-views-blocklocations-mega-menu-block').length) {
67          $('.view-id-locations_mega_menu .list-title').each(function(index, item){
68            let locationFind = $(item).find('.location-region');
69            if (!locationFind.length) {
70              $(item).next('.list-group').addClass('region-element');
71            }
72          });
73        }
74
75        if($('.right-menu')) {
76          if($('.menu-item--active-trail').find('.menu').length) {
77            $('.menu-item--active-trail').find('.menu').show();
78          }
79        }
80
81        // College tertiary menu, show first element.
82        if($('body').hasClass('node--type-college')) {
83          $('.degrees-tertiary-menu .tab-content section').first().addClass('show active');
84        }
85      };
86
87      // Accordion menu helper
88      $('#block-ecpi-university-footer .accordion-header', context).each(function () {
89        var header_id = $(this).attr('id');
90        var control_id = $(this).find('.accordion-button').attr('aria-controls');
91        $(this).next('.accordion-collapse').attr('id', control_id).attr('aria-labelledby', header_id);
92      });
93
94      $('.accordion-item', context).each(function() {
95        var accButton = $(this).find('.accordion-button'); // Find the accordion button
96    
97        // Prevent multiple rapid clicks by adding a "no-clicked" class
98        accButton.addClass('no-clicked');
99    
100        accButton.click(function() {
101            // If the button has the "no-clicked" class, allow the click to proceed
102            if ($(this).hasClass('no-clicked')) {
103                // Remove the "no-clicked" class after the click to allow future clicks
104                $(this).removeClass('no-clicked');
105            } else {
106                // Optionally, do something if clicked again before waiting for transition
107                // But avoid triggering another click programmatically
108            }
109        });
110    });
111
112      // Update State title in Locations page.
113      $('.state-name-items-wrapper .state-name-item', context).each(function () {
114        var link = $(this).find('> a');
115        link.click(function () {
116          $('.current-filter-title h3', context).text($(this).text().trim());
117          $('.form-exposed-filter--wrapper').html('');
118        });
119      });
120
121      // Hero & CTA Blocks - Webform
122      $('.hero .has-webform .webform-form, .cta-blocks .has-webform .webform-form', context).hide();
123      $('.hero .has-webform .cta, .cta-blocks .has-webform .cta', context).each(function () {
124        var ctaBtn = $(this).find('.btn-open-webform');
125        ctaBtn.click(function (e) {
126          e.preventDefault();
127          var wid = $(this).data('wid');
128          $(this).closest('.has-webform').find('.webform-form[data-wid="' + wid + '"]').show();
129          $(this).closest('.has-webform').find('.webform-form-wrapper').slideDown().removeClass('closed');
130        });
131      });
132
133      $('.hero .has-webform .close-webform, .cta-blocks .has-webform .close-webform').click(function (e) {
134        e.preventDefault();
135
136        $(this).closest('.has-webform').find('.webform-form-wrapper').slideUp(400, function () {
137          $(this).addClass('closed');
138          $(this).closest('.has-webform').find('.webform-form').hide();
139        });
140      });
141
142      // Table mobile support
143      $('table', context).each(function () {
144        $(this).wrap('<div style="overflow-x: auto"></div>');
145      });
146
147      // Custom code for Online Demo page
148      // if($('#block-webform-5').length != 0 ) {
149      //   $('.sidebar_second').contents().appendTo('.rightwrappertour');
150      //   $('.sidebar_second').remove();
151      //   $('.main-content').removeClass('col-md-9');
152      // }
153
154      // Custom code for Glide videos to refresh when tabbing
155      $('button[role="tab"]').on('shown.bs.tab', function (e) {        
156        window.dispatchEvent(new Event('resize'));
157      });
158
159      // Custom code for image hoverover
160      $('img[data-hover]', context).each(function () {
161        $(this).mouseenter(function () {
162          var hoverimage = $(this).attr('data-hover');
163          $(this).attr('src', hoverimage);
164        });
165   
166        $(this).mouseleave(function () {
167          var srcimage = $(this).attr('data-src');
168          $(this).attr('src', srcimage);
169        }).mouseleave();
170      });
171
172      
173    }
174  };
175
176})(jQuery, Drupal);

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.