1(function ($, Drupal, once) { 2 Drupal.behaviors.customDropdown = { 3 attach: function (context, settings) { 4 // Forms 5 const $elements = $( 6 once( 7 "customDropdown", 8 ".bef-exposed-form:not(.recherche--equivalences) select.form-select, .custom-select", 9 context 10 ) 11 ); 12 $elements.each(function () { 13 var $this = $(this), 14 numberOfOptions = $(this).children("option").length, 15 selectedOption = $(this).prop("selectedIndex"); 16 17 $this.addClass("select-hidden"); 18 $this.wrap('<div class="select"></div>'); 19 $this.after('<div class="select-styled"></div>'); 20 21 var svg = 22 '<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="32px" height="32px" viewBox="0 0 32 32" enable-background="new 0 0 32 32" xml:space="preserve"><path d="M3.75,6.125L16,18.313L28.25,6.125L32,9.875l-16,16l-16-16L3.75,6.125z"/></svg>'; 23 var $styledSelect = $this.next("div.select-styled"); 24 $styledSelect 25 .text($this.children("option").eq(selectedOption).text()) 26 .append(svg); 27 28 var $list = $("<ul />", { 29 class: "select-options", 30 }).insertAfter($styledSelect); 31 32 for (var i = 0; i < numberOfOptions; i++) { 33 $("<li />", { 34 text: $this.children("option").eq(i).text(), 35 rel: $this.children("option").eq(i).val(), 36 }).appendTo($list); 37 } 38 39 var $listItems = $list.children("li"); 40 41 $styledSelect.on("click", function (e) { 42 e.stopPropagation(); 43 $("div.select-styled.active") 44 .not(this) 45 .each(function () { 46 $(this).removeClass("active").next("ul.select-options").hide(); 47 }); 48 $(this).toggleClass("active").next("ul.select-options").toggle(); 49 }); 50 51 $listItems.on("click", function (e) { 52 e.stopPropagation(); 53 $styledSelect.text($(this).text()).append(svg).removeClass("active"); 54 $this.val($(this).attr("rel")); 55 if ( 56 $this.closest("form").attr("data-bef-auto-submit-full-form") == "" 57 ) { 58 $this.closest("form").trigger("submit"); 59 } 60 $this.trigger("change"); 61 $list.hide(); 62 }); 63 64 $(document).on("click", function () { 65 $styledSelect.removeClass("active"); 66 $list.hide(); 67 }); 68 }); 69 }, 70 }; 71})(jQuery, Drupal, once);
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.