From 06aaeca290b217ac356d312874feb20fc72fbf93 Mon Sep 17 00:00:00 2001 From: phasefx Date: Mon, 5 Dec 2005 16:35:48 +0000 Subject: [PATCH] main.list git-svn-id: svn://svn.open-ils.org/ILS/trunk@2212 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../chrome/content/evergreen/main/list.js | 81 +++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 Open-ILS/xul/staff_client/chrome/content/evergreen/main/list.js diff --git a/Open-ILS/xul/staff_client/chrome/content/evergreen/main/list.js b/Open-ILS/xul/staff_client/chrome/content/evergreen/main/list.js new file mode 100644 index 0000000000..ee8df3f29f --- /dev/null +++ b/Open-ILS/xul/staff_client/chrome/content/evergreen/main/list.js @@ -0,0 +1,81 @@ +dump('entering main/list.js\n'); + +if (typeof main == 'undefined') main = {}; +main.list = function (id) { + + this.node = document.getElementById(id); + + if (!this.node) throw('Could not find element ' + id); + if (this.node.nodeName != 'tree') throw(id + ' is not a tree'); + + JSAN.use('util.error'); this.error = new util.error(); + + return this; +}; + +main.list.prototype = { + + 'init' : function (params) { + + if (typeof params.map_row_to_column == 'function') this.map_row_to_column = params.map_row_to_column; + + this.prebuilt = false; + if (typeof params.prebuilt != 'undefined') this.prebuilt = params.prebuilt; + + if (typeof params.columns == 'undefined') throw('main.list.init: No columns'); + this.columns = params.columns; + + if (this.prebuilt) { + + this.treechildren = this.node.lastChild; + + } else { + var treecols = document.createElement('treecols'); + this.node.appendChild(treecols); + + for (var i = 0; i < this.columns.length; i++) { + var treecol = document.createElement('treecol'); + for (var j in this.columns[i]) { + treecol.setAttribute(j,this.columns[i][j]); + } + treecols.appendChild(treecol); + } + + var treechildren = document.createElement('treechildren'); + this.node.appendChild(treechildren); + this.treechildren = treechildren; + } + }, + + 'append' : function (params) { + + if (typeof params.row == 'undefined') throw('main.list.append: Object must contain a row'); + + var treeitem = document.createElement('treeitem'); + this.treechildren.appendChild( treeitem ); + var treerow = document.createElement('treerow'); + treeitem.appendChild( treerow ); + + for (var i = 0; i < this.columns.length; i++) { + var treecell = document.createElement('treecell'); + var label = ''; + if (typeof params.map_row_to_col == 'function') { + + label = params.map_row_to_col(params.row,this.columns[i]); + + } else { + + if (typeof this.map_row_to_col == 'function') { + + label = this.map_row_to_col(params.row,this.columns[i]); + } + } + treecell.setAttribute('label',label); + treerow.appendChild( treecell ); + } + + return treeitem; + } + +} +dump('exiting main/list.js\n'); -- 2.43.2