Filtering fixes
This commit is contained in:
1 parent
3e11ea9b75
commit
3ae6a0675a
3 files changed
+29
-16
No files matched your search
+15
-8
@@ -6,25 +6,32 @@ $(document).ready(function() {
|
||||
});
|
||||
}
|
||||
function filter_customers(typed) {
|
||||
/* FIXME: Does not work well. */
|
||||
setTimeout(function() {
|
||||
$("li.customer").each(function(i) {
|
||||
if($(this).children("span.name").text().indexOf(typed) == -1) {
|
||||
var pattern = new RegExp(typed,"i");
|
||||
var name = $(this).children("span.name").text();
|
||||
if(!pattern.test(name)) {
|
||||
$(this).hide();
|
||||
$(this).removeClass("marked");
|
||||
} else {
|
||||
$(this).show();
|
||||
}
|
||||
/* Full match */
|
||||
if($(this).children("span.name").text() == typed) {
|
||||
$(this).addClass("marked");
|
||||
var full_match = name.toLowerCase() == typed.toLowerCase();
|
||||
// FIXME: needs one more char.
|
||||
//var single_match = $("li.customer:visible").length == 1;
|
||||
//console.log(full_match, single_match);
|
||||
//if(full_match || single_match) {
|
||||
if(full_match) {
|
||||
$(this).addClass("marked");
|
||||
} else {
|
||||
$(this).removeClass("marked");
|
||||
}
|
||||
}
|
||||
});
|
||||
}, 50);
|
||||
}
|
||||
/* Customer search */
|
||||
$('.typeahead').typeahead();
|
||||
$('#id_customer_name').keydown(function(event) {
|
||||
//$('.typeahead').typeahead();
|
||||
$('#id_customer_typeahead').keyup(function(event) {
|
||||
filter_customers(event.srcElement.value);
|
||||
});
|
||||
/* Customer selection */
|
||||
|
||||
Reference in new issue
Block a user