make strikethrough of navbar work in more cases

This commit is contained in:
Oliver Gorwits
2013-09-22 16:15:45 +01:00
parent 5f028adc47
commit 230c6e3c0c

View File

@@ -39,7 +39,7 @@ function do_search (event, tab) {
); );
return; return;
} }
if (response === "") { if (response == "") {
$(target).html( $(target).html(
'<div class="span2 alert alert-info">No matching records.</div>' '<div class="span2 alert alert-info">No matching records.</div>'
); );
@@ -111,32 +111,41 @@ if (window.History && window.History.enabled) {
// if any field in Search Options has content, highlight in green // if any field in Search Options has content, highlight in green
function device_form_state(e) { function device_form_state(e) {
if (e.prop('value') != "") { var with_val = $.grep(form_inputs,
e.parent(".clearfix").addClass('success'); function(n,i) {return($(n).prop('value') != "")}).length;
var with_text = $.grep(form_inputs.not('select'),
function(n,i) {return($(n).val() != "")}).length;
if (e.parents('#device_form').length) { if (e.prop('value') == "") {
$('#nq').css('text-decoration', 'line-through');
if (e.attr('type') == 'text') {
$('.nd_field-copy-icon').hide();
}
}
var id = '#' + e.attr('name') + '_clear_btn';
$(id).show();
}
else {
e.parent(".clearfix").removeClass('success'); e.parent(".clearfix").removeClass('success');
var id = '#' + e.attr('name') + '_clear_btn'; var id = '#' + e.attr('name') + '_clear_btn';
$(id).hide(); $(id).hide();
var num_empty = $.grep(form_inputs, // if form has no field val, clear strikethough
function(n,i) {return($(n).val() != "")}).length; if (with_val == 0) {
if (num_empty === 3) {
$('#nq').css('text-decoration', 'none'); $('#nq').css('text-decoration', 'none');
}
// for text inputs only, extra formatting
if (with_text == 0) {
$('.nd_field-copy-icon').show(); $('.nd_field-copy-icon').show();
} }
} }
else {
e.parent(".clearfix").addClass('success');
var id = '#' + e.attr('name') + '_clear_btn';
$(id).show();
// if form still has any field val, set strikethough
if (e.parents('form[action="/search"]').length > 0 && with_val != 0) {
$('#nq').css('text-decoration', 'line-through');
}
// if we're text, hide copy icon when we get a val
if (e.attr('type') == 'text') {
$('.nd_field-copy-icon').hide();
}
}
} }
$(document).ready(function() { $(document).ready(function() {