diff options
Diffstat (limited to 'rt/html/NoAuth/js')
-rw-r--r-- | rt/html/NoAuth/js/ahah.js | 80 | ||||
-rw-r--r-- | rt/html/NoAuth/js/autohandler | 53 | ||||
-rw-r--r-- | rt/html/NoAuth/js/cascaded.js | 66 | ||||
-rw-r--r-- | rt/html/NoAuth/js/class.js | 62 | ||||
-rw-r--r-- | rt/html/NoAuth/js/combobox.js | 265 | ||||
-rw-r--r-- | rt/html/NoAuth/js/list.js | 159 | ||||
-rw-r--r-- | rt/html/NoAuth/js/titlebox-state.js | 83 | ||||
-rw-r--r-- | rt/html/NoAuth/js/util.js | 250 |
8 files changed, 1018 insertions, 0 deletions
diff --git a/rt/html/NoAuth/js/ahah.js b/rt/html/NoAuth/js/ahah.js new file mode 100644 index 000000000..03ed12a97 --- /dev/null +++ b/rt/html/NoAuth/js/ahah.js @@ -0,0 +1,80 @@ +%# BEGIN BPS TAGGED BLOCK {{{ +%# +%# COPYRIGHT: +%# +%# This software is Copyright (c) 1996-2007 Best Practical Solutions, LLC +%# <jesse@bestpractical.com> +%# +%# (Except where explicitly superseded by other copyright notices) +%# +%# +%# LICENSE: +%# +%# This work is made available to you under the terms of Version 2 of +%# the GNU General Public License. A copy of that license should have +%# been provided with this software, but in any event can be snarfed +%# from www.gnu.org. +%# +%# This work is distributed in the hope that it will be useful, but +%# WITHOUT ANY WARRANTY; without even the implied warranty of +%# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%# General Public License for more details. +%# +%# You should have received a copy of the GNU General Public License +%# along with this program; if not, write to the Free Software +%# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +%# 02110-1301 or visit their web page on the internet at +%# http://www.gnu.org/copyleft/gpl.html. +%# +%# +%# CONTRIBUTION SUBMISSION POLICY: +%# +%# (The following paragraph is not intended to limit the rights granted +%# to you to modify and distribute this software under the terms of +%# the GNU General Public License and is only of importance to you if +%# you choose to contribute your changes and enhancements to the +%# community by submitting them to Best Practical Solutions, LLC.) +%# +%# By intentionally submitting any modifications, corrections or +%# derivatives to this work, or any other work intended for use with +%# Request Tracker, to Best Practical Solutions, LLC, you confirm that +%# you are the copyright holder for those contributions and you grant +%# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable, +%# royalty-free, perpetual, license to use, copy, create derivative +%# works based on those contributions, and sublicense and distribute +%# those contributions and any derivatives thereof. +%# +%# END BPS TAGGED BLOCK }}} +/* +% $r->content_type('application/x-javascript'); +*/ +// Fetched from http://www.opendarwin.org/~drernie/src/ahah.js +function ahah(url, target, delay) { + // document.getElementById(target).innerHTML = 'Loading <a href="'+url+'">'+url +'</a>...'; + if (window.XMLHttpRequest) { + req = new XMLHttpRequest(); + } else if (window.ActiveXObject) { + req = new ActiveXObject("Microsoft.XMLHTTP"); + } + if (req != undefined) { + req.onreadystatechange = function() {ahahDone(url, target, delay);}; + req.open("GET", url, true); + req.send(""); + } +} + +function ahahDone(url, target, delay) { + if (req.readyState == 4) { // only if req is "loaded" + if (req.status == 200) { // only if "OK" + document.getElementById(target).innerHTML = req.responseText; + } else { + document.getElementById(target).innerHTML="Error loading '"+url+"':\n"+req.statusText; + } + if (delay != undefined) { + setTimeout("ahah(url,target,delay)", delay); // resubmit after delay + //server should ALSO delay before responding + } + } +} + +% $m->abort(); diff --git a/rt/html/NoAuth/js/autohandler b/rt/html/NoAuth/js/autohandler new file mode 100644 index 000000000..fd1b90075 --- /dev/null +++ b/rt/html/NoAuth/js/autohandler @@ -0,0 +1,53 @@ +%# BEGIN BPS TAGGED BLOCK {{{ +%# +%# COPYRIGHT: +%# +%# This software is Copyright (c) 1996-2007 Best Practical Solutions, LLC +%# <jesse@bestpractical.com> +%# +%# (Except where explicitly superseded by other copyright notices) +%# +%# +%# LICENSE: +%# +%# This work is made available to you under the terms of Version 2 of +%# the GNU General Public License. A copy of that license should have +%# been provided with this software, but in any event can be snarfed +%# from www.gnu.org. +%# +%# This work is distributed in the hope that it will be useful, but +%# WITHOUT ANY WARRANTY; without even the implied warranty of +%# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%# General Public License for more details. +%# +%# You should have received a copy of the GNU General Public License +%# along with this program; if not, write to the Free Software +%# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +%# 02110-1301 or visit their web page on the internet at +%# http://www.gnu.org/copyleft/gpl.html. +%# +%# +%# CONTRIBUTION SUBMISSION POLICY: +%# +%# (The following paragraph is not intended to limit the rights granted +%# to you to modify and distribute this software under the terms of +%# the GNU General Public License and is only of importance to you if +%# you choose to contribute your changes and enhancements to the +%# community by submitting them to Best Practical Solutions, LLC.) +%# +%# By intentionally submitting any modifications, corrections or +%# derivatives to this work, or any other work intended for use with +%# Request Tracker, to Best Practical Solutions, LLC, you confirm that +%# you are the copyright holder for those contributions and you grant +%# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable, +%# royalty-free, perpetual, license to use, copy, create derivative +%# works based on those contributions, and sublicense and distribute +%# those contributions and any derivatives thereof. +%# +%# END BPS TAGGED BLOCK }}} +<%init> +&RT::Interface::Web::StaticFileHeaders(); +$r->content_type('application/x-javascript'); +$m->call_next(); +return(); +</%init> diff --git a/rt/html/NoAuth/js/cascaded.js b/rt/html/NoAuth/js/cascaded.js new file mode 100644 index 000000000..79da4167f --- /dev/null +++ b/rt/html/NoAuth/js/cascaded.js @@ -0,0 +1,66 @@ +%# BEGIN BPS TAGGED BLOCK {{{ +%# +%# COPYRIGHT: +%# +%# This software is Copyright (c) 1996-2007 Best Practical Solutions, LLC +%# <jesse@bestpractical.com> +%# +%# (Except where explicitly superseded by other copyright notices) +%# +%# +%# LICENSE: +%# +%# This work is made available to you under the terms of Version 2 of +%# the GNU General Public License. A copy of that license should have +%# been provided with this software, but in any event can be snarfed +%# from www.gnu.org. +%# +%# This work is distributed in the hope that it will be useful, but +%# WITHOUT ANY WARRANTY; without even the implied warranty of +%# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%# General Public License for more details. +%# +%# You should have received a copy of the GNU General Public License +%# along with this program; if not, write to the Free Software +%# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +%# 02110-1301 or visit their web page on the internet at +%# http://www.gnu.org/copyleft/gpl.html. +%# +%# +%# CONTRIBUTION SUBMISSION POLICY: +%# +%# (The following paragraph is not intended to limit the rights granted +%# to you to modify and distribute this software under the terms of +%# the GNU General Public License and is only of importance to you if +%# you choose to contribute your changes and enhancements to the +%# community by submitting them to Best Practical Solutions, LLC.) +%# +%# By intentionally submitting any modifications, corrections or +%# derivatives to this work, or any other work intended for use with +%# Request Tracker, to Best Practical Solutions, LLC, you confirm that +%# you are the copyright holder for those contributions and you grant +%# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable, +%# royalty-free, perpetual, license to use, copy, create derivative +%# works based on those contributions, and sublicense and distribute +%# those contributions and any derivatives thereof. +%# +%# END BPS TAGGED BLOCK }}} +function filter_cascade (id, val) { + var select = document.getElementById(id); + if (!select) { return }; + var i; + var children = select.childNodes; + for (i in children) { + var style = children[i].style; + if (!style) { continue }; + if (val == '') { + style.display = 'block'; + continue; + } + if (children[i].label.substr(0, val.length) == val) { + style.display = 'block'; + continue; + } + style.display = 'none'; + } +} diff --git a/rt/html/NoAuth/js/class.js b/rt/html/NoAuth/js/class.js new file mode 100644 index 000000000..9e4c70ea5 --- /dev/null +++ b/rt/html/NoAuth/js/class.js @@ -0,0 +1,62 @@ +%# BEGIN BPS TAGGED BLOCK {{{ +%# +%# COPYRIGHT: +%# +%# This software is Copyright (c) 1996-2007 Best Practical Solutions, LLC +%# <jesse@bestpractical.com> +%# +%# (Except where explicitly superseded by other copyright notices) +%# +%# +%# LICENSE: +%# +%# This work is made available to you under the terms of Version 2 of +%# the GNU General Public License. A copy of that license should have +%# been provided with this software, but in any event can be snarfed +%# from www.gnu.org. +%# +%# This work is distributed in the hope that it will be useful, but +%# WITHOUT ANY WARRANTY; without even the implied warranty of +%# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%# General Public License for more details. +%# +%# You should have received a copy of the GNU General Public License +%# along with this program; if not, write to the Free Software +%# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +%# 02110-1301 or visit their web page on the internet at +%# http://www.gnu.org/copyleft/gpl.html. +%# +%# +%# CONTRIBUTION SUBMISSION POLICY: +%# +%# (The following paragraph is not intended to limit the rights granted +%# to you to modify and distribute this software under the terms of +%# the GNU General Public License and is only of importance to you if +%# you choose to contribute your changes and enhancements to the +%# community by submitting them to Best Practical Solutions, LLC.) +%# +%# By intentionally submitting any modifications, corrections or +%# derivatives to this work, or any other work intended for use with +%# Request Tracker, to Best Practical Solutions, LLC, you confirm that +%# you are the copyright holder for those contributions and you grant +%# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable, +%# royalty-free, perpetual, license to use, copy, create derivative +%# works based on those contributions, and sublicense and distribute +%# those contributions and any derivatives thereof. +%# +%# END BPS TAGGED BLOCK }}} +/* by TKirby, released under GPL */ + + function _ClassSetup(Object) { + this.prototype = Object; + return this; + } + + function Class(name) { + var _newclass_; + eval("window."+name+" = new Function('this."+name+".apply(this,arguments);');"); + eval("window."+name+".define = _ClassSetup;"); + eval("_newclass_ = window."+name+";"); + return _newclass_; + } + diff --git a/rt/html/NoAuth/js/combobox.js b/rt/html/NoAuth/js/combobox.js new file mode 100644 index 000000000..9225870b6 --- /dev/null +++ b/rt/html/NoAuth/js/combobox.js @@ -0,0 +1,265 @@ +%# BEGIN BPS TAGGED BLOCK {{{ +%# +%# COPYRIGHT: +%# +%# This software is Copyright (c) 1996-2007 Best Practical Solutions, LLC +%# <jesse@bestpractical.com> +%# +%# (Except where explicitly superseded by other copyright notices) +%# +%# +%# LICENSE: +%# +%# This work is made available to you under the terms of Version 2 of +%# the GNU General Public License. A copy of that license should have +%# been provided with this software, but in any event can be snarfed +%# from www.gnu.org. +%# +%# This work is distributed in the hope that it will be useful, but +%# WITHOUT ANY WARRANTY; without even the implied warranty of +%# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%# General Public License for more details. +%# +%# You should have received a copy of the GNU General Public License +%# along with this program; if not, write to the Free Software +%# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +%# 02110-1301 or visit their web page on the internet at +%# http://www.gnu.org/copyleft/gpl.html. +%# +%# +%# CONTRIBUTION SUBMISSION POLICY: +%# +%# (The following paragraph is not intended to limit the rights granted +%# to you to modify and distribute this software under the terms of +%# the GNU General Public License and is only of importance to you if +%# you choose to contribute your changes and enhancements to the +%# community by submitting them to Best Practical Solutions, LLC.) +%# +%# By intentionally submitting any modifications, corrections or +%# derivatives to this work, or any other work intended for use with +%# Request Tracker, to Best Practical Solutions, LLC, you confirm that +%# you are the copyright holder for those contributions and you grant +%# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable, +%# royalty-free, perpetual, license to use, copy, create derivative +%# works based on those contributions, and sublicense and distribute +%# those contributions and any derivatives thereof. +%# +%# END BPS TAGGED BLOCK }}} +function ComboBox_InitWith(n) { + if ( typeof( window.addEventListener ) != "undefined" ) { + window.addEventListener("load", ComboBox_Init(n), false); + } else if ( typeof( window.attachEvent ) != "undefined" ) { + window.attachEvent("onload", ComboBox_Init(n)); + } else { + ComboBox_Init(n)(); + } +} +function ComboBox_Init(n) { + return function () { + if ( ComboBox_UplevelBrowser( n ) ) { + ComboBox_Load( n ); + } + } +} +function ComboBox_UplevelBrowser( n ) { + if( typeof( document.getElementById ) == "undefined" ) return false; + var combo = document.getElementById( n + "_Container" ); + if( combo == null || typeof( combo ) == "undefined" ) return false; + if( typeof( combo.style ) == "undefined" ) return false; + if( typeof( combo.innerHTML ) == "undefined" ) return false; + return true; +} +function ComboBox_Load( comboId ) { + var combo = document.getElementById( comboId + "_Container" ); + var button = document.getElementById( comboId + "_Button" ); + var list = document.getElementById( comboId + "_List" ); + var text = document.getElementById( comboId ); + + + combo.List = list; + combo.Button = button; + combo.Text = text; + + button.Container = combo; + button.Toggle = ComboBox_ToggleList; + button.onclick = button.Toggle; + button.onmouseover = function(e) { this.Container.List.DisableBlur(e); }; + button.onmouseout = function(e) { this.Container.List.EnableBlur(e); }; + button.innerHTML = "\u25BC"; + button.onselectstart = function(e){ return false; }; + button.style.height = ( list.offsetHeight - 4 ) + "px"; + + text.Container = combo; + text.TypeDown = ComboBox_TextTypeDown; + text.KeyAccess = ComboBox_TextKeyAccess; + text.onkeyup = function(e) { this.KeyAccess(e); this.TypeDown(e); }; + text.style.width = ( list.offsetWidth ) + "px"; + + list.Container = combo; + list.Show = ComboBox_ShowList; + list.Hide = ComboBox_HideList; + list.EnableBlur = ComboBox_ListEnableBlur; + list.DisableBlur = ComboBox_ListDisableBlur; + list.Select = ComboBox_ListItemSelect; + list.ClearSelection = ComboBox_ListClearSelection; + list.KeyAccess = ComboBox_ListKeyAccess; + list.FireTextChange = ComboBox_ListFireTextChange; + list.onchange = null; + list.onclick = function(e){ this.Select(e); this.ClearSelection(); this.FireTextChange(); }; + list.onkeyup = function(e) { this.KeyAccess(e); }; + list.EnableBlur(null); + list.style.position = "absolute"; + list.size = ComboBox_GetListSize( list ); + list.IsShowing = true; + list.Hide(); + +} +function ComboBox_InitEvent( e ) { + if( typeof( e ) == "undefined" && typeof( window.event ) != "undefined" ) e = window.event; + if( e == null ) e = new Object(); + return e; +} +function ComboBox_ListClearSelection() { + if ( typeof( this.Container.Text.createTextRange ) == "undefined" ) return; + var rNew = this.Container.Text.createTextRange(); + rNew.moveStart('character', this.Container.Text.value.length) ; + rNew.select(); +} +function ComboBox_GetListSize( theList ) { + ComboBox_EnsureListSize( theList ); + return theList.listSize; +} +function ComboBox_EnsureListSize( theList ) { + if ( typeof( theList.listSize ) == "undefined" ) { + if( typeof( theList.getAttribute ) != "undefined" ) { + if( theList.getAttribute( "listSize" ) != null && theList.getAttribute( "listSize" ) != "" ) { + theList.listSize = theList.getAttribute( "listSize" ); + return; + } + } + if( theList.options.length > 0 ) { + theList.listSize = theList.options.length; + return; + } + theList.listSize = 4; + } +} +function ComboBox_ListKeyAccess(e) { //Make enter/space and escape do the right thing :) + e = ComboBox_InitEvent( e ); + if( e.keyCode == 13 || e.keyCode == 32 ) { + this.Select(); + return; + } + if( e.keyCode == 27 ) { + this.Hide(); + this.Container.Text.focus(); + return; + } +} +function ComboBox_TextKeyAccess(e) { //Make alt+arrow expand the list + e = ComboBox_InitEvent( e ); + if( e.altKey && (e.keyCode == 38 || e.keyCode == 40) ) { + this.Container.List.Show(); + } +} +function ComboBox_TextTypeDown(e) { //Make the textbox do a type-down on the list + e = ComboBox_InitEvent( e ); + var items = this.Container.List.options; + if( this.value == "" ) return; + var ctrlKeys = Array( 8, 46, 37, 38, 39, 40, 33, 34, 35, 36, 45, 16, 20 ); + for( var i = 0; i < ctrlKeys.length; i++ ) { + if( e.keyCode == ctrlKeys[i] ) return; + } + for( var i = 0; i < items.length; i++ ) { + var item = items[i]; + if( item.text.toLowerCase().indexOf( this.value.toLowerCase() ) == 0 ) { + this.Container.List.selectedIndex = i; + if ( typeof( this.Container.Text.createTextRange ) != "undefined" ) { + this.Container.List.Select(); + } + break; + } + } +} +function ComboBox_ListFireTextChange() { + var textOnChange = this.Container.Text.onchange; + if ( textOnChange != null && typeof(textOnChange) == "function" ) { + textOnChange(); + } +} +function ComboBox_ListEnableBlur(e) { + this.onblur = this.Hide; +} +function ComboBox_ListDisableBlur(e) { + this.onblur = null; +} +function ComboBox_ListItemSelect(e) { + if( this.options.length > 0 ) { + var text = this.Container.Text; + var oldValue = text.value; + var newValue = this.options[ this.selectedIndex ].text; + text.value = newValue; + if ( typeof( text.createTextRange ) != "undefined" ) { + if (newValue != oldValue) { + var rNew = text.createTextRange(); + rNew.moveStart('character', oldValue.length) ; + rNew.select(); + } + } + } + this.Hide(); + this.Container.Text.focus(); +} +function ComboBox_ToggleList(e) { + if( this.Container.List.IsShowing == true ) { + this.Container.List.Hide(); + } else { + this.Container.List.Show(); + } +} +function ComboBox_ShowList(e) { + if ( !this.IsShowing && !this.disabled ) { + this.style.width = ( this.Container.offsetWidth ) + "px"; + this.style.top = ( this.Container.offsetHeight + ComboBox_RecursiveOffsetTop(this.Container,true) ) + "px"; + this.style.left = ( ComboBox_RecursiveOffsetLeft(this.Container,true) + 1 ) + "px"; + ComboBox_SetVisibility(this,true); + this.focus(); + this.IsShowing = true; + } +} +function ComboBox_HideList(e) { + if( this.IsShowing ) { + ComboBox_SetVisibility(this,false); + this.IsShowing = false; + } +} +function ComboBox_SetVisibility(theList, isVisible) { + setVisibility(theList, isVisible); +} +function ComboBox_RecursiveOffsetTop(thisObject,isFirst) { + if(thisObject.offsetParent) { + if ( thisObject.style.position == "absolute" && !isFirst && typeof(document.designMode) != "undefined" ) { + return 0; + } + return (thisObject.offsetTop + ComboBox_RecursiveOffsetTop(thisObject.offsetParent,false)); + } else { + return thisObject.offsetTop; + } +} +function ComboBox_RecursiveOffsetLeft(thisObject,isFirst) { + if(thisObject.offsetParent) { + if ( thisObject.style.position == "absolute" && !isFirst && typeof(document.designMode) != "undefined" ) { + return 0; + } + return (thisObject.offsetLeft + ComboBox_RecursiveOffsetLeft(thisObject.offsetParent,false)); + } else { + return thisObject.offsetLeft; + } +} +function ComboBox_SimpleAttach(selectElement,textElement) { + textElement.value = selectElement.options[ selectElement.options.selectedIndex ].text; + var textOnChange = textElement.onchange; + if ( textOnChange != null && typeof( textOnChange ) == "function" ) { + textOnChange(); + } +} diff --git a/rt/html/NoAuth/js/list.js b/rt/html/NoAuth/js/list.js new file mode 100644 index 000000000..9753b9771 --- /dev/null +++ b/rt/html/NoAuth/js/list.js @@ -0,0 +1,159 @@ +%# BEGIN BPS TAGGED BLOCK {{{ +%# +%# COPYRIGHT: +%# +%# This software is Copyright (c) 1996-2007 Best Practical Solutions, LLC +%# <jesse@bestpractical.com> +%# +%# (Except where explicitly superseded by other copyright notices) +%# +%# +%# LICENSE: +%# +%# This work is made available to you under the terms of Version 2 of +%# the GNU General Public License. A copy of that license should have +%# been provided with this software, but in any event can be snarfed +%# from www.gnu.org. +%# +%# This work is distributed in the hope that it will be useful, but +%# WITHOUT ANY WARRANTY; without even the implied warranty of +%# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%# General Public License for more details. +%# +%# You should have received a copy of the GNU General Public License +%# along with this program; if not, write to the Free Software +%# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +%# 02110-1301 or visit their web page on the internet at +%# http://www.gnu.org/copyleft/gpl.html. +%# +%# +%# CONTRIBUTION SUBMISSION POLICY: +%# +%# (The following paragraph is not intended to limit the rights granted +%# to you to modify and distribute this software under the terms of +%# the GNU General Public License and is only of importance to you if +%# you choose to contribute your changes and enhancements to the +%# community by submitting them to Best Practical Solutions, LLC.) +%# +%# By intentionally submitting any modifications, corrections or +%# derivatives to this work, or any other work intended for use with +%# Request Tracker, to Best Practical Solutions, LLC, you confirm that +%# you are the copyright holder for those contributions and you grant +%# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable, +%# royalty-free, perpetual, license to use, copy, create derivative +%# works based on those contributions, and sublicense and distribute +%# those contributions and any derivatives thereof. +%# +%# END BPS TAGGED BLOCK }}} +/* by TKirby, released under GPL */ +/* Define the "list" Class */ +Class("list").define({ + name : null, + xml : null, + sels : null, + list : function (src, esrc, name) { this.init(src, esrc, name); }, + read : function () { + var i = 0; + if(this.xml.readyState!=4) { setTimeout(this.name+".read()", 100); } + else if(this.xml.status!=200) alert("Document not available."); + else { + var doc = this.xml.responseXML; + var nNode = null; + if(doc.childNodes[0].nodeName=="parseerror") alert("Parse Error."); + doc = doc.getElementsByTagName("list")[0]; + for(i=0;i<doc.childNodes.length;i++) { + if(doc.childNodes[i].childNodes.length>0) { + nNode = document.createElement("option"); + nNode.appendChild(document.createTextNode(doc.childNodes[i].childNodes[0].nodeValue)); + this.sels[0].appendChild(nNode); + } + } + } + }, + + init : function (src,esrc,name) { + if(!src) return; + this.name = name; + this.sels = new Array(); + var i = 0; + for(i=0;i<src.childNodes.length;i++) { + if(src.childNodes[i].nodeName=="select" || src.childNodes[i].nodeName=="SELECT") { + this.sels.push(src.childNodes[i]); + } + + if((src.childNodes[i].nodeName=="input" || src.childNodes[i].nodeName=="INPUT") + && (src.childNodes[i].name=="fromjs")) { + src.childNodes[i].value = 1; + } + + if((src.childNodes[i].nodeName=="input" || src.childNodes[i].nodeName=="INPUT") + && (src.childNodes[i].type=="submit" || src.childNodes[i].type=="SUBMIT")) { + + if (src.childNodes[i].name.indexOf("Save") < 0) { + var tmp = document.createElement("input"); + tmp.type = "button"; + tmp.name = src.childNodes[i].name; + tmp.value = src.childNodes[i].value; + src.replaceChild(tmp,src.childNodes[i]); + } + + if(src.childNodes[i].name=="add") + src.childNodes[i].onclick = new Function(this.name+".add();"); + if(src.childNodes[i].name=="remove") + src.childNodes[i].onclick = new Function(this.name+".remove();"); + if(src.childNodes[i].name=="moveup") + src.childNodes[i].onclick = new Function(this.name+".moveup();"); + if(src.childNodes[i].name=="movedown") + src.childNodes[i].onclick = new Function(this.name+".movedown();"); + } + } + if (esrc) { + this.xml = (window.navigator.appName!="Microsoft Internet Explorer" + ?new XMLHttpRequest():new ActiveXObject("Microsoft.XMLHTTP")); + this.xml.open("GET", esrc); + this.xml.send(""); + setTimeout(this.name+".read()", 100); + } + }, + + add : function() { + var i, j = 0; + var dNode = null; + for(i=0;i<this.sels[0].length;i++) if(this.sels[0][i].selected) { + for(j=0;j<this.sels[1].length;j++) if(this.sels[1][j].value==this.sels[0][i].value) break; + if(j==this.sels[1].length) dNode = this.sels[0][i].cloneNode(true), + this.sels[1].appendChild(dNode); + } + }, + + moveup : function() { this.move(-1); }, + movedown : function() { this.move(1); }, + move : function(v) { + var i = 0; + if(v<0) for(i=0;i<this.sels[1].length;i++) this.moveOne(v, i); + else if(v>0) for(i=this.sels[1].length-1;i>=0;i--)this.moveOne(v, i); + }, + + moveOne : function(v, i) { + var ins = v + i; + if(ins<0 || ins>=this.sels[1].length) return; + if(this.sels[1][ins].selected) return; + if(this.sels[1][i].selected) { + Node = this.sels[1][i]; + this.sels[1].removeChild(Node); + this.sels[1].insertBefore(Node, this.sels[1][ins]); + } + }, + + remove : function() { + var i = 0; + for(i=this.sels[1].length-1;i>=0;i--) if(this.sels[1][i].selected) + this.sels[1].removeChild(this.sels[1][i]); + }, + + selectAll: function() { + var i = 0; + for(i=0;i<this.sels[0].length;i++) this.sels[0][i].selected = false; + for(i=0;i<this.sels[1].length;i++) this.sels[1][i].selected = true; + } +}); diff --git a/rt/html/NoAuth/js/titlebox-state.js b/rt/html/NoAuth/js/titlebox-state.js new file mode 100644 index 000000000..8950f9e62 --- /dev/null +++ b/rt/html/NoAuth/js/titlebox-state.js @@ -0,0 +1,83 @@ +%# BEGIN BPS TAGGED BLOCK {{{ +%# +%# COPYRIGHT: +%# +%# This software is Copyright (c) 1996-2007 Best Practical Solutions, LLC +%# <jesse@bestpractical.com> +%# +%# (Except where explicitly superseded by other copyright notices) +%# +%# +%# LICENSE: +%# +%# This work is made available to you under the terms of Version 2 of +%# the GNU General Public License. A copy of that license should have +%# been provided with this software, but in any event can be snarfed +%# from www.gnu.org. +%# +%# This work is distributed in the hope that it will be useful, but +%# WITHOUT ANY WARRANTY; without even the implied warranty of +%# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%# General Public License for more details. +%# +%# You should have received a copy of the GNU General Public License +%# along with this program; if not, write to the Free Software +%# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +%# 02110-1301 or visit their web page on the internet at +%# http://www.gnu.org/copyleft/gpl.html. +%# +%# +%# CONTRIBUTION SUBMISSION POLICY: +%# +%# (The following paragraph is not intended to limit the rights granted +%# to you to modify and distribute this software under the terms of +%# the GNU General Public License and is only of importance to you if +%# you choose to contribute your changes and enhancements to the +%# community by submitting them to Best Practical Solutions, LLC.) +%# +%# By intentionally submitting any modifications, corrections or +%# derivatives to this work, or any other work intended for use with +%# Request Tracker, to Best Practical Solutions, LLC, you confirm that +%# you are the copyright holder for those contributions and you grant +%# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable, +%# royalty-free, perpetual, license to use, copy, create derivative +%# works based on those contributions, and sublicense and distribute +%# those contributions and any derivatives thereof. +%# +%# END BPS TAGGED BLOCK }}} +function createCookie(name,value,days) { + var path = "<%$RT::WebPath%>" ? "<%$RT::WebPath%>" : "/"; + + if (days) { + var date = new Date(); + date.setTime(date.getTime()+(days*24*60*60*1000)); + var expires = "; expires="+date.toGMTString(); + } + else + expires = ""; + + document.cookie = name+"="+value+expires+"; path="+path; +} + +function loadTitleBoxStates() { + var cookies = document.cookie.split(/;\s*/); + var len = cookies.length; + + for (var i = 0; i < len; i++) { + var c = cookies[i].split('='); + + if (c[0].match(/^TitleBox--/)) { + var e = document.getElementById(c[0]); + if (e) { + var e2 = e.parentNode; + + if (c[1] != 0) { + set_rollup_state(e,e2,'shown'); + } + else { + set_rollup_state(e,e2,'hidden'); + } + } + } + } +} diff --git a/rt/html/NoAuth/js/util.js b/rt/html/NoAuth/js/util.js new file mode 100644 index 000000000..0de071ad3 --- /dev/null +++ b/rt/html/NoAuth/js/util.js @@ -0,0 +1,250 @@ +%# BEGIN BPS TAGGED BLOCK {{{ +%# +%# COPYRIGHT: +%# +%# This software is Copyright (c) 1996-2007 Best Practical Solutions, LLC +%# <jesse@bestpractical.com> +%# +%# (Except where explicitly superseded by other copyright notices) +%# +%# +%# LICENSE: +%# +%# This work is made available to you under the terms of Version 2 of +%# the GNU General Public License. A copy of that license should have +%# been provided with this software, but in any event can be snarfed +%# from www.gnu.org. +%# +%# This work is distributed in the hope that it will be useful, but +%# WITHOUT ANY WARRANTY; without even the implied warranty of +%# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%# General Public License for more details. +%# +%# You should have received a copy of the GNU General Public License +%# along with this program; if not, write to the Free Software +%# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +%# 02110-1301 or visit their web page on the internet at +%# http://www.gnu.org/copyleft/gpl.html. +%# +%# +%# CONTRIBUTION SUBMISSION POLICY: +%# +%# (The following paragraph is not intended to limit the rights granted +%# to you to modify and distribute this software under the terms of +%# the GNU General Public License and is only of importance to you if +%# you choose to contribute your changes and enhancements to the +%# community by submitting them to Best Practical Solutions, LLC.) +%# +%# By intentionally submitting any modifications, corrections or +%# derivatives to this work, or any other work intended for use with +%# Request Tracker, to Best Practical Solutions, LLC, you confirm that +%# you are the copyright holder for those contributions and you grant +%# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable, +%# royalty-free, perpetual, license to use, copy, create derivative +%# works based on those contributions, and sublicense and distribute +%# those contributions and any derivatives thereof. +%# +%# END BPS TAGGED BLOCK }}} +/* $(...) + Returns DOM node or array of nodes (if more then one argument passed). + If argument is node object allready then do nothing. + // Stolen from Prototype +*/ +function $() { + var elements = new Array(); + + for (var i = 0; i < arguments.length; i++) { + var element = arguments[i]; + if (typeof element == 'string') + element = document.getElementById(element); + + if (arguments.length == 1) + return element; + + elements.push(element); + } + + return elements; +} + +/* Visibility */ + +function show(id) { delClass( id, 'hidden' ) } +function hide(id) { addClass( id, 'hidden' ) } + +function hideshow(id) { return toggleVisibility( id ) } +function toggleVisibility(id) { + var e = $(id); + + if ( e.className.match( /\bhidden\b/ ) ) + show(e); + else + hide(e); + + return false; +} + +function setVisibility(id, visibility) { + if ( visibility ) show(id); + else hide(id); +} + +function switchVisibility(id1, id2) { + // Show both and then hide the one we want + show(id1); + show(id2); + hide(id2); + return false; +} + +/* Classes */ + +function addClass(id, value) { + var e = $(id); + if ( e.className.match( new RegExp('\b'+ value +'\b') ) ) + return; + e.className += e.className? ' '+value : value; +} + +function delClass(id, value) { + var e = $(id); + e.className = e.className.replace( new RegExp('\\s?\\b'+ value +'\\b', 'g'), '' ); +} + +/* Rollups */ + +function rollup(id) { + var e = $(id); + var e2 = e.parentNode; + + if (e.className.match(/\bhidden\b/)) { + set_rollup_state(e,e2,'shown'); + createCookie(id,1,365); + } + else { + set_rollup_state(e,e2,'hidden'); + createCookie(id,0,365); + } + return false; +} + +function set_rollup_state(e,e2,state) { + if (e && e2) { + if (state == 'shown') { + show(e); + delClass( e2, 'rolled-up' ); + } + else if (state == 'hidden') { + hide(e); + addClass( e2, 'rolled-up' ); + } + } +} + + +/* onload handlers */ + +var onLoadStack = new Array(); +var onLoadLastStack = new Array(); +var onLoadExecuted = 0; + +function onLoadHook(commandStr) { + if(typeof(commandStr) == "string") { + onLoadStack[ onLoadStack.length ] = commandStr; + return true; + } + return false; +} + +// some things *really* need to be done after everything else +function onLoadLastHook(commandStr) { + if(typeof(commandStr) == "string"){ + onLoadLastStack[onLoadLastStack.length] = commandStr; + return true; + } + return false; +} + +function doOnLoadHooks() { + if(onLoadExecuted) return; + + var i; + for ( i in onLoadStack ) { + eval( onLoadStack[i] ); + } + for ( i in onLoadLastStack ) { + eval( onLoadLastStack[i] ); + } + onLoadExecuted = 1; +} + +window.onload = doOnLoadHooks; + +/* calendar functions */ + +function openCalWindow(field) { + var objWindow = window.open('<%$RT::WebPath%>/Helpers/CalPopup.html?field='+field, + 'RT_Calendar', + 'height=235,width=285,scrollbars=1'); + objWindow.focus(); +} + +function createCalendarLink(input) { + var e = $(input); + if (e) { + var link = document.createElement('a'); + link.setAttribute('href', '#'); + + clickevent = function clickevent(e) { openCalWindow(input); return false; }; + if (! addEvent(link, "click", clickevent)) { + return false; + } + + var text = document.createTextNode('<% loc("Choose a date") %>'); + link.appendChild(text); + + var space = document.createTextNode(' '); + + e.parentNode.insertBefore(link, e.nextSibling); + e.parentNode.insertBefore(space, e.nextSibling); + + return true; + } + return false; +} + +/* other utils */ + +function focusElementById(id) { + var e = $(id); + if (e) e.focus(); +} + +function updateParentField(field, value) { + if (window.opener) { + window.opener.$(field).value = value; + window.close(); + } +} + +function addEvent(obj, sType, fn) { + if (obj.addEventListener) { + obj.addEventListener(sType, fn, false); + } else if (obj.attachEvent) { + var r = obj.attachEvent("on"+sType, fn); + } else { + return false; + } + return true; +} + +function setCheckbox(form, name, val) { + var myfield = form.getElementsByTagName('input'); + for ( var i = 0; i < myfield.length; i++ ) { + if ( name && myfield[i].name != name ) continue; + if ( myfield[i].type != 'checkbox' ) continue; + + myfield[i].checked = val; + } +} + |