all_checkboxes now work on tables too
authorDobrica Pavlinusic <dpavlin@rot13.org>
Sun, 12 Aug 2012 13:49:02 +0000 (15:49 +0200)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Sun, 12 Aug 2012 13:49:02 +0000 (15:49 +0200)
This was required to add regex file selector when loading files

public/mojo_facets.css
templates/all_checkboxes.html.ep
templates/data/columns.html.ep
templates/data/facet.html.ep
templates/data/index.html.ep

index 10ec588..7e408e6 100644 (file)
@@ -137,12 +137,12 @@ div.col_opts {
        width: 100%;
 }
 
-label.included,
+.included,
 a#included {
        color: #080;
 }
 
-label.excluded,
+.excluded,
 a#excluded {
        color: #800;
 }
index ac67713..91d62d7 100644 (file)
@@ -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]')
index 8c8c1e7..f6b63ff 100644 (file)
@@ -35,7 +35,7 @@ Load view:
 
 <input type=submit value="Select">
 
-<%= include 'all_checkboxes' %>
+%= include 'all_checkboxes', add_class_to => 'parent()'
 
 <ul id="sortable">
 % foreach my $n ( @$columns ) {
index 65d316f..ab01c3c 100644 (file)
@@ -18,7 +18,7 @@
 <span id=facet-count title="total"><%= $facet_count %></span>
 </span>
 
-<%= include 'all_checkboxes' %>
+%= include 'all_checkboxes', add_class_to => 'parent()'
 
 <%= include 'sorting' %>
 
index 473cc89..92972ec 100644 (file)
@@ -1,4 +1,4 @@
-% layout 'default';
+% layout 'ui';
 % my $path = session('path');
 
 <h2>Select data file to load</h2>
@@ -7,6 +7,8 @@
 
 <input type=submit value="Load">
 
+%= include 'all_checkboxes', add_class_to => 'parent().parent()'
+
 <table>
 <tr><th rowspan=2>name</th><th colspan=2>size</th><th rowspan=2>items</th><th rowspan=2>changes</th><th rowspan=2 title="loaded in memory">m</th><th colspan=2>columns</th></tr>
 <tr><th>disk</th><th>storable</th></tr>