From a89454e7cd95361712cf1528bd70be0863f4a756 Mon Sep 17 00:00:00 2001 From: Dobrica Pavlinusic Date: Sun, 12 Aug 2012 15:49:02 +0200 Subject: [PATCH] all_checkboxes now work on tables too This was required to add regex file selector when loading files --- public/mojo_facets.css | 4 ++-- templates/all_checkboxes.html.ep | 17 ++++++++++------- templates/data/columns.html.ep | 2 +- templates/data/facet.html.ep | 2 +- templates/data/index.html.ep | 4 +++- 5 files changed, 17 insertions(+), 12 deletions(-) diff --git a/public/mojo_facets.css b/public/mojo_facets.css index 10ec588..7e408e6 100644 --- a/public/mojo_facets.css +++ b/public/mojo_facets.css @@ -137,12 +137,12 @@ div.col_opts { width: 100%; } -label.included, +.included, a#included { color: #080; } -label.excluded, +.excluded, a#excluded { color: #800; } diff --git a/templates/all_checkboxes.html.ep b/templates/all_checkboxes.html.ep index ac67713..91d62d7 100644 --- a/templates/all_checkboxes.html.ep +++ b/templates/all_checkboxes.html.ep @@ -38,7 +38,7 @@ function update_checked_count(full) { var count = $('#checked-count'); var nr = -1; if ( full ) { - nr = $("label input[type='checkbox']:checked").length; + nr = $("input[type='checkbox']:checked").length; } else { nr = parseInt( count.text() ); if ( this.checked ) { @@ -57,31 +57,34 @@ var toggle_checkbox = function() { }; $('a#included').click( function(){ - $("label.included input[type='checkbox']:not([disabled='disabled'])").each( toggle_checkbox ); + $(".included input[type='checkbox']:not([disabled='disabled'])").each( toggle_checkbox ); update_checked_count(1); }); $('a#excluded').click( function(){ - $("label.excluded input[type='checkbox']:not([disabled='disabled'])").each( toggle_checkbox ); + $(".excluded input[type='checkbox']:not([disabled='disabled'])").each( toggle_checkbox ); update_checked_count(1); }); // regex for column names +var last_user_regex = ''; + var filter_regex = function(user_regex) { - if ( user_regex == '' ) return false; + if ( user_regex == '' || user_regex == last_user_regex ) return false; + last_user_regex = user_regex; var r = new RegExp( user_regex,'i'); var included = 0; var excluded = 0; $("input[type='checkbox']:not([disabled='disabled'])").each( function(i,element){ if ( r.test( this.value ) ) { - $(this).parent().removeClass('excluded').addClass('included'); + $(this).<%= $add_class_to %>.removeClass('excluded').addClass('included'); included++; } else { - $(this).parent().removeClass('included').addClass('excluded'); + $(this).<%= $add_class_to %>.removeClass('included').addClass('excluded'); excluded++; } }); @@ -89,7 +92,7 @@ var filter_regex = function(user_regex) { $('a#included').text(included).show(); $('a#excluded').text(excluded).show(); - console.debug('filter_regex',included,excluded); + console.debug('filter_regex',user_regex,included,excluded, last_user_regex); }; $('input[name=filter_regex]') diff --git a/templates/data/columns.html.ep b/templates/data/columns.html.ep index 8c8c1e7..f6b63ff 100644 --- a/templates/data/columns.html.ep +++ b/templates/data/columns.html.ep @@ -35,7 +35,7 @@ Load view: -<%= include 'all_checkboxes' %> +%= include 'all_checkboxes', add_class_to => 'parent()'