source: trunk/instant_messenger/js/templates.js @ 151

Revision 151, 10.6 KB checked in by niltonneto, 16 years ago (diff)

Commit da nova versão do módulo, usando agente em C.
Vide Página do módulo do Trac:
http://www.expressolivre.org/dev/wiki/messenger

A versão anterior encontra-se na subpasta bkp (32/64).

Line 
1function Templates()
2{
3        this.xtools             = new XTools();
4        this.zValue             = 100;
5        this.documentMousedown = null;
6        this.jabber     = new Jabber;
7}
8
9Templates.prototype = {
10
11        "add_user": function()
12        {
13                var XmlDoc = "<adduser>" +
14                                                 "<top>" +
15                                                         "<lang1>" + im.get_lang("Organization Unit")+ "</lang1>" +
16                                                 "</top>" +
17                                                 "<table>"+
18                                                         "<lang1>" + im.get_lang("Jid Contact") + "</lang1>" +
19                                                         "<lang2>" + im.get_lang("Nickname") + "</lang2>" +
20                                                         "<lang3>" + im.get_lang("Group") + "</lang3>" +
21                                                         "<lang4>" + im.get_lang("Add") + "</lang4>" +
22                                                         "<lang5>" + im.get_lang("Close") + "</lang5>" +                                                 
23                                                 "</table>" +
24                                         "</adduser>";
25                im_window.load('add_user_im','instant_messenger_content','<title>.:: Adicionar Novos Contatos ::.</title>','window.xsl','545',true,true,true);
26                im_window.elementC('add_user_im').innerHTML  = this.xtools.parse(XmlDoc,'add_user.xsl');
27                im.ldap();
28        },
29
30        "colors": function(pJid)
31        {
32                var Xmlsmiles = "<colors>" +   
33                                                        "<lang1>Black</lang1>" +
34                                                        "<lang2>Silver</lang2>" +
35                                                        "<lang3>Yellow</lang3>" +
36                                                        "<lang4>Red</lang4>" +
37                                                        "<lang5>Pink</lang5>" +
38                                                        "<lang6>Green</lang6>" +
39                                                        "<lang7>Blue</lang7>" +
40                                                        "<lang8>Magenta</lang8>" +
41                                                        "<path>"+path_im+"</path>" +
42                                                        "<name>"+pJid+"</name>" +
43                                                "</colors>";
44
45                menu_action.menu(pJid + '_button_dest', this.xtools.parse(Xmlsmiles,'colors.xsl'));
46                func.byId(pJid + '_button_dest').style.top = func.byId(pJid + '_button_color').offsetTop + 10;
47                func.byId(pJid + '_button_dest').style.left = func.byId(pJid + '_button_color').offsetLeft + 10;
48                func.byId(pJid + '_button_dest').style.zIndex = this.zValue++;
49                func.byId(pJid + '_button_dest').style.position = "absolute";
50        },
51
52        "fast_menu" : function()
53        {
54                var XmlDoc = "<fast_menu>" +   
55                                                "<lang1>Online</lang1>" +
56                                                "<lang2>Ausente</lang2>" +
57                                                "<lang3>Ocupado</lang3>" +
58                                                "<lang4>Offline</lang4>" +
59                                                "<lang5>Mensagem</lang5>" +
60                                                "<img1>"+path_im+"templates/default/images/available.gif</img1>" +
61                                                "<img2>"+path_im+"templates/default/images/away.gif</img2>" +
62                                                "<img3>"+path_im+"templates/default/images/dnd.gif</img3>" +
63                                                "<img4>"+path_im+"templates/default/images/unavailable.gif</img4>" +
64                                                "<img5>"+path_im+"templates/default/images/icon_edit.gif</img5>" +                                                                                                                                             
65                                         "</fast_menu>";
66
67                menu_action.menu('fast_menu_im', this.xtools.parse(XmlDoc,'fast_menu.xsl'));
68                document.getElementById('fast_menu_im').style.top = document.getElementById('fast_menu_im').offsetTop + 60;
69                document.getElementById('fast_menu_im').style.left = document.getElementById('fast_menu_im').offsetLeft + 5;
70                document.getElementById('fast_menu_im').style.zIndex = this.zValue++;
71                document.getElementById('fast_menu_im').style.position = "absolute";
72        },
73       
74        "mysettings": function()
75        {
76                var XmlDoc = "<settings>" +
77                                                "<lang1>Opções</lang1>" +
78                                                "<lang2>Exibir amigos desconectados</lang2>" +
79                                                "<lang3>Ausente</lang3>" +
80                                                "<lang4>Ficar ausente depois de</lang4>" +
81                                                "<lang5>minutos</lang5>" +
82                                                "<lang6>Ativar aviso de mensagens recebidas</lang6>" +
83                                                "<lang7>Normal</lang7>" +                                                                                                                                                                                                                                                                                               
84                                                "<lang8>Treme Tela</lang8>" +
85                                                "<lang9>" + im.get_lang("Save") + "</lang9>" +
86                                                "<lang10>" + im.get_lang("Close") + "</lang10> " +
87                                         "</settings>";
88               
89                im_window.load('my_settings_im','instant_messenger_content','<title>.:: ' + im.get_lang("My Settings") + ' ::.</title>','window.xsl','400',true,true,true);
90                im_window.elementC('my_settings_im').innerHTML = this.xtools.parse(XmlDoc,'mysettings.xsl');
91                im.get_preferences();
92        },
93       
94        "options" : function(pEv, pJid)
95        {
96                try
97                {
98                        var pEvent = pEv;
99
100                        if ( pEvent.button > 1 )
101                        {
102                                document.oncontextmenu = new Function("return false");                         
103                                document.onmousedown = new Function("return false");
104
105                                this.options_button_right(pJid);
106       
107                                document.onmousedown = new Function("return true");                                                     
108                        }
109                        else
110                        {
111                                this.options_button_left(pJid);
112                        }
113
114                }catch(e){}
115
116        },
117       
118        "options_button_left" : function(pJid)
119        {
120                var _this = this;
121
122                if(!(im.nickname_contacts[pJid]))
123                        im.request_vcard(pJid,'nickname');
124
125                if(func.byId('img_' + pJid).src != im_unavailable.src )
126                {
127                        im_window.load(pJid, 'instant_messenger_content', '<title>.:: Expresso Messenger ::.</title>', 'chat.xsl','310',true,true,true);
128                        func.byId(pJid + '_avatar').src = path_im + "/templates/default/images/photo.png";
129
130                        var win = im_window.elementC(pJid);
131
132                        var iframe = document.createElement('iframe');
133                        iframe.id = 'iframe_' + pJid;
134                        iframe.style.width = '290px';
135                        iframe.style.height = '46px';
136                        iframe.style.border = '0';
137                        iframe.style.margin = '0';
138                        iframe.style.padding = '0'
139
140                        var _messages_ = win.firstChild.firstChild.nextSibling.nextSibling;
141                        _messages_.appendChild(iframe);
142
143                        iframe.contentWindow.document.write('<html><body id="' + pJid + '" style="margin:0px;padding:0px"></body></html>');
144                        iframe.contentWindow.document.close();
145                        iframe.contentWindow.document.designMode = "On";
146                        iframe.contentWindow.focus();
147
148                        function keypress_handler(e)
149                        {
150                                var evt = e.keyCode;
151                                var pId = ( e.srcElement ) ? e.srcElement.id : e.target.getElementsByTagName('body').item(0).id;
152                                switch ( evt )
153                                {
154                                        case 13 :
155                                                if ( !e.shiftKey )
156                                                        _this.jabber.doIt('sendMessage',{'message' : iframe.contentWindow.document.getElementsByTagName('body').item(0), 'from' : pJid });
157                                                return false;
158                                        break;
159                                        case 27 :
160                                                im_window.window_close(pId);
161                                        break;
162                                        default :
163                                        break;
164                                }
165                        }
166                        function keyup_handler(e)
167                        {
168                                var evt = e.keyCode;
169                                var _text = ( e.srcElement ) ? e.srcElement.id : e.target.getElementsByTagName('body').item(0);
170
171                                switch ( evt )
172                                {
173                                        case 13 :
174                                                if ( !e.shiftKey )
175                                                        _text.innerHTML = '';
176                                                return false;
177                                        break;
178                                        default :
179                                        break;
180                                }
181                        }
182                        var obj = iframe.contentWindow.document;
183
184                        if ( obj.addEventListener )
185                        {
186                                obj.addEventListener('keypress', keypress_handler, false);
187                                obj.addEventListener('keyup', keyup_handler, false);
188                        }
189                        else if ( obj.attachEvent )
190                        {
191                                obj.attachEvent('onkeypress', keypress_handler);
192                                obj.attachEvent('onkeyup', keyup_handler);
193                        }
194                       
195                        im.ldap_photo(pJid + "_avatar");
196                }
197        },
198       
199        "options_button_right" : function( pJid )
200        {
201
202                var XmlDoc = "<options>" +     
203                                                "<lang1>" + im.get_lang("Nickname") + "</lang1>" +
204                                                "<lang2>" + im.get_lang("Group") + "</lang2>" +
205                                                "<lang3>" + im.get_lang("Remove") + "</lang3>" +
206                                                "<lang4>(Re)-requisitar Autorização</lang4>" +
207                                                "<lang5>" + im.get_lang("See Info") + "</lang5>" +
208                                                "<jid>" + pJid + "</jid>" +
209                                                "<path>" + path_im + "</path>" +               
210                                         "</options>";
211                menu_action.menu('sub_' + pJid, this.xtools.parse(XmlDoc,'options.xsl'));
212            func.byId('sub_' + pJid).style.zIndex = '99999';
213                func.byId('sub_' + pJid).style.left = parseInt(func.byId('sub_' + pJid).style.left) - 5;           
214            func.byId('sub_' + pJid).style.position = 'absolute';
215               
216        },
217
218        "preferences": function(pElement)
219        {
220                var XmlDoc = "<preferences>" +
221                                                "<lang1>" + im.get_lang("Add Contact") + "</lang1>" +
222                                                "<function1>templates.add_user();</function1>" +
223                                                "<lang2>" + im.get_lang("Remove Contact") + "</lang2>" +
224                                                "<function2>templates.remove_user();</function2>" +
225                                                "<lang3>" + im.get_lang("Vcard") +"</lang3>" +
226                                                "<function3>im.request_vcard('this','user')</function3>" +
227                                                "<lang4>" + im.get_lang("Preferences") + "</lang4>" +
228                                                "<function4>templates.mysettings()</function4>" +
229                                                "<path>"+ path_im + "</path>" +
230                                         "</preferences>";
231
232                menu_action.menu(pElement, this.xtools.parse(XmlDoc,'preferences.xsl'));
233                document.getElementById(pElement).style.zIndex   = this.zValue++;
234                document.getElementById(pElement).style.position = "absolute";
235        },
236
237        "remove_user": function()
238        {
239                var XmlDoc = "<remove_user>" +
240                                                "<lang1>" + im.get_lang("Contact") + "</lang1>" +
241                                                "<lang2>" + im.get_lang("Remove") +"</lang2>" +
242                                                "<lang3>" + im.get_lang("Close") + "</lang3>" +
243                                         "</remove_user>";
244
245                im_window.load('remove_user_im','instant_messenger_content','<title>.:: Remover Contatos ::.</title>','window.xsl','350',true,true,true);
246                im_window.elementC('remove_user_im').innerHTML = this.xtools.parse(XmlDoc,'remove_user.xsl');
247                im.get_contacts();
248        },
249
250        "smiles": function(pJid)
251        {
252                var Xmlsmiles = "<smiles>" +   
253                                                        "<path>"+path_im+"</path>" +                                                                                                                                                                                                                                                                                                                                           
254                                                        "<pjid>"+pJid+"</pjid>" +
255                                                "</smiles>";
256
257                menu_action.menu(pJid + '_button_dest', this.xtools.parse(Xmlsmiles,'smiles.xsl'));
258                func.byId(pJid + '_button_dest').style.top = func.byId(pJid + '_button_emoticons').offsetTop + 10;
259                func.byId(pJid + '_button_dest').style.left = func.byId(pJid + '_button_emoticons').offsetLeft + 10;
260                func.byId(pJid + '_button_dest').style.zIndex = this.zValue++;
261                func.byId(pJid + '_button_dest').style.position = "absolute";
262        },
263
264        "vcard_contact" : function(pXml)       
265        {
266                var title = "Informações do Contato - Expresso";
267                var XmlDoc = "<vcard_contact>" +
268                                                "<lang1>" + im.get_lang("Full Name") + "</lang1>" +
269                                                "<lang2>" + im.get_lang("Nickname") + "</lang2>" +
270                                                "<lang3>" + im.get_lang("Organization") +"</lang3>" +
271                                                "<lang4>" + im.get_lang("Sector") + "</lang4>" +
272                                                "<lang5>" + im.get_lang("Role") + "</lang5>" +
273                                                "<lang6>" + im.get_lang("Birthday") + "</lang6>" +
274                                                "<lang7>" + im.get_lang("Close") + "</lang7>" +                                                                                                                                 
275                                                this.xtools.parse(pXml,'vcard.xsl') +
276                                                "<id>vcard_contact_im</id>"+
277                                        "</vcard_contact>";
278
279                im_window.load('vcard_contact_im','instant_messenger_content','<title>.:: ' + title +' ::.</title>','window.xsl','390',true,true,true);
280                im_window.elementC('vcard_contact_im').innerHTML = this.xtools.parse(XmlDoc,'vcard_contacts.xsl');
281        },
282
283        "vcard_user" : function(pXml)
284        {
285                var title = "Informações Pessoais - Expresso";
286                var XmlDoc = "<vcard_user>" +   
287                                                "<lang1>" + im.get_lang("Full Name") + "</lang1>" +
288                                                "<lang2>" + im.get_lang("Nickname") + "</lang2>" +
289                                                "<lang3>" + im.get_lang("Organization") + "</lang3>" +
290                                                "<lang4>" + im.get_lang("Sector") + "</lang4>" +
291                                                "<lang5>" + im.get_lang("Role") + "</lang5>" +
292                                                "<lang6>" + im.get_lang("Birthday") + "</lang6>" +
293                                                "<lang7>" + im.get_lang("Save") + "</lang7>" +
294                                                "<lang8>" + im.get_lang("Close") + "</lang8>" +
295                                                this.xtools.parse(pXml,'vcard.xsl') +                                           
296                                                "<id>vcard_user_im</id>"+                                               
297                                         "</vcard_user>";
298                im_window.load('vcard_user_im','instant_messenger_content','<title>.:: ' + title +' ::.</title>','window.xsl','470',true,true,true);
299                im_window.elementC('vcard_user_im').innerHTML = this.xtools.parse(XmlDoc,'vcard_user.xsl');
300        }
301}
302
303var templates = new Templates();
Note: See TracBrowser for help on using the repository browser.