Added select function to ui-object

This commit is contained in:
wnz_gh05t 2005-06-11 14:58:07 +00:00
parent 78a891846a
commit ee90696e3b
2 changed files with 112 additions and 0 deletions

View File

@ -19,6 +19,7 @@ class ui_resources
'index' => True, 'index' => True,
'edit' => True, 'edit' => True,
'show' => True, 'show' => True,
'select' => True,
'admin' => True, 'admin' => True,
'writeLangFile' => True 'writeLangFile' => True
); );
@ -78,6 +79,8 @@ class ui_resources
case 'view': case 'view':
list($id) = each($content['nm']['rows']['view']); list($id) = each($content['nm']['rows']['view']);
return $this->show($id); return $this->show($id);
case 'select': // note: this is a popup dialog
return $this->select();
case 'bookable': case 'bookable':
case 'buyable': case 'buyable':
} }
@ -296,6 +299,113 @@ class ui_resources
} }
/**
* select resources
*
* @author Lukas Weiss <wnz.gh05t@users.sourceforge.net>
*/
function select()
{
if (isset($_GET['name'])) $name = $_GET['name'];
$content=array('js_id' => $name)
$content['js'] = "<script LANGUAGE=\"JavaScript\">
window.focus();
function addOption(id,label,value,multiple)
{
openerSelectBox = opener.document.getElementById(id);
if (multiple && openerSelectBox) {
select = '';
for(i=0; i < openerSelectBox.length; i++) {
with (openerSelectBox.options[i]) {
if (selected || openerSelectBox.selectedIndex == i) {
select += (value.slice(0,1)==',' ? '' : ',')+value;
}
}
}
select += (select ? ',' : '')+value;
opener.addOption(id,label,value,0);
opener.addOption(id,'multiple*',select,0);
}
else {
opener.addOption(id,label,value,!multiple && openerSelectBox && openerSelectBox.selectedIndex < 0);
}
selectBox = document.getElementById('uiaccountsel_popup_selection');
if (selectBox) {
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);
}
}
}
function removeSelectedOptions(id)
{
openerSelectBox = opener.document.getElementById(id);
if (openerSelectBox == null) window.close();
selectBox = document.getElementById('uiaccountsel_popup_selection');
for (i=0; i < selectBox.length; i++) {
if (selectBox.options[i].selected) {
for (j=0; j < openerSelectBox.length; j++) {
if (openerSelectBox[j].value == selectBox.options[i].value) {
openerSelectBox.removeChild(openerSelectBox[j]);
}
}
selectBox.options[i--] = null;
}
}
}
function copyOptions(id)
{
openerSelectBox = opener.document.getElementById(id);
selectBox = document.getElementById('uiaccountsel_popup_selection');
for (i=0; i < openerSelectBox.length; i++) {
with (openerSelectBox.options[i]) {
if (selected && value.slice(0,1) != ',') {
selectBox.options[selectBox.length] = new Option(text,value);
}
}
}
}
function oneLineSubmit(id)
{
openerSelectBox = opener.document.getElementById(id);
if (openerSelectBox) {
if (openerSelectBox.selectedIndex >= 0) {
selected = openerSelectBox.options[openerSelectBox.selectedIndex].value;
if (selected.slice(0,1) == ',') selected = selected.slice(1);
opener.addOption(id,'multiple*',selected,1);
}
else {
for (i=0; i < openerSelectBox.length; i++) {
with (openerSelectBox.options[i]) {
if (selected) {
opener.addOption(id,text,value,1);
break;
}
}
}
}
}
window.close();
}
</script>";
$sel_options = array();
$no_button = array();
$preserv = $content;
$this->tmpl->read('resources.resource_select');
$this->tmpl->exec('resources.ui_resources.select',$content,$sel_options,$no_button,$preserv,2);
}
/** /**
* deletes a resource * deletes a resource
* *

View File

@ -1,2 +1,4 @@
.buttonbox {vertical-align: top;} .buttonbox {vertical-align: top;}
.tdAppbox {width: 100%;} .tdAppbox {width: 100%;}
.big {font-weight: bold;}
select.sel {width: 100%;}