noalyss Version-9
infobulle.js
Go to the documentation of this file.
1/*
2 * This file is part of NOALYSS.
3 *
4 * NOALYSS is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * NOALYSS is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with NOALYSS; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17*/
18/*!\file
19 * \brief create the infobulle, the internalization is not yet implemented
20 * \code
21 // Example
22 echo JS_INFOBULLE;
23 echo Icon_Action::infobulle(x);
24 \endcode
25 */
26
27var posX=0,posY=0,offsetX=10,offsetY=10;
28document.onmousemove=getPosition;
29
30function showBulle(p_ctl){
31 var d=document.getElementById('bulle');
32 var viewport = document.viewport.getDimensions();
33 if ( posX+offsetX > viewport.width-d.getWidth()) { posX-=d.getWidth()+20;}
34 if ( posY+offsetY > viewport.height-d.getHeight()-20) { posY-=d.getHeight()+20}
35 d.innerHTML=content[p_ctl];
36 d.style.top=posY+offsetY+"px";
37 d.style.left=posX+offsetX-10+"px";
38 d.style.visibility="visible";
39}
40function getPosition(e)
41{
42 if (document.all)
43 {
44 posX=event.x+document.body.scrollLeft;
45 posY=event.y+document.body.scrollTop;
46 }
47 else
48 {
49 posX=e.pageX;
50 posY=e.pageY;
51 }
52}
53function hideBulle(p_ctl)
54{
55 var d=document.getElementById('bulle');
56 d.style.visibility="hidden";
57}
58function displayBulle(p_comment) {
59 var d=document.getElementById('bulle');
60 var viewport = document.viewport.getDimensions();
61 d.innerHTML=p_comment;
62 if ( posX+offsetX > viewport.width-d.getWidth()) { posX-=d.getWidth()+20;}
63 if ( posY+offsetY > viewport.height-d.getHeight()-20) { posY-=d.getHeight()+20}
64 d.style.top=posY+offsetY+"px";
65 d.style.left=posX+offsetX+"px";
66 d.style.visibility="visible";
67}
68
69/**
70 *
71 * @param p_name
72 * @see select_box.class.php
73 */
74function displaySelectBox(p_name) {
75 try {
76 var newDiv=null;
77 if (! document.getElementById("select_box_content"+p_name) ) {
78
79 newDiv=new Element("div");
80 newDiv.id="select_box_content"+p_name;
81 document.body.appendChild(newDiv);
82 newDiv.addClassName("select_box");
83 $("select_box_content"+p_name).onmouseleave=function() {
84 try {
85 var newDiv=$("select_box_content"+p_name);
86 newDiv.setStyle({display:"none"});
87 } catch(e) {
88 alert(e.message);
89 }
90 }
91 } else {
92 newDiv=document.getElementById("select_box_content"+p_name);
93 }
94 newDiv.innerHTML=$("select_box"+p_name).innerHTML;
95 var viewport = document.viewport.getDimensions();
96 var locPosY=posY;
97 if ( posY+offsetY+ newDiv.getHeight() > window.innerHeight -3) {
98 locPosY-=newDiv.getHeight()+20
99 }
100 newDiv.style.top=locPosY+"px";
101
102 newDiv.style.left=document.getElementById(p_name+"_bt").offsetLeft+"px";
103 newDiv.setStyle({display:"block",position:"absolute","z-index":999});
104
105 if ( $("search_"+p_name+"_list") ) {
106 var sTmp = newDiv.innerHTML;
107 var regex=new RegExp(p_name+"_list","g");
108 sTmp = sTmp.replace(regex,p_name+"_t_list");
109 newDiv.innerHTML=sTmp;
110 $("search_"+p_name+"_t_list").focus();
111 }
112 } catch(e) {
113 alert(e.message);
114 }
115
116}