1(function ($) { 2 $.widget("custom.combobox", { 3 _create: function () { 4 this.wrapper = $("<span>") 5 .addClass("custom-combobox") 6 .insertAfter(this.element); 7 this.element.hide(); 8 this._createAutocomplete(); 9 this._createShowAllButton(); 10 }, 11 _createAutocomplete: function () { 12 var selected = this.element.children(":selected"), 13 value = selected.val() ? selected.text() : ""; 14 this.input = $("<input>") 15 .appendTo(this.wrapper) 16 .val(value) 17 .attr("title", "") 18 .addClass("custom-combobox-input ui-widget ui-widget-content ui-state-default ui-corner-left") 19 .autocomplete({ 20 delay: 0, 21 minLength: 0, 22 source: $.proxy(this, "_source") 23 }) 24 .tooltip({ 25 tooltipClass: "ui-state-highlight" 26 }); 27 this._on(this.input, { 28 autocompleteselect: function (event, ui) { 29 ui.item.option.selected = true; 30 this._trigger("select", event, { 31 item: ui.item.option 32 }); 33 }, 34 autocompletechange: "_removeIfInvalid" 35 }); 36 }, 37 _createShowAllButton: function () { 38 var input = this.input, 39 wasOpen = false; 40 $("<a>") 41 .attr("tabIndex", -1) 42 .attr("title", "Show All Items") 43 .tooltip() 44 .appendTo(this.wrapper) 45 .button({ 46 icons: { 47 primary: "ui-icon-carat-2-n-s" 48 }, 49 text: false 50 }) 51 .removeClass("ui-corner-all") 52 .addClass("custom-combobox-toggle ui-corner-right") 53 .mousedown(function () { 54 wasOpen = input.autocomplete("widget").is(":visible"); 55 }) 56 .click(function () { 57 input.focus(); 58 // Close if already visible 59 if (wasOpen) { 60 return; 61 } 62 // Pass empty string as value to search for, displaying all results 63 input.autocomplete("search", ""); 64 }); 65 }, 66 _source: function (request, response) { 67 var matcher = new RegExp($.ui.autocomplete.escapeRegex(request.term), "i"); 68 response(this.element.children("option").map(function () { 69 var text = $(this).text(); 70 if (this.value && (!request.term || matcher.test(text))) 71 return { 72 label: text, 73 value: text, 74 option: this 75 }; 76 })); 77 }, 78 _removeIfInvalid: function (event, ui) { 79 // Selected an item, nothing to do 80 if (ui.item) { 81 return; 82 } 83 // Search for a match (case-insensitive) 84 var value = this.input.val(), 85 valueLowerCase = value.toLowerCase(), 86 valid = false; 87 this.element.children("option").each(function () { 88 if ($(this).text().toLowerCase() === valueLowerCase) { 89 this.selected = valid = true; 90 return false; 91 } 92 }); 93 // Found a match, nothing to do 94 if (valid) { 95 return; 96 } 97 // Remove invalid value 98 this.input 99 .val("") 100 .attr("title", value + " didn't match any item") 101 .tooltip("open"); 102 this.element.val(""); 103 this._delay(function () { 104 this.input.tooltip("close").attr("title", ""); 105 }, 2500); 106 this.input.data("ui-autocomplete").term = ""; 107 }, 108 _destroy: function () { 109 this.wrapper.remove(); 110 this.element.show(); 111 } 112 });
113})(jQuery); 114 115function disableEmptyFields(token) { 116 //disable all empty fields to have a nice url 117 jQuery('#dir-container-'+token).submit(function() { 118 jQuery(':input', this).each(function() { 119 this.disabled = !(jQuery(this).val()); 120 }); 121 122 jQuery('#dir-container-'+token+' select').each(function() { 123 if(!(jQuery(this).val()) || jQuery(this).val()==0 && !jQuery(this).hasClass('required')){ 124 jQuery(this).attr('disabled', 'disabled'); 125 } 126 }); 127 }); 128} 129 130function codeLatLng(lat, lng) { 131 let location = []; 132 location.latitude = lat; 133 location.longitude = lng; 134 135 let callback = function(country_code) { 136 jQuery("#geo-country").val(country_code); 137 }; 138 139 JBDMapHelper.reverseGeocoding(location, callback); 140}
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.