1(function (jQuery, Drupal, drupalSettings) { 2 Drupal.behaviors.servizi_toscana_autocomplete = { 3 4 mouse_is_inside : false, 5 already_attached : false, 6 7 attach: function (context, settings) { 8 if(!Drupal.behaviors.servizi_toscana_autocomplete.already_attached){ 9 Drupal.behaviors.servizi_toscana_autocomplete.already_attached = true; 10 jQuery(document).on("click",function(e) { 11 if(Drupal.behaviors.servizi_toscana_autocomplete.mouse_is_inside == false){ 12 jQuery('#autocompletami').html(""); 13 } 14 }); 15 } 16 17 jQuery(once('link-to-main-page-ricerca','#link-to-main-page-ricerca',context)).on("click",function(event) { 18 // The id of the section we want to go to. 19 var id = "#main-page-ricerca"; 20 21 // An offset to push the content down from the top. 22 var offset = 60; 23 24 // Our scroll target : the top position of the 25 // section that has the id referenced by our href. 26 var target = jQuery(id).offset().top - offset; 27 28 // The magic...smooth scrollin' goodness. 29 jQuery('html, body').animate({scrollTop:target}, 500); 30 31 //prevent the page from jumping down to our section. 32 event.preventDefault(); 33 }); 34 35 jQuery(once('searchfield-mostwanted-click','.mostWanted',context)).on("click",function(event) { 36 var target = event.target || event.srcElement; 37 jQuery('#ricerca').val(""); 38 jQuery('#autocomplete').val(target.innerHTML); 39 jQuery('.autocompleteid').val(jQuery(target).data("id")); 40 jQuery('#autocompletami').html(""); 41 jQuery('#searchBtn').trigger("click"); 42 }); 43 44 jQuery(once('searchfield-keyup-click','#ricerca',context)).on("keyup",function(e) { 45 if((e.keyCode) == 13){ 46 jQuery('#searchBtn').trigger("click"); 47 jQuery('#autocompletami').html(""); 48 jQuery('.form-item-autocomplete').removeClass('d-flex'); 49 jQuery('.form-item-autocomplete').hide(); 50 jQuery('.form-item-ricerca').show(); 51 return; 52 } 53 54 if((e.keyCode) == 27){ 55 jQuery('#autocompletami').html(""); 56 return; 57 } 58 59 var term = jQuery('#ricerca').val(); 60 jQuery.ajax({ 61 dataType: "json", 62 url: "/servizi/autocompletamento" , 63 data: { q: term }, 64 success: function (data) { 65 var content = ""; 66 var i = 0; 67 if(data.length >0){ 68 content = "<div class='autocompleteItemList'>"; 69 for(;data[i];) { 70 content += "<div class='autocompleteItem' data-id='" + data[i]['id'] + "'>" + data[i]['name'] + "</div>" ; 71 i++; 72 } 73 content += "</div>"; 74 } 75 jQuery('#autocompletami').html(content); 76 jQuery('.autocompleteItem').on("click",function(event) { 77 var target = event.target || event.srcElement; 78 jQuery('#ricerca').val(""); 79 jQuery('#autocomplete').val(target.innerHTML); 80 // jQuery('.form-item-ricerca').hide(); 81 // jQuery('.form-item-autocomplete').addClass('d-flex'); 82 jQuery('.autocompleteid').val(jQuery(target).data("id")); 83 jQuery('#autocompletami').html(""); 84 jQuery('#searchBtn').trigger("click"); 85 }); 86 jQuery(".autocompleteItemList").on("mouseenter",function(e){ 87 Drupal.behaviors.servizi_toscana_autocomplete.mouse_is_inside = true; 88 }); 89 90 jQuery(".autocompleteItemList").on("mouseleave",function(e){ 91 Drupal.behaviors.servizi_toscana_autocomplete.mouse_is_inside = false;
92 }); 93 94 } 95 }); 96 }); 97 } 98 }; 99 })(jQuery, Drupal, drupalSettings); 100;
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.