Filtering fixes
This commit is contained in:
1 parent
3e11ea9b75
commit
3ae6a0675a
3 files changed
+27
-14
No files matched your search
+14
-7
@@ -6,25 +6,32 @@ $(document).ready(function() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
function filter_customers(typed) {
|
function filter_customers(typed) {
|
||||||
/* FIXME: Does not work well. */
|
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
$("li.customer").each(function(i) {
|
$("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).hide();
|
||||||
$(this).removeClass("marked");
|
$(this).removeClass("marked");
|
||||||
} else {
|
} else {
|
||||||
$(this).show();
|
$(this).show();
|
||||||
}
|
var full_match = name.toLowerCase() == typed.toLowerCase();
|
||||||
/* Full match */
|
// FIXME: needs one more char.
|
||||||
if($(this).children("span.name").text() == typed) {
|
//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");
|
$(this).addClass("marked");
|
||||||
|
} else {
|
||||||
|
$(this).removeClass("marked");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}, 50);
|
}, 50);
|
||||||
}
|
}
|
||||||
/* Customer search */
|
/* Customer search */
|
||||||
$('.typeahead').typeahead();
|
//$('.typeahead').typeahead();
|
||||||
$('#id_customer_name').keydown(function(event) {
|
$('#id_customer_typeahead').keyup(function(event) {
|
||||||
filter_customers(event.srcElement.value);
|
filter_customers(event.srcElement.value);
|
||||||
});
|
});
|
||||||
/* Customer selection */
|
/* Customer selection */
|
||||||
|
|||||||
+12
-6
@@ -21,19 +21,25 @@ $(document).ready(function() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
function filter_customers(typed) {
|
function filter_customers(typed) {
|
||||||
/* FIXME: Does not work. */
|
|
||||||
console.log(typed);
|
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
$("li.customer").each(function(i) {
|
$("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).hide();
|
||||||
$(this).removeClass("marked");
|
$(this).removeClass("marked");
|
||||||
} else {
|
} else {
|
||||||
$(this).show();
|
$(this).show();
|
||||||
}
|
var full_match = name.toLowerCase() == typed.toLowerCase();
|
||||||
/* Full match */
|
// FIXME: needs one more char.
|
||||||
if($(this).children("span.name").text() == typed) {
|
//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");
|
$(this).addClass("marked");
|
||||||
|
} else {
|
||||||
|
$(this).removeClass("marked");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}, 50);
|
}, 50);
|
||||||
|
|||||||
@@ -52,7 +52,7 @@
|
|||||||
</section>
|
</section>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% block tailinc %}
|
{% block tailinc %}
|
||||||
<script src="{{ STATIC_URL }}js/bootstrap-typeahead.js"></script>
|
<!--<script src="{{ STATIC_URL }}js/bootstrap-typeahead.js"></script>-->
|
||||||
<script src="{{ STATIC_URL }}js/deposit.js"></script>
|
<script src="{{ STATIC_URL }}js/deposit.js"></script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
Reference in new issue
Block a user