Merge branch 'dev-8-select-box'
This commit is contained in:
commit
ce0a8f85ff
5 changed files with 82 additions and 118 deletions
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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("<?=_('Choisissez au moins une opération')?>");
|
||||
smoke.alert("<?=_('Choisissez au moins une opération et le type d\'export')?>");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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('<input type="button" class="smallbutton " id="%s_bt" value="%s ▾" >', $this->id, $this->value);
|
||||
printf('<input type="hidden" id="%s" name="%s" value="%s">', $this->id, $this->id, $this->default_value);
|
||||
printf('<div class="select_box " id="select_box%s" style="%s">', $this->id, $this->style_box);
|
||||
printf('<input type="button" class="smallbutton " id="%s_bt" value="%s ▾" >',
|
||||
$this->id, $this->value);
|
||||
printf('<input type="hidden" id="%s" name="%s" value="%s">',
|
||||
$this->id, $this->id, $this->default_value);
|
||||
printf('<div class="select_box " id="select_box%s" style="%s">',
|
||||
$this->id, $this->style_box);
|
||||
|
||||
// Show the filter if there is one,
|
||||
if ($this->filter!="")
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
</p>
|
||||
<h2>in-absolute</h2>
|
||||
<p style="float : static">
|
||||
<?php
|
||||
require_once NOALYSS_INCLUDE.'/lib/select_box.class.php';
|
||||
$a=new Select_Box("test","click me !");
|
||||
$a=new Select_Box("test","position in-absolute click me !");
|
||||
$a->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();
|
||||
|
||||
?>
|
||||
?>
|
||||
</p>
|
||||
<h2>normal and absolute</h2>
|
||||
<p>
|
||||
<?php
|
||||
$a=new Select_Box("test2","click me !");
|
||||
$a=new Select_Box("test2","position normal click me !");
|
||||
$a->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();
|
||||
|
||||
?>
|
||||
?>
|
||||
</p>
|
||||
|
||||
</div>
|
||||
</body>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue