PageSourceSearch

https://acrobat-project.eu/themes/custom/calibr8_subtheme/scripts/scripts.js?v=1.x

js acrobat-project.eu collected 2026-10-04 13:24:53 UTC 13,041 bytes, 482 lines download raw bytes

1/**
2 * @file
3 * Calibr8 custom scripts.
4 */
5
6(function ($, Drupal) {
7
8  'use strict';
9
10  Drupal.vito = Drupal.vito || {};
11
12  var options = {};
13  if(drupalSettings.calibr8_subtheme != undefined) {
14    var options = $.extend({
15      breakpoints: {
16        'sm': drupalSettings.calibr8_subtheme.breakpoints['sm'],
17        'md': drupalSettings.calibr8_subtheme.breakpoints['md'],
18        'lg': drupalSettings.calibr8_subtheme.breakpoints['lg'],
19        'xl': drupalSettings.calibr8_subtheme.breakpoints['xl']
20      }
21    }, drupalSettings.calibr8);
22  } else {
23    // default breakpoints
24    var options = {
25      breakpoints: {
26        'sm': 'screen and (min-width: 392px)',
27        'md': 'screen and (min-width: 692px)',
28        'lg': 'screen and (min-width: 992px)',
29        'xl': 'screen and (min-width: 992px)'
30      }
31    }
32  }
33
34  // Extract the pixel value from the breakpoint
35  Drupal.vito.bpExtract = function($bp) {
36    switch ($bp) {
37      case 'sm':
38        $bp = options.breakpoints.sm;
39        break;
40      case 'md':
41        $bp = options.breakpoints.md;
42        break;
43      case 'lg':
44        $bp = options.breakpoints.lg;
45        break;
46      case 'xl':
47        $bp = options.breakpoints.xl;
48        break;
49    }
50    return $bp.substring($bp.lastIndexOf(": ")+1,$bp.lastIndexOf("px"));
51  }
52
53  /**
54   * MatchHeight settings
55   */
56  if ($.fn.matchHeight) {
57    // Under certain conditions where the size of the page is dynamically changing,
58    // such as during resize or when adding new elements,
59    // browser bugs cause the page scroll position to change unexpectedly.
60    $.fn.matchHeight._maintainScroll = true;
61    // By default, the _update method is throttled to execute at a maximum rate
62    // of once every 80ms.
63    $.fn.matchHeight._throttle = 80;
64    // Execute matchheight.
65    $.fn.matchHeight._update();
66  }
67
68  var matchHeightElements = [
69    '.equal-heights article',
70  ];
71
72  /**
73   * Media Queries
74   */
75  var mobileQuery = 'screen and (max-width:' + (Drupal.vito.bpExtract(options.breakpoints.md) - 1) + 'px)';
76  var nonMobileQuery = options.breakpoints.md;
77
78  /**
79   * Offcanvas Menu
80   */
81  Drupal.behaviors.offcanvasMenu = {
82    attach: function (context, settings) {
83      $('.mobile-menu-anchor').off().on('click', function(evt) {
84        evt.preventDefault();
85        $('#site-wrapper').toggleClass('offcanvas');
86        $('.region--navigation').css('height', $('#site-wrapper').height());
87      });
88
89      // Close menu
90      $(document).on('click', '.offcanvas .region--navigation a', function() {
91        $('#site-wrapper').removeClass('offcanvas');
92      });
93    }
94  }
95
96  /**
97   * Paragraph: Collapse
98   */
99  Drupal.behaviors.paragraphCollapse = {
100    attach: function (context, settings) {
101      var $title = $('.paragraph--type--collapse-item .field--name-field-title');
102
103      // Toggle Item
104      $title.off().on('click', function() {
105        $(this).closest('.paragraph').toggleClass('open');
106        $(this).next().slideToggle();
107      });
108
109      // Toggle All Items
110      $('.paragraph--type--collapse').each(function() {
111        var $this = $(this);
112
113        $('.vito--toggle-all-collapse', $this).off().on('click', function() {
114          var $text = $('.field--name-field-text', $this),
115              $item = $('.paragraph--type--collapse-item', $this);
116
117          if($('.paragraph--type--collapse-item:not(.open)', $this).length == 0) {
118            $text.slideUp();
119            $item.removeClass('open');
120          } else {
121            $item.addClass('open');
122            $text.slideDown();
123          }
124        });
125      });
126    }
127  }
128
129  /**
130   * Paragraph: Image Masonry
131   * (https://masonry.desandro.com)
132   */
133  Drupal.behaviors.paragraphMasonry = {
134    attach: function(context, settings) {
135      var $masonry = $('.paragraph-masonry .vito--paragraph-content > .field__items');
136
137      // Initialize Masonry
138      $masonry.masonry();
139
140      // Re-initialize for backend pages because of fadeIn effect on .node-form
141      if($('body').hasClass('vito--admin-edit') || $('body').hasClass('vito--admin-add')) {
142        setTimeout(function() {
143          $masonry.masonry();
144        }, 400);
145      }
146    }
147  }
148
149  /**
150   * Scroll to Top
151   */
152  Drupal.vito.scrollToTop = {
153    init: function() {
154
155      $(window).scroll(function () {
156        if ($(window).scrollTop() > $(window).height() / 2) {
157          $('.vito--back-to-top').fadeIn();
158        } else {
159          $('.vito--back-to-top').fadeOut();
160        }
161      });
162
163      $('.vito--back-to-top').on('click', function() {
164        $('html, body').animate({
165          scrollTop: 0
166        }, 300);
167      });
168    }
169  }
170
171  /**
172   * Anchor Links
173   */
174  Drupal.vito.anchorLinks = {
175    init: function() {
176      var height = 32;
177
178      if($('body').hasClass('vito--sticky-header')) {
179        var height = $('.region--header').outerHeight() + 32;
180      }
181
182       //Window Load
183      if(window.location.hash) {
184        var hash = window.location.hash.substring(1);
185
186        $('html, body').animate({
187          scrollTop: $('#'+hash+'').offset().top - height
188        }, 300);
189      }
190
191      //Anchor Click
192      if(!$('body').hasClass('vito--admin-edit') && !$('body').hasClass('vito--admin-add')) {
193        $('a[href*="#"]').on('click', function(evt) {
194          var val = $(this).attr('href');
195
196          if(val != '#') {
197            var id = val.substr(val.indexOf('#') + 1);
198
199            // Scroll to ID if available on current page
200            if($('#'+id+'').length) {
201              evt.preventDefault();
202              $('html, body').animate({
203                scrollTop: $('#'+id+'').offset().top - height
204              }, 300);
205            }
206          }
207        });
208      }
209    }
210  }
211
212  /**
213   * Header Search
214   */
215  Drupal.behaviors.headerSearch = {
216    attach: function (context, settings) {
217      var $form = $('.search-block-form');
218
219      // Toggle search bar
220      $('.open-search-header, .close-search-header').off().on('click', function(evt) {
221        $form.toggleClass('open');
222      });
223    },
224  }
225
226  /**
227   * Sticky Header
228   */
229  Drupal.vito.stickyHeader = {
230    init: function() {
231      var $header   = $('.vito--sticky-header .region--header'),
232          $wrapper  = $('#site-wrapper');
233
234      if(Drupal.vito.width() >
234  Drupal.vito.bpExtract(options.breakpoints.md)) {
235        $wrapper.css('padding-top', $header.outerHeight());
236      } else {
237        $wrapper.css('padding-top', '');
238      }
239    },
240    scroll: function() {
241      var $header   = $('.vito--sticky-header .region--header'),
242          offset    = $(document).scrollTop();
243
244      if(offset > 48) { // 48 = 3rem
245        $header.addClass('minified');
246      } else {
247        $header.removeClass('minified');
248      }
249    }
250  }
251
252  Drupal.vito.adminHome = {
253    init: function() {
254      var $link = $('.toolbar-icon-escape-admin');
255      $link.text('Home');
256    }
257  }
258
259  /**
260   * Sticky Sidebar
261   */
262  Drupal.vito.stickySidebar = {
263    init: function() {
264      var $sidebar      = $('.sidebar-sticky'),
265          $window       = $(window),
266          $body         = $('body'),
267          offset        = $sidebar.offset(),
268          topPadding    = 40,
269          bottomPadding = 40,
270          marginTop     = 40,
271          sticky        = 0,
272          $content      = $('.region--content');
273
274      if($body.hasClass('vito--page-type-article')) {
275        marginTop = 84;
276      }
277
278      if(!$sidebar.hasClass('element-hidden')) {
279        $window.scroll(function() {
280          // Add header height into calculations
281          if($('body').hasClass('vito--sticky-header')) {
282            sticky = $('.region--header').outerHeight();
283          }
284          if($body.hasClass('vito--page-type-article')) {
285            if($sidebar.length > 0 && ((parseInt($sidebar.css('margin-top')) + $sidebar.height()) <= $content.height())) {
286              if ($window.scrollTop() + sticky + marginTop > offset.top - topPadding) {
287                $sidebar.stop().animate({
288                  marginTop: (Math.min($content.height() - $sidebar.height() - bottomPadding, Math.max(0, $window.scrollTop() - offset.top + sticky + (topPadding * 2))) - marginTop)
289                }, 0);
290              } else {
291                $sidebar.stop().animate({
292                  marginTop: -marginTop
293                }, 0);
294              }
295            }
296          } else {
297            if($sidebar.length > 0 && ((parseInt($sidebar.css('margin-top')) + $sidebar.height()) <= $content.height())) {
298              if ($window.scrollTop() + sticky + marginTop > offset.top - topPadding) {
299                $sidebar.stop().animate({
300                  marginTop: (Math.min($content.height() - $sidebar.height() - bottomPadding, Math.max(0, $window.scrollTop() - offset.top + sticky + (topPadding * 2))) + marginTop)
301                }, 0);
302              } else {
303                $sidebar.stop().animate({
304                  marginTop: marginTop
305                }, 0);
306              }
307            }
308          }
309
310        });
311      }
312    }
313  }
314
315  /**
316   * Sticky Footer
317   */
318  Drupal.vito.stickyFooter = {
319    init: function() {
320      var $footer   = $('.footer'),
321          $wrapper  = $('#site-wrapper');
322
323      if(Drupal.vito.width() >  Drupal.vito.bpExtract(options.breakpoints.md)) {
324        var $footerHeight = $footer.height();
325
326        $wrapper.css('padding-bottom', $footerHeight);
327        $footer.css('opacity', '1');
328
329        if(!$('body').hasClass('vito--page-type-article')) {
330          if($('.field--paragraphs > .paragraph--type--section:last-child').length == 1) {
331            $wrapper.css('padding-bottom', ($footer.height() - 80));
332
333            if($('.region--footer-cta').length == 1) {
334              $wrapper.css('padding-bottom', ($footer.height() - 32));
335            }
336          }
337          if($('.field--paragraphs > [class*="background--"]:last-child').length == 1) {
338            $wrapper.css('padding-bottom', ($footer.height() - 32));
339          }
340        }
341      }
342    }
343  }
344
345  /**
346   * Initialize wow.js
347   */
348  Drupal.vito.wowAnimations = {
349    init: function() {
350      new WOW().init();
351    }
352  }
353
354  /**
355   * Status Messages
356   */
357  Drupal.behaviors.messages = {
358    attach: function(context, settings) {
359      $('.messages--close-message').on('click', function() {
360        $(this).parent().remove();
361      });
362
363      // Close message automatically after set time
364      setTimeout(function(){
365        $('.messages--status').fadeOut();
366      }, 4000);
367    }
368  }
369
370  /**
371   * User login tabs
372   */
373  Drupal.behaviors.userLogin = {
374    attach: function(context, settings) {
375      var $blocks = $('.region--page-user .block');
376      var $tabs = $('.region--content-user-tabs li a');
377
378      $tabs.on('click', function(e) {
379        var i = $(this).parent().index();
380
381        // Update tabs
382        $('li.active').removeClass('active');
383        $(this).parent().addClass('active');
384
385        // Toggle Content
386        $blocks.hide();
387        $blocks.each(function(index) {
388          if(index == i) {
389            $(this).show();
390          }
391        });
392      });
393    }
394  }
395
396  /**
397   * Tippy tooltips
398   * (https://atomiks.github.io/tippyjs)
399   */
400  //Drupal.behaviors.tippyTooltip = {
401  //  attach: function(context, settings) {
402  //    tippy('img, button, input', {
403  //      arrow: true,
404  //    });
405  //  }
406  //}
407
408
409  /**
410   * CSS media queries do not add the scrollbar to the width of the window,
411   * however the default way in JavaScript does. Not all browsers support the
412   * innerWidth method, so return with a fallback.
413   */
414  Drupal.vito.width = function() {
415    var e = window, a = 'inner';
416    if (!('innerWidth' in window )) {
417      a = 'client';
418      e = document.documentElement || document.body;
419    }
420    return e[ a+'Width' ];
421  };
422
423
424  /**
425   * Initialize Enquire
426   */
427  if (typeof enquire !== 'undefined') {
428    enquire.register(mobileQuery, {
429
430      match : function() {
431      },
432
433      unmatch : function() {
434      },
435
436      setup : function() {},
437      deferSetup : true,
438
439      destroy : function() {}
440
441    }).register(nonMobileQuery, {
442      match : function() {
443        $(matchHeightElements.join(', ')).matchHeight({ byRow: true, property: 'min-height' });
444        Drupal.vito.stickySidebar.init();
445      },
446
447      unmatch : function() {
448        $(matchHeightElements.join(', ')).matchHeight({ property: 'min-height', remove: true });
449      },
450
451      setup : function() {},
452      deferSetup : true,
453
454      destroy : function() {}
455
456    });
457  }
458
459  // Window Load
460  $(window).on('load', function() {
461    Drupal.vito.stickyFooter.init();
462    //Drupal.vito.paragraphSlider.init();
463    Drupal.vito.scrollToTop.init();
464    Drupal.vito.anchorLinks.init();
465    Drupal.vito.stickyHeader.init();
466    Drupal.vito.adminHome.init();
467    Drupal.vito.wowAnimations.init();
468  });
469
470  // Window Resize
471  $(window).on('resize', function() {
472    Drupal.vito.stickyFooter.init();
473    //Drupal.vito.paragraphSlider.init();
474    Drupal.vito.stickyHeader.init();
475  });
476
477  // Window Scroll
478  $(window).on('scroll', function() {
479    Drupal.vito.stickyHeader.scroll();
480  });
481
482})(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.