From e11f55a702551f59f40146e9ffc1e415c6ec57b5 Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Sun, 22 Jan 2012 10:19:59 +0000 Subject: [PATCH] only show sweep when field has content --- Netdisco/views/js/device.js | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/Netdisco/views/js/device.js b/Netdisco/views/js/device.js index 2225b07e..e6835800 100644 --- a/Netdisco/views/js/device.js +++ b/Netdisco/views/js/device.js @@ -104,9 +104,27 @@ }; $('.add-on :checkbox').each(syncCheckBox).click(syncCheckBox); + // show or hide sweeping brush icon when field has content + var sweep = $('#ports_form').find("input[name=q]"); + + if (sweep.val() === "") { + $('.field_clear_icon').hide(); + } else { + $('.field_clear_icon').show(); + } + + sweep.change(function() { + if ($(this).val() === "") { + $('.field_clear_icon').hide(); + } else { + $('.field_clear_icon').show(); + } + }); + // handler for sweeping brush icon in port filter box $('.field_clear_icon').click(function() { - $('#ports_form').find("input[name=q]").val(''); + sweep.val(''); + $('.field_clear_icon').hide(); $('#ports_form').trigger('submit'); });