PageSourceSearch

https://dbr.gov.ua/theme/js/ckeditor-accordion.js?v=1.x

js dbr.gov.ua collected 2026-10-02 05:07:08 UTC 2,876 bytes, 71 lines download raw bytes

1/**
2 * @file
3 * CKEditor Accordion functionality.
4 */
5
6(function ($, Drupal, drupalSettings) {
7  'use strict';
8  Drupal.behaviors.ckeditorAccordion = {
9    attach: function (context, settings) {
10
11      // Create accordion functionality if the required elements exist is available.
12      var $ckeditorAccordion = $('.ckeditor-accordion');
13      if ($ckeditorAccordion.length > 0) {
14        // Create simple accordion mechanism for each tab.
15        $ckeditorAccordion.each(function () {
16          var $accordion = $(this);
17          if ($accordion.hasClass('styled')) {
18            return;
19          }
20
21          // The first one is the correct one.
22          if (!drupalSettings.ckeditorAccordion.accordionStyle.collapseAll) {
23            $accordion.children('dt:first').addClass('active');
24            $accordion.children('dd:first').addClass('active');
25            $accordion.children('dd:first').css('display', 'block');
26          }
27
28          // Turn the accordion tabs to links so that the content is accessible & can be traversed using keyboard.
29          $accordion.children('dt').each(function () {
30            var $tab = $(this);
31            var tabText = $tab.text().trim();
32            var toggleClass = $tab.hasClass('active') ? ' active' : '';
33            $tab.html('<span class="ckeditor-accordion-toggle' + toggleClass + '"></span><a class="ckeditor-accordion-toggler" href="#">' + tabText + '</a>');
34          });
35
36          // Wrap the accordion in a div element so that quick edit function shows the source correctly.
37          $accordion.addClass('styled').removeClass('ckeditor-accordion').wrap('<div class="ckeditor-accordion-container"></div>');
38
39          // Trigger an ckeditorAccordionAttached event to let other frameworks know that the accordion has been attached.
40          $accordion.trigger('ckeditorAccordionAttached');
41        });
42
43        // Add click event to body once because quick edits & ajax calls might reset the HTML.
44        $('body').once('ckeditorAccordionToggleEvent').on('click', '.ckeditor-accordion-toggler', function (e) {
45          var $t = $(this).parent();
46          var $parent = $t.parent();
47
48          // Clicking on open element, close it.
49          if ($t.hasClass('active')) {
50            $t.removeClass('active');
51            $t.next().slideUp();
52          }
53          else {
54            // Remove active classes.
55            $parent.children('dt.active').removeClass('active').children('a').removeClass('active');
56            $parent.children('dd.active').slideUp(function () {
57              $(this).removeClass('active');
58            });
59
60            // Show the selected tab.
61            $t.addClass('active');
62            $t.next().slideDown(300).addClass('active');
63          }
64
65          // Don't add hash to url.
66          e.preventDefault();
67        });
68      }
69    }
70  };
71})(jQuery, Drupal, drupalSettings);

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.