source: sandbox/jabberit_messenger/trophy/js/loadIM.js @ 2325

Revision 2325, 7.5 KB checked in by alexandrecorreia, 14 years ago (diff)

Ticket #986 - Adicionado function ao botao troca de status e criacao de div.

  • Property svn:executable set to *
Line 
1(function()
2{
3        var path                        = "/jmessenger/";
4        var _showhidden         = null;
5        var _xtools                     = null;
6        var zIndex                      = 9001;
7       
8        function configEvents(pObj, pEvent, pHandler)
9        {
10                if ( typeof pObj == 'object' )
11                {
12                        if ( pEvent.substring(0, 2) == 'on' )
13                                pEvent = pEvent.substring(2, pEvent.length);
14
15                        if ( pObj.addEventListener )
16                                pObj.addEventListener(pEvent, pHandler, false);
17                        else if ( pObj.attachEvent )
18                                pObj.attachEvent('on' + pEvent, pHandler);
19                }
20        }
21       
22        function TrophyIMChatArea()
23        {
24                /*
25                var winImChatArea =
26                {
27                         id_window              : "window_chat_area",
28                         width                  : 490,
29                         height                 : 395,
30                         top                    : 100,
31                         left                   : 400,
32                         draggable              : true,
33                         visible                : "display",
34                         resizable              : true,
35                         zindex                 : zIndex++,
36                         title                  : "Mensagens - Expresso Messenger",
37                         closeAction    : "remove",
38                         content                : '<div id="trophyimchat"><div id="trophyimchattabs"/></div>'   
39                };
40               
41                _winBuild( winImChatArea );
42               
43                return '<div id="trophyimchat"><div id="trophyimchattabs"/></div>';
44                */
45        }
46       
47        function TrophyIMChatBox()
48        {
49                var chatBox = '<div>' +
50                                                '<div id="trophyimchattabs"/>' +
51                                                '<div class="trophyimchatbox"/>' +
52                                                        '<form name="chat" onsubmit="TrophyIM.sendMessage(this); return(false);">' +
53                                                                '<textarea class="trophyimchatinput" rows="3" cols="50"></textarea>' +
54                                                                '<input type="button" value="Send" onclick="TrophyIM.sendMessage(this)"/>' +
55                                                        '</form>' +
56                                           '</div>';
57               
58                return chatBox;
59        }
60       
61        function TrophyIMChatTab()
62        {
63        var chatTab     =       '<div class="trophyimchattab" onclick="TrophyIM.tabClick(this);">' +
64                                        '<div class="trophyimchattabjid" />' +
65                                                '<div class="trophyimtabclose" onclick="TrophyIM.tabClose(this);">X</div>' +
66                                        '<div class="trophyimchattabname" />' +
67                                '</div>';
68                return chatTab;
69        }
70       
71        function TrophyIMLoggingDiv()
72        {
73                return '<div id="trophyimlog"/>';
74        }
75       
76        function TrophyIMLoginPage()
77        {
78                setXTools();
79               
80                var winLoginPage =
81                {       
82                         id_window              : "window_login_page",
83                         width                  : 260,
84                         height                 : 150,
85                         top                    : 100,
86                         left                   : 400,
87                         draggable              : true,
88                         visible                : "display",
89                         resizable              : true,
90                         zindex                 : zIndex++,
91                         title                  : "Login - Expresso Messenger",
92                         closeAction    : "remove",
93                         content                : _xtools.parse(_xtools.xml("login_page"), "loginPage.xsl")     
94                };
95
96                _winBuild( winLoginPage );
97        }
98       
99        function TrophyIMRosterDiv()
100        {
101                setXTools();                   
102
103                var winRosterDiv =
104                {
105                         id_window              : "window_Roster_im",
106                         width                  : 250,
107                         height                 : 410,
108                         top                    : 50,
109                         left                   : 50,
110                         draggable              : true,
111                         visible                : "display",
112                         resizable              : true,
113                         zindex                 : zIndex++,
114                         title                  : "Contatos - Expresso Messenger",
115                         closeAction    : "hidden",
116                         content                : _xtools.parse(_xtools.xml("contacts_list"),"contactsList.xsl")       
117                };
118               
119                _winBuild( winRosterDiv );
120        }
121       
122        function TrophyIMRosterGroup()
123        {
124                return '<div class="trophyimrostergroup"><div class="trophyimrosterlabel"/></div>';
125        }
126       
127        function TrophyIMRosterItem()
128        {
129                var rosterItem = '<div class="trophyimrosteritem" onclick="TrophyIM.rosterClick(this)">' +
130                                                '<div class="trophyimrosterjid" />' +
131                                                '<div class="trophyimrostername" />' +
132                                         '</div>';
133       
134        return rosterItem;
135        }
136       
137        function HTMLSnippets( pType )
138        {
139                return new ( function( )
140                {
141                        this.chatArea           = TrophyIMChatArea;
142       
143                        this.chatBox            = TrophyIMChatBox;
144       
145                        this.chatTab            = TrophyIMChatTab;
146                               
147                        this.loggingDiv         = TrophyIMLoggingDiv;
148               
149                        this.loginPage          = TrophyIMLoginPage;
150                               
151                        this.rosterDiv          = TrophyIMRosterDiv;
152                               
153                        this.rosterGroup        = TrophyIMRosterGroup;
154       
155                        this.rosterItem         = TrophyIMRosterItem;
156
157                } );
158        }
159       
160        function getZindex()
161        {
162                return zIndex++;
163        }
164       
165        function parse()
166        {
167                if( arguments.length == 2 )
168                        return _xtools.parse(_xtools.xml(arguments[0]), arguments[1] );
169               
170                if( arguments.length === 3 )
171                        return _xtools.parse(_xtools.xml(arguments[0]), arguments[1], arguments[2] );
172        }
173       
174        function loadScripts(pFiles)
175        {
176                // Load JavaScript
177                var loadJavaScript = function(pJs)
178                {
179                        var newScript = document.createElement("script");
180                                newScript.setAttribute("type", "text/javascript");
181                                newScript.setAttribute("src", pJs );
182                               
183                        return newScript;
184                };
185               
186                // Load CSS
187                var loadStyleSheet = function(pCss)
188                {
189                        var newStyle = document.createElement("link");
190                                newStyle.setAttribute("rel", "stylesheet");
191                                newStyle.setAttribute("type", "text/css");
192                                newStyle.setAttribute("href", pCss);
193                               
194                        return newStyle;
195                };
196               
197                for(var i = 0; i < pFiles.length; i++)
198                {
199                        if( pFiles[i].indexOf(".js") > -1 )
200                                document.getElementsByTagName("head")[0].appendChild(loadJavaScript(pFiles[i]));
201                               
202                        if( pFiles[i].indexOf(".css") > -1 )
203                                document.getElementsByTagName("head")[0].appendChild(loadStyleSheet(pFiles[i]));
204                }
205        }
206
207       
208        function setPresence()
209        {
210                if( arguments.length > 0 )
211                {
212                        var element = arguments[0];
213                       
214                        if( _showhidden == null )
215                                _showhidden = new ShowHidden(300);
216                       
217                        var _status = [
218                                               ['Afastado', 'away', '<img src="images/away.gif" />'],
219                                               ['Disponível', 'available', '<img src="images/available.gif" />'],
220                                               ['Livre p/ Conversa', 'chat', '<img src="images/chat.gif" />'],
221                                               ['Não Disponível', 'xa', '<img src="images/xa.gif" />'],
222                                               ['Ocupado', 'dnd', '<img src="images/dnd.gif" />'],
223                                          ];
224                       
225                        var _itens = "";
226                       
227                        for( var i in _status )
228                        {
229                                _itens += '<span style="cursor:pointer;" onclick="TrophyIM.setPresence(\''+_status[i][1]+'\'); loadIM.setStatusJabber(\''+_status[i][0]+'\',\''+_status[i][1]+'\');">';
230                                _itens += _status[i][2]+ "<span style='margin:3px;'>" + _status[i][0] + "</span></span><br/>";
231                        }
232                       
233                        var _statusItens = document.createElement("div");
234                                _statusItens.setAttribute("style", "margin: 62px 0px 0px 76px;");
235                                _statusItens.className          = "x-menu";
236                                _statusItens.style.zIndex       = '99999';
237                                _statusItens.innerHTML          = _itens; 
238                                                                                 
239                                _showhidden.action('onmouseover', 'onmouseout', _statusItens);
240                               
241                        element.parentNode.onmouseout   = function(){ _showhidden.hiddenObject(false); };
242                        element.parentNode.onmouseover  = function(){ _showhidden.hiddenObject(true); };
243                        element.parentNode.appendChild(_statusItens);
244                }
245        }
246       
247        function setStatusJabber()
248        {
249                if( arguments.length > 0 )
250                {
251                        var _text       = arguments[0];
252                        var _img        = arguments[1];
253                       
254                        document.getElementById('statusJabberImg').setAttribute("style", "background-image: url('images/"+_img+".gif'); margin-left: 13px;width:15px; height:15px;");
255                        document.getElementById('statusJabberText').innerHTML = _text;
256                }       
257        }
258       
259        function setXTools()
260        {
261                if( _xtools == null )
262                        _xtools = new xtools(path);
263        }
264
265        function loadIM()
266        {
267                var files =     [
268                                 'js/xtools.js',
269                                 'js/dragdrop.js',
270                                 'js/makeW.js',
271                                 'js/show_hidden.js',
272                                 'css/trophyim.css',
273                                 'css/window_azul.css'
274                                 //'css/window_cataratas.css'
275                                 //'css/window_celepar.css'
276                                 //'css/window_comics.css'
277                                 //'css/window_default.css'
278                                 //'css/window_escritorio.css'
279                                 //'css/window_metropole.css'
280                                 //'css/window_rochas.css'
281                            ];
282               
283                loadScripts(files);
284               
285        }
286       
287        loadIM.prototype.configEvents           = configEvents;
288        loadIM.prototype.getZIndex                      = getZindex;
289        loadIM.prototype.parse                          = parse;
290        loadIM.prototype.setPresence            = setPresence;
291        loadIM.prototype.setStatusJabber        = setStatusJabber;
292       
293        loadIM.prototype.HTMLSnippets           = new HTMLSnippets;
294        window.loadIM                                           = new loadIM;
295       
296})();
Note: See TracBrowser for help on using the repository browser.