From 1cce6dd13ce4bdf62b0b2209c89d11b9969c0f6f Mon Sep 17 00:00:00 2001 From: erickson Date: Mon, 2 Oct 2006 04:40:39 +0000 Subject: [PATCH] added select all/none links to the select column git-svn-id: svn://svn.open-ils.org/ILS/trunk@6328 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/web/opac/common/js/fm_table.js | 34 +++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/Open-ILS/web/opac/common/js/fm_table.js b/Open-ILS/web/opac/common/js/fm_table.js index 80170e4bb1..1772c9c29b 100644 --- a/Open-ILS/web/opac/common/js/fm_table.js +++ b/Open-ILS/web/opac/common/js/fm_table.js @@ -14,6 +14,7 @@ function drawFMObjectTable( args ) { if( typeof destination == 'string' ) destination = $(destination); var builder = new FMObjectBuilder(obj, args); + destination.appendChild(builder.build()); return builder; } @@ -30,6 +31,8 @@ function FMObjectBuilder( obj, args ) { this.display = args.display; this.selectCol = args.selectCol; this.selectColName = args.selectColName; + this.selectAllName = args.selectAllName; + this.selectNoneName = args.selectNoneName; this.rows = []; if(!this.display) this.display = {}; @@ -64,8 +67,20 @@ FMObjectBuilder.prototype.build = function() { if( o ) { this.setKeys(o); - if( this.selectCol ) - this.thead_tr.appendChild(elem('td',null,this.selectColName)); + if( this.selectCol ) { + var obj = this; + var td = elem('td',null,this.selectColName); + + var all = elem('a',{href:'javascript:void(0);','class':'fm_select_link' }, this.selectAllName); + var none = elem('a',{href:'javascript:void(0);', 'class':'fm_select_link'}, this.selectNoneName); + + all.onclick = function(){obj.selectAll()}; + none.onclick = function(){obj.selectNone()}; + + td.appendChild(all); + td.appendChild(none); + this.thead_tr.appendChild(td); + } for( var i = 0; i < this.keys.length; i++ ) this.thead_tr.appendChild(elem('td',null,this.keys[i])); @@ -77,6 +92,21 @@ FMObjectBuilder.prototype.build = function() { } +FMObjectBuilder.prototype.selectAll = function() { + for( var i = 0; i < this.rows.length; i++ ) { + var r = $(this.rows[i]); + $n(r,'selected').checked = true; + } +} + +FMObjectBuilder.prototype.selectNone = function() { + for( var i = 0; i < this.rows.length; i++ ) { + var r = $(this.rows[i]); + $n(r,'selected').checked = false; + } +} + + /* */ FMObjectBuilder.prototype.setKeys = function(o) { var sortme = false; -- 2.11.0