1 | XEvents.add( window, "onload", function( ) |
---|
2 | { |
---|
3 | if ( template == 'classic' || template == 'celepar' ) |
---|
4 | return false; |
---|
5 | |
---|
6 | var icons = document.getElementById( "app_icons" ).getElementsByTagName( "td" ); |
---|
7 | for ( var i = 0; i < icons.length; i++ ) |
---|
8 | { |
---|
9 | XEvents.add( icons.item( i ), "onmouseover", function( ) |
---|
10 | { |
---|
11 | if ( this.className != "navbar_butOut" ) |
---|
12 | { |
---|
13 | this.className = "navbar_butOver"; |
---|
14 | /*zoom_in( this.firstChild.firstChild.id );*/ |
---|
15 | } |
---|
16 | } ); |
---|
17 | XEvents.add( icons.item( i ), "onmouseout", function( ) |
---|
18 | { |
---|
19 | if ( this.className != "navbar_butOut" ) |
---|
20 | { |
---|
21 | this.className = "navbar_but"; |
---|
22 | /*zoom_out( this.firstChild.firstChild.id );*/ |
---|
23 | } |
---|
24 | } ); |
---|
25 | XEvents.add( icons.item( i ), "onclick", function( ) |
---|
26 | { |
---|
27 | if ( this.className != "navbar_butOut" ) |
---|
28 | { |
---|
29 | this.className = "navbar_butOut"; |
---|
30 | /*zoom_out( this.firstChild.firstChild.id );*/ |
---|
31 | var app = document.getElementById( curr_app ); |
---|
32 | if ( app ) |
---|
33 | app.parentNode.parentNode.className= "navbar_but"; |
---|
34 | //curr_app = "' . str_replace( '_', '', $app ) . 'id" |
---|
35 | } |
---|
36 | } ); |
---|
37 | } |
---|
38 | } ); |
---|
39 | |
---|
40 | function openWindow( newWidth, newHeight, link ) |
---|
41 | { |
---|
42 | newScreenX = screen.width - newWidth; |
---|
43 | newScreenY = 0; |
---|
44 | Window1 = window.open( link, "", |
---|
45 | "width=" + newWidth + ", height=" + newHeight |
---|
46 | + ", screenX=" + newScreenX + ", screenY=" + newScreenY |
---|
47 | + ", top=" + newScreenY + ", left=" + newScreenX |
---|
48 | + ", toolbar=no, scrollbars=yes, resizable=no" |
---|
49 | ); |
---|
50 | } |
---|
51 | |
---|
52 | function borkb(size){ |
---|
53 | kbyte = 1024; |
---|
54 | mbyte = kbyte*1024; |
---|
55 | gbyte = mbyte*1024; |
---|
56 | if (!size) |
---|
57 | size = 0; |
---|
58 | if (size < kbyte) |
---|
59 | return size + ' B'; |
---|
60 | else if (size < mbyte) |
---|
61 | return parseInt(size/kbyte) + ' KB'; |
---|
62 | else if (size < gbyte) |
---|
63 | if (size/mbyte > 100) |
---|
64 | return (size/mbyte).toFixed(0) + ' MB'; |
---|
65 | else |
---|
66 | return (size/mbyte).toFixed(1) + ' MB'; |
---|
67 | else |
---|
68 | return (size/gbyte).toFixed(1) + ' GB'; |
---|
69 | } |
---|
70 | |
---|
71 | function url_encode(str){ |
---|
72 | return escape(str); |
---|
73 | } |
---|
74 | function url_decode(str) { |
---|
75 | return unescape(str); |
---|
76 | } |
---|
77 | |
---|
78 | function replaceAll(string, token, newtoken) { |
---|
79 | while (string.indexOf(token) != -1) { |
---|
80 | string = string.replace(token, newtoken); |
---|
81 | } |
---|
82 | return string; |
---|
83 | } |
---|
84 | |
---|
85 | function config_events(pObj, pEvent, pHandler) |
---|
86 | { |
---|
87 | if( typeof pObj == 'object') |
---|
88 | { |
---|
89 | if( pEvent.substring(0, 2) == 'on') |
---|
90 | pEvent = pEvent.substring(2, pEvent.length); |
---|
91 | |
---|
92 | if ( pObj.addEventListener ) |
---|
93 | pObj.addEventListener(pEvent, pHandler, false); |
---|
94 | else if( pObj.attachEvent ) |
---|
95 | pObj.attachEvent('on' + pEvent, pHandler ); |
---|
96 | } |
---|
97 | } |
---|
98 | |
---|
99 | function createAndSet(elemType,attributes,values,innerCode){ |
---|
100 | var elem = document.createElement(elemType); |
---|
101 | for(i=0; i < attributes.length; i++){ |
---|
102 | elem.setAttribute(attributes[i],values[i]); |
---|
103 | } |
---|
104 | if(typeof(innerCode) != 'undefined') |
---|
105 | elem.innerHTML = innerCode; |
---|
106 | return elem; |
---|
107 | } |
---|
108 | |
---|
109 | function appendChilds(elem){ |
---|
110 | for(i = 1; typeof(arguments[i]) != 'undefined'; i++) |
---|
111 | elem.appendChild(arguments[i]); |
---|
112 | return elem; |
---|
113 | } |
---|
114 | |
---|
115 | function removeAll(id){ |
---|
116 | do |
---|
117 | { |
---|
118 | if (typeof(Element(id)) == 'undefined') |
---|
119 | break; |
---|
120 | Element(id).parentNode.removeChild(Element(id)); |
---|
121 | } |
---|
122 | while(Element(id)); |
---|
123 | } |
---|
124 | function validateEmail(email){ |
---|
125 | if (typeof(email) != 'string') |
---|
126 | return false; |
---|
127 | var validName = /^[a-z][a-z-_0-9\.]*/i; |
---|
128 | emailParts = email.split('@'); |
---|
129 | return (validName.test(emailParts[0]) && validateDomain(emailParts[1])); |
---|
130 | } |
---|
131 | function validateDomain(domain){ |
---|
132 | var domainReg = /^(([A-Za-z\d][A-Za-z\d-]{0,61}[A-Za-z\d]\.)+[A-Za-z]{2,6}|\[\d{1,3}(\.\d{1,3}){3}\])$/i; |
---|
133 | return (domainReg.test(domain)); |
---|
134 | } |
---|
135 | |
---|
136 | function validateUrl(url){ |
---|
137 | var urlReg = /([A-Za-z]{2,7}:\/\/)(.*)/i; |
---|
138 | urlParts = url.split(urlReg); |
---|
139 | return (urlParts[1].length > 4 && validateDomain(urlParts[2])); |
---|
140 | } |
---|
141 | |
---|
142 | function trim(inputString) { |
---|
143 | if (typeof inputString != "string") |
---|
144 | return inputString; |
---|
145 | |
---|
146 | var retValue = inputString; |
---|
147 | var ch = retValue.substring(0, 1); |
---|
148 | while (ch == " ") { |
---|
149 | retValue = retValue.substring(1, retValue.length); |
---|
150 | ch = retValue.substring(0, 1); |
---|
151 | } |
---|
152 | ch = retValue.substring(retValue.length-1, retValue.length); |
---|
153 | while (ch == " ") { |
---|
154 | retValue = retValue.substring(0, retValue.length-1); |
---|
155 | ch = retValue.substring(retValue.length-1, retValue.length); |
---|
156 | } |
---|
157 | while (retValue.indexOf(" ") != -1) { |
---|
158 | retValue = retValue.substring(0, retValue.indexOf(" ")) + retValue.substring(retValue.indexOf(" ")+1, retValue.length); |
---|
159 | } |
---|
160 | return retValue; |
---|
161 | } |
---|
162 | |
---|
163 | |
---|
164 | function LTrim(value){ |
---|
165 | var w_space = String.fromCharCode(32); |
---|
166 | var strTemp = ""; |
---|
167 | var iTemp = 0; |
---|
168 | |
---|
169 | var v_length = value ? value.length : 0; |
---|
170 | if(v_length < 1) |
---|
171 | return ""; |
---|
172 | |
---|
173 | while(iTemp < v_length){ |
---|
174 | if(value && value.charAt(iTemp) != w_space){ |
---|
175 | strTemp = value.substring(iTemp,v_length); |
---|
176 | break; |
---|
177 | } |
---|
178 | iTemp++; |
---|
179 | } |
---|
180 | return strTemp; |
---|
181 | } |
---|
182 | |
---|
183 | |
---|
184 | function add_className(obj, className){ |
---|
185 | if (obj && !exist_className(obj, className)) |
---|
186 | obj.className = obj.className + ' ' + className; |
---|
187 | } |
---|
188 | |
---|
189 | function remove_className(obj, className){ |
---|
190 | var re = new RegExp("\\s*"+className); |
---|
191 | if (obj) |
---|
192 | obj.className = obj.className.replace(re, ' '); |
---|
193 | } |
---|
194 | |
---|
195 | function exist_className(obj, className){ |
---|
196 | return ( obj && obj.className.indexOf(className) != -1 ); |
---|
197 | } |
---|
198 | |
---|
199 | |
---|
200 | |
---|
201 | function validate_date(date){ |
---|
202 | if (date.match(/^[0-3][0-9]\/[0-1][0-9]\/\d{4,4}$/)) |
---|
203 | { |
---|
204 | tmp = date.split('/'); |
---|
205 | |
---|
206 | day = new Number(tmp[0]); |
---|
207 | month = new Number(tmp[1]); |
---|
208 | year = new Number(tmp[2]); |
---|
209 | if (month >= 1 && month <= 12 && day >= 1 && day <= 31) |
---|
210 | { |
---|
211 | if (month == 02 && day <= 29) |
---|
212 | { |
---|
213 | return true; |
---|
214 | } |
---|
215 | return true; |
---|
216 | } |
---|
217 | else |
---|
218 | { |
---|
219 | return false; |
---|
220 | } |
---|
221 | } |
---|
222 | else |
---|
223 | { |
---|
224 | return false; |
---|
225 | } |
---|
226 | } |
---|
227 | |
---|
228 | // Translate words and phrases using user language from eGroupware. |
---|
229 | function get_lang(_key) { |
---|
230 | try |
---|
231 | { |
---|
232 | var key = _key.toLowerCase(); |
---|
233 | if(array_lang[key]) |
---|
234 | var _value = array_lang[key]; |
---|
235 | else |
---|
236 | var _value = _key+"*"; |
---|
237 | |
---|
238 | if(arguments.length > 1) |
---|
239 | for(j = 1; typeof(arguments[j]) != 'undefined'; j++) |
---|
240 | _value = _value.replace("%"+j,arguments[j]); |
---|
241 | return _value; |
---|
242 | } |
---|
243 | catch ( e ) |
---|
244 | { |
---|
245 | return _key+"*"; |
---|
246 | } |
---|
247 | } |
---|
248 | |
---|
249 | |
---|
250 | function showBar(){ |
---|
251 | bar = document.getElementById("toolbar"); |
---|
252 | bar.style.visibility = ""; |
---|
253 | bar.style.position ="static"; |
---|
254 | but = document.getElementById("hiddenButton"); |
---|
255 | but.style.visibility = ""; |
---|
256 | but.style.position = "absolute"; |
---|
257 | but.style.top = "5px"; |
---|
258 | but.style.left = "5px"; |
---|
259 | title = get_lang('hide_bar_txt'); |
---|
260 | extra = document.getElementById("extraButton"); |
---|
261 | extra.style.visibility = "hidden"; |
---|
262 | but.innerHTML='<a title="' +title + '" onClick="javascript:changeBar()"><img alt="'+get_lang('hide details')+'" src="' + URL_SERVER + 'phpgwapi/templates/default/images/up.button.png" /></a>'; |
---|
263 | var neverExpires = new Date("January 01, 2100 00:00:00"); |
---|
264 | document.cookie = "showHeader=true"+ |
---|
265 | ";expires=" + neverExpires.toGMTString()+ |
---|
266 | ";path=/"; |
---|
267 | } |
---|
268 | |
---|
269 | function hideBar(){ |
---|
270 | bar = document.getElementById("toolbar"); |
---|
271 | bar.style.position ="absolute"; |
---|
272 | bar.style.visibility = "hidden"; |
---|
273 | but = document.getElementById("hiddenButton"); |
---|
274 | but.style.visibility = "hidden"; |
---|
275 | title = get_lang('show_bar_txt'); |
---|
276 | extra = document.getElementById("extraButton"); |
---|
277 | extra.style.visibility = ""; |
---|
278 | extra.style.top = "7px"; |
---|
279 | extra.style.left = "7px"; |
---|
280 | var neverExpires = new Date("January 01, 2100 00:00:00"); |
---|
281 | document.cookie = "showHeader=false"+ |
---|
282 | ";expires=" + neverExpires.toGMTString()+ |
---|
283 | ";path=/"; |
---|
284 | } |
---|
285 | function changeBar(){ |
---|
286 | bar = document.getElementById("toolbar"); |
---|
287 | if(bar.style.visibility == "hidden") |
---|
288 | showBar(); |
---|
289 | else |
---|
290 | hideBar(); |
---|
291 | } |
---|
292 | function initBar(val){ |
---|
293 | |
---|
294 | if(val == 'true') |
---|
295 | showBar(); |
---|
296 | else |
---|
297 | hideBar(); |
---|
298 | } |
---|
299 | var zoomTimer = { '_in': [] , '_out': [] }; |
---|
300 | var imgSize = []; |
---|
301 | |
---|
302 | function zoom_in(id) |
---|
303 | { |
---|
304 | clearTimeout(zoomTimer._out[id]); |
---|
305 | var elem = document.getElementById(id); |
---|
306 | if (imgSize[id] == undefined) |
---|
307 | imgSize[id]=elem.height; |
---|
308 | |
---|
309 | if (elem.height > (imgSize[id]+10)) |
---|
310 | { |
---|
311 | clearTimeout(zoomTimer._in[id]); |
---|
312 | return false; |
---|
313 | } |
---|
314 | var propor = (elem.width/elem.height); |
---|
315 | elem.height += 3; |
---|
316 | elem.width += propor*3; |
---|
317 | zoomTimer._in[id] = setTimeout('zoom_in("'+id+'");',30); |
---|
318 | } |
---|
319 | function zoom_out(id) |
---|
320 | { |
---|
321 | clearTimeout(zoomTimer._in[id]); |
---|
322 | var elem = document.getElementById(id); |
---|
323 | if ( ! elem ) |
---|
324 | return; |
---|
325 | if (elem.height < imgSize[id]) |
---|
326 | { |
---|
327 | clearTimeout(zoomTimer._out[id]); |
---|
328 | return false; |
---|
329 | } |
---|
330 | var propor = (elem.width/elem.height); |
---|
331 | elem.height -= 3; |
---|
332 | elem.width -= propor*3; |
---|
333 | zoomTimer._out[id] = setTimeout('zoom_out("'+id+'");',30); |
---|
334 | }; |
---|
335 | |
---|