PageSourceSearch

https://www.patrimonionacional.es/themes/custom/patrimonio/js/patrimonio.js?v=2.4.x

js patrimonionacional.es collected 2026-09-24 08:54:28 UTC 10,378 bytes, 256 lines download raw bytes

1(function ($, Drupal, drupalSettings) {
2
3  Drupal.behaviors.responsiveHeader = {
4    attach: function (context, settings) {
5
6      $('.region-sidebar-first .main-menu .collapse').each(function () {
7        var submenuMenu = $(this).html();
8        if ($("#block-patrimonio-main-menu .navbar-collapse .responsive-submenu-menu").length == 0) {
9          $("#block-patrimonio-main-menu .navbar-collapse").append('<div class="responsive-submenu-menu"></div>');
10          $("#block-patrimonio-main-menu .navbar-collapse .responsive-submenu-menu").empty();
11          $("#block-patrimonio-main-menu .navbar-collapse .responsive-submenu-menu").append(submenuMenu);
12        }
13      });
14
15      $('#block-secondarymenu').each(function () {
16        var secondaryMenu = $(this).html();
17        if ($("#block-patrimonio-main-menu .navbar-collapse .responsive-secondary-menu").length == 0) {
18          $("#block-patrimonio-main-menu .navbar-collapse").append('<div class="responsive-secondary-menu"></div>');
19          $("#block-patrimonio-main-menu .navbar-collapse .responsive-secondary-menu").empty();
20          $("#block-patrimonio-main-menu .navbar-collapse .responsive-secondary-menu").append(secondaryMenu);
21        }
22      });
23
24      $(".region-sidebar-first .menu--secondary-menu").each(function() {
25        var secondarySubMenu = $(this).html();
26
27        if ($("#block-patrimonio-main-menu .navbar-collapse .responsive-secondary-menu .responsive-secondary-submenu").length == 0){
28           $("#block-patrimonio-main-menu .navbar-collapse  .responsive-secondary-menu").append('<div class="responsive-secondary-submenu nav"></div>');
29           $("#block-patrimonio-main-menu .navbar-collapse .responsive-secondary-submenu").empty();
30           $("#block-patrimonio-main-menu .navbar-collapse .responsive-secondary-submenu").append(secondarySubMenu);
31         }
32      });
33
34    }
35  };
36
37  Drupal.behaviors.dropdownActiveOpen = {
38    attach: function (context, settings) {
39
40      $('.dropdown-menu a.is-active').each(function () {
41        $(this).closest('.dropdown-menu').addClass('is-showed');
42      });
43
44    }
45  };
46
47  Drupal.behaviors.carouselHome = {
48    attach: function (context, settings) {
49
50      function carouselImageToBackground() {
51        $('.field--name-field-home-carousel .paragraph--type--__carousel-image img').each(function () {
52          $(this).css('display', 'none');
53          var imageUrl = $(this).attr('src');
54          $(this).closest('.field--name-field-home-carousel .paragraph--type--__carousel-image').css('background', 'url("' + imageUrl + '") no-repeat center center / cover');
55        });
56      }
57
58      $(function () {
59        carouselImageToBackground();
60      });
61
62    }
63  };
64
65  Drupal.behaviors.innerLists = {
66    attach: function (context, settings) {
67
68      function listImageToBackground(url) {
69
70        if ($(url).length > 0) {
71
72
73          $(url).each(function () {
74
75            var imageUrl = $(this).find('img').attr('src');
76
77            if ($(this).find('img').length !== 0) {
78              var element = $(this).find('img');
79              $.ajax({
80                url: $(this).find('img').attr('src'),
81                type: 'get',
82                async: false,
83                error: function (response) {
84                  var replace_src = "/themes/custom/patrimonio/images/load-error.png";
85                  // Again check the default image
86                  $.ajax({
87                    url: replace_src,
88                    type: 'get',
89                    async: false,
90                    success: function () {
91                      $(element).attr('src', replace_src);
92                    },
93                    error: function (response) {
94                      $(element).hide();
95                    }
96                  });
97                }
98              });
99              $(this).find('img').css('display', 'none');
100              $(this).css('background', 'rgba(0, 0, 0, 0) url("' + imageUrl + '") no-repeat center top / contain');
101            } else {
102
103              if ($(this).closest('.views-row').find('.no-foto-link').length == 0) {
104
105                if ($(this).closest('.views-row').find('.views-field-name').length != 0) {
106                  var linkHref = $(this).closest('.views-row').find('.views-field-name a').attr('href');
107                  var linkText = $(this).closest('.views-row').find('.views-field-name a').text();
108                } else {
109                  var linkHref = $(this).closest('.views-row').find('.views-field-title a').attr('href');
110                  var linkText = $(this).closest('.views-row').find('.views-field-title a').text();
111                }
112                $(this).closest('.views-row').append('<a href=' + linkHref + ' class="no-foto-link">' + linkText + '</a>');
113              }
114
115              $(this).css('background', 'rgba(0, 0, 0, 0.2) url("/themes/custom/patrimonio/images/load-error.png") no-repeat center center / 100% auto');
116            }
117
118          });
119
120        }
121
122      }
123
124      function titleHeight(url) {
125
126        if ($(url).length > 0) {
127
128          $(url).height('auto');
129          var maxHeight = -1;
130          $(url).each(function () {
131            if ($(this).height() > maxHeight) {
132              maxHeight = $(this).height();
133            }
134          });
135          if (maxHeight > 63) {
136            maxHeight = 63;
137          }
138          $(url).height(maxHeight);
139
140          if (url == '.view-expositions .views-field-title') {
141            $('.view-expositions .views-field-field-date-range').each(function () {
142              $(this).css('bottom', maxHeight + 10);
143            });
144          }
145
146          if (url == '.view-concert-serie .views-field-title') {
147            $('.view-concert-serie .views-field-field-date-range').each(function () {
148              $(this).css('bottom', maxHeight + 10);
149            });
150          }
151
152          if (url == '.view-royal-sites-magazine .views-field-title') {
153            $('.view-royal-sites-magazine .views-field-field-magazine-period').each(function () {
154              $(this).css('bottom', maxHeight + 10);
155            });
156          }
157
158          if (url == '.view-royal-collections-item .views-field-field-item-author') {
159            $('.view-royal-collections-item .views-field-title').each(function () {
160              $(this).css('bottom', maxHeight + 10);
161            });
162          }
163        }
164      }
165    }
166  };
167
168  Drupal.behaviors.alturah1 = {
169    attach: function (context, settings) {
170      if (jQuery('.sidebar-first-wrapper').length > 0) {
171        var altura = $('.page-header').outerHeight();
172        $('.sidebar-first-wrapper').css('top', '-' + altura + 'px');
173      }
174    }
175  };
176
177  Drupal.behaviors.piecesLoanCollapsible = {
178    attach: function (context, settings) {
179      jQuery('.pieces-on-loan .field--name-field-body-components .paragraph--type--piece-loan-date .panel-collapse').first().toggleClass('in');
180    }
181  }
182
183  Drupal.behaviors.searchNoResultsFound = {
184    attach: function (context, settings) {
185      if (jQuery('.view-patrimonio-search div.views-element-container').find('.view-content').length !== 0) {
186        jQuery('div.view-empty').css('display', 'none');
187      }
188    }
189  }
190
191  Drupal.behaviors.royalCollectionsArchivoGeneralPalacioMenu = {
192    attach: function (context, settings) {
193      $current_path = window.location.pathname;
194      if (($current_path != '/colecciones-reales/archivo-general-de-palacio') && ($current_path.match('^/colecciones-reales/archivo-general-de-palacio'))) {
195        $current_path_class = $current_path.split('/').slice(3, 4);
196        $('.region-sidebar-first ul.navbar-nav li.dropdown a.' + $current_path_class).closest('li.dropdown').addClass('is-active');
197        $('.region-sidebar-first ul.navbar-nav li.dropdown a.' + $current_path_class).closest('li.dropdown').find('> a').addClass('is-active');
198        $('.region-sidebar-first ul.navbar-nav li.dropdown a.' + $current_path_class).addClass('is-active');
199      }
200    }
201  }
202
203  Drupal.behaviors.royalCollectionsExpositionsActiveTrail = {
204    attach: function (context, settings) {
205      $exp_current_path = window.location.pathname;
206      if (($exp_current_path != '/colecciones-reales/exposiciones-temporales') && ($exp_current_path.match('^/colecciones-reales/exposiciones-temporales'))) {
207        $exp_current_path_class = $exp_current_path.split('/').slice(3, 4);
208        $('.region-sidebar-first ul.navbar-nav li.dropdown a.' + $exp_current_path_class).closest('li.dropdown').addClass('is-active');
209        $('.region-sidebar-first ul.navbar-nav li.dropdown a.' + $exp_current_path_class).closest('li.dropdown').find('> a').addClass('is-active');
210        $('.region-sidebar-first ul.navbar-nav li.dropdown a.' + $exp_current_path_class).addClass('is-active');
211
212        if (!$exp_current_path.match('/colecciones-reales/exposiciones/exposiciones-anteriores')) {
213          $('.region-sidebar-first .navbar-collapse ul.navbar-nav li.dropdown:first').addClass('is-active');
214          $('.region-sidebar-first .navbar-collapse ul.navbar-nav li.dropdown:first > a').addClass('is-active');
215        }
216      }
217    }
218  }
219
220  // Imagen de item de colección real: detectar ratio de la imagen
221  jQuery(document).ready(function () {
222
223    if (jQuery('.node--type-royal_collection_item.node--view-mode-full .layout--onecol-vertical').length !== 0) {
224      var imageWidth = jQuery('.node--type-royal_collection_item.node--view-mode-full .layout--onecol-vertical .image-zoom > img').width();
225      var imageHeight = jQuery('.node--type-royal_collection_item.node--view-mode-full .layout--onecol-vertical .image-zoom > img').height();
226      if (imageWidth > imageHeight) {
227        jQuery('.node--type-royal_collection_item.node--view-mode-full').addClass('image-mode-horizontal');
228      } else {
229        jQuery('.node--type-royal_collection_item.node--view-mode-full').addClass('image-mode-vertical');
230      }
231    }
232
233  const scrollIntoViewWithOffset = (selector, offset) => {
234    window.scrollTo({
235      behavior: 'smooth',
236      top:
237        selector.getBoundingClientRect().top -
238        document.body.getBoundingClientRect().top -
239        offset,
240    })
241  }
242
243  //Scroll Glossary
244  $('.letra').click(
245    (item)=> {
246      const letraId = item.target.textContent.toLowerCase();
247
248      let element = $("#"+letraId)[0];
249
250      scrollIntoViewWithOffset(element, 180);
251    }
252  );
253
254  });
255
256})(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.