diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 40b71cbc27..a7fe933a87 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,8 @@ +2010-08-23 Sergio Martin + + * include/functions_ui.php: Added a function to toggle + an html code easly. The function is called toggle() + 2010-08-23 Sergio Martin * include/functions_reporting.php: Fixed a null into diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index 0080a827b7..3cab37de21 100644 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -1310,6 +1310,58 @@ function get_include_contents ($filename, $params = false) { return $contents; } +/** + * Print a code into a DIV and enable a toggle to show and hide it + * + * @param string html code + * @param string name of the link + * @param string title of the link + * @param bool if the div will be hidden by default (default: true) + * + */ + +function toggle($code, $name, $title = '', $hidde_default = true) { +// Generate unique Id +$uniqid = uniqid(''); + +// Options +if($hidde_default) { + $style = 'display:none'; + $toggle_a = "$('#tgl_div_".$uniqid."').show();"; + $toggle_b = "$('#tgl_div_".$uniqid."').hide();"; + $image_a = "images/go.png"; + $image_b = "images/down.png"; +}else { + $style = ''; + $toggle_a = "$('#tgl_div_".$uniqid."').hide();"; + $toggle_b = "$('#tgl_div_".$uniqid."').show();"; + $image_a = "images/down.png"; + $image_b = "images/go.png"; +} +// Link to toggle +echo ''.$name.' '.print_image ($image_b, true, array ("title" => $title, "id" => "image_".$uniqid)).'

'; + +// Code into a div +echo ""; + +// JQuery Toggle + +echo ''; +} /** * Construct and return the URL to be used in order to refresh the current page correctly.