Skip to content
This repository has been archived by the owner on Aug 31, 2022. It is now read-only.

Commit

Permalink
reinstated persist logic
Browse files Browse the repository at this point in the history
  • Loading branch information
maggiewachs committed Nov 10, 2011
1 parent 7fae75e commit 29b5fd5
Showing 1 changed file with 27 additions and 24 deletions.
51 changes: 27 additions & 24 deletions _js/table.js
Expand Up @@ -10,6 +10,7 @@

options: {
idprefix: null, // specify a prefix for the id/headers values
persist: null, // specify a class assigned to column headers (th) that should always be present; the script not create a checkbox for these columns
checkContainer: null // container element where the hide/show checkboxes will be inserted; if none specified, the script creates a menu
},

Expand Down Expand Up @@ -45,30 +46,32 @@

// create the hide/show toggles
// TEMP - hard-coded for now
var toggle = $('<div><input type="checkbox" name="toggle-cols" id="toggle-col-'+i+'" value="'+id+'" /> <label for="toggle-col-'+i+'">'+th.text()+'</label></div>');

if (classes) { toggle.addClass(classes); };

container.append(toggle);

toggle.find("input")
.change(function(){
var input = $(this),
val = input.val(),
cols = $("#" + val + ", [headers="+ val +"]");

if (input.is(":checked")) { cols.show(); }
else { cols.hide(); };
})
.bind("updateCheck", function(){
if ( th.css("display") == "table-cell") {
$(this).attr("checked", true);
}
else {
$(this).attr("checked", false);
}
})
.trigger("updateCheck");
if ( !th.is("." + o.persist) ) {
var toggle = $('<div><input type="checkbox" name="toggle-cols" id="toggle-col-'+i+'" value="'+id+'" /> <label for="toggle-col-'+i+'">'+th.text()+'</label></div>');

if (classes) { toggle.addClass(classes); };

container.append(toggle);

toggle.find("input")
.change(function(){
var input = $(this),
val = input.val(),
cols = $("#" + val + ", [headers="+ val +"]");

if (input.is(":checked")) { cols.show(); }
else { cols.hide(); };
})
.bind("updateCheck", function(){
if ( th.css("display") == "table-cell") {
$(this).attr("checked", true);
}
else {
$(this).attr("checked", false);
}
})
.trigger("updateCheck");
};

}); // end hdrCols loop

Expand Down

0 comments on commit 29b5fd5

Please sign in to comment.