source: trunk/instant_messenger/js/im_win.js @ 55

Revision 55, 41.4 KB checked in by niltonneto, 17 years ago (diff)

Nova versão do Instant Messenger.

  • Property svn:eol-style set to native
  • Property svn:executable set to *
Line 
1var im_win = {
2
3   chat_pJid : null,
4   _imWindowTemplate : null,
5   xslWin : false,
6   photo  : false,
7       
8   "load" : function()
9   {
10      try
11      {
12                        backFantom = func.newEl('div');
13                        func.confEl(backFantom, 'id', 'backFantom');
14                        func.confEl(backFantom, 'style', 'position:absolute;top:0px;left:0px;width:100%;height:100%;z-Index:-1;');
15
16                        test = func.newEl('div');
17                        func.confEl(test, 'id', 'test');
18                        func.confEl(test, 'style', 'visibility: hidden;');
19
20                        menu_contato = func.newEl('div');
21                        func.confEl(menu_contato, 'id', 'menu_contato');
22                        func.confEl(menu_contato, 'class', 'menu_im');
23                        func.confEl(menu_contato, 'style', 'position:absolute;z-index:99999');
24
25                        emotions = func.newEl('div');
26                        func.confEl(emotions, 'id', 'shared_emotions');
27                        func.confEl(emotions, 'class', 'emotionFrame');
28                        func.confEl(emotions, 'style', 'position:absolute;padding:1px;left:350px;visibility:hidden;top:0px');
29
30                        font_name = func.newEl('div');
31                        func.confEl(font_name, 'id', 'shared_fontName');
32                        func.confEl(font_name, 'class', 'statusMenu');
33                        func.confEl(font_name, 'style', 'position:absolute;visibility:hidden;padding:1px;left:400px;top:0px');
34
35                        font_size = func.newEl('div');
36                        func.confEl(font_size, 'id', 'shared_fontSize');
37                        func.confEl(font_size, 'class', 'statusMenu');
38                        func.confEl(font_size, 'style', 'position:absolute;visibility:hidden;padding:1px;left:400px;top:0px');
39
40                        font_color = func.newEl('div');
41                        func.confEl(font_color, 'id', 'shared_fontColor');
42                        func.confEl(font_color, 'class', 'statusMenu');
43                        func.confEl(font_color, 'style', 'position:absolute;visibility:hidden;padding:1px;left:400px;top:0px');
44
45                        font_style = func.newEl('div');
46                        func.confEl(font_style, 'id', 'shared_fontStyle');
47                        func.confEl(font_style, 'class', 'statusMenu');
48                        func.confEl(font_style, 'style', 'position:absolute;visibility:hidden;padding:1px;left:400px;top:0px');
49
50                        func.insEl(backFantom, test, menu_contato, emotions, font_name, font_size, font_color, font_style, false);
51
52                        emotions.innerHTML = Templates.emotions();
53                        font_name.innerHTML = Templates.font_name();
54                        font_size.innerHTML = Templates.font_size();
55                        font_color.innerHTML = Templates.font_color();
56                        font_style.innerHTML = Templates.font_style();
57
58                        pId = 'contacts';
59
60                        main_menu_all = func.newEl('div');
61                        func.confEl(main_menu_all, 'style', 'margin: 3px;');
62
63                        main_menu_head = func.newEl('div');
64                        func.confEl(main_menu_head, 'id', pId + '_im_window_body_inner_head');
65                        func.confEl(main_menu_head, 'style', 'margin: 0px 0px 3px 0px; border: 1px solid #809aa9; display: block;');
66
67                        main_menu_vcard = func.newEl('div');
68                        func.confEl(main_menu_vcard, 'id', 'im_vcard_contacts');
69                        func.confEl(main_menu_vcard, 'style', 'display: none;');
70
71                        main_menu_body = func.newEl('div');
72                        func.confEl(main_menu_body, 'id', 'div_contacts');
73                        func.confEl(main_menu_body, 'style', 'border: 1px solid #809aa9;');
74
75                        func.insEl(main_menu_head, main_menu_vcard, main_menu_body, main_menu_all);
76
77                        main_menu_head_picture = func.newEl('img');
78                        func.confEl(main_menu_head_picture, 'id', pId + '_avatar');
79                        func.confEl(main_menu_head_picture, 'src', img_photo.src);
80                        func.confEl(main_menu_head_picture, 'style', 'float: left; height: 65px; margin: 2px; width: 49px;');
81
82                        main_menu_head_name = func.newEl('span');
83                        func.confEl(main_menu_head_name, 'id', 'span_nickname');
84                        main_menu_head_name_txt = document.createTextNode(" your nickname");
85                        func.insEl(main_menu_head_name_txt, main_menu_head_name);
86
87                        br1 = func.newEl('br');
88
89                        main_menu_head_message = func.newEl('span');
90                        func.confEl(main_menu_head_message, 'id', 'span_message');
91                        main_menu_head_message_txt = document.createTextNode(' your message');
92                        func.insEl(main_menu_head_message_txt, main_menu_head_message);
93
94                        br2 = func.newEl('br');
95
96                        func.insEl(main_menu_head_picture, main_menu_head_name, br1, main_menu_head_message, br2, main_menu_head);
97
98                        main_menu_head_div = func.newEl("div");
99                        func.confEl(main_menu_head_div,'id','menu_preferences');
100                        func.confEl(main_menu_head_div,'class','menu_im');
101                        func.confEl(main_menu_head_div,'style','float: left;cursor:pointer');
102
103                        func.insEl(main_menu_head_div, false);
104
105                    var params = [];
106                        params['body']       = main_menu_all;
107                        params['close']      = true;
108                        params['height']     = 260;
109                        params['left']       = 10;
110                        params['id']         = pId;
111                        params['maximize']   = true;
112                        params['style']      = 'visibility:hidden';
113                        params['title']      = ".: " + IM.get_lang("instant_messenger") + " :.";
114                        params['top']        = 10;
115                        params['width']      = 200;
116                        this.build(params);
117
118                        this.config(pId);
119
120                        this.windowMinimize(pId + '_im');
121
122                        main_menu_head.innerHTML += '<span id="span_menu_pref" style="float: left;" onmousedown="IM.menu_preferences(event ,\'menu_preferences\'); document.oncontextmenu = new Function(\'return false\');"></span>';
123
124                        br3 = func.newEl('br');
125                        func.confEl(br3, 'style', 'clear: both');
126
127                        div_ie = func.newEl('div');
128
129                        func.insEl(br3, div_ie, main_menu_head);
130
131                        main_menu_head_pref_img = func.newEl('img');
132                        func.confEl(main_menu_head_pref_img, 'src', img_group_close.src);
133                        func.confEl(main_menu_head_pref_img, 'id', 'img_pref');
134
135                        main_menu_head_pref_txt = document.createTextNode(IM.get_lang('Options'));
136
137                        func.insEl(main_menu_head_pref_img, main_menu_head_pref_txt, 'span_menu_pref');
138      }
139      catch(e)
140      {
141         alert("load\n\n" + e + "\n\n" + e.description)
142      }
143   },
144
145   "config" : function(pId)
146   {
147      try
148      {
149         ADD_DHTML("backFantom"+NO_DRAG);
150         ADD_DHTML("shared_fontStyle"+NO_DRAG);
151         ADD_DHTML("shared_fontColor"+NO_DRAG);
152         ADD_DHTML("shared_fontSize"+NO_DRAG);
153         ADD_DHTML("shared_fontName"+NO_DRAG);
154         ADD_DHTML("shared_emotions"+NO_DRAG);
155         ADD_DHTML(pId+"_im_window_body_inner"+NO_DRAG);
156         ADD_DHTML(pId+"_im_window"+NO_DRAG);
157         ADD_DHTML(pId+"_im_window_master"+NO_DRAG);
158         ADD_DHTML(pId+"_im_window_fantom"+NO_DRAG);
159         ADD_DHTML(pId+"_im_window_movable"+CURSOR_MOVE);
160         ADD_DHTML(pId+"_im_window_resize"+CURSOR_NW_RESIZE);
161
162
163         dd.elements.backFantom.setOpacity(0);
164         document.getElementById("backFantom").style.zIndex = -1;
165
166
167         dd.elements.contacts_im_window_resize.moveTo(dd.elements.contacts_im_window.x+dd.elements.contacts_im_window.w-dd.elements.contacts_im_window_resize.w-2, dd.elements.contacts_im_window.y+dd.elements.contacts_im_window.h-dd.elements.contacts_im_window_resize.h-2);
168         dd.elements.contacts_im_window_movable.moveTo(dd.elements.contacts_im_window.x, dd.elements.contacts_im_window.y);
169         dd.elements.contacts_im_window_movable.setOpacity(0);
170
171         dd.elements.contacts_im_window_resize.setOpacity(1);
172         dd.elements.contacts_im_window_resize.moveTo(dd.elements.contacts_im_window_fantom.x+dd.elements.contacts_im_window_fantom.w-dd.elements.contacts_im_window_resize.w-2, dd.elements.contacts_im_window_fantom.y+dd.elements.contacts_im_window_fantom.h-dd.elements.contacts_im_window_resize.h-2);
173
174         var contacts_im_window = new Object();
175         contacts_im_window.x = dd.elements.contacts_im_window_master.x;
176         contacts_im_window.y = dd.elements.contacts_im_window_master.y;
177         contacts_im_window.w = dd.elements.contacts_im_window_master.w;
178         contacts_im_window.h = dd.elements.contacts_im_window_master.h;
179         contacts_im_window.state = WINDOW_STATE_REGULAR;
180         windowItems[pId] = contacts_im_window;
181      }
182      catch(e)
183      {
184         alert("config\n\n" + e + "\n\n" + e.description)
185      }
186   },
187
188   "build" : function()
189   {
190      var pBody       = '';
191      var pClose      = true;
192      var pHeight     = 360;
193      var pId         = false;
194      var pLeft       = NaN;
195      var pMaximize   = true;
196      var pMinimize   = true;
197      var pStyle      = '';
198      var pTitle      = '';
199      var pTop        = NaN;
200      var pWidth      = 250;
201      //for ( aa in arguments )
202      for ( var i = 0; i < arguments.length; i++ )
203      {
204         //if ( func.isArray(arguments[i]) )
205            for ( var n in arguments[i] )
206               if ( !func.isUndefined(arguments[i][n]) )
207                  switch ( n )
208                  {
209                     case 'body'    : pBody     = arguments[i][n]; break;
210                     case 'close'   : pClose    = arguments[i][n]; break;
211                     case 'height'  : pHeight   = arguments[i][n]; break;
212                     case 'id'      : pId       = arguments[i][n]; break;
213                     case 'left'    : pLeft     = arguments[i][n]; break;
214                     case 'maximize': pMaximize = arguments[i][n]; break;
215                     case 'minimize': pMinimize = arguments[i][n]; break;
216                     case 'style'   : pStyle    = arguments[i][n]; break;
217                     case 'title'   : pTitle    = arguments[i][n]; break;
218                     case 'top'     : pTop      = arguments[i][n]; break;
219                     case 'width'   : pWidth    = arguments[i][n]; break;
220                  }
221      }
222
223      if ( !pId || pHeight < 60 || pWidth < 100 )
224         return false;
225
226      if ( isNaN(pLeft) )
227         if ( windowItems[pId] )
228            pLeft = windowItems[pId].x;
229         else
230            pLeft = Math.floor(Math.random()*(dd.getWndH()-100));
231
232      if ( isNaN(pTop) )
233         if ( windowItems[pId] )
234            pTop = windowItems[pId].y;
235         else
236            pTop = Math.floor(Math.random()*(dd.getWndW()-pHeight-480))
237
238      if ( windowItems[pId] )
239      {
240         pHeight = dd.elements[pId + "_im_window_body_inner"].h;
241         pWidth = dd.elements[pId + "_im_window_body_inner"].w;
242      }
243
244      if ( !this.xslWin ) this.xslWin = XMLTools.load(im_path + 'xsl/window.xsl?' + Date.parse(new Date));
245      _xmlDoc = '<window id="' + pId + '" title="' + pTitle + '" height="' + pHeight + '" width="' + pWidth + '" left="' + pLeft + '" top="' + pTop + '" minimize="' + pMinimize + '" maximize="' + pMaximize  + '" close="' + pClose + '" style="position:absolute;' + pStyle + '" />';
246
247      a = document.createElement('div');
248
249      if (window.ActiveXObject)
250      {
251         var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
252         xmlDoc.async = "false";
253         xmlDoc.loadXML(_xmlDoc);
254      }
255      else
256      {
257         var parser = new DOMParser();
258         var xmlDoc = parser.parseFromString(_xmlDoc, "text/xml");
259      }
260      a.innerHTML = XMLTools.transform(xmlDoc, this.xslWin);
261      document.getElementsByTagName('body').item(0).appendChild(a);
262
263      switch ( typeof pBody )
264      {
265         case 'object' :
266                        func.insEl(pBody, pId + '_im_window_body_inner');
267         break;
268         case 'string' :
269                        func.byId(pId + '_im_window_body_inner').innerHTML = pBody;
270
271      }
272
273      RoundedTop('div#' + pId + '_im_window_master', '', '#cbdae4');
274      this.windowMaximizeZ(pId);
275
276   },
277
278   "hideAllChatSelections" : function()
279   {
280      this.hideEmotionSelection();
281      this.hideFontNameSelection();
282      this.hideFontSizeSelection();
283      this.hideFontColorSelection();
284      this.hideFontStyleSelection();
285   },
286
287   "hideWindowItem" : function(pId)
288   {
289      try
290      {
291         dd.elements[pId + "_im_window"].hide();
292         dd.elements[pId + "_im_window_master"].hide();
293         dd.elements[pId + "_im_window_fantom"].hide();
294         dd.elements[pId + "_im_window_resize"].hide();
295         dd.elements[pId + "_im_window_movable"].hide();
296         if ( (name_document = document.getElementById(pId + '_divEdita')) )
297         {
298            name_document.innerHTML = '';
299            var contact = func.byId(pId);
300            var _status = IM.vcard_contacts[contact.getAttribute('nuncontact')].online
301            contact.firstChild.src = ( _status == parseInt(1) ) ? img_online.src : img_offline.src;
302         }
303      }
304      catch(e)
305      {}
306   },
307
308   "incZ" : function()
309   {
310      zValue += 5;
311      return zValue;
312   },
313
314   "drag" : function()
315   {
316      try
317      {
318         var objName = dd.obj.name;
319         i = objName.indexOf("_");
320         objName = objName.substr(0,i);
321
322         this.incZ();
323         document.getElementById(objName + "_im_window_fantom").style.zIndex = zValue;
324         dd.elements[objName + "_im_window_fantom"].setOpacity(0.5);
325
326         document.getElementById(objName + "_im_window_fantom").className = "im_window_fantom";
327
328         var posX = dd.obj.x;
329         var posY = dd.obj.y;
330         if ( posX < 0 )
331            posX = 0;
332         if ( posY < 0 )
333            posY = 0;
334
335         dd.elements[objName + "_im_window_resize"].setOpacity(0);
336
337         if ( dd.obj.name == (objName + "_im_window_resize") )
338         {
339            windowState = WINDOW_STATE_REGULAR;
340
341            // check if the re-size goes out of the screen
342            if ( posX > ( dd.getWndW() - 15 ) )
343               posX = dd.getWndW()-15;
344            if ( posY > ( dd.getWndH() - 13 ) )
345               posY = dd.getWndH()-13;
346
347            // everything is fine, let's change the size of all required objects
348            var newW = posX-dd.elements[objName + "_im_window_fantom"].x+15;
349            var newH = posY-dd.elements[objName + "_im_window_fantom"].y+15;
350            if ( newW < 100) newW = 100;
351            if ( newH < 100) newH = 100;
352            dd.elements[objName + "_im_window_fantom"].resizeTo(newW, newH);
353            dd.elements[objName + "_im_window_resize"].moveTo(dd.elements[objName + "_im_window_fantom"].x+dd.elements[objName + "_im_window_fantom"].w-dd.elements[objName + "_im_window_resize"].w-2, dd.elements[objName + "_im_window_fantom"].y+dd.elements[objName + "_im_window_fantom"].h-dd.elements[objName + "_im_window_resize"].h-2);
354            var windowItem = windowItems[objName];
355            windowItem.state = WINDOW_STATE_REGULAR;
356         }
357         else
358         {
359            if ( posX > ( dd.getWndW() - dd.elements[objName + "_im_window_master"].w ) )
360               posX = dd.getWndW() - dd.elements[objName + "_im_window_master"].w;
361
362            if ( posY > ( dd.getWndH() - dd.elements[objName + "_im_window_master"].h ) )
363               posY = dd.getWndH() - dd.elements[objName + "_im_window_master"].h;
364
365            dd.elements[objName + "_im_window_fantom"].moveTo(posX, posY);
366         }
367      }
368      catch(e)
369      {
370      }
371   },
372
373   "drop" : function()
374   {
375      try
376      {
377         document.getElementById("backFantom").style.zIndex = -1;
378
379         var objName = dd.obj.name;
380         i = objName.indexOf("_");
381         objName = objName.substr(0,i);
382
383         var posX = dd.obj.x;
384         var posY = dd.obj.y;
385         if ( posX < 0 )
386            posX = 0;
387         if ( posY < 0 )
388            posY = 0;
389         if ( posX > ( dd.getWndW() - dd.elements[objName + "_im_window_master"].w ) )
390            posX = dd.getWndW() - dd.elements[objName + "_im_window_master"].w;
391         if ( posY > ( dd.getWndH() - dd.elements[objName + "_im_window_master"].h ) )
392            posY = dd.getWndH() - dd.elements[objName + "_im_window_master"].h;
393
394         dd.elements[objName + "_im_window_resize"].setOpacity(1);
395
396         if ( dd.obj.name == (objName + "_im_window_resize") )
397         {
398            var newW = dd.obj.x-dd.elements[objName + "_im_window_fantom"].x+17;
399            var newH = dd.obj.y-dd.elements[objName + "_im_window_fantom"].y+17;
400
401            if ( newW < 100) newW = 100;
402            if ( newH < 100) newH = 100;
403
404            var winW = dd.elements[objName + "_im_window_master"].w - dd.elements[objName + "_im_window"].w;
405            var winH = dd.elements[objName + "_im_window_master"].h - dd.elements[objName + "_im_window"].h;
406
407            dd.elements[objName + "_im_window_fantom"].resizeTo(newW, newH);
408            dd.elements[objName + "_im_window_master"].resizeTo(newW, newH);
409
410            var bodyW = dd.elements[objName + "_im_window"].w - dd.elements[objName + "_im_window_body_inner"].w;
411            var bodyH = dd.elements[objName + "_im_window"].h - dd.elements[objName + "_im_window_body_inner"].h;
412
413            dd.elements[objName + "_im_window"].resizeTo(newW - winW, newH - winH);
414
415            bodyW = dd.elements[objName + "_im_window"].w - bodyW;
416            bodyH = dd.elements[objName + "_im_window"].h - bodyH;
417
418            dd.elements[objName + "_im_window_body_inner"].resizeTo(bodyW, bodyH);
419
420            dd.elements[objName + "_im_window_movable"].resizeTo(newW-55, 25);
421            dd.elements[objName + "_im_window_resize"].moveTo(dd.elements[objName + "_im_window_fantom"].x+dd.elements[objName + "_im_window_fantom"].w-dd.elements[objName + "_im_window_resize"].w-2, dd.elements[objName + "_im_window_fantom"].y+dd.elements[objName + "_im_window_fantom"].h-dd.elements[objName + "_im_window_resize"].h-2);
422         }
423         else
424         {
425            dd.elements[objName + "_im_window_fantom"].moveTo(posX, posY);
426            dd.elements[objName + "_im_window_master"].moveTo(posX, posY);
427            dd.elements[objName + "_im_window"].moveTo(posX, (posY+4));
428            dd.elements[objName + "_im_window_movable"].moveTo(posX, posY);
429            dd.elements[objName + "_im_window_resize"].moveTo(dd.elements[objName + "_im_window_fantom"].x+dd.elements[objName + "_im_window_fantom"].w-dd.elements[objName + "_im_window_resize"].w-3, dd.elements[objName + "_im_window_fantom"].y+dd.elements[objName + "_im_window_fantom"].h-dd.elements[objName + "_im_window_resize"].h-3);
430         }
431
432         this.windowMaximizeZ(objName);
433
434         dd.elements[objName + "_im_window_fantom"].setOpacity(0);
435         var windowItem = windowItems[objName];
436
437         if ( windowItem != null )
438         {
439            windowItem.x = dd.elements[objName + "_im_window_master"].x;
440            windowItem.y = dd.elements[objName + "_im_window_master"].y;
441            windowItem.w = dd.elements[objName + "_im_window_master"].w;
442            windowItem.h = dd.elements[objName + "_im_window_master"].h;
443         }
444      }
445      catch(e)
446      {
447         //alert(e)
448      }
449   },
450
451   "pick" : function()
452   {
453      document.getElementById("backFantom").style.zIndex = zValue;
454      this.hideAllChatSelections();
455      var objName = dd.obj.name;
456      i = objName.indexOf("_im");
457      objName = objName.substr(0,i);
458      ACTIVE_OBJECTID = objName;
459   },
460
461   "showWindowItem" : function(pId)
462   {
463      if ( (name_document = document.getElementById(pId + '_divEdita')) )
464      {
465         name_document.innerHTML = '<iframe name="' + pId.replace('@', '_at_').replace(/\./g, '_dot_') + '_edita" class="edit_message" id="' + pId + '_edita" frameborder="0" style="border:margin: 3px 1px 0px 2px; width:220px; height:50px; float:left;"></iframe>';
466
467         name_document = document.getElementById(pId + '_edita');
468         name_document.contentWindow.document.write('<html><body id="' + pId.replace('@', '_at_').replace(/\./g, '_dot_') + '" style="margin:0px;padding:0px"></body></html>');
469         name_document.contentWindow.document.close();
470         name_document.contentWindow.document.designMode = "On";
471
472         func.attachEvent(name_document.contentWindow.document, 'keypress', im_win.getText);
473         func.attachEvent(name_document.contentWindow.document, 'keyup', im_win.clearText);
474
475         name_document.contentWindow.focus();
476      }
477
478      dd.elements[pId + "_im_window_master"].show();
479      dd.elements[pId + "_im_window"].show();
480      dd.elements[pId + "_im_window_fantom"].show();
481      dd.elements[pId + "_im_window_resize"].show();
482      dd.elements[pId + "_im_window_movable"].show();
483   },
484
485   "windowMaximizeZ" : function(objName)
486   {
487      try
488      {
489         this.incZ();
490         document.getElementById(objName + "_im_window_fantom").style.zIndex = zValue-3;
491         document.getElementById(objName + "_im_window_master").style.zIndex = zValue-2;
492         document.getElementById(objName + "_im_window").style.zIndex = zValue-1;
493         document.getElementById(objName + "_im_window_body_inner").style.zIndex = zValue-1;
494         document.getElementById(objName + "_im_window_resize").style.zIndex = zValue;
495         document.getElementById(objName + "_im_window_movable").style.zIndex = zValue;
496         if ( dd.elements[objName + "_im_window_movable"] )
497            dd.elements[objName + "_im_window_movable"].z = zValue+1;
498      }
499      catch(e)
500      {}
501   },
502
503   "windowMinimize" : function(objName)
504   {
505      with(objName)
506         objName = substr(0, indexOf('_im'));
507
508      this.hideWindowItem(objName);
509      windowItem = windowItems[objName];
510      if ( windowItem != null )
511      {
512         windowItem.state = WINDOW_STATE_MINIMIZED;
513      }
514
515   },
516
517   "windowMaximizeRestore" : function(objName)
518   {
519      with(objName)
520         objName = substr(0, indexOf('_im'));
521
522      this.hideAllChatSelections();
523
524      windowItem = windowItems[objName];
525
526      if ( windowItem != null )
527      {
528         var bodyW = dd.elements[objName + "_im_window"].w - dd.elements[objName + "_im_window_body_inner"].w;
529         var bodyH = dd.elements[objName + "_im_window"].h - dd.elements[objName + "_im_window_body_inner"].h;
530
531         if ( windowItem.state==WINDOW_STATE_REGULAR )
532         {
533            windowItem.x = dd.elements[objName + "_im_window_master"].x;
534            windowItem.y = dd.elements[objName + "_im_window_master"].y;
535            windowItem.w = dd.elements[objName + "_im_window_master"].w;
536            windowItem.h = dd.elements[objName + "_im_window_master"].h;
537
538            var bodyX = dd.elements[objName + "_im_window_body_inner"].x + dd.elements[objName + "_im_window"].x;
539            var bodyY = dd.elements[objName + "_im_window_body_inner"].y + dd.elements[objName + "_im_window"].y;
540
541            dd.elements[objName + "_im_window_fantom"].moveTo(0, 0);
542            dd.elements[objName + "_im_window_master"].moveTo(0, 0);
543            dd.elements[objName + "_im_window"].moveTo(0, 4);
544
545            dd.elements[objName + "_im_window_fantom"].resizeTo(dd.getWndW(), dd.getWndH());
546            dd.elements[objName + "_im_window_master"].resizeTo(dd.getWndW(), dd.getWndH());
547            dd.elements[objName + "_im_window"].resizeTo(dd.getWndW(), dd.getWndH() - 5);
548            dd.elements[objName + "_im_window_body_inner"].resizeTo(dd.getWndW() - bodyW, dd.getWndH() - bodyH - 5);
549
550            dd.elements[objName + "_im_window_resize"].moveTo(dd.elements[objName + "_im_window_fantom"].x+dd.elements[objName + "_im_window_fantom"].w-dd.elements[objName + "_im_window_resize"].w-2, dd.elements[objName + "_im_window_fantom"].y+dd.elements[objName + "_im_window_fantom"].h-dd.elements[objName + "_im_window_resize"].h-2);
551            windowItem.state = WINDOW_STATE_MAXIMIZED;
552
553            window.status = objName + "'s Z: " + document.getElementById(objName+"_im_window").style.zIndex;
554
555         }
556         else
557         {
558            dd.elements[objName + "_im_window_fantom"].resizeTo(windowItem.w, windowItem.h);
559            dd.elements[objName + "_im_window_master"].resizeTo(windowItem.w, windowItem.h);
560            dd.elements[objName + "_im_window"].resizeTo(windowItem.w, windowItem.h - 5);
561            dd.elements[objName + "_im_window_body_inner"].resizeTo(windowItem.w - bodyW, windowItem.h - bodyH - 5);
562
563            dd.elements[objName + "_im_window_fantom"].moveTo(windowItem.x, windowItem.y);
564            dd.elements[objName + "_im_window_master"].moveTo(windowItem.x, windowItem.y);
565            dd.elements[objName + "_im_window_resize"].moveTo(dd.elements[objName + "_im_window_fantom"].x+dd.elements[objName + "_im_window_fantom"].w-dd.elements[objName + "_im_window_resize"].w-2, dd.elements[objName + "_im_window_fantom"].y+dd.elements[objName + "_im_window_fantom"].h-dd.elements[objName + "_im_window_resize"].h-2);
566            windowItem.state = WINDOW_STATE_REGULAR;
567         }
568
569      dd.elements[objName + "_im_window_movable"].moveTo(dd.elements[objName + "_im_window"].x, dd.elements[objName + "_im_window"].y);
570      dd.elements[objName + "_im_window_movable"].resizeTo(dd.elements[objName + "_im_window"].w-55, 25);
571
572      this.showWindowItem(objName);
573      this.windowMaximizeZ(objName);
574      }
575     
576          if( !this.photo )
577          {
578                setTimeout('im_win.get_photo_ldap(\"user@user\")',1000 );
579                this.photo = true;
580          }
581   },
582
583   "create_window" : function()
584   {
585      pId = arguments[0]['id'];
586
587      if ( document.getElementById(pId + '_im_window'))
588      {
589         this.windowMaximizeZ(pId);
590         this.showWindowItem(pId);
591      }
592      else
593      {
594         this.build(arguments[0]);
595
596         ADD_DHTML(pId + "_im_window_body_inner"+NO_DRAG);
597         ADD_DHTML(pId + "_im_window"+NO_DRAG);
598         ADD_DHTML(pId + "_im_window_master"+NO_DRAG);
599         ADD_DHTML(pId + "_im_window_fantom"+NO_DRAG);
600         ADD_DHTML(pId + "_im_window_movable"+CURSOR_MOVE);
601         ADD_DHTML(pId + "_im_window_resize"+CURSOR_NW_RESIZE);
602
603         dd.elements[pId + "_im_window_movable"].moveTo(dd.elements[pId + "_im_window"].x, dd.elements[pId + "_im_window"].y);
604         dd.elements[pId + "_im_window_movable"].resizeTo(dd.elements[pId + "_im_window"].w-20, 25);
605         dd.elements[pId + "_im_window_movable"].setOpacity(0);
606
607         dd.elements[pId + "_im_window_resize"].setOpacity(1);
608
609         dd.elements[pId + "_im_window_resize"].moveTo(dd.elements[pId + "_im_window"].x+dd.elements[pId + "_im_window"].w-dd.elements[pId + "_im_window_resize"].w-2, dd.elements[pId + "_im_window"].y+dd.elements[pId + "_im_window"].h-dd.elements[pId + "_im_window_resize"].h-2);
610         dd.elements[pId + "_im_window_resize"].moveTo(dd.elements[pId + "_im_window_fantom"].x+dd.elements[pId + "_im_window_fantom"].w-dd.elements[pId + "_im_window_resize"].w-2, dd.elements[pId + "_im_window_fantom"].y+dd.elements[pId + "_im_window_fantom"].h-dd.elements[pId + "_im_window_resize"].h-2);
611
612         var windowItem = new Object();
613         windowItem.x = dd.elements[pId + "_im_window_master"].x;
614         windowItem.y = dd.elements[pId + "_im_window_master"].y;
615         windowItem.w = dd.elements[pId + "_im_window_master"].w;
616         windowItem.h = dd.elements[pId + "_im_window_master"].h;
617         windowItem.state = WINDOW_STATE_MINIMIZED;
618         windowItems[pId] = windowItem;
619
620         title = (arguments[0]['title']) ? arguments[0]['title'] : arguments[0]['id'];
621         this.windowMinimize(pId + '_im');
622         this.windowMaximizeRestore(pId + '_im');
623      }
624   },
625
626   "open_chat" : function(pId)
627   {
628      if ( !func.byId(pId + '_im_window') )
629      {
630         text = '';
631         text += '<div class="border" id="' + pId + '_chatMessages" style="width:220px; height:130px; margin: 2px 0px 2px 2px; overflow:auto;"></div>'
632         text += '<div style="float: left; position: relative; height:130px;">';
633         text += '   <div class="myAvatar">'
634         text += '      <img id="' + pId + '_avatar" alt="Display Picture" title="Display Picture" src="' + im_path + 'templates/default/images/photo.png" width="49" height="65" border="0" />'
635         text += '   </div>'
636         text += '   <div id="' + pId + '_composing" class="composing"><img src="' + img_typing.src + '" /></div>';
637         text += '</div>';
638         text += '<br style="clear:both;"/>'
639         text += '<dl>'
640         text += '   <dd class="small">'
641         text += '      &nbsp;<span id="selectEmotionsDiv" class="des-small" onmouseover="selectDiv(this)" onmouseout="unselectDiv(this)" onclick="im_win.showEmotionSelection(\'' + pId + '\');" title="Select Imotions here!"><img src="' + im_path + 'templates/default/images/img/1.gif" width="15" height="15" alt="Select Imotions here!" style="vertical-align:  text-top;" /></span>'
642         text += '   </dd>'
643         text += '   <dd class="small">|</dd>'
644         text += '   <dd class="small">'
645         text += '      <span id="selectFontNameDiv" class="des-small" onmouseover="selectDiv(this)" onmouseout="unselectDiv(this)" onclick="im_win.showFontNameSelection(\'' + pId + '\');" title="Select Font Name here!" style="height:19px;">'+IM.get_lang('Font')+'</span>'
646         text += '   </dd>'
647         text += '   <dd class="small">|</dd>'
648         text += '   <dd class="small">'
649         text += '      <span id="selectFontSizeDiv" class="des-small" onmouseover="selectDiv(this)" onmouseout="unselectDiv(this)" onclick="im_win.showFontSizeSelection(\'' + pId + '\')" title="Select Font Size here!" style="height:19px;">'+IM.get_lang('Size')+'</span>'
650         text += '   </dd>'
651         text += '   <dd class="small">|</dd>'
652         text += '   <dd class="small">'
653         text += '      <span id="selectFontColorDiv" class="des-small" onmouseover="selectDiv(this)" onmouseout="unselectDiv(this)" onclick="im_win.showFontColorSelection(\'' + pId + '\')" title="Select Font Color here!" style="height:19px;">'+IM.get_lang('Color')+'</span>'
654         text += '   </dd>'
655         text += '   <dd class="small">|</dd>'
656         text += '   <dd class="small">'
657         text += '      <span id="selectFontStyleDiv" class="des-small" onmouseover="selectDiv(this)" onmouseout="unselectDiv(this)" onclick="im_win.showFontStyleSelection(\'' + pId + '\')" title="Select Font Color here!" style="height:19px;">'+IM.get_lang('Style')+'</span>'
658         text += '   </dd>'
659         text += '</dl>'
660         text += '<div id="' + pId + '_divEdita" style="margin: 0px 2px"><iframe name="' + pId.replace('@', '_at_').replace(/\./g, '_dot_') + '_edita" class="edit_message" id="' + pId + '_edita" frameborder="0" style="margin: 3px 1px 0px 2px; width:220px; height:50px; float:left;"></iframe></div>'
661         text += '<br/><a onclick="javascript:IM.sendMessage(\'' + pId + '\')" title="Send a message" style="float:left;margin: 0px 2px;"><img src="' + im_path + 'templates/default/images/img/skins/deathdart/send.gif" width="50" height="25" border=0 style="margin-top:3px"></a>';
662         text += '<br style="clear:both" /><span id="' + pId + '_im_window_message" style="margin-left: 2px" />';
663
664         var params = [];
665         params['body']     = text;
666         params['height']   = 225;
667         params['id']       = pId;
668         params['maximize'] = false;
669         params['minimize'] = false;
670         params['title']    = pId;
671         params['width']    = 320;
672         this.create_window(params);
673
674         // Photo Ldap;
675         this.get_photo_ldap(pId);
676
677         name_document = document.getElementById(pId + '_edita');
678         name_document.contentWindow.document.write('<html><body id="' + pId.replace('@', '_at_').replace(/\./g, '_dot_') + '" style="margin:0px;padding:0px"></body></html>');
679         name_document.contentWindow.document.close();
680         name_document.contentWindow.document.designMode = "On";
681
682         func.attachEvent(name_document.contentWindow.document, 'keypress', im_win.getText);
683         func.attachEvent(name_document.contentWindow.document, 'keyup', im_win.clearText);
684
685         name_document.contentWindow.focus();
686         
687         var status = func.byId(pId + '_im_window');
688         status.firstChild.style.background = 'url('+func.byId(pId).firstChild.src+')';
689      }
690      else
691      {
692         this.showWindowItem(pId);
693      }
694   },
695
696   "get_photo_ldap" : function(IdLdap)
697   {
698                var uid_ldap = IdLdap.substr(0,IdLdap.indexOf('@'));
699                var handler_photo_ldap = function(_XMLdata)
700                {
701                        var data = _XMLdata.getElementsByTagName('retorno').item(0);
702                        data = eval(data.firstChild.nodeValue);
703                        if(data)
704                        {
705                                IdLdap = ( IdLdap == 'user@user' ) ? 'contacts' : IdLdap;
706                                if( document.getElementById(IdLdap + "_avatar") != null ){
707                                        var ph_img = document.getElementById(IdLdap + "_avatar");
708                                        ph_img.src = (im_path + "inc/class.ldap_im.inc.php?user="+uid_ldap) ? im_path + "inc/class.ldap_im.inc.php?user="+uid_ldap : img_photo.src ;
709                                }
710                        }
711                }
712
713            XMLTools.__RETURN_MODE__ = 'XML';
714                XMLTools.request('$this.ldap_im.photo_ldap','POST',handler_photo_ldap,'uid='+uid_ldap);
715   },
716
717   "windowClose" : function(objName)
718   {
719      with(objName)
720         objName = substr(0, indexOf('_im'));
721
722      this.hideWindowItem(objName);
723      this.hideAllChatSelections();
724
725      var windowItem = windowItems[objName];
726      if ( windowItem != null )
727         windowItem.state = WINDOW_STATE_CLOSED;
728
729      if ( objName != 'contacts' )
730      {
731         var win = document.getElementById(objName + '_im_window_master');
732         var resize = document.getElementById(objName + '_im_window_resize');
733         var fantom = document.getElementById(objName + '_im_window_fantom');
734         var movable = document.getElementById(objName + '_im_window_movable');
735
736         win.parentNode.removeChild(win);
737         resize.parentNode.removeChild(resize);
738         fantom.parentNode.removeChild(fantom);
739         movable.parentNode.removeChild(movable);
740
741         // delete windowItem;
742      }
743   },
744
745   "hideEmotionSelection" : function()
746   {
747      emotionsDiv = document.getElementById("shared_emotions");
748      if ( isEmotionSelectionVisible )
749      {
750         emotionsDiv.style.visibility = "hidden";
751         isEmotionSelectionVisible = false;
752      }
753   },
754
755   "highlightie5" : function (e)
756   {
757      if ( e.className == "emotionItem" )
758         e.className = "emotionItem-sel";
759      else if ( e.className == "menuitems" )
760         e.className = "menuitems-sel";
761
762   },
763
764   "lowlightie5" : function(e)
765   {
766      if ( e.className == "emotionItem-sel" )
767         e.className = "emotionItem";
768      else if ( e.className == "menuitems-sel" )
769         e.className = "menuitems";
770   },
771
772   "addEmotion" : function(emotion)
773   {
774         n_document = document.getElementById(this.chat_pJid + '_edita');
775         var edita = n_document.contentWindow.document.getElementsByTagName('body').item(0);
776         edita.innerHTML += IM.emotions_icons(emotion);
777
778     this.hideEmotionSelection();
779   },
780
781   "showEmotionSelection" : function(objName)
782   {
783      this.chat_pJid = objName;
784      activeChatWindowId = objName;
785      var emotionsDiv = document.getElementById("shared_emotions");
786      if(!isEmotionSelectionVisible)
787      {
788         this.hideAllChatSelections();
789         chatObj = dd.elements[objName + "_im_window"];
790         x = chatObj.x + 6;
791         y = chatObj.y + chatObj.h - 200;
792         dd.elements.shared_emotions.moveTo(x,y);
793         this.incZ();
794         document.getElementById("shared_emotions").style.zIndex = zValue;
795         emotionsDiv.style.visibility = "visible";
796         isEmotionSelectionVisible = true;
797      }
798      else
799      {
800         this.hideAllChatSelections();
801      }
802   },
803
804   "showFontNameSelection" : function(objName)
805   {
806      this.chat_pJid = objName;
807      activeChatWindowId = objName;
808      var objDiv = document.getElementById("shared_fontName");
809      if(!isFontNameSelectionVisible)
810      {
811         this.hideAllChatSelections();
812         chatObj = dd.elements[objName + "_im_window"];
813         x = chatObj.x + 85;
814         y = chatObj.y + chatObj.h - 185;
815         dd.elements.shared_fontName.moveTo(x,y);
816         this.incZ();
817         document.getElementById("shared_fontName").style.zIndex = zValue;
818         objDiv.style.visibility = "visible";
819         isFontNameSelectionVisible = true;
820      }
821      else
822      {
823         this.hideAllChatSelections();
824      }
825   },
826
827   "hideFontNameSelection" : function()
828   {
829      var objDiv = document.getElementById("shared_fontName");
830      if ( isFontNameSelectionVisible )
831      {
832         objDiv.style.visibility = "hidden";
833         isFontNameSelectionVisible = false;
834      }
835   },
836
837   "showFontSizeSelection" : function(objName)
838   {
839
840      this.chat_pJid = objName;
841      activeChatWindowId = objName;
842      var objDiv = document.getElementById("shared_fontSize");
843      if ( !isFontSizeSelectionVisible )
844      {
845         this.hideAllChatSelections();
846         chatObj = dd.elements[objName + "_im_window"];
847         x = chatObj.x + 154;
848         y = chatObj.y + chatObj.h - 200;
849         dd.elements.shared_fontSize.moveTo(x,y);
850         this.incZ();
851         document.getElementById("shared_fontSize").style.zIndex = zValue;
852         objDiv.style.visibility = "visible";
853         isFontSizeSelectionVisible = true;
854      }
855      else
856      {
857         this.hideAllChatSelections();
858      }
859   },
860
861   "hideFontSizeSelection" : function()
862   {
863      var objDiv = document.getElementById("shared_fontSize");
864      if ( isFontSizeSelectionVisible )
865      {
866         objDiv.style.visibility = "hidden";
867         isFontSizeSelectionVisible = false;
868      }
869   },
870
871   "showFontColorSelection" : function(objName)
872   {
873      this.chat_pJid = objName;
874      activeChatWindowId = objName;
875      var objDiv = document.getElementById("shared_fontColor");
876      if ( !isFontColorSelectionVisible )
877      {
878         this.hideAllChatSelections();
879         chatObj = dd.elements[objName + "_im_window"];
880         x = chatObj.x + 191;
881         y = chatObj.y + chatObj.h - 200;
882         dd.elements.shared_fontColor.moveTo(x,y);
883         this.incZ();
884         document.getElementById("shared_fontColor").style.zIndex = zValue;
885         objDiv.style.visibility = "visible";
886         isFontColorSelectionVisible = true;
887      }
888      else
889      {
890         this.hideAllChatSelections();
891      }
892   },
893
894   "showFontStyleSelection" : function(objName)
895   {
896      this.chat_pJid = objName;
897      activeChatWindowId = objName;
898      var objDiv = document.getElementById("shared_fontStyle");
899      if ( !isFontStyleSelectionVisible )
900      {
901         this.hideAllChatSelections();
902         chatObj = dd.elements[objName + "_im_window"];
903         x = chatObj.x + 234;
904         y = chatObj.y + chatObj.h - 181;
905         dd.elements.shared_fontStyle.moveTo(x,y);
906         this.incZ();
907         document.getElementById("shared_fontStyle").style.zIndex = zValue;
908         objDiv.style.visibility = "visible";
909         isFontStyleSelectionVisible = true;
910      }
911      else
912      {
913         this.hideAllChatSelections();
914      }
915   },
916
917   "showMessageHistoryWindow" : function()
918   {
919           // Revisar ALC
920      alert("Função Indisponivel");
921      return false;
922   },
923
924   "hideFontColorSelection" : function()
925   {
926      var objDiv = document.getElementById("shared_fontColor");
927      if ( isFontColorSelectionVisible )
928      {
929         objDiv.style.visibility = "hidden";
930         isFontColorSelectionVisible = false;
931      }
932   },
933
934   "hideFontStyleSelection" : function()
935   {
936      var objDiv = document.getElementById("shared_fontStyle");
937      if ( isFontStyleSelectionVisible )
938      {
939         objDiv.style.visibility = "hidden";
940         isFontStyleSelectionVisible = false;
941      }
942   },
943
944   "newMessageNotification" : function()
945   {
946      if ( !focusFlag )
947      {
948         if ( document.title=="......................" )
949            document.title = IM.get_lang("New Message!");
950         else
951            document.title = "......................";
952         
953         this.Mod_Notification();
954
955         if ( newMessageTimer )
956            clearTimeout(newMessageTimer);
957         newMessageTimer = setTimeout("im_win.newMessageNotification()", 1000);
958      }
959      else
960      {
961         if ( newMessageTimer ) clearTimeout(newMessageTimer);
962      }
963     
964   },
965
966   "Mod_Notification" : function()
967   {
968                // Aviso Normal
969                if(eval(IM_Preferences.LoadPreferences('rd_nm')))
970                {
971                }
972                // Aviso Chato           
973                if(eval(IM_Preferences.LoadPreferences('rd_ch')))
974                {
975                        if(self.moveBy)
976                        {
977                                for(i=10;i>0;i--)
978                                {
979                                  self.moveBy(i,0);
980                                  self.moveBy(-i,0);
981                                }
982                        }
983                }
984   },
985
986   "getText" : function(e)
987   {
988      if ( !focusFlag ) windowFocus();
989      evt = e.keyCode;
990      pId = ( e.srcElement ) ? e.srcElement.id : e.target.getElementsByTagName('body').item(0).id;
991      pId = pId.replace('_at_', '@').replace(/_dot_/g, '.')
992      switch ( evt )
993      {
994         case 13 :
995                  if ( !e.shiftKey )
996                     IM.sendMessage(pId);
997                  return false;
998         break;
999         case 27 :
1000                  im_win.windowClose(pId + '_im');
1001         break;
1002      }
1003   },
1004
1005   "clearText" : function(e)
1006   {
1007      if ( !focusFlag ) windowFocus();
1008      evt = e.keyCode;
1009      _text = ( e.srcElement ) ? e.srcElement.id : e.target.getElementsByTagName('body').item(0);
1010
1011      switch ( evt )
1012      {
1013         case 13 :
1014                  //if ( !e.shiftKey )
1015                     _text.innerHTML = '';
1016                     return false;
1017         break;
1018      }
1019   }
1020}
1021
1022function my_DragFunc()
1023{
1024   im_win.drag();
1025}
1026function my_DropFunc()
1027{
1028   im_win.drop();
1029}
1030function my_PickFunc()
1031{
1032   im_win.pick();
1033}
1034function selectDiv(obj) {
1035  obj.className = "sel-small";
1036}
1037function unselectDiv(obj) {
1038  obj.className = "des-small";
1039}
1040function getElementsBySelector(selector)
1041{
1042   var i;
1043   var s=[];
1044   var selid="";
1045   var selclass="";
1046   var tag=selector;
1047   var objlist=[];
1048   if ( selector.indexOf(" ") > 0 )
1049   {//descendant selector like "tag#id tag"
1050      s=selector.split(" ");
1051      var fs=s[0].split("#");
1052      if ( fs.length == 1 )
1053         return(objlist);
1054      return(document.getElementById(fs[1]).getElementsByTagName(s[1]));
1055   }
1056   if ( selector.indexOf("#") > 0 )
1057   {//id selector like "tag#id"
1058      s=selector.split("#");
1059      tag=s[0];
1060      selid=s[1];
1061   }
1062   if ( selid != "" )
1063   {
1064      objlist.push(document.getElementById(selid));
1065      return(objlist);
1066   }
1067   if ( selector.indexOf(".") > 0 )
1068   {//class selector like "tag.class"
1069      s=selector.split(".");
1070      tag=s[0];
1071      selclass=s[1];
1072   }
1073   var v = document.getElementsByTagName(tag);  // tag selector like "tag"
1074   if ( selclass == "" )
1075      return(v);
1076
1077   for ( i = 0; i < v.length; i++ )
1078      if ( v[i].className ==selclass )
1079         objlist.push(v[i]);
1080
1081   return(objlist);
1082}
1083function AddTop(el,bk,color,size)
1084{
1085   try
1086   {
1087      var i;
1088      var d=document.createElement("b");
1089      var cn="_r";
1090      var lim=4;
1091      if(size && size=="small"){ cn="_rs"; lim=2}
1092      d.className="_rtop";
1093      d.style.backgroundColor=bk;
1094      for(i=1;i<=lim;i++)
1095      {
1096         var x=document.createElement("b");
1097         x.className=cn + i;
1098         x.style.backgroundColor=color;
1099         d.appendChild(x);
1100      }
1101      el.insertBefore(d,el.firstChild);
1102   }
1103   catch(e)
1104   {}
1105}
1106function RoundedTop(selector,bk,color,size){
1107   var i;
1108   var v=getElementsBySelector(selector);
1109   for(i=0;i<v.length;i++)
1110          AddTop(v[i],bk,color,size);
1111}
1112
1113im_win.load();
Note: See TracBrowser for help on using the repository browser.