Show icon based on icon-selectbox, hide placeholder (broken image), if no icon selected

This commit is contained in:
Ralf Becker 2012-04-05 12:32:07 +00:00
parent dd410d49fb
commit 9954e7b42e
2 changed files with 23 additions and 1 deletions

View File

@ -254,6 +254,7 @@ class admin_categories
egw_framework::set_onload('$j(document).ready(function() {
cat_original_owner = [' . ($content['owner'] ? $content['owner'] : ($content['id'] ? '0' : '')) .'];
permission_prompt = \'' . lang('Removing access for groups may cause problems for data in this category. Are you sure? Users in these groups may no longer have access:').'\';
change_icon();
});');
$readonlys['button[delete]'] = !$content['id'] || !self::$acl_delete || // cant delete not yet saved category

View File

@ -41,7 +41,6 @@ function check_owner(element_id) {
}
}
// Somebody will lose permission, give warning.
if(diff.length > 0) {
var msg = permission_prompt;
@ -52,3 +51,25 @@ function check_owner(element_id) {
}
return true;
}
/**
* Show icon based on icon-selectbox, hide placeholder (broken image), if no icon selected
*/
function change_icon(_icon)
{
var img = document.getElementById('exec[icon_url]') || document.getElementById('icon_url');
if (typeof _icon == 'undefined')
{
_icon = document.getElementById('exec[data][icon]') || document.getElementById('data[icon]');
}
if (_icon && _icon.value)
{
img.src = img.src.replace(/\/[^\/]*$/,'\/'+_icon.value);
img.style.display = 'block';
}
else
{
img.style.display = 'none';
}
}