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

Revision 2293, 5.6 KB checked in by alexandrecorreia, 14 years ago (diff)

Ticket #986 - Implementado recebimento das mensagens dentro das janelas.

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