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

Revision 2320, 6.7 KB checked in by alexandrecorreia, 14 years ago (diff)

Ticket #986 - Ajuste de layout, botao adicionar, botao troca de status e imagens.

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