Skip to main content

City of Northampton Housing Partnership, Legal Resources for Tenants and Landlords

Citation
City of Northampton Housing Partnership, Legal Resources for Tenants and Landlords
Source
Official source

Related Parts of This Source

Full Text

1,777 chars
if ($(checkboxSelector).is(':checked') || false) {
doWidgetSearch($.trim(term), Number(0));
} else {
doWidgetSearch($.trim(term), 0);
}
return false;
}
return true;
});

// autocomplete: set minLength and guard source
if (true) {
var $searchField = $(searchFieldSelector).autocomplete({
minLength: minPrefixLength,
source: createWidgetAutoCompleteSource({
delay: autoCompleteDebounceDelay,
timeout: 10000,
shouldSearch: shouldSearch,
url: getAutoCompleteUrl,
success: function () {
$('.autoCompleteError').remove();
},
error: function (xmlhttprequest, textstatus, message) {
if (textstatus === "timeout") {
if ($(searchFieldSelector).siblings('.autoCompleteError').length == 0)
$('<span class="autoCompleteError"><p class="alert error">Search autocomplete is currently not responding. Please try again later.</p></span>').insertAfter($(searchFieldSelector));
}
}
}),
html: true,
delay: 0,
select: function (event, ui) {
$(this).val(ui.item.value);
$(this).next().click();
}
});

$searchField.data("ui-autocomplete")._renderItem = function (ul, item) {
return $("<li class=\"itemList\"></li>")
.data("ui-autocomplete-item", item)
.append("<a>" + item.label + "</a>")
.appendTo(ul);
};
}

// keep searchBtnApplyQuery consistent with prefix rule
window.searchBtnApplyQuery = function() {
var $field = $(searchFieldSelector);
var term = $field.val() + "";
if (shouldSearch(term)) {
// update href for the icon/button (if present)
var btn = document.getElementById("btnSearchIcon");
if (btn) btn.href = "/Search?searchPhrase=" + encodeURIComponent($.trim(term));
} else {
var btn = document.getElementById("btnSearchIcon");
if (btn) btn.href = "#";
}
};
}
catch(e) {} //we're going to eat this error. Autocomplete won't work but we dont wan't to break anything else on the page.
});