2003-08-28 16:31:11 +02:00
|
|
|
/**************************************************************************\
|
2004-01-27 17:58:19 +01:00
|
|
|
* eGroupWare - EditableTemplates - javascript support functions *
|
|
|
|
* http://www.egroupware.org *
|
2003-08-28 16:31:11 +02:00
|
|
|
* Written by Ralf Becker <RalfBecker@outdoor-training.de> *
|
|
|
|
* -------------------------------------------- *
|
|
|
|
* This program is free software; you can redistribute it and/or modify it *
|
|
|
|
* under the terms of the GNU General Public License as published by the *
|
|
|
|
* Free Software Foundation; either version 2 of the License, or (at your *
|
|
|
|
* option) any later version. *
|
|
|
|
\**************************************************************************/
|
|
|
|
|
|
|
|
/* $Id$ */
|
|
|
|
|
2004-02-14 19:48:53 +01:00
|
|
|
function submitit(form,name)
|
|
|
|
{
|
|
|
|
//alert(name+' pressed');
|
|
|
|
form.submit_button.value = name;
|
|
|
|
form.submit();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2003-08-28 16:31:11 +02:00
|
|
|
function set_element(form,name,value)
|
|
|
|
{
|
|
|
|
//alert('set_element: '+name+'='+value);
|
|
|
|
for (i = 0; i < form.length; i++)
|
|
|
|
{
|
|
|
|
if (form.elements[i].name == name)
|
|
|
|
{
|
2005-05-19 15:16:52 +02:00
|
|
|
//alert('set_element: '+name+'='+value);
|
2003-08-28 16:31:11 +02:00
|
|
|
form.elements[i].value = value;
|
2005-05-19 15:16:52 +02:00
|
|
|
//alert(name+'='+form.elements[i].value);
|
2003-08-28 16:31:11 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function set_element2(form,name,vname)
|
|
|
|
{
|
|
|
|
//alert('set_element2: '+name+'='+vname);
|
|
|
|
for (i = 0; i < form.length; i++)
|
|
|
|
{
|
|
|
|
if (form.elements[i].name == vname)
|
|
|
|
{
|
|
|
|
value = form.elements[i].value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//alert('set_element2: '+name+'='+value);
|
|
|
|
for (i = 0; i < form.length; i++)
|
|
|
|
{
|
|
|
|
if (form.elements[i].name == name)
|
|
|
|
{
|
|
|
|
form.elements[i].value = value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function activate_tab(tab,all_tabs,name)
|
|
|
|
{
|
|
|
|
var tabs = all_tabs.split('|');
|
|
|
|
var parts = tab.split('.');
|
|
|
|
var last_part = parts.length-1;
|
|
|
|
|
|
|
|
for (n = 0; n < tabs.length; n++)
|
|
|
|
{
|
|
|
|
var t = tabs[n];
|
|
|
|
|
|
|
|
if (t.indexOf('.') < 0 && parts.length > 1)
|
|
|
|
{
|
|
|
|
parts[last_part] = t;
|
|
|
|
t = parts.join('.');
|
|
|
|
}
|
2005-05-19 15:16:52 +02:00
|
|
|
document.getElementById(t).style.display = t == tab ? 'inline' : 'none';
|
2003-08-28 16:31:11 +02:00
|
|
|
document.getElementById(t+'-tab').className = 'etemplate_tab'+(t == tab ? '_active th' : ' row_on');
|
|
|
|
}
|
2005-05-19 15:16:52 +02:00
|
|
|
if (name) {
|
|
|
|
set_element(document.eTemplate,name,tab);
|
|
|
|
}
|
2003-08-28 16:31:11 +02:00
|
|
|
}
|
2005-06-11 21:06:38 +02:00
|
|
|
|
|
|
|
/* proxy to to add options to a selectbox, needed by IE, but works everywhere */
|
|
|
|
function selectbox_add_option(id,label,value,do_onchange)
|
|
|
|
{
|
|
|
|
selectBox = document.getElementById(id);
|
|
|
|
for (i=0; i < selectBox.length; i++) {
|
|
|
|
if (selectBox.options[i].value == value) {
|
|
|
|
selectBox.options[i].selected = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else if (value.slice(0,1) == "," && selectBox.options[i].value.slice(0,1) == ",") {
|
|
|
|
selectBox.options[i].value = value;
|
|
|
|
selectBox.options[i].text = "multiple*";
|
|
|
|
selectBox.options[i].title = label;
|
|
|
|
selectBox.options[i].selected = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (i >= selectBox.length) {
|
|
|
|
selectBox.options[selectBox.length] = new Option(label,value,false,true);
|
|
|
|
}
|
|
|
|
if (selectBox.onchange && do_onchange) selectBox.onchange();
|
|
|
|
}
|