diff --git a/html/js/infobulle.js b/html/js/infobulle.js index 48ae712ae..f283d5ce7 100644 --- a/html/js/infobulle.js +++ b/html/js/infobulle.js @@ -65,3 +65,47 @@ function displayBulle(p_comment) { d.style.left=posX+offsetX+"px"; d.style.visibility="visible"; } + +/** + * + * @param p_name + * @see select_box.class.php + */ +function displaySelectBox(p_name) { + try { + if (! document.getElementById("select_box_content") ) { + + var newDiv=new Element("div"); + newDiv.id="select_box_content"; + document.body.appendChild(newDiv); + newDiv.addClassName("select_box"); + $("select_box_content").onmouseleave=function() { + try { + var newDiv=$("select_box_content"); + newDiv.setStyle({display:"none"}); + } catch(e) { + alert(e.message); + } + } + } else { + var newDiv=document.getElementById("select_box_content"); + } + newDiv.innerHTML=$("select_box"+p_name).innerHTML; + var viewport = document.viewport.getDimensions(); + newDiv.style.top=posY+"px"; + + newDiv.style.left=document.getElementById(p_name+"_bt").offsetLeft+"px"; + newDiv.setStyle({display:"block",position:"absolute","z-index":999}); + + if ( $("search_"+p_name+"_list") ) { + var sTmp = newDiv.innerHTML; + var regex=new RegExp(p_name+"_list","g"); + sTmp = sTmp.replace(regex,p_name+"_t_list"); + newDiv.innerHTML=sTmp; + $("search_"+p_name+"_t_list").focus(); + } + } catch(e) { + alert(e.message); + } + +} diff --git a/include/anc_great_ledger.inc.php b/include/anc_great_ledger.inc.php index 53d727df5..da412775f 100644 --- a/include/anc_great_ledger.inc.php +++ b/include/anc_great_ledger.inc.php @@ -45,7 +45,7 @@ if ($result != null) $type_pdf=new Select_Box("type_pdf",_("Type export PDF")); $type_pdf->add_value(_("Un seul PDF"),1); $type_pdf->add_value(_("Un PDF par opération"),2); - $type_pdf->set_position("absolute"); + $type_pdf->set_position("in-absolute"); echo $type_pdf->input(); echo $grandLivre->button_export_pdf(); @@ -67,11 +67,16 @@ if ($result != null) break; } } + if (document.getElementById("type_pdf").value == "-1" ) + { + valid=false; + } + if ( valid ) { progress_bar_start(p_task_id,p_message); return true; } else { - smoke.alert(""); + smoke.alert(""); return false; } diff --git a/include/lib/select_box.class.php b/include/lib/select_box.class.php index 85b768b09..d3a0088f5 100644 --- a/include/lib/select_box.class.php +++ b/include/lib/select_box.class.php @@ -109,109 +109,14 @@ class Select_Box switch ($this->position) { case 'absolute': - // Show when click - $javascript=sprintf(' - $("%s_bt").onclick=function() { - try { - - - if (! document.getElementById("select_box%s") ) { - - var newDiv=new Element("div"); - newDiv.id="select_box%s"; - document.body.appendChild(newDiv); - newDiv.addClassName("select_box"); - $("select_box%s").onmouseleave=function() { - try { - var newDiv=$("select_box%s"); - newDiv.setStyle({display:"none"}); - } catch(e) { - alert(e.message); - } - } - } else { - var newDiv=document.getElementById("select_box%s"); - } - newDiv.innerHTML=$("select_box%s").innerHTML; - var pos=$("%s_bt").cumulativeOffset(); - var nTop=pos.top; - var viewport = document.viewport.getDimensions(); - if ( nTop> viewport.height-newDiv.getHeight()-20) { nTop-=newDiv.getHeight()-5} - - newDiv.setStyle({display:"block",position:"absolute",top:nTop+"px",left:pos.left+5+"px","z-index":999}); - - if ( $("search_%s") ) { $("search_%s").focus();} - } catch(e) { - alert(e.message); - } - } - ', $this->id, $this->id, $this->id,$this->id, $this->id, $this->id, $this->id, $this->id, $list_id, $list_id); - - break; case "normal": - - // Show when click - $javascript=sprintf('$("%s_bt").onclick=function() { - try { - var newDiv=$("select_box%s"); - var pos=$("%s_bt").cumulativeOffset(); - newDiv.setStyle({display:"block",position:"fixed",top:pos.top+25+"px",left:pos.left+5+"px"}); - - if ( $("search_%s") ) { $("search_%s").focus();} - - } catch(e) { - alert(e.message); - } - } - ', $this->id, $this->id, $this->id, $list_id, $list_id); - // Hide when out of the zone - $javascript.=sprintf('$("select_box%s").onmouseleave=function() { - try { - var newDiv=$("select_box%s"); - newDiv.setStyle({display:"none"}); - } catch(e) { - alert(e.message); - } - }', $this->id, $this->id); - break; case "in-absolute": // Show when click $javascript=sprintf(' $("%s_bt").onclick=function() { - try { - - - if (! document.getElementById("select_box_content") ) { - - var newDiv=new Element("div"); - newDiv.id="select_box_content"; - document.body.appendChild(newDiv); - newDiv.addClassName("select_box"); - $("select_box_content").onmouseleave=function() { - try { - var newDiv=$("select_box_content"); - newDiv.setStyle({display:"none"}); - } catch(e) { - alert(e.message); - } - } - } else { - var newDiv=document.getElementById("select_box_content"); - } - newDiv.innerHTML=$("select_box%s").innerHTML; - var pos=$("%s_bt").cumulativeOffset(); - var nTop=pos.top; - var viewport = document.viewport.getDimensions(); - if ( nTop> viewport.height-newDiv.getHeight()-20) { nTop-=newDiv.getHeight()-5} - - newDiv.setStyle({display:"block",position:"absolute",top:nTop+"px",left:pos.left+5+"px","z-index":999}); - - if ( $("search_%s") ) { $("search_%s").focus();} - } catch(e) { - alert(e.message); - } + displaySelectBox("%s"); } - ', $this->id, $this->id, $this->id, $list_id, $list_id); + ', $this->id, $this->id); break; @@ -228,12 +133,13 @@ class Select_Box // Show when click $javascript=$this->compute_position(); - - // display the button - printf('', $this->id, $this->value); - printf('', $this->id, $this->id, $this->default_value); - printf('
', $this->id, $this->style_box); + printf('', + $this->id, $this->value); + printf('', + $this->id, $this->id, $this->default_value); + printf('
', + $this->id, $this->style_box); // Show the filter if there is one, if ($this->filter!="") diff --git a/include/template/ledger_detail_bottom.php b/include/template/ledger_detail_bottom.php index 3675ad2d1..fd22f8b40 100644 --- a/include/template/ledger_detail_bottom.php +++ b/include/template/ledger_detail_bottom.php @@ -14,7 +14,7 @@ require_once NOALYSS_INCLUDE."/lib/select_box.class.php"; $select_box=new \Select_Box("sb_".$jr_id, _("Autre action")); -$select_box->set_position("in-absolute"); +$select_box->set_position("normal"); $cn=Dossier::connect(); // Contains all the linked actions $a_followup = Follow_Up::get_all_operation($jr_id); diff --git a/scenario/select-box-test.php b/scenario/select-box-test.php index d439de502..a739d0213 100644 --- a/scenario/select-box-test.php +++ b/scenario/select-box-test.php @@ -35,15 +35,15 @@ display: block; } .select_box { - border:solid 0.5px darkblue; - background:white; - width:455px; - max-width:250px; - padding:3px; - margin:0px; - display:none; - top:-17px; - position:absolute; + border:solid 0.5px darkblue; + background:white; + width:455px; + max-width:250px; + padding:3px; + margin:0px; + display:none; + position:absolute; + z-index:10; } div.select_box ul { list-style:none; @@ -75,10 +75,13 @@ div.select_box a:hover,div.select_box ul li:hover { Le CSS est important , surtout la position, il faut qu'il soit dans un élément positionné en absolu.

+

in-absolute

set_position("in-absolute"); + $a->add_url("List (link)","?id=5&".Dossier::get()); $a->add_javascript("Hello (Javascript)","alert('hello')"); $a->add_value("Value = 10 (set value)",10); @@ -87,10 +90,15 @@ div.select_box a:hover,div.select_box ul li:hover { echo $a->input(); - ?> + ?> +

+

normal and absolute

+

set_filter(_("recherche")); + $a->set_position("normal"); + $a->add_value("Value = 10 (set value)",10); $a->add_value("Value = 1 (set value)",1); $a->add_value("Value = 17 (set value)",15); @@ -105,7 +113,8 @@ div.select_box a:hover,div.select_box ul li:hover { echo $a->input(); - ?> + ?>

+