PageSourceSearch

https://www.hologic.es/sites/default/files/cohesion/scripts/cohMatchHeights/coh-match-heights.js?tm4wcr

js hologic.es collected 2026-10-08 20:32:21 UTC 4,124 bytes, 133 lines download raw bytes

1(function ($, Drupal, once) {
2
3  "use strict";
4
5  Drupal.behaviors.CohesionMatchHeights = {
6
7    attach: function (context) {
8
9      var cmm = new Drupal.CohesionResponsiveBreakpoints();
10
11      // List of possible elements that could be loaded into the DOM onload
12      var loaders = [
13        'img',
14        'frame',
15        'iframe',
16        'input[type="image"]',
17        'link',
18        'script',
19        'style'
20      ];
21
22      /**
23             * Applies match height to the given and current DOM objects
24             * @param {object} settings - the settings
25             * @returns {object} the match height object
26             */
27      function cohInitMatchHeights(settings) {
28
29        var s = settings.cohesion.settings;
30        var $this = s.element;
31        var target = '';
32        var $el;
33
34        if (s && s.breakpoints && settings.cohesion && settings.cohesion.key && s.breakpoints[settings.cohesion.key] && s.breakpoints[settings.cohesion.key].target) {
35          target = s.breakpoints[settings.cohesion.key].target;
36          target = target.match(/^[.]/) ? target : '.' + target;
37        } else {
38          return;
39        }
40
41        // Should we target the children
42        if(typeof s.breakpoints[settings.cohesion.key].children !== 'undefined' && s.breakpoints[settings.cohesion.key].children === true)  {
43          $el = $(target, $this);
44        } else {
45          $el =  s.element.add(target);
46        }
47
48        // Save the current matches so we can destroy it later
49        if (typeof $this.data('currentMatchHeight') !== 'undefined') {
50
51          // If $el is the same there is not point in matching again
52          if ($this.data('currentMatchHeight') === $el) {
53            return;
54          }
55
56          cohUnsetMatchHeight($this.data('currentMatchHeight'));
57
58          // If none is set then just return as well
59          if (s.breakpoints[settings.cohesion.key].target === 'none') {
60            return;
61          }
62        }
63
64        $this.data('currentMatchHeight', $el);
65
66        return $el.matchHeight({
67          byRow: false
68        });
69      }
70
71      /**
72             * Unset match heights to just the current active DOM objects
73             * @param {type} $this
74             * @returns {undefined}
75             */
76      function cohUnsetMatchHeight($this) {
77        return $this.matchHeight({});
78      }
79
80      // Trigger match heights to update - this will be called when behaviors are reattached
81      $.fn.matchHeight._update();
82
83      $(once('coh-js-matchheights-init', '[data-coh-match-heights]', context)).each(function () {
84
85        var $this = $(this),
86          targets = $this.data('cohMatchHeights'),
87          key;
88
89        var settings = {};
90        settings.element = $this;
91        settings.breakpoints = {};
92
93        // Update the settings prior to attaching the listeners
94        for (var i = 0; i < cmm.breakpoints.length; i++) {
95
96          key = cmm.breakpoints[i].key;
97
98          // Populate all breakpoints regardless of whether the settings are set or not to simulate inheritance
99          settings.breakpoints[key] = {};
100          if (typeof targets[key] !== 'undefined') {
101
102            settings.breakpoints[key] = targets[key];
103
104            var previous = targets[key];
105
106          } else {
107
108            if (typeof cmm.breakpoints[i - 1] !== 'undefined' && typeof previous !== 'undefined') {
109              settings.breakpoints[key] = previous;
110            }
111          }
112        }
113
114        // Bind the listeners to our callback
115        cmm.addListeners(settings, cohInitMatchHeights);
116
117        // Once the ajax has finished loading AND anything else that could effect the layout (onload)
118        $(context).ajaxComplete(function (event, xhr, settings) {
119
120          $.fn.matchHeight._update();
121
122          $(loaders.toString(), context).on('load', function () {
123            // if the triggering element was a react/styled-component, don't refresh match heights.
124            if ($(this).length && this.dataset.styled !== "active") {
125              $.fn.matchHeight._update();
126            }
127          });
128        });
129      });
130    }
131  };
132
133})(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.