Files
structural_pages/js/structural_pages_select2.js
Quintino A. G. Souza 36c3a2e9c0 Altera lógica de Site Section e adiciona redirect em content_page
- Adiciona campo field_redirect_link (link) no bundle content_page;
  EventSubscriber emite redirect 301 quando o campo está preenchido
- field_site_section passa a ser obrigatório
- Formulário de content_page: AJAX no site section, select hierárquico
  de página pai filtrado por seção, validação customizada
- StructuralPagesMenuBlock: MAX_DEPTH 10→50, nova lógica de raiz via
  field_site_section, variável ancestor_url no render array
- Template do menu: novas classes BEM/Gva, suporte a is_redirect,
  usa ancestor_url em vez de chamada Twig direta
- CSS do menu reescrito com estilos flyout/sidebar; Select2 adicionado
  para o campo de página pai no formulário admin
- display_submitted desabilitado no tipo content_page

Co-Authored-By: Bauer <henrique@webcontent.com.br>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-03 08:04:43 -03:00

35 lines
1.3 KiB
JavaScript

(function ($, Drupal, once) {
Drupal.behaviors.structuralPagesSelect2 = {
attach: function (context, settings) {
function initSelect2() {
var elements = once('structural-pages-select2', 'select.select2-widget', context);
if (elements.length) {
var $select = $(elements);
// If the select2 jQuery plugin is loaded (by another module/theme), use it.
// Otherwise, try chosen if it's there.
if (typeof $.fn.select2 !== 'undefined') {
$select.select2({
width: '100%',
dropdownAutoWidth: true
});
}
else if (typeof $.fn.chosen !== 'undefined') {
$select.chosen({
width: '100%',
search_contains: true
});
}
}
}
// Initialize on load
initSelect2();
// Some admin themes replace select elements entirely. This ensures we hook in.
$(document).on('ajaxComplete', function () {
initSelect2();
});
}
};
})(jQuery, Drupal, once);