noalyss  Version-6.7.2
 All Data Structures Namespaces Files Functions Variables Enumerations
class_ipopup.php
Go to the documentation of this file.
00001 <?php
00002 /*
00003  *   This file is part of NOALYSS.
00004  *
00005  *   NOALYSS is free software; you can redistribute it and/or modify
00006  *   it under the terms of the GNU General Public License as published by
00007  *   the Free Software Foundation; either version 2 of the License, or
00008  *   (at your option) any later version.
00009  *
00010  *   NOALYSS is distributed in the hope that it will be useful,
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  *   GNU General Public License for more details.
00014  *
00015  *   You should have received a copy of the GNU General Public License
00016  *   along with NOALYSS; if not, write to the Free Software
00017  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 */
00019 
00020 // Copyright Author Dany De Bontridder danydb@aevalys.eu
00021 
00022 /*!\file
00023  * \brief create a popup in html above the current layer
00024  * the html inside the popup cannot contain any floating elt as div..
00025  *
00026  */
00027 require_once('function_javascript.php');
00028 require_once('class_html_input.php');
00029 
00030 class IPopup extends HtmlInput
00031 {
00032     var $name;                  /*!< name name and id of the div */
00033     function __construct($p_name)
00034     {
00035         $this->name=$p_name;
00036         $this->parameter='';
00037         $this->attribute=array();
00038         $this->drag=false;
00039         $this->blocking=true;
00040     }
00041     function set_width($p_val)
00042     {
00043         $js=sprintf('$("%s'.'_border").style.width="%s";',
00044                     $this->name,$p_val);
00045         $this->parameter.=$js;
00046 
00047     }
00048     function set_height($p_val)
00049     {
00050         $js=sprintf('$("%s'.'_border").style.height="%s";',
00051                     $this->name,$p_val);
00052         $this->parameter.=$js;
00053 
00054     }
00055     /**
00056      *@brief set or not a blocking fond
00057      *@param $p_block if true if you want to avoid access to background,
00058      *accept true or false
00059      */
00060     function set_block($p_block)
00061     {
00062         $this->blocking=$p_block;
00063     }
00064 
00065     function set_zindex($p_val)
00066     {
00067         $js=sprintf('$("%s'.'_border").style.zIndex=%d;',
00068                     $this->name,$p_val);
00069         $js=sprintf('$("%s'.'_content").style.zIndex=%d;',
00070                     $this->name,$p_val);
00071         $this->parameter.=$js;
00072     }
00073     function set_dragguable($p_value)
00074     {
00075         $this->drag=$p_value;
00076     }
00077     /*!\brief set the attribute thanks javascript as the width, the position ...
00078      *\param $p_name attribute name
00079      *\param $p_val val of the attribute
00080      *\note add to  the this->attribut, it will be used in input()
00081      */
00082     function set_attribute($p_name,$p_val)
00083     {
00084         $this->attribute[]=array($p_name,$p_val);
00085     }
00086     /*!\brief set the title of a ipopup thanks javascript and php mode
00087      *\param title of the IPopup
00088      *\return html string with js script
00089      */
00090     function set_title($p_title)
00091     {
00092         $this->title=$p_title;
00093         $s=sprintf('$("%s_"+"title")="%s"',
00094                    $this->name,$this->title);
00095         return create_script($s);
00096     }
00097     function input()
00098     {
00099         $r="";
00100         if ($this->blocking)
00101         {
00102             $r.=sprintf('<div id="%s_fond" name="fond" class="popup_back">',$this->name);
00103             $r.="</div>";
00104         }
00105         $javascript=sprintf("javascript:hideIPopup('%s')",
00106                             $this->name);
00107 
00108 
00109         if ( isset($this->title) && trim($this->title) != "" )
00110         {
00111             $r.=sprintf('<div name ="%s_border" id="%s_border" class="popup_border_title">',
00112                         $this->name,
00113                         $this->name);
00114             $r.=sprintf('<span id="%s_">%s</span>',$this->name,$this->title);
00115         }
00116         else
00117         {
00118             $r.=sprintf('<div name ="%s_border" id="%s_border" class="popup_border_notitle">',
00119                         $this->name,
00120                         $this->name);
00121         }
00122         $r.='<div style="position:absolute;top:0px;right:10px;font-weight:normal;font-size:9px;color:black;text-align:right">';
00123         $r.=sprintf('<a style="background-color:blue;color:white;text-decoration:none" href="%s">'._('Fermer').'</a></div>',
00124                     $javascript);
00125 
00126         $r.=sprintf('<div name ="%s_content" id="%s_content" class="popup_content"> %s </div></div>',
00127                     $this->name,
00128                     $this->name,
00129                     $this->value);
00130 
00131 
00132         /* Add properties at the widget */
00133         $attr=$this->parameter;
00134         for ($i=0;$i< count($this->attribute);$i++)
00135         {
00136             list($name,$value)=$this->attribute[$i];
00137             $tmp1=sprintf("$('%s').%s='%s';",
00138                           $this->name,
00139                           $name,
00140                           $value);
00141             $attr.=$tmp1;
00142         }
00143         $draggable='';
00144         if ($this->drag==true)
00145         {
00146             /* add draggable possibility */
00147             $draggable=sprintf("  new Draggable('%s_border',{starteffect:function(){
00148                                new Effect.Highlight('%s_border',{scroll:window,queue:'end'});  } });"
00149                                ,$this->name
00150                                ,$this->name);
00151 
00152         }
00153         $attr=create_script($attr.$draggable);
00154         $r.=$attr;
00155         return $r;
00156     }
00157 
00158     static function test_me()
00159     {
00160         echo js_include('js/scripts.js');
00161         require_once('class_iselect.php');
00162         $select=new ISelect('a');
00163         $select->value=array(array ('value'=>0,'label'=>'Première valeur'),
00164                              array ('value'=>0,'label'=>'Première valeur'),
00165                              array ('value'=>0,'label'=>'Première valeur'));
00166         for ($e=0;$e<50;$e++)
00167         {
00168             echo $select->input();
00169             if ($e%10 == 0 ) echo '<hr>';
00170         }
00171         $a=new IPopup('pop1');
00172         $a->value="";
00173         for ($e=0;$e<500;$e++)
00174         {
00175             $a->value.="<p>Il etait une fois dans  un pays vraiment lointain où même plus loin que ça</p>";
00176         }
00177         echo $a->input();
00178         echo '
00179         <input type="button" onclick="hide(\'pop1\');hide(\'pop1_border\')" value="cacher">
00180                                      <input type="button" onclick="showIPopup(\'pop1\')" value="montrer">
00181               ',
00182         $a=new IPopup('pop2');
00183         $a->value='';
00184         $a->title="Retrouvez une saucisse";
00185         echo $a->input();
00186         echo '
00187         <input type="button" onclick="hide(\'pop2\');hide(\'pop2_border\')" value="cacher">
00188                         <input type="button" onclick="showIPopup(\'pop2\')" value="montrer">
00189               ';
00190 
00191     }
00192 }
 All Data Structures Namespaces Files Functions Variables Enumerations