From 34a695cc9c8006adae4979603f7d202c4f08f9ef Mon Sep 17 00:00:00 2001 From: Jochen Topf Date: Fri, 16 May 2014 20:12:57 +0200 Subject: Disable comparison list clear and compare when they don't make sense. --- web/public/js/taginfo.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'web/public') diff --git a/web/public/js/taginfo.js b/web/public/js/taginfo.js index abb8589..8925e20 100644 --- a/web/public/js/taginfo.js +++ b/web/public/js/taginfo.js @@ -591,9 +591,20 @@ function set_comparison_list(list) { } function comparison_list_update() { + var l = get_comparison_list().length; var cl = jQuery('#list option:first').html(); - cl = cl.replace(/([0-9]+)/, String(get_comparison_list().length)); + cl = cl.replace(/([0-9]+)/, String(l)); jQuery('#list option:first').html(cl); + if (l == 0) { + jQuery('#list option:eq(2)').attr('style', 'color: #e0e0e0'); + } else { + jQuery('#list option:eq(2)').attr('style', ''); + } + if (l < 2) { + jQuery('#list option:eq(3)').attr('style', 'color: #e0e0e0'); + } else { + jQuery('#list option:eq(3)').attr('style', ''); + } jQuery('#list').val('title').change(); } @@ -636,7 +647,7 @@ function comparison_list_change(key, value) { set_comparison_list(list); } else if (command == 'clear') { set_comparison_list([]); - } else if (command == 'compare') { + } else if (command == 'compare' && list.length >= 2) { window.location = comparison_list_url(list); } -- cgit v1.2.3