1 | /** |
---|
2 | * eGroupWare - API |
---|
3 | * http://www.egroupware.org |
---|
4 | * |
---|
5 | * This file was originally created Tyamad, but their content is now completly removed! |
---|
6 | * It still contains some commonly used javascript functions, always included by EGroupware. |
---|
7 | * |
---|
8 | * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License |
---|
9 | * @package api |
---|
10 | * @subpackage jsapi |
---|
11 | * @version $Id: jsapi.js 27380 2009-07-07 12:55:11Z ralfbecker $ |
---|
12 | */ |
---|
13 | |
---|
14 | /***********************************************\ |
---|
15 | * INITIALIZATION * |
---|
16 | \***********************************************/ |
---|
17 | if (document.all) |
---|
18 | { |
---|
19 | navigator.userAgent.toLowerCase().indexOf('msie 5') != -1 ? is_ie5 = true : is_ie5 = false; |
---|
20 | is_ie = true; |
---|
21 | is_moz1_6 = false; |
---|
22 | is_mozilla = false; |
---|
23 | is_ns4 = false; |
---|
24 | } |
---|
25 | else if (document.getElementById) |
---|
26 | { |
---|
27 | navigator.userAgent.toLowerCase().match('mozilla.*rv[:]1\.6.*gecko') ? is_moz1_6 = true : is_moz1_6 = false; |
---|
28 | is_ie = false; |
---|
29 | is_ie5 = false; |
---|
30 | is_mozilla = true; |
---|
31 | is_ns4 = false; |
---|
32 | } |
---|
33 | else if (document.layers) |
---|
34 | { |
---|
35 | is_ie = false; |
---|
36 | is_ie5 = false |
---|
37 | is_moz1_6 = false; |
---|
38 | is_mozilla = false; |
---|
39 | is_ns4 = true; |
---|
40 | } |
---|
41 | |
---|
42 | // works only correctly in Mozilla/FF and Konqueror |
---|
43 | function phpgw_openWindowCentered2(_url, _windowName, _width, _height, _status) |
---|
44 | { |
---|
45 | windowWidth = phpgw_getWindowOuterWidth(); |
---|
46 | windowHeight = phpgw_getWindowOuterHeight(); |
---|
47 | |
---|
48 | positionLeft = (windowWidth/2)-(_width/2)+phpgw_getWindowLeft(); |
---|
49 | positionTop = (windowHeight/2)-(_height/2)+phpgw_getWindowTop(); |
---|
50 | |
---|
51 | windowID = window.open(_url, _windowName, "width=" + _width + ",height=" + _height + |
---|
52 | ",screenX=" + positionLeft + ",left=" + positionLeft + ",screenY=" + positionTop + ",top=" + positionTop + |
---|
53 | ",location=no,menubar=no,directories=no,toolbar=no,scrollbars=yes,resizable=yes,status="+_status); |
---|
54 | |
---|
55 | return windowID; |
---|
56 | } |
---|
57 | |
---|
58 | function phpgw_openWindowCentered(_url, _windowName, _width, _height) |
---|
59 | { |
---|
60 | return phpgw_openWindowCentered2(_url, _windowName, _width, _height, 'no'); |
---|
61 | } |
---|
62 | |
---|
63 | // return the left position of the window |
---|
64 | function phpgw_getWindowLeft() |
---|
65 | { |
---|
66 | if(is_mozilla) |
---|
67 | { |
---|
68 | return window.screenX; |
---|
69 | } |
---|
70 | else |
---|
71 | { |
---|
72 | return window.screenLeft; |
---|
73 | } |
---|
74 | } |
---|
75 | |
---|
76 | // return the left position of the window |
---|
77 | function phpgw_getWindowTop() |
---|
78 | { |
---|
79 | if(is_mozilla) |
---|
80 | { |
---|
81 | return window.screenY; |
---|
82 | } |
---|
83 | else |
---|
84 | { |
---|
85 | //alert(window.screenTop); |
---|
86 | return window.screenTop-90; |
---|
87 | } |
---|
88 | } |
---|
89 | |
---|
90 | // get the outerWidth of the browser window. For IE we simply return the innerWidth |
---|
91 | function phpgw_getWindowInnerWidth() |
---|
92 | { |
---|
93 | if (is_mozilla) |
---|
94 | { |
---|
95 | return window.innerWidth; |
---|
96 | } |
---|
97 | else |
---|
98 | { |
---|
99 | // works only after the body has parsed |
---|
100 | //return document.body.offsetWidth; |
---|
101 | return document.body.clientWidth; |
---|
102 | //return document.documentElement.clientWidth; |
---|
103 | } |
---|
104 | } |
---|
105 | |
---|
106 | // get the outerHeight of the browser window. For IE we simply return the innerHeight |
---|
107 | function phpgw_getWindowInnerHeight() |
---|
108 | { |
---|
109 | if (is_mozilla) |
---|
110 | { |
---|
111 | return window.innerHeight; |
---|
112 | } |
---|
113 | else |
---|
114 | { |
---|
115 | // works only after the body has parsed |
---|
116 | //return document.body.offsetHeight; |
---|
117 | //return document.body.clientHeight; |
---|
118 | return document.documentElement.clientHeight; |
---|
119 | } |
---|
120 | } |
---|
121 | |
---|
122 | // get the outerWidth of the browser window. For IE we simply return the innerWidth |
---|
123 | function phpgw_getWindowOuterWidth() |
---|
124 | { |
---|
125 | if (is_mozilla) |
---|
126 | { |
---|
127 | return window.outerWidth; |
---|
128 | } |
---|
129 | else |
---|
130 | { |
---|
131 | return phpgw_getWindowInnerWidth(); |
---|
132 | } |
---|
133 | } |
---|
134 | |
---|
135 | // get the outerHeight of the browser window. For IE we simply return the innerHeight |
---|
136 | function phpgw_getWindowOuterHeight() |
---|
137 | { |
---|
138 | if (is_mozilla) |
---|
139 | { |
---|
140 | return window.outerHeight; |
---|
141 | } |
---|
142 | else |
---|
143 | { |
---|
144 | return phpgw_getWindowInnerHeight(); |
---|
145 | } |
---|
146 | } |
---|
147 | |
---|
148 | |
---|
149 | |
---|
150 | function changeSorting(_sort) { |
---|
151 | resetMessageSelect(); |
---|
152 | |
---|
153 | document.getElementById('messageCounter').innerHTML = '<span style="font-weight: bold;">Change sorting ...</span>'; |
---|
154 | document.getElementById('divMessageList').innerHTML = ''; |
---|
155 | xajax_doXMLHTTP("felamimail.ajaxfelamimail.changeSorting",_sort); |
---|
156 | } |
---|
157 | |
---|
158 | function onNodeSelect(_nodeID) { |
---|
159 | window.location.href = nodeSelectURL+'&folderid='+_nodeID; |
---|
160 | } |
---|
161 | |
---|
162 | function onNodeSelectRight(_nodeID) { |
---|
163 | var nodeObject = false; |
---|
164 | var domObject; |
---|
165 | var top=0; |
---|
166 | var left=0; |
---|
167 | |
---|
168 | if(nodeObject = tree._globalIdStorageFind(_nodeID)) { |
---|
169 | domObject = nodeObject.htmlNode.childNodes[0].childNodes[0].childNodes[3].childNodes[0]; |
---|
170 | top = getPosTop(domObject) + domObject.offsetHeight; |
---|
171 | left = getPosLeft(domObject) + 10; |
---|
172 | |
---|
173 | resultBox = document.getElementById('rightClickMenu'); |
---|
174 | resultBox.style.top=top + 'px'; |
---|
175 | resultBox.style.left=left + 'px'; |
---|
176 | resultBox.style.display='block'; |
---|
177 | } |
---|
178 | } |
---|
179 | |
---|
180 | function selectFolder(_folderID, _formName) { |
---|
181 | openDlg = phpgw_openWindowCentered(folderChooserURL+"&form="+_formName+"&mode=3&exlcude=-1&folderid="+_folderID,'openDlg',300,450); |
---|
182 | } |
---|
183 | |
---|
184 | function getPosLeft(_node) { |
---|
185 | var left=0; |
---|
186 | |
---|
187 | if(_node.offsetParent) { |
---|
188 | while (_node.offsetParent) |
---|
189 | { |
---|
190 | left += _node.offsetLeft; |
---|
191 | _node = _node.offsetParent; |
---|
192 | } |
---|
193 | } else if (_node.x) { |
---|
194 | left += _node.x; |
---|
195 | } |
---|
196 | |
---|
197 | return left; |
---|
198 | } |
---|
199 | |
---|
200 | function getPosTop(_node) { |
---|
201 | var top=0; |
---|
202 | |
---|
203 | if(_node.offsetParent) { |
---|
204 | while (_node.offsetParent) { |
---|
205 | top += _node.offsetTop; |
---|
206 | if(_node.parentNode.scrollTop) { |
---|
207 | top -= _node.parentNode.scrollTop |
---|
208 | } |
---|
209 | _node = _node.offsetParent; |
---|
210 | } |
---|
211 | } else if (_node.y) { |
---|
212 | left += _node.y; |
---|
213 | } |
---|
214 | |
---|
215 | return top; |
---|
216 | } |
---|
217 | |
---|