1 %# BEGIN BPS TAGGED BLOCK {{{
5 %# This software is Copyright (c) 1996-2007 Best Practical Solutions, LLC
6 %# <jesse@bestpractical.com>
8 %# (Except where explicitly superseded by other copyright notices)
13 %# This work is made available to you under the terms of Version 2 of
14 %# the GNU General Public License. A copy of that license should have
15 %# been provided with this software, but in any event can be snarfed
18 %# This work is distributed in the hope that it will be useful, but
19 %# WITHOUT ANY WARRANTY; without even the implied warranty of
20 %# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 %# General Public License for more details.
23 %# You should have received a copy of the GNU General Public License
24 %# along with this program; if not, write to the Free Software
25 %# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
26 %# 02110-1301 or visit their web page on the internet at
27 %# http://www.gnu.org/copyleft/gpl.html.
30 %# CONTRIBUTION SUBMISSION POLICY:
32 %# (The following paragraph is not intended to limit the rights granted
33 %# to you to modify and distribute this software under the terms of
34 %# the GNU General Public License and is only of importance to you if
35 %# you choose to contribute your changes and enhancements to the
36 %# community by submitting them to Best Practical Solutions, LLC.)
38 %# By intentionally submitting any modifications, corrections or
39 %# derivatives to this work, or any other work intended for use with
40 %# Request Tracker, to Best Practical Solutions, LLC, you confirm that
41 %# you are the copyright holder for those contributions and you grant
42 %# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable,
43 %# royalty-free, perpetual, license to use, copy, create derivative
44 %# works based on those contributions, and sublicense and distribute
45 %# those contributions and any derivatives thereof.
47 %# END BPS TAGGED BLOCK }}}
48 /* by TKirby, released under GPL */
49 /* Define the "list" Class */
50 Class("list").define({
54 list : function (src, esrc, name) { this.init(src, esrc, name); },
57 if(this.xml.readyState!=4) { setTimeout(this.name+".read()", 100); }
58 else if(this.xml.status!=200) alert("Document not available.");
60 var doc = this.xml.responseXML;
62 if(doc.childNodes[0].nodeName=="parseerror") alert("Parse Error.");
63 doc = doc.getElementsByTagName("list")[0];
64 for(i=0;i<doc.childNodes.length;i++) {
65 if(doc.childNodes[i].childNodes.length>0) {
66 nNode = document.createElement("option");
67 nNode.appendChild(document.createTextNode(doc.childNodes[i].childNodes[0].nodeValue));
68 this.sels[0].appendChild(nNode);
74 init : function (src,esrc,name) {
77 this.sels = new Array();
79 for(i=0;i<src.childNodes.length;i++) {
80 if(src.childNodes[i].nodeName=="select" || src.childNodes[i].nodeName=="SELECT") {
81 this.sels.push(src.childNodes[i]);
84 if((src.childNodes[i].nodeName=="input" || src.childNodes[i].nodeName=="INPUT")
85 && (src.childNodes[i].name=="fromjs")) {
86 src.childNodes[i].value = 1;
89 if((src.childNodes[i].nodeName=="input" || src.childNodes[i].nodeName=="INPUT")
90 && (src.childNodes[i].type=="submit" || src.childNodes[i].type=="SUBMIT")) {
92 if (src.childNodes[i].name.indexOf("Save") < 0) {
93 var tmp = document.createElement("input");
95 tmp.name = src.childNodes[i].name;
96 tmp.value = src.childNodes[i].value;
97 src.replaceChild(tmp,src.childNodes[i]);
100 if(src.childNodes[i].name=="add")
101 src.childNodes[i].onclick = new Function(this.name+".add();");
102 if(src.childNodes[i].name=="remove")
103 src.childNodes[i].onclick = new Function(this.name+".remove();");
104 if(src.childNodes[i].name=="moveup")
105 src.childNodes[i].onclick = new Function(this.name+".moveup();");
106 if(src.childNodes[i].name=="movedown")
107 src.childNodes[i].onclick = new Function(this.name+".movedown();");
111 this.xml = (window.navigator.appName!="Microsoft Internet Explorer"
112 ?new XMLHttpRequest():new ActiveXObject("Microsoft.XMLHTTP"));
113 this.xml.open("GET", esrc);
115 setTimeout(this.name+".read()", 100);
122 for(i=0;i<this.sels[0].length;i++) if(this.sels[0][i].selected) {
123 for(j=0;j<this.sels[1].length;j++) if(this.sels[1][j].value==this.sels[0][i].value) break;
124 if(j==this.sels[1].length) dNode = this.sels[0][i].cloneNode(true),
125 this.sels[1].appendChild(dNode);
129 moveup : function() { this.move(-1); },
130 movedown : function() { this.move(1); },
133 if(v<0) for(i=0;i<this.sels[1].length;i++) this.moveOne(v, i);
134 else if(v>0) for(i=this.sels[1].length-1;i>=0;i--)this.moveOne(v, i);
137 moveOne : function(v, i) {
139 if(ins<0 || ins>=this.sels[1].length) return;
140 if(this.sels[1][ins].selected) return;
141 if(this.sels[1][i].selected) {
142 Node = this.sels[1][i];
143 this.sels[1].removeChild(Node);
144 this.sels[1].insertBefore(Node, this.sels[1][ins]);
148 remove : function() {
150 for(i=this.sels[1].length-1;i>=0;i--) if(this.sels[1][i].selected)
151 this.sels[1].removeChild(this.sels[1][i]);
154 selectAll: function() {
156 for(i=0;i<this.sels[0].length;i++) this.sels[0][i].selected = false;
157 for(i=0;i<this.sels[1].length;i++) this.sels[1][i].selected = true;