1$(document).ready(function() 2{ 3 $.widget( "custom.bsautocomplete", $.ui.autocomplete, { 4 _renderMenu: function( ul, items ) { 5 var that = this, 6 currentCategory = ""; 7 $.each( items, function( index, item ) { 8 var li; 9 if ( item.type !== "" && item.type !== currentCategory && item.type !== "too_ambiguous" && item.type !== "no_results_found" ) { 10 ul.append( "<li class='ui-autocomplete-category'>" 11 + "<span class='autocomplete-icon-" + item.type + "'></span>" 12 + item.type_name 13 + "<span class='autocomplete-total-count' title='" + item.show_all_text + "'>" 14 + (BS.Design.template.is_selected("palladium") 15 ? item.show_all_text + " (" + $(".ui-autocomplete").data("total_" + item.type) + ")" 16 : $(".ui-autocomplete").data("total_" + item.type)) 17 + "</span></li>" ); 18 currentCategory = item.type; 19 } 20 li = that._renderItemData( ul, item ); 21 }); 22 }, 23 _renderItem: function( ul, item ) { 24 var $item_html = ''; 25 if (item.type !== "too_ambiguous" && item.type !== "no_results_found") 26 { 27 $item_html += '<a style="width: auto;">'; 28 if (item.type === "product") 29 { 30 if(!BS.Design.template.is_selected(BS.Design.templates.TEMPLATE_KRYPTON) 31 && !BS.Design.template.is_selected(BS.Design.templates.TEMPLATE_KRYPTONIT) 32 && !BS.Design.template.is_selected(BS.Design.templates.TEMPLATE_THORIUM)) 33 { 34 $item_html += '<div class="ui-autocomplete-price">' + item.price + '</div>'; 35 } 36 $item_html += '<div class="ui-autocomplete-image"><span class="ui-autocomplete-image-helper"></span><img style="" src="' + item.image + '"></div>'; 37 $item_html += '<div class="ui-autocomplete-text">' 38 $item_html += '<span class="ui-autocomplete-text-title">'; 39 $item_html += item.name; 40 $item_html += '</span>'; 41 $item_html += '<span class="ui-autocomplete-text-desc">' + item.desc + '</span>'; 42 if(BS.Design.template.is_selected(BS.Design.templates.TEMPLATE_THORIUM)) 43 { 44 $item_html += '<div class="ui-autocomplete-price">' + item.price + '</div>'; 45 } 46 $item_html += '</div>'; 47 if(BS.Design.template.is_selected(BS.Design.templates.TEMPLATE_KRYPTON) 48 || BS.Design.template.is_selected(BS.Design.templates.TEMPLATE_KRYPTONIT)) 49 { 50 $item_html += '<div class="ui-autocomplete-price">' + item.price + '</div>'; 51 } 52 } 53 else 54 { 55 $item_html += item.name; 56 } 57 $item_html += '</a>'; 58 } 59 else 60 { 61 $item_html += '<span class="ui-autocomplete-no-results">'; 62 if (item.type === "no_results_found") 63 { 64 $item_html += WA.Translation._autocompleter_no_results_found; 65 } 66 else 67 { 68 $item_html += WA.Translation._autocompleter_ambiguous_query; 69 } 70 $item_html += '</span>'; 71 } 72 return $( '<li class="ui-autocomplete-row ui-autocomplete-row-' + item.type + '">' ) 73 .append( $item_html ) 74 .appendTo( ul ); 75 } 76 }); 77 78 if ($("#responsive_layout_large").css("display") !== "none") 79 { 80 $( "#q" ).bsautocomplete({ 81 minLength: 3, 82 delay: 500, 83 source: function($autocomplete_request, response) 84 { 85 var $exact_phrase = 0; 86 if ($("#search_exact_phrase").length > 0 && $("#search_exact_phrase").is(":checked")) 87 { 88 var $exact_phrase = 1; 89 } 90 91 $source_service = $( "#source_service" ).val(); 92 93 $request = BS.extend(BS.Request.$default, { 94 data: { action: 'Search_autocompleter', id_zakaznik: BS.User.id, term: $autocomplete_request["term"], exact_phrase: $exact_phrase, source_service:$source_service }, 95 timeout: 2000, 96 success: function($data) 97 { 98 BS.Fce.hide_top_bar_loading(); 99 $(".ui-autocomplete").data("total_category", $data.total_categories); 100 $(".ui-autocomplete").data("total_product", $data.total_products); 101 if ($data.found_items.length === 0) 102 { 103 var result = [{type: 'no_results_found'}]; 104 response(result); 105 } 106 else 107 { 108 response($data.found_items); 109 } 110 }, 111 error: function() 112 { 113 BS.Fce.hide_top_bar_loading(); 114 var result = [{type: 'too_ambiguous'}]; 115 response(result); 116 } 117 }); 118 $.ajax($request); 119 }, 120 select: function( event, ui ) 121 { 122 self.location.href = ui.item.url; 123 }, 124 open: function() 125 { 126 BS.Fce.call_conversion_request('search', { search_term: $("#q").val()}); 127 var autocomplete = $(".ui-autocomplete"); 128 autocomplete.addClass("search_autocomplete"); 129 if (BS.User.is_responsive_layout) 130 { 131 autocomplete.css("top", $(".ui-autocomplete-input").offset().top + $(".ui-autocomplete-input").height() + 13); 132 } 133 else 134 { 135 autocomplete.css("top", $(".ui-autocomplete-input").offset().top + $(".ui-autocomplete-input").height() + 5); 136 } 137 }, 138 search: function() 139 { 140 $search_query = $( "#q" ).val(); 141 $search_query_length = 0; 142 $search_query_word_count = 0; 143 144 if ($search_query != "") 145 { 146 $search_query_length = $( "#q" ).val().length; 147 148 $query_splitted = $( "#q" ).val().split(' '); 149 $search_query_word_count = $query_splitted.length; 150 } 151 152 if ( $search_query == "" 153 || $search_query_length > BS.User.max_search_query_length 154 || $search_query_word_count > BS.User.max_autocomplete_words_count ) 155 { 156 $(".ui-autocomplete").hide(); 157 return false;
158 } 159 BS.Fce.show_top_bar_loading(); 160 }, 161 response: function() 162 { 163 BS.Fce.hide_top_bar_loading(); 164 } 165 }); 166 } 167 168 $(".eshop_search_type").change(function() 169 { 170 var $search_type_val = ""; 171 if ($(".eshop_search_type").is("select")) 172 { 173 $search_type_val = $(".eshop_search_type").val(); 174 } 175 else 176 { 177 $search_type_val = $(".eshop_search_type:checked").val(); 178 } 179 180 if ($search_type_val === "2") 181 { 182 $( "#q" ).bsautocomplete("enable"); 183 } 184 else 185 { 186 $( "#q" ).bsautocomplete("disable"); 187 } 188 }); 189 190 $("body").delegate(".autocomplete-total-count", "click", function() 191 { 192 if (BS.User.is_responsive_layout) 193 { 194 $(".search_submit").click(); 195 } 196 else 197 { 198 $("#form_eshop_search").submit(); 199 } 200 return false; 201 }); 202});
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.