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);
|
2005-06-11 22:11:41 +02:00
|
|
|
/*alert('selectbox_add_option('+id+','+label+','+value+') '+selectBox);*/
|
2005-06-11 21:06:38 +02:00
|
|
|
for (i=0; i < selectBox.length; i++) {
|
|
|
|
if (selectBox.options[i].value == value) {
|
|
|
|
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();
|
|
|
|
}
|
2005-06-12 17:58:22 +02:00
|
|
|
|
|
|
|
/* toggles all checkboxes named name in form form, to be used as custom javascript in onclick of a button/image */
|
|
|
|
function toggle_all(form,name)
|
|
|
|
{
|
|
|
|
/* alert('toggle_all('+form+','+name+',elements[name].length='+form.elements[name].length+')'); */
|
|
|
|
var all_set = true;
|
|
|
|
|
|
|
|
for (var i = 0; i < form.elements[name].length; i++)
|
|
|
|
{
|
|
|
|
if (!form.elements[name][i].checked)
|
|
|
|
{
|
|
|
|
all_set = false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (var i = 0; i < form.elements[name].length; i++)
|
|
|
|
{
|
|
|
|
form.elements[name][i].checked = !all_set;
|
|
|
|
}
|
|
|
|
}
|