PageSourceSearch

https://www.10joursenmai.fr/core/modules/contextual/js/contextual.js?v=9.5.11

js 10joursenmai.fr collected 2026-10-02 11:55:49 UTC 5,550 bytes, 152 lines download raw bytes

1/**
2* DO NOT EDIT THIS FILE.
3* See the following change record for more information,
4* https://www.drupal.org/node/2815083
5* @preserve
6**/
7(function ($, Drupal, drupalSettings, _, Backbone, JSON, storage) {
8  var options = $.extend(drupalSettings.contextual, {
9    strings: {
10      open: Drupal.t('Open'),
11      close: Drupal.t('Close')
12    }
13  });
14  var cachedPermissionsHash = storage.getItem('Drupal.contextual.permissionsHash');
15  var permissionsHash = drupalSettings.user.permissionsHash;
16  if (cachedPermissionsHash !== permissionsHash) {
17    if (typeof permissionsHash === 'string') {
18      _.chain(storage).keys().each(function (key) {
19        if (key.substring(0, 18) === 'Drupal.contextual.') {
20          storage.removeItem(key);
21        }
22      });
23    }
24    storage.setItem('Drupal.contextual.permissionsHash', permissionsHash);
25  }
26  function adjustIfNestedAndOverlapping($contextual) {
27    var $contextuals = $contextual.parents('.contextual-region').eq(-1).find('.contextual');
28    if ($contextuals.length <= 1) {
29      return;
30    }
31    var firstTop = $contextuals.eq(0).offset().top;
32    var secondTop = $contextuals.eq(1).offset().top;
33    if (firstTop === secondTop) {
34      var $nestedContextual = $contextuals.eq(1);
35      var height = 0;
36      var $trigger = $nestedContextual.find('.trigger');
37      $trigger.removeClass('visually-hidden');
38      height = $nestedContextual.height();
39      $trigger.addClass('visually-hidden');
40      $nestedContextual.css({
41        top: $nestedContextual.position().top + height
42      });
43    }
44  }
45  function initContextual($contextual, html) {
46    var $region = $contextual.closest('.contextual-region');
47    var contextual = Drupal.contextual;
48    $contextual.html(html).addClass('contextual').prepend(Drupal.theme('contextualTrigger'));
49    var destination = "destination=".concat(Drupal.encodePath(Drupal.url(drupalSettings.path.currentPath + window.location.search)));
50    $contextual.find('.contextual-links a').each(function () {
51      var url = this.getAttribute('href');
52      var glue = url.indexOf('?') === -1 ? '?' : '&';
53      this.setAttribute('href', url + glue + destination);
54    });
55    var title = '';
56    var $regionHeading = $region.find('h2');
57    if ($regionHeading.length) {
58      title = $regionHeading[0].textContent.trim();
59    }
60    var model = new contextual.StateModel({
61      title: title
62    });
63    var viewOptions = $.extend({
64      el: $contextual,
65      model: model
66    }, options);
67    contextual.views.push({
68      visual: new contextual.VisualView(viewOptions),
69      aural: new contextual.AuralView(viewOptions),
70      keyboard: new contextual.KeyboardView(viewOptions)
71    });
72    contextual.regionViews.push(new contextual.RegionView($.extend({
73      el: $region,
74      model: model
75    }, options)));
76    contextual.collection.add(model);
77    $(document).trigger('drupalContextualLinkAdded', Drupal.deprecatedProperty({
78      target: {
79        $el: $contextual,
80        $region: $region,
81        model: model
82      },
83      deprecatedProperty: 'model',
84      message: 'The model property is deprecated in drupal:9.4.0 and is removed from drupal:11.0.0. There is no replacement.'
85    }));
86    adjustIfNestedAndOverlapping($contextual);
87  }
88  Drupal.behaviors.contextual = {
89    attach: function attach(context) {
90      var $context = $(context);
91      var $placeholders = $(once('contextual-render', '[data-contextual-id]', context));
92      if ($placeholders.length === 0) {
93        return;
94      }
95      var ids = [];
96      $placeholders.each(function () {
97        ids.push({
98          id: $(this).attr('data-contextual-id'),
99          token: $(this).attr('data-contextual-token')
100        });
101      });
102      var uncachedIDs = [];
103      var uncachedTokens = [];
104      ids.forEach(function (contextualID) {
105        var html = storage.getItem("Drupal.contextual.".concat(contextualID.id));
106        if (html && html.length) {
107          window.setTimeout(function () {
108            initContextual($context.find("[data-contextual-id=\"".concat(contextualID.id, "\"]:empty")).eq(0), html);
109          });
110          return;
111        }
112        uncachedIDs.push(contextualID.id);
113        uncachedTokens.push(contextualID.token);
114      });
115      if (uncachedIDs.length > 0) {
116        $.ajax({
117          url: Drupal.url('contextual/render'),
118          type: 'POST',
119          data: {
120            'ids[]': uncachedIDs,
121            'tokens[]': uncachedTokens
122          },
123          dataType: 'json',
124          success: function success(results) {
125            _.each(results, function (html, contextualID) {
126              storage.setItem("Drupal.contextual.".concat(contextualID), html);
127              if (html.length > 0) {
128                $placeholders = $context.find("[data-contextual-id=\"".concat(contextualID, "\"]"));
129                for (var i = 0; i < $placeholders.length; i++) {
130                  initContextual($placeholders.eq(i), html);
131                }
132              }
133            });
134          }
135        });
136      }
137    }
138  };
139  Drupal.contextual = {
140    views: [],
141    regionViews: []
142  };
143  Drupal.contextual.collection = new Backbone.Collection([], {
144    model: Drupal.contextual.StateModel
145  });
146  Drupal.theme.contextualTrigger = function () {
147    return '<button class="trigger visually-hidden focusable" type="button"></button>';
148  };
149  $(document).on('drupalContextualLinkAdded', function (event, data) {
150    Drupal.ajax.bindAjaxLinks(data.$el[0]);
151  });
152})(jQuery, Drupal, drupalSettings, _, Backbone, window.JSON, window.sessionStorage);

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.